From 930328ca97bd1ea6e1d56743712fb937492c34b7 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Wed, 18 Oct 2017 20:19:53 -0700 Subject: Annotate threads for some IME handling methods This is a preparation to work on Bug 36897707. For instance, the reason why most of IME-related callbacks in InputMethodService get called on the main thread is because IInputMethodWrapper keeps forwarding incoming IPCs into the main looper of the IME process as follows: InputMethodManagerService (IMMS) ------ -> one-way binder IPCs over IInputMethod ------ -> IInputMethodWrapper (on the binder thread(s)) -> Handler (to dispatch tasks to main thread) -> InputMethodImpl.* (on the main thread) -> InputMethodService.* (on the main thread) By adding explicit annotations such as @BinderThread and @MainThread in relevant methods, this CL makes that kind of investigation much easier than before. Bug: 36897707 Test: compile Change-Id: I8f9afe9a1986a9fa41fb66fdc64e8f0f67e45c2e --- core/java/android/inputmethodservice/InputMethodService.java | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'core/java/android/inputmethodservice/InputMethodService.java') diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java index 96535d950c06..223ed73bb15a 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -384,6 +384,7 @@ public class InputMethodService extends AbstractInputMethodService { /** * {@inheritDoc} */ + @MainThread @Override public void attachToken(IBinder token) { if (mToken == null) { @@ -397,6 +398,7 @@ public class InputMethodService extends AbstractInputMethodService { * *

Calls {@link InputMethodService#onBindInput()} when done.

*/ + @MainThread @Override public void bindInput(InputBinding binding) { mInputBinding = binding; @@ -415,6 +417,7 @@ public class InputMethodService extends AbstractInputMethodService { * *

Calls {@link InputMethodService#onUnbindInput()} when done.

*/ + @MainThread @Override public void unbindInput() { if (DEBUG) Log.v(TAG, "unbindInput(): binding=" + mInputBinding @@ -427,6 +430,7 @@ public class InputMethodService extends AbstractInputMethodService { /** * {@inheritDoc} */ + @MainThread @Override public void startInput(InputConnection ic, EditorInfo attribute) { if (DEBUG) Log.v(TAG, "startInput(): editor=" + attribute); @@ -436,6 +440,7 @@ public class InputMethodService extends AbstractInputMethodService { /** * {@inheritDoc} */ + @MainThread @Override public void restartInput(InputConnection ic, EditorInfo attribute) { if (DEBUG) Log.v(TAG, "restartInput(): editor=" + attribute); @@ -446,6 +451,7 @@ public class InputMethodService extends AbstractInputMethodService { * {@inheritDoc} * @hide */ + @MainThread @Override public void dispatchStartInputWithToken(@Nullable InputConnection inputConnection, @NonNull EditorInfo editorInfo, boolean restarting, @@ -462,6 +468,7 @@ public class InputMethodService extends AbstractInputMethodService { /** * {@inheritDoc} */ + @MainThread @Override public void hideSoftInput(int flags, ResultReceiver resultReceiver) { if (DEBUG) Log.v(TAG, "hideSoftInput()"); @@ -481,6 +488,7 @@ public class InputMethodService extends AbstractInputMethodService { /** * {@inheritDoc} */ + @MainThread @Override public void showSoftInput(int flags, ResultReceiver resultReceiver) { if (DEBUG) Log.v(TAG, "showSoftInput()"); @@ -513,6 +521,7 @@ public class InputMethodService extends AbstractInputMethodService { /** * {@inheritDoc} */ + @MainThread @Override public void changeInputMethodSubtype(InputMethodSubtype subtype) { onCurrentInputMethodSubtypeChanged(subtype); -- cgit v1.2.3