diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index 05aebcc7b0a86..1570fced1102d 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -2687,25 +2687,30 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } if (getCurToken() != null) { - if (DEBUG) { - Slog.v(TAG, "Removing window token: " + getCurToken() + " for display: " - + mCurTokenDisplayId); - } - mWindowManagerInternal.removeWindowToken(getCurToken(), false /* removeWindows */, - false /* animateExit */, mCurTokenDisplayId); - // Set IME window status as invisible when unbind current method. - mImeWindowVis = 0; - mBackDisposition = InputMethodService.BACK_DISPOSITION_DEFAULT; - updateSystemUiLocked(mImeWindowVis, mBackDisposition); - setCurToken(null); - mCurTokenDisplayId = INVALID_DISPLAY; - mCurHostInputToken = null; + removeCurrentTokenLocked(); } setCurId(null); clearCurMethodLocked(); } + @GuardedBy("mMethodMap") + void removeCurrentTokenLocked() { + IBinder token = getCurToken(); + if (DEBUG) { + Slog.v(TAG, "Removing window token: " + token + " for display: " + mCurTokenDisplayId); + } + mWindowManagerInternal.removeWindowToken(token, false /* removeWindows */, + false /* animateExit */, mCurTokenDisplayId); + // Set IME window status as invisible when unbind current method. + mImeWindowVis = 0; + mBackDisposition = InputMethodService.BACK_DISPOSITION_DEFAULT; + updateSystemUiLocked(mImeWindowVis, mBackDisposition); + setCurToken(null); + mCurTokenDisplayId = INVALID_DISPLAY; + mCurHostInputToken = null; + } + @GuardedBy("mMethodMap") void resetCurrentMethodAndClientLocked(@UnbindReason int unbindClientReason) { setSelectedMethodId(null);