Loading services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +19 −24 Original line number Diff line number Diff line Loading @@ -1765,8 +1765,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub mLastSwitchUserId = userId; // mSettings should be created before buildInputMethodListLocked mSettings = new InputMethodSettings( mRes, context.getContentResolver(), mMethodMap, userId, !mSystemReady); mSettings = new InputMethodSettings(mContext, mMethodMap, userId, !mSystemReady); updateCurrentProfileIds(); AdditionalSubtypeUtils.load(mAdditionalSubtypeMap, userId); Loading Loading @@ -2138,8 +2137,8 @@ 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(mContext.getResources(), mContext.getContentResolver(), methodMap, userId, true); final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, true); final InputMethodInfo imi = methodMap.get(settings.getSelectedInputMethod()); return imi != null && imi.supportsStylusHandwriting(); } Loading Loading @@ -2171,8 +2170,8 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub return mSettings.getEnabledInputMethodListLocked(); } final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId); final InputMethodSettings settings = new InputMethodSettings(mContext.getResources(), mContext.getContentResolver(), methodMap, userId, true); final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, true); return settings.getEnabledInputMethodListLocked(); } Loading Loading @@ -2237,17 +2236,17 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub return Collections.emptyList(); } return mSettings.getEnabledInputMethodSubtypeListLocked( mContext, imi, allowsImplicitlySelectedSubtypes); imi, allowsImplicitlySelectedSubtypes); } final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId); final InputMethodInfo imi = methodMap.get(imiId); if (imi == null) { return Collections.emptyList(); } final InputMethodSettings settings = new InputMethodSettings(mContext.getResources(), mContext.getContentResolver(), methodMap, userId, true); final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, true); return settings.getEnabledInputMethodSubtypeListLocked( mContext, imi, allowsImplicitlySelectedSubtypes); imi, allowsImplicitlySelectedSubtypes); } /** Loading Loading @@ -3066,7 +3065,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub for (int i = 0; i < numImes; ++i) { final InputMethodInfo imi = imes.get(i); final List<InputMethodSubtype> subtypes = mSettings.getEnabledInputMethodSubtypeListLocked(mContext, imi, true); mSettings.getEnabledInputMethodSubtypeListLocked(imi, true); final int subtypeCount = subtypes.size(); if (subtypeCount == 0) { ++nonAuxCount; Loading Loading @@ -4155,8 +4154,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub } final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId); final InputMethodSettings settings = new InputMethodSettings( mContext.getResources(), mContext.getContentResolver(), methodMap, final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, false); return settings.getLastInputMethodSubtypeLocked(); } Loading Loading @@ -5317,7 +5315,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub // the most applicable subtype from explicitly or implicitly enabled // subtypes. List<InputMethodSubtype> explicitlyOrImplicitlyEnabledSubtypes = mSettings.getEnabledInputMethodSubtypeListLocked(mContext, imi, true); mSettings.getEnabledInputMethodSubtypeListLocked(imi, true); // If there is only one explicitly or implicitly enabled subtype, // just returns it. if (explicitlyOrImplicitlyEnabledSubtypes.size() == 1) { Loading Loading @@ -5361,9 +5359,8 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub return true; } final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId); final InputMethodSettings settings = new InputMethodSettings( mContext.getResources(), mContext.getContentResolver(), methodMap, userId, false); final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, false); if (!methodMap.containsKey(imeId) || !settings.getEnabledInputMethodListLocked().contains(methodMap.get(imeId))) { return false; // IME is not found or not enabled. Loading Loading @@ -5435,8 +5432,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub return true; } final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId); final InputMethodSettings settings = new InputMethodSettings( mContext.getResources(), mContext.getContentResolver(), methodMap, final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, false); if (!methodMap.containsKey(imeId)) { return false; // IME is not found. Loading Loading @@ -6138,8 +6134,8 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub } } else { final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId); final InputMethodSettings settings = new InputMethodSettings(mContext.getResources(), mContext.getContentResolver(), methodMap, userId, false); final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, false); if (enabled) { if (!methodMap.containsKey(imeId)) { failedToEnableUnknownIme = true; Loading Loading @@ -6275,9 +6271,8 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub AdditionalSubtypeUtils.load(additionalSubtypeMap, userId); queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap, methodMap, methodList, DirectBootAwareness.AUTO); final InputMethodSettings settings = new InputMethodSettings( mContext.getResources(), mContext.getContentResolver(), methodMap, userId, false); final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, false); nextEnabledImes = InputMethodInfoUtils.getDefaultEnabledImes(mContext, methodList); Loading services/core/java/com/android/server/inputmethod/InputMethodSubtypeSwitchingController.java +1 −1 Original line number Diff line number Diff line Loading @@ -200,7 +200,7 @@ final class InputMethodSubtypeSwitchingController { continue; } final List<InputMethodSubtype> explicitlyOrImplicitlyEnabledSubtypeList = mSettings.getEnabledInputMethodSubtypeListLocked(mContext, imi, true); mSettings.getEnabledInputMethodSubtypeListLocked(imi, true); final ArraySet<String> enabledSubtypeSet = new ArraySet<>(); for (InputMethodSubtype subtype : explicitlyOrImplicitlyEnabledSubtypeList) { enabledSubtypeSet.add(String.valueOf(subtype.hashCode())); Loading services/core/java/com/android/server/inputmethod/InputMethodUtils.java +11 −6 Original line number Diff line number Diff line Loading @@ -233,6 +233,7 @@ final class InputMethodUtils { * TODO: Move all putters and getters of settings to this class. * TODO(b/235661780): Make the setting supports multi-users. */ @UserHandleAware public static class InputMethodSettings { private final TextUtils.SimpleStringSplitter mInputMethodSplitter = new TextUtils.SimpleStringSplitter(INPUT_METHOD_SEPARATOR); Loading @@ -240,6 +241,8 @@ final class InputMethodUtils { private final TextUtils.SimpleStringSplitter mSubtypeSplitter = new TextUtils.SimpleStringSplitter(INPUT_METHOD_SUBTYPE_SEPARATOR); @NonNull private final Context mUserAwareContext; private final Resources mRes; private final ContentResolver mResolver; private final ArrayMap<String, InputMethodInfo> mMethodMap; Loading Loading @@ -299,11 +302,14 @@ final class InputMethodUtils { return imsList; } InputMethodSettings(Resources res, ContentResolver resolver, InputMethodSettings(@NonNull Context context, ArrayMap<String, InputMethodInfo> methodMap, @UserIdInt int userId, boolean copyOnWrite) { mRes = res; mResolver = resolver; mUserAwareContext = context.getUserId() == userId ? context : context.createContextAsUser(UserHandle.of(userId), 0 /* flags */); mRes = mUserAwareContext.getResources(); mResolver = mUserAwareContext.getContentResolver(); mMethodMap = methodMap; switchCurrentUser(userId, copyOnWrite); } Loading Loading @@ -405,12 +411,11 @@ final class InputMethodUtils { } List<InputMethodSubtype> getEnabledInputMethodSubtypeListLocked( Context context, InputMethodInfo imi, boolean allowsImplicitlySelectedSubtypes) { InputMethodInfo imi, boolean allowsImplicitlySelectedSubtypes) { List<InputMethodSubtype> enabledSubtypes = getEnabledInputMethodSubtypeListLocked(imi); if (allowsImplicitlySelectedSubtypes && enabledSubtypes.isEmpty()) { enabledSubtypes = SubtypeUtils.getImplicitlyApplicableSubtypesLocked( context.getResources(), imi); enabledSubtypes = SubtypeUtils.getImplicitlyApplicableSubtypesLocked(mRes, imi); } return InputMethodSubtype.sort(imi, enabledSubtypes); } Loading Loading
services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +19 −24 Original line number Diff line number Diff line Loading @@ -1765,8 +1765,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub mLastSwitchUserId = userId; // mSettings should be created before buildInputMethodListLocked mSettings = new InputMethodSettings( mRes, context.getContentResolver(), mMethodMap, userId, !mSystemReady); mSettings = new InputMethodSettings(mContext, mMethodMap, userId, !mSystemReady); updateCurrentProfileIds(); AdditionalSubtypeUtils.load(mAdditionalSubtypeMap, userId); Loading Loading @@ -2138,8 +2137,8 @@ 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(mContext.getResources(), mContext.getContentResolver(), methodMap, userId, true); final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, true); final InputMethodInfo imi = methodMap.get(settings.getSelectedInputMethod()); return imi != null && imi.supportsStylusHandwriting(); } Loading Loading @@ -2171,8 +2170,8 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub return mSettings.getEnabledInputMethodListLocked(); } final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId); final InputMethodSettings settings = new InputMethodSettings(mContext.getResources(), mContext.getContentResolver(), methodMap, userId, true); final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, true); return settings.getEnabledInputMethodListLocked(); } Loading Loading @@ -2237,17 +2236,17 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub return Collections.emptyList(); } return mSettings.getEnabledInputMethodSubtypeListLocked( mContext, imi, allowsImplicitlySelectedSubtypes); imi, allowsImplicitlySelectedSubtypes); } final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId); final InputMethodInfo imi = methodMap.get(imiId); if (imi == null) { return Collections.emptyList(); } final InputMethodSettings settings = new InputMethodSettings(mContext.getResources(), mContext.getContentResolver(), methodMap, userId, true); final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, true); return settings.getEnabledInputMethodSubtypeListLocked( mContext, imi, allowsImplicitlySelectedSubtypes); imi, allowsImplicitlySelectedSubtypes); } /** Loading Loading @@ -3066,7 +3065,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub for (int i = 0; i < numImes; ++i) { final InputMethodInfo imi = imes.get(i); final List<InputMethodSubtype> subtypes = mSettings.getEnabledInputMethodSubtypeListLocked(mContext, imi, true); mSettings.getEnabledInputMethodSubtypeListLocked(imi, true); final int subtypeCount = subtypes.size(); if (subtypeCount == 0) { ++nonAuxCount; Loading Loading @@ -4155,8 +4154,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub } final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId); final InputMethodSettings settings = new InputMethodSettings( mContext.getResources(), mContext.getContentResolver(), methodMap, final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, false); return settings.getLastInputMethodSubtypeLocked(); } Loading Loading @@ -5317,7 +5315,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub // the most applicable subtype from explicitly or implicitly enabled // subtypes. List<InputMethodSubtype> explicitlyOrImplicitlyEnabledSubtypes = mSettings.getEnabledInputMethodSubtypeListLocked(mContext, imi, true); mSettings.getEnabledInputMethodSubtypeListLocked(imi, true); // If there is only one explicitly or implicitly enabled subtype, // just returns it. if (explicitlyOrImplicitlyEnabledSubtypes.size() == 1) { Loading Loading @@ -5361,9 +5359,8 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub return true; } final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId); final InputMethodSettings settings = new InputMethodSettings( mContext.getResources(), mContext.getContentResolver(), methodMap, userId, false); final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, false); if (!methodMap.containsKey(imeId) || !settings.getEnabledInputMethodListLocked().contains(methodMap.get(imeId))) { return false; // IME is not found or not enabled. Loading Loading @@ -5435,8 +5432,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub return true; } final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId); final InputMethodSettings settings = new InputMethodSettings( mContext.getResources(), mContext.getContentResolver(), methodMap, final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, false); if (!methodMap.containsKey(imeId)) { return false; // IME is not found. Loading Loading @@ -6138,8 +6134,8 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub } } else { final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId); final InputMethodSettings settings = new InputMethodSettings(mContext.getResources(), mContext.getContentResolver(), methodMap, userId, false); final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, false); if (enabled) { if (!methodMap.containsKey(imeId)) { failedToEnableUnknownIme = true; Loading Loading @@ -6275,9 +6271,8 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub AdditionalSubtypeUtils.load(additionalSubtypeMap, userId); queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap, methodMap, methodList, DirectBootAwareness.AUTO); final InputMethodSettings settings = new InputMethodSettings( mContext.getResources(), mContext.getContentResolver(), methodMap, userId, false); final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, false); nextEnabledImes = InputMethodInfoUtils.getDefaultEnabledImes(mContext, methodList); Loading
services/core/java/com/android/server/inputmethod/InputMethodSubtypeSwitchingController.java +1 −1 Original line number Diff line number Diff line Loading @@ -200,7 +200,7 @@ final class InputMethodSubtypeSwitchingController { continue; } final List<InputMethodSubtype> explicitlyOrImplicitlyEnabledSubtypeList = mSettings.getEnabledInputMethodSubtypeListLocked(mContext, imi, true); mSettings.getEnabledInputMethodSubtypeListLocked(imi, true); final ArraySet<String> enabledSubtypeSet = new ArraySet<>(); for (InputMethodSubtype subtype : explicitlyOrImplicitlyEnabledSubtypeList) { enabledSubtypeSet.add(String.valueOf(subtype.hashCode())); Loading
services/core/java/com/android/server/inputmethod/InputMethodUtils.java +11 −6 Original line number Diff line number Diff line Loading @@ -233,6 +233,7 @@ final class InputMethodUtils { * TODO: Move all putters and getters of settings to this class. * TODO(b/235661780): Make the setting supports multi-users. */ @UserHandleAware public static class InputMethodSettings { private final TextUtils.SimpleStringSplitter mInputMethodSplitter = new TextUtils.SimpleStringSplitter(INPUT_METHOD_SEPARATOR); Loading @@ -240,6 +241,8 @@ final class InputMethodUtils { private final TextUtils.SimpleStringSplitter mSubtypeSplitter = new TextUtils.SimpleStringSplitter(INPUT_METHOD_SUBTYPE_SEPARATOR); @NonNull private final Context mUserAwareContext; private final Resources mRes; private final ContentResolver mResolver; private final ArrayMap<String, InputMethodInfo> mMethodMap; Loading Loading @@ -299,11 +302,14 @@ final class InputMethodUtils { return imsList; } InputMethodSettings(Resources res, ContentResolver resolver, InputMethodSettings(@NonNull Context context, ArrayMap<String, InputMethodInfo> methodMap, @UserIdInt int userId, boolean copyOnWrite) { mRes = res; mResolver = resolver; mUserAwareContext = context.getUserId() == userId ? context : context.createContextAsUser(UserHandle.of(userId), 0 /* flags */); mRes = mUserAwareContext.getResources(); mResolver = mUserAwareContext.getContentResolver(); mMethodMap = methodMap; switchCurrentUser(userId, copyOnWrite); } Loading Loading @@ -405,12 +411,11 @@ final class InputMethodUtils { } List<InputMethodSubtype> getEnabledInputMethodSubtypeListLocked( Context context, InputMethodInfo imi, boolean allowsImplicitlySelectedSubtypes) { InputMethodInfo imi, boolean allowsImplicitlySelectedSubtypes) { List<InputMethodSubtype> enabledSubtypes = getEnabledInputMethodSubtypeListLocked(imi); if (allowsImplicitlySelectedSubtypes && enabledSubtypes.isEmpty()) { enabledSubtypes = SubtypeUtils.getImplicitlyApplicableSubtypesLocked( context.getResources(), imi); enabledSubtypes = SubtypeUtils.getImplicitlyApplicableSubtypesLocked(mRes, imi); } return InputMethodSubtype.sort(imi, enabledSubtypes); } Loading