IMF: Avoid config changes when resetting IMEs in IMMS

Fixes an issue where "cmd input_method ime reset" triggers
a configuration change through Configuration.keyboardHidden.

Bug: 266708619
Test: atest CtsInputMethodTestCases
Change-Id: I4347c77d78593c9e1a1c2f5172ab7874aa4ba4d5
This commit is contained in:
Adrian Roos
2023-03-02 13:57:55 +00:00
parent c728095ce2
commit b182995d3b

View File

@@ -6394,19 +6394,21 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
0 /* flags */, null /* resultReceiver */,
SoftInputShowHideReason.HIDE_RESET_SHELL_COMMAND);
mBindingController.unbindCurrentMethod();
// Reset the current IME
resetSelectedInputMethodAndSubtypeLocked(null);
// Also reset the settings of the current IME
mSettings.putSelectedInputMethod(null);
// Disable all enabled IMEs.
for (InputMethodInfo inputMethodInfo :
mSettings.getEnabledInputMethodListLocked()) {
setInputMethodEnabledLocked(inputMethodInfo.getId(), false);
// Enable default IMEs, disable others
var toDisable = mSettings.getEnabledInputMethodListLocked();
var defaultEnabled = InputMethodInfoUtils.getDefaultEnabledImes(
mContext, mMethodList);
toDisable.removeAll(defaultEnabled);
for (InputMethodInfo info : toDisable) {
setInputMethodEnabledLocked(info.getId(), false);
}
// Re-enable with default enabled IMEs.
for (InputMethodInfo imi : InputMethodInfoUtils.getDefaultEnabledImes(
mContext, mMethodList)) {
setInputMethodEnabledLocked(imi.getId(), true);
for (InputMethodInfo info : defaultEnabled) {
setInputMethodEnabledLocked(info.getId(), true);
}
// Choose new default IME, reset to none if no IME available.
if (!chooseNewDefaultIMELocked()) {
resetSelectedInputMethodAndSubtypeLocked(null);
}
updateInputMethodsFromSettingsLocked(true /* enabledMayChange */);
InputMethodUtils.setNonSelectedSystemImesDisabledUntilUsed(