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

Commit f2fd2eb5 authored by Matt Pietal's avatar Matt Pietal
Browse files

Tweak to isOnLockscreen

With numerous notifs on the lockscreen and UDFPS set up,
tap a notification to show ALTERNATE_BOUNCER. During the
end of this transition, the bounds may flicker. This occurs
as there is a tiny gap between conditions in isOnLockscreen
flow. Use transitionValue() instead for all checks.

Fixes: 372210467
Test: atest SharedNotificationContainerViewModelTest
Flag: EXEMPT bugfix
Change-Id: Ieaa8d1d6ca380fbd0fdb6552b087215208953974
parent 388ef45b
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
@@ -635,6 +635,45 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S
            assertThat(bounds).isEqualTo(NotificationContainerBounds(top = 1f, bottom = 2f))
        }

    @Test
    @DisableSceneContainer
    fun boundsStableWhenGoingToAlternateBouncer() =
        testScope.runTest {
            val bounds by collectLastValue(underTest.bounds)

            // Start on lockscreen
            showLockscreen()

            keyguardInteractor.setNotificationContainerBounds(
                NotificationContainerBounds(top = 1f, bottom = 2f)
            )

            assertThat(bounds).isEqualTo(NotificationContainerBounds(top = 1f, bottom = 2f))

            // Begin transition to AOD
            keyguardTransitionRepository.sendTransitionStep(
                TransitionStep(LOCKSCREEN, ALTERNATE_BOUNCER, 0f, TransitionState.STARTED)
            )
            runCurrent()
            keyguardTransitionRepository.sendTransitionStep(
                TransitionStep(LOCKSCREEN, ALTERNATE_BOUNCER, 0f, TransitionState.RUNNING)
            )
            runCurrent()

            // This is the last step before FINISHED is sent, which could trigger a change in bounds
            keyguardTransitionRepository.sendTransitionStep(
                TransitionStep(LOCKSCREEN, ALTERNATE_BOUNCER, 1f, TransitionState.RUNNING)
            )
            runCurrent()
            assertThat(bounds).isEqualTo(NotificationContainerBounds(top = 1f, bottom = 2f))

            keyguardTransitionRepository.sendTransitionStep(
                TransitionStep(LOCKSCREEN, ALTERNATE_BOUNCER, 1f, TransitionState.FINISHED)
            )
            runCurrent()
            assertThat(bounds).isEqualTo(NotificationContainerBounds(top = 1f, bottom = 2f))
        }

    @Test
    @DisableSceneContainer
    fun boundsDoNotChangeWhileLockscreenToAodTransitionIsActive() =
+9 −7
Original line number Diff line number Diff line
@@ -221,13 +221,15 @@ constructor(
    /** If the user is visually on one of the unoccluded lockscreen states. */
    val isOnLockscreen: Flow<Boolean> =
        anyOf(
                keyguardTransitionInteractor.isFinishedIn(AOD),
                keyguardTransitionInteractor.isFinishedIn(DOZING),
                keyguardTransitionInteractor.isFinishedIn(ALTERNATE_BOUNCER),
                keyguardTransitionInteractor.isFinishedIn(
                keyguardTransitionInteractor.transitionValue(AOD).map { it > 0f },
                keyguardTransitionInteractor.transitionValue(DOZING).map { it > 0f },
                keyguardTransitionInteractor.transitionValue(ALTERNATE_BOUNCER).map { it > 0f },
                keyguardTransitionInteractor
                    .transitionValue(
                        scene = Scenes.Bouncer,
                        stateWithoutSceneContainer = PRIMARY_BOUNCER,
                ),
                    )
                    .map { it > 0f },
                keyguardTransitionInteractor.transitionValue(LOCKSCREEN).map { it > 0f },
            )
            .flowName("isOnLockscreen")