Loading packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalDreamStartableTest.kt +61 −13 Original line number Diff line number Diff line Loading @@ -16,14 +16,17 @@ package com.android.systemui.communal import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import android.platform.test.flag.junit.FlagsParameterization import android.service.dream.dreamManager import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.Flags import com.android.systemui.Flags.FLAG_GLANCEABLE_HUB_V2 import com.android.systemui.SysuiTestCase import com.android.systemui.communal.domain.interactor.communalSceneInteractor import com.android.systemui.communal.domain.interactor.communalSettingsInteractor import com.android.systemui.communal.domain.interactor.setCommunalV2Enabled import com.android.systemui.flags.Flags.COMMUNAL_SERVICE_ENABLED import com.android.systemui.flags.fakeFeatureFlagsClassic import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository Loading @@ -48,12 +51,14 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mockito.never import org.mockito.Mockito.verify import platform.test.runner.parameterized.ParameterizedAndroidJunit4 import platform.test.runner.parameterized.Parameters @OptIn(ExperimentalCoroutinesApi::class) @SmallTest @EnableFlags(Flags.FLAG_COMMUNAL_HUB) @RunWith(AndroidJUnit4::class) class CommunalDreamStartableTest : SysuiTestCase() { @RunWith(ParameterizedAndroidJunit4::class) class CommunalDreamStartableTest(flags: FlagsParameterization) : SysuiTestCase() { private val kosmos = testKosmos() private val testScope = kosmos.testScope Loading @@ -63,6 +68,10 @@ class CommunalDreamStartableTest : SysuiTestCase() { private val keyguardRepository by lazy { kosmos.fakeKeyguardRepository } private val powerRepository by lazy { kosmos.fakePowerRepository } init { mSetFlagsRule.setFlagsParameterization(flags) } @Before fun setUp() { kosmos.fakeFeatureFlagsClassic.set(COMMUNAL_SERVICE_ENABLED, true) Loading @@ -77,12 +86,32 @@ class CommunalDreamStartableTest : SysuiTestCase() { communalSceneInteractor = kosmos.communalSceneInteractor, bgScope = kosmos.applicationCoroutineScope, ) .apply { start() } } @EnableFlags(FLAG_GLANCEABLE_HUB_V2) @Test fun dreamNotStartedWhenTransitioningToHub() = testScope.runTest { // Enable v2 flag and recreate + rerun start method. kosmos.setCommunalV2Enabled(true) underTest.start() keyguardRepository.setKeyguardShowing(true) keyguardRepository.setDreaming(false) powerRepository.setScreenPowerState(ScreenPowerState.SCREEN_ON) whenever(dreamManager.canStartDreaming(/* isScreenOn= */ true)).thenReturn(true) runCurrent() transition(from = KeyguardState.DREAMING, to = KeyguardState.GLANCEABLE_HUB) verify(dreamManager, never()).startDream() } @DisableFlags(FLAG_GLANCEABLE_HUB_V2) @Test fun startDreamWhenTransitioningToHub() = testScope.runTest { underTest.start() keyguardRepository.setKeyguardShowing(true) keyguardRepository.setDreaming(false) powerRepository.setScreenPowerState(ScreenPowerState.SCREEN_ON) Loading @@ -100,6 +129,7 @@ class CommunalDreamStartableTest : SysuiTestCase() { @EnableFlags(Flags.FLAG_RESTART_DREAM_ON_UNOCCLUDE) fun restartDreamingWhenTransitioningFromDreamingToOccludedToDreaming() = testScope.runTest { underTest.start() keyguardRepository.setDreaming(false) powerRepository.setScreenPowerState(ScreenPowerState.SCREEN_ON) whenever(dreamManager.canStartDreaming(/* isScreenOn= */ true)).thenReturn(true) Loading @@ -122,9 +152,11 @@ class CommunalDreamStartableTest : SysuiTestCase() { verify(dreamManager).startDream() } @DisableFlags(FLAG_GLANCEABLE_HUB_V2) @Test fun shouldNotStartDreamWhenIneligibleToDream() = testScope.runTest { underTest.start() keyguardRepository.setDreaming(false) powerRepository.setScreenPowerState(ScreenPowerState.SCREEN_ON) // Not eligible to dream Loading @@ -134,9 +166,11 @@ class CommunalDreamStartableTest : SysuiTestCase() { verify(dreamManager, never()).startDream() } @DisableFlags(FLAG_GLANCEABLE_HUB_V2) @Test fun shouldNotStartDreamIfAlreadyDreaming() = testScope.runTest { underTest.start() keyguardRepository.setDreaming(true) powerRepository.setScreenPowerState(ScreenPowerState.SCREEN_ON) whenever(dreamManager.canStartDreaming(/* isScreenOn= */ true)).thenReturn(true) Loading @@ -145,9 +179,11 @@ class CommunalDreamStartableTest : SysuiTestCase() { verify(dreamManager, never()).startDream() } @DisableFlags(FLAG_GLANCEABLE_HUB_V2) @Test fun shouldNotStartDreamForInvalidTransition() = testScope.runTest { underTest.start() keyguardRepository.setDreaming(true) powerRepository.setScreenPowerState(ScreenPowerState.SCREEN_ON) whenever(dreamManager.canStartDreaming(/* isScreenOn= */ true)).thenReturn(true) Loading @@ -160,9 +196,11 @@ class CommunalDreamStartableTest : SysuiTestCase() { } } @DisableFlags(FLAG_GLANCEABLE_HUB_V2) @Test fun shouldNotStartDreamWhenLaunchingWidget() = testScope.runTest { underTest.start() keyguardRepository.setKeyguardShowing(true) keyguardRepository.setDreaming(false) powerRepository.setScreenPowerState(ScreenPowerState.SCREEN_ON) Loading @@ -175,9 +213,11 @@ class CommunalDreamStartableTest : SysuiTestCase() { verify(dreamManager, never()).startDream() } @DisableFlags(FLAG_GLANCEABLE_HUB_V2) @Test fun shouldNotStartDreamWhenOccluded() = testScope.runTest { underTest.start() keyguardRepository.setKeyguardShowing(true) keyguardRepository.setDreaming(false) powerRepository.setScreenPowerState(ScreenPowerState.SCREEN_ON) Loading @@ -194,8 +234,16 @@ class CommunalDreamStartableTest : SysuiTestCase() { kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps( from = from, to = to, testScope = this testScope = this, ) runCurrent() } companion object { @JvmStatic @Parameters(name = "{0}") fun getParams(): List<FlagsParameterization> { return FlagsParameterization.allCombinationsOf(FLAG_GLANCEABLE_HUB_V2) } } } packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/DreamOverlayServiceTest.kt +30 −2 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ import com.android.systemui.communal.domain.interactor.communalInteractor import com.android.systemui.communal.domain.interactor.communalSettingsInteractor import com.android.systemui.communal.domain.interactor.setCommunalAvailable import com.android.systemui.communal.domain.interactor.setCommunalV2ConfigEnabled import com.android.systemui.communal.domain.interactor.setCommunalV2Enabled import com.android.systemui.communal.shared.log.CommunalUiEvent import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.complication.ComplicationHostViewController Loading Loading @@ -747,7 +748,7 @@ class DreamOverlayServiceTest(flags: FlagsParameterization?) : SysuiTestCase() { @Test @EnableFlags(Flags.FLAG_DREAM_WAKE_REDIRECT, FLAG_COMMUNAL_HUB) @DisableFlags(FLAG_SCENE_CONTAINER) @DisableFlags(FLAG_SCENE_CONTAINER, FLAG_GLANCEABLE_HUB_V2) @kotlin.Throws(RemoteException::class) fun testTransitionToGlanceableHub() = testScope.runTest { Loading @@ -774,6 +775,7 @@ class DreamOverlayServiceTest(flags: FlagsParameterization?) : SysuiTestCase() { @Test @EnableFlags(Flags.FLAG_DREAM_WAKE_REDIRECT, FLAG_SCENE_CONTAINER, FLAG_COMMUNAL_HUB) @DisableFlags(FLAG_GLANCEABLE_HUB_V2) @kotlin.Throws(RemoteException::class) fun testTransitionToGlanceableHub_sceneContainer() = testScope.runTest { Loading Loading @@ -801,8 +803,30 @@ class DreamOverlayServiceTest(flags: FlagsParameterization?) : SysuiTestCase() { verify(mUiEventLogger).log(CommunalUiEvent.DREAM_TO_COMMUNAL_HUB_DREAM_AWAKE_START) } @Test @EnableFlags(Flags.FLAG_DREAM_WAKE_REDIRECT, FLAG_COMMUNAL_HUB, FLAG_GLANCEABLE_HUB_V2) @Throws(RemoteException::class) fun testRedirect_v2Enabled_notTriggered() = testScope.runTest { kosmos.setCommunalV2Enabled(true) // Inform the overlay service of dream starting. Do not show dream complications. client.startDream( mWindowParams, mDreamOverlayCallback, DREAM_COMPONENT, false /*isPreview*/, false, /*shouldShowComplication*/ ) // Set communal available, verify that onRedirectWake is never called. kosmos.setCommunalAvailable(true) mMainExecutor.runAllReady() runCurrent() verify(mDreamOverlayCallback, never()).onRedirectWake(any()) } @Test @EnableFlags(Flags.FLAG_DREAM_WAKE_REDIRECT, FLAG_COMMUNAL_HUB) @DisableFlags(FLAG_GLANCEABLE_HUB_V2) @Throws(RemoteException::class) fun testRedirectExit() = testScope.runTest { Loading Loading @@ -1347,7 +1371,11 @@ class DreamOverlayServiceTest(flags: FlagsParameterization?) : SysuiTestCase() { @JvmStatic @Parameters(name = "{0}") fun getParams(): List<FlagsParameterization> { return FlagsParameterization.allCombinationsOf(FLAG_COMMUNAL_HUB).andSceneContainer() return FlagsParameterization.allCombinationsOf( FLAG_COMMUNAL_HUB, FLAG_GLANCEABLE_HUB_V2, ) .andSceneContainer() } } } packages/SystemUI/src/com/android/systemui/communal/CommunalDreamStartable.kt +14 −8 Original line number Diff line number Diff line Loading @@ -91,13 +91,19 @@ constructor( .launchIn(bgScope) } // Restart the dream underneath the hub in order to support the ability to swipe // away the hub to enter the dream. // With hub v2, we no longer need to keep the dream running underneath the hub as there is // no more swipe between the hub and dream. We can just start the dream on-demand when the // user presses the dream coin. if (!communalSettingsInteractor.isV2FlagEnabled()) { // Restart the dream underneath the hub in order to support the ability to swipe away // the hub to enter the dream. startDream .sampleFilter(powerInteractor.isAwake) { isAwake -> !glanceableHubAllowKeyguardWhenDreaming() && dreamManager.canStartDreaming(isAwake) !glanceableHubAllowKeyguardWhenDreaming() && dreamManager.canStartDreaming(isAwake) } .onEach { dreamManager.startDream() } .launchIn(bgScope) } } } packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java +7 −0 Original line number Diff line number Diff line Loading @@ -562,6 +562,13 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ return; } if (mCommunalSettingsInteractor.isV2FlagEnabled()) { // Dream wake redirect is not needed in V2 as we do not need to keep the dream awake // underneath the hub anymore as there is no more swipe between the dream and hub. SysUI // will automatically transition to the hub when the dream wakes. return; } redirectWake(mCommunalAvailable && !glanceableHubAllowKeyguardWhenDreaming()); } Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalDreamStartableTest.kt +61 −13 Original line number Diff line number Diff line Loading @@ -16,14 +16,17 @@ package com.android.systemui.communal import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import android.platform.test.flag.junit.FlagsParameterization import android.service.dream.dreamManager import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.Flags import com.android.systemui.Flags.FLAG_GLANCEABLE_HUB_V2 import com.android.systemui.SysuiTestCase import com.android.systemui.communal.domain.interactor.communalSceneInteractor import com.android.systemui.communal.domain.interactor.communalSettingsInteractor import com.android.systemui.communal.domain.interactor.setCommunalV2Enabled import com.android.systemui.flags.Flags.COMMUNAL_SERVICE_ENABLED import com.android.systemui.flags.fakeFeatureFlagsClassic import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository Loading @@ -48,12 +51,14 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mockito.never import org.mockito.Mockito.verify import platform.test.runner.parameterized.ParameterizedAndroidJunit4 import platform.test.runner.parameterized.Parameters @OptIn(ExperimentalCoroutinesApi::class) @SmallTest @EnableFlags(Flags.FLAG_COMMUNAL_HUB) @RunWith(AndroidJUnit4::class) class CommunalDreamStartableTest : SysuiTestCase() { @RunWith(ParameterizedAndroidJunit4::class) class CommunalDreamStartableTest(flags: FlagsParameterization) : SysuiTestCase() { private val kosmos = testKosmos() private val testScope = kosmos.testScope Loading @@ -63,6 +68,10 @@ class CommunalDreamStartableTest : SysuiTestCase() { private val keyguardRepository by lazy { kosmos.fakeKeyguardRepository } private val powerRepository by lazy { kosmos.fakePowerRepository } init { mSetFlagsRule.setFlagsParameterization(flags) } @Before fun setUp() { kosmos.fakeFeatureFlagsClassic.set(COMMUNAL_SERVICE_ENABLED, true) Loading @@ -77,12 +86,32 @@ class CommunalDreamStartableTest : SysuiTestCase() { communalSceneInteractor = kosmos.communalSceneInteractor, bgScope = kosmos.applicationCoroutineScope, ) .apply { start() } } @EnableFlags(FLAG_GLANCEABLE_HUB_V2) @Test fun dreamNotStartedWhenTransitioningToHub() = testScope.runTest { // Enable v2 flag and recreate + rerun start method. kosmos.setCommunalV2Enabled(true) underTest.start() keyguardRepository.setKeyguardShowing(true) keyguardRepository.setDreaming(false) powerRepository.setScreenPowerState(ScreenPowerState.SCREEN_ON) whenever(dreamManager.canStartDreaming(/* isScreenOn= */ true)).thenReturn(true) runCurrent() transition(from = KeyguardState.DREAMING, to = KeyguardState.GLANCEABLE_HUB) verify(dreamManager, never()).startDream() } @DisableFlags(FLAG_GLANCEABLE_HUB_V2) @Test fun startDreamWhenTransitioningToHub() = testScope.runTest { underTest.start() keyguardRepository.setKeyguardShowing(true) keyguardRepository.setDreaming(false) powerRepository.setScreenPowerState(ScreenPowerState.SCREEN_ON) Loading @@ -100,6 +129,7 @@ class CommunalDreamStartableTest : SysuiTestCase() { @EnableFlags(Flags.FLAG_RESTART_DREAM_ON_UNOCCLUDE) fun restartDreamingWhenTransitioningFromDreamingToOccludedToDreaming() = testScope.runTest { underTest.start() keyguardRepository.setDreaming(false) powerRepository.setScreenPowerState(ScreenPowerState.SCREEN_ON) whenever(dreamManager.canStartDreaming(/* isScreenOn= */ true)).thenReturn(true) Loading @@ -122,9 +152,11 @@ class CommunalDreamStartableTest : SysuiTestCase() { verify(dreamManager).startDream() } @DisableFlags(FLAG_GLANCEABLE_HUB_V2) @Test fun shouldNotStartDreamWhenIneligibleToDream() = testScope.runTest { underTest.start() keyguardRepository.setDreaming(false) powerRepository.setScreenPowerState(ScreenPowerState.SCREEN_ON) // Not eligible to dream Loading @@ -134,9 +166,11 @@ class CommunalDreamStartableTest : SysuiTestCase() { verify(dreamManager, never()).startDream() } @DisableFlags(FLAG_GLANCEABLE_HUB_V2) @Test fun shouldNotStartDreamIfAlreadyDreaming() = testScope.runTest { underTest.start() keyguardRepository.setDreaming(true) powerRepository.setScreenPowerState(ScreenPowerState.SCREEN_ON) whenever(dreamManager.canStartDreaming(/* isScreenOn= */ true)).thenReturn(true) Loading @@ -145,9 +179,11 @@ class CommunalDreamStartableTest : SysuiTestCase() { verify(dreamManager, never()).startDream() } @DisableFlags(FLAG_GLANCEABLE_HUB_V2) @Test fun shouldNotStartDreamForInvalidTransition() = testScope.runTest { underTest.start() keyguardRepository.setDreaming(true) powerRepository.setScreenPowerState(ScreenPowerState.SCREEN_ON) whenever(dreamManager.canStartDreaming(/* isScreenOn= */ true)).thenReturn(true) Loading @@ -160,9 +196,11 @@ class CommunalDreamStartableTest : SysuiTestCase() { } } @DisableFlags(FLAG_GLANCEABLE_HUB_V2) @Test fun shouldNotStartDreamWhenLaunchingWidget() = testScope.runTest { underTest.start() keyguardRepository.setKeyguardShowing(true) keyguardRepository.setDreaming(false) powerRepository.setScreenPowerState(ScreenPowerState.SCREEN_ON) Loading @@ -175,9 +213,11 @@ class CommunalDreamStartableTest : SysuiTestCase() { verify(dreamManager, never()).startDream() } @DisableFlags(FLAG_GLANCEABLE_HUB_V2) @Test fun shouldNotStartDreamWhenOccluded() = testScope.runTest { underTest.start() keyguardRepository.setKeyguardShowing(true) keyguardRepository.setDreaming(false) powerRepository.setScreenPowerState(ScreenPowerState.SCREEN_ON) Loading @@ -194,8 +234,16 @@ class CommunalDreamStartableTest : SysuiTestCase() { kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps( from = from, to = to, testScope = this testScope = this, ) runCurrent() } companion object { @JvmStatic @Parameters(name = "{0}") fun getParams(): List<FlagsParameterization> { return FlagsParameterization.allCombinationsOf(FLAG_GLANCEABLE_HUB_V2) } } }
packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/DreamOverlayServiceTest.kt +30 −2 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ import com.android.systemui.communal.domain.interactor.communalInteractor import com.android.systemui.communal.domain.interactor.communalSettingsInteractor import com.android.systemui.communal.domain.interactor.setCommunalAvailable import com.android.systemui.communal.domain.interactor.setCommunalV2ConfigEnabled import com.android.systemui.communal.domain.interactor.setCommunalV2Enabled import com.android.systemui.communal.shared.log.CommunalUiEvent import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.complication.ComplicationHostViewController Loading Loading @@ -747,7 +748,7 @@ class DreamOverlayServiceTest(flags: FlagsParameterization?) : SysuiTestCase() { @Test @EnableFlags(Flags.FLAG_DREAM_WAKE_REDIRECT, FLAG_COMMUNAL_HUB) @DisableFlags(FLAG_SCENE_CONTAINER) @DisableFlags(FLAG_SCENE_CONTAINER, FLAG_GLANCEABLE_HUB_V2) @kotlin.Throws(RemoteException::class) fun testTransitionToGlanceableHub() = testScope.runTest { Loading @@ -774,6 +775,7 @@ class DreamOverlayServiceTest(flags: FlagsParameterization?) : SysuiTestCase() { @Test @EnableFlags(Flags.FLAG_DREAM_WAKE_REDIRECT, FLAG_SCENE_CONTAINER, FLAG_COMMUNAL_HUB) @DisableFlags(FLAG_GLANCEABLE_HUB_V2) @kotlin.Throws(RemoteException::class) fun testTransitionToGlanceableHub_sceneContainer() = testScope.runTest { Loading Loading @@ -801,8 +803,30 @@ class DreamOverlayServiceTest(flags: FlagsParameterization?) : SysuiTestCase() { verify(mUiEventLogger).log(CommunalUiEvent.DREAM_TO_COMMUNAL_HUB_DREAM_AWAKE_START) } @Test @EnableFlags(Flags.FLAG_DREAM_WAKE_REDIRECT, FLAG_COMMUNAL_HUB, FLAG_GLANCEABLE_HUB_V2) @Throws(RemoteException::class) fun testRedirect_v2Enabled_notTriggered() = testScope.runTest { kosmos.setCommunalV2Enabled(true) // Inform the overlay service of dream starting. Do not show dream complications. client.startDream( mWindowParams, mDreamOverlayCallback, DREAM_COMPONENT, false /*isPreview*/, false, /*shouldShowComplication*/ ) // Set communal available, verify that onRedirectWake is never called. kosmos.setCommunalAvailable(true) mMainExecutor.runAllReady() runCurrent() verify(mDreamOverlayCallback, never()).onRedirectWake(any()) } @Test @EnableFlags(Flags.FLAG_DREAM_WAKE_REDIRECT, FLAG_COMMUNAL_HUB) @DisableFlags(FLAG_GLANCEABLE_HUB_V2) @Throws(RemoteException::class) fun testRedirectExit() = testScope.runTest { Loading Loading @@ -1347,7 +1371,11 @@ class DreamOverlayServiceTest(flags: FlagsParameterization?) : SysuiTestCase() { @JvmStatic @Parameters(name = "{0}") fun getParams(): List<FlagsParameterization> { return FlagsParameterization.allCombinationsOf(FLAG_COMMUNAL_HUB).andSceneContainer() return FlagsParameterization.allCombinationsOf( FLAG_COMMUNAL_HUB, FLAG_GLANCEABLE_HUB_V2, ) .andSceneContainer() } } }
packages/SystemUI/src/com/android/systemui/communal/CommunalDreamStartable.kt +14 −8 Original line number Diff line number Diff line Loading @@ -91,13 +91,19 @@ constructor( .launchIn(bgScope) } // Restart the dream underneath the hub in order to support the ability to swipe // away the hub to enter the dream. // With hub v2, we no longer need to keep the dream running underneath the hub as there is // no more swipe between the hub and dream. We can just start the dream on-demand when the // user presses the dream coin. if (!communalSettingsInteractor.isV2FlagEnabled()) { // Restart the dream underneath the hub in order to support the ability to swipe away // the hub to enter the dream. startDream .sampleFilter(powerInteractor.isAwake) { isAwake -> !glanceableHubAllowKeyguardWhenDreaming() && dreamManager.canStartDreaming(isAwake) !glanceableHubAllowKeyguardWhenDreaming() && dreamManager.canStartDreaming(isAwake) } .onEach { dreamManager.startDream() } .launchIn(bgScope) } } }
packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java +7 −0 Original line number Diff line number Diff line Loading @@ -562,6 +562,13 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ return; } if (mCommunalSettingsInteractor.isV2FlagEnabled()) { // Dream wake redirect is not needed in V2 as we do not need to keep the dream awake // underneath the hub anymore as there is no more swipe between the dream and hub. SysUI // will automatically transition to the hub when the dream wakes. return; } redirectWake(mCommunalAvailable && !glanceableHubAllowKeyguardWhenDreaming()); } Loading