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

Commit 836516ff authored by Josh Tsuji's avatar Josh Tsuji
Browse files

Make entire screen touchable if screen off is playing.

Previously we relied upon the panel expansion state to
consume these touches, but something changed with how
that is dispatches, and it now comes in later in the
screen off animation.

This way, we explicitly consume all touches whenever
the animation is playing, and recalculate whether or
not we do that whenever we sleep/wake.

Fixes: 224592908
Test: tap launcher icons right after pressing power
Change-Id: I075c8028e52d6103127c05b60f341fd64ef07634
parent 50d3d730
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -3572,6 +3572,7 @@ public class CentralSurfacesImpl extends CoreStartable implements
            dismissVolumeDialog();
            mWakeUpCoordinator.setFullyAwake(false);
            mKeyguardBypassController.onStartedGoingToSleep();
            mStatusBarTouchableRegionManager.updateTouchableRegion();

            // The unlocked screen off and fold to aod animations might use our LightRevealScrim -
            // we need to be expanded for it to be visible.
@@ -3600,6 +3601,7 @@ public class CentralSurfacesImpl extends CoreStartable implements
                // once we fully woke up.
                updateRevealEffect(true /* wakingUp */);
                updateNotificationPanelTouchState();
                mStatusBarTouchableRegionManager.updateTouchableRegion();

                // If we are waking up during the screen off animation, we should undo making the
                // expanded visible (we did that so the LightRevealScrim would be visible).
+21 −4
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ public final class StatusBarTouchableRegionManager implements Dumpable {
    private final Context mContext;
    private final HeadsUpManagerPhone mHeadsUpManager;
    private final NotificationShadeWindowController mNotificationShadeWindowController;
    private final UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController;

    private boolean mIsStatusBarExpanded = false;
    private boolean mShouldAdjustInsets = false;
@@ -72,7 +73,8 @@ public final class StatusBarTouchableRegionManager implements Dumpable {
            Context context,
            NotificationShadeWindowController notificationShadeWindowController,
            ConfigurationController configurationController,
            HeadsUpManagerPhone headsUpManager
            HeadsUpManagerPhone headsUpManager,
            UnlockedScreenOffAnimationController unlockedScreenOffAnimationController
    ) {
        mContext = context;
        initResources();
@@ -115,6 +117,8 @@ public final class StatusBarTouchableRegionManager implements Dumpable {
        mNotificationShadeWindowController.setForcePluginOpenListener((forceOpen) -> {
            updateTouchableRegion();
        });

        mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController;
    }

    protected void setup(
@@ -179,7 +183,7 @@ public final class StatusBarTouchableRegionManager implements Dumpable {
    /**
     * Set the touchable portion of the status bar based on what elements are visible.
     */
    private void updateTouchableRegion() {
    public void updateTouchableRegion() {
        boolean hasCutoutInset = (mNotificationShadeWindowView != null)
                && (mNotificationShadeWindowView.getRootWindowInsets() != null)
                && (mNotificationShadeWindowView.getRootWindowInsets().getDisplayCutout() != null);
@@ -242,12 +246,25 @@ public final class StatusBarTouchableRegionManager implements Dumpable {
        touchableRegion.union(bounds);
    }

    /**
     * Helper to let us know when calculating the region is not needed because we know the entire
     * screen needs to be touchable.
     */
    private boolean shouldMakeEntireScreenTouchable() {
        // The touchable region is always the full area when expanded, whether we're showing the
        // shade or the bouncer. It's also fully touchable when the screen off animation is playing
        // since we don't want stray touches to go through the light reveal scrim to whatever is
        // underneath.
        return mIsStatusBarExpanded
                || mCentralSurfaces.isBouncerShowing()
                || mUnlockedScreenOffAnimationController.isAnimationPlaying();
    }

    private final OnComputeInternalInsetsListener mOnComputeInternalInsetsListener =
            new OnComputeInternalInsetsListener() {
        @Override
        public void onComputeInternalInsets(ViewTreeObserver.InternalInsetsInfo info) {
            if (mIsStatusBarExpanded || mCentralSurfaces.isBouncerShowing()) {
                // The touchable region is always the full area when expanded
            if (shouldMakeEntireScreenTouchable()) {
                return;
            }