summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Yohei Yukawa <yukawa@google.com> 2024-06-21 14:15:09 -0700
committer Yohei Yukawa <yukawa@google.com> 2024-06-21 14:15:09 -0700
commit1a8b94de034f9d6afa68af65f9886ae502548bb3 (patch)
tree93489e0872603b3c69cbee8d1bd95e3d7ab2536d
parent34053329d8a90aa8786338bc428fe3d9137dbf7e (diff)
Simplify InputMethodSubtypeSwitchingController a bit
This simplifies InputMethodSubtypeSwitchingController a bit by taking advantage of InputMethodSettings, which is in general a super set of InputMethodMap and user ID. This is a mechanical refactoring CL. There must be no semantic behavior change. Bug: 305849394 Bug: 346662143 Bug: 347693610 Flag: EXEMPT refactor Test: atest InputMethodSubtypeSwitchingControllerTest Change-Id: Ibc1410c6a49401983a5216a1b8973fb95f117e20
-rw-r--r--services/core/java/com/android/server/inputmethod/InputMethodManagerService.java15
-rw-r--r--services/core/java/com/android/server/inputmethod/InputMethodSubtypeSwitchingController.java15
2 files changed, 13 insertions, 17 deletions
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
index af2bc34a1ea1..27ccd50c8217 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
@@ -1296,8 +1296,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
final InputMethodSettings settings = InputMethodSettingsRepository.get(mCurrentUserId);
- mSwitchingController = new InputMethodSubtypeSwitchingController(context,
- settings.getMethodMap(), settings.getUserId());
+ mSwitchingController = new InputMethodSubtypeSwitchingController(context, settings);
getUserData(mCurrentUserId).mHardwareKeyboardShortcutController.update(settings);
mMenuController = new InputMethodMenuController(this);
mVisibilityStateComputer = new ImeVisibilityStateComputer(this);
@@ -3042,10 +3041,9 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
// TODO: Instantiate mSwitchingController for each user.
if (userId == mSwitchingController.getUserId()) {
- mSwitchingController.resetCircularListLocked(settings.getMethodMap());
+ mSwitchingController.resetCircularListLocked(settings);
} else {
- mSwitchingController = new InputMethodSubtypeSwitchingController(mContext,
- settings.getMethodMap(), userId);
+ mSwitchingController = new InputMethodSubtypeSwitchingController(mContext, settings);
}
getUserData(userId).mHardwareKeyboardShortcutController.update(settings);
sendOnNavButtonFlagsChangedLocked();
@@ -4917,7 +4915,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
final List<ImeSubtypeListItem> imList = InputMethodSubtypeSwitchingController
.getSortedInputMethodAndSubtypeList(
showAuxSubtypes, isScreenLocked, true /* forImeMenu */,
- mContext, settings.getMethodMap(), settings.getUserId());
+ mContext, settings);
if (imList.isEmpty()) {
Slog.w(TAG, "Show switching menu failed, imList is empty,"
+ " showAuxSubtypes: " + showAuxSubtypes
@@ -5307,10 +5305,9 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
// TODO: Instantiate mSwitchingController for each user.
if (userId == mSwitchingController.getUserId()) {
- mSwitchingController.resetCircularListLocked(settings.getMethodMap());
+ mSwitchingController.resetCircularListLocked(settings);
} else {
- mSwitchingController = new InputMethodSubtypeSwitchingController(mContext,
- settings.getMethodMap(), mCurrentUserId);
+ mSwitchingController = new InputMethodSubtypeSwitchingController(mContext, settings);
}
getUserData(userId).mHardwareKeyboardShortcutController.update(settings);
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodSubtypeSwitchingController.java b/services/core/java/com/android/server/inputmethod/InputMethodSubtypeSwitchingController.java
index bf9621fb5660..f97a5165ebec 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodSubtypeSwitchingController.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodSubtypeSwitchingController.java
@@ -163,13 +163,12 @@ final class InputMethodSubtypeSwitchingController {
@NonNull
static List<ImeSubtypeListItem> getSortedInputMethodAndSubtypeList(
boolean includeAuxiliarySubtypes, boolean isScreenLocked, boolean forImeMenu,
- @NonNull Context context, @NonNull InputMethodMap methodMap,
- @UserIdInt int userId) {
+ @NonNull Context context, @NonNull InputMethodSettings settings) {
+ final int userId = settings.getUserId();
final Context userAwareContext = context.getUserId() == userId
? context
: context.createContextAsUser(UserHandle.of(userId), 0 /* flags */);
final String mSystemLocaleStr = SystemLocaleWrapper.get(userId).get(0).toLanguageTag();
- final InputMethodSettings settings = InputMethodSettings.create(methodMap, userId);
final ArrayList<InputMethodInfo> imis = settings.getEnabledInputMethodList();
if (imis.isEmpty()) {
@@ -487,13 +486,13 @@ final class InputMethodSubtypeSwitchingController {
private ControllerImpl mController;
InputMethodSubtypeSwitchingController(@NonNull Context context,
- @NonNull InputMethodMap methodMap, @UserIdInt int userId) {
+ @NonNull InputMethodSettings settings) {
mContext = context;
- mUserId = userId;
+ mUserId = settings.getUserId();
mController = ControllerImpl.createFrom(null,
getSortedInputMethodAndSubtypeList(
false /* includeAuxiliarySubtypes */, false /* isScreenLocked */,
- false /* forImeMenu */, context, methodMap, userId));
+ false /* forImeMenu */, context, settings));
}
@AnyThread
@@ -507,11 +506,11 @@ final class InputMethodSubtypeSwitchingController {
mController.onUserActionLocked(imi, subtype);
}
- public void resetCircularListLocked(@NonNull InputMethodMap methodMap) {
+ public void resetCircularListLocked(@NonNull InputMethodSettings settings) {
mController = ControllerImpl.createFrom(mController,
getSortedInputMethodAndSubtypeList(
false /* includeAuxiliarySubtypes */, false /* isScreenLocked */,
- false /* forImeMenu */, mContext, methodMap, mUserId));
+ false /* forImeMenu */, mContext, settings));
}
@Nullable