diff --git a/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java b/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java index 1fb7eff087afc..4f939af201f3e 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java @@ -269,8 +269,7 @@ final class InputMethodBindingController { @Override public void onBindingDied(ComponentName name) { synchronized (mMethodMap) { if (mVisibleBound) { - mContext.unbindService(mVisibleConnection); - mVisibleBound = false; + unbindVisibleConnectionLocked(); } } } @@ -368,8 +367,7 @@ final class InputMethodBindingController { @GuardedBy("mMethodMap") void unbindCurrentMethodLocked() { if (mVisibleBound) { - mContext.unbindService(mVisibleConnection); - mVisibleBound = false; + unbindVisibleConnectionLocked(); } if (mHasConnection) { @@ -385,6 +383,13 @@ final class InputMethodBindingController { mService.clearCurMethodLocked(); } + + @GuardedBy("mMethodMap") + void unbindVisibleConnectionLocked() { + mContext.unbindService(mVisibleConnection); + mVisibleBound = false; + } + @GuardedBy("mMethodMap") private boolean bindCurrentInputMethodServiceLocked(ServiceConnection conn, int flags) { if (mCurIntent == null || conn == null) { diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index d3da4751364ce..1dbdc0d538aba 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -313,23 +313,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub private int mMethodMapUpdateCount = 0; /** - * Indicates whether {@link #getVisibleConnection} is currently in use. + * Indicates whether {@link InputMethodBindingController#getVisibleConnection} is currently + * in use. */ private boolean isVisibleBound() { return mBindingController.isVisibleBound(); } - private void setVisibleBound(boolean visibleBound) { - mBindingController.setVisibleBound(visibleBound); - } - - /** - * Used to bring IME service up to visible adjustment while it is being shown. - */ - private ServiceConnection getVisibleConnection() { - return mBindingController.getVisibleConnection(); - } - /** * Used to bind the IME while it is not currently being shown. */ @@ -3254,8 +3244,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub res = false; } if (hasConnection() && isVisibleBound()) { - mContext.unbindService(getVisibleConnection()); - setVisibleBound(false); + mBindingController.unbindVisibleConnectionLocked(); } mInputShown = false; mShowRequested = false;