From dd333ffc23c8f8a400c2b60e15f7d355a3864a29 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Fri, 21 Jan 2022 07:41:14 -0800 Subject: [PATCH] Remove IMMS#MSG_INITIALIZE_IME This CL inlines InputMethodManagerService#MSG_INITIALIZE_IME handler as it has always been executed from the calling thread. There should be no observable behavior change. Bug: 215609403 Test: presubmit Change-Id: If2806df9cef00cbe7612085b6afa7800f5d9d930 --- .../InputMethodBindingController.java | 4 +-- .../InputMethodManagerService.java | 34 +++++++------------ 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java b/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java index db13deba1972b..784d058c4a4b1 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java @@ -309,8 +309,8 @@ final class InputMethodBindingController { if (DEBUG) Slog.v(TAG, "Initiating attach with token: " + mCurToken); final InputMethodInfo info = mMethodMap.get(mSelectedMethodId); mSupportsStylusHw = info.supportsStylusHandwriting(); - mService.executeOrSendInitializeIme(mCurMethod, mCurToken, - info.getConfigChanges(), mSupportsStylusHw); + mService.initializeImeLocked(mCurMethod, mCurToken, info.getConfigChanges(), + mSupportsStylusHw); mService.scheduleNotifyImeUidToAudioService(mCurMethodUid); mService.reRequestCurrentClientSessionLocked(); } diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index d0b379996c119..3e1f41dd8fc0f 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -222,7 +222,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub private static final int MSG_SHOW_IM_CONFIG = 3; private static final int MSG_HIDE_CURRENT_INPUT_METHOD = 1035; - private static final int MSG_INITIALIZE_IME = 1040; private static final int MSG_CREATE_SESSION = 1050; private static final int MSG_REMOVE_IME_SURFACE = 1060; private static final int MSG_REMOVE_IME_SURFACE_FROM_WINDOW = 1061; @@ -2519,11 +2518,19 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } - @AnyThread - void executeOrSendInitializeIme(@NonNull IInputMethod inputMethod, @NonNull IBinder token, + @GuardedBy("ImfLock.class") + void initializeImeLocked(@NonNull IInputMethod inputMethod, @NonNull IBinder token, @android.content.pm.ActivityInfo.Config int configChanges, boolean supportStylusHw) { - executeOrSendMessage(inputMethod, mCaller.obtainMessageIOOO(MSG_INITIALIZE_IME, - configChanges, inputMethod, token, supportStylusHw)); + if (DEBUG) { + Slog.v(TAG, "Sending attach of token: " + token + " for display: " + + mCurTokenDisplayId); + } + try { + inputMethod.initializeInternal(token, + new InputMethodPrivilegedOperationsImpl(this, token), configChanges, + supportStylusHw); + } catch (RemoteException e) { + } } @AnyThread @@ -4248,23 +4255,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } return true; - case MSG_INITIALIZE_IME: - args = (SomeArgs)msg.obj; - try { - if (DEBUG) { - synchronized (ImfLock.class) { - Slog.v(TAG, "Sending attach of token: " + args.arg2 + " for display: " - + mCurTokenDisplayId); - } - } - final IBinder token = (IBinder) args.arg2; - ((IInputMethod) args.arg1).initializeInternal(token, - new InputMethodPrivilegedOperationsImpl(this, token), - msg.arg1, (boolean) args.arg3); - } catch (RemoteException e) { - } - args.recycle(); - return true; case MSG_CREATE_SESSION: { args = (SomeArgs)msg.obj; IInputMethod method = (IInputMethod)args.arg1;