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

Commit 6ee0d792 authored by Matt Pietal's avatar Matt Pietal
Browse files

Isolate Notification alpha changes for PRIMARY_BOUNCER->GONE

Previously, all lockscreen and NSSL alpha changes were bundled
together, which works in most cases. However, if the shade is
expanded while unlocking, notification must remain visible,
especially for things like inline replies.

This fixes both flag on/off paths.

Fixes: 325118951
Test: atest PrimaryBouncerToGoneTransitionViewModelTest
Flag: ACONFIG com.android.systemui.migrate_clocks_to_blueprint
TEAMFOOD

Change-Id: Ia9a7b46163108e5ddf7b2998ce50bfba1a00ff42
parent e437c588
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
@@ -149,6 +149,42 @@ class PrimaryBouncerToGoneTransitionViewModelTest : SysuiTestCase() {
            values.forEach { assertThat(it).isEqualTo(1f) }
        }

    @Test
    fun notificationAlpha() =
        testScope.runTest {
            val values by collectValues(underTest.notificationAlpha)
            runCurrent()

            keyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.PRIMARY_BOUNCER,
                to = KeyguardState.GONE,
                testScope,
            )

            assertThat(values[0]).isEqualTo(1f)
            // Should fade to zero between here
            assertThat(values[1]).isEqualTo(0f)
        }

    @Test
    fun notificationAlpha_leaveShadeOpen() =
        testScope.runTest {
            val values by collectValues(underTest.notificationAlpha)
            runCurrent()

            sysuiStatusBarStateController.setLeaveOpenOnKeyguardHide(true)

            keyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.PRIMARY_BOUNCER,
                to = KeyguardState.GONE,
                testScope,
            )

            assertThat(values.size).isEqualTo(2)
            // Shade stays open, and alpha should remain visible
            values.forEach { assertThat(it).isEqualTo(1f) }
        }

    private fun step(
        value: Float,
        state: TransitionState = TransitionState.RUNNING
+17 −0
Original line number Diff line number Diff line
@@ -60,6 +60,22 @@ constructor(
    private var leaveShadeOpen: Boolean = false
    private var willRunDismissFromKeyguard: Boolean = false

    val notificationAlpha: Flow<Float> =
        transitionAnimation.sharedFlow(
            duration = 200.milliseconds,
            onStart = {
                leaveShadeOpen = statusBarStateController.leaveOpenOnKeyguardHide()
                willRunDismissFromKeyguard = primaryBouncerInteractor.willRunDismissFromKeyguard()
            },
            onStep = {
                if (willRunDismissFromKeyguard || leaveShadeOpen) {
                    1f
                } else {
                    1f - it
                }
            },
        )

    /** Bouncer container alpha */
    val bouncerAlpha: Flow<Float> =
        if (featureFlags.isEnabled(Flags.REFACTOR_KEYGUARD_DISMISS_INTENT)) {
@@ -94,6 +110,7 @@ constructor(
        } else {
            createLockscreenAlpha(primaryBouncerInteractor::willRunDismissFromKeyguard)
        }

    private fun createLockscreenAlpha(willRunAnimationOnKeyguard: () -> Boolean): Flow<Float> {
        return transitionAnimation.sharedFlow(
            duration = 50.milliseconds,
+15 −2
Original line number Diff line number Diff line
@@ -1201,7 +1201,12 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
        // Primary bouncer->Gone (ensures lockscreen content is not visible on successful auth)
        if (!migrateClocksToBlueprint()) {
            collectFlow(mView, mPrimaryBouncerToGoneTransitionViewModel.getLockscreenAlpha(),
                    setTransitionAlpha(mNotificationStackScrollLayoutController), mMainDispatcher);
                    setTransitionAlpha(mNotificationStackScrollLayoutController,
                            /* excludeNotifications=*/ true), mMainDispatcher);
            collectFlow(mView, mPrimaryBouncerToGoneTransitionViewModel.getNotificationAlpha(),
                    (Float alpha) -> {
                        mNotificationStackScrollLayoutController.setMaxAlphaForExpansion(alpha);
                    }, mMainDispatcher);
        }
    }

@@ -4724,9 +4729,17 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump

    private Consumer<Float> setTransitionAlpha(
            NotificationStackScrollLayoutController stackScroller) {
        return setTransitionAlpha(stackScroller, /* excludeNotifications= */ false);
    }

    private Consumer<Float> setTransitionAlpha(
            NotificationStackScrollLayoutController stackScroller,
            boolean excludeNotifications) {
        return (Float alpha) -> {
            mKeyguardStatusViewController.setAlpha(alpha);
            if (!excludeNotifications) {
                stackScroller.setMaxAlphaForExpansion(alpha);
            }

            if (keyguardBottomAreaRefactor()) {
                mKeyguardInteractor.setAlpha(alpha);
+1 −1
Original line number Diff line number Diff line
@@ -333,7 +333,7 @@ constructor(
                lockscreenToPrimaryBouncerTransitionViewModel.lockscreenAlpha,
                occludedToAodTransitionViewModel.lockscreenAlpha,
                occludedToLockscreenTransitionViewModel.lockscreenAlpha,
                primaryBouncerToGoneTransitionViewModel.lockscreenAlpha,
                primaryBouncerToGoneTransitionViewModel.notificationAlpha,
                primaryBouncerToLockscreenTransitionViewModel.lockscreenAlpha,
            )

+2 −0
Original line number Diff line number Diff line
@@ -599,6 +599,8 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase {
        // Primary Bouncer->Gone
        when(mPrimaryBouncerToGoneTransitionViewModel.getLockscreenAlpha())
                .thenReturn(emptyFlow());
        when(mPrimaryBouncerToGoneTransitionViewModel.getNotificationAlpha())
                .thenReturn(emptyFlow());

        NotificationsKeyguardViewStateRepository notifsKeyguardViewStateRepository =
                new NotificationsKeyguardViewStateRepository();