summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Yohei Yukawa <yukawa@google.com> 2024-01-01 01:36:58 +0900
committer Yohei Yukawa <yukawa@google.com> 2024-01-01 01:36:58 +0900
commita2d5f0eb9d39dd16b6445b4534213a708c428a57 (patch)
treebd15767f3b79e8f5e11cdbf5be80268996577828
parentc39dcef31c04abcf3d4f8c0f0ba7e7e831cb5ff4 (diff)
Remove unused InputMethodSettings#mCopyOnWrite
Now that InputMethodSettings#mCopyOnWrite has no side effect thus can be safely removed. Bug: 309837937 Test: presubmit Change-Id: I915c7a997f2c413f3bf98f4712029fd0ce83cd52
-rw-r--r--services/core/java/com/android/server/inputmethod/InputMethodManagerService.java37
-rw-r--r--services/core/java/com/android/server/inputmethod/InputMethodUtils.java13
-rw-r--r--services/tests/servicestests/src/com/android/server/inputmethod/InputMethodUtilsTest.java4
3 files changed, 22 insertions, 32 deletions
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
index 8789066f36af..c4d94ee93235 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 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
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 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
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 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
// 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 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
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 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
//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 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
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 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
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 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
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 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
}
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 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
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 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
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 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
}
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 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
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 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
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 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
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 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
}
} 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 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
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 f561d4cb70e6..547fd2f17980 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 @@ final class InputMethodUtils {
public static class InputMethodSettings {
private final ArrayMap<String, InputMethodInfo> mMethodMap;
- private boolean mCopyOnWrite = false;
@UserIdInt
private int mCurrentUserId;
@@ -227,26 +226,21 @@ final class InputMethodUtils {
}
}
- 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 @@ final class InputMethodUtils {
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 0d25faf2bcf1..6dd91718f70d 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 @@ public class InputMethodUtilsTest {
// 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 @@ public class InputMethodUtilsTest {
// 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();