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

Commit 63c7f505 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Let IMMS#updateSystemUiLocked() take a user ID

As a preparation befor making IMMS#mMenuController multi-user aware,
this CL introduces a variant of

  InputMethodManagerService#updateSystemUiLocked(),

which takes a user ID as an input parameter.

This is a mechanical refactoring CL with no behavior change expected.

Bug: 305849394
Test: presubmit
Change-Id: Ib2a93992e9abe23f1ecc9f529f25ce6dda3cb556
parent 7695a1d2
Loading
Loading
Loading
Loading
+16 −7
Original line number Diff line number Diff line
@@ -2847,14 +2847,22 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
    // Caution! This method is called in this class. Handle multi-user carefully
    @GuardedBy("ImfLock.class")
    private void updateSystemUiLocked(int vis, int backDisposition) {
        if (getCurTokenLocked() == null) {
        updateSystemUiLocked(vis, backDisposition, mCurrentUserId);
    }

    @GuardedBy("ImfLock.class")
    private void updateSystemUiLocked(int vis, int backDisposition, @UserIdInt int userId) {
        final var bindingController = getInputMethodBindingController(userId);
        final var curToken = bindingController.getCurToken();
        if (curToken == null) {
            return;
        }
        final int curTokenDisplayId = bindingController.getCurTokenDisplayId();
        if (DEBUG) {
            Slog.d(TAG, "IME window vis: " + vis
                    + " active: " + (vis & InputMethodService.IME_ACTIVE)
                    + " inv: " + (vis & InputMethodService.IME_INVISIBLE)
                    + " displayId: " + getCurTokenDisplayIdLocked());
                    + " displayId: " + curTokenDisplayId);
        }
        final IBinder focusedWindowToken = mImeBindingState != null
                ? mImeBindingState.mFocusedWindow : null;
@@ -2873,17 +2881,18 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            } else {
                vis &= ~InputMethodService.IME_VISIBLE_IMPERCEPTIBLE;
            }
            final var curId = getInputMethodBindingController(mCurrentUserId).getCurId();
            final var curId = bindingController.getCurId();
            // TODO(b/305849394): Make mMenuController multi-user aware.
            if (mMenuController.getSwitchingDialogLocked() != null
                    || !Objects.equals(curId, getSelectedMethodIdLocked())) {
                    || !Objects.equals(curId, bindingController.getSelectedMethodId())) {
                // When the IME switcher dialog is shown, or we are switching IMEs,
                // 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, mCurrentUserId);
            final boolean needsToShowImeSwitcher = shouldShowImeSwitcherLocked(vis, userId);
            if (mStatusBarManagerInternal != null) {
                mStatusBarManagerInternal.setImeWindowStatus(getCurTokenDisplayIdLocked(),
                        getCurTokenLocked(), vis, backDisposition, needsToShowImeSwitcher);
                mStatusBarManagerInternal.setImeWindowStatus(curTokenDisplayId,
                        curToken, vis, backDisposition, needsToShowImeSwitcher);
            }
        } finally {
            Binder.restoreCallingIdentity(ident);