Loading packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/DreamOverlayServiceTest.kt +34 −0 Original line number Diff line number Diff line Loading @@ -1035,6 +1035,7 @@ class DreamOverlayServiceTest(flags: FlagsParameterization?) : SysuiTestCase() { assertThat(lifecycleRegistry.currentState).isEqualTo(Lifecycle.State.RESUMED) } @DisableFlags(FLAG_SCENE_CONTAINER) @Test fun testBouncerShown_setsLifecycleState() { val client = client Loading Loading @@ -1067,6 +1068,39 @@ class DreamOverlayServiceTest(flags: FlagsParameterization?) : SysuiTestCase() { assertThat(lifecycleRegistry.currentState).isEqualTo(Lifecycle.State.RESUMED) } @EnableFlags(FLAG_SCENE_CONTAINER) @Test fun testBouncerShown_withSceneContainer_setsLifecycleState() { val client = client // Inform the overlay service of dream starting. client.startDream( mWindowParams, mDreamOverlayCallback, DREAM_COMPONENT, false /*isPreview*/, false, /*shouldShowComplication*/ ) mMainExecutor.runAllReady() assertThat(lifecycleRegistry.currentState).isEqualTo(Lifecycle.State.RESUMED) // Bouncer shows. kosmos.sceneInteractor.changeScene(Scenes.Bouncer, "test") testScope.runCurrent() mMainExecutor.runAllReady() // Lifecycle state goes from resumed back to started when the bouncer shows. assertThat(lifecycleRegistry.currentState).isEqualTo(Lifecycle.State.STARTED) // Bouncer closes. kosmos.sceneInteractor.changeScene(Scenes.Dream, "test") testScope.runCurrent() mMainExecutor.runAllReady() // Lifecycle state goes back to RESUMED. assertThat(lifecycleRegistry.currentState).isEqualTo(Lifecycle.State.RESUMED) } @Test @DisableFlags(FLAG_SCENE_CONTAINER) fun testCommunalVisible_setsLifecycleState() { Loading packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java +26 −11 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import androidx.lifecycle.ServiceLifecycleDispatcher; import androidx.lifecycle.ViewModelStore; import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.compose.animation.scene.SceneKey; import com.android.dream.lowlight.dagger.LowLightDreamModule; import com.android.internal.logging.UiEvent; import com.android.internal.logging.UiEventLogger; Loading Loading @@ -212,16 +213,14 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ private final Consumer<Boolean> mBouncerShowingConsumer = new Consumer<>() { @Override public void accept(Boolean bouncerShowing) { mExecutor.execute(() -> { if (mBouncerShowing == bouncerShowing) { return; mExecutor.execute(() -> updateBouncerShowingLocked(bouncerShowing)); } }; mBouncerShowing = bouncerShowing; updateLifecycleStateLocked(); updateGestureBlockingLocked(); }); private final Consumer<SceneKey> mCurrentSceneConsumer = new Consumer<>() { @Override public void accept(SceneKey currentScene) { mExecutor.execute(() -> updateBouncerShowingLocked(currentScene == Scenes.Bouncer)); } }; Loading Loading @@ -425,9 +424,14 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ mIsCommunalAvailableCallback)); mFlows.add(collectFlow(getLifecycle(), communalInteractor.isCommunalVisible(), mCommunalVisibleConsumer)); if (SceneContainerFlag.isEnabled()) { mFlows.add(collectFlow(getLifecycle(), sceneInteractor.getCurrentScene(), mCurrentSceneConsumer)); } else { mFlows.add(collectFlow(getLifecycle(), keyguardInteractor.primaryBouncerShowing, mBouncerShowingConsumer)); } } @NonNull @Override Loading Loading @@ -707,4 +711,15 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ Log.w(TAG, "Removing dream overlay container view parent!"); parentView.removeView(containerView); } private void updateBouncerShowingLocked(boolean bouncerShowing) { if (mBouncerShowing == bouncerShowing) { return; } mBouncerShowing = bouncerShowing; updateLifecycleStateLocked(); updateGestureBlockingLocked(); } } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/DreamOverlayServiceTest.kt +34 −0 Original line number Diff line number Diff line Loading @@ -1035,6 +1035,7 @@ class DreamOverlayServiceTest(flags: FlagsParameterization?) : SysuiTestCase() { assertThat(lifecycleRegistry.currentState).isEqualTo(Lifecycle.State.RESUMED) } @DisableFlags(FLAG_SCENE_CONTAINER) @Test fun testBouncerShown_setsLifecycleState() { val client = client Loading Loading @@ -1067,6 +1068,39 @@ class DreamOverlayServiceTest(flags: FlagsParameterization?) : SysuiTestCase() { assertThat(lifecycleRegistry.currentState).isEqualTo(Lifecycle.State.RESUMED) } @EnableFlags(FLAG_SCENE_CONTAINER) @Test fun testBouncerShown_withSceneContainer_setsLifecycleState() { val client = client // Inform the overlay service of dream starting. client.startDream( mWindowParams, mDreamOverlayCallback, DREAM_COMPONENT, false /*isPreview*/, false, /*shouldShowComplication*/ ) mMainExecutor.runAllReady() assertThat(lifecycleRegistry.currentState).isEqualTo(Lifecycle.State.RESUMED) // Bouncer shows. kosmos.sceneInteractor.changeScene(Scenes.Bouncer, "test") testScope.runCurrent() mMainExecutor.runAllReady() // Lifecycle state goes from resumed back to started when the bouncer shows. assertThat(lifecycleRegistry.currentState).isEqualTo(Lifecycle.State.STARTED) // Bouncer closes. kosmos.sceneInteractor.changeScene(Scenes.Dream, "test") testScope.runCurrent() mMainExecutor.runAllReady() // Lifecycle state goes back to RESUMED. assertThat(lifecycleRegistry.currentState).isEqualTo(Lifecycle.State.RESUMED) } @Test @DisableFlags(FLAG_SCENE_CONTAINER) fun testCommunalVisible_setsLifecycleState() { Loading
packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java +26 −11 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import androidx.lifecycle.ServiceLifecycleDispatcher; import androidx.lifecycle.ViewModelStore; import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.compose.animation.scene.SceneKey; import com.android.dream.lowlight.dagger.LowLightDreamModule; import com.android.internal.logging.UiEvent; import com.android.internal.logging.UiEventLogger; Loading Loading @@ -212,16 +213,14 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ private final Consumer<Boolean> mBouncerShowingConsumer = new Consumer<>() { @Override public void accept(Boolean bouncerShowing) { mExecutor.execute(() -> { if (mBouncerShowing == bouncerShowing) { return; mExecutor.execute(() -> updateBouncerShowingLocked(bouncerShowing)); } }; mBouncerShowing = bouncerShowing; updateLifecycleStateLocked(); updateGestureBlockingLocked(); }); private final Consumer<SceneKey> mCurrentSceneConsumer = new Consumer<>() { @Override public void accept(SceneKey currentScene) { mExecutor.execute(() -> updateBouncerShowingLocked(currentScene == Scenes.Bouncer)); } }; Loading Loading @@ -425,9 +424,14 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ mIsCommunalAvailableCallback)); mFlows.add(collectFlow(getLifecycle(), communalInteractor.isCommunalVisible(), mCommunalVisibleConsumer)); if (SceneContainerFlag.isEnabled()) { mFlows.add(collectFlow(getLifecycle(), sceneInteractor.getCurrentScene(), mCurrentSceneConsumer)); } else { mFlows.add(collectFlow(getLifecycle(), keyguardInteractor.primaryBouncerShowing, mBouncerShowingConsumer)); } } @NonNull @Override Loading Loading @@ -707,4 +711,15 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ Log.w(TAG, "Removing dream overlay container view parent!"); parentView.removeView(containerView); } private void updateBouncerShowingLocked(boolean bouncerShowing) { if (mBouncerShowing == bouncerShowing) { return; } mBouncerShowing = bouncerShowing; updateLifecycleStateLocked(); updateGestureBlockingLocked(); } }