From 9bc49a5abbd45a185ceaf53d8b064a72f9a6d45e Mon Sep 17 00:00:00 2001 From: Nikolas Havrikov Date: Tue, 9 Nov 2021 12:39:54 +0100 Subject: [PATCH] Extract isSelectedMethodBound method Bug: 205676419 Test: make Change-Id: I0b08f54ee46422980ce8738c12c02cfe6ba29ad8 --- .../server/inputmethod/InputMethodManagerService.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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