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

Commit 3535c8dd authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Avoid passing USER_ALL to getInputMethodBindingController()

This CL fixes a bug that sending ACTION_CLOSE_SYSTEM_DIALOGS to
USER_ALL can register user -1 into IMMS#mUserDataRepository.

The root cause was that

  ImmsBroadcastReceiverForAllUsers#onReceive()

had passed senderUserId as is even when it is USER_ALL (-1).

There must be no observable behavior change in the single-user
mode. As for multi-user mode, InputMethodMenuController{,New} are not
yet supported thus there should be no behavior change.

Bug: 350386877
Test: Manually verified
Flag: EXEMPT bug fix
Change-Id: I26093b432d1ea7eb9fb73d9f9f00d503592b252a
parent 0c88439c
Loading
Loading
Loading
Loading
+10 −14
Original line number Diff line number Diff line
@@ -678,22 +678,18 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                }
                // sender userId can be a real user ID or USER_ALL.
                final int senderUserId = pendingResult.getSendingUserId();
                if (senderUserId != UserHandle.USER_ALL) {
                synchronized (ImfLock.class) {
                        if (senderUserId != mCurrentUserId) {
                    if (senderUserId != UserHandle.USER_ALL && senderUserId != mCurrentUserId) {
                        // A background user is trying to hide the dialog. Ignore.
                        return;
                    }
                    }
                }
                    final int userId = mCurrentUserId;
                    if (mNewInputMethodSwitcherMenuEnabled) {
                    synchronized (ImfLock.class) {
                        final var bindingController = getInputMethodBindingController(senderUserId);
                        mMenuControllerNew.hide(bindingController.getCurTokenDisplayId(),
                                senderUserId);
                    }
                        final var bindingController = getInputMethodBindingController(userId);
                        mMenuControllerNew.hide(bindingController.getCurTokenDisplayId(), userId);
                    } else {
                    mMenuController.hideInputMethodMenu(senderUserId);
                        mMenuController.hideInputMethodMenuLocked(userId);
                    }
                }
            } else {
                Slog.w(TAG, "Unexpected intent " + intent);