From e82e9f729727c835accf9727939959a6e20dde7f Mon Sep 17 00:00:00 2001 From: Nikolas Havrikov Date: Thu, 11 Nov 2021 10:54:41 +0100 Subject: [PATCH] Move more encapsulated IMMS members Bug: 205676419 Test: make Change-Id: I005761b1b1aa909c2abe726999be138e3a667510 --- .../InputMethodBindingController.java | 29 +++++++++++++++++++ .../InputMethodManagerService.java | 14 +++------ 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java b/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java index f8eb3e2ef1886..8b586ccb5f695 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java @@ -23,9 +23,12 @@ import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.os.IBinder; +import android.os.Process; import android.util.ArrayMap; import android.view.inputmethod.InputMethodInfo; +import com.android.internal.view.IInputMethod; + /** * A controller managing the state of the input method binding. */ @@ -42,6 +45,8 @@ final class InputMethodBindingController { @Nullable private String mCurId; @Nullable private String mSelectedMethodId; @Nullable private Intent mCurIntent; + @Nullable private IInputMethod mCurMethod; + private int mCurMethodUid = Process.INVALID_UID; private IBinder mCurToken; private int mCurSeq; private boolean mVisibleBound; @@ -159,6 +164,30 @@ final class InputMethodBindingController { } } + /** + * If non-null, this is the input method service we are currently connected + * to. + */ + @Nullable + IInputMethod getCurMethod() { + return mCurMethod; + } + + void setCurMethod(@Nullable IInputMethod curMethod) { + mCurMethod = curMethod; + } + + /** + * If not {@link Process#INVALID_UID}, then the UID of {@link #getCurIntent()}. + */ + int getCurMethodUid() { + return mCurMethodUid; + } + + void setCurMethodUid(int curMethodUid) { + mCurMethodUid = curMethodUid; + } + /** * Indicates whether {@link #getVisibleConnection} is currently in use. */ diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index cac69791770c6..9f56c7655779b 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -661,30 +661,24 @@ public class InputMethodManagerService extends IInputMethodManager.Stub */ @Nullable private IInputMethod getCurMethod() { - return mCurMethod; + return mBindingController.getCurMethod(); } private void setCurMethod(@Nullable IInputMethod curMethod) { - mCurMethod = curMethod; + mBindingController.setCurMethod(curMethod); } - @Nullable - private IInputMethod mCurMethod; - - /** * If not {@link Process#INVALID_UID}, then the UID of {@link #getCurIntent()}. */ private int getCurMethodUid() { - return mCurMethodUid; + return mBindingController.getCurMethodUid(); } private void setCurMethodUid(int curMethodUid) { - mCurMethodUid = curMethodUid; + mBindingController.setCurMethodUid(curMethodUid); } - private int mCurMethodUid = Process.INVALID_UID; - /** * Time that we last initiated a bind to the input method, to determine * if we should try to disconnect and reconnect to it.