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

Commit b4ddeb0e authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Always propagate userId to InputMethodMenuController" into main

parents b41ce4ef 0bece904
Loading
Loading
Loading
Loading
+6 −12
Original line number Diff line number Diff line
@@ -619,7 +619,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            case Settings.Secure.SHOW_IME_WITH_HARD_KEYBOARD: {
                if (!mNewInputMethodSwitcherMenuEnabled) {
                    if (userId == mCurrentUserId) {
                        mMenuController.updateKeyboardFromSettingsLocked();
                        mMenuController.updateKeyboardFromSettingsLocked(userId);
                    }
                }
                break;
@@ -693,7 +693,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                                senderUserId);
                    }
                } else {
                    mMenuController.hideInputMethodMenu();
                    mMenuController.hideInputMethodMenu(senderUserId);
                }
            } else {
                Slog.w(TAG, "Unexpected intent " + intent);
@@ -1222,12 +1222,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
        }
    }

    @GuardedBy("ImfLock.class")
    @UserIdInt
    int getCurrentImeUserIdLocked() {
        return mCurrentUserId;
    }

    private final class InkWindowInitializer implements Runnable {
        public void run() {
            synchronized (ImfLock.class) {
@@ -1826,7 +1820,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            if (mNewInputMethodSwitcherMenuEnabled) {
                mMenuControllerNew.hide(bindingController.getCurTokenDisplayId(), userId);
            } else {
                mMenuController.hideInputMethodMenuLocked();
                mMenuController.hideInputMethodMenuLocked(userId);
            }
        }
    }
@@ -2860,7 +2854,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
    void updateFromSettingsLocked(boolean enabledMayChange, @UserIdInt int userId) {
        updateInputMethodsFromSettingsLocked(enabledMayChange, userId);
        if (!mNewInputMethodSwitcherMenuEnabled) {
            mMenuController.updateKeyboardFromSettingsLocked();
            mMenuController.updateKeyboardFromSettingsLocked(userId);
        }
    }

@@ -5071,7 +5065,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            mMenuControllerNew.show(menuItems, selectedIndex, displayId, userId);
        } else {
            mMenuController.showInputMethodMenuLocked(showAuxSubtypes, displayId,
                    lastInputMethodId, lastInputMethodSubtypeId, imList);
                    lastInputMethodId, lastInputMethodSubtypeId, imList, userId);
        }
    }

@@ -5948,7 +5942,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                        final var bindingController = getInputMethodBindingController(userId);
                        mMenuControllerNew.hide(bindingController.getCurTokenDisplayId(), userId);
                    } else {
                        mMenuController.hideInputMethodMenuLocked();
                        mMenuController.hideInputMethodMenuLocked(userId);
                    }
                }
            }
+15 −13
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static com.android.server.inputmethod.InputMethodUtils.NOT_A_SUBTYPE_ID;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -77,13 +78,12 @@ final class InputMethodMenuController {
    @GuardedBy("ImfLock.class")
    void showInputMethodMenuLocked(boolean showAuxSubtypes, int displayId,
            String preferredInputMethodId, int preferredInputMethodSubtypeId,
            @NonNull List<ImeSubtypeListItem> imList) {
            @NonNull List<ImeSubtypeListItem> imList, @UserIdInt int userId) {
        if (DEBUG) Slog.v(TAG, "Show switching menu. showAuxSubtypes=" + showAuxSubtypes);

        final int userId = mService.getCurrentImeUserIdLocked();
        final var bindingController = mService.getInputMethodBindingController(userId);

        hideInputMethodMenuLocked();
        hideInputMethodMenuLocked(userId);

        if (preferredInputMethodSubtypeId == NOT_A_SUBTYPE_ID) {
            final InputMethodSubtype currentSubtype =
@@ -131,7 +131,7 @@ final class InputMethodMenuController {
        }
        final Context dialogWindowContext = mDialogWindowContext.get(displayId);
        mDialogBuilder = new AlertDialog.Builder(dialogWindowContext);
        mDialogBuilder.setOnCancelListener(dialog -> hideInputMethodMenu());
        mDialogBuilder.setOnCancelListener(dialog -> hideInputMethodMenu(userId));

        final Context dialogContext = mDialogBuilder.getContext();
        final TypedArray a = dialogContext.obtainStyledAttributes(null,
@@ -162,7 +162,7 @@ final class InputMethodMenuController {
                    isChecked, userId);
            // Ensure that the input method dialog is dismissed when changing
            // the hardware keyboard state.
            hideInputMethodMenu();
            hideInputMethodMenu(userId);
        });

        // Fill the list items with onClick listener, which takes care of IME (and subtype)
@@ -185,7 +185,7 @@ final class InputMethodMenuController {
                    }
                    mService.setInputMethodLocked(im.getId(), subtypeId, userId);
                }
                hideInputMethodMenuLocked();
                hideInputMethodMenuLocked(userId);
            }
        };
        mDialogBuilder.setSingleChoiceItems(adapter, checkedItem, choiceListener);
@@ -209,10 +209,10 @@ final class InputMethodMenuController {
        mSwitchingDialog.show();
    }

    void updateKeyboardFromSettingsLocked() {
    void updateKeyboardFromSettingsLocked(@UserIdInt int userId) {
        mShowImeWithHardKeyboard =
                SecureSettingsWrapper.getBoolean(Settings.Secure.SHOW_IME_WITH_HARD_KEYBOARD,
                        false, mService.getCurrentImeUserIdLocked());
                        false, userId);
        if (mSwitchingDialog != null && mSwitchingDialogTitleView != null
                && mSwitchingDialog.isShowing()) {
            final Switch hardKeySwitch = mSwitchingDialogTitleView.findViewById(
@@ -223,18 +223,22 @@ final class InputMethodMenuController {

    /**
     * Hides the input method switcher menu.
     *
     * @param userId user ID for this operation
     */
    void hideInputMethodMenu() {
    void hideInputMethodMenu(@UserIdInt int userId) {
        synchronized (ImfLock.class) {
            hideInputMethodMenuLocked();
            hideInputMethodMenuLocked(userId);
        }
    }

    /**
     * Hides the input method switcher menu, synchronised version of {@link #hideInputMethodMenu}.
     *
     * @param userId user ID for this operation
     */
    @GuardedBy("ImfLock.class")
    void hideInputMethodMenuLocked() {
    void hideInputMethodMenuLocked(@UserIdInt int userId) {
        if (DEBUG) Slog.v(TAG, "Hide switching menu");

        if (mSwitchingDialog != null) {
@@ -242,8 +246,6 @@ final class InputMethodMenuController {
            mSwitchingDialog = null;
            mSwitchingDialogTitleView = null;

            // TODO(b/305849394): Make InputMethodMenuController multi-user aware
            final int userId = mService.getCurrentImeUserIdLocked();
            mService.updateSystemUiLocked(userId);
            mService.sendOnNavButtonFlagsChangedToAllImesLocked();
            mDialogBuilder = null;