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

Commit 5ffdbdd5 authored by Matt Pietal's avatar Matt Pietal
Browse files

If a PRIMARY_BOUNCER->LOCKSCREEN is running...

... don't process shade alpha request. This can happen when
you swipe down and enabled the setting to disable notifs on
lockscreen. This will pop up the bouncer, and swiping back
should be smooth.

Fixes: 342528378
Test: atest KeyguardRootViewModelTest
Flag: com.android.systemui.keyguard_bottom_area_refactor
Change-Id: Idda37d4e811973e879b9a3df21503f11cbf2d4a6
parent e87bfe9e
Loading
Loading
Loading
Loading
+47 −0
Original line number Diff line number Diff line
@@ -398,6 +398,53 @@ class KeyguardRootViewModelTest(flags: FlagsParameterization) : SysuiTestCase()
            assertThat(alpha).isEqualTo(0f)
        }

    @Test
    @DisableSceneContainer
    fun alphaFromShadeExpansion_doesNotEmitWhenTransitionRunning() =
        testScope.runTest {
            keyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.AOD,
                to = KeyguardState.LOCKSCREEN,
                testScope,
            )

            val alpha by collectLastValue(underTest.alpha(viewState))
            shadeTestUtil.setQsExpansion(0f)
            runCurrent()
            assertThat(alpha).isEqualTo(1f)

            keyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.LOCKSCREEN,
                to = KeyguardState.PRIMARY_BOUNCER,
                testScope,
            )
            assertThat(alpha).isEqualTo(0f)

            keyguardTransitionRepository.sendTransitionSteps(
                listOf(
                    TransitionStep(
                        from = KeyguardState.PRIMARY_BOUNCER,
                        to = KeyguardState.LOCKSCREEN,
                        transitionState = TransitionState.STARTED,
                        value = 0f,
                    ),
                    TransitionStep(
                        from = KeyguardState.PRIMARY_BOUNCER,
                        to = KeyguardState.LOCKSCREEN,
                        transitionState = TransitionState.RUNNING,
                        value = 0.8f,
                    ),
                ),
                testScope,
            )
            // Alpha should be 1f from the above transition
            assertThat(alpha).isEqualTo(1f)

            shadeTestUtil.setQsExpansion(0.5f)
            // Alpha should remain unchanged instead of fading out
            assertThat(alpha).isEqualTo(1f)
        }

    @Test
    fun alpha_shadeClosedOverLockscreen_isOne() =
        testScope.runTest {
+11 −4
Original line number Diff line number Diff line
@@ -222,17 +222,24 @@ constructor(
    override fun getDefaultAnimatorForTransitionsToState(toState: KeyguardState): ValueAnimator {
        return ValueAnimator().apply {
            interpolator = Interpolators.LINEAR
            duration = DEFAULT_DURATION.inWholeMilliseconds
            duration =
                when (toState) {
                    KeyguardState.AOD -> TO_AOD_DURATION
                    KeyguardState.DOZING -> TO_DOZING_DURATION
                    KeyguardState.GONE -> TO_GONE_DURATION
                    KeyguardState.LOCKSCREEN -> TO_LOCKSCREEN_DURATION
                    else -> DEFAULT_DURATION
                }.inWholeMilliseconds
        }
    }

    companion object {
        private val DEFAULT_DURATION = 300.milliseconds
        val TO_GONE_DURATION = 500.milliseconds
        val TO_GONE_SHORT_DURATION = 200.milliseconds
        val TO_AOD_DURATION = DEFAULT_DURATION
        val TO_LOCKSCREEN_DURATION = DEFAULT_DURATION
        val TO_DOZING_DURATION = DEFAULT_DURATION
        val TO_GONE_DURATION = 500.milliseconds
        val TO_GONE_SHORT_DURATION = 200.milliseconds
        val TO_LOCKSCREEN_DURATION = 450.milliseconds
        val TO_GONE_SURFACE_BEHIND_VISIBLE_THRESHOLD = 0.5f
    }
}
+6 −0
Original line number Diff line number Diff line
@@ -103,6 +103,12 @@ constructor(
            }
        }

        scope.launch {
            keyguardInteractor.isKeyguardGoingAway.collect {
                logger.log(TAG, VERBOSE, "isKeyguardGoingAway", it)
            }
        }

        scope.launch {
            keyguardInteractor.isKeyguardOccluded.collect {
                logger.log(TAG, VERBOSE, "isOccluded", it)
+17 −2
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import com.android.systemui.keyguard.shared.model.KeyguardState.AOD
import com.android.systemui.keyguard.shared.model.KeyguardState.GONE
import com.android.systemui.keyguard.shared.model.KeyguardState.LOCKSCREEN
import com.android.systemui.keyguard.shared.model.KeyguardState.OCCLUDED
import com.android.systemui.keyguard.shared.model.KeyguardState.PRIMARY_BOUNCER
import com.android.systemui.keyguard.shared.model.TransitionState.RUNNING
import com.android.systemui.keyguard.shared.model.TransitionState.STARTED
import com.android.systemui.keyguard.ui.StateToValue
@@ -159,12 +160,26 @@ constructor(
                    edge = Edge.create(from = LOCKSCREEN, to = Scenes.Gone),
                    edgeWithoutSceneContainer = Edge.create(from = LOCKSCREEN, to = GONE),
                ),
                keyguardTransitionInteractor.isInTransition(
                    edge = Edge.create(from = PRIMARY_BOUNCER, to = Scenes.Lockscreen),
                    edgeWithoutSceneContainer =
                        Edge.create(from = PRIMARY_BOUNCER, to = LOCKSCREEN),
                ),
                isOnLockscreen,
                shadeInteractor.qsExpansion,
                shadeInteractor.shadeExpansion,
            ) { lockscreenToGoneTransitionRunning, isOnLockscreen, qsExpansion, shadeExpansion ->
            ) {
                lockscreenToGoneTransitionRunning,
                primaryBouncerToLockscreenTransitionRunning,
                isOnLockscreen,
                qsExpansion,
                shadeExpansion ->
                // Fade out quickly as the shade expands
                if (isOnLockscreen && !lockscreenToGoneTransitionRunning) {
                if (
                    isOnLockscreen &&
                        !lockscreenToGoneTransitionRunning &&
                        !primaryBouncerToLockscreenTransitionRunning
                ) {
                    val alpha =
                        1f -
                            MathUtils.constrainedMap(
+12 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ class FakeKeyguardTransitionRepository(
    private val _transitions =
        MutableSharedFlow<TransitionStep>(replay = 3, onBufferOverflow = BufferOverflow.DROP_OLDEST)
    override val transitions: SharedFlow<TransitionStep> = _transitions

    @Inject constructor() : this(initInLockscreen = true)

    private val _currentTransitionInfo: MutableStateFlow<TransitionInfo> =
@@ -137,6 +138,17 @@ class FakeKeyguardTransitionRepository(
                    )
            )
            testScheduler.runCurrent()

            sendTransitionStep(
                step =
                    TransitionStep(
                        transitionState = TransitionState.RUNNING,
                        from = from,
                        to = to,
                        value = 1f
                    )
            )
            testScheduler.runCurrent()
        }

        if (throughTransitionState == TransitionState.FINISHED) {