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

Commit 1b20f607 authored by Ale Nijamkin's avatar Ale Nijamkin
Browse files

[flexiglass] SUW visible again.

The setup wizard (SUW) wasn't shown because Flexiglass was incorrectly
reporting to WindowManager (WM) that the keyguard is visible.

By changing the lockscreenVisibilityWithScenes flow to take
SceneInteractor.isVisible into account, we fix this issue.

The reason this works is because, when Flexiglass is on,
WindowManagerLockscreenVisibilityInteractor.surfaceBehindVisibility is
what determines what System UI reports to WM and surfaceBehindVisibility
depends on lockscreenVisibilityWithScenes. The SceneInteractor.isVisible
state is fed by the SceneContainerStartable, setting it to false when
device provisioning is still ongoing (which is the state when SUW is
showing).

Fix: 396690884
Test: unit tests added
Test: manually verified that the SysUiState dump ($ adb shell dumpsys activity service com.android.systemui/.SystemUIService | grep SysUiState -A 10)
is the same when flexiglass is on as it is when it's off
Test: manually verified that SUW is visible when Flexiglass is on and
that skipping SUW makes the scene container be visible again
Flag: com.android.systemui.scene_container

Change-Id: I01d8e19250346bfe02ef730b44b41a2dbb63afd0
parent 4d68d7bb
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -338,6 +338,22 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() {
            }
        }

    @Test
    @EnableSceneContainer
    fun surfaceBehindVisibility_whileSceneContainerNotVisible_alwaysTrue() =
        testScope.runTest {
            val isSurfaceBehindVisible by collectLastValue(underTest.value.surfaceBehindVisibility)
            val currentScene by collectLastValue(kosmos.sceneInteractor.currentScene)
            assertThat(currentScene).isEqualTo(Scenes.Lockscreen)
            assertThat(isSurfaceBehindVisible).isFalse()

            kosmos.sceneInteractor.setVisible(false, "test")
            runCurrent()

            assertThat(currentScene).isEqualTo(Scenes.Lockscreen)
            assertThat(isSurfaceBehindVisible).isTrue()
        }

    @Test
    @EnableSceneContainer
    fun surfaceBehindVisibility_idleWhileLocked_alwaysFalse() =
+41 −30
Original line number Diff line number Diff line
@@ -196,23 +196,30 @@ constructor(
                .distinctUntilChanged()
        }

    private val lockscreenVisibilityWithScenes =
    private val lockscreenVisibilityWithScenes: Flow<Boolean> =
        // The scene container visibility into account as that will be forced to false when the
        // device isn't yet provisioned (e.g. still in the setup wizard).
        sceneInteractor.get().isVisible.flatMapLatestConflated { isVisible ->
            if (isVisible) {
                combine(
                        sceneInteractor.get().transitionState.flatMapLatestConflated {
                            when (it) {
                        is Idle -> {
                                is Idle ->
                                    when (it.currentScene) {
                                        in keyguardContent -> flowOf(true)
                                        in nonKeyguardContent -> flowOf(false)
                                        in keyguardAgnosticContent -> isDeviceNotEnteredDirectly
                                        else ->
                                    throw IllegalStateException("Unknown scene: ${it.currentScene}")
                            }
                                            throw IllegalStateException(
                                                "Unknown scene: ${it.currentScene}"
                                            )
                                    }
                        is Transition -> {
                                is Transition ->
                                    when {
                                it.isTransitioningSets(from = keyguardContent) -> flowOf(true)
                                it.isTransitioningSets(from = nonKeyguardContent) -> flowOf(false)
                                        it.isTransitioningSets(from = keyguardContent) ->
                                            flowOf(true)
                                        it.isTransitioningSets(from = nonKeyguardContent) ->
                                            flowOf(false)
                                        it.isTransitioningSets(from = keyguardAgnosticContent) ->
                                            isDeviceNotEnteredDirectly
                                        else ->
@@ -221,7 +228,6 @@ constructor(
                                            )
                                    }
                            }
                    }
                        },
                        wakeToGoneInteractor.canWakeDirectlyToGone,
                        ::Pair,
@@ -229,6 +235,11 @@ constructor(
                    .map { (lockscreenVisibilityByTransitionState, canWakeDirectlyToGone) ->
                        lockscreenVisibilityByTransitionState && !canWakeDirectlyToGone
                    }
            } else {
                // Lockscreen is never visible when the scene container is invisible.
                flowOf(false)
            }
        }

    private val lockscreenVisibilityLegacy =
        combine(
+2 −1
Original line number Diff line number Diff line
@@ -195,7 +195,8 @@ constructor(
                    return
                }

                printSection("Scene state") {
                printSection("Framework state") {
                    println("isVisible", sceneInteractor.isVisible.value)
                    println("currentScene", sceneInteractor.currentScene.value.debugName)
                    println(
                        "currentOverlays",