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

Commit b8ec0378 authored by Michal Brzezinski's avatar Michal Brzezinski
Browse files

Fixing scrims visible in split shade on lockscreen

This issue occured when we were going to displayed lockscreen directly from expanded shade - compared to turning off the screen and then going to lockscreen after a moment.
Animation didn't have time to fully run and we ended up in not fully clean state of QS. This change forces closing QS and reseting its state when going from unlocked mode to keyguard.

To make it easier to catch similar issues in the future I also added wtf logging which is triggered when we recognize scrims and lockscreen clock visible at the same time.

Also removing mInSplitShade which was just duplicate mSplitShadeEnabled.

Test: NotificationPanelViewControllerTest
Test: display heads-up notification -> long press power button -> lockdown -> see scrims not visible on lockscreen (see b/257930534 for more reproduction steps)
Fixes: 257930534
Change-Id: I79fc78c24d4755d3fc2bbdcf5f4438993a72706b
parent b725e706
Loading
Loading
Loading
Loading
+30 −7
Original line number Diff line number Diff line
@@ -625,7 +625,6 @@ public final class NotificationPanelViewController implements Dumpable {
    private float mLastGesturedOverExpansion = -1;
    /** Whether the current animator is the spring back animation. */
    private boolean mIsSpringBackAnimation;
    private boolean mInSplitShade;
    private float mHintDistance;
    private float mInitialOffsetOnTouch;
    private boolean mCollapsedAndHeadsUpOnDown;
@@ -1061,7 +1060,6 @@ public final class NotificationPanelViewController implements Dumpable {
        mSlopMultiplier = configuration.getScaledAmbiguousGestureMultiplier();
        mHintDistance = mResources.getDimension(R.dimen.hint_move_distance);
        mPanelFlingOvershootAmount = mResources.getDimension(R.dimen.panel_overshoot_amount);
        mInSplitShade = mResources.getBoolean(R.bool.config_use_split_notification_shade);
        mFlingAnimationUtils = mFlingAnimationUtilsBuilder.get()
                .setMaxLengthSeconds(0.4f).build();
        mStatusBarMinHeight = SystemBarUtils.getStatusBarHeight(mView.getContext());
@@ -1836,6 +1834,10 @@ public final class NotificationPanelViewController implements Dumpable {
    public void closeQs() {
        cancelQsAnimation();
        setQsExpansionHeight(mQsMinExpansionHeight);
        // qsExpandImmediate is a safety latch in case we're calling closeQS while we're in the
        // middle of animation - we need to make sure that value is always false when shade if
        // fully collapsed or expanded
        setQsExpandImmediate(false);
    }

    @VisibleForTesting
@@ -1938,7 +1940,7 @@ public final class NotificationPanelViewController implements Dumpable {
        // we want to perform an overshoot animation when flinging open
        final boolean addOverscroll =
                expand
                        && !mInSplitShade // Split shade has its own overscroll logic
                        && !mSplitShadeEnabled // Split shade has its own overscroll logic
                        && mStatusBarStateController.getState() != KEYGUARD
                        && mOverExpansion == 0.0f
                        && vel >= 0;
@@ -2727,8 +2729,10 @@ public final class NotificationPanelViewController implements Dumpable {
     * as well based on the bounds of the shade and QS state.
     */
    private void setQSClippingBounds() {
        final int qsPanelBottomY = calculateQsBottomPosition(computeQsExpansionFraction());
        final boolean qsVisible = (computeQsExpansionFraction() > 0 || qsPanelBottomY > 0);
        float qsExpansionFraction = computeQsExpansionFraction();
        final int qsPanelBottomY = calculateQsBottomPosition(qsExpansionFraction);
        final boolean qsVisible = (qsExpansionFraction > 0 || qsPanelBottomY > 0);
        checkCorrectScrimVisibility(qsExpansionFraction);

        int top = calculateTopQsClippingBound(qsPanelBottomY);
        int bottom = calculateBottomQsClippingBound(top);
@@ -2739,6 +2743,19 @@ public final class NotificationPanelViewController implements Dumpable {
        applyQSClippingBounds(left, top, right, bottom, qsVisible);
    }

    private void checkCorrectScrimVisibility(float expansionFraction) {
        // issues with scrims visible on keyguard occur only in split shade
        if (mSplitShadeEnabled) {
            boolean keyguardViewsVisible = mBarState == KEYGUARD && mKeyguardOnlyContentAlpha == 1;
            // expansionFraction == 1 means scrims are fully visible as their size/visibility depend
            // on QS expansion
            if (expansionFraction == 1 && keyguardViewsVisible) {
                Log.wtf(TAG,
                        "Incorrect state, scrim is visible at the same time when clock is visible");
            }
        }
    }

    private int calculateTopQsClippingBound(int qsPanelBottomY) {
        int top;
        if (mSplitShadeEnabled) {
@@ -4393,7 +4410,7 @@ public final class NotificationPanelViewController implements Dumpable {
        ipw.print("mPanelFlingOvershootAmount="); ipw.println(mPanelFlingOvershootAmount);
        ipw.print("mLastGesturedOverExpansion="); ipw.println(mLastGesturedOverExpansion);
        ipw.print("mIsSpringBackAnimation="); ipw.println(mIsSpringBackAnimation);
        ipw.print("mInSplitShade="); ipw.println(mInSplitShade);
        ipw.print("mSplitShadeEnabled="); ipw.println(mSplitShadeEnabled);
        ipw.print("mHintDistance="); ipw.println(mHintDistance);
        ipw.print("mInitialOffsetOnTouch="); ipw.println(mInitialOffsetOnTouch);
        ipw.print("mCollapsedAndHeadsUpOnDown="); ipw.println(mCollapsedAndHeadsUpOnDown);
@@ -4911,7 +4928,7 @@ public final class NotificationPanelViewController implements Dumpable {
            float maxPanelHeight = getMaxPanelTransitionDistance();
            if (mHeightAnimator == null) {
                // Split shade has its own overscroll logic
                if (mTracking && !mInSplitShade) {
                if (mTracking && !mSplitShadeEnabled) {
                    float overExpansionPixels = Math.max(0, h - maxPanelHeight);
                    setOverExpansionInternal(overExpansionPixels, true /* isFromGesture */);
                }
@@ -5459,6 +5476,12 @@ public final class NotificationPanelViewController implements Dumpable {
                //  - from SHADE to KEYGUARD
                //  - from SHADE_LOCKED to SHADE
                //  - getting notified again about the current SHADE or KEYGUARD state
                if (mSplitShadeEnabled && oldState == SHADE && statusBarState == KEYGUARD) {
                    // user can go to keyguard from different shade states and closing animation
                    // may not fully run - we always want to make sure we close QS when that happens
                    // as we never need QS open in fresh keyguard state
                    closeQs();
                }
                final boolean animatingUnlockedShadeToKeyguard = oldState == SHADE
                        && statusBarState == KEYGUARD
                        && mScreenOffAnimationController.isKeyguardShowDelayed();
+13 −0
Original line number Diff line number Diff line
@@ -1118,6 +1118,19 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
        assertThat(mStatusBarStateController.getState()).isEqualTo(SHADE_LOCKED);
    }

    @Test
    public void testUnlockedSplitShadeTransitioningToKeyguard_closesQS() {
        enableSplitShade(true);
        mStatusBarStateController.setState(SHADE);
        mNotificationPanelViewController.setQsExpanded(true);

        mStatusBarStateController.setState(KEYGUARD);


        assertThat(mNotificationPanelViewController.isQsExpanded()).isEqualTo(false);
        assertThat(mNotificationPanelViewController.isQsExpandImmediate()).isEqualTo(false);
    }

    @Test
    public void testSwitchesToCorrectClockInSinglePaneShade() {
        mStatusBarStateController.setState(KEYGUARD);