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

Commit a618c087 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Make "ime {enable,disable} --user <userId>" consistent among users

With this CL

  adb shell ime enable --user <userId> <imeId>
  adb shell ime disable --user <userId> <imeId>

start behaving in the same manner across users, meaning that there is
no special behavior when the userId is not IMMS#mCurrentUserId.

No impact is expected on all the tests and manual work in this CL.

Bug: 350386877
Bug: 350834650
Test: manually verified
Flag: EXEMPT refactor
Change-Id: I9efbba6590ae0b586f2e90ab5125da0ad010f7cc
parent 1054f4ec
Loading
Loading
Loading
Loading
+3 −29
Original line number Diff line number Diff line
@@ -6707,36 +6707,8 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
    private boolean handleShellCommandEnableDisableInputMethodInternalLocked(
            @UserIdInt int userId, String imeId, boolean enabled, PrintWriter out,
            PrintWriter error) {
        boolean failedToEnableUnknownIme = false;
        boolean previouslyEnabled = false;
        final InputMethodSettings settings = InputMethodSettingsRepository.get(userId);
        if (userId == mCurrentUserId) {
        if (enabled && !settings.getMethodMap().containsKey(imeId)) {
                failedToEnableUnknownIme = true;
            } else {
                previouslyEnabled = setInputMethodEnabledLocked(imeId, enabled, userId);
            }
        } else {
            if (enabled) {
                if (!settings.getMethodMap().containsKey(imeId)) {
                    failedToEnableUnknownIme = true;
                } else {
                    final String enabledImeIdsStr = settings.getEnabledInputMethodsStr();
                    final String newEnabledImeIdsStr = InputMethodUtils.concatEnabledImeIds(
                            enabledImeIdsStr, imeId);
                    previouslyEnabled = TextUtils.equals(enabledImeIdsStr, newEnabledImeIdsStr);
                    if (!previouslyEnabled) {
                        settings.putEnabledInputMethodsStr(newEnabledImeIdsStr);
                    }
                }
            } else {
                previouslyEnabled =
                        settings.buildAndPutEnabledInputMethodsStrRemovingId(
                                new StringBuilder(),
                                settings.getEnabledInputMethodsAndSubtypeList(), imeId);
            }
        }
        if (failedToEnableUnknownIme) {
            error.print("Unknown input method ");
            error.print(imeId);
            error.println(" cannot be enabled for user #" + userId);
@@ -6745,6 +6717,8 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                    + " failed due to its unrecognized IME ID.");
            return false;
        }

        final boolean previouslyEnabled = setInputMethodEnabledLocked(imeId, enabled, userId);
        out.print("Input method ");
        out.print(imeId);
        out.print(": ");