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

Commit 3e762ba3 authored by Matt Pietal's avatar Matt Pietal Committed by Android (Google) Code Review
Browse files

Merge "Revert^2 "Prevent notif flicker during entirety of swipe to unlock"" into main

parents f58571ee 0e4121e5
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -68,9 +68,7 @@ class LockscreenToGoneTransitionViewModelTest : SysuiTestCase() {
            repository.sendTransitionStep(step(0f))
            assertThat(alpha).isEqualTo(0.5f)

            repository.sendTransitionStep(step(0.25f))
            assertThat(alpha).isEqualTo(0.25f)

            // Before the halfway point, it will have reached zero
            repository.sendTransitionStep(step(.5f))
            assertThat(alpha).isEqualTo(0f)
        }
+53 −0
Original line number Diff line number Diff line
@@ -719,6 +719,59 @@ class SharedNotificationContainerViewModelTest : SysuiTestCase() {
            assertThat(alpha).isEqualTo(1f)
        }

    @Test
    fun alphaDoesNotUpdateWhileGoneTransitionIsRunning() =
        testScope.runTest {
            val viewState = ViewStateAccessor()
            val alpha by collectLastValue(underTest.keyguardAlpha(viewState))

            showLockscreen()
            // GONE transition gets to 90% complete
            keyguardTransitionRepository.sendTransitionStep(
                TransitionStep(
                    from = KeyguardState.LOCKSCREEN,
                    to = KeyguardState.GONE,
                    transitionState = TransitionState.STARTED,
                    value = 0f,
                )
            )
            runCurrent()
            keyguardTransitionRepository.sendTransitionStep(
                TransitionStep(
                    from = KeyguardState.LOCKSCREEN,
                    to = KeyguardState.GONE,
                    transitionState = TransitionState.RUNNING,
                    value = 0.9f,
                )
            )
            runCurrent()

            // At this point, alpha should be zero
            assertThat(alpha).isEqualTo(0f)

            // An attempt to override by the shade should be ignored
            shadeRepository.setQsExpansion(0.5f)
            assertThat(alpha).isEqualTo(0f)
        }

    @Test
    fun alphaWhenGoneIsSetToOne() =
        testScope.runTest {
            val viewState = ViewStateAccessor()
            val alpha by collectLastValue(underTest.keyguardAlpha(viewState))

            showLockscreen()

            keyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.LOCKSCREEN,
                to = KeyguardState.GONE,
                testScope
            )
            keyguardRepository.setStatusBarState(StatusBarState.SHADE)

            assertThat(alpha).isEqualTo(1f)
        }

    @Test
    fun shadeCollapseFadeIn() =
        testScope.runTest {
+5 −16
Original line number Diff line number Diff line
@@ -289,7 +289,10 @@ constructor(
                .collect { pair ->
                    val (isKeyguardGoingAway, lastStartedStep) = pair
                    if (isKeyguardGoingAway && lastStartedStep.to == KeyguardState.LOCKSCREEN) {
                        startTransitionTo(KeyguardState.GONE)
                        startTransitionTo(
                            KeyguardState.GONE,
                            modeOnCanceled = TransitionModeOnCanceled.RESET,
                        )
                    }
                }
        }
@@ -303,20 +306,6 @@ constructor(
                    startTransitionTo(KeyguardState.GONE)
                }
            }

            return
        }

        scope.launch {
            keyguardInteractor.isKeyguardGoingAway
                .sample(startedKeyguardTransitionStep, ::Pair)
                .collect { pair ->
                    KeyguardWmStateRefactor.assertInLegacyMode()
                    val (isKeyguardGoingAway, lastStartedStep) = pair
                    if (isKeyguardGoingAway && lastStartedStep.to == KeyguardState.LOCKSCREEN) {
                        startTransitionTo(KeyguardState.GONE)
                    }
                }
        }
    }

@@ -413,7 +402,7 @@ constructor(
        val TO_OCCLUDED_DURATION = 450.milliseconds
        val TO_AOD_DURATION = 500.milliseconds
        val TO_PRIMARY_BOUNCER_DURATION = DEFAULT_DURATION
        val TO_GONE_DURATION = DEFAULT_DURATION
        val TO_GONE_DURATION = 633.milliseconds
        val TO_GLANCEABLE_HUB_DURATION = 1.seconds
    }
}
+17 −18
Original line number Diff line number Diff line
@@ -30,8 +30,6 @@ import javax.inject.Inject
import kotlin.time.Duration.Companion.milliseconds
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.map

/**
 * Breaks down AOD->LOCKSCREEN transition into discrete steps for corresponding views to consume.
@@ -53,6 +51,8 @@ constructor(
            to = KeyguardState.LOCKSCREEN,
        )

    private var isShadeExpanded = false

    /**
     * Begin the transition from wherever the y-translation value is currently. This helps ensure a
     * smooth transition if a transition in canceled.
@@ -77,22 +77,21 @@ constructor(
    }

    val notificationAlpha: Flow<Float> =
        combine(
            shadeInteractor.shadeExpansion.map { it > 0f },
            shadeInteractor.qsExpansion.map { it > 0f },
        transitionAnimation.sharedFlow(
            duration = 500.milliseconds,
                onStep = { it },
                onCancel = { 1f },
            ),
        ) { isShadeExpanded, isQsExpanded, alpha ->
            if (isShadeExpanded || isQsExpanded) {
                // One example of this happening is dragging a notification while pulsing on AOD
            onStart = {
                isShadeExpanded =
                    shadeInteractor.shadeExpansion.value > 0f ||
                        shadeInteractor.qsExpansion.value > 0f
            },
            onStep = {
                if (isShadeExpanded) {
                    1f
                } else {
                alpha
            }
                    it
                }
            },
        )

    val shortcutsAlpha: Flow<Float> =
        transitionAnimation.sharedFlow(
+1 −1
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ interface BaseShadeInteractor {
    val isAnyExpanded: StateFlow<Boolean>

    /** The amount [0-1] that the shade has been opened. */
    val shadeExpansion: Flow<Float>
    val shadeExpansion: StateFlow<Float>

    /**
     * The amount [0-1] QS has been opened. Normal shade with notifications (QQS) visible will
Loading