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

Commit 5c48f380 authored by Ale Nijamkin's avatar Ale Nijamkin
Browse files

[flexiglass] Fixes user switching issue.

In ag/32362050, we tied lockscreenVisibilityWithScenes to the visibility
of the scene container because that already took device provisioning
into account. As it turns out, that's doing too much.

Because now lockscreenVisibilityWithScenes is returning false when the
scene container isn't visible which is then checked indirectly from
KeyguardViewMediator when attempting to respond to commands from system
server when the user is switched.

By changing lockscreenVisibilityWithScenes to more narrowly depend on
isDeviceProvisioned, we let KeyguardViewMediator see that lockscreen is
visible when it needs to be as part of user switching.

Fix: 408267151
Test: unit test updated and passes
Test: manually verified that switching to and from a secondary user on a
phone works as expected and doesn't just time out and restart as it did
before
Test: factory reset the device to enter device provisioning mode (when
setup wizard is shown) and verified that the lockscreen isn't showing
and that it shows up again once the setup wizard is skipped; also
checked the SysUiState via the command from ag/32362050
Flag: com.android.systemui.scene_container

Change-Id: I35bcdaeeda523e761b4b231b5af70d726a465c4d
parent dab48225
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import com.android.systemui.scene.domain.interactor.sceneBackInteractor
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.policy.data.repository.fakeDeviceProvisioningRepository
import com.android.systemui.testKosmos
import com.android.systemui.util.mockito.mock
import com.android.systemui.util.mockito.whenever
@@ -340,14 +341,14 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() {

    @Test
    @EnableSceneContainer
    fun surfaceBehindVisibility_whileSceneContainerNotVisible_alwaysTrue() =
    fun surfaceBehindVisibility_whileDeviceNotProvisioned_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")
            kosmos.fakeDeviceProvisioningRepository.setDeviceProvisioned(false)
            runCurrent()

            assertThat(currentScene).isEqualTo(Scenes.Lockscreen)
+6 −5
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ 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.notification.domain.interactor.NotificationLaunchAnimationInteractor
import com.android.systemui.statusbar.policy.domain.interactor.DeviceProvisioningInteractor
import com.android.systemui.util.kotlin.Utils.Companion.toQuad
import com.android.systemui.utils.coroutines.flow.flatMapLatestConflated
import dagger.Lazy
@@ -57,6 +58,7 @@ constructor(
    sceneInteractor: Lazy<SceneInteractor>,
    deviceEntryInteractor: Lazy<DeviceEntryInteractor>,
    wakeToGoneInteractor: KeyguardWakeDirectlyToGoneInteractor,
    deviceProvisioningInteractor: Lazy<DeviceProvisioningInteractor>,
) {
    private val defaultSurfaceBehindVisibility =
        combine(
@@ -197,10 +199,9 @@ constructor(
        }

    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) {
        deviceProvisioningInteractor.get().isDeviceProvisioned.flatMapLatestConflated {
            isProvisioned ->
            if (isProvisioned) {
                combine(
                        sceneInteractor.get().transitionState.flatMapLatestConflated {
                            when (it) {
@@ -236,7 +237,7 @@ constructor(
                        lockscreenVisibilityByTransitionState && !canWakeDirectlyToGone
                    }
            } else {
                // Lockscreen is never visible when the scene container is invisible.
                // Lockscreen is never visible when the device isn't provisioned.
                flowOf(false)
            }
        }
+2 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import com.android.systemui.keyguard.data.repository.keyguardTransitionRepositor
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.statusbar.notification.domain.interactor.notificationLaunchAnimationInteractor
import com.android.systemui.statusbar.policy.domain.interactor.deviceProvisioningInteractor

val Kosmos.windowManagerLockscreenVisibilityInteractor by
    Kosmos.Fixture {
@@ -36,5 +37,6 @@ val Kosmos.windowManagerLockscreenVisibilityInteractor by
            sceneInteractor = { sceneInteractor },
            deviceEntryInteractor = { deviceEntryInteractor },
            wakeToGoneInteractor = keyguardWakeDirectlyToGoneInteractor,
            deviceProvisioningInteractor = { deviceProvisioningInteractor },
        )
    }