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

Commit 5882d11f authored by Andreas Miko's avatar Andreas Miko Committed by Android (Google) Code Review
Browse files

Merge "Add new Edge APIs and convert listeners" into main

parents afe01246 7175951f
Loading
Loading
Loading
Loading
+26 −23
Original line number Diff line number Diff line
@@ -97,8 +97,10 @@ class KeyguardTransitionInteractorTest : SysuiTestCase() {
    @Test
    fun transitionCollectorsReceivesOnlyAppropriateEvents() =
        testScope.runTest {
            val lockscreenToAodSteps by collectValues(underTest.transition(LOCKSCREEN, AOD))
            val aodToLockscreenSteps by collectValues(underTest.transition(AOD, LOCKSCREEN))
            val lockscreenToAodSteps by
                collectValues(underTest.transition(Edge.create(LOCKSCREEN, AOD)))
            val aodToLockscreenSteps by
                collectValues(underTest.transition(Edge.create(AOD, LOCKSCREEN)))

            val steps = mutableListOf<TransitionStep>()
            steps.add(TransitionStep(AOD, GONE, 0f, STARTED))
@@ -1447,10 +1449,10 @@ class KeyguardTransitionInteractorTest : SysuiTestCase() {

    @Test
    @DisableSceneContainer
    fun getOrCreateFlow_no_conversion_with_flag_off() =
    fun transition_no_conversion_with_flag_off() =
        testScope.runTest {
            val currentStates by
                collectValues(underTest.getOrCreateFlow(Edge(PRIMARY_BOUNCER, GONE)))
                collectValues(underTest.transition(Edge.create(PRIMARY_BOUNCER, GONE)))

            val sendStep1 = TransitionStep(PRIMARY_BOUNCER, GONE, 0f, STARTED)
            sendSteps(sendStep1)
@@ -1460,10 +1462,10 @@ class KeyguardTransitionInteractorTest : SysuiTestCase() {

    @Test
    @EnableSceneContainer
    fun getOrCreateFlow_conversion_with_flag_on() =
    fun transition_conversion_with_flag_on() =
        testScope.runTest {
            val currentStates by
                collectValues(underTest.getOrCreateFlow(Edge(PRIMARY_BOUNCER, GONE)))
                collectValues(underTest.transition(Edge.create(PRIMARY_BOUNCER, GONE)))

            val sendStep1 = TransitionStep(PRIMARY_BOUNCER, GONE, 0f, STARTED)
            sendSteps(sendStep1)
@@ -1473,11 +1475,11 @@ class KeyguardTransitionInteractorTest : SysuiTestCase() {

    @Test
    @EnableSceneContainer
    fun getOrCreateFlow_conversion_emits_values_with_sceneContainer_in_correct_state() =
    fun transition_conversion_emits_values_with_sceneContainer_in_correct_state() =
        testScope.runTest {
            val currentStates by collectValues(underTest.getOrCreateFlow(Edge(LOCKSCREEN, GONE)))
            val currentStates by collectValues(underTest.transition(Edge.create(LOCKSCREEN, GONE)))
            val currentStatesConverted by
                collectValues(underTest.getOrCreateFlow(Edge(LOCKSCREEN, UNDEFINED)))
                collectValues(underTest.transition(Edge.create(LOCKSCREEN, UNDEFINED)))

            sceneTransitions.value = lsToGone
            val sendStep1 = TransitionStep(LOCKSCREEN, UNDEFINED, 0f, STARTED)
@@ -1491,9 +1493,9 @@ class KeyguardTransitionInteractorTest : SysuiTestCase() {

    @Test
    @EnableSceneContainer
    fun getOrCreateFlow_conversion_emits_nothing_with_sceneContainer_in_wrong_state() =
    fun transition_conversion_emits_nothing_with_sceneContainer_in_wrong_state() =
        testScope.runTest {
            val currentStates by collectValues(underTest.getOrCreateFlow(Edge(LOCKSCREEN, GONE)))
            val currentStates by collectValues(underTest.transition(Edge.create(LOCKSCREEN, GONE)))

            sceneTransitions.value = goneToLs
            val sendStep1 = TransitionStep(LOCKSCREEN, UNDEFINED, 0f, STARTED)
@@ -1506,9 +1508,10 @@ class KeyguardTransitionInteractorTest : SysuiTestCase() {

    @Test
    @EnableSceneContainer
    fun getOrCreateFlow_conversion_emits_values_when_edge_within_lockscreen_scene() =
    fun transition_conversion_emits_values_when_edge_within_lockscreen_scene() =
        testScope.runTest {
            val currentStates by collectValues(underTest.getOrCreateFlow(Edge(LOCKSCREEN, DOZING)))
            val currentStates by
                collectValues(underTest.transition(Edge.create(LOCKSCREEN, DOZING)))

            sceneTransitions.value = goneToLs
            val sendStep1 = TransitionStep(LOCKSCREEN, DOZING, 0f, STARTED)
@@ -1521,11 +1524,11 @@ class KeyguardTransitionInteractorTest : SysuiTestCase() {

    @Test
    @EnableSceneContainer
    fun getOrCreateFlow_conversion_emits_values_with_null_edge_within_lockscreen_scene() =
    fun transition_conversion_emits_values_with_null_edge_within_lockscreen_scene() =
        testScope.runTest {
            val currentStates by collectValues(underTest.getOrCreateFlow(Edge(LOCKSCREEN, null)))
            val currentStates by collectValues(underTest.transition(Edge.create(LOCKSCREEN, null)))
            val currentStatesReversed by
                collectValues(underTest.getOrCreateFlow(Edge(null, LOCKSCREEN)))
                collectValues(underTest.transition(Edge.create(null, LOCKSCREEN)))

            sceneTransitions.value = goneToLs
            val sendStep1 = TransitionStep(LOCKSCREEN, DOZING, 0f, STARTED)
@@ -1540,10 +1543,10 @@ class KeyguardTransitionInteractorTest : SysuiTestCase() {

    @Test
    @EnableSceneContainer
    fun getOrCreateFlow_conversion_emits_values_with_null_edge_out_of_lockscreen_scene() =
    fun transition_conversion_emits_values_with_null_edge_out_of_lockscreen_scene() =
        testScope.runTest {
            val currentStates by collectValues(underTest.getOrCreateFlow(Edge(null, UNDEFINED)))
            val currentStatesMapped by collectValues(underTest.getOrCreateFlow(Edge(null, GONE)))
            val currentStates by collectValues(underTest.transition(Edge.create(null, UNDEFINED)))
            val currentStatesMapped by collectValues(underTest.transition(Edge.create(null, GONE)))

            sceneTransitions.value = lsToGone
            val sendStep1 = TransitionStep(LOCKSCREEN, UNDEFINED, 0f, STARTED)
@@ -1558,9 +1561,9 @@ class KeyguardTransitionInteractorTest : SysuiTestCase() {

    @Test
    @EnableSceneContainer
    fun getOrCreateFlow_conversion_does_not_emit_with_null_edge_with_wrong_stl_state() =
    fun transition_conversion_does_not_emit_with_null_edge_with_wrong_stl_state() =
        testScope.runTest {
            val currentStatesMapped by collectValues(underTest.getOrCreateFlow(Edge(null, GONE)))
            val currentStatesMapped by collectValues(underTest.transition(Edge.create(null, GONE)))

            sceneTransitions.value = goneToLs
            val sendStep1 = TransitionStep(LOCKSCREEN, UNDEFINED, 0f, STARTED)
@@ -1574,10 +1577,10 @@ class KeyguardTransitionInteractorTest : SysuiTestCase() {

    @Test
    @EnableSceneContainer
    fun getOrCreateFlow_null_edges_throw() =
    fun transition_null_edges_throw() =
        testScope.runTest {
            assertThrows(IllegalStateException::class.java) {
                underTest.getOrCreateFlow(Edge(null, null))
                underTest.transition(Edge.create(null, null))
            }
        }

+10 −5
Original line number Diff line number Diff line
@@ -23,11 +23,13 @@ import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.coroutines.collectValues
import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository
import com.android.systemui.keyguard.shared.model.Edge
import com.android.systemui.keyguard.shared.model.KeyguardState.DREAMING
import com.android.systemui.keyguard.shared.model.KeyguardState.GONE
import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.keyguard.shared.model.TransitionStep
import com.android.systemui.kosmos.testScope
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import kotlin.time.Duration.Companion.milliseconds
@@ -50,10 +52,13 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() {
    @Before
    fun setUp() {
        underTest =
            animationFlow.setup(
            animationFlow
                .setup(
                    duration = 1000.milliseconds,
                from = GONE,
                to = DREAMING,
                    edge = Edge.create(from = Scenes.Gone, to = DREAMING),
                )
                .setupWithoutSceneContainer(
                    edge = Edge.create(from = GONE, to = DREAMING),
                )
    }

+4 −3
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import com.android.systemui.flags.Flags.REGION_SAMPLING
import com.android.systemui.keyguard.MigrateClocksToBlueprint
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor
import com.android.systemui.keyguard.shared.model.Edge
import com.android.systemui.keyguard.shared.model.KeyguardState.AOD
import com.android.systemui.keyguard.shared.model.KeyguardState.DOZING
import com.android.systemui.keyguard.shared.model.KeyguardState.LOCKSCREEN
@@ -544,10 +545,10 @@ constructor(
    internal fun listenForDozeAmountTransition(scope: CoroutineScope): Job {
        return scope.launch {
            merge(
                    keyguardTransitionInteractor.transition(AOD, LOCKSCREEN).map { step ->
                        step.copy(value = 1f - step.value)
                    keyguardTransitionInteractor.transition(Edge.create(AOD, LOCKSCREEN)).map {
                        it.copy(value = 1f - it.value)
                    },
                    keyguardTransitionInteractor.transition(LOCKSCREEN, AOD),
                    keyguardTransitionInteractor.transition(Edge.create(LOCKSCREEN, AOD)),
                ).filter {
                    it.transitionState != TransitionState.FINISHED
                }
+38 −29
Original line number Diff line number Diff line
@@ -32,11 +32,18 @@ import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor
import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerInteractor
import com.android.systemui.dump.DumpManager
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.model.Edge
import com.android.systemui.keyguard.shared.model.KeyguardState.ALTERNATE_BOUNCER
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.GONE
import com.android.systemui.keyguard.shared.model.KeyguardState.OCCLUDED
import com.android.systemui.keyguard.shared.model.KeyguardState.PRIMARY_BOUNCER
import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.res.R
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.statusbar.LockscreenShadeTransitionController
import com.android.systemui.statusbar.StatusBarState
@@ -131,6 +138,7 @@ open class UdfpsKeyguardViewControllerLegacy(
            override fun onUnlockedChanged() {
                updatePauseAuth()
            }

            override fun onLaunchTransitionFadingAwayChanged() {
                launchTransitionFadingAway = keyguardStateController.isLaunchTransitionFadingAway
                updatePauseAuth()
@@ -211,7 +219,10 @@ open class UdfpsKeyguardViewControllerLegacy(
    suspend fun listenForPrimaryBouncerToAodTransitions(scope: CoroutineScope): Job {
        return scope.launch {
            transitionInteractor
                .transition(KeyguardState.PRIMARY_BOUNCER, KeyguardState.AOD)
                .transition(
                    edge = Edge.create(Scenes.Bouncer, AOD),
                    edgeWithoutSceneContainer = Edge.create(PRIMARY_BOUNCER, AOD)
                )
                .collect { transitionStep ->
                    view.onDozeAmountChanged(
                        transitionStep.value,
@@ -225,8 +236,7 @@ open class UdfpsKeyguardViewControllerLegacy(
    @VisibleForTesting
    suspend fun listenForDreamingToAodTransitions(scope: CoroutineScope): Job {
        return scope.launch {
            transitionInteractor.transition(KeyguardState.DREAMING, KeyguardState.AOD).collect {
                transitionStep ->
            transitionInteractor.transition(Edge.create(DREAMING, AOD)).collect { transitionStep ->
                view.onDozeAmountChanged(
                    transitionStep.value,
                    transitionStep.value,
@@ -239,9 +249,8 @@ open class UdfpsKeyguardViewControllerLegacy(
    @VisibleForTesting
    suspend fun listenForAlternateBouncerToAodTransitions(scope: CoroutineScope): Job {
        return scope.launch {
            transitionInteractor
                .transition(KeyguardState.ALTERNATE_BOUNCER, KeyguardState.AOD)
                .collect { transitionStep ->
            transitionInteractor.transition(Edge.create(ALTERNATE_BOUNCER, AOD)).collect {
                transitionStep ->
                view.onDozeAmountChanged(
                    transitionStep.value,
                    transitionStep.value,
@@ -254,8 +263,7 @@ open class UdfpsKeyguardViewControllerLegacy(
    @VisibleForTesting
    suspend fun listenForAodToOccludedTransitions(scope: CoroutineScope): Job {
        return scope.launch {
            transitionInteractor.transition(KeyguardState.AOD, KeyguardState.OCCLUDED).collect {
                transitionStep ->
            transitionInteractor.transition(Edge.create(AOD, OCCLUDED)).collect { transitionStep ->
                view.onDozeAmountChanged(
                    1f - transitionStep.value,
                    1f - transitionStep.value,
@@ -268,8 +276,7 @@ open class UdfpsKeyguardViewControllerLegacy(
    @VisibleForTesting
    suspend fun listenForOccludedToAodTransition(scope: CoroutineScope): Job {
        return scope.launch {
            transitionInteractor.transition(KeyguardState.OCCLUDED, KeyguardState.AOD).collect {
                transitionStep ->
            transitionInteractor.transition(Edge.create(OCCLUDED, AOD)).collect { transitionStep ->
                view.onDozeAmountChanged(
                    transitionStep.value,
                    transitionStep.value,
@@ -282,8 +289,12 @@ open class UdfpsKeyguardViewControllerLegacy(
    @VisibleForTesting
    suspend fun listenForGoneToAodTransition(scope: CoroutineScope): Job {
        return scope.launch {
            transitionInteractor.transition(KeyguardState.GONE, KeyguardState.AOD).collect {
                transitionStep ->
            transitionInteractor
                .transition(
                    edge = Edge.create(Scenes.Gone, AOD),
                    edgeWithoutSceneContainer = Edge.create(GONE, AOD)
                )
                .collect { transitionStep ->
                    view.onDozeAmountChanged(
                        transitionStep.value,
                        transitionStep.value,
@@ -298,13 +309,10 @@ open class UdfpsKeyguardViewControllerLegacy(
        return scope.launch {
            transitionInteractor.dozeAmountTransition.collect { transitionStep ->
                if (
                    transitionStep.from == KeyguardState.AOD &&
                    transitionStep.from == AOD &&
                        transitionStep.transitionState == TransitionState.CANCELED
                ) {
                    if (
                        transitionInteractor.startedKeyguardTransitionStep.first().to !=
                            KeyguardState.AOD
                    ) {
                    if (transitionInteractor.startedKeyguardTransitionStep.first().to != AOD) {
                        // If the next started transition isn't transitioning back to AOD, force
                        // doze amount to be 0f (as if the transition to the lockscreen completed).
                        view.onDozeAmountChanged(
@@ -557,6 +565,7 @@ open class UdfpsKeyguardViewControllerLegacy(
    private fun updateScaleFactor() {
        udfpsController.mOverlayParams?.scaleFactor?.let { view.setScaleFactor(it) }
    }

    companion object {
        const val TAG = "UdfpsKeyguardViewController"
    }
+2 −1
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import com.android.systemui.keyguard.data.repository.FaceDetectTableLog
import com.android.systemui.keyguard.data.repository.KeyguardRepository
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor
import com.android.systemui.keyguard.shared.model.Edge
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.model.StatusBarState
import com.android.systemui.keyguard.shared.model.SysUiFaceAuthenticateOptions
@@ -302,7 +303,7 @@ constructor(

    private fun listenForSchedulingWatchdog() {
        keyguardTransitionInteractor
            .transition(to = KeyguardState.GONE)
            .transition(Edge.create(to = KeyguardState.GONE))
            .filter { it.transitionState == TransitionState.FINISHED }
            .onEach {
                // We deliberately want to run this in background because scheduleWatchdog does
Loading