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

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

Merge "Let IMMS#shouldShowImeSwitcherLocked() take a user ID" into main

parents bc596251 7695a1d2
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -2695,25 +2695,27 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
        final boolean canImeDrawsImeNavBar =
                mImeDrawsImeNavBarRes != null && mImeDrawsImeNavBarRes.get() && hasNavigationBar;
        final boolean shouldShowImeSwitcherWhenImeIsShown = shouldShowImeSwitcherLocked(
                InputMethodService.IME_ACTIVE | InputMethodService.IME_VISIBLE);
                InputMethodService.IME_ACTIVE | InputMethodService.IME_VISIBLE,
                mCurrentUserId);
        return (canImeDrawsImeNavBar ? InputMethodNavButtonFlags.IME_DRAWS_IME_NAV_BAR : 0)
                | (shouldShowImeSwitcherWhenImeIsShown
                ? InputMethodNavButtonFlags.SHOW_IME_SWITCHER_WHEN_IME_IS_SHOWN : 0);
    }

    @GuardedBy("ImfLock.class")
    private boolean shouldShowImeSwitcherLocked(int visibility) {
    private boolean shouldShowImeSwitcherLocked(int visibility, @UserIdInt int userId) {
        if (!mShowOngoingImeSwitcherForPhones) return false;
        // When the IME switcher dialog is shown, the IME switcher button should be hidden.
        // TODO(b/305849394): Make mMenuController multi-user aware.
        if (mMenuController.getSwitchingDialogLocked() != null) return false;
        // When we are switching IMEs, the IME switcher button should be hidden.
        final var bindingController = getInputMethodBindingController(mCurrentUserId);
        final var bindingController = getInputMethodBindingController(userId);
        if (!Objects.equals(bindingController.getCurId(),
                bindingController.getSelectedMethodId())) {
            return false;
        }
        if (mWindowManagerInternal.isKeyguardShowingAndNotOccluded()
                && mWindowManagerInternal.isKeyguardSecure(mCurrentUserId)) {
                && mWindowManagerInternal.isKeyguardSecure(userId)) {
            return false;
        }
        if ((visibility & InputMethodService.IME_ACTIVE) == 0
@@ -2730,7 +2732,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            return false;
        }

        final InputMethodSettings settings = InputMethodSettingsRepository.get(mCurrentUserId);
        final InputMethodSettings settings = InputMethodSettingsRepository.get(userId);
        List<InputMethodInfo> imes = settings.getEnabledInputMethodListWithFilter(
                InputMethodInfo::shouldShowInInputMethodPicker);
        final int numImes = imes.size();
@@ -2878,7 +2880,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                // the back button should be in the default state (as if the IME is not shown).
                backDisposition = InputMethodService.BACK_DISPOSITION_ADJUST_NOTHING;
            }
            final boolean needsToShowImeSwitcher = shouldShowImeSwitcherLocked(vis);
            final boolean needsToShowImeSwitcher = shouldShowImeSwitcherLocked(vis, mCurrentUserId);
            if (mStatusBarManagerInternal != null) {
                mStatusBarManagerInternal.setImeWindowStatus(getCurTokenDisplayIdLocked(),
                        getCurTokenLocked(), vis, backDisposition, needsToShowImeSwitcher);