diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index 962952a4b4a87..f3d799183b95a 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -2459,8 +2459,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub // Check if the input method is changing. // We expect the caller has already verified that the client is allowed to access this // display ID. - if (getCurId() != null && getCurId().equals(getSelectedMethodId()) - && displayIdToShowIme == mCurTokenDisplayId) { + if (isSelectedMethodBound(displayIdToShowIme)) { if (cs.curSession != null) { // Fast case: if we are already connected to the input method, // then just return it. @@ -2495,6 +2494,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub return InputBindResult.IME_NOT_CONNECTED; } + private boolean isSelectedMethodBound(int displayIdToShowIme) { + String curId = getCurId(); + return curId != null && curId.equals(getSelectedMethodId()) + && displayIdToShowIme == mCurTokenDisplayId; + } + @GuardedBy("mMethodMap") private void prepareClientSwitchLocked(ClientState cs) { // If the client is changing, we need to switch over to the new