diff --git a/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java b/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java index 94cd448c1b4dd..10fcb23b071ad 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java @@ -257,7 +257,7 @@ final class InputMethodBindingController { updateCurrentMethodUidLocked(); if (mCurToken == null) { Slog.w(TAG, "Service connected without a token!"); - mService.unbindCurrentMethodLocked(); + unbindCurrentMethodLocked(); Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); return; } @@ -322,4 +322,23 @@ final class InputMethodBindingController { } }; + @GuardedBy("mMethodMap") + void unbindCurrentMethodLocked() { + if (mVisibleBound) { + mContext.unbindService(mVisibleConnection); + mVisibleBound = false; + } + + if (mHasConnection) { + mContext.unbindService(mNonVisibleConnection); + mHasConnection = false; + } + + if (mCurToken != null) { + mService.removeCurrentTokenLocked(); + } + + mCurId = null; + mService.clearCurMethodLocked(); + } } diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index 1570fced1102d..ad78ccd6ab387 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -761,7 +761,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub * * * Do not update this value outside of {@link #setImeWindowStatus(IBinder, int, int)} and - * {@link #unbindCurrentMethodLocked()}. + * {@link InputMethodBindingController#unbindCurrentMethodLocked()}. */ int mImeWindowVis; @@ -2506,7 +2506,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub throw new IllegalArgumentException("Unknown id: " + getSelectedMethodId()); } - unbindCurrentMethodLocked(); + mBindingController.unbindCurrentMethodLocked(); Intent intent = createImeBindingIntent(info.getComponent()); setCurIntent(intent); @@ -2674,26 +2674,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub channel.dispose(); } - @GuardedBy("mMethodMap") - void unbindCurrentMethodLocked() { - if (isVisibleBound()) { - mContext.unbindService(getVisibleConnection()); - setVisibleBound(false); - } - - if (hasConnection()) { - mContext.unbindService(getMainConnection()); - setHasConnection(false); - } - - if (getCurToken() != null) { - removeCurrentTokenLocked(); - } - - setCurId(null); - clearCurMethodLocked(); - } - @GuardedBy("mMethodMap") void removeCurrentTokenLocked() { IBinder token = getCurToken(); @@ -2714,7 +2694,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub @GuardedBy("mMethodMap") void resetCurrentMethodAndClientLocked(@UnbindReason int unbindClientReason) { setSelectedMethodId(null); - unbindCurrentMethodLocked(); + mBindingController.unbindCurrentMethodLocked(); unbindCurrentClientLocked(unbindClientReason); } @@ -3583,7 +3563,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub // Note that we can trust client's display ID as long as it matches // to the display ID obtained from the window. if (cs.selfReportedDisplayId != mCurTokenDisplayId) { - unbindCurrentMethodLocked(); + mBindingController.unbindCurrentMethodLocked(); } } } else if (isTextEditor && doAutoShow @@ -5801,7 +5781,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub if (userId == mSettings.getCurrentUserId()) { hideCurrentInputLocked(mCurFocusedWindow, 0, null, SoftInputShowHideReason.HIDE_RESET_SHELL_COMMAND); - unbindCurrentMethodLocked(); + mBindingController.unbindCurrentMethodLocked(); // Reset the current IME resetSelectedInputMethodAndSubtypeLocked(null); // Also reset the settings of the current IME