Loading services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +14 −22 Original line number Diff line number Diff line Loading @@ -1689,7 +1689,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub mLastSwitchUserId = userId; // mSettings should be created before buildInputMethodListLocked mSettings = new InputMethodSettings(mContext, mMethodMap, userId, !mSystemReady); mSettings = new InputMethodSettings(mMethodMap, userId, !mSystemReady); AdditionalSubtypeUtils.load(mAdditionalSubtypeMap, userId); mSwitchingController = Loading Loading @@ -2019,8 +2019,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(mContext, methodMap, userId, true); final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, true); final InputMethodInfo imi = methodMap.get(settings.getSelectedInputMethod()); return imi != null && imi.supportsStylusHandwriting(); } Loading Loading @@ -2056,7 +2055,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub AdditionalSubtypeUtils.load(additionalSubtypeMap, userId); queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap, methodMap, methodList, directBootAwareness); settings = new InputMethodSettings(mContext, methodMap, userId, true /* copyOnWrite */); settings = new InputMethodSettings(methodMap, userId, true /* copyOnWrite */); } // filter caller's access to input methods methodList.removeIf(imi -> Loading @@ -2074,7 +2073,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub settings = mSettings; } else { final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId); settings = new InputMethodSettings(mContext, methodMap, userId, true /* copyOnWrite */); settings = new InputMethodSettings(methodMap, userId, true /* copyOnWrite */); methodList = settings.getEnabledInputMethodListLocked(); } // filter caller's access to input methods Loading Loading @@ -2154,8 +2153,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub if (imi == null) { return Collections.emptyList(); } final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, true); final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, true); if (!canCallerAccessInputMethod(imi.getPackageName(), callingUid, userId, settings)) { return Collections.emptyList(); } Loading Loading @@ -4132,8 +4130,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub } final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId); final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, false); final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, false); return settings.getLastInputMethodSubtypeLocked(); } } Loading Loading @@ -4185,8 +4182,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(mContext, methodMap, userId, false); final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, false); settings.setAdditionalInputMethodSubtypes(imiId, toBeAdded, additionalSubtypeMap, mPackageManagerInternal, callingUid); } Loading Loading @@ -4215,7 +4211,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub final boolean currentUser = (mSettings.getCurrentUserId() == userId); final InputMethodSettings settings = currentUser ? mSettings : new InputMethodSettings(mContext, queryMethodMapForUser(userId), userId, : new InputMethodSettings(queryMethodMapForUser(userId), userId, !mUserManagerInternal.isUserUnlocked(userId)); if (!settings.setEnabledInputMethodSubtypes(imeId, subtypeHashCodes)) { return; Loading Loading @@ -5365,8 +5361,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub } final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId); final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, false); final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, false); return settings.getCurrentInputMethodSubtypeForNonCurrentUsers(); } } Loading Loading @@ -5439,8 +5434,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub AdditionalSubtypeUtils.load(additionalSubtypeMap, userId); queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap, methodMap, methodList, DirectBootAwareness.AUTO); InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, true /* copyOnWrite */); InputMethodSettings settings = new InputMethodSettings(methodMap, userId, true); return methodMap.get(settings.getSelectedInputMethod()); } Loading @@ -5467,8 +5461,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub return true; } final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId); final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, false); final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, false); if (!methodMap.containsKey(imeId) || !settings.getEnabledInputMethodListLocked().contains(methodMap.get(imeId))) { return false; // IME is not found or not enabled. Loading Loading @@ -5607,7 +5600,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub return true; } final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId); final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, false); if (!methodMap.containsKey(imeId)) { return false; // IME is not found. Loading Loading @@ -6331,8 +6324,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub } } else { final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId); final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, false); final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, false); if (enabled) { if (!methodMap.containsKey(imeId)) { failedToEnableUnknownIme = true; Loading Loading @@ -6476,7 +6468,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(mContext, final InputMethodSettings settings = new InputMethodSettings( methodMap, userId, false); nextEnabledImes = InputMethodInfoUtils.getDefaultEnabledImes(mContext, Loading services/core/java/com/android/server/inputmethod/InputMethodUtils.java +1 −14 Original line number Diff line number Diff line Loading @@ -208,8 +208,6 @@ final class InputMethodUtils { */ @UserHandleAware public static class InputMethodSettings { @NonNull private Context mUserAwareContext; private final ArrayMap<String, InputMethodInfo> mMethodMap; private boolean mCopyOnWrite = false; Loading Loading @@ -253,17 +251,9 @@ final class InputMethodUtils { return imsList; } private void initContentWithUserContext(@NonNull Context context, @UserIdInt int userId) { mUserAwareContext = context.getUserId() == userId ? context : context.createContextAsUser(UserHandle.of(userId), 0 /* flags */); } InputMethodSettings(@NonNull Context context, ArrayMap<String, InputMethodInfo> methodMap, @UserIdInt int userId, InputMethodSettings(ArrayMap<String, InputMethodInfo> methodMap, @UserIdInt int userId, boolean copyOnWrite) { mMethodMap = methodMap; initContentWithUserContext(context, userId); switchCurrentUser(userId, copyOnWrite); } Loading @@ -282,9 +272,6 @@ final class InputMethodUtils { if (mCurrentUserId != userId || mCopyOnWrite != copyOnWrite) { mEnabledInputMethodsStrCache = ""; } if (mUserAwareContext.getUserId() != userId) { initContentWithUserContext(mUserAwareContext, userId); } mCurrentUserId = userId; mCopyOnWrite = copyOnWrite; } Loading services/tests/servicestests/src/com/android/server/inputmethod/InputMethodUtilsTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -1234,7 +1234,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( ownerUserContext, methodMap, 0 /* userId */, true); methodMap, 0 /* userId */, true); assertEquals(0, settings.getCurrentUserId()); settings.isShowImeWithHardKeyboardEnabled(); Loading Loading
services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +14 −22 Original line number Diff line number Diff line Loading @@ -1689,7 +1689,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub mLastSwitchUserId = userId; // mSettings should be created before buildInputMethodListLocked mSettings = new InputMethodSettings(mContext, mMethodMap, userId, !mSystemReady); mSettings = new InputMethodSettings(mMethodMap, userId, !mSystemReady); AdditionalSubtypeUtils.load(mAdditionalSubtypeMap, userId); mSwitchingController = Loading Loading @@ -2019,8 +2019,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(mContext, methodMap, userId, true); final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, true); final InputMethodInfo imi = methodMap.get(settings.getSelectedInputMethod()); return imi != null && imi.supportsStylusHandwriting(); } Loading Loading @@ -2056,7 +2055,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub AdditionalSubtypeUtils.load(additionalSubtypeMap, userId); queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap, methodMap, methodList, directBootAwareness); settings = new InputMethodSettings(mContext, methodMap, userId, true /* copyOnWrite */); settings = new InputMethodSettings(methodMap, userId, true /* copyOnWrite */); } // filter caller's access to input methods methodList.removeIf(imi -> Loading @@ -2074,7 +2073,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub settings = mSettings; } else { final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId); settings = new InputMethodSettings(mContext, methodMap, userId, true /* copyOnWrite */); settings = new InputMethodSettings(methodMap, userId, true /* copyOnWrite */); methodList = settings.getEnabledInputMethodListLocked(); } // filter caller's access to input methods Loading Loading @@ -2154,8 +2153,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub if (imi == null) { return Collections.emptyList(); } final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, true); final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, true); if (!canCallerAccessInputMethod(imi.getPackageName(), callingUid, userId, settings)) { return Collections.emptyList(); } Loading Loading @@ -4132,8 +4130,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub } final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId); final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, false); final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, false); return settings.getLastInputMethodSubtypeLocked(); } } Loading Loading @@ -4185,8 +4182,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(mContext, methodMap, userId, false); final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, false); settings.setAdditionalInputMethodSubtypes(imiId, toBeAdded, additionalSubtypeMap, mPackageManagerInternal, callingUid); } Loading Loading @@ -4215,7 +4211,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub final boolean currentUser = (mSettings.getCurrentUserId() == userId); final InputMethodSettings settings = currentUser ? mSettings : new InputMethodSettings(mContext, queryMethodMapForUser(userId), userId, : new InputMethodSettings(queryMethodMapForUser(userId), userId, !mUserManagerInternal.isUserUnlocked(userId)); if (!settings.setEnabledInputMethodSubtypes(imeId, subtypeHashCodes)) { return; Loading Loading @@ -5365,8 +5361,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub } final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId); final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, false); final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, false); return settings.getCurrentInputMethodSubtypeForNonCurrentUsers(); } } Loading Loading @@ -5439,8 +5434,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub AdditionalSubtypeUtils.load(additionalSubtypeMap, userId); queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap, methodMap, methodList, DirectBootAwareness.AUTO); InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, true /* copyOnWrite */); InputMethodSettings settings = new InputMethodSettings(methodMap, userId, true); return methodMap.get(settings.getSelectedInputMethod()); } Loading @@ -5467,8 +5461,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub return true; } final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId); final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, false); final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, false); if (!methodMap.containsKey(imeId) || !settings.getEnabledInputMethodListLocked().contains(methodMap.get(imeId))) { return false; // IME is not found or not enabled. Loading Loading @@ -5607,7 +5600,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub return true; } final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId); final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, false); if (!methodMap.containsKey(imeId)) { return false; // IME is not found. Loading Loading @@ -6331,8 +6324,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub } } else { final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId); final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, false); final InputMethodSettings settings = new InputMethodSettings(methodMap, userId, false); if (enabled) { if (!methodMap.containsKey(imeId)) { failedToEnableUnknownIme = true; Loading Loading @@ -6476,7 +6468,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(mContext, final InputMethodSettings settings = new InputMethodSettings( methodMap, userId, false); nextEnabledImes = InputMethodInfoUtils.getDefaultEnabledImes(mContext, Loading
services/core/java/com/android/server/inputmethod/InputMethodUtils.java +1 −14 Original line number Diff line number Diff line Loading @@ -208,8 +208,6 @@ final class InputMethodUtils { */ @UserHandleAware public static class InputMethodSettings { @NonNull private Context mUserAwareContext; private final ArrayMap<String, InputMethodInfo> mMethodMap; private boolean mCopyOnWrite = false; Loading Loading @@ -253,17 +251,9 @@ final class InputMethodUtils { return imsList; } private void initContentWithUserContext(@NonNull Context context, @UserIdInt int userId) { mUserAwareContext = context.getUserId() == userId ? context : context.createContextAsUser(UserHandle.of(userId), 0 /* flags */); } InputMethodSettings(@NonNull Context context, ArrayMap<String, InputMethodInfo> methodMap, @UserIdInt int userId, InputMethodSettings(ArrayMap<String, InputMethodInfo> methodMap, @UserIdInt int userId, boolean copyOnWrite) { mMethodMap = methodMap; initContentWithUserContext(context, userId); switchCurrentUser(userId, copyOnWrite); } Loading @@ -282,9 +272,6 @@ final class InputMethodUtils { if (mCurrentUserId != userId || mCopyOnWrite != copyOnWrite) { mEnabledInputMethodsStrCache = ""; } if (mUserAwareContext.getUserId() != userId) { initContentWithUserContext(mUserAwareContext, userId); } mCurrentUserId = userId; mCopyOnWrite = copyOnWrite; } Loading
services/tests/servicestests/src/com/android/server/inputmethod/InputMethodUtilsTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -1234,7 +1234,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( ownerUserContext, methodMap, 0 /* userId */, true); methodMap, 0 /* userId */, true); assertEquals(0, settings.getCurrentUserId()); settings.isShowImeWithHardKeyboardEnabled(); Loading