From 81fa0e6b61d664994ff650d5a3d42eca7c1b5188 Mon Sep 17 00:00:00 2001 From: Nikolas Havrikov Date: Thu, 11 Nov 2021 14:16:35 +0100 Subject: [PATCH] Extract removing current window token Bug: 205676419 Test: make Change-Id: Ie6ba42d3b2ca86e2f0270bf8190632ec09d5b1da --- .../InputMethodManagerService.java | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) 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);