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

Commit 930e5d77 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Inline IMMS#hasAttachedClient() with making it multi-user aware

This CL inlines

  InputMethodManagerService#hasAttachedClient()

with also propagating the correct user ID rather than always using

  InputMethodManagerService#mCurrentUserId.

The observable behavior should remain to be the same for single user
mode, and for concurrent multi-user mode the new behavior should be
the right one.

Bug: 350386877
Test: presubmit
Flag: android.view.inputmethod.concurrent_input_methods
Change-Id: I9befe37eac3d40d0140f063305a9b92c3bf1f8dc
parent 850a834c
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -172,6 +172,7 @@ final class DefaultImeVisibilityApplier {
            @ImeVisibilityStateComputer.VisibilityState int state,
            @SoftInputShowHideReason int reason, @UserIdInt int userId) {
        final var bindingController = mService.getInputMethodBindingController(userId);
        final var userData = mService.getUserData(userId);
        final int displayIdToShowIme = bindingController.getDisplayIdToShowIme();
        switch (state) {
            case STATE_SHOW_IME:
@@ -184,7 +185,7 @@ final class DefaultImeVisibilityApplier {
                break;
            case STATE_HIDE_IME:
                if (!Flags.refactorInsetsController()) {
                    if (mService.hasAttachedClient()) {
                    if (userData.mCurClient != null) {
                        ImeTracker.forLogging().onProgress(statsToken,
                                ImeTracker.PHASE_SERVER_APPLY_IME_VISIBILITY);
                        // IMMS only knows of focused window, not the actual IME target.
+0 −9
Original line number Diff line number Diff line
@@ -1856,15 +1856,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
        }
    }

    /**
     * {@code true} when a {@link ClientState} has attached from starting the
     * input connection.
     */
    @GuardedBy("ImfLock.class")
    boolean hasAttachedClient() {
        return getUserData(mCurrentUserId).mCurClient != null;
    }

    @VisibleForTesting
    void setAttachedClientForTesting(@NonNull ClientState cs) {
        synchronized (ImfLock.class) {