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

Commit 4714b33b authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Simplify IMMS#updateInputMethodsFromSettingsLocked() a bit

This CL simplifies

  InputMethodManagerService#updateInputMethodsFromSettingsLocked()

a bit by explicitly having a local instance "userId" instead of using

  settings.getUserId()

as a synonym of it.

This is a mechanical refactoring CL, which should have no behavior
change.

Bug: 345519864
Test: presubmit
Flag: EXEMPT refactor
Change-Id: Ic8d803624b90e04a52ddf72381634df4c628a103
parent 2da64f9b
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -2979,10 +2979,11 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.

    @GuardedBy("ImfLock.class")
    void updateInputMethodsFromSettingsLocked(boolean enabledMayChange) {
        final InputMethodSettings settings = InputMethodSettingsRepository.get(mCurrentUserId);
        final int userId = mCurrentUserId;
        final InputMethodSettings settings = InputMethodSettingsRepository.get(userId);
        if (enabledMayChange) {
            final PackageManager userAwarePackageManager = getPackageManagerForUser(mContext,
                    settings.getUserId());
                    userId);

            List<InputMethodInfo> enabled = settings.getEnabledInputMethodList();
            for (int i = 0; i < enabled.size(); i++) {
@@ -3011,20 +3012,19 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.

        if (mDeviceIdToShowIme == DEVICE_ID_DEFAULT) {
            String ime = SecureSettingsWrapper.getString(
                    Settings.Secure.DEFAULT_INPUT_METHOD, null, settings.getUserId());
                    Settings.Secure.DEFAULT_INPUT_METHOD, null, userId);
            String defaultDeviceIme = SecureSettingsWrapper.getString(
                    Settings.Secure.DEFAULT_DEVICE_INPUT_METHOD, null, settings.getUserId());
                    Settings.Secure.DEFAULT_DEVICE_INPUT_METHOD, null, userId);
            if (defaultDeviceIme != null && !Objects.equals(ime, defaultDeviceIme)) {
                if (DEBUG) {
                    Slog.v(TAG, "Current input method " + ime + " differs from the stored default"
                            + " device input method for user " + settings.getUserId()
                            + " device input method for user " + userId
                            + " - restoring " + defaultDeviceIme);
                }
                SecureSettingsWrapper.putString(
                        Settings.Secure.DEFAULT_INPUT_METHOD, defaultDeviceIme,
                        settings.getUserId());
                        Settings.Secure.DEFAULT_INPUT_METHOD, defaultDeviceIme, userId);
                SecureSettingsWrapper.putString(
                        Settings.Secure.DEFAULT_DEVICE_INPUT_METHOD, null, settings.getUserId());
                        Settings.Secure.DEFAULT_DEVICE_INPUT_METHOD, null, userId);
            }
        }

@@ -3050,18 +3050,18 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
        }

        // TODO: Instantiate mSwitchingController for each user.
        if (settings.getUserId() == mSwitchingController.getUserId()) {
        if (userId == mSwitchingController.getUserId()) {
            mSwitchingController.resetCircularListLocked(settings.getMethodMap());
        } else {
            mSwitchingController = InputMethodSubtypeSwitchingController.createInstanceLocked(
                    mContext, settings.getMethodMap(), settings.getUserId());
                    mContext, settings.getMethodMap(), userId);
        }
        // TODO: Instantiate mHardwareKeyboardShortcutController for each user.
        if (settings.getUserId() == mHardwareKeyboardShortcutController.getUserId()) {
        if (userId == mHardwareKeyboardShortcutController.getUserId()) {
            mHardwareKeyboardShortcutController.reset(settings.getMethodMap());
        } else {
            mHardwareKeyboardShortcutController = new HardwareKeyboardShortcutController(
                    settings.getMethodMap(), settings.getUserId());
                    settings.getMethodMap(), userId);
        }
        sendOnNavButtonFlagsChangedLocked();
    }