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

Commit 63b7d688 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[Dual Shade] Hide the status bar when either shade is open." into main

parents 008ca7b3 d61f9dd9
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -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
@@ -555,6 +558,30 @@ class HomeStatusBarViewModelImplTest : SysuiTestCase() {
            assertThat(latest).isTrue()
        }

    @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 {
+36 −0
Original line number Diff line number Diff line
@@ -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() {
@@ -95,6 +98,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 {
@@ -116,6 +128,30 @@ class KeyguardStatusBarViewModelTest(flags: FlagsParameterization) : SysuiTestCa
            assertThat(latest).isFalse()
        }

    @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 {
+12 −6
Original line number Diff line number Diff line
@@ -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(
+8 −2
Original line number Diff line number Diff line
@@ -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)