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

Commit 9a302201 authored by Felix Stern's avatar Felix Stern
Browse files

Redirecting hide call from IMMS to client

Instead of calling directly into hideCurrentInputLocked, we should call
setImeVisibilityOnFocusedWindowClient, to make sure that the hide
request is synced with InsetsController.

Bug: 298172246
Test: atest CtsInputMethodTestCases
Flag: android.view.inputmethod.refactor_insets_controller
Change-Id: I84b3b26ad0099c7ef3f1ecb4278c800ccee71bcf
parent 61d48932
Loading
Loading
Loading
Loading
+30 −9
Original line number Diff line number Diff line
@@ -1826,8 +1826,14 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            @NonNull UserData userData) {
        final int userId = userData.mUserId;
        if (userData.mCurClient == client) {
            if (Flags.refactorInsetsController()) {
                final var statsToken = createStatsTokenForFocusedClient(false /* show */,
                        SoftInputShowHideReason.HIDE_REMOVE_CLIENT, userId);
                setImeVisibilityOnFocusedWindowClient(false, userData, statsToken);
            } else {
                hideCurrentInputLocked(userData.mImeBindingState.mFocusedWindow, 0 /* flags */,
                        SoftInputShowHideReason.HIDE_REMOVE_CLIENT, userId);
            }
            if (userData.mBoundToMethod) {
                userData.mBoundToMethod = false;
                final var userBindingController = userData.mBindingController;
@@ -2097,8 +2103,14 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
        }

        if (visibilityStateComputer.getImePolicy().isImeHiddenByDisplayPolicy()) {
            if (Flags.refactorInsetsController()) {
                final var statsToken = createStatsTokenForFocusedClient(false /* show */,
                        SoftInputShowHideReason.HIDE_DISPLAY_IME_POLICY_HIDE, userId);
                setImeVisibilityOnFocusedWindowClient(false, userData, statsToken);
            } else {
                hideCurrentInputLocked(userData.mImeBindingState.mFocusedWindow, 0 /* flags */,
                        SoftInputShowHideReason.HIDE_DISPLAY_IME_POLICY_HIDE, userId);
            }
            return InputBindResult.NO_IME;
        }

@@ -3855,8 +3867,17 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                        Slog.w(TAG, "If you need to impersonate a foreground user/profile from"
                                + " a background user, use EditorInfo.targetInputMethodUser with"
                                + " INTERACT_ACROSS_USERS_FULL permission.");

                        if (Flags.refactorInsetsController()) {
                            final var statsToken = createStatsTokenForFocusedClient(
                                    false /* show */, SoftInputShowHideReason.HIDE_INVALID_USER,
                                    userId);
                            setImeVisibilityOnFocusedWindowClient(false, userData, statsToken);
                        } else {
                            hideCurrentInputLocked(userData.mImeBindingState.mFocusedWindow,
                                0 /* flags */, SoftInputShowHideReason.HIDE_INVALID_USER, userId);
                                    0 /* flags */, SoftInputShowHideReason.HIDE_INVALID_USER,
                                    userId);
                        }
                        return InputBindResult.INVALID_USER;
                    }

@@ -4993,7 +5014,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                        setImeVisibilityOnFocusedWindowClient(false, userData,
                                null /* TODO(b/353463205) check statsToken */);
                    } else {

                        hideCurrentInputLocked(userData.mImeBindingState.mFocusedWindow,
                                0 /* flags */, reason, userId);
                    }
@@ -6688,8 +6708,9 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                    final InputMethodSettings settings = InputMethodSettingsRepository.get(userId);
                    final var userData = getUserData(userId);
                    if (Flags.refactorInsetsController()) {
                        setImeVisibilityOnFocusedWindowClient(false, userData,
                                null /* TODO(b329229469) initialize statsToken here? */);
                        final var statsToken = createStatsTokenForFocusedClient(false /* show */,
                                SoftInputShowHideReason.HIDE_RESET_SHELL_COMMAND, userId);
                        setImeVisibilityOnFocusedWindowClient(false, userData, statsToken);
                    } else {
                        hideCurrentInputLocked(userData.mImeBindingState.mFocusedWindow,
                                0 /* flags */,