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

Commit 5cab3691 authored by Cosmin Băieș's avatar Cosmin Băieș
Browse files

Remove IME_VISIBLE_IMPERCEPTIBLE

This was originally added in [1] to provide an early signal to taskbar
that the IME is going to be shown. However, this bypasses all the checks
from NavBarHelper.isImeVisible related to keyguard. Moreover, depending
of the timing between getting IME_VISIBLE and updating the perceptible
value, this could lead to the issue from b/158079255, where the taskbar
considers the IME visible too early.

The perceptible state is based on the IME insets being at least
partially animated in, and at least partially opaque. This can only be
updated during the IME show/hide animation.

The IME_VISIBLE flag is set when calling
InputMethodService.showSoftInput and reset when calling hideSoftInput.
For the show flow, this is always before starting the animation. For the
hide flow, this used to be before starting the animation, but with the
insets refactor from [2], this is now after calling the animation.

This simplifies the code by reverting it to the state from [3]. However,
it does mean that the taskbar will be hidden slightly later, after the
IME becomes perceptible, but it will be shown faster, after the IME
becomes not perceptible.

  [1]: I39c15578ed3e5b729f4645ad76988b113f0b57a6
  [2]: I8e3a74ee579f085cb582040fdba725e7a63d6b85
  [3]: I4dc9d6513d0559156f7da39244f3fc5ebc952ed4

Flag: EXEMPT bugfix
Test: show IME with pinned taskbar, switch across apps that previously
  had the IME open, show and hide the IME and observe taskbar updates
Bug: 390251355
Change-Id: Ib5a22d493d2c04e3644f3d268a3fbc073b0ebf22
parent fc2d0835
Loading
Loading
Loading
Loading
+1 −11
Original line number Diff line number Diff line
@@ -527,21 +527,12 @@ public class InputMethodService extends AbstractInputMethodService {
    public static final int IME_ACTIVE = 1 << 0;

    /**
     * The IME is perceptibly visible to the user.
     * The IME is visible.
     *
     * @hide
     */
    public static final int IME_VISIBLE = 1 << 1;

    /**
     * The IME is visible, but not yet perceptible to the user (e.g. fading in)
     * by {@link android.view.WindowInsetsController}.
     *
     * @see InputMethodManager#reportPerceptible
     * @hide
     */
    public static final int IME_VISIBLE_IMPERCEPTIBLE = 1 << 2;

    /**
     * The IME window visibility state.
     *
@@ -550,7 +541,6 @@ public class InputMethodService extends AbstractInputMethodService {
    @IntDef(flag = true, prefix = { "IME_" }, value = {
            IME_ACTIVE,
            IME_VISIBLE,
            IME_VISIBLE_IMPERCEPTIBLE,
    })
    public @interface ImeWindowVisibility {}

+1 −4
Original line number Diff line number Diff line
@@ -44,7 +44,6 @@ import android.app.StatusBarManager.WindowVisibleState;
import android.content.Context;
import android.graphics.Rect;
import android.hardware.display.DisplayManager;
import android.inputmethodservice.InputMethodService;
import android.inputmethodservice.InputMethodService.BackDispositionMode;
import android.inputmethodservice.InputMethodService.ImeWindowVisibility;
import android.os.Handler;
@@ -503,9 +502,7 @@ public class TaskbarDelegate implements CommandQueue.Callbacks,
    @Override
    public void setImeWindowStatus(int displayId, @ImeWindowVisibility int vis,
            @BackDispositionMode int backDisposition, boolean showImeSwitcher) {
        // Count imperceptible changes as visible so we transition taskbar out quickly.
        final boolean isImeVisible = mNavBarHelper.isImeVisible(vis)
                || (vis & InputMethodService.IME_VISIBLE_IMPERCEPTIBLE) != 0;
        final boolean isImeVisible = mNavBarHelper.isImeVisible(vis);
        final int flags = Utilities.updateNavbarFlagsFromIme(mNavbarFlags, backDisposition,
                isImeVisible, showImeSwitcher);
        if (flags == mNavbarFlags) {
+1 −6
Original line number Diff line number Diff line
@@ -2902,12 +2902,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
        final long ident = Binder.clearCallingIdentity();
        try {
            if (windowPerceptible != null && !windowPerceptible) {
                if ((vis & InputMethodService.IME_VISIBLE) != 0) {
                vis &= ~InputMethodService.IME_VISIBLE;
                    vis |= InputMethodService.IME_VISIBLE_IMPERCEPTIBLE;
                }
            } else {
                vis &= ~InputMethodService.IME_VISIBLE_IMPERCEPTIBLE;
            }
            final var curId = bindingController.getCurId();
            // TODO(b/305849394): Make mMenuController multi-user aware.