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

Commit 51b42ea0 authored by Josh Tsuji's avatar Josh Tsuji
Browse files

Fix issue where notifications are visible during screen off if bypass is enabled.

- NotificationWakeUpCoordinator should prioritize screen off doze override.
- We should tell the stack scroll layout to switch to KEYGUARD so that it doesn't show notifs even if bypass is enabled.

Fixes: 190227875
Test: with/without face unlock and bypass
Change-Id: I902692fa6ae417c051a77b248fd3863f51e0bc36
parent 20da155d
Loading
Loading
Loading
Loading
+11 −19
Original line number Diff line number Diff line
@@ -98,8 +98,6 @@ class NotificationWakeUpCoordinator @Inject constructor(
            }
        }

    private var animatingScreenOff = false

    private var collapsedEnoughToHide: Boolean = false

    var pulsing: Boolean = false
@@ -236,11 +234,11 @@ class NotificationWakeUpCoordinator @Inject constructor(
    }

    override fun onDozeAmountChanged(linear: Float, eased: Float) {
        if (overrideDozeAmountIfBypass()) {
        if (overrideDozeAmountIfAnimatingScreenOff(linear)) {
            return
        }

        if (overrideDozeAmountIfAnimatingScreenOff(linear)) {
        if (overrideDozeAmountIfBypass()) {
            return
        }

@@ -267,7 +265,7 @@ class NotificationWakeUpCoordinator @Inject constructor(

    override fun onStateChanged(newState: Int) {
        if (unlockedScreenOffAnimationController.shouldPlayScreenOffAnimation()) {
            if (animatingScreenOff &&
            if (unlockedScreenOffAnimationController.isScreenOffAnimationPlaying() &&
                    state == StatusBarState.KEYGUARD &&
                    newState == StatusBarState.SHADE) {
                // If we're animating the screen off and going from KEYGUARD back to SHADE, the
@@ -275,12 +273,16 @@ class NotificationWakeUpCoordinator @Inject constructor(
                // dozing) so that the notifications are no longer hidden.
                setDozeAmount(0f, 0f)
            }
        }

            animatingScreenOff =
                    state == StatusBarState.SHADE && newState == StatusBarState.KEYGUARD
        if (overrideDozeAmountIfAnimatingScreenOff(mLinearDozeAmount)) {
            return
        }

        if (overrideDozeAmountIfBypass()) {
            return
        }

        overrideDozeAmountIfBypass()
        if (bypassController.bypassEnabled &&
                newState == StatusBarState.KEYGUARD && state == StatusBarState.SHADE_LOCKED &&
            (!statusBarStateController.isDozing || shouldAnimateVisibility())) {
@@ -330,12 +332,7 @@ class NotificationWakeUpCoordinator @Inject constructor(
     * animation. If true, the original doze amount should be ignored.
     */
    private fun overrideDozeAmountIfAnimatingScreenOff(linearDozeAmount: Float): Boolean {
        if (animatingScreenOff) {
            if (linearDozeAmount == 1f) {
                animatingScreenOff = false
                return false
            }

        if (unlockedScreenOffAnimationController.isScreenOffAnimationPlaying()) {
            setDozeAmount(1f, 1f)
            return true
        }
@@ -395,11 +392,6 @@ class NotificationWakeUpCoordinator @Inject constructor(
    override fun onDozingChanged(isDozing: Boolean) {
        if (isDozing) {
            setNotificationsVisible(visible = false, animate = false, increaseSpeed = false)
        } else {
            // We only unset the flag once we fully went asleep. If the user interrupts the
            // animation in the middle, we have to abort the animation as well to make sure
            // the notifications are visible again.
            animatingScreenOff = false
        }
    }

+7 −2
Original line number Diff line number Diff line
@@ -106,6 +106,7 @@ import com.android.systemui.statusbar.phone.HeadsUpAppearanceController;
import com.android.systemui.statusbar.phone.HeadsUpTouchHelper;
import com.android.systemui.statusbar.phone.ShadeController;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.phone.UnlockedScreenOffAnimationController;
import com.android.systemui.statusbar.policy.HeadsUpUtil;
import com.android.systemui.statusbar.policy.ScrollAdapter;
import com.android.systemui.util.Assert;
@@ -455,6 +456,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    private long mNumHeadsUp;
    private NotificationStackScrollLayoutController.TouchHandler mTouchHandler;
    private final FeatureFlags mFeatureFlags;
    private final UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController;
    private boolean mShouldUseSplitNotificationShade;

    private final ExpandableView.OnHeightChangedListener mOnChildHeightChangedListener =
@@ -495,11 +497,13 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
            GroupMembershipManager groupMembershipManager,
            GroupExpansionManager groupExpansionManager,
            AmbientState ambientState,
            FeatureFlags featureFlags) {
            FeatureFlags featureFlags,
            UnlockedScreenOffAnimationController unlockedScreenOffAnimationController) {
        super(context, attrs, 0, 0);
        Resources res = getResources();
        mSectionsManager = notificationSectionsManager;
        mFeatureFlags = featureFlags;
        mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController;
        mShouldUseSplitNotificationShade = shouldUseSplitNotificationShade(mFeatureFlags, res);
        mSectionsManager.initialize(this, LayoutInflater.from(context));
        mSections = mSectionsManager.createSectionsForBuckets();
@@ -600,6 +604,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        RemoteInputController remoteInputController = mRemoteInputManager.getController();
        boolean showFooterView = (showDismissView || mController.hasActiveNotifications())
                && mStatusBarState != StatusBarState.KEYGUARD
                && !mUnlockedScreenOffAnimationController.isScreenOffAnimationPlaying()
                && (remoteInputController == null || !remoteInputController.isRemoteInputActive());
        boolean showHistory = Settings.Secure.getIntForUser(mContext.getContentResolver(),
                Settings.Secure.NOTIFICATION_HISTORY_ENABLED, 0, UserHandle.USER_CURRENT) == 1;
@@ -4606,7 +4611,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable

    @ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
    @VisibleForTesting
    protected void setStatusBarState(int statusBarState) {
    public void setStatusBarState(int statusBarState) {
        mStatusBarState = statusBarState;
        mAmbientState.setStatusBarState(statusBarState);
        updateSpeedBumpIndex();
+2 −1
Original line number Diff line number Diff line
@@ -4314,7 +4314,8 @@ public class NotificationPanelViewController extends PanelViewController {
    /**
     * Reconfigures the shade to show the AOD UI (clock, smartspace, etc). This is called by the
     * screen off animation controller in order to animate in AOD without "actually" fully switching
     * to the KEYGUARD state.
     * to the KEYGUARD state, which is a heavy transition that causes jank as 10+ files react to the
     * change.
     */
    public void showAodUi() {
        setDozing(true /* dozing */, false /* animate */, null);
+4 −1
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ import com.android.systemui.statusbar.notification.row.FooterView;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.KeyguardBypassEnabledProvider;
import com.android.systemui.statusbar.phone.ShadeController;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.phone.UnlockedScreenOffAnimationController;

import org.junit.Assert;
import org.junit.Before;
@@ -105,6 +106,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    @Mock private NotificationSwipeHelper mNotificationSwipeHelper;
    @Mock private NotificationStackScrollLayoutController mStackScrollLayoutController;
    @Mock private FeatureFlags mFeatureFlags;
    @Mock private UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController;

    @Before
    @UiThreadTest
@@ -143,7 +145,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
                mGroupMembershipManger,
                mGroupExpansionManager,
                mAmbientState,
                mFeatureFlags);
                mFeatureFlags,
                mUnlockedScreenOffAnimationController);
        mStackScrollerInternal.initView(getContext(), mKeyguardBypassEnabledProvider,
                mNotificationSwipeHelper);
        mStackScroller = spy(mStackScrollerInternal);