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

Commit 537acc26 authored by Matt Pietal's avatar Matt Pietal
Browse files

Ensure alpha of 0 when GONE

Safety measure to ensure the keyguard alphas are set to 0 when
keyguard transitions to GONE.

Fix: 315345556
Test: atest KeyguardRootViewModelTest
Flag: Flag: ACONFIG com.android.systemui.keyguard_shade_migration_nssl
DEVELOPMENT

Change-Id: Ied9d2d6740a1465042d3c8067669e7be2cb76429
parent 657d5e03
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -111,10 +111,21 @@ constructor(

    /** An observable for the alpha level for the entire keyguard root view. */
    val alpha: Flow<Float> =
        combine(
                keyguardTransitionInteractor.transitionValue(GONE).onStart { emit(0f) },
                merge(
            keyguardInteractor.keyguardAlpha.distinctUntilChanged(),
                    keyguardInteractor.keyguardAlpha,
                    occludedToLockscreenTransitionViewModel.lockscreenAlpha,
                )
            ) { transitionToGone, alpha ->
                if (transitionToGone == 1f) {
                    // Ensures content is not visible when in GONE state
                    0f
                } else {
                    alpha
                }
            }
            .distinctUntilChanged()

    private fun burnIn(): Flow<BurnInModel> {
        val dozingAmount: Flow<Float> =
+31 −7
Original line number Diff line number Diff line
@@ -144,19 +144,43 @@ class KeyguardRootViewModelTest : SysuiTestCase() {
    @Test
    fun alpha() =
        testScope.runTest {
            val value = collectLastValue(underTest.alpha)
            assertThat(value()).isEqualTo(0f)
            val alpha by collectLastValue(underTest.alpha)

            keyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.OFF,
                to = KeyguardState.LOCKSCREEN,
                testScope = testScope,
            )

            repository.setKeyguardAlpha(0.1f)
            assertThat(value()).isEqualTo(0.1f)
            assertThat(alpha).isEqualTo(0.1f)
            repository.setKeyguardAlpha(0.5f)
            assertThat(value()).isEqualTo(0.5f)
            assertThat(alpha).isEqualTo(0.5f)
            repository.setKeyguardAlpha(0.2f)
            assertThat(value()).isEqualTo(0.2f)
            assertThat(alpha).isEqualTo(0.2f)
            repository.setKeyguardAlpha(0f)
            assertThat(value()).isEqualTo(0f)
            assertThat(alpha).isEqualTo(0f)
            occludedToLockscreenAlpha.value = 0.8f
            assertThat(value()).isEqualTo(0.8f)
            assertThat(alpha).isEqualTo(0.8f)
        }

    @Test
    fun alphaWhenGoneEqualsZero() =
        testScope.runTest {
            val alpha by collectLastValue(underTest.alpha)

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

            repository.setKeyguardAlpha(0.1f)
            assertThat(alpha).isEqualTo(0f)
            repository.setKeyguardAlpha(0.5f)
            assertThat(alpha).isEqualTo(0f)
            repository.setKeyguardAlpha(1f)
            assertThat(alpha).isEqualTo(0f)
        }

    @Test