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

Commit 4c008421 authored by Lucas Silva's avatar Lucas Silva
Browse files

Ensure keyguard stays hidden when transitioning between hidden states.

Defines hidden states which should hide the keyguard when we are fully
on that state, and also if transitioning between hidden states. This
ensures we never show the keyguard when transitioning between the dream
and glanceable hub.

Fixes: 359758497
Test: atest KeyguardRootViewModelTest
Flag: EXEMPT bugfix
Change-Id: If5c0e53e84dcc7eeed9a867110317c2fbae9204c
parent ed4b4fd5
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -359,6 +359,25 @@ class KeyguardRootViewModelTest(flags: FlagsParameterization) : SysuiTestCase()
            assertThat(alpha).isEqualTo(0f)
        }

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

            // Default value check
            assertThat(alpha).isEqualTo(1f)

            // Start transitioning between DREAM and HUB but don't finish.
            keyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.DREAMING,
                to = KeyguardState.GLANCEABLE_HUB,
                testScope = testScope,
                throughTransitionState = TransitionState.STARTED,
            )

            assertThat(alpha).isEqualTo(0f)
        }

    @Test
    @EnableSceneContainer
    fun alpha_transitionToHub_isZero_scene_container() =
+30 −19
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@ import com.android.systemui.keyguard.shared.model.BurnInModel
import com.android.systemui.keyguard.shared.model.Edge
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.DREAMING
import com.android.systemui.keyguard.shared.model.KeyguardState.GLANCEABLE_HUB
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
@@ -45,6 +47,7 @@ import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.statusbar.notification.domain.interactor.NotificationsKeyguardInteractor
import com.android.systemui.statusbar.phone.DozeParameters
import com.android.systemui.statusbar.phone.ScreenOffAnimationController
import com.android.systemui.util.kotlin.BooleanFlowOperators.any
import com.android.systemui.util.kotlin.BooleanFlowOperators.anyOf
import com.android.systemui.util.kotlin.pairwise
import com.android.systemui.util.kotlin.sample
@@ -198,29 +201,37 @@ 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.
     * Keyguard states which should fully hide the keyguard.
     *
     * Note: [GONE] is not included as it is handled separately.
     */
    private val hiddenKeyguardStates = listOf(OCCLUDED, DREAMING, GLANCEABLE_HUB)

    /**
     * Keyguard should not show if fully transitioned into a hidden keyguard state or if
     * transitioning between hidden states.
     */
    private val hideKeyguard: Flow<Boolean> =
        combine(
                communalInteractor.isIdleOnCommunal,
        (hiddenKeyguardStates.map { state ->
                keyguardTransitionInteractor
                    .transitionValue(scene = Scenes.Gone, stateWithoutSceneContainer = GONE)
                    .transitionValue(state)
                    .map { it == 1f }
                    .onStart { emit(false) },
                    .onStart { emit(false) }
            } +
                listOf(
                    communalInteractor.isIdleOnCommunal,
                    keyguardTransitionInteractor
                    .transitionValue(OCCLUDED)
                        .transitionValue(scene = Scenes.Gone, stateWithoutSceneContainer = GONE)
                        .map { it == 1f }
                        .onStart { emit(false) },
                    keyguardTransitionInteractor
                    .transitionValue(KeyguardState.DREAMING)
                    .map { it == 1f }
                        .isInTransitionWhere(
                            fromStatePredicate = { hiddenKeyguardStates.contains(it) },
                            toStatePredicate = { hiddenKeyguardStates.contains(it) },
                        )
                        .onStart { emit(false) },
            ) { isIdleOnCommunal, isGone, isOccluded, isDreaming ->
                isIdleOnCommunal || isGone || isOccluded || isDreaming
            }
            .distinctUntilChanged()
                ))
            .any()

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