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

Commit 508e1180 authored by Chris Göllner's avatar Chris Göllner Committed by Android (Google) Code Review
Browse files

Merge "Fix status bar not showing when shade expanded on another display" into main

parents 58ca0115 73d3fc97
Loading
Loading
Loading
Loading
+44 −0
Original line number Diff line number Diff line
@@ -674,6 +674,50 @@ class HomeStatusBarViewModelImplTest(flags: FlagsParameterization) : SysuiTestCa
            assertThat(latest).isFalse()
        }

    @Test
    @EnableFlags(Flags.FLAG_SHADE_WINDOW_GOES_AROUND)
    @EnableSceneContainer
    fun isHomeStatusBarAllowed_onExternalDisplay_whenNotificationShadeIsVisibleOnDefaultDisplay_isTrue() =
        kosmos.runTest {
            val underTest = homeStatusBarViewModelFactory(EXTERNAL_DISPLAY)
            val latest by collectLastValue(underTest.isHomeStatusBarAllowed)

            sceneContainerRepository.instantlyTransitionTo(Scenes.Gone)
            sceneContainerRepository.showOverlay(Overlays.NotificationsShade)
            fakeShadeDisplaysRepository.setDisplayId(DEFAULT_DISPLAY)

            assertThat(latest).isTrue()
        }

    @Test
    @EnableFlags(Flags.FLAG_SHADE_WINDOW_GOES_AROUND)
    @EnableSceneContainer
    fun isHomeStatusBarAllowed_onDefaultDisplay_whenShadeIsVisibleOnDefaultDisplay_isFalse() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.isHomeStatusBarAllowed)

            sceneContainerRepository.instantlyTransitionTo(Scenes.Gone)
            sceneContainerRepository.showOverlay(Overlays.QuickSettingsShade)
            fakeShadeDisplaysRepository.setDisplayId(DEFAULT_DISPLAY)

            assertThat(latest).isFalse()
        }

    @Test
    @EnableFlags(Flags.FLAG_SHADE_WINDOW_GOES_AROUND)
    @EnableSceneContainer
    fun isHomeStatusBarAllowed_onExternalDisplay_whenShadeIsVisibleOnDefaultDisplay_isTrue() =
        kosmos.runTest {
            val underTest = homeStatusBarViewModelFactory(EXTERNAL_DISPLAY)
            val latest by collectLastValue(underTest.isHomeStatusBarAllowed)

            sceneContainerRepository.instantlyTransitionTo(Scenes.Gone)
            sceneContainerRepository.showOverlay(Overlays.QuickSettingsShade)
            fakeShadeDisplaysRepository.setDisplayId(DEFAULT_DISPLAY)

            assertThat(latest).isTrue()
        }

    @Test
    fun shouldShowOperatorNameView_allowedByInteractor_allowedByDisableFlags_visible() =
        kosmos.runTest {
+12 −11
Original line number Diff line number Diff line
@@ -348,18 +348,19 @@ constructor(
    private val isHomeStatusBarAllowedByScene: Flow<Boolean> =
        combine(
                sceneInteractor.currentScene,
                isShadeVisibleOnThisDisplay,
                isShadeVisibleOnAnyDisplay,
                sceneContainerOcclusionInteractor.invisibleDueToOcclusion,
            ) { currentScene, isShadeVisible, isOccluded ->

                // All scenes have their own status bars, so we should only show the home status bar
                // 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 && !isShadeVisible) || isOccluded
                isShadeWindowOnThisDisplay,
            ) { currentScene, isShadeVisibleOnAnyDisplay, isOccluded, isShadeWindowOnThisDisplay ->
                if (isOccluded) {
                    true
                } else if (isShadeWindowOnThisDisplay) {
                    currentScene == Scenes.Gone && !isShadeVisibleOnAnyDisplay
                } else {
                    // When the shade is visible on another display,
                    // allow the home status bar on the current display.
                    currentScene == Scenes.Gone || isShadeVisibleOnAnyDisplay
                }
            }
            .distinctUntilChanged()
            .logDiffsForTable(