From a1a9ae5392be5c4fb99b256428f1f118a37a96e7 Mon Sep 17 00:00:00 2001 From: Nikolas Havrikov Date: Thu, 18 Nov 2021 17:37:44 +0100 Subject: [PATCH] Move clearing current method to controller Bug: 205676419 Test: make Change-Id: I11641791abbc4f24d97e2d371900a912c9b6ba41 --- .../inputmethod/InputMethodBindingController.java | 14 ++++++-------- .../inputmethod/InputMethodManagerService.java | 13 ++----------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java b/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java index efc18f8659587..05e1bdd11db60 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java @@ -231,10 +231,6 @@ final class InputMethodBindingController { return mCurMethod; } - void setCurMethod(@Nullable IInputMethod curMethod) { - mCurMethod = curMethod; - } - /** * If not {@link Process#INVALID_UID}, then the UID of {@link #getCurIntent()}. */ @@ -242,10 +238,6 @@ final class InputMethodBindingController { return mCurMethodUid; } - void setCurMethodUid(int curMethodUid) { - mCurMethodUid = curMethodUid; - } - /** * Indicates whether {@link #getVisibleConnection} is currently in use. */ @@ -369,6 +361,12 @@ final class InputMethodBindingController { mService.clearClientSessionsLocked(); } + @GuardedBy("mMethodMap") + void clearCurMethodLocked() { + mCurMethod = null; + mCurMethodUid = Process.INVALID_UID; + } + @GuardedBy("mMethodMap") private void removeCurrentTokenLocked() { int curTokenDisplayId = mService.getCurTokenDisplayId(); diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index 457dc561ed85a..6bb945c5f0d90 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -606,10 +606,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub return mBindingController.getCurMethod(); } - private void setCurMethod(@Nullable IInputMethod curMethod) { - mBindingController.setCurMethod(curMethod); - } - /** * If not {@link Process#INVALID_UID}, then the UID of {@link #getCurIntent()}. */ @@ -617,10 +613,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub return mBindingController.getCurMethodUid(); } - private void setCurMethodUid(int curMethodUid) { - mBindingController.setCurMethodUid(curMethodUid); - } - /** * Time that we last initiated a bind to the input method, to determine * if we should try to disconnect and reconnect to it. @@ -2598,9 +2590,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub finishSessionLocked(mEnabledSession); mEnabledSession = null; - setCurMethod(null); - setCurMethodUid(Process.INVALID_UID); - scheduleNotifyImeUidToAudioService(getCurMethodUid()); + mBindingController.clearCurMethodLocked(); + scheduleNotifyImeUidToAudioService(Process.INVALID_UID); } hideStatusBarIconLocked(); mInFullscreenMode = false;