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

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

Ensure keyguard is hidden on OCCLUDED

... that's it

Fixes: 327652916
Test: atest KeyguardRootViewModelTest
Flag: ACONFIG com.android.systemui.migrate_clocks_to_blueprint
TEAMFOOD

Change-Id: Ia02092812fc13a24771b9f29a80020192e683c7d
parent 75128c1c
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
@@ -328,4 +328,42 @@ class KeyguardRootViewModelTest : SysuiTestCase() {
            shadeRepository.setQsExpansion(0.5f)
            assertThat(alpha).isEqualTo(0f)
        }

    @Test
    fun alpha_idleOnOccluded_isZero() =
        testScope.runTest {
            val alpha by collectLastValue(underTest.alpha(viewState))
            assertThat(alpha).isEqualTo(1f)

            // Go to OCCLUDED state
            keyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.LOCKSCREEN,
                to = KeyguardState.OCCLUDED,
                testScope = testScope,
            )
            assertThat(alpha).isEqualTo(0f)

            // Try pulling down shade and ensure the value doesn't change
            shadeRepository.setQsExpansion(0.5f)
            assertThat(alpha).isEqualTo(0f)
        }

    @Test
    fun alpha_idleOnGone_isZero() =
        testScope.runTest {
            val alpha by collectLastValue(underTest.alpha(viewState))
            assertThat(alpha).isEqualTo(1f)

            // Go to GONE state
            keyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.LOCKSCREEN,
                to = KeyguardState.GONE,
                testScope = testScope,
            )
            assertThat(alpha).isEqualTo(0f)

            // Try pulling down shade and ensure the value doesn't change
            shadeRepository.setQsExpansion(0.5f)
            assertThat(alpha).isEqualTo(0f)
        }
}
+25 −12
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import com.android.systemui.keyguard.shared.model.KeyguardState
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.TransitionState.RUNNING
import com.android.systemui.keyguard.shared.model.TransitionState.STARTED
import com.android.systemui.keyguard.ui.StateToValue
@@ -122,6 +123,27 @@ constructor(
            }
            .distinctUntilChanged()

    /**
     * Keyguard should not show while the communal hub is fully visible. This check is added since
     * at the moment, closing the notification shade will cause the keyguard alpha to be set back to
     * 1. Also ensure keyguard is never visible when GONE.
     */
    private val hideKeyguard: Flow<Boolean> =
        combine(
                communalInteractor.isIdleOnCommunal,
                keyguardTransitionInteractor
                    .transitionValue(GONE)
                    .map { it == 1f }
                    .onStart { emit(false) },
                keyguardTransitionInteractor
                    .transitionValue(OCCLUDED)
                    .map { it == 1f }
                    .onStart { emit(false) },
            ) { isIdleOnCommunal, isGone, isOccluded ->
                isIdleOnCommunal || isGone || isOccluded
            }
            .distinctUntilChanged()

    /** Last point that the root view was tapped */
    val lastRootViewTapPosition: Flow<Point?> = keyguardInteractor.lastRootViewTapPosition

@@ -138,12 +160,7 @@ constructor(
    /** An observable for the alpha level for the entire keyguard root view. */
    fun alpha(viewState: ViewStateAccessor): Flow<Float> {
        return combine(
                communalInteractor.isIdleOnCommunal,
                keyguardTransitionInteractor
                    .transitionValue(GONE)
                    .map { it == 1f }
                    .onStart { emit(false) }
                    .distinctUntilChanged(),
                hideKeyguard,
                // The transitions are mutually exclusive, so they are safe to merge to get the last
                // value emitted by any of them. Do not add flows that cannot make this guarantee.
                merge(
@@ -171,12 +188,8 @@ constructor(
                        primaryBouncerToLockscreenTransitionViewModel.lockscreenAlpha,
                    )
                    .onStart { emit(1f) }
            ) { isIdleOnCommunal, gone, alpha ->
                if (isIdleOnCommunal || gone) {
                    // Keyguard should not show while the communal hub is fully visible. This check
                    // is added since at the moment, closing the notification shade will cause the
                    // keyguard alpha to be set back to 1. Also ensure keyguard is never visible
                    // when GONE.
            ) { hideKeyguard, alpha ->
                if (hideKeyguard) {
                    0f
                } else {
                    alpha