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

Commit 4f938d3f authored by Priyanka Advani's avatar Priyanka Advani Committed by Android (Google) Code Review
Browse files

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

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

            // Before the halfway point, it will have reached zero
            repository.sendTransitionStep(step(0.25f))
            assertThat(alpha).isEqualTo(0.25f)

            repository.sendTransitionStep(step(.5f))
            assertThat(alpha).isEqualTo(0f)
        }
+0 −53
Original line number Diff line number Diff line
@@ -719,59 +719,6 @@ 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 {
+16 −5
Original line number Diff line number Diff line
@@ -289,10 +289,7 @@ constructor(
                .collect { pair ->
                    val (isKeyguardGoingAway, lastStartedStep) = pair
                    if (isKeyguardGoingAway && lastStartedStep.to == KeyguardState.LOCKSCREEN) {
                        startTransitionTo(
                            KeyguardState.GONE,
                            modeOnCanceled = TransitionModeOnCanceled.RESET,
                        )
                        startTransitionTo(KeyguardState.GONE)
                    }
                }
        }
@@ -306,6 +303,20 @@ 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)
                    }
                }
        }
    }

@@ -402,7 +413,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 = 633.milliseconds
        val TO_GONE_DURATION = DEFAULT_DURATION
        val TO_GLANCEABLE_HUB_DURATION = 1.seconds
    }
}
+0 −1
Original line number Diff line number Diff line
@@ -86,7 +86,6 @@ constructor(
        return transitionValueCache.getOrPut(state) {
            MutableSharedFlow<Float>(
                extraBufferCapacity = 2,
                replay = 1,
                onBufferOverflow = BufferOverflow.DROP_OLDEST
            )
        }
+18 −17
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ 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.
@@ -51,8 +53,6 @@ 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,21 +77,22 @@ constructor(
    }

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

    val shortcutsAlpha: Flow<Float> =
        transitionAnimation.sharedFlow(
Loading