Merge "Teach IMMS#shouldShowImeSwitcherLocked() about shouldShowInInputMethodPicker attr" into sc-dev
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
index a0004a0..3c0dae5 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
@@ -2762,7 +2762,8 @@
return false;
}
- List<InputMethodInfo> imis = mSettings.getEnabledInputMethodListLocked();
+ List<InputMethodInfo> imis = mSettings.getEnabledInputMethodListWithFilterLocked(
+ InputMethodInfo::shouldShowInInputMethodPicker);
final int N = imis.size();
if (N > 2) return true;
if (N < 1) return false;
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodUtils.java b/services/core/java/com/android/server/inputmethod/InputMethodUtils.java
index ac3c31d..e619fff 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodUtils.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodUtils.java
@@ -54,6 +54,7 @@
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
+import java.util.function.Predicate;
/**
* This class provides random static utility methods for {@link InputMethodManagerService} and its
@@ -946,8 +947,14 @@
}
ArrayList<InputMethodInfo> getEnabledInputMethodListLocked() {
+ return getEnabledInputMethodListWithFilterLocked(null /* matchingCondition */);
+ }
+
+ @NonNull
+ ArrayList<InputMethodInfo> getEnabledInputMethodListWithFilterLocked(
+ @Nullable Predicate<InputMethodInfo> matchingCondition) {
return createEnabledInputMethodListLocked(
- getEnabledInputMethodsAndSubtypeListLocked());
+ getEnabledInputMethodsAndSubtypeListLocked(), matchingCondition);
}
List<InputMethodSubtype> getEnabledInputMethodSubtypeListLocked(
@@ -1036,11 +1043,13 @@
}
private ArrayList<InputMethodInfo> createEnabledInputMethodListLocked(
- List<Pair<String, ArrayList<String>>> imsList) {
+ List<Pair<String, ArrayList<String>>> imsList,
+ Predicate<InputMethodInfo> matchingCondition) {
final ArrayList<InputMethodInfo> res = new ArrayList<>();
for (Pair<String, ArrayList<String>> ims: imsList) {
InputMethodInfo info = mMethodMap.get(ims.first);
- if (info != null && !info.isVrOnly()) {
+ if (info != null && !info.isVrOnly()
+ && (matchingCondition == null || matchingCondition.test(info))) {
res.add(info);
}
}