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

Commit ff09c42b authored by Andrew Xu's avatar Andrew Xu Committed by Android (Google) Code Review
Browse files

Merge "[Flexiglass] Make the shade window focusable when an overlay shows" into main

parents 47ce9996 228ae9f1
Loading
Loading
Loading
Loading
+49 −0
Original line number Diff line number Diff line
@@ -1768,6 +1768,55 @@ class SceneContainerStartableTest : SysuiTestCase() {
            verify(notificationShadeWindowController, times(2)).setNotificationShadeFocusable(false)
        }

    @Test
    fun hydrateWindowController_setNotificationShadeFocusable_dual_shade() =
        kosmos.runTest {
            enableDualShade()
            runCurrent()
            val currentDesiredSceneKey by collectLastValue(sceneInteractor.currentScene)
            val transitionStateFlow = prepareState(
                isDeviceUnlocked = true,
                initialSceneKey = Scenes.Gone,
            )
            assertThat(currentDesiredSceneKey).isEqualTo(Scenes.Gone)
            verify(notificationShadeWindowController, never())
                .setNotificationShadeFocusable(anyBoolean())

            underTest.start()
            runCurrent()

            // By default, the notification shade window should not be focusable.
            verify(notificationShadeWindowController, times(1)).setNotificationShadeFocusable(false)
            verify(notificationShadeWindowController, times(0)).setNotificationShadeFocusable(true)

            sceneInteractor.showOverlay(Overlays.QuickSettingsShade, loggingReason="")
            transitionStateFlow.value =
                ObservableTransitionState.Idle(
                    Scenes.Gone,
                    setOf(Overlays.QuickSettingsShade)
                )

            // When showing the Quick Settings shade with the `Gone` scene, the notification shade
            // window should be focusable.
            runCurrent()
            verify(notificationShadeWindowController, times(1)).setNotificationShadeFocusable(false)
            verify(notificationShadeWindowController, times(1)).setNotificationShadeFocusable(true)

            sceneInteractor.showOverlay(Overlays.NotificationsShade, loggingReason="")
            sceneInteractor.hideOverlay(Overlays.QuickSettingsShade, loggingReason="")
            transitionStateFlow.value =
                ObservableTransitionState.Idle(
                    Scenes.Gone,
                    setOf(Overlays.NotificationsShade)
                )

            // When showing the notification shade with the `Gone` scene, the notification shade
            // window should be focusable.
            runCurrent()
            verify(notificationShadeWindowController, times(1)).setNotificationShadeFocusable(false)
            verify(notificationShadeWindowController, times(2)).setNotificationShadeFocusable(true)
        }

    @Test
    fun hydrateWindowController_setKeyguardShowing() =
        kosmos.runTest {
+6 −5
Original line number Diff line number Diff line
@@ -834,12 +834,13 @@ constructor(
    private fun hydrateWindowController() {
        applicationScope.launch {
            sceneInteractor.transitionState
                .mapNotNull { transitionState ->
                    (transitionState as? ObservableTransitionState.Idle)?.currentScene
                }
                .filterIsInstance<ObservableTransitionState.Idle>()
                .map { it.currentScene to it.currentOverlays }
                .distinctUntilChanged()
                .collect { sceneKey ->
                    windowController.setNotificationShadeFocusable(sceneKey != Scenes.Gone)
                .collect { (currentScene, currentOverlays) ->
                    windowController.setNotificationShadeFocusable(
                        currentScene != Scenes.Gone || currentOverlays.isNotEmpty()
                    )
                }
        }