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);