Merge "Fix the behavior for choosing new default IME not to choose an auxiliary IME as the default IME"

This commit is contained in:
satok
2011-10-10 00:59:41 -07:00
committed by Android (Google) Code Review

View File

@@ -574,7 +574,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
} }
} }
if (defIm == null && mMethodList.size() > 0) { if (defIm == null && mMethodList.size() > 0) {
defIm = mMethodList.get(0); defIm = getMostApplicableDefaultIMELocked();
Slog.i(TAG, "No default found, using " + defIm.getId()); Slog.i(TAG, "No default found, using " + defIm.getId());
} }
if (defIm != null) { if (defIm != null) {
@@ -1925,19 +1925,26 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
return subtypes; return subtypes;
} }
private boolean chooseNewDefaultIMELocked() { private InputMethodInfo getMostApplicableDefaultIMELocked() {
List<InputMethodInfo> enabled = mSettings.getEnabledInputMethodListLocked(); List<InputMethodInfo> enabled = mSettings.getEnabledInputMethodListLocked();
if (enabled != null && enabled.size() > 0) { if (enabled != null && enabled.size() > 0) {
// We'd prefer to fall back on a system IME, since that is safer. // We'd prefer to fall back on a system IME, since that is safer.
int i=enabled.size(); int i=enabled.size();
while (i > 0) { while (i > 0) {
i--; i--;
if ((enabled.get(i).getServiceInfo().applicationInfo.flags final InputMethodInfo imi = enabled.get(i);
& ApplicationInfo.FLAG_SYSTEM) != 0) { if (isSystemIme(imi) && !imi.isAuxiliaryIme()) {
break; break;
} }
} }
InputMethodInfo imi = enabled.get(i); return enabled.get(i);
}
return null;
}
private boolean chooseNewDefaultIMELocked() {
final InputMethodInfo imi = getMostApplicableDefaultIMELocked();
if (imi != null) {
if (DEBUG) { if (DEBUG) {
Slog.d(TAG, "New default IME was selected: " + imi.getId()); Slog.d(TAG, "New default IME was selected: " + imi.getId());
} }