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

Commit 228ae9f1 authored by Andrew X's avatar Andrew X
Browse files

[Flexiglass] Make the shade window focusable when an overlay shows

This CL ensures that the notification shade window is focusable when
an overlay shows.

Bug: 434639832
Flag: EXEMPT bugfix
Test:com.android.systemui.scene.domain.startable.SceneContainerStartableTest
Change-Id: I34d53a70f6876831b4d15506a05b06fa38d33302
parent df7dfcb9
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()
                    )
                }
        }