Remove unused InputMethodSettings#mCopyOnWrite
Now that
InputMethodSettings#mCopyOnWrite
has no side effect thus can be safely removed.
Bug: 309837937
Test: presubmit
Change-Id: I915c7a997f2c413f3bf98f4712029fd0ce83cd52
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
index 8789066f..c4d94ee 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
@@ -1619,7 +1619,7 @@
if (userId != currentUserId) {
return;
}
- mSettings.switchCurrentUser(currentUserId, !mSystemReady);
+ mSettings.switchCurrentUser(currentUserId);
if (mSystemReady) {
// We need to rebuild IMEs.
buildInputMethodListLocked(false /* resetDefaultEnabledIme */);
@@ -1693,7 +1693,7 @@
mLastSwitchUserId = userId;
// mSettings should be created before buildInputMethodListLocked
- mSettings = new InputMethodSettings(mMethodMap, userId, !mSystemReady);
+ mSettings = new InputMethodSettings(mMethodMap, userId);
AdditionalSubtypeUtils.load(mAdditionalSubtypeMap, userId);
mSwitchingController =
@@ -1811,7 +1811,7 @@
// copy-on-write settings.
final boolean useCopyOnWriteSettings =
!mSystemReady || !mUserManagerInternal.isUserUnlockingOrUnlocked(newUserId);
- mSettings.switchCurrentUser(newUserId, useCopyOnWriteSettings);
+ mSettings.switchCurrentUser(newUserId);
// Additional subtypes should be reset when the user is changed
AdditionalSubtypeUtils.load(mAdditionalSubtypeMap, newUserId);
final String defaultImiId = mSettings.getSelectedInputMethod();
@@ -1873,8 +1873,7 @@
if (!mSystemReady) {
mSystemReady = true;
final int currentUserId = mSettings.getCurrentUserId();
- mSettings.switchCurrentUser(currentUserId,
- !mUserManagerInternal.isUserUnlockingOrUnlocked(currentUserId));
+ mSettings.switchCurrentUser(currentUserId);
mStatusBarManagerInternal =
LocalServices.getService(StatusBarManagerInternal.class);
hideStatusBarIconLocked();
@@ -2023,7 +2022,7 @@
//TODO(b/197848765): This can be optimized by caching multi-user methodMaps/methodList.
//TODO(b/210039666): use cache.
final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId);
- final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, true);
+ final InputMethodSettings settings = new InputMethodSettings(methodMap, userId);
final InputMethodInfo imi = methodMap.get(settings.getSelectedInputMethod());
return imi != null && imi.supportsStylusHandwriting();
}
@@ -2059,7 +2058,7 @@
AdditionalSubtypeUtils.load(additionalSubtypeMap, userId);
queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap, methodMap,
methodList, directBootAwareness);
- settings = new InputMethodSettings(methodMap, userId, true /* copyOnWrite */);
+ settings = new InputMethodSettings(methodMap, userId);
}
// filter caller's access to input methods
methodList.removeIf(imi ->
@@ -2077,7 +2076,7 @@
settings = mSettings;
} else {
final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId);
- settings = new InputMethodSettings(methodMap, userId, true /* copyOnWrite */);
+ settings = new InputMethodSettings(methodMap, userId);
methodList = settings.getEnabledInputMethodListLocked();
}
// filter caller's access to input methods
@@ -2157,7 +2156,7 @@
if (imi == null) {
return Collections.emptyList();
}
- final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, true);
+ final InputMethodSettings settings = new InputMethodSettings(methodMap, userId);
if (!canCallerAccessInputMethod(imi.getPackageName(), callingUid, userId, settings)) {
return Collections.emptyList();
}
@@ -4134,7 +4133,7 @@
}
final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId);
- final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, false);
+ final InputMethodSettings settings = new InputMethodSettings(methodMap, userId);
return settings.getLastInputMethodSubtypeLocked();
}
}
@@ -4186,7 +4185,7 @@
AdditionalSubtypeUtils.load(additionalSubtypeMap, userId);
queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap, methodMap,
methodList, DirectBootAwareness.AUTO);
- final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, false);
+ final InputMethodSettings settings = new InputMethodSettings(methodMap, userId);
settings.setAdditionalInputMethodSubtypes(imiId, toBeAdded, additionalSubtypeMap,
mPackageManagerInternal, callingUid);
}
@@ -4215,8 +4214,7 @@
final boolean currentUser = (mSettings.getCurrentUserId() == userId);
final InputMethodSettings settings = currentUser
? mSettings
- : new InputMethodSettings(queryMethodMapForUser(userId), userId,
- !mUserManagerInternal.isUserUnlocked(userId));
+ : new InputMethodSettings(queryMethodMapForUser(userId), userId);
if (!settings.setEnabledInputMethodSubtypes(imeId, subtypeHashCodes)) {
return;
}
@@ -5365,7 +5363,7 @@
}
final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId);
- final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, false);
+ final InputMethodSettings settings = new InputMethodSettings(methodMap, userId);
return settings.getCurrentInputMethodSubtypeForNonCurrentUsers();
}
}
@@ -5438,7 +5436,7 @@
AdditionalSubtypeUtils.load(additionalSubtypeMap, userId);
queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap, methodMap,
methodList, DirectBootAwareness.AUTO);
- InputMethodSettings settings = new InputMethodSettings(methodMap, userId, true);
+ InputMethodSettings settings = new InputMethodSettings(methodMap, userId);
return methodMap.get(settings.getSelectedInputMethod());
}
@@ -5465,7 +5463,7 @@
return true;
}
final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId);
- final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, false);
+ final InputMethodSettings settings = new InputMethodSettings(methodMap, userId);
if (!methodMap.containsKey(imeId)
|| !settings.getEnabledInputMethodListLocked().contains(methodMap.get(imeId))) {
return false; // IME is not found or not enabled.
@@ -5604,8 +5602,7 @@
return true;
}
final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId);
- final InputMethodSettings settings = new InputMethodSettings(methodMap,
- userId, false);
+ final InputMethodSettings settings = new InputMethodSettings(methodMap, userId);
if (!methodMap.containsKey(imeId)) {
return false; // IME is not found.
}
@@ -6348,7 +6345,7 @@
}
} else {
final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId);
- final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, false);
+ final InputMethodSettings settings = new InputMethodSettings(methodMap, userId);
if (enabled) {
if (!methodMap.containsKey(imeId)) {
failedToEnableUnknownIme = true;
@@ -6491,7 +6488,7 @@
queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap,
methodMap, methodList, DirectBootAwareness.AUTO);
final InputMethodSettings settings = new InputMethodSettings(
- methodMap, userId, false);
+ methodMap, userId);
nextEnabledImes = InputMethodInfoUtils.getDefaultEnabledImes(mContext,
methodList);
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodUtils.java b/services/core/java/com/android/server/inputmethod/InputMethodUtils.java
index f561d4c..547fd2f 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodUtils.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodUtils.java
@@ -213,7 +213,6 @@
public static class InputMethodSettings {
private final ArrayMap<String, InputMethodInfo> mMethodMap;
- private boolean mCopyOnWrite = false;
@UserIdInt
private int mCurrentUserId;
@@ -227,26 +226,21 @@
}
}
- InputMethodSettings(ArrayMap<String, InputMethodInfo> methodMap, @UserIdInt int userId,
- boolean copyOnWrite) {
+ InputMethodSettings(ArrayMap<String, InputMethodInfo> methodMap, @UserIdInt int userId) {
mMethodMap = methodMap;
- switchCurrentUser(userId, copyOnWrite);
+ switchCurrentUser(userId);
}
/**
* Must be called when the current user is changed.
*
* @param userId The user ID.
- * @param copyOnWrite If {@code true}, for each settings key
- * (e.g. {@link Settings.Secure#ACTION_INPUT_METHOD_SUBTYPE_SETTINGS}) we use the actual
- * settings on the {@link Settings.Secure} until we do the first write operation.
*/
- void switchCurrentUser(@UserIdInt int userId, boolean copyOnWrite) {
+ void switchCurrentUser(@UserIdInt int userId) {
if (DEBUG) {
Slog.d(TAG, "--- Switch the current user from " + mCurrentUserId + " to " + userId);
}
mCurrentUserId = userId;
- mCopyOnWrite = copyOnWrite;
}
private void putString(@NonNull String key, @Nullable String str) {
@@ -840,7 +834,6 @@
public void dumpLocked(final Printer pw, final String prefix) {
pw.println(prefix + "mCurrentUserId=" + mCurrentUserId);
- pw.println(prefix + "mCopyOnWrite=" + mCopyOnWrite);
}
}
diff --git a/services/tests/servicestests/src/com/android/server/inputmethod/InputMethodUtilsTest.java b/services/tests/servicestests/src/com/android/server/inputmethod/InputMethodUtilsTest.java
index 0d25faf..6dd9171 100644
--- a/services/tests/servicestests/src/com/android/server/inputmethod/InputMethodUtilsTest.java
+++ b/services/tests/servicestests/src/com/android/server/inputmethod/InputMethodUtilsTest.java
@@ -1236,7 +1236,7 @@
// Init InputMethodSettings for the owner user (userId=0), verify calls can get the
// corresponding user's context, contentResolver and the resources configuration.
InputMethodUtils.InputMethodSettings settings = new InputMethodUtils.InputMethodSettings(
- methodMap, 0 /* userId */, true);
+ methodMap, 0 /* userId */);
assertEquals(0, settings.getCurrentUserId());
settings.isShowImeWithHardKeyboardEnabled();
@@ -1247,7 +1247,7 @@
// Calling switchCurrentUser to the secondary user (userId=10), verify calls can get the
// corresponding user's context, contentResolver and the resources configuration.
- settings.switchCurrentUser(10 /* userId */, true);
+ settings.switchCurrentUser(10 /* userId */);
assertEquals(10, settings.getCurrentUserId());
settings.isShowImeWithHardKeyboardEnabled();