Merge "Fix lint issues in IMMS"
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
index 8d0114d..794c06f 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
@@ -1,16 +1,17 @@
/*
+ * Copyright (C) 2022 The Android Open Source Project
*
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package com.android.server.inputmethod;
@@ -367,29 +368,29 @@
Future<?> mImeDrawsImeNavBarResLazyInitFuture;
static class SessionState {
- final ClientState client;
- final IInputMethodInvoker method;
+ final ClientState mClient;
+ final IInputMethodInvoker mMethod;
- IInputMethodSession session;
- InputChannel channel;
+ IInputMethodSession mSession;
+ InputChannel mChannel;
@Override
public String toString() {
- return "SessionState{uid " + client.uid + " pid " + client.pid
+ return "SessionState{uid " + mClient.mUid + " pid " + mClient.mPid
+ " method " + Integer.toHexString(
- IInputMethodInvoker.getBinderIdentityHashCode(method))
+ IInputMethodInvoker.getBinderIdentityHashCode(mMethod))
+ " session " + Integer.toHexString(
- System.identityHashCode(session))
- + " channel " + channel
+ System.identityHashCode(mSession))
+ + " channel " + mChannel
+ "}";
}
- SessionState(ClientState _client, IInputMethodInvoker _method,
- IInputMethodSession _session, InputChannel _channel) {
- client = _client;
- method = _method;
- session = _session;
- channel = _channel;
+ SessionState(ClientState client, IInputMethodInvoker method,
+ IInputMethodSession session, InputChannel channel) {
+ mClient = client;
+ mMethod = method;
+ mSession = session;
+ mChannel = channel;
}
}
@@ -405,7 +406,7 @@
@Override
public String toString() {
- return "AccessibilitySessionState{uid " + mClient.uid + " pid " + mClient.pid
+ return "AccessibilitySessionState{uid " + mClient.mUid + " pid " + mClient.mPid
+ " id " + Integer.toHexString(mId)
+ " session " + Integer.toHexString(
System.identityHashCode(mSession))
@@ -436,37 +437,37 @@
}
static final class ClientState {
- final IInputMethodClientInvoker client;
- final IRemoteInputConnection fallbackInputConnection;
- final int uid;
- final int pid;
- final int selfReportedDisplayId;
- final InputBinding binding;
- final ClientDeathRecipient clientDeathRecipient;
+ final IInputMethodClientInvoker mClient;
+ final IRemoteInputConnection mFallbackInputConnection;
+ final int mUid;
+ final int mPid;
+ final int mSelfReportedDisplayId;
+ final InputBinding mBinding;
+ final ClientDeathRecipient mClientDeathRecipient;
- boolean sessionRequested;
+ boolean mSessionRequested;
boolean mSessionRequestedForAccessibility;
- SessionState curSession;
+ SessionState mCurSession;
SparseArray<AccessibilitySessionState> mAccessibilitySessions = new SparseArray<>();
@Override
public String toString() {
return "ClientState{" + Integer.toHexString(
- System.identityHashCode(this)) + " uid=" + uid
- + " pid=" + pid + " displayId=" + selfReportedDisplayId + "}";
+ System.identityHashCode(this)) + " mUid=" + mUid
+ + " mPid=" + mPid + " mSelfReportedDisplayId=" + mSelfReportedDisplayId + "}";
}
- ClientState(IInputMethodClientInvoker _client,
- IRemoteInputConnection _fallbackInputConnection,
- int _uid, int _pid, int _selfReportedDisplayId,
- ClientDeathRecipient _clientDeathRecipient) {
- client = _client;
- fallbackInputConnection = _fallbackInputConnection;
- uid = _uid;
- pid = _pid;
- selfReportedDisplayId = _selfReportedDisplayId;
- binding = new InputBinding(null, fallbackInputConnection.asBinder(), uid, pid);
- clientDeathRecipient = _clientDeathRecipient;
+ ClientState(IInputMethodClientInvoker client,
+ IRemoteInputConnection fallbackInputConnection,
+ int uid, int pid, int selfReportedDisplayId,
+ ClientDeathRecipient clientDeathRecipient) {
+ mClient = client;
+ mFallbackInputConnection = fallbackInputConnection;
+ mUid = uid;
+ mPid = pid;
+ mSelfReportedDisplayId = selfReportedDisplayId;
+ mBinding = new InputBinding(null, mFallbackInputConnection.asBinder(), mUid, mPid);
+ mClientDeathRecipient = clientDeathRecipient;
}
}
@@ -764,7 +765,7 @@
*/
boolean mBoundToAccessibility;
- /**
+ /**
* Currently enabled session.
*/
@GuardedBy("ImfLock.class")
@@ -1009,7 +1010,7 @@
* <p>TODO: Consider to follow what other system services have been doing to manage
* constants (e.g. {@link android.provider.Settings.Global#ACTIVITY_MANAGER_CONSTANTS}).</p>
*/
- private final static int ENTRY_SIZE_FOR_HIGH_RAM_DEVICE = 32;
+ private static final int ENTRY_SIZE_FOR_HIGH_RAM_DEVICE = 32;
/**
* Entry size for non low-RAM devices.
@@ -1017,7 +1018,7 @@
* <p>TODO: Consider to follow what other system services have been doing to manage
* constants (e.g. {@link android.provider.Settings.Global#ACTIVITY_MANAGER_CONSTANTS}).</p>
*/
- private final static int ENTRY_SIZE_FOR_LOW_RAM_DEVICE = 5;
+ private static final int ENTRY_SIZE_FOR_LOW_RAM_DEVICE = 5;
private static int getEntrySize() {
if (ActivityManager.isLowRamDeviceStatic()) {
@@ -1140,7 +1141,7 @@
pw.print(prefix);
pw.println(" softInputMode=" + InputMethodDebug.softInputModeToString(
- entry.mTargetWindowSoftInputMode));
+ entry.mTargetWindowSoftInputMode));
pw.print(prefix);
pw.println(" inputType=0x" + Integer.toHexString(entry.mEditorInfo.inputType)
@@ -1336,7 +1337,7 @@
* rescanning.</p>
*/
@GuardedBy("ImfLock.class")
- final private ArraySet<String> mKnownImePackageNames = new ArraySet<>();
+ private final ArraySet<String> mKnownImePackageNames = new ArraySet<>();
/**
* Packages that are appeared, disappeared, or modified for whatever reason.
@@ -1364,7 +1365,7 @@
}
@GuardedBy("ImfLock.class")
- final void addKnownImePackageNameLocked(@NonNull String packageName) {
+ void addKnownImePackageNameLocked(@NonNull String packageName) {
mKnownImePackageNames.add(packageName);
}
@@ -1387,9 +1388,9 @@
return false;
}
String curInputMethodId = mSettings.getSelectedInputMethod();
- final int N = mMethodList.size();
+ final int numImes = mMethodList.size();
if (curInputMethodId != null) {
- for (int i=0; i<N; i++) {
+ for (int i = 0; i < numImes; i++) {
InputMethodInfo imi = mMethodList.get(i);
if (imi.getId().equals(curInputMethodId)) {
for (String pkg : packages) {
@@ -1491,8 +1492,8 @@
// Otherwise, check if mKnownImePackageNames and mChangedPackages have any intersection.
// TODO: Consider to create a utility method to do the following test. List.retainAll()
// is an option, but it may still do some extra operations that we do not need here.
- final int N = mChangedPackages.size();
- for (int i = 0; i < N; ++i) {
+ final int numPackages = mChangedPackages.size();
+ for (int i = 0; i < numPackages; ++i) {
final String packageName = mChangedPackages.get(i);
if (mKnownImePackageNames.contains(packageName)) {
return true;
@@ -1512,9 +1513,9 @@
InputMethodInfo curIm = null;
String curInputMethodId = mSettings.getSelectedInputMethod();
- final int N = mMethodList.size();
+ final int numImes = mMethodList.size();
if (curInputMethodId != null) {
- for (int i=0; i<N; i++) {
+ for (int i = 0; i < numImes; i++) {
InputMethodInfo imi = mMethodList.get(i);
final String imiId = imi.getId();
if (imiId.equals(curInputMethodId)) {
@@ -1620,6 +1621,10 @@
@GuardedBy("ImfLock.class")
private UserSwitchHandlerTask mUserSwitchHandlerTask;
+ /**
+ * {@link SystemService} used to publish and manage the lifecycle of
+ * {@link InputMethodManagerService}.
+ */
public static final class Lifecycle extends SystemService {
private final InputMethodManagerService mService;
@@ -1853,8 +1858,10 @@
@GuardedBy("ImfLock.class")
private void switchUserOnHandlerLocked(@UserIdInt int newUserId,
IInputMethodClientInvoker clientToBeReset) {
- if (DEBUG) Slog.d(TAG, "Switching user stage 1/3. newUserId=" + newUserId
- + " currentUserId=" + mSettings.getCurrentUserId());
+ if (DEBUG) {
+ Slog.d(TAG, "Switching user stage 1/3. newUserId=" + newUserId
+ + " currentUserId=" + mSettings.getCurrentUserId());
+ }
maybeInitImeNavbarConfigLocked(newUserId);
@@ -1871,8 +1878,10 @@
AdditionalSubtypeUtils.load(mAdditionalSubtypeMap, newUserId);
final String defaultImiId = mSettings.getSelectedInputMethod();
- if (DEBUG) Slog.d(TAG, "Switching user stage 2/3. newUserId=" + newUserId
- + " defaultImiId=" + defaultImiId);
+ if (DEBUG) {
+ Slog.d(TAG, "Switching user stage 2/3. newUserId=" + newUserId
+ + " defaultImiId=" + defaultImiId);
+ }
// For secondary users, the list of enabled IMEs may not have been updated since the
// callbacks to PackageMonitor are ignored for the secondary user. Here, defaultImiId may
@@ -1899,8 +1908,10 @@
mSettings.getEnabledInputMethodListLocked());
}
- if (DEBUG) Slog.d(TAG, "Switching user stage 3/3. newUserId=" + newUserId
- + " selectedIme=" + mSettings.getSelectedInputMethod());
+ if (DEBUG) {
+ Slog.d(TAG, "Switching user stage 3/3. newUserId=" + newUserId
+ + " selectedIme=" + mSettings.getSelectedInputMethod());
+ }
mLastSwitchUserId = newUserId;
@@ -1910,7 +1921,7 @@
// The client is already gone.
return;
}
- cs.client.scheduleStartInputIfNecessary(mInFullscreenMode);
+ cs.mClient.scheduleStartInputIfNecessary(mInFullscreenMode);
}
}
@@ -1934,6 +1945,9 @@
}
}
+ /**
+ * TODO(b/32343335): The entire systemRunning() method needs to be revisited.
+ */
public void systemRunning(StatusBarManagerService statusBar) {
synchronized (ImfLock.class) {
if (DEBUG) {
@@ -2033,7 +2047,7 @@
// by a token.
if (mContext.checkCallingOrSelfPermission(
android.Manifest.permission.INTERACT_ACROSS_USERS_FULL)
- == PackageManager.PERMISSION_GRANTED) {
+ == PackageManager.PERMISSION_GRANTED) {
if (DEBUG) {
Slog.d(TAG, "--- Access granted because the calling process has "
+ "the INTERACT_ACROSS_USERS_FULL permission");
@@ -2270,8 +2284,8 @@
final int numClients = mClients.size();
for (int i = 0; i < numClients; ++i) {
final ClientState state = mClients.valueAt(i);
- if (state.uid == callerUid && state.pid == callerPid
- && state.selfReportedDisplayId == selfReportedDisplayId) {
+ if (state.mUid == callerUid && state.mPid == callerPid
+ && state.mSelfReportedDisplayId == selfReportedDisplayId) {
throw new SecurityException("uid=" + callerUid + "/pid=" + callerPid
+ "/displayId=" + selfReportedDisplayId + " is already registered.");
}
@@ -2303,7 +2317,7 @@
synchronized (ImfLock.class) {
ClientState cs = mClients.remove(client.asBinder());
if (cs != null) {
- client.asBinder().unlinkToDeath(cs.clientDeathRecipient, 0);
+ client.asBinder().unlinkToDeath(cs.mClientDeathRecipient, 0);
clearClientSessionLocked(cs);
clearClientSessionForAccessibilityLocked(cs);
@@ -2342,8 +2356,10 @@
@GuardedBy("ImfLock.class")
void unbindCurrentClientLocked(@UnbindReason int unbindClientReason) {
if (mCurClient != null) {
- if (DEBUG) Slog.v(TAG, "unbindCurrentInputLocked: client="
- + mCurClient.client.asBinder());
+ if (DEBUG) {
+ Slog.v(TAG, "unbindCurrentInputLocked: client="
+ + mCurClient.mClient.asBinder());
+ }
if (mBoundToMethod) {
mBoundToMethod = false;
IInputMethodInvoker curMethod = getCurMethodLocked();
@@ -2356,10 +2372,10 @@
// Since we set active false to current client and set mCurClient to null, let's unbind
// all accessibility too. That means, when input method get disconnected (including
// switching ime), we also unbind accessibility
- mCurClient.client.setActive(false /* active */, false /* fullscreen */,
+ mCurClient.mClient.setActive(false /* active */, false /* fullscreen */,
false /* reportToImeController */);
- mCurClient.client.onUnbindMethod(getSequenceNumberLocked(), unbindClientReason);
- mCurClient.sessionRequested = false;
+ mCurClient.mClient.onUnbindMethod(getSequenceNumberLocked(), unbindClientReason);
+ mCurClient.mSessionRequested = false;
mCurClient.mSessionRequestedForAccessibility = false;
mCurClient = null;
mCurVirtualDisplayToScreenMatrix = null;
@@ -2401,7 +2417,7 @@
@NonNull
InputBindResult attachNewInputLocked(@StartInputReason int startInputReason, boolean initial) {
if (!mBoundToMethod) {
- getCurMethodLocked().bindInput(mCurClient.binding);
+ getCurMethodLocked().bindInput(mCurClient.mBinding);
mBoundToMethod = true;
}
@@ -2410,7 +2426,7 @@
final StartInputInfo info = new StartInputInfo(mSettings.getCurrentUserId(),
getCurTokenLocked(),
mCurTokenDisplayId, getCurIdLocked(), startInputReason, restarting,
- UserHandle.getUserId(mCurClient.uid), mCurClient.selfReportedDisplayId,
+ UserHandle.getUserId(mCurClient.mUid), mCurClient.mSelfReportedDisplayId,
mCurFocusedWindow, mCurEditorInfo, mCurFocusedWindowSoftInputMode,
getSequenceNumberLocked());
mImeTargetWindowMap.put(startInputToken, mCurFocusedWindow);
@@ -2421,17 +2437,17 @@
// same-user scenarios.
// That said ignoring cross-user scenario will never affect IMEs that do not have
// INTERACT_ACROSS_USERS(_FULL) permissions, which is actually almost always the case.
- if (mSettings.getCurrentUserId() == UserHandle.getUserId(mCurClient.uid)) {
+ if (mSettings.getCurrentUserId() == UserHandle.getUserId(mCurClient.mUid)) {
mPackageManagerInternal.grantImplicitAccess(mSettings.getCurrentUserId(),
- null /* intent */, UserHandle.getAppId(getCurMethodUidLocked()), mCurClient.uid,
- true /* direct */);
+ null /* intent */, UserHandle.getAppId(getCurMethodUidLocked()),
+ mCurClient.mUid, true /* direct */);
}
@InputMethodNavButtonFlags
final int navButtonFlags = getInputMethodNavButtonFlagsLocked();
- final SessionState session = mCurClient.curSession;
+ final SessionState session = mCurClient.mCurSession;
setEnabledSessionLocked(session);
- session.method.startInput(startInputToken, mCurInputConnection, mCurEditorInfo, restarting,
+ session.mMethod.startInput(startInputToken, mCurInputConnection, mCurEditorInfo, restarting,
navButtonFlags, mCurImeDispatcher);
if (mShowRequested) {
if (DEBUG) Slog.v(TAG, "Attach new input asks to show input");
@@ -2446,8 +2462,8 @@
final SparseArray<IAccessibilityInputMethodSession> accessibilityInputMethodSessions =
createAccessibilityInputMethodSessions(mCurClient.mAccessibilitySessions);
return new InputBindResult(InputBindResult.ResultCode.SUCCESS_WITH_IME_SESSION,
- session.session, accessibilityInputMethodSessions,
- (session.channel != null ? session.channel.dup() : null),
+ session.mSession, accessibilityInputMethodSessions,
+ (session.mChannel != null ? session.mChannel.dup() : null),
curId, getSequenceNumberLocked(), mCurVirtualDisplayToScreenMatrix,
suppressesSpellChecker);
}
@@ -2470,10 +2486,10 @@
} else {
matrix.postConcat(info.mMatrix);
}
- if (info.mParentClient.selfReportedDisplayId == imeDisplayId) {
+ if (info.mParentClient.mSelfReportedDisplayId == imeDisplayId) {
return matrix;
}
- displayId = info.mParentClient.selfReportedDisplayId;
+ displayId = info.mParentClient.mSelfReportedDisplayId;
}
}
@@ -2541,16 +2557,16 @@
null, null, null, selectedMethodId, getSequenceNumberLocked(), null, false);
}
- if (!InputMethodUtils.checkIfPackageBelongsToUid(mAppOpsManager, cs.uid,
+ if (!InputMethodUtils.checkIfPackageBelongsToUid(mAppOpsManager, cs.mUid,
editorInfo.packageName)) {
Slog.e(TAG, "Rejecting this client as it reported an invalid package name."
- + " uid=" + cs.uid + " package=" + editorInfo.packageName);
+ + " uid=" + cs.mUid + " package=" + editorInfo.packageName);
return InputBindResult.INVALID_PACKAGE_NAME;
}
// Compute the final shown display ID with validated cs.selfReportedDisplayId for this
// session & other conditions.
- mDisplayIdToShowIme = computeImeDisplayIdForTarget(cs.selfReportedDisplayId,
+ mDisplayIdToShowIme = computeImeDisplayIdForTarget(cs.mSelfReportedDisplayId,
mImeDisplayValidator);
if (mDisplayIdToShowIme == INVALID_DISPLAY) {
@@ -2572,7 +2588,7 @@
mCurRemoteAccessibilityInputConnection = remoteAccessibilityInputConnection;
mCurImeDispatcher = imeDispatcher;
mCurVirtualDisplayToScreenMatrix =
- getVirtualDisplayToScreenMatrixLocked(cs.selfReportedDisplayId,
+ getVirtualDisplayToScreenMatrixLocked(cs.mSelfReportedDisplayId,
mDisplayIdToShowIme);
mCurEditorInfo = editorInfo;
@@ -2591,7 +2607,7 @@
// We expect the caller has already verified that the client is allowed to access this
// display ID.
if (isSelectedMethodBoundLocked()) {
- if (cs.curSession != null) {
+ if (cs.mCurSession != null) {
// Fast case: if we are already connected to the input method,
// then just return it.
// This doesn't mean a11y sessions are there. When a11y service is
@@ -2667,7 +2683,7 @@
unbindCurrentClientLocked(UnbindReason.SWITCH_CLIENT);
// If the screen is on, inform the new client it is active
if (mIsInteractive) {
- cs.client.setActive(true /* active */, false /* fullscreen */,
+ cs.mClient.setActive(true /* active */, false /* fullscreen */,
false /* reportToImeController */);
}
}
@@ -2779,13 +2795,13 @@
&& curMethod.asBinder() == method.asBinder()) {
if (mCurClient != null) {
clearClientSessionLocked(mCurClient);
- mCurClient.curSession = new SessionState(mCurClient,
+ mCurClient.mCurSession = new SessionState(mCurClient,
method, session, channel);
InputBindResult res = attachNewInputLocked(
StartInputReason.SESSION_CREATED_BY_IME, true);
attachNewAccessibilityLocked(StartInputReason.SESSION_CREATED_BY_IME, true);
if (res.method != null) {
- mCurClient.client.onBindMethod(res);
+ mCurClient.mClient.onBindMethod(res);
}
return;
}
@@ -2828,7 +2844,7 @@
@GuardedBy("ImfLock.class")
void requestClientSessionLocked(ClientState cs) {
- if (!cs.sessionRequested) {
+ if (!cs.mSessionRequested) {
if (DEBUG) Slog.v(TAG, "Creating new session for client " + cs);
final InputChannel serverChannel;
final InputChannel clientChannel;
@@ -2838,7 +2854,7 @@
clientChannel = channels[1];
}
- cs.sessionRequested = true;
+ cs.mSessionRequested = true;
final IInputMethodInvoker curMethod = getCurMethodLocked();
final IInputMethodSessionCallback.Stub callback =
@@ -2881,9 +2897,9 @@
@GuardedBy("ImfLock.class")
void clearClientSessionLocked(ClientState cs) {
- finishSessionLocked(cs.curSession);
- cs.curSession = null;
- cs.sessionRequested = false;
+ finishSessionLocked(cs.mCurSession);
+ cs.mCurSession = null;
+ cs.mSessionRequested = false;
}
@GuardedBy("ImfLock.class")
@@ -2907,18 +2923,18 @@
@GuardedBy("ImfLock.class")
private void finishSessionLocked(SessionState sessionState) {
if (sessionState != null) {
- if (sessionState.session != null) {
+ if (sessionState.mSession != null) {
try {
- sessionState.session.finishSession();
+ sessionState.mSession.finishSession();
} catch (RemoteException e) {
Slog.w(TAG, "Session failed to close due to remote exception", e);
updateSystemUiLocked(0 /* vis */, mBackDisposition);
}
- sessionState.session = null;
+ sessionState.mSession = null;
}
- if (sessionState.channel != null) {
- sessionState.channel.dispose();
- sessionState.channel = null;
+ if (sessionState.mChannel != null) {
+ sessionState.mChannel.dispose();
+ sessionState.mChannel = null;
}
}
}
@@ -3017,7 +3033,7 @@
InputMethodService.IME_ACTIVE | InputMethodService.IME_VISIBLE);
return (canImeDrawsImeNavBar ? InputMethodNavButtonFlags.IME_DRAWS_IME_NAV_BAR : 0)
| (shouldShowImeSwitcherWhenImeIsShown
- ? InputMethodNavButtonFlags.SHOW_IME_SWITCHER_WHEN_IME_IS_SHOWN : 0);
+ ? InputMethodNavButtonFlags.SHOW_IME_SWITCHER_WHEN_IME_IS_SHOWN : 0);
}
@GuardedBy("ImfLock.class")
@@ -3040,17 +3056,17 @@
return false;
}
- List<InputMethodInfo> imis = mSettings.getEnabledInputMethodListWithFilterLocked(
+ List<InputMethodInfo> imes = mSettings.getEnabledInputMethodListWithFilterLocked(
InputMethodInfo::shouldShowInInputMethodPicker);
- final int N = imis.size();
- if (N > 2) return true;
- if (N < 1) return false;
+ final int numImes = imes.size();
+ if (numImes > 2) return true;
+ if (numImes < 1) return false;
int nonAuxCount = 0;
int auxCount = 0;
InputMethodSubtype nonAuxSubtype = null;
InputMethodSubtype auxSubtype = null;
- for(int i = 0; i < N; ++i) {
- final InputMethodInfo imi = imis.get(i);
+ for (int i = 0; i < numImes; ++i) {
+ final InputMethodInfo imi = imes.get(i);
final List<InputMethodSubtype> subtypes =
mSettings.getEnabledInputMethodSubtypeListLocked(mContext, imi, true);
final int subtypeCount = subtypes.size();
@@ -3074,8 +3090,8 @@
} else if (nonAuxCount == 1 && auxCount == 1) {
if (nonAuxSubtype != null && auxSubtype != null
&& (nonAuxSubtype.getLocale().equals(auxSubtype.getLocale())
- || auxSubtype.overridesImplicitlyEnabledSubtype()
- || nonAuxSubtype.overridesImplicitlyEnabledSubtype())
+ || auxSubtype.overridesImplicitlyEnabledSubtype()
+ || nonAuxSubtype.overridesImplicitlyEnabledSubtype())
&& nonAuxSubtype.containsExtraValueKey(TAG_TRY_SUPPRESSING_IME_SWITCHER)) {
return false;
}
@@ -3231,7 +3247,7 @@
void updateInputMethodsFromSettingsLocked(boolean enabledMayChange) {
if (enabledMayChange) {
List<InputMethodInfo> enabled = mSettings.getEnabledInputMethodListLocked();
- for (int i=0; i<enabled.size(); i++) {
+ for (int i = 0; i < enabled.size(); i++) {
// We allow the user to select "disabled until used" apps, so if they
// are enabling one of those here we now need to make it enabled.
InputMethodInfo imm = enabled.get(i);
@@ -3437,10 +3453,10 @@
return false;
}
- if ((flags&InputMethodManager.SHOW_FORCED) != 0) {
+ if ((flags & InputMethodManager.SHOW_FORCED) != 0) {
mShowExplicitlyRequested = true;
mShowForced = true;
- } else if ((flags&InputMethodManager.SHOW_IMPLICIT) == 0) {
+ } else if ((flags & InputMethodManager.SHOW_IMPLICIT) == 0) {
mShowExplicitlyRequested = true;
}
@@ -3496,12 +3512,12 @@
@GuardedBy("ImfLock.class")
boolean hideCurrentInputLocked(IBinder windowToken, int flags, ResultReceiver resultReceiver,
@SoftInputShowHideReason int reason) {
- if ((flags&InputMethodManager.HIDE_IMPLICIT_ONLY) != 0
+ if ((flags & InputMethodManager.HIDE_IMPLICIT_ONLY) != 0
&& (mShowExplicitlyRequested || mShowForced)) {
if (DEBUG) Slog.v(TAG, "Not hiding: explicit show not cancelled by non-explicit hide");
return false;
}
- if (mShowForced && (flags&InputMethodManager.HIDE_NOT_ALWAYS) != 0) {
+ if (mShowForced && (flags & InputMethodManager.HIDE_NOT_ALWAYS) != 0) {
if (DEBUG) Slog.v(TAG, "Not hiding: forced show not cancelled by not-always hide");
return false;
}
@@ -3548,7 +3564,7 @@
private boolean isImeClientFocused(IBinder windowToken, ClientState cs) {
final int imeClientFocus = mWindowManagerInternal.hasInputMethodClientFocus(
- windowToken, cs.uid, cs.pid, cs.selfReportedDisplayId);
+ windowToken, cs.mUid, cs.mPid, cs.mSelfReportedDisplayId);
return imeClientFocus == WindowManagerInternal.ImeClientFocusResult.HAS_IME_FOCUS;
}
@@ -3663,7 +3679,7 @@
}
final int imeClientFocus = mWindowManagerInternal.hasInputMethodClientFocus(
- windowToken, cs.uid, cs.pid, cs.selfReportedDisplayId);
+ windowToken, cs.mUid, cs.mPid, cs.mSelfReportedDisplayId);
switch (imeClientFocus) {
case WindowManagerInternal.ImeClientFocusResult.DISPLAY_ID_MISMATCH:
Slog.e(TAG, "startInputOrWindowGainedFocusInternal: display ID mismatch.");
@@ -3675,8 +3691,8 @@
// next client receiving focus that has any interest in input will
// be calling through here after that change happens.
if (DEBUG) {
- Slog.w(TAG, "Focus gain on non-focused client " + cs.client
- + " (uid=" + cs.uid + " pid=" + cs.pid + ")");
+ Slog.w(TAG, "Focus gain on non-focused client " + cs.mClient
+ + " (uid=" + cs.mUid + " pid=" + cs.mPid + ")");
}
return InputBindResult.NOT_IME_TARGET_WINDOW;
case WindowManagerInternal.ImeClientFocusResult.INVALID_DISPLAY_ID:
@@ -3687,19 +3703,19 @@
// There is already an on-going pending user switch task.
final int nextUserId = mUserSwitchHandlerTask.mToUserId;
if (userId == nextUserId) {
- scheduleSwitchUserTaskLocked(userId, cs.client);
+ scheduleSwitchUserTaskLocked(userId, cs.mClient);
return InputBindResult.USER_SWITCHING;
}
for (int profileId : mUserManager.getProfileIdsWithDisabled(nextUserId)) {
if (profileId == userId) {
- scheduleSwitchUserTaskLocked(userId, cs.client);
+ scheduleSwitchUserTaskLocked(userId, cs.mClient);
return InputBindResult.USER_SWITCHING;
}
}
return InputBindResult.INVALID_USER;
}
- final boolean shouldClearFlag = mImePlatformCompatUtils.shouldClearShowForcedFlag(cs.uid);
+ final boolean shouldClearFlag = mImePlatformCompatUtils.shouldClearShowForcedFlag(cs.mUid);
// In case mShowForced flag affects the next client to keep IME visible, when the current
// client is leaving due to the next focused client, we clear mShowForced flag when the
// next client's targetSdkVersion is T or higher.
@@ -3719,7 +3735,7 @@
}
if (userId != mSettings.getCurrentUserId()) {
- scheduleSwitchUserTaskLocked(userId, cs.client);
+ scheduleSwitchUserTaskLocked(userId, cs.mClient);
return InputBindResult.USER_SWITCHING;
}
@@ -3760,7 +3776,7 @@
final boolean doAutoShow =
(softInputMode & LayoutParams.SOFT_INPUT_MASK_ADJUST)
== LayoutParams.SOFT_INPUT_ADJUST_RESIZE
- || mRes.getConfiguration().isLayoutSizeAtLeast(
+ || mRes.getConfiguration().isLayoutSizeAtLeast(
Configuration.SCREENLAYOUT_SIZE_LARGE);
// We want to start input before showing the IME, but after closing
@@ -3803,7 +3819,7 @@
// window token removed.
// 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) {
+ if (cs.mSelfReportedDisplayId != mCurTokenDisplayId) {
mBindingController.unbindCurrentMethod();
}
}
@@ -3918,7 +3934,7 @@
private boolean canInteractWithImeLocked(
int uid, IInputMethodClient client, String methodName) {
if (mCurClient == null || client == null
- || mCurClient.client.asBinder() != client.asBinder()) {
+ || mCurClient.mClient.asBinder() != client.asBinder()) {
// We need to check if this is the current client with
// focus in the window manager, to allow this call to
// be made before input is started in it.
@@ -3951,7 +3967,7 @@
private boolean canShowInputMethodPickerLocked(IInputMethodClient client) {
final int uid = Binder.getCallingUid();
if (mCurFocusedWindowClient != null && client != null
- && mCurFocusedWindowClient.client.asBinder() == client.asBinder()) {
+ && mCurFocusedWindowClient.mClient.asBinder() == client.asBinder()) {
return true;
}
if (mSettings.getCurrentUserId() != UserHandle.getUserId(uid)) {
@@ -3979,7 +3995,7 @@
// Always call subtype picker, because subtype picker is a superset of input method
// picker.
final int displayId =
- (mCurClient != null) ? mCurClient.selfReportedDisplayId : DEFAULT_DISPLAY;
+ (mCurClient != null) ? mCurClient.mSelfReportedDisplayId : DEFAULT_DISPLAY;
mHandler.obtainMessage(MSG_SHOW_IM_SUBTYPE_PICKER, auxiliarySubtypeMode, displayId)
.sendToTarget();
}
@@ -4078,11 +4094,11 @@
// the most applicable enabled keyboard subtype of the system imes.
final List<InputMethodInfo> enabled = mSettings.getEnabledInputMethodListLocked();
if (enabled != null) {
- final int N = enabled.size();
+ final int enabledCount = enabled.size();
final String locale = mCurrentSubtype == null
? mRes.getConfiguration().locale.toString()
: mCurrentSubtype.getLocale();
- for (int i = 0; i < N; ++i) {
+ for (int i = 0; i < enabledCount; ++i) {
final InputMethodInfo imi = enabled.get(i);
if (imi.getSubtypeCount() > 0 && imi.isSystem()) {
InputMethodSubtype keyboardSubtype =
@@ -4093,7 +4109,7 @@
targetLastImiId = imi.getId();
subtypeId = SubtypeUtils.getSubtypeIdFromHashCode(imi,
keyboardSubtype.hashCode());
- if(keyboardSubtype.getLocale().equals(locale)) {
+ if (keyboardSubtype.getLocale().equals(locale)) {
break;
}
}
@@ -4230,8 +4246,9 @@
* {@link InputMethodManager#getInputMethodWindowVisibleHeight()} and a dependency in
* {@link InputMethodService#onCreate()}.
*
- * <p>TODO(Bug 113914148): Check if we can remove this.</p>
* @return {@link WindowManagerInternal#getInputMethodWindowVisibleHeight(int)}
+ *
+ * @deprecated TODO(b/113914148): Check if we can remove this
*/
@Override
@Deprecated
@@ -4305,7 +4322,7 @@
+ " is already registered by " + info.mParentClient);
}
if (info == null) {
- if (!mWindowManagerInternal.isUidAllowedOnDisplay(childDisplayId, cs.uid)) {
+ if (!mWindowManagerInternal.isUidAllowedOnDisplay(childDisplayId, cs.mUid)) {
throw new SecurityException(cs + " cannot access to display #"
+ childDisplayId);
}
@@ -4314,12 +4331,12 @@
}
info.mMatrix.setValues(matrixValues);
- if (mCurClient == null || mCurClient.curSession == null) {
+ if (mCurClient == null || mCurClient.mCurSession == null) {
return;
}
Matrix matrix = null;
- int displayId = mCurClient.selfReportedDisplayId;
+ int displayId = mCurClient.mSelfReportedDisplayId;
boolean needToNotify = false;
while (true) {
needToNotify |= (displayId == childDisplayId);
@@ -4332,16 +4349,16 @@
} else {
matrix.postConcat(next.mMatrix);
}
- if (next.mParentClient.selfReportedDisplayId == mCurTokenDisplayId) {
+ if (next.mParentClient.mSelfReportedDisplayId == mCurTokenDisplayId) {
if (needToNotify) {
final float[] values = new float[9];
matrix.getValues(values);
- mCurClient.client.updateVirtualDisplayToScreenMatrix(
+ mCurClient.mClient.updateVirtualDisplayToScreenMatrix(
getSequenceNumberLocked(), values);
}
break;
}
- displayId = info.mParentClient.selfReportedDisplayId;
+ displayId = info.mParentClient.mSelfReportedDisplayId;
}
}
} catch (Throwable t) {
@@ -4493,7 +4510,7 @@
/**
* Starting point for dumping the IME tracing information in proto format.
*
- * @param clientProtoDump dump information from the IME client side
+ * @param protoDump dump information from the IME client side
*/
@BinderThread
@Override
@@ -4558,7 +4575,7 @@
}
for (ClientState state : clients.values()) {
if (state != null) {
- state.client.setImeTraceEnabled(true /* enabled */);
+ state.mClient.setImeTraceEnabled(true /* enabled */);
}
}
}
@@ -4573,7 +4590,7 @@
}
for (ClientState state : clients.values()) {
if (state != null) {
- state.client.setImeTraceEnabled(false /* enabled */);
+ state.mClient.setImeTraceEnabled(false /* enabled */);
}
}
}
@@ -4652,7 +4669,7 @@
// actual IME target.
mWindowManagerInternal.hideIme(
mHideRequestWindowMap.get(windowToken),
- mCurClient.selfReportedDisplayId);
+ mCurClient.mSelfReportedDisplayId);
}
} else {
// Send to window manager to show IME after IME layout finishes.
@@ -4683,7 +4700,7 @@
!= PackageManager.PERMISSION_GRANTED) {
throw new SecurityException(
"Using null token requires permission "
- + android.Manifest.permission.WRITE_SECURE_SETTINGS);
+ + android.Manifest.permission.WRITE_SECURE_SETTINGS);
}
} else if (getCurTokenLocked() != token) {
Slog.w(TAG, "Ignoring setInputMethod of uid " + Binder.getCallingUid()
@@ -4751,14 +4768,14 @@
@GuardedBy("ImfLock.class")
void setEnabledSessionLocked(SessionState session) {
if (mEnabledSession != session) {
- if (mEnabledSession != null && mEnabledSession.session != null) {
+ if (mEnabledSession != null && mEnabledSession.mSession != null) {
if (DEBUG) Slog.v(TAG, "Disabling: " + mEnabledSession);
- mEnabledSession.method.setSessionEnabled(mEnabledSession.session, false);
+ mEnabledSession.mMethod.setSessionEnabled(mEnabledSession.mSession, false);
}
mEnabledSession = session;
- if (mEnabledSession != null && mEnabledSession.session != null) {
+ if (mEnabledSession != null && mEnabledSession.mSession != null) {
if (DEBUG) Slog.v(TAG, "Enabling: " + mEnabledSession);
- mEnabledSession.method.setSessionEnabled(mEnabledSession.session, true);
+ mEnabledSession.mMethod.setSessionEnabled(mEnabledSession.mSession, true);
}
}
}
@@ -4837,9 +4854,9 @@
case MSG_REMOVE_IME_SURFACE: {
synchronized (ImfLock.class) {
try {
- if (mEnabledSession != null && mEnabledSession.session != null
+ if (mEnabledSession != null && mEnabledSession.mSession != null
&& !mShowRequested) {
- mEnabledSession.session.removeImeSurface();
+ mEnabledSession.mSession.removeImeSurface();
}
} catch (RemoteException e) {
}
@@ -4851,8 +4868,8 @@
synchronized (ImfLock.class) {
try {
if (windowToken == mCurFocusedWindow
- && mEnabledSession != null && mEnabledSession.session != null) {
- mEnabledSession.session.removeImeSurface();
+ && mEnabledSession != null && mEnabledSession.mSession != null) {
+ mEnabledSession.mSession.removeImeSurface();
}
} catch (RemoteException e) {
}
@@ -4962,8 +4979,8 @@
updateSystemUiLocked(interactive ? mImeWindowVis : 0, mBackDisposition);
// Inform the current client of the change in active status
- if (mCurClient != null && mCurClient.client != null) {
- mCurClient.client.setActive(mIsInteractive, mInFullscreenMode,
+ if (mCurClient != null && mCurClient.mClient != null) {
+ mCurClient.mClient.setActive(mIsInteractive, mInFullscreenMode,
mImePlatformCompatUtils.shouldFinishInputWithReportToIme(
getCurMethodUidLocked()));
}
@@ -5073,8 +5090,8 @@
mContext.getPackageManager().queryIntentServicesAsUser(
new Intent(InputMethod.SERVICE_INTERFACE),
PackageManager.MATCH_DISABLED_COMPONENTS, mSettings.getCurrentUserId());
- final int N = allInputMethodServices.size();
- for (int i = 0; i < N; ++i) {
+ final int numImes = allInputMethodServices.size();
+ for (int i = 0; i < numImes; ++i) {
final ServiceInfo si = allInputMethodServices.get(i).serviceInfo;
if (android.Manifest.permission.BIND_INPUT_METHOD.equals(si.permission)) {
mMyPackageMonitor.addKnownImePackageNameLocked(si.packageName);
@@ -5088,8 +5105,8 @@
boolean enabledImeFound = false;
boolean enabledNonAuxImeFound = false;
final List<InputMethodInfo> enabledImes = mSettings.getEnabledInputMethodListLocked();
- final int N = enabledImes.size();
- for (int i = 0; i < N; ++i) {
+ final int numImes = enabledImes.size();
+ for (int i = 0; i < numImes; ++i) {
final InputMethodInfo imi = enabledImes.get(i);
if (mMethodList.contains(imi)) {
enabledImeFound = true;
@@ -5117,8 +5134,8 @@
final ArrayList<InputMethodInfo> defaultEnabledIme =
InputMethodInfoUtils.getDefaultEnabledImes(mContext, mMethodList,
reenableMinimumNonAuxSystemImes);
- final int N = defaultEnabledIme.size();
- for (int i = 0; i < N; ++i) {
+ final int numImes = defaultEnabledIme.size();
+ for (int i = 0; i < numImes; ++i) {
final InputMethodInfo imi = defaultEnabledIme.get(i);
if (DEBUG) {
Slog.d(TAG, "--- enable ime = " + imi);
@@ -5360,7 +5377,7 @@
if (userId == mSettings.getCurrentUserId()) {
if (!mMethodMap.containsKey(imeId)
|| !mSettings.getEnabledInputMethodListLocked()
- .contains(mMethodMap.get(imeId))) {
+ .contains(mMethodMap.get(imeId))) {
return false; // IME is not found or not enabled.
}
setInputMethodLocked(imeId, NOT_A_SUBTYPE_ID);
@@ -5371,8 +5388,7 @@
mContext.getResources(), mContext.getContentResolver(), methodMap,
userId, false);
if (!methodMap.containsKey(imeId)
- || !settings.getEnabledInputMethodListLocked()
- .contains(methodMap.get(imeId))) {
+ || !settings.getEnabledInputMethodListLocked().contains(methodMap.get(imeId))) {
return false; // IME is not found or not enabled.
}
settings.putSelectedInputMethod(imeId);
@@ -5528,18 +5544,18 @@
attachNewAccessibilityLocked(StartInputReason.SESSION_CREATED_BY_ACCESSIBILITY,
true);
- final SessionState sessionState = mCurClient.curSession;
+ final SessionState sessionState = mCurClient.mCurSession;
final IInputMethodSession imeSession = sessionState == null
- ? null : sessionState.session;
+ ? null : sessionState.mSession;
final SparseArray<IAccessibilityInputMethodSession>
accessibilityInputMethodSessions =
- createAccessibilityInputMethodSessions(
- mCurClient.mAccessibilitySessions);
+ createAccessibilityInputMethodSessions(
+ mCurClient.mAccessibilitySessions);
final InputBindResult res = new InputBindResult(
InputBindResult.ResultCode.SUCCESS_WITH_ACCESSIBILITY_SESSION,
imeSession, accessibilityInputMethodSessions, null, getCurIdLocked(),
getSequenceNumberLocked(), mCurVirtualDisplayToScreenMatrix, false);
- mCurClient.client.onBindAccessibilityService(res, accessibilityConnectionId);
+ mCurClient.mClient.onBindAccessibilityService(res, accessibilityConnectionId);
}
}
}
@@ -5550,11 +5566,11 @@
if (mCurClient != null) {
if (DEBUG) {
Slog.v(TAG, "unbindAccessibilityFromCurrentClientLocked: client="
- + mCurClient.client.asBinder());
+ + mCurClient.mClient.asBinder());
}
// A11yManagerService unbinds the disabled accessibility service. We don't need
// to do it here.
- mCurClient.client.onUnbindAccessibilityService(getSequenceNumberLocked(),
+ mCurClient.mClient.onUnbindAccessibilityService(getSequenceNumberLocked(),
accessibilityConnectionId);
}
// We only have sessions when we bound to an input method. Remove this session
@@ -5620,7 +5636,7 @@
// This user ID can never bee spoofed.
final int imeUserId = UserHandle.getUserId(uid);
// This user ID can never bee spoofed.
- final int appUserId = UserHandle.getUserId(mCurClient.uid);
+ final int appUserId = UserHandle.getUserId(mCurClient.mUid);
// This user ID may be invalid if "contentUri" embedded an invalid user ID.
final int contentUriOwnerUserId = ContentProvider.getUserIdFromUri(contentUri,
imeUserId);
@@ -5642,9 +5658,9 @@
if (!calledWithValidTokenLocked(token)) {
return;
}
- if (mCurClient != null && mCurClient.client != null) {
+ if (mCurClient != null && mCurClient.mClient != null) {
mInFullscreenMode = fullscreen;
- mCurClient.client.reportFullscreenMode(fullscreen);
+ mCurClient.mClient.reportFullscreenMode(fullscreen);
}
}
}
@@ -5722,9 +5738,9 @@
synchronized (ImfLock.class) {
p.println("Current Input Method Manager state:");
- int N = mMethodList.size();
+ int numImes = mMethodList.size();
p.println(" Input Methods: mMethodMapUpdateCount=" + mMethodMapUpdateCount);
- for (int i=0; i<N; i++) {
+ for (int i = 0; i < numImes; i++) {
InputMethodInfo info = mMethodList.get(i);
p.println(" InputMethod #" + i + ":");
info.dump(p, " ");
@@ -5734,20 +5750,20 @@
for (int i = 0; i < numClients; ++i) {
final ClientState ci = mClients.valueAt(i);
p.println(" Client " + ci + ":");
- p.println(" client=" + ci.client);
- p.println(" fallbackInputConnection=" + ci.fallbackInputConnection);
- p.println(" sessionRequested=" + ci.sessionRequested);
+ p.println(" client=" + ci.mClient);
+ p.println(" fallbackInputConnection=" + ci.mFallbackInputConnection);
+ p.println(" sessionRequested=" + ci.mSessionRequested);
p.println(" sessionRequestedForAccessibility="
+ ci.mSessionRequestedForAccessibility);
- p.println(" curSession=" + ci.curSession);
+ p.println(" curSession=" + ci.mCurSession);
}
p.println(" mCurMethodId=" + getSelectedMethodIdLocked());
client = mCurClient;
p.println(" mCurClient=" + client + " mCurSeq=" + getSequenceNumberLocked());
p.println(" mCurPerceptible=" + mCurPerceptible);
p.println(" mCurFocusedWindow=" + mCurFocusedWindow
- + " softInputMode=" +
- InputMethodDebug.softInputModeToString(mCurFocusedWindowSoftInputMode)
+ + " softInputMode="
+ + InputMethodDebug.softInputModeToString(mCurFocusedWindowSoftInputMode)
+ " client=" + mCurFocusedWindowClient);
focusedWindowClient = mCurFocusedWindowClient;
p.println(" mCurId=" + getCurIdLocked() + " mHaveConnection=" + hasConnectionLocked()
@@ -5791,7 +5807,7 @@
if (client != null) {
pw.flush();
try {
- TransferPipe.dumpAsync(client.client.asBinder(), fd, args);
+ TransferPipe.dumpAsync(client.mClient.asBinder(), fd, args);
} catch (IOException | RemoteException e) {
p.println("Failed to dump input method client: " + e);
}
@@ -5807,7 +5823,7 @@
p.println(" ");
pw.flush();
try {
- TransferPipe.dumpAsync(focusedWindowClient.client.asBinder(), fd, args);
+ TransferPipe.dumpAsync(focusedWindowClient.mClient.asBinder(), fd, args);
} catch (IOException | RemoteException e) {
p.println("Failed to dump input method client in focused window: " + e);
}
@@ -6359,7 +6375,7 @@
}
for (ClientState state : clients.values()) {
if (state != null) {
- state.client.setImeTraceEnabled(isImeTraceEnabled);
+ state.mClient.setImeTraceEnabled(isImeTraceEnabled);
}
}
return ShellCommandResult.SUCCESS;