Merge "Add "Locked" suffix to IMMS methods"
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java b/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java
index c5dc23e..4c70776 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java
@@ -72,16 +72,16 @@
@NonNull private final WindowManagerInternal mWindowManagerInternal;
@NonNull private final Resources mRes;
- private long mLastBindTime;
- private boolean mHasConnection;
- @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;
+ @GuardedBy("mMethodMap") private long mLastBindTime;
+ @GuardedBy("mMethodMap") private boolean mHasConnection;
+ @GuardedBy("mMethodMap") @Nullable private String mCurId;
+ @GuardedBy("mMethodMap") @Nullable private String mSelectedMethodId;
+ @GuardedBy("mMethodMap") @Nullable private Intent mCurIntent;
+ @GuardedBy("mMethodMap") @Nullable private IInputMethod mCurMethod;
+ @GuardedBy("mMethodMap") private int mCurMethodUid = Process.INVALID_UID;
+ @GuardedBy("mMethodMap") private IBinder mCurToken;
+ @GuardedBy("mMethodMap") private int mCurSeq;
+ @GuardedBy("mMethodMap") private boolean mVisibleBound;
private boolean mSupportsStylusHw;
/**
@@ -146,6 +146,7 @@
* Time that we last initiated a bind to the input method, to determine
* if we should try to disconnect and reconnect to it.
*/
+ @GuardedBy("mMethodMap")
long getLastBindTime() {
return mLastBindTime;
}
@@ -154,6 +155,7 @@
* Set to true if our ServiceConnection is currently actively bound to
* a service (whether or not we have gotten its IBinder back yet).
*/
+ @GuardedBy("mMethodMap")
boolean hasConnection() {
return mHasConnection;
}
@@ -166,6 +168,7 @@
*
* @see #getSelectedMethodId()
*/
+ @GuardedBy("mMethodMap")
@Nullable
String getCurId() {
return mCurId;
@@ -184,11 +187,13 @@
*
* @see #getCurId()
*/
+ @GuardedBy("mMethodMap")
@Nullable
String getSelectedMethodId() {
return mSelectedMethodId;
}
+ @GuardedBy("mMethodMap")
void setSelectedMethodId(@Nullable String selectedMethodId) {
mSelectedMethodId = selectedMethodId;
}
@@ -197,6 +202,7 @@
* The token we have made for the currently active input method, to
* identify it in the future.
*/
+ @GuardedBy("mMethodMap")
IBinder getCurToken() {
return mCurToken;
}
@@ -204,6 +210,7 @@
/**
* The Intent used to connect to the current input method.
*/
+ @GuardedBy("mMethodMap")
@Nullable
Intent getCurIntent() {
return mCurIntent;
@@ -213,6 +220,7 @@
* The current binding sequence number, incremented every time there is
* a new bind performed.
*/
+ @GuardedBy("mMethodMap")
int getSequenceNumber() {
return mCurSeq;
}
@@ -221,6 +229,7 @@
* Increase the current binding sequence number by one.
* Reset to 1 on overflow.
*/
+ @GuardedBy("mMethodMap")
void advanceSequenceNumber() {
mCurSeq += 1;
if (mCurSeq <= 0) {
@@ -232,6 +241,7 @@
* If non-null, this is the input method service we are currently connected
* to.
*/
+ @GuardedBy("mMethodMap")
@Nullable
IInputMethod getCurMethod() {
return mCurMethod;
@@ -240,6 +250,7 @@
/**
* If not {@link Process#INVALID_UID}, then the UID of {@link #getCurIntent()}.
*/
+ @GuardedBy("mMethodMap")
int getCurMethodUid() {
return mCurMethodUid;
}
@@ -247,6 +258,7 @@
/**
* Indicates whether {@link #mVisibleConnection} is currently in use.
*/
+ @GuardedBy("mMethodMap")
boolean isVisibleBound() {
return mVisibleBound;
}
@@ -254,11 +266,12 @@
/**
* Used to bring IME service up to visible adjustment while it is being shown.
*/
+ @GuardedBy("mMethodMap")
private final ServiceConnection mVisibleConnection = new ServiceConnection() {
@Override public void onBindingDied(ComponentName name) {
synchronized (mMethodMap) {
if (mVisibleBound) {
- unbindVisibleConnectionLocked();
+ unbindVisibleConnection();
}
}
}
@@ -273,6 +286,7 @@
/**
* Used to bind the IME while it is not currently being shown.
*/
+ @GuardedBy("mMethodMap")
private final ServiceConnection mMainConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
@@ -280,10 +294,10 @@
synchronized (mMethodMap) {
if (mCurIntent != null && name.equals(mCurIntent.getComponent())) {
mCurMethod = IInputMethod.Stub.asInterface(service);
- updateCurrentMethodUidLocked();
+ updateCurrentMethodUid();
if (mCurToken == null) {
Slog.w(TAG, "Service connected without a token!");
- unbindCurrentMethodLocked();
+ unbindCurrentMethod();
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
return;
}
@@ -305,7 +319,7 @@
}
@GuardedBy("mMethodMap")
- private void updateCurrentMethodUidLocked() {
+ private void updateCurrentMethodUid() {
final String curMethodPackage = mCurIntent.getComponent().getPackageName();
final int curMethodUid = mPackageManagerInternal.getPackageUid(
curMethodPackage, 0 /* flags */, mSettings.getCurrentUserId());
@@ -339,7 +353,7 @@
// We consider this to be a new bind attempt, since the system
// should now try to restart the service for us.
mLastBindTime = SystemClock.uptimeMillis();
- clearCurMethodAndSessionsLocked();
+ clearCurMethodAndSessions();
mService.clearInputShowRequestLocked();
mService.unbindCurrentClientLocked(UnbindReason.DISCONNECT_IME);
}
@@ -348,34 +362,34 @@
};
@GuardedBy("mMethodMap")
- void unbindCurrentMethodLocked() {
+ void unbindCurrentMethod() {
if (mVisibleBound) {
- unbindVisibleConnectionLocked();
+ unbindVisibleConnection();
}
if (mHasConnection) {
- unbindMainConnectionLocked();
+ unbindMainConnection();
}
if (mCurToken != null) {
- removeCurrentTokenLocked();
+ removeCurrentToken();
mService.resetSystemUiLocked();
}
mCurId = null;
- clearCurMethodAndSessionsLocked();
+ clearCurMethodAndSessions();
}
@GuardedBy("mMethodMap")
- private void clearCurMethodAndSessionsLocked() {
+ private void clearCurMethodAndSessions() {
mService.clearClientSessionsLocked();
mCurMethod = null;
mCurMethodUid = Process.INVALID_UID;
}
@GuardedBy("mMethodMap")
- private void removeCurrentTokenLocked() {
- int curTokenDisplayId = mService.getCurTokenDisplayId();
+ private void removeCurrentToken() {
+ int curTokenDisplayId = mService.getCurTokenDisplayIdLocked();
if (DEBUG) {
Slog.v(TAG,
@@ -388,7 +402,7 @@
@GuardedBy("mMethodMap")
@NonNull
- InputBindResult bindCurrentMethodLocked() {
+ InputBindResult bindCurrentMethod() {
InputMethodInfo info = mMethodMap.get(mSelectedMethodId);
if (info == null) {
throw new IllegalArgumentException("Unknown id: " + mSelectedMethodId);
@@ -396,11 +410,11 @@
mCurIntent = createImeBindingIntent(info.getComponent());
- if (bindCurrentInputMethodServiceMainConnectionLocked()) {
+ if (bindCurrentInputMethodServiceMainConnection()) {
mCurId = info.getId();
mLastBindTime = SystemClock.uptimeMillis();
- addFreshWindowTokenLocked();
+ addFreshWindowToken();
return new InputBindResult(
InputBindResult.ResultCode.SUCCESS_WAITING_IME_BINDING,
null, null, mCurId, mCurSeq, false);
@@ -425,11 +439,11 @@
}
@GuardedBy("mMethodMap")
- private void addFreshWindowTokenLocked() {
- int displayIdToShowIme = mService.getDisplayIdToShowIme();
+ private void addFreshWindowToken() {
+ int displayIdToShowIme = mService.getDisplayIdToShowImeLocked();
mCurToken = new Binder();
- mService.setCurTokenDisplayId(displayIdToShowIme);
+ mService.setCurTokenDisplayIdLocked(displayIdToShowIme);
try {
if (DEBUG) {
@@ -445,19 +459,19 @@
}
@GuardedBy("mMethodMap")
- private void unbindMainConnectionLocked() {
+ private void unbindMainConnection() {
mContext.unbindService(mMainConnection);
mHasConnection = false;
}
@GuardedBy("mMethodMap")
- void unbindVisibleConnectionLocked() {
+ void unbindVisibleConnection() {
mContext.unbindService(mVisibleConnection);
mVisibleBound = false;
}
@GuardedBy("mMethodMap")
- private boolean bindCurrentInputMethodServiceLocked(ServiceConnection conn, int flags) {
+ private boolean bindCurrentInputMethodService(ServiceConnection conn, int flags) {
if (mCurIntent == null || conn == null) {
Slog.e(TAG, "--- bind failed: service = " + mCurIntent + ", conn = " + conn);
return false;
@@ -467,15 +481,15 @@
}
@GuardedBy("mMethodMap")
- private boolean bindCurrentInputMethodServiceVisibleConnectionLocked() {
- mVisibleBound = bindCurrentInputMethodServiceLocked(mVisibleConnection,
+ private boolean bindCurrentInputMethodServiceVisibleConnection() {
+ mVisibleBound = bindCurrentInputMethodService(mVisibleConnection,
IME_VISIBLE_BIND_FLAGS);
return mVisibleBound;
}
@GuardedBy("mMethodMap")
- private boolean bindCurrentInputMethodServiceMainConnectionLocked() {
- mHasConnection = bindCurrentInputMethodServiceLocked(mMainConnection,
+ private boolean bindCurrentInputMethodServiceMainConnection() {
+ mHasConnection = bindCurrentInputMethodService(mMainConnection,
mImeConnectionBindFlags);
return mHasConnection;
}
@@ -487,11 +501,11 @@
* Performs a rebind if no binding is achieved in {@link #TIME_TO_RECONNECT} milliseconds.
*/
@GuardedBy("mMethodMap")
- void setCurrentMethodVisibleLocked() {
+ void setCurrentMethodVisible() {
if (mCurMethod != null) {
- if (DEBUG) Slog.d(TAG, "setCurrentMethodVisibleLocked: mCurToken=" + mCurToken);
+ if (DEBUG) Slog.d(TAG, "setCurrentMethodVisible: mCurToken=" + mCurToken);
if (mHasConnection && !mVisibleBound) {
- bindCurrentInputMethodServiceVisibleConnectionLocked();
+ bindCurrentInputMethodServiceVisibleConnection();
}
return;
}
@@ -504,9 +518,9 @@
// to try to prod things along.
EventLog.writeEvent(EventLogTags.IMF_FORCE_RECONNECT_IME, getSelectedMethodId(),
bindingDuration, 1);
- Slog.w(TAG, "Force disconnect/connect to the IME in setCurrentMethodVisibleLocked()");
- unbindMainConnectionLocked();
- bindCurrentInputMethodServiceMainConnectionLocked();
+ Slog.w(TAG, "Force disconnect/connect to the IME in setCurrentMethodVisible()");
+ unbindMainConnection();
+ bindCurrentInputMethodServiceMainConnection();
} else {
if (DEBUG) {
Slog.d(TAG, "Can't show input: connection = " + mHasConnection + ", time = "
@@ -519,9 +533,9 @@
* Remove the binding needed for the IME to be shown.
*/
@GuardedBy("mMethodMap")
- void setCurrentMethodNotVisibleLocked() {
+ void setCurrentMethodNotVisible() {
if (mVisibleBound) {
- unbindVisibleConnectionLocked();
+ unbindVisibleConnection();
}
}
}
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
index 262ab93..34ea86b 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
@@ -310,7 +310,7 @@
* The display id for which the latest startInput was called.
*/
@GuardedBy("mMethodMap")
- int getDisplayIdToShowIme() {
+ int getDisplayIdToShowImeLocked() {
return mDisplayIdToShowIme;
}
@@ -416,17 +416,19 @@
* <p>This can be transiently {@code null} when the system is re-initializing input method
* settings, e.g., the system locale is just changed.</p>
*
- * <p>Note that {@link InputMethodBindingController#getCurId()} is used to track which IME is
- * being connected to {@link InputMethodManagerService}.</p>
+ * <p>Note that {@link InputMethodBindingController#getCurId()} is used to track which IME
+ * is being connected to {@link InputMethodManagerService}.</p>
*
* @see InputMethodBindingController#getCurId()
*/
+ @GuardedBy("mMethodMap")
@Nullable
- private String getSelectedMethodId() {
+ private String getSelectedMethodIdLocked() {
return mBindingController.getSelectedMethodId();
}
- private void setSelectedMethodId(@Nullable String selectedMethodId) {
+ @GuardedBy("mMethodMap")
+ private void setSelectedMethodIdLocked(@Nullable String selectedMethodId) {
mBindingController.setSelectedMethodId(selectedMethodId);
}
@@ -434,7 +436,8 @@
* The current binding sequence number, incremented every time there is
* a new bind performed.
*/
- private int getSequenceNumber() {
+ @GuardedBy("mMethodMap")
+ private int getSequenceNumberLocked() {
return mBindingController.getSequenceNumber();
}
@@ -442,7 +445,8 @@
* Increase the current binding sequence number by one.
* Reset to 1 on overflow.
*/
- private void advanceSequenceNumber() {
+ @GuardedBy("mMethodMap")
+ private void advanceSequenceNumberLocked() {
mBindingController.advanceSequenceNumber();
}
@@ -501,10 +505,11 @@
*
* <p>This can be {@code null} when no input method is connected.</p>
*
- * @see #getSelectedMethodId()
+ * @see #getSelectedMethodIdLocked()
*/
+ @GuardedBy("mMethodMap")
@Nullable
- private String getCurId() {
+ private String getCurIdLocked() {
return mBindingController.getCurId();
}
@@ -522,7 +527,8 @@
* Set to true if our ServiceConnection is currently actively bound to
* a service (whether or not we have gotten its IBinder back yet).
*/
- private boolean hasConnection() {
+ @GuardedBy("mMethodMap")
+ private boolean hasConnectionLocked() {
return mBindingController.hasConnection();
}
@@ -554,8 +560,9 @@
/**
* The Intent used to connect to the current input method.
*/
+ @GuardedBy("mMethodMap")
@Nullable
- private Intent getCurIntent() {
+ private Intent getCurIntentLocked() {
return mBindingController.getCurIntent();
}
@@ -563,22 +570,26 @@
* The token we have made for the currently active input method, to
* identify it in the future.
*/
- private IBinder getCurToken() {
+ @GuardedBy("mMethodMap")
+ private IBinder getCurTokenLocked() {
return mBindingController.getCurToken();
}
/**
* The displayId of current active input method.
*/
- int getCurTokenDisplayId() {
+ @GuardedBy("mMethodMap")
+ int getCurTokenDisplayIdLocked() {
return mCurTokenDisplayId;
}
- void setCurTokenDisplayId(int curTokenDisplayId) {
+ @GuardedBy("mMethodMap")
+ void setCurTokenDisplayIdLocked(int curTokenDisplayId) {
mCurTokenDisplayId = curTokenDisplayId;
}
- int mCurTokenDisplayId = INVALID_DISPLAY;
+ @GuardedBy("mMethodMap")
+ private int mCurTokenDisplayId = INVALID_DISPLAY;
/**
* The host input token of the current active input method.
@@ -599,15 +610,17 @@
* If non-null, this is the input method service we are currently connected
* to.
*/
+ @GuardedBy("mMethodMap")
@Nullable
- private IInputMethod getCurMethod() {
+ private IInputMethod getCurMethodLocked() {
return mBindingController.getCurMethod();
}
/**
- * If not {@link Process#INVALID_UID}, then the UID of {@link #getCurIntent()}.
+ * If not {@link Process#INVALID_UID}, then the UID of {@link #getCurIntentLocked()}.
*/
- private int getCurMethodUid() {
+ @GuardedBy("mMethodMap")
+ private int getCurMethodUidLocked() {
return mBindingController.getCurMethodUid();
}
@@ -615,7 +628,8 @@
* Time that we last initiated a bind to the input method, to determine
* if we should try to disconnect and reconnect to it.
*/
- private long getLastBindTime() {
+ @GuardedBy("mMethodMap")
+ private long getLastBindTimeLocked() {
return mBindingController.getLastBindTime();
}
@@ -658,7 +672,7 @@
* </dd>
* </dl>
* <em>Do not update this value outside of {@link #setImeWindowStatus(IBinder, int, int)} and
- * {@link InputMethodBindingController#unbindCurrentMethodLocked()}.</em>
+ * {@link InputMethodBindingController#unbindCurrentMethod()}.</em>
*/
int mImeWindowVis;
@@ -1654,7 +1668,7 @@
@GuardedBy("mMethodMap")
private void resetDefaultImeLocked(Context context) {
// Do not reset the default (current) IME when it is a 3rd-party IME
- String selectedMethodId = getSelectedMethodId();
+ String selectedMethodId = getSelectedMethodIdLocked();
if (selectedMethodId != null && !mMethodMap.get(selectedMethodId).isSystem()) {
return;
}
@@ -1862,7 +1876,7 @@
if (token == null) {
throw new InvalidParameterException("token must not be null.");
}
- if (token != getCurToken()) {
+ if (token != getCurTokenLocked()) {
Slog.e(TAG, "Ignoring " + Debug.getCaller() + " due to an invalid token."
+ " uid:" + Binder.getCallingUid() + " token:" + token);
return false;
@@ -1957,15 +1971,16 @@
@GuardedBy("mMethodMap")
private void onCreateInlineSuggestionsRequestLocked(@UserIdInt int userId,
InlineSuggestionsRequestInfo requestInfo, IInlineSuggestionsRequestCallback callback) {
- final InputMethodInfo imi = mMethodMap.get(getSelectedMethodId());
+ final InputMethodInfo imi = mMethodMap.get(getSelectedMethodIdLocked());
try {
- IInputMethod curMethod = getCurMethod();
+ IInputMethod curMethod = getCurMethodLocked();
if (userId == mSettings.getCurrentUserId() && imi != null
&& imi.isInlineSuggestionsEnabled() && curMethod != null) {
executeOrSendMessage(curMethod,
mCaller.obtainMessageOOO(MSG_INLINE_SUGGESTIONS_REQUEST, curMethod,
requestInfo, new InlineSuggestionsRequestCallbackDecorator(callback,
- imi.getPackageName(), mCurTokenDisplayId, getCurToken(),
+ imi.getPackageName(), mCurTokenDisplayId,
+ getCurTokenLocked(),
this)));
} else {
callback.onInlineSuggestionsUnsupported();
@@ -2101,7 +2116,7 @@
boolean allowsImplicitlySelectedSubtypes, @UserIdInt int userId) {
if (userId == mSettings.getCurrentUserId()) {
final InputMethodInfo imi;
- String selectedMethodId = getSelectedMethodId();
+ String selectedMethodId = getSelectedMethodIdLocked();
if (imiId == null && selectedMethodId != null) {
imi = mMethodMap.get(selectedMethodId);
} else {
@@ -2194,7 +2209,7 @@
mCurFocusedWindow, 0, null, SoftInputShowHideReason.HIDE_REMOVE_CLIENT);
if (mBoundToMethod) {
mBoundToMethod = false;
- IInputMethod curMethod = getCurMethod();
+ IInputMethod curMethod = getCurMethodLocked();
if (curMethod != null) {
executeOrSendMessage(curMethod, mCaller.obtainMessageO(
MSG_UNBIND_INPUT, curMethod));
@@ -2225,7 +2240,7 @@
+ mCurClient.client.asBinder());
if (mBoundToMethod) {
mBoundToMethod = false;
- IInputMethod curMethod = getCurMethod();
+ IInputMethod curMethod = getCurMethodLocked();
if (curMethod != null) {
executeOrSendMessage(curMethod, mCaller.obtainMessageO(
MSG_UNBIND_INPUT, curMethod));
@@ -2235,7 +2250,8 @@
scheduleSetActiveToClient(mCurClient, false /* active */, false /* fullscreen */,
false /* reportToImeController */);
executeOrSendMessage(mCurClient.client, mCaller.obtainMessageIIO(
- MSG_UNBIND_CLIENT, getSequenceNumber(), unbindClientReason, mCurClient.client));
+ MSG_UNBIND_CLIENT, getSequenceNumberLocked(), unbindClientReason,
+ mCurClient.client));
mCurClient.sessionRequested = false;
mCurClient = null;
@@ -2276,18 +2292,19 @@
@NonNull
InputBindResult attachNewInputLocked(@StartInputReason int startInputReason, boolean initial) {
if (!mBoundToMethod) {
- IInputMethod curMethod = getCurMethod();
+ IInputMethod curMethod = getCurMethodLocked();
executeOrSendMessage(curMethod, mCaller.obtainMessageOO(
MSG_BIND_INPUT, curMethod, mCurClient.binding));
mBoundToMethod = true;
}
final Binder startInputToken = new Binder();
- final StartInputInfo info = new StartInputInfo(mSettings.getCurrentUserId(), getCurToken(),
- mCurTokenDisplayId, getCurId(), startInputReason, !initial,
+ final StartInputInfo info = new StartInputInfo(mSettings.getCurrentUserId(),
+ getCurTokenLocked(),
+ mCurTokenDisplayId, getCurIdLocked(), startInputReason, !initial,
UserHandle.getUserId(mCurClient.uid), mCurClient.selfReportedDisplayId,
mCurFocusedWindow, mCurAttribute, mCurFocusedWindowSoftInputMode,
- getSequenceNumber());
+ getSequenceNumberLocked());
mImeTargetWindowMap.put(startInputToken, mCurFocusedWindow);
mStartInputHistory.addEntry(info);
@@ -2298,7 +2315,7 @@
// INTERACT_ACROSS_USERS(_FULL) permissions, which is actually almost always the case.
if (mSettings.getCurrentUserId() == UserHandle.getUserId(mCurClient.uid)) {
mPackageManagerInternal.grantImplicitAccess(mSettings.getCurrentUserId(),
- null /* intent */, UserHandle.getAppId(getCurMethodUid()), mCurClient.uid,
+ null /* intent */, UserHandle.getAppId(getCurMethodUidLocked()), mCurClient.uid,
true /* direct */);
}
@@ -2312,13 +2329,13 @@
SoftInputShowHideReason.ATTACH_NEW_INPUT);
}
- String curId = getCurId();
+ String curId = getCurIdLocked();
final InputMethodInfo curInputMethodInfo = mMethodMap.get(curId);
final boolean suppressesSpellChecker =
curInputMethodInfo != null && curInputMethodInfo.suppressesSpellChecker();
return new InputBindResult(InputBindResult.ResultCode.SUCCESS_WITH_IME_SESSION,
session.session, (session.channel != null ? session.channel.dup() : null),
- curId, getSequenceNumber(), suppressesSpellChecker);
+ curId, getSequenceNumberLocked(), suppressesSpellChecker);
}
@GuardedBy("mMethodMap")
@@ -2327,7 +2344,7 @@
@NonNull EditorInfo attribute, @StartInputFlags int startInputFlags,
@StartInputReason int startInputReason) {
// If no method is currently selected, do nothing.
- String selectedMethodId = getSelectedMethodId();
+ String selectedMethodId = getSelectedMethodIdLocked();
if (selectedMethodId == null) {
return InputBindResult.NO_IME;
}
@@ -2337,7 +2354,7 @@
// party code.
return new InputBindResult(
InputBindResult.ResultCode.ERROR_SYSTEM_NOT_READY,
- null, null, selectedMethodId, getSequenceNumber(), false);
+ null, null, selectedMethodId, getSequenceNumberLocked(), false);
}
if (!InputMethodUtils.checkIfPackageBelongsToUid(mAppOpsManager, cs.uid,
@@ -2369,7 +2386,7 @@
}
// Bump up the sequence for this client and attach it.
- advanceSequenceNumber();
+ advanceSequenceNumberLocked();
mCurClient = cs;
mCurInputContext = inputContext;
mCurAttribute = attribute;
@@ -2377,7 +2394,7 @@
// 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 (isSelectedMethodBound()) {
+ if (isSelectedMethodBoundLocked()) {
if (cs.curSession != null) {
// Fast case: if we are already connected to the input method,
// then just return it.
@@ -2391,14 +2408,15 @@
}
}
- mBindingController.unbindCurrentMethodLocked();
+ mBindingController.unbindCurrentMethod();
- return mBindingController.bindCurrentMethodLocked();
+ return mBindingController.bindCurrentMethod();
}
- private boolean isSelectedMethodBound() {
- String curId = getCurId();
- return curId != null && curId.equals(getSelectedMethodId())
+ @GuardedBy("mMethodMap")
+ private boolean isSelectedMethodBoundLocked() {
+ String curId = getCurIdLocked();
+ return curId != null && curId.equals(getSelectedMethodIdLocked())
&& mDisplayIdToShowIme == mCurTokenDisplayId;
}
@@ -2417,16 +2435,16 @@
@GuardedBy("mMethodMap")
@Nullable
private InputBindResult tryReuseConnectionLocked(@NonNull ClientState cs) {
- if (hasConnection()) {
- if (getCurMethod() != null) {
+ if (hasConnectionLocked()) {
+ if (getCurMethodLocked() != null) {
// Return to client, and we will get back with it when
// we have had a session made for it.
requestClientSessionLocked(cs);
return new InputBindResult(
InputBindResult.ResultCode.SUCCESS_WAITING_IME_SESSION,
- null, null, getCurId(), getSequenceNumber(), false);
+ null, null, getCurIdLocked(), getSequenceNumberLocked(), false);
} else {
- long bindingDuration = SystemClock.uptimeMillis() - getLastBindTime();
+ long bindingDuration = SystemClock.uptimeMillis() - getLastBindTimeLocked();
if (bindingDuration < TIME_TO_RECONNECT) {
// In this case we have connected to the service, but
// don't yet have its interface. If it hasn't been too
@@ -2437,10 +2455,10 @@
// to see if we can get back in touch with the service.
return new InputBindResult(
InputBindResult.ResultCode.SUCCESS_WAITING_IME_BINDING,
- null, null, getCurId(), getSequenceNumber(), false);
+ null, null, getCurIdLocked(), getSequenceNumberLocked(), false);
} else {
EventLog.writeEvent(EventLogTags.IMF_FORCE_RECONNECT_IME,
- getSelectedMethodId(), bindingDuration, 0);
+ getSelectedMethodIdLocked(), bindingDuration, 0);
}
}
}
@@ -2493,7 +2511,7 @@
channel.dispose();
return;
}
- IInputMethod curMethod = getCurMethod();
+ IInputMethod curMethod = getCurMethodLocked();
if (curMethod != null && method != null
&& curMethod.asBinder() == method.asBinder()) {
if (mCurClient != null) {
@@ -2527,8 +2545,8 @@
@GuardedBy("mMethodMap")
void resetCurrentMethodAndClientLocked(@UnbindReason int unbindClientReason) {
- setSelectedMethodId(null);
- mBindingController.unbindCurrentMethodLocked();
+ setSelectedMethodIdLocked(null);
+ mBindingController.unbindCurrentMethod();
unbindCurrentClientLocked(unbindClientReason);
}
@@ -2546,7 +2564,7 @@
if (DEBUG) Slog.v(TAG, "Creating new session for client " + cs);
InputChannel[] channels = InputChannel.openInputChannelPair(cs.toString());
cs.sessionRequested = true;
- IInputMethod curMethod = getCurMethod();
+ IInputMethod curMethod = getCurMethodLocked();
executeOrSendMessage(curMethod, mCaller.obtainMessageOOO(
MSG_CREATE_SESSION, curMethod, channels[1],
new MethodCallback(this, curMethod, channels[0])));
@@ -2581,7 +2599,7 @@
@GuardedBy("mMethodMap")
void clearClientSessionsLocked() {
- if (getCurMethod() != null) {
+ if (getCurMethodLocked() != null) {
final int numClients = mClients.size();
for (int i = 0; i < numClients; ++i) {
clearClientSessionLocked(mClients.valueAt(i));
@@ -2773,7 +2791,7 @@
// Caution! This method is called in this class. Handle multi-user carefully
@GuardedBy("mMethodMap")
private void updateSystemUiLocked(int vis, int backDisposition) {
- if (getCurToken() == null) {
+ if (getCurTokenLocked() == null) {
return;
}
if (DEBUG) {
@@ -2798,10 +2816,10 @@
// mImeWindowVis should be updated before calling shouldShowImeSwitcherLocked().
final boolean needsToShowImeSwitcher = shouldShowImeSwitcherLocked(vis);
if (mStatusBar != null) {
- mStatusBar.setImeWindowStatus(mCurTokenDisplayId, getCurToken(), vis,
+ mStatusBar.setImeWindowStatus(mCurTokenDisplayId, getCurTokenLocked(), vis,
backDisposition, needsToShowImeSwitcher);
}
- final InputMethodInfo imi = mMethodMap.get(getSelectedMethodId());
+ final InputMethodInfo imi = mMethodMap.get(getSelectedMethodIdLocked());
if (imi != null && needsToShowImeSwitcher) {
// Used to load label
final CharSequence title = mRes.getText(
@@ -2909,7 +2927,7 @@
}
// See if we need to notify a subtype change within the same IME.
- if (id.equals(getSelectedMethodId())) {
+ if (id.equals(getSelectedMethodIdLocked())) {
final int subtypeCount = info.getSubtypeCount();
if (subtypeCount <= 0) {
return;
@@ -2930,7 +2948,7 @@
}
if (newSubtype != oldSubtype) {
setSelectedInputMethodAndSubtypeLocked(info, subtypeId, true);
- IInputMethod curMethod = getCurMethod();
+ IInputMethod curMethod = getCurMethodLocked();
if (curMethod != null) {
try {
updateSystemUiLocked(mImeWindowVis, mBackDisposition);
@@ -2952,7 +2970,7 @@
// mCurMethodId should be updated after setSelectedInputMethodAndSubtypeLocked()
// because mCurMethodId is stored as a history in
// setSelectedInputMethodAndSubtypeLocked().
- setSelectedMethodId(id);
+ setSelectedMethodIdLocked(id);
if (LocalServices.getService(ActivityManagerInternal.class).isSystemReady()) {
Intent intent = new Intent(Intent.ACTION_INPUT_METHOD_CHANGED);
@@ -3045,12 +3063,12 @@
return false;
}
- mBindingController.setCurrentMethodVisibleLocked();
- if (getCurMethod() != null) {
+ mBindingController.setCurrentMethodVisible();
+ if (getCurMethodLocked() != null) {
// create a placeholder token for IMS so that IMS cannot inject windows into client app.
Binder showInputToken = new Binder();
mShowRequestWindowMap.put(showInputToken, windowToken);
- IInputMethod curMethod = getCurMethod();
+ IInputMethod curMethod = getCurMethodLocked();
executeOrSendMessage(curMethod, mCaller.obtainMessageIIOOO(MSG_SHOW_SOFT_INPUT,
getImeShowFlagsLocked(), reason, curMethod, resultReceiver,
showInputToken));
@@ -3125,7 +3143,7 @@
// since Android Eclair. That's why we need to accept IMM#hideSoftInput() even when only
// IMMS#InputShown indicates that the software keyboard is shown.
// TODO: Clean up, IMMS#mInputShown, IMMS#mImeWindowVis and mShowRequested.
- IInputMethod curMethod = getCurMethod();
+ IInputMethod curMethod = getCurMethodLocked();
final boolean shouldHideSoftInput = (curMethod != null) && (mInputShown
|| (mImeWindowVis & InputMethodService.IME_ACTIVE) != 0);
boolean res;
@@ -3142,7 +3160,7 @@
} else {
res = false;
}
- mBindingController.setCurrentMethodNotVisibleLocked();
+ mBindingController.setCurrentMethodNotVisible();
mInputShown = false;
mShowRequested = false;
mShowExplicitlyRequested = false;
@@ -3381,7 +3399,7 @@
// Note that we can trust client's display ID as long as it matches
// to the display ID obtained from the window.
if (cs.selfReportedDisplayId != mCurTokenDisplayId) {
- mBindingController.unbindCurrentMethodLocked();
+ mBindingController.unbindCurrentMethod();
}
}
} else if (isTextEditor && doAutoShow
@@ -3503,10 +3521,10 @@
if (mCurFocusedWindowClient != null && client != null
&& mCurFocusedWindowClient.client.asBinder() == client.asBinder()) {
return true;
- } else if (getCurIntent() != null && InputMethodUtils.checkIfPackageBelongsToUid(
+ } else if (getCurIntentLocked() != null && InputMethodUtils.checkIfPackageBelongsToUid(
mAppOpsManager,
uid,
- getCurIntent().getComponent().getPackageName())) {
+ getCurIntentLocked().getComponent().getPackageName())) {
return true;
}
return false;
@@ -3592,7 +3610,7 @@
if (!calledFromValidUserLocked()) {
return;
}
- executeOrSendMessage(getCurMethod(), mCaller.obtainMessageO(
+ executeOrSendMessage(getCurMethodLocked(), mCaller.obtainMessageO(
MSG_SHOW_IM_SUBTYPE_ENABLER, inputMethodId));
}
}
@@ -3613,7 +3631,7 @@
String targetLastImiId = null;
int subtypeId = NOT_A_SUBTYPE_ID;
if (lastIme != null && lastImi != null) {
- final boolean imiIdIsSame = lastImi.getId().equals(getSelectedMethodId());
+ final boolean imiIdIsSame = lastImi.getId().equals(getSelectedMethodIdLocked());
final int lastSubtypeHash = Integer.parseInt(lastIme.second);
final int currentSubtypeHash = mCurrentSubtype == null ? NOT_A_SUBTYPE_ID
: mCurrentSubtype.hashCode();
@@ -3659,7 +3677,7 @@
if (!TextUtils.isEmpty(targetLastImiId)) {
if (DEBUG) {
Slog.d(TAG, "Switch to: " + lastImi.getId() + ", " + lastIme.second
- + ", from: " + getSelectedMethodId() + ", " + subtypeId);
+ + ", from: " + getSelectedMethodIdLocked() + ", " + subtypeId);
}
setInputMethodWithSubtypeIdLocked(token, targetLastImiId, subtypeId);
return true;
@@ -3676,7 +3694,7 @@
return false;
}
final ImeSubtypeListItem nextSubtype = mSwitchingController.getNextInputMethodLocked(
- onlyCurrentIme, mMethodMap.get(getSelectedMethodId()), mCurrentSubtype);
+ onlyCurrentIme, mMethodMap.get(getSelectedMethodIdLocked()), mCurrentSubtype);
if (nextSubtype == null) {
return false;
}
@@ -3693,7 +3711,7 @@
return false;
}
final ImeSubtypeListItem nextSubtype = mSwitchingController.getNextInputMethodLocked(
- false /* onlyCurrentIme */, mMethodMap.get(getSelectedMethodId()),
+ false /* onlyCurrentIme */, mMethodMap.get(getSelectedMethodIdLocked()),
mCurrentSubtype);
if (nextSubtype == null) {
return false;
@@ -3908,8 +3926,8 @@
private void dumpDebug(ProtoOutputStream proto, long fieldId) {
synchronized (mMethodMap) {
final long token = proto.start(fieldId);
- proto.write(CUR_METHOD_ID, getSelectedMethodId());
- proto.write(CUR_SEQ, getSequenceNumber());
+ proto.write(CUR_METHOD_ID, getSelectedMethodIdLocked());
+ proto.write(CUR_SEQ, getSequenceNumberLocked());
proto.write(CUR_CLIENT, Objects.toString(mCurClient));
proto.write(CUR_FOCUSED_WINDOW_NAME,
mWindowManagerInternal.getWindowName(mCurFocusedWindow));
@@ -3920,17 +3938,17 @@
if (mCurAttribute != null) {
mCurAttribute.dumpDebug(proto, CUR_ATTRIBUTE);
}
- proto.write(CUR_ID, getCurId());
+ proto.write(CUR_ID, getCurIdLocked());
proto.write(SHOW_REQUESTED, mShowRequested);
proto.write(SHOW_EXPLICITLY_REQUESTED, mShowExplicitlyRequested);
proto.write(SHOW_FORCED, mShowForced);
proto.write(INPUT_SHOWN, mInputShown);
proto.write(IN_FULLSCREEN_MODE, mInFullscreenMode);
- proto.write(CUR_TOKEN, Objects.toString(getCurToken()));
+ proto.write(CUR_TOKEN, Objects.toString(getCurTokenLocked()));
proto.write(CUR_TOKEN_DISPLAY_ID, mCurTokenDisplayId);
proto.write(SYSTEM_READY, mSystemReady);
proto.write(LAST_SWITCH_USER_ID, mLastSwitchUserId);
- proto.write(HAVE_CONNECTION, hasConnection());
+ proto.write(HAVE_CONNECTION, hasConnectionLocked());
proto.write(BOUND_TO_METHOD, mBoundToMethod);
proto.write(IS_INTERACTIVE, mIsInteractive);
proto.write(BACK_DISPOSITION, mBackDisposition);
@@ -3948,14 +3966,14 @@
Slog.d(TAG, "Got the notification of a user action.");
}
synchronized (mMethodMap) {
- if (getCurToken() != token) {
+ if (getCurTokenLocked() != token) {
if (DEBUG) {
Slog.d(TAG, "Ignoring the user action notification from IMEs that are no longer"
+ " active.");
}
return;
}
- final InputMethodInfo imi = mMethodMap.get(getSelectedMethodId());
+ final InputMethodInfo imi = mMethodMap.get(getSelectedMethodIdLocked());
if (imi != null) {
mSwitchingController.onUserActionLocked(imi, mCurrentSubtype);
}
@@ -3999,7 +4017,7 @@
"Using null token requires permission "
+ android.Manifest.permission.WRITE_SECURE_SETTINGS);
}
- } else if (getCurToken() != token) {
+ } else if (getCurTokenLocked() != token) {
Slog.w(TAG, "Ignoring setInputMethod of uid " + Binder.getCallingUid()
+ " token: " + token);
return;
@@ -4371,7 +4389,7 @@
boolean reportToImeController = false;
try {
reportToImeController = mPlatformCompat.isChangeEnabledByUid(
- FINISH_INPUT_NO_FALLBACK_CONNECTION, getCurMethodUid());
+ FINISH_INPUT_NO_FALLBACK_CONNECTION, getCurMethodUidLocked());
} catch (RemoteException e) {
}
scheduleSetActiveToClient(mCurClient, mIsInteractive, mInFullscreenMode,
@@ -4675,7 +4693,8 @@
@GuardedBy("mMethodMap")
private void setSelectedInputMethodAndSubtypeLocked(InputMethodInfo imi, int subtypeId,
boolean setSubtypeOnly) {
- mSettings.saveCurrentInputMethodAndSubtypeToHistory(getSelectedMethodId(), mCurrentSubtype);
+ mSettings.saveCurrentInputMethodAndSubtypeToHistory(getSelectedMethodIdLocked(),
+ mCurrentSubtype);
// Set Subtype here
if (imi == null || subtypeId < 0) {
@@ -4734,7 +4753,7 @@
@GuardedBy("mMethodMap")
InputMethodSubtype getCurrentInputMethodSubtypeLocked() {
- String selectedMethodId = getSelectedMethodId();
+ String selectedMethodId = getSelectedMethodIdLocked();
if (selectedMethodId == null) {
return null;
}
@@ -4775,7 +4794,7 @@
@Nullable
String getCurrentMethodId() {
- return getSelectedMethodId();
+ return getSelectedMethodIdLocked();
}
private List<InputMethodInfo> getInputMethodListAsUser(@UserIdInt int userId) {
@@ -4988,11 +5007,11 @@
synchronized (mMethodMap) {
final int uid = Binder.getCallingUid();
- if (getSelectedMethodId() == null) {
+ if (getSelectedMethodIdLocked() == null) {
return null;
}
- if (getCurToken() != token) {
- Slog.e(TAG, "Ignoring createInputContentUriToken mCurToken=" + getCurToken()
+ if (getCurTokenLocked() != token) {
+ Slog.e(TAG, "Ignoring createInputContentUriToken mCurToken=" + getCurTokenLocked()
+ " token=" + token);
return null;
}
@@ -5127,24 +5146,24 @@
p.println(" sessionRequested=" + ci.sessionRequested);
p.println(" curSession=" + ci.curSession);
}
- p.println(" mCurMethodId=" + getSelectedMethodId());
+ p.println(" mCurMethodId=" + getSelectedMethodIdLocked());
client = mCurClient;
- p.println(" mCurClient=" + client + " mCurSeq=" + getSequenceNumber());
+ p.println(" mCurClient=" + client + " mCurSeq=" + getSequenceNumberLocked());
p.println(" mCurPerceptible=" + mCurPerceptible);
p.println(" mCurFocusedWindow=" + mCurFocusedWindow
+ " softInputMode=" +
InputMethodDebug.softInputModeToString(mCurFocusedWindowSoftInputMode)
+ " client=" + mCurFocusedWindowClient);
focusedWindowClient = mCurFocusedWindowClient;
- p.println(" mCurId=" + getCurId() + " mHaveConnection=" + hasConnection()
+ p.println(" mCurId=" + getCurIdLocked() + " mHaveConnection=" + hasConnectionLocked()
+ " mBoundToMethod=" + mBoundToMethod + " mVisibleBound="
+ mBindingController.isVisibleBound());
- p.println(" mCurToken=" + getCurToken());
+ p.println(" mCurToken=" + getCurTokenLocked());
p.println(" mCurTokenDisplayId=" + mCurTokenDisplayId);
p.println(" mCurHostInputToken=" + mCurHostInputToken);
- p.println(" mCurIntent=" + getCurIntent());
- method = getCurMethod();
- p.println(" mCurMethod=" + getCurMethod());
+ p.println(" mCurIntent=" + getCurIntentLocked());
+ method = getCurMethodLocked();
+ p.println(" mCurMethod=" + getCurMethodLocked());
p.println(" mEnabledSession=" + mEnabledSession);
p.println(" mShowRequested=" + mShowRequested
+ " mShowExplicitlyRequested=" + mShowExplicitlyRequested
@@ -5644,7 +5663,7 @@
if (userId == mSettings.getCurrentUserId()) {
hideCurrentInputLocked(mCurFocusedWindow, 0, null,
SoftInputShowHideReason.HIDE_RESET_SHELL_COMMAND);
- mBindingController.unbindCurrentMethodLocked();
+ mBindingController.unbindCurrentMethod();
// Reset the current IME
resetSelectedInputMethodAndSubtypeLocked(null);
// Also reset the settings of the current IME