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

Commit 5b4ccd58 authored by Alejandro Nijamkin's avatar Alejandro Nijamkin
Browse files

[flexiglass] StatusBarState is SHADE when occluded.

As it turns out, the state needs to be SHADE when system UI is occluded.

To make sure of this, I compared the output of
adb shell dumpsys activity service com.android.systemui/.SystemUIService StatusBarStateControllerImpl | grep mState
when the camera app is occluding system UI in pre-Flexiglass to Flexiglass.

By having it be SHADE, the codepath in
CentralSurfaces.showBouncerOrLockScreenIfKeyguard doesn't actually try
to show the bouncer each time that visibility is changed - which was
continuously causing a change to the bouncer scene behind the occluding
camera activity.

Bug: 349438272
Test: added unit test
Test: manually verified that the scene isn't being changed to bouncer
behind the occluding camera app, this is done using adb logcat -s
SceneFramework
Flag: com.android.systemui.scene_container

Change-Id: Id12cfed12ed31909afc4724e79c2932913c1f6ed
parent 3d6fe892
Loading
Loading
Loading
Loading
+44 −0
Original line number Diff line number Diff line
@@ -40,9 +40,11 @@ import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.model.SuccessFingerprintAuthenticationStatus
import com.android.systemui.kosmos.testScope
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.scene.domain.interactor.sceneContainerOcclusionInteractor
import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.shade.domain.interactor.shadeInteractor
import com.android.systemui.statusbar.domain.interactor.keyguardOcclusionInteractor
import com.android.systemui.testKosmos
import com.android.systemui.util.kotlin.JavaAdapter
import com.android.systemui.util.mockito.mock
@@ -105,6 +107,7 @@ class StatusBarStateControllerImplTest(flags: FlagsParameterization) : SysuiTest
                    { kosmos.shadeInteractor },
                    { kosmos.deviceUnlockedInteractor },
                    { kosmos.sceneInteractor },
                    { kosmos.sceneContainerOcclusionInteractor },
                    { kosmos.keyguardClockInteractor },
                ) {
                override fun createDarkAnimator(): ObjectAnimator {
@@ -335,6 +338,47 @@ class StatusBarStateControllerImplTest(flags: FlagsParameterization) : SysuiTest
            assertThat(statusBarState).isEqualTo(StatusBarState.SHADE)
        }

    @Test
    @EnableSceneContainer
    fun start_hydratesStatusBarState_whileOccluded() =
        testScope.runTest {
            var statusBarState = underTest.state
            val listener =
                object : StatusBarStateController.StateListener {
                    override fun onStateChanged(newState: Int) {
                        statusBarState = newState
                    }
                }
            underTest.addCallback(listener)

            val currentScene by collectLastValue(kosmos.sceneInteractor.currentScene)
            assertThat(currentScene).isEqualTo(Scenes.Lockscreen)
            val isOccluded by
                collectLastValue(kosmos.sceneContainerOcclusionInteractor.invisibleDueToOcclusion)
            kosmos.keyguardOcclusionInteractor.setWmNotifiedShowWhenLockedActivityOnTop(
                showWhenLockedActivityOnTop = true,
                taskInfo = mock(),
            )
            runCurrent()
            assertThat(isOccluded).isTrue()

            // Call start to begin hydrating based on the scene framework:
            underTest.start()

            kosmos.sceneInteractor.changeScene(toScene = Scenes.Shade, loggingReason = "reason")
            runCurrent()
            assertThat(currentScene).isEqualTo(Scenes.Shade)
            assertThat(statusBarState).isEqualTo(StatusBarState.SHADE)

            kosmos.sceneInteractor.changeScene(
                toScene = Scenes.QuickSettings,
                loggingReason = "reason"
            )
            runCurrent()
            assertThat(currentScene).isEqualTo(Scenes.QuickSettings)
            assertThat(statusBarState).isEqualTo(StatusBarState.SHADE)
        }

    @Test
    fun leaveOpenOnKeyguard_whenGone_isFalse() =
        testScope.runTest {
+8 −2
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor;
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor;
import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener;
import com.android.systemui.res.R;
import com.android.systemui.scene.domain.interactor.SceneContainerOcclusionInteractor;
import com.android.systemui.scene.domain.interactor.SceneInteractor;
import com.android.systemui.scene.shared.flag.SceneContainerFlag;
import com.android.systemui.scene.shared.model.Scenes;
@@ -114,6 +115,7 @@ public class StatusBarStateControllerImpl implements
    private final Lazy<ShadeInteractor> mShadeInteractorLazy;
    private final Lazy<DeviceUnlockedInteractor> mDeviceUnlockedInteractorLazy;
    private final Lazy<SceneInteractor> mSceneInteractorLazy;
    private final Lazy<SceneContainerOcclusionInteractor> mSceneContainerOcclusionInteractorLazy;
    private final Lazy<KeyguardClockInteractor> mKeyguardClockInteractorLazy;
    private int mState;
    private int mLastState;
@@ -182,6 +184,7 @@ public class StatusBarStateControllerImpl implements
            Lazy<ShadeInteractor> shadeInteractorLazy,
            Lazy<DeviceUnlockedInteractor> deviceUnlockedInteractorLazy,
            Lazy<SceneInteractor> sceneInteractorLazy,
            Lazy<SceneContainerOcclusionInteractor> sceneContainerOcclusionInteractor,
            Lazy<KeyguardClockInteractor> keyguardClockInteractorLazy) {
        mUiEventLogger = uiEventLogger;
        mInteractionJankMonitorLazy = interactionJankMonitorLazy;
@@ -190,6 +193,7 @@ public class StatusBarStateControllerImpl implements
        mShadeInteractorLazy = shadeInteractorLazy;
        mDeviceUnlockedInteractorLazy = deviceUnlockedInteractorLazy;
        mSceneInteractorLazy = sceneInteractorLazy;
        mSceneContainerOcclusionInteractorLazy = sceneContainerOcclusionInteractor;
        mKeyguardClockInteractorLazy = keyguardClockInteractorLazy;
        for (int i = 0; i < HISTORY_SIZE; i++) {
            mHistoricalRecords[i] = new HistoricalState();
@@ -214,6 +218,7 @@ public class StatusBarStateControllerImpl implements
                    combineFlows(
                        mDeviceUnlockedInteractorLazy.get().getDeviceUnlockStatus(),
                        mSceneInteractorLazy.get().getCurrentScene(),
                        mSceneContainerOcclusionInteractorLazy.get().getInvisibleDueToOcclusion(),
                        this::calculateStateFromSceneFramework),
                    this::onStatusBarStateChanged);
        }
@@ -664,10 +669,11 @@ public class StatusBarStateControllerImpl implements

    private int calculateStateFromSceneFramework(
            DeviceUnlockStatus deviceUnlockStatus,
            SceneKey currentScene) {
            SceneKey currentScene,
            boolean isOccluded) {
        SceneContainerFlag.isUnexpectedlyInLegacyMode();

        if (deviceUnlockStatus.isUnlocked()) {
        if (deviceUnlockStatus.isUnlocked() || isOccluded) {
            return StatusBarState.SHADE;
        } else {
            return Preconditions.checkNotNull(sStatusBarStateByLockedSceneKey.get(currentScene));
+2 −0
Original line number Diff line number Diff line
@@ -464,6 +464,7 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase {
                () -> mShadeInteractor,
                () -> mKosmos.getDeviceUnlockedInteractor(),
                () -> mKosmos.getSceneInteractor(),
                () -> mKosmos.getSceneContainerOcclusionInteractor(),
                () -> mKosmos.getKeyguardClockInteractor());

        KeyguardStatusView keyguardStatusView = new KeyguardStatusView(mContext);
@@ -621,6 +622,7 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase {
                                () -> mShadeInteractor,
                                () -> mKosmos.getDeviceUnlockedInteractor(),
                                () -> mKosmos.getSceneInteractor(),
                                () -> mKosmos.getSceneContainerOcclusionInteractor(),
                                () -> mKosmos.getKeyguardClockInteractor()),
                        mKeyguardBypassController,
                        mDozeParameters,
+2 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import com.android.systemui.model.sceneContainerPlugin
import com.android.systemui.plugins.statusbar.statusBarStateController
import com.android.systemui.power.data.repository.fakePowerRepository
import com.android.systemui.power.domain.interactor.powerInteractor
import com.android.systemui.scene.domain.interactor.sceneContainerOcclusionInteractor
import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.scene.domain.startable.scrimStartable
import com.android.systemui.scene.sceneContainerConfig
@@ -142,4 +143,5 @@ class KosmosJavaAdapter() {
    val ongoingActivityChipsViewModel by lazy { kosmos.ongoingActivityChipsViewModel }
    val scrimController by lazy { kosmos.scrimController }
    val scrimStartable by lazy { kosmos.scrimStartable }
    val sceneContainerOcclusionInteractor by lazy { kosmos.sceneContainerOcclusionInteractor }
}
+2 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import com.android.systemui.jank.interactionJankMonitor
import com.android.systemui.keyguard.domain.interactor.keyguardClockInteractor
import com.android.systemui.keyguard.domain.interactor.keyguardTransitionInteractor
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.scene.domain.interactor.sceneContainerOcclusionInteractor
import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.shade.domain.interactor.shadeInteractor
import com.android.systemui.statusbar.StatusBarStateControllerImpl
@@ -38,6 +39,7 @@ var Kosmos.statusBarStateController: SysuiStatusBarStateController by
            { shadeInteractor },
            { deviceUnlockedInteractor },
            { sceneInteractor },
            { sceneContainerOcclusionInteractor },
            { keyguardClockInteractor },
        )
    }