diff options
4 files changed, 83 insertions, 8 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/HomeStatusBarViewModelImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/HomeStatusBarViewModelImplTest.kt index dc355434c00b..2719e85f5db5 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/HomeStatusBarViewModelImplTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/HomeStatusBarViewModelImplTest.kt @@ -44,6 +44,7 @@ import com.android.systemui.keyguard.shared.model.TransitionStep import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.collectValues +import com.android.systemui.kosmos.runCurrent import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.useUnconfinedTestDispatcher @@ -52,6 +53,7 @@ import com.android.systemui.mediaprojection.data.model.MediaProjectionState import com.android.systemui.mediaprojection.data.repository.fakeMediaProjectionRepository import com.android.systemui.plugins.DarkIconDispatcher import com.android.systemui.scene.data.repository.sceneContainerRepository +import com.android.systemui.scene.shared.model.Overlays import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.screenrecord.data.model.ScreenRecordModel import com.android.systemui.screenrecord.data.repository.screenRecordRepository @@ -90,6 +92,7 @@ import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.test.runCurrent import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @@ -556,6 +559,30 @@ class HomeStatusBarViewModelImplTest : SysuiTestCase() { } @Test + fun isHomeStatusBarAllowedByScene_sceneGoneWithNotificationsShadeOverlay_false() = + kosmos.runTest { + val latest by collectLastValue(underTest.isHomeStatusBarAllowedByScene) + + kosmos.sceneContainerRepository.snapToScene(Scenes.Gone) + kosmos.sceneContainerRepository.showOverlay(Overlays.NotificationsShade) + runCurrent() + + assertThat(latest).isFalse() + } + + @Test + fun isHomeStatusBarAllowedByScene_sceneGoneWithQuickSettingsShadeOverlay_false() = + kosmos.runTest { + val latest by collectLastValue(underTest.isHomeStatusBarAllowedByScene) + + kosmos.sceneContainerRepository.snapToScene(Scenes.Gone) + kosmos.sceneContainerRepository.showOverlay(Overlays.QuickSettingsShade) + runCurrent() + + assertThat(latest).isFalse() + } + + @Test fun shouldShowOperatorNameView_allowedByInteractor_allowedByDisableFlags_visible() = kosmos.runTest { kosmos.setHomeStatusBarInteractorShowOperatorName(true) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/ui/viewmodel/KeyguardStatusBarViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/ui/viewmodel/KeyguardStatusBarViewModelTest.kt index ebb4697d800e..381ac1519ce8 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/ui/viewmodel/KeyguardStatusBarViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/ui/viewmodel/KeyguardStatusBarViewModelTest.kt @@ -32,6 +32,7 @@ import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.kosmos.testScope import com.android.systemui.scene.data.repository.sceneContainerRepository import com.android.systemui.scene.domain.interactor.sceneInteractor +import com.android.systemui.scene.shared.model.Overlays import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.statusbar.domain.interactor.keyguardStatusBarInteractor import com.android.systemui.statusbar.headsup.shared.StatusBarNoHunBehavior @@ -44,6 +45,7 @@ import com.android.systemui.testKosmos import com.android.systemui.util.mockito.argumentCaptor import com.android.systemui.util.mockito.capture import com.google.common.truth.Truth.assertThat +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest @@ -54,6 +56,7 @@ import org.mockito.Mockito.verify import platform.test.runner.parameterized.ParameterizedAndroidJunit4 import platform.test.runner.parameterized.Parameters +@OptIn(ExperimentalCoroutinesApi::class) @SmallTest @RunWith(ParameterizedAndroidJunit4::class) class KeyguardStatusBarViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { @@ -96,6 +99,15 @@ class KeyguardStatusBarViewModelTest(flags: FlagsParameterization) : SysuiTestCa } @Test + fun isVisible_lockscreen_true() = + testScope.runTest { + val latest by collectLastValue(underTest.isVisible) + kosmos.sceneContainerRepository.snapToScene(Scenes.Lockscreen) + + assertThat(latest).isTrue() + } + + @Test fun isVisible_dozing_false() = testScope.runTest { val latest by collectLastValue(underTest.isVisible) @@ -117,6 +129,30 @@ class KeyguardStatusBarViewModelTest(flags: FlagsParameterization) : SysuiTestCa } @Test + fun isVisible_notificationsShadeOverlay_false() = + testScope.runTest { + val latest by collectLastValue(underTest.isVisible) + + kosmos.sceneContainerRepository.snapToScene(Scenes.Lockscreen) + kosmos.sceneContainerRepository.showOverlay(Overlays.NotificationsShade) + runCurrent() + + assertThat(latest).isFalse() + } + + @Test + fun isVisible_quickSettingsShadeOverlay_false() = + testScope.runTest { + val latest by collectLastValue(underTest.isVisible) + + kosmos.sceneContainerRepository.snapToScene(Scenes.Lockscreen) + kosmos.sceneContainerRepository.showOverlay(Overlays.QuickSettingsShade) + runCurrent() + + assertThat(latest).isFalse() + } + + @Test fun isVisible_sceneBouncer_false() = testScope.runTest { val latest by collectLastValue(underTest.isVisible) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/HomeStatusBarViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/HomeStatusBarViewModel.kt index 67366bb09f04..df6a2fe3597e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/HomeStatusBarViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/HomeStatusBarViewModel.kt @@ -34,6 +34,7 @@ import com.android.systemui.plugins.DarkIconDispatcher import com.android.systemui.scene.domain.interactor.SceneContainerOcclusionInteractor import com.android.systemui.scene.domain.interactor.SceneInteractor import com.android.systemui.scene.shared.flag.SceneContainerFlag +import com.android.systemui.scene.shared.model.Overlays import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.shade.domain.interactor.ShadeInteractor import com.android.systemui.statusbar.chips.mediaprojection.domain.model.MediaProjectionStopDialogModel @@ -228,14 +229,19 @@ constructor( override val isHomeStatusBarAllowedByScene: StateFlow<Boolean> = combine( sceneInteractor.currentScene, + sceneInteractor.currentOverlays, sceneContainerOcclusionInteractor.invisibleDueToOcclusion, - ) { currentScene, isOccluded -> + ) { currentScene, currentOverlays, isOccluded -> // All scenes have their own status bars, so we should only show the home status bar - // if we're not in a scene. The one exception: If the scene is occluded, then the - // occluding app needs to show the status bar. (Fullscreen apps actually won't show - // the status bar but that's handled with the rest of our fullscreen app logic, - // which lives elsewhere.) - currentScene == Scenes.Gone || isOccluded + // if we're not in a scene. There are two exceptions: + // 1) The shade (notifications or quick settings) is shown, because it has its own + // status-bar-like header. + // 2) If the scene is occluded, then the occluding app needs to show the status bar. + // (Fullscreen apps actually won't show the status bar but that's handled with the + // rest of our fullscreen app logic, which lives elsewhere.) + (currentScene == Scenes.Gone && + Overlays.NotificationsShade !in currentOverlays && + Overlays.QuickSettingsShade !in currentOverlays) || isOccluded } .distinctUntilChanged() .logDiffsForTable( diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ui/viewmodel/KeyguardStatusBarViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/ui/viewmodel/KeyguardStatusBarViewModel.kt index 12ef68dafa64..7d9a7d49cf7f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/ui/viewmodel/KeyguardStatusBarViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/ui/viewmodel/KeyguardStatusBarViewModel.kt @@ -22,6 +22,7 @@ import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.scene.domain.interactor.SceneInteractor import com.android.systemui.scene.shared.flag.SceneContainerFlag +import com.android.systemui.scene.shared.model.Overlays import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.statusbar.domain.interactor.KeyguardStatusBarInteractor import com.android.systemui.statusbar.headsup.shared.StatusBarNoHunBehavior @@ -70,10 +71,15 @@ constructor( val isVisible: StateFlow<Boolean> = combine( sceneInteractor.currentScene, + sceneInteractor.currentOverlays, keyguardInteractor.isDozing, showingHeadsUpStatusBar, - ) { currentScene, isDozing, showHeadsUpStatusBar -> - currentScene == Scenes.Lockscreen && !isDozing && !showHeadsUpStatusBar + ) { currentScene, currentOverlays, isDozing, showHeadsUpStatusBar -> + currentScene == Scenes.Lockscreen && + Overlays.NotificationsShade !in currentOverlays && + Overlays.QuickSettingsShade !in currentOverlays && + !isDozing && + !showHeadsUpStatusBar } .stateIn(scope, SharingStarted.WhileSubscribed(), false) |