Loading packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalSceneTransitionInteractorTest.kt +45 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.se import com.android.systemui.power.domain.interactor.powerInteractor import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlin.time.Duration.Companion.seconds import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow Loading @@ -78,6 +79,7 @@ class CommunalSceneTransitionInteractorTest : SysuiTestCase() { private val underTest by lazy { kosmos.communalSceneTransitionInteractor } private val keyguardTransitionRepository by lazy { kosmos.realKeyguardTransitionRepository } private val keyguardRepository by lazy { kosmos.fakeKeyguardRepository } private val ownerName = CommunalSceneTransitionInteractor::class.java.simpleName private val progress = MutableSharedFlow<Float>() Loading Loading @@ -789,4 +791,47 @@ class CommunalSceneTransitionInteractorTest : SysuiTestCase() { ) ) } /** Verifies that we correctly transition to GONE after keyguard goes away */ @Test fun transition_to_blank_after_unlock_should_go_to_gone() = testScope.runTest { keyguardRepository.setKeyguardShowing(true) sceneTransitions.value = Idle(CommunalScenes.Communal) val currentStep by collectLastValue(keyguardTransitionRepository.transitions) assertThat(currentStep) .isEqualTo( TransitionStep( from = LOCKSCREEN, to = GLANCEABLE_HUB, transitionState = FINISHED, value = 1f, ownerName = ownerName, ) ) // Keyguard starts exiting after a while, then fully exits after some time. advanceTimeBy(1.seconds) keyguardRepository.setKeyguardGoingAway(true) advanceTimeBy(2.seconds) keyguardRepository.setKeyguardGoingAway(false) keyguardRepository.setKeyguardShowing(false) runCurrent() // We snap to the blank scene as a result of keyguard going away. sceneTransitions.value = Idle(CommunalScenes.Blank) assertThat(currentStep) .isEqualTo( TransitionStep( from = GLANCEABLE_HUB, to = GONE, transitionState = FINISHED, value = 1f, ownerName = ownerName, ) ) } } packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSceneTransitionInteractor.kt +20 −14 Original line number Diff line number Diff line Loading @@ -41,6 +41,8 @@ import kotlinx.coroutines.Job import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch Loading Loading @@ -88,22 +90,26 @@ constructor( keyguardInteractor.isAbleToDream, keyguardInteractor.isKeyguardOccluded, keyguardInteractor.isKeyguardGoingAway, ) { dreaming, occluded, keyguardGoingAway -> keyguardInteractor.isKeyguardShowing, ) { dreaming, occluded, keyguardGoingAway, keyguardShowing -> if (keyguardGoingAway) { KeyguardState.GONE } else if (occluded && !dreaming) { KeyguardState.OCCLUDED } else if (dreaming) { KeyguardState.DREAMING } else { } else if (keyguardShowing) { KeyguardState.LOCKSCREEN } else { null } } .filterNotNull() private val nextKeyguardState: StateFlow<KeyguardState> = combine( repository.nextLockscreenTargetState, nextKeyguardStateInternal, nextKeyguardStateInternal.onStart { emit(KeyguardState.LOCKSCREEN) }, ) { override, nextState -> override ?: nextState } Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalSceneTransitionInteractorTest.kt +45 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.se import com.android.systemui.power.domain.interactor.powerInteractor import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlin.time.Duration.Companion.seconds import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow Loading @@ -78,6 +79,7 @@ class CommunalSceneTransitionInteractorTest : SysuiTestCase() { private val underTest by lazy { kosmos.communalSceneTransitionInteractor } private val keyguardTransitionRepository by lazy { kosmos.realKeyguardTransitionRepository } private val keyguardRepository by lazy { kosmos.fakeKeyguardRepository } private val ownerName = CommunalSceneTransitionInteractor::class.java.simpleName private val progress = MutableSharedFlow<Float>() Loading Loading @@ -789,4 +791,47 @@ class CommunalSceneTransitionInteractorTest : SysuiTestCase() { ) ) } /** Verifies that we correctly transition to GONE after keyguard goes away */ @Test fun transition_to_blank_after_unlock_should_go_to_gone() = testScope.runTest { keyguardRepository.setKeyguardShowing(true) sceneTransitions.value = Idle(CommunalScenes.Communal) val currentStep by collectLastValue(keyguardTransitionRepository.transitions) assertThat(currentStep) .isEqualTo( TransitionStep( from = LOCKSCREEN, to = GLANCEABLE_HUB, transitionState = FINISHED, value = 1f, ownerName = ownerName, ) ) // Keyguard starts exiting after a while, then fully exits after some time. advanceTimeBy(1.seconds) keyguardRepository.setKeyguardGoingAway(true) advanceTimeBy(2.seconds) keyguardRepository.setKeyguardGoingAway(false) keyguardRepository.setKeyguardShowing(false) runCurrent() // We snap to the blank scene as a result of keyguard going away. sceneTransitions.value = Idle(CommunalScenes.Blank) assertThat(currentStep) .isEqualTo( TransitionStep( from = GLANCEABLE_HUB, to = GONE, transitionState = FINISHED, value = 1f, ownerName = ownerName, ) ) } }
packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSceneTransitionInteractor.kt +20 −14 Original line number Diff line number Diff line Loading @@ -41,6 +41,8 @@ import kotlinx.coroutines.Job import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch Loading Loading @@ -88,22 +90,26 @@ constructor( keyguardInteractor.isAbleToDream, keyguardInteractor.isKeyguardOccluded, keyguardInteractor.isKeyguardGoingAway, ) { dreaming, occluded, keyguardGoingAway -> keyguardInteractor.isKeyguardShowing, ) { dreaming, occluded, keyguardGoingAway, keyguardShowing -> if (keyguardGoingAway) { KeyguardState.GONE } else if (occluded && !dreaming) { KeyguardState.OCCLUDED } else if (dreaming) { KeyguardState.DREAMING } else { } else if (keyguardShowing) { KeyguardState.LOCKSCREEN } else { null } } .filterNotNull() private val nextKeyguardState: StateFlow<KeyguardState> = combine( repository.nextLockscreenTargetState, nextKeyguardStateInternal, nextKeyguardStateInternal.onStart { emit(KeyguardState.LOCKSCREEN) }, ) { override, nextState -> override ?: nextState } Loading