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

Commit 7e6a7855 authored by Liran Binyamin's avatar Liran Binyamin Committed by Android (Google) Code Review
Browse files

Merge "Fix IME visibility issue when device is locked" into main

parents c51923ac 7b80be55
Loading
Loading
Loading
Loading
+26 −2
Original line number Diff line number Diff line
@@ -640,6 +640,14 @@ public class BubbleController implements ConfigurationChangeListener,
        mOnImeHidden = onImeHidden;
        mBubblePositioner.setImeVisible(false /* visible */, 0 /* height */);
        int displayId = mWindowManager.getDefaultDisplay().getDisplayId();
        // if the device is locked we can't use the status bar service to hide the IME because
        // the IME state is frozen and it will lead to internal IME state going out of sync. This
        // will make the IME visible when the device is unlocked. Instead we use
        // DisplayImeController directly to make sure the state is correct when the device unlocks.
        if (isDeviceLocked()) {
            mDisplayImeController.hideImeForBubblesWhenLocked(displayId);
            return;
        }
        try {
            mBarService.hideCurrentInputMethodForBubbles(displayId);
        } catch (RemoteException e) {
@@ -679,9 +687,21 @@ public class BubbleController implements ConfigurationChangeListener,
                        ? mNotifEntryToExpandOnShadeUnlock.getKey() : "null"));
        mIsStatusBarShade = isShade;
        if (!mIsStatusBarShade && didChange) {
            // Only collapse stack on change
            if (mBubbleData.isExpanded()) {
                // If the IME is visible, hide it first and then collapse.
                if (mBubblePositioner.isImeVisible()) {
                    hideCurrentInputMethod(this::collapseStack);
                } else {
                    collapseStack();
                }
            } else if (mOnImeHidden != null) {
                // a request to collapse started before we're notified that the device is locking.
                // we're currently waiting for the IME to collapse, before mOnImeHidden can be
                // executed, which may not happen since the screen may already be off. hide the IME
                // immediately now that we're locked and pass the same runnable so it can complete.
                hideCurrentInputMethod(mOnImeHidden);
            }
        }

        if (mNotifEntryToExpandOnShadeUnlock != null) {
            expandStackAndSelectBubble(mNotifEntryToExpandOnShadeUnlock);
@@ -2483,6 +2503,10 @@ public class BubbleController implements ConfigurationChangeListener,
        mBubbleData.setSelectedBubbleAndExpandStack(bubbleToSelect);
    }

    private boolean isDeviceLocked() {
        return !mIsStatusBarShade;
    }

    /**
     * Description of current bubble state.
     */
+6 −0
Original line number Diff line number Diff line
@@ -224,6 +224,12 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
        }
    }

    /** Hides the IME for Bubbles when the device is locked. */
    public void hideImeForBubblesWhenLocked(int displayId) {
        PerDisplay pd = mImePerDisplay.get(displayId);
        pd.setImeInputTargetRequestedVisibility(false, pd.getImeSourceControl().getImeStatsToken());
    }

    /** An implementation of {@link IDisplayWindowInsetsController} for a given display id. */
    public class PerDisplay implements DisplayInsetsController.OnInsetsChangedListener {
        final int mDisplayId;