From bf82be54a84f7323be61e172f190990cd2b1e164 Mon Sep 17 00:00:00 2001 From: Nikolas Havrikov Date: Mon, 15 Nov 2021 19:03:52 +0100 Subject: [PATCH] Reduce binding controller coupling to IMMS This CL extracts direct interactions with accessor methods Bug: 205676419 Test: make Change-Id: If31a2ed79eea0113030ff7f0e2f14195ab57054a --- .../InputMethodBindingController.java | 12 ++---- .../InputMethodManagerService.java | 38 +++++++------------ 2 files changed, 17 insertions(+), 33 deletions(-) diff --git a/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java b/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java index f438d944c73af..755c093498c0f 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java @@ -49,7 +49,6 @@ import com.android.internal.annotations.GuardedBy; import com.android.internal.inputmethod.InputBindResult; import com.android.internal.inputmethod.UnbindReason; import com.android.internal.view.IInputMethod; -import com.android.server.inputmethod.InputMethodManagerService.ClientState; import com.android.server.wm.WindowManagerInternal; /** @@ -302,11 +301,7 @@ final class InputMethodBindingController { mMethodMap.get(mSelectedMethodId).getConfigChanges(), mCurMethod, mCurToken)); mService.scheduleNotifyImeUidToAudioService(mCurMethodUid); - ClientState curClient = mService.getCurClient(); - if (curClient != null) { - mService.clearClientSessionLocked(curClient); - mService.requestClientSessionLocked(curClient); - } + mService.reRequestCurrentClientSessionLocked(); } } Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); @@ -344,12 +339,11 @@ final class InputMethodBindingController { } if (mCurMethod != null && mCurIntent != null && name.equals(mCurIntent.getComponent())) { - mService.clearCurMethodLocked(); // We consider this to be a new bind attempt, since the system // should now try to restart the service for us. mLastBindTime = SystemClock.uptimeMillis(); - mService.setShowRequested(mService.isInputShown()); - mService.setInputShown(false); + mService.clearCurMethodLocked(); + mService.clearInputShowRequestLocked(); mService.unbindCurrentClientLocked(UnbindReason.DISCONNECT_IME); } } diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index b9b0501796405..e9c2edb36c2f7 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -455,14 +455,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub */ boolean mImeHiddenByDisplayPolicy; - ClientState getCurClient() { - return mCurClient; - } - - void setCurClient(ClientState curClient) { - mCurClient = curClient; - } - /** * The client that is currently bound to an input method. */ @@ -536,14 +528,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub return mBindingController.hasConnection(); } - boolean isShowRequested() { - return mShowRequested; - } - - void setShowRequested(boolean showRequested) { - mShowRequested = showRequested; - } - /** * Set if the client has asked for the input method to be shown. */ @@ -559,14 +543,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub */ boolean mShowForced; - boolean isInputShown() { - return mInputShown; - } - - void setInputShown(boolean inputShown) { - mInputShown = inputShown; - } - /** * Set if we last told the input method to show itself. */ @@ -2278,6 +2254,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } + @GuardedBy("mMethodMap") + void clearInputShowRequestLocked() { + mShowRequested = mInputShown; + mInputShown = false; + } + @GuardedBy("mMethodMap") private int getImeShowFlagsLocked() { int flags = 0; @@ -2561,6 +2543,14 @@ public class InputMethodManagerService extends IInputMethodManager.Stub unbindCurrentClientLocked(unbindClientReason); } + @GuardedBy("mMethodMap") + void reRequestCurrentClientSessionLocked() { + if (mCurClient != null) { + clearClientSessionLocked(mCurClient); + requestClientSessionLocked(mCurClient); + } + } + @GuardedBy("mMethodMap") void requestClientSessionLocked(ClientState cs) { if (!cs.sessionRequested) {