Skip to content

Commit 4a553e3

Browse files
committed
Prioritize the order of subtypes in method.xml for implicitly enabled subtypes
Bug: 5401115 Change-Id: I6d9229cd266e27b68a6b9a2892aabfba4fe4de00
1 parent 53b1aaa commit 4a553e3

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

services/java/com/android/server/InputMethodManagerService.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2426,7 +2426,7 @@ private static ArrayList<InputMethodSubtype> getImplicitlyApplicableSubtypesLock
24262426
final List<InputMethodSubtype> subtypes = getSubtypes(imi);
24272427
final String systemLocale = res.getConfiguration().locale.toString();
24282428
if (TextUtils.isEmpty(systemLocale)) return new ArrayList<InputMethodSubtype>();
2429-
HashMap<String, InputMethodSubtype> applicableModeAndSubtypesMap =
2429+
final HashMap<String, InputMethodSubtype> applicableModeAndSubtypesMap =
24302430
new HashMap<String, InputMethodSubtype>();
24312431
final int N = subtypes.size();
24322432
boolean containsKeyboardSubtype = false;
@@ -2444,7 +2444,7 @@ private static ArrayList<InputMethodSubtype> getImplicitlyApplicableSubtypesLock
24442444
return new ArrayList<InputMethodSubtype>(applicableModeAndSubtypesMap.values());
24452445
}
24462446
for (int i = 0; i < N; ++i) {
2447-
InputMethodSubtype subtype = subtypes.get(i);
2447+
final InputMethodSubtype subtype = subtypes.get(i);
24482448
final String locale = subtype.getLocale();
24492449
final String mode = subtype.getMode();
24502450
// When system locale starts with subtype's locale, that subtype will be applicable
@@ -2456,10 +2456,12 @@ private static ArrayList<InputMethodSubtype> getImplicitlyApplicableSubtypesLock
24562456
// need to find applicable subtypes aggressively unlike
24572457
// findLastResortApplicableSubtypeLocked.
24582458
if (systemLocale.startsWith(locale)) {
2459-
InputMethodSubtype applicableSubtype = applicableModeAndSubtypesMap.get(mode);
2459+
final InputMethodSubtype applicableSubtype = applicableModeAndSubtypesMap.get(mode);
24602460
// If more applicable subtypes are contained, skip.
2461-
if (applicableSubtype != null
2462-
&& systemLocale.equals(applicableSubtype.getLocale())) continue;
2461+
if (applicableSubtype != null) {
2462+
if (systemLocale.equals(applicableSubtype.getLocale())) continue;
2463+
if (!systemLocale.equals(locale)) continue;
2464+
}
24632465
applicableModeAndSubtypesMap.put(mode, subtype);
24642466
if (!containsKeyboardSubtype
24652467
&& SUBTYPE_MODE_KEYBOARD.equalsIgnoreCase(subtype.getMode())) {

0 commit comments

Comments
 (0)