Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt +13 −3 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.onStart /** View-model for the shared notification container, used by both the shade and keyguard spaces */ class SharedNotificationContainerViewModel Loading @@ -45,8 +46,8 @@ constructor( ) { private val statesForConstrainedNotifications = setOf( KeyguardState.LOCKSCREEN, KeyguardState.AOD, KeyguardState.LOCKSCREEN, KeyguardState.DOZING, KeyguardState.ALTERNATE_BOUNCER, KeyguardState.PRIMARY_BOUNCER Loading @@ -68,8 +69,17 @@ constructor( /** If the user is visually on one of the unoccluded lockscreen states. */ val isOnLockscreen: Flow<Boolean> = keyguardTransitionInteractor.finishedKeyguardState .map { statesForConstrainedNotifications.contains(it) } combine( keyguardTransitionInteractor.finishedKeyguardState.map { statesForConstrainedNotifications.contains(it) }, keyguardTransitionInteractor .transitionValue(KeyguardState.LOCKSCREEN) .onStart { emit(0f) } .map { it > 0 } ) { constrainedNotificationState, transitioningToOrFromLockscreen -> constrainedNotificationState || transitioningToOrFromLockscreen } .distinctUntilChanged() /** Are we purely on the keyguard without the shade/qs? */ Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt +17 −1 Original line number Diff line number Diff line Loading @@ -192,10 +192,26 @@ class SharedNotificationContainerViewModelTest : SysuiTestCase() { val isOnLockscreen by collectLastValue(underTest.isOnLockscreen) keyguardTransitionRepository.sendTransitionStep( TransitionStep(to = KeyguardState.GONE, transitionState = TransitionState.FINISHED) TransitionStep( from = KeyguardState.LOCKSCREEN, to = KeyguardState.GONE, value = 1f, transitionState = TransitionState.FINISHED ) ) assertThat(isOnLockscreen).isFalse() // While progressing from lockscreen, should still be true keyguardTransitionRepository.sendTransitionStep( TransitionStep( from = KeyguardState.LOCKSCREEN, to = KeyguardState.GONE, value = 0.8f, transitionState = TransitionState.RUNNING ) ) assertThat(isOnLockscreen).isTrue() keyguardTransitionRepository.sendTransitionStep( TransitionStep( to = KeyguardState.LOCKSCREEN, Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt +13 −3 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.onStart /** View-model for the shared notification container, used by both the shade and keyguard spaces */ class SharedNotificationContainerViewModel Loading @@ -45,8 +46,8 @@ constructor( ) { private val statesForConstrainedNotifications = setOf( KeyguardState.LOCKSCREEN, KeyguardState.AOD, KeyguardState.LOCKSCREEN, KeyguardState.DOZING, KeyguardState.ALTERNATE_BOUNCER, KeyguardState.PRIMARY_BOUNCER Loading @@ -68,8 +69,17 @@ constructor( /** If the user is visually on one of the unoccluded lockscreen states. */ val isOnLockscreen: Flow<Boolean> = keyguardTransitionInteractor.finishedKeyguardState .map { statesForConstrainedNotifications.contains(it) } combine( keyguardTransitionInteractor.finishedKeyguardState.map { statesForConstrainedNotifications.contains(it) }, keyguardTransitionInteractor .transitionValue(KeyguardState.LOCKSCREEN) .onStart { emit(0f) } .map { it > 0 } ) { constrainedNotificationState, transitioningToOrFromLockscreen -> constrainedNotificationState || transitioningToOrFromLockscreen } .distinctUntilChanged() /** Are we purely on the keyguard without the shade/qs? */ Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt +17 −1 Original line number Diff line number Diff line Loading @@ -192,10 +192,26 @@ class SharedNotificationContainerViewModelTest : SysuiTestCase() { val isOnLockscreen by collectLastValue(underTest.isOnLockscreen) keyguardTransitionRepository.sendTransitionStep( TransitionStep(to = KeyguardState.GONE, transitionState = TransitionState.FINISHED) TransitionStep( from = KeyguardState.LOCKSCREEN, to = KeyguardState.GONE, value = 1f, transitionState = TransitionState.FINISHED ) ) assertThat(isOnLockscreen).isFalse() // While progressing from lockscreen, should still be true keyguardTransitionRepository.sendTransitionStep( TransitionStep( from = KeyguardState.LOCKSCREEN, to = KeyguardState.GONE, value = 0.8f, transitionState = TransitionState.RUNNING ) ) assertThat(isOnLockscreen).isTrue() keyguardTransitionRepository.sendTransitionStep( TransitionStep( to = KeyguardState.LOCKSCREEN, Loading