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

Commit 867dcbfb authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Call StatusBarManagerInternal methods only for the current IME user

With recent CLs we now started triggering methods like

 * InputMethodManagerService#hideStatusBarIconLocked()
 * InputMethodManagerService#updateSystemUiLocked()
 * InputMethodManagerService#updateStatusIcon()

not only for the current IME user but also for any running background
user. These methods eventually trigger the following three methods.

 * StatusBarManagerInternal#setIcon
 * StatusBarManagerInternal#setIconVisibility
 * StatusBarManagerInternal#setImeWindowStatus

At least on phones and tablets apparently they are not ready to be
used by multiple users on multiple displays at the same time. To
minimize the risk of confusing existing SysUI implementations, let's
call the above methods only for the current IME user unless

  InputMethodManagerService#mConcurrentMultiUserModeEnabled

is set to true.

For concurrent multi-user mode, the corresponding SysUI is responsible
for making sure that it would not be messed up.

Bug: 357178609
Test: presubmit
Flag: android.view.inputmethod.concurrent_input_methods
Change-Id: I5918e074a833a2dd6bc3e2555995b6461931b438
parent 56394c58
Loading
Loading
Loading
Loading
+19 −4
Original line number Diff line number Diff line
@@ -1443,7 +1443,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                final int currentUserId = mCurrentUserId;
                mStatusBarManagerInternal =
                        LocalServices.getService(StatusBarManagerInternal.class);
                hideStatusBarIconLocked();
                hideStatusBarIconLocked(currentUserId);
                final var bindingController = getInputMethodBindingController(currentUserId);
                updateSystemUiLocked(bindingController.getImeWindowVis(),
                        bindingController.getBackDisposition(), currentUserId);
@@ -2586,7 +2586,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            userData.mEnabledAccessibilitySessions.clear();
            scheduleNotifyImeUidToAudioService(Process.INVALID_UID);
        }
        hideStatusBarIconLocked();
        hideStatusBarIconLocked(userId);
        getUserData(userId).mInFullscreenMode = false;
        mWindowManagerInternal.setDismissImeOnBackKeyPressed(false);
        scheduleResetStylusHandwriting();
@@ -2597,6 +2597,11 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            @DrawableRes int iconId, @NonNull UserData userData) {
        final int userId = userData.mUserId;
        synchronized (ImfLock.class) {
            // To minimize app compat risk, ignore background users' request for single-user mode.
            // TODO(b/357178609): generalize the logic and remove this special rule.
            if (!mConcurrentMultiUserModeEnabled && userId != mCurrentUserId) {
                return;
            }
            if (!calledWithValidTokenLocked(token, userData)) {
                return;
            }
@@ -2604,7 +2609,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            try {
                if (iconId == 0) {
                    if (DEBUG) Slog.d(TAG, "hide the small icon for the input method");
                    hideStatusBarIconLocked();
                    hideStatusBarIconLocked(userId);
                } else if (packageName != null) {
                    if (DEBUG) Slog.d(TAG, "show a small icon for the input method");
                    final PackageManager userAwarePackageManager =
@@ -2632,7 +2637,12 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
    }

    @GuardedBy("ImfLock.class")
    private void hideStatusBarIconLocked() {
    private void hideStatusBarIconLocked(@UserIdInt int userId) {
        // To minimize app compat risk, ignore background users' request for single-user mode.
        // TODO(b/357178609): generalize the logic and remove this special rule.
        if (!mConcurrentMultiUserModeEnabled && userId != mCurrentUserId) {
            return;
        }
        if (mStatusBarManagerInternal != null) {
            mStatusBarManagerInternal.setIconVisibility(mSlotIme, false);
        }
@@ -2839,6 +2849,11 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.

    @GuardedBy("ImfLock.class")
    private void updateSystemUiLocked(int vis, int backDisposition, @UserIdInt int userId) {
        // To minimize app compat risk, ignore background users' request for single-user mode.
        // TODO(b/357178609): generalize the logic and remove this special rule.
        if (!mConcurrentMultiUserModeEnabled && userId != mCurrentUserId) {
            return;
        }
        final var userData = getUserData(userId);
        final var bindingController = userData.mBindingController;
        final var curToken = bindingController.getCurToken();