Loading services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +11 −9 Original line number Diff line number Diff line Loading @@ -2085,7 +2085,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub new ArrayMap<>(); AdditionalSubtypeUtils.load(additionalSubtypeMap, userId); queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap, methodMap, methodList, directBootAwareness, mSettings.getEnabledInputMethodNames()); methodList, directBootAwareness); settings = new InputMethodSettings(mContext, methodMap, userId, true /* copyOnWrite */); } // filter caller's access to input methods Loading Loading @@ -4200,7 +4200,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub new ArrayMap<>(); AdditionalSubtypeUtils.load(additionalSubtypeMap, userId); queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap, methodMap, methodList, DirectBootAwareness.AUTO, mSettings.getEnabledInputMethodNames()); methodList, DirectBootAwareness.AUTO); final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, false); settings.setAdditionalInputMethodSubtypes(imiId, toBeAdded, additionalSubtypeMap, Loading Loading @@ -5025,7 +5025,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub static void queryInputMethodServicesInternal(Context context, @UserIdInt int userId, ArrayMap<String, List<InputMethodSubtype>> additionalSubtypeMap, ArrayMap<String, InputMethodInfo> methodMap, ArrayList<InputMethodInfo> methodList, @DirectBootAwareness int directBootAwareness, List<String> enabledInputMethodList) { @DirectBootAwareness int directBootAwareness) { final Context userAwareContext = context.getUserId() == userId ? context : context.createContextAsUser(UserHandle.of(userId), 0 /* flags */); Loading Loading @@ -5058,6 +5058,11 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub methodList.ensureCapacity(services.size()); methodMap.ensureCapacity(services.size()); // Note: This is a temporary solution for Bug 261723412. If there is any better solution, // we should remove this data dependency. final List<String> enabledInputMethodList = InputMethodUtils.getEnabledInputMethodIdsForFiltering(context, userId); filterInputMethodServices(additionalSubtypeMap, methodMap, methodList, enabledInputMethodList, userAwareContext, services); } Loading Loading @@ -5124,8 +5129,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub mMyPackageMonitor.clearKnownImePackageNamesLocked(); queryInputMethodServicesInternal(mContext, mSettings.getCurrentUserId(), mAdditionalSubtypeMap, mMethodMap, mMethodList, DirectBootAwareness.AUTO, mSettings.getEnabledInputMethodNames()); mAdditionalSubtypeMap, mMethodMap, mMethodList, DirectBootAwareness.AUTO); // Construct the set of possible IME packages for onPackageChanged() to avoid false // negatives when the package state remains to be the same but only the component state is Loading Loading @@ -5486,8 +5490,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub new ArrayMap<>(); AdditionalSubtypeUtils.load(additionalSubtypeMap, userId); queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap, methodMap, methodList, DirectBootAwareness.AUTO, mSettings.getEnabledInputMethodNames()); methodMap, methodList, DirectBootAwareness.AUTO); return methodMap; } Loading Loading @@ -6511,8 +6514,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub new ArrayMap<>(); AdditionalSubtypeUtils.load(additionalSubtypeMap, userId); queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap, methodMap, methodList, DirectBootAwareness.AUTO, mSettings.getEnabledInputMethodNames()); methodMap, methodList, DirectBootAwareness.AUTO); final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, false); Loading services/core/java/com/android/server/inputmethod/InputMethodUtils.java +38 −0 Original line number Diff line number Diff line Loading @@ -1028,6 +1028,44 @@ final class InputMethodUtils { return new int[]{sourceUserId}; } /** * Returns a list of enabled IME IDs to address Bug 261723412. * * <p>This is a temporary workaround until we come up with a better solution. Do not use this * for anything other than Bug 261723412.</p> * * @param context {@link Context} object to query secure settings. * @param userId User ID to query about. * @return A list of enabled IME IDs. */ @NonNull static List<String> getEnabledInputMethodIdsForFiltering(@NonNull Context context, @UserIdInt int userId) { final String enabledInputMethodsStr = TextUtils.nullIfEmpty( Settings.Secure.getStringForUser( context.getContentResolver(), Settings.Secure.ENABLED_INPUT_METHODS, userId)); if (enabledInputMethodsStr == null) { return List.of(); } final TextUtils.SimpleStringSplitter inputMethodSplitter = new TextUtils.SimpleStringSplitter(INPUT_METHOD_SEPARATOR); final TextUtils.SimpleStringSplitter subtypeSplitter = new TextUtils.SimpleStringSplitter(INPUT_METHOD_SUBTYPE_SEPARATOR); inputMethodSplitter.setString(enabledInputMethodsStr); final ArrayList<String> result = new ArrayList<>(); while (inputMethodSplitter.hasNext()) { String nextImsStr = inputMethodSplitter.next(); subtypeSplitter.setString(nextImsStr); if (subtypeSplitter.hasNext()) { // The first element is ime id. result.add(subtypeSplitter.next()); } } return result; } /** * Convert the input method ID to a component name * Loading Loading
services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +11 −9 Original line number Diff line number Diff line Loading @@ -2085,7 +2085,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub new ArrayMap<>(); AdditionalSubtypeUtils.load(additionalSubtypeMap, userId); queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap, methodMap, methodList, directBootAwareness, mSettings.getEnabledInputMethodNames()); methodList, directBootAwareness); settings = new InputMethodSettings(mContext, methodMap, userId, true /* copyOnWrite */); } // filter caller's access to input methods Loading Loading @@ -4200,7 +4200,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub new ArrayMap<>(); AdditionalSubtypeUtils.load(additionalSubtypeMap, userId); queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap, methodMap, methodList, DirectBootAwareness.AUTO, mSettings.getEnabledInputMethodNames()); methodList, DirectBootAwareness.AUTO); final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, false); settings.setAdditionalInputMethodSubtypes(imiId, toBeAdded, additionalSubtypeMap, Loading Loading @@ -5025,7 +5025,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub static void queryInputMethodServicesInternal(Context context, @UserIdInt int userId, ArrayMap<String, List<InputMethodSubtype>> additionalSubtypeMap, ArrayMap<String, InputMethodInfo> methodMap, ArrayList<InputMethodInfo> methodList, @DirectBootAwareness int directBootAwareness, List<String> enabledInputMethodList) { @DirectBootAwareness int directBootAwareness) { final Context userAwareContext = context.getUserId() == userId ? context : context.createContextAsUser(UserHandle.of(userId), 0 /* flags */); Loading Loading @@ -5058,6 +5058,11 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub methodList.ensureCapacity(services.size()); methodMap.ensureCapacity(services.size()); // Note: This is a temporary solution for Bug 261723412. If there is any better solution, // we should remove this data dependency. final List<String> enabledInputMethodList = InputMethodUtils.getEnabledInputMethodIdsForFiltering(context, userId); filterInputMethodServices(additionalSubtypeMap, methodMap, methodList, enabledInputMethodList, userAwareContext, services); } Loading Loading @@ -5124,8 +5129,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub mMyPackageMonitor.clearKnownImePackageNamesLocked(); queryInputMethodServicesInternal(mContext, mSettings.getCurrentUserId(), mAdditionalSubtypeMap, mMethodMap, mMethodList, DirectBootAwareness.AUTO, mSettings.getEnabledInputMethodNames()); mAdditionalSubtypeMap, mMethodMap, mMethodList, DirectBootAwareness.AUTO); // Construct the set of possible IME packages for onPackageChanged() to avoid false // negatives when the package state remains to be the same but only the component state is Loading Loading @@ -5486,8 +5490,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub new ArrayMap<>(); AdditionalSubtypeUtils.load(additionalSubtypeMap, userId); queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap, methodMap, methodList, DirectBootAwareness.AUTO, mSettings.getEnabledInputMethodNames()); methodMap, methodList, DirectBootAwareness.AUTO); return methodMap; } Loading Loading @@ -6511,8 +6514,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub new ArrayMap<>(); AdditionalSubtypeUtils.load(additionalSubtypeMap, userId); queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap, methodMap, methodList, DirectBootAwareness.AUTO, mSettings.getEnabledInputMethodNames()); methodMap, methodList, DirectBootAwareness.AUTO); final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, false); Loading
services/core/java/com/android/server/inputmethod/InputMethodUtils.java +38 −0 Original line number Diff line number Diff line Loading @@ -1028,6 +1028,44 @@ final class InputMethodUtils { return new int[]{sourceUserId}; } /** * Returns a list of enabled IME IDs to address Bug 261723412. * * <p>This is a temporary workaround until we come up with a better solution. Do not use this * for anything other than Bug 261723412.</p> * * @param context {@link Context} object to query secure settings. * @param userId User ID to query about. * @return A list of enabled IME IDs. */ @NonNull static List<String> getEnabledInputMethodIdsForFiltering(@NonNull Context context, @UserIdInt int userId) { final String enabledInputMethodsStr = TextUtils.nullIfEmpty( Settings.Secure.getStringForUser( context.getContentResolver(), Settings.Secure.ENABLED_INPUT_METHODS, userId)); if (enabledInputMethodsStr == null) { return List.of(); } final TextUtils.SimpleStringSplitter inputMethodSplitter = new TextUtils.SimpleStringSplitter(INPUT_METHOD_SEPARATOR); final TextUtils.SimpleStringSplitter subtypeSplitter = new TextUtils.SimpleStringSplitter(INPUT_METHOD_SUBTYPE_SEPARATOR); inputMethodSplitter.setString(enabledInputMethodsStr); final ArrayList<String> result = new ArrayList<>(); while (inputMethodSplitter.hasNext()) { String nextImsStr = inputMethodSplitter.next(); subtypeSplitter.setString(nextImsStr); if (subtypeSplitter.hasNext()) { // The first element is ime id. result.add(subtypeSplitter.next()); } } return result; } /** * Convert the input method ID to a component name * Loading