Skip to content

Commit af8139e

Browse files
satok16Android (Google) Code Review
authored andcommitted
Merge "Fix the behavior for choosing new default IME not to choose an auxiliary IME as the default IME"
2 parents f6497e4 + dc9ddae commit af8139e

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ public void executeMessage(Message msg) {
574574
}
575575
}
576576
if (defIm == null && mMethodList.size() > 0) {
577-
defIm = mMethodList.get(0);
577+
defIm = getMostApplicableDefaultIMELocked();
578578
Slog.i(TAG, "No default found, using " + defIm.getId());
579579
}
580580
if (defIm != null) {
@@ -1925,19 +1925,26 @@ private static ArrayList<InputMethodSubtype> getOverridingImplicitlyEnabledSubty
19251925
return subtypes;
19261926
}
19271927

1928-
private boolean chooseNewDefaultIMELocked() {
1928+
private InputMethodInfo getMostApplicableDefaultIMELocked() {
19291929
List<InputMethodInfo> enabled = mSettings.getEnabledInputMethodListLocked();
19301930
if (enabled != null && enabled.size() > 0) {
19311931
// We'd prefer to fall back on a system IME, since that is safer.
19321932
int i=enabled.size();
19331933
while (i > 0) {
19341934
i--;
1935-
if ((enabled.get(i).getServiceInfo().applicationInfo.flags
1936-
& ApplicationInfo.FLAG_SYSTEM) != 0) {
1935+
final InputMethodInfo imi = enabled.get(i);
1936+
if (isSystemIme(imi) && !imi.isAuxiliaryIme()) {
19371937
break;
19381938
}
19391939
}
1940-
InputMethodInfo imi = enabled.get(i);
1940+
return enabled.get(i);
1941+
}
1942+
return null;
1943+
}
1944+
1945+
private boolean chooseNewDefaultIMELocked() {
1946+
final InputMethodInfo imi = getMostApplicableDefaultIMELocked();
1947+
if (imi != null) {
19411948
if (DEBUG) {
19421949
Slog.d(TAG, "New default IME was selected: " + imi.getId());
19431950
}

0 commit comments

Comments
 (0)