Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b182995d authored by Adrian Roos's avatar Adrian Roos
Browse files

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
parent c728095c
Loading
Loading
Loading
Loading
+14 −12
Original line number Diff line number Diff line
@@ -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

                        // 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);
                        }
                        for (InputMethodInfo info : defaultEnabled) {
                            setInputMethodEnabledLocked(info.getId(), true);
                        }
                        // Choose new default IME, reset to none if no IME available.
                        if (!chooseNewDefaultIMELocked()) {
                            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);
                        }
                        // Re-enable with default enabled IMEs.
                        for (InputMethodInfo imi : InputMethodInfoUtils.getDefaultEnabledImes(
                                mContext, mMethodList)) {
                            setInputMethodEnabledLocked(imi.getId(), true);
                        }
                        updateInputMethodsFromSettingsLocked(true /* enabledMayChange */);
                        InputMethodUtils.setNonSelectedSystemImesDisabledUntilUsed(