From 017011469631ecfb8734d7a38b48232f8703e5e1 Mon Sep 17 00:00:00 2001 From: Nikolas Havrikov Date: Fri, 5 Nov 2021 14:08:14 +0100 Subject: [PATCH] Extract part of the client switch logic Bug: 205676419 Test: make Change-Id: If387b0f0d007ca468f3a038693ca2014d8e671d6 --- .../InputMethodManagerService.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index ec7975c9b6192..3b95738f5c42c 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -2447,14 +2447,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub mImeHiddenByDisplayPolicy = false; if (mCurClient != cs) { - // If the client is changing, we need to switch over to the new - // one. - unbindCurrentClientLocked(UnbindReason.SWITCH_CLIENT); - // If the screen is on, inform the new client it is active - if (mIsInteractive) { - scheduleSetActiveToClient(cs, true /* active */, false /* fullscreen */, - false /* reportToImeController */); - } + prepareClientSwitchLocked(cs); } // Bump up the sequence for this client and attach it. @@ -2523,6 +2516,18 @@ public class InputMethodManagerService extends IInputMethodManager.Stub return InputBindResult.IME_NOT_CONNECTED; } + @GuardedBy("mMethodMap") + private void prepareClientSwitchLocked(ClientState cs) { + // If the client is changing, we need to switch over to the new + // one. + unbindCurrentClientLocked(UnbindReason.SWITCH_CLIENT); + // If the screen is on, inform the new client it is active + if (mIsInteractive) { + scheduleSetActiveToClient(cs, true /* active */, false /* fullscreen */, + false /* reportToImeController */); + } + } + @NonNull private Intent createImeBindingIntent(ComponentName component) { Intent intent = new Intent(InputMethod.SERVICE_INTERFACE);