Loading packages/SystemUI/multivalentTests/src/com/android/systemui/scene/SceneFrameworkIntegrationTest.kt +2 −1 Original line number Diff line number Diff line Loading @@ -265,7 +265,8 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { powerInteractor = powerInteractor, bouncerInteractor = bouncerInteractor, simBouncerInteractor = dagger.Lazy { utils.simBouncerInteractor }, authenticationInteractor = dagger.Lazy { utils.authenticationInteractor() } authenticationInteractor = dagger.Lazy { utils.authenticationInteractor() }, windowController = mock(), ) startable.start() Loading packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/startable/SceneContainerStartableTest.kt +83 −16 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ import com.android.systemui.scene.SceneTestUtils import com.android.systemui.scene.shared.model.ObservableTransitionState import com.android.systemui.scene.shared.model.SceneKey import com.android.systemui.scene.shared.model.SceneModel import com.android.systemui.statusbar.NotificationShadeWindowController import com.android.systemui.util.mockito.mock import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi Loading @@ -46,18 +47,24 @@ import kotlinx.coroutines.flow.map import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.mockito.ArgumentMatchers.anyBoolean import org.mockito.Mock import org.mockito.Mockito.clearInvocations import org.mockito.Mockito.never import org.mockito.Mockito.times import org.mockito.Mockito.verify import org.mockito.MockitoAnnotations @SmallTest @RunWith(AndroidJUnit4::class) @EnableFlags(AconfigFlags.FLAG_SCENE_CONTAINER) class SceneContainerStartableTest : SysuiTestCase() { @Mock private lateinit var windowController: NotificationShadeWindowController private val utils = SceneTestUtils(this) private val testScope = utils.testScope private val sceneInteractor = utils.sceneInteractor() Loading @@ -77,7 +84,13 @@ class SceneContainerStartableTest : SysuiTestCase() { private val falsingCollector: FalsingCollector = mock() private val powerInteractor = PowerInteractorFactory.create().powerInteractor private val underTest = private lateinit var underTest: SceneContainerStartable @Before fun setUp() { MockitoAnnotations.initMocks(this) underTest = SceneContainerStartable( applicationScope = testScope.backgroundScope, sceneInteractor = sceneInteractor, Loading @@ -92,7 +105,9 @@ class SceneContainerStartableTest : SysuiTestCase() { bouncerInteractor = bouncerInteractor, simBouncerInteractor = dagger.Lazy { utils.simBouncerInteractor }, authenticationInteractor = dagger.Lazy { authenticationInteractor }, windowController = windowController, ) } @Test fun hydrateVisibility() = Loading Loading @@ -655,6 +670,58 @@ class SceneContainerStartableTest : SysuiTestCase() { assertThat(currentSceneKey).isEqualTo(SceneKey.Gone) } @Test fun hydrateWindowFocus() = testScope.runTest { val currentDesiredSceneKey by collectLastValue(sceneInteractor.desiredScene.map { it.key }) val transitionStateFlow = prepareState( isDeviceUnlocked = true, initialSceneKey = SceneKey.Gone, ) assertThat(currentDesiredSceneKey).isEqualTo(SceneKey.Gone) verify(windowController, never()).setNotificationShadeFocusable(anyBoolean()) underTest.start() runCurrent() verify(windowController, times(1)).setNotificationShadeFocusable(false) sceneInteractor.changeScene(SceneModel(SceneKey.Shade), "reason") transitionStateFlow.value = ObservableTransitionState.Transition( fromScene = SceneKey.Gone, toScene = SceneKey.Shade, progress = flowOf(0.5f), isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), ) runCurrent() verify(windowController, times(1)).setNotificationShadeFocusable(false) sceneInteractor.onSceneChanged(SceneModel(SceneKey.Shade), "reason") transitionStateFlow.value = ObservableTransitionState.Idle(SceneKey.Shade) runCurrent() verify(windowController, times(1)).setNotificationShadeFocusable(true) sceneInteractor.changeScene(SceneModel(SceneKey.Gone), "reason") transitionStateFlow.value = ObservableTransitionState.Transition( fromScene = SceneKey.Shade, toScene = SceneKey.Gone, progress = flowOf(0.5f), isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), ) runCurrent() verify(windowController, times(1)).setNotificationShadeFocusable(true) sceneInteractor.onSceneChanged(SceneModel(SceneKey.Gone), "reason") transitionStateFlow.value = ObservableTransitionState.Idle(SceneKey.Gone) runCurrent() verify(windowController, times(2)).setNotificationShadeFocusable(false) } private fun TestScope.prepareState( isDeviceUnlocked: Boolean = false, isBypassEnabled: Boolean = false, Loading packages/SystemUI/src/com/android/systemui/scene/domain/startable/SceneContainerStartable.kt +17 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICA import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_VISIBLE import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_QUICK_SETTINGS_EXPANDED import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING import com.android.systemui.statusbar.NotificationShadeWindowController import com.android.systemui.statusbar.notification.stack.shared.flexiNotifsEnabled import com.android.systemui.util.asIndenting import com.android.systemui.util.printSection Loading Loading @@ -83,6 +84,7 @@ constructor( private val powerInteractor: PowerInteractor, private val simBouncerInteractor: Lazy<SimBouncerInteractor>, private val authenticationInteractor: Lazy<AuthenticationInteractor>, private val windowController: NotificationShadeWindowController, ) : CoreStartable { override fun start() { Loading @@ -92,6 +94,7 @@ constructor( automaticallySwitchScenes() hydrateSystemUiState() collectFalsingSignals() hydrateWindowFocus() } else { sceneLogger.logFrameworkEnabled( isEnabled = false, Loading Loading @@ -348,6 +351,20 @@ constructor( } } /** Keeps the focus state of the window view up-to-date. */ private fun hydrateWindowFocus() { applicationScope.launch { sceneInteractor.transitionState .mapNotNull { transitionState -> (transitionState as? ObservableTransitionState.Idle)?.scene } .distinctUntilChanged() .collect { sceneKey -> windowController.setNotificationShadeFocusable(sceneKey != SceneKey.Gone) } } } private fun switchToScene(targetSceneKey: SceneKey, loggingReason: String) { sceneInteractor.changeScene( scene = SceneModel(targetSceneKey), Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/scene/SceneFrameworkIntegrationTest.kt +2 −1 Original line number Diff line number Diff line Loading @@ -265,7 +265,8 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { powerInteractor = powerInteractor, bouncerInteractor = bouncerInteractor, simBouncerInteractor = dagger.Lazy { utils.simBouncerInteractor }, authenticationInteractor = dagger.Lazy { utils.authenticationInteractor() } authenticationInteractor = dagger.Lazy { utils.authenticationInteractor() }, windowController = mock(), ) startable.start() Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/startable/SceneContainerStartableTest.kt +83 −16 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ import com.android.systemui.scene.SceneTestUtils import com.android.systemui.scene.shared.model.ObservableTransitionState import com.android.systemui.scene.shared.model.SceneKey import com.android.systemui.scene.shared.model.SceneModel import com.android.systemui.statusbar.NotificationShadeWindowController import com.android.systemui.util.mockito.mock import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi Loading @@ -46,18 +47,24 @@ import kotlinx.coroutines.flow.map import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.mockito.ArgumentMatchers.anyBoolean import org.mockito.Mock import org.mockito.Mockito.clearInvocations import org.mockito.Mockito.never import org.mockito.Mockito.times import org.mockito.Mockito.verify import org.mockito.MockitoAnnotations @SmallTest @RunWith(AndroidJUnit4::class) @EnableFlags(AconfigFlags.FLAG_SCENE_CONTAINER) class SceneContainerStartableTest : SysuiTestCase() { @Mock private lateinit var windowController: NotificationShadeWindowController private val utils = SceneTestUtils(this) private val testScope = utils.testScope private val sceneInteractor = utils.sceneInteractor() Loading @@ -77,7 +84,13 @@ class SceneContainerStartableTest : SysuiTestCase() { private val falsingCollector: FalsingCollector = mock() private val powerInteractor = PowerInteractorFactory.create().powerInteractor private val underTest = private lateinit var underTest: SceneContainerStartable @Before fun setUp() { MockitoAnnotations.initMocks(this) underTest = SceneContainerStartable( applicationScope = testScope.backgroundScope, sceneInteractor = sceneInteractor, Loading @@ -92,7 +105,9 @@ class SceneContainerStartableTest : SysuiTestCase() { bouncerInteractor = bouncerInteractor, simBouncerInteractor = dagger.Lazy { utils.simBouncerInteractor }, authenticationInteractor = dagger.Lazy { authenticationInteractor }, windowController = windowController, ) } @Test fun hydrateVisibility() = Loading Loading @@ -655,6 +670,58 @@ class SceneContainerStartableTest : SysuiTestCase() { assertThat(currentSceneKey).isEqualTo(SceneKey.Gone) } @Test fun hydrateWindowFocus() = testScope.runTest { val currentDesiredSceneKey by collectLastValue(sceneInteractor.desiredScene.map { it.key }) val transitionStateFlow = prepareState( isDeviceUnlocked = true, initialSceneKey = SceneKey.Gone, ) assertThat(currentDesiredSceneKey).isEqualTo(SceneKey.Gone) verify(windowController, never()).setNotificationShadeFocusable(anyBoolean()) underTest.start() runCurrent() verify(windowController, times(1)).setNotificationShadeFocusable(false) sceneInteractor.changeScene(SceneModel(SceneKey.Shade), "reason") transitionStateFlow.value = ObservableTransitionState.Transition( fromScene = SceneKey.Gone, toScene = SceneKey.Shade, progress = flowOf(0.5f), isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), ) runCurrent() verify(windowController, times(1)).setNotificationShadeFocusable(false) sceneInteractor.onSceneChanged(SceneModel(SceneKey.Shade), "reason") transitionStateFlow.value = ObservableTransitionState.Idle(SceneKey.Shade) runCurrent() verify(windowController, times(1)).setNotificationShadeFocusable(true) sceneInteractor.changeScene(SceneModel(SceneKey.Gone), "reason") transitionStateFlow.value = ObservableTransitionState.Transition( fromScene = SceneKey.Shade, toScene = SceneKey.Gone, progress = flowOf(0.5f), isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), ) runCurrent() verify(windowController, times(1)).setNotificationShadeFocusable(true) sceneInteractor.onSceneChanged(SceneModel(SceneKey.Gone), "reason") transitionStateFlow.value = ObservableTransitionState.Idle(SceneKey.Gone) runCurrent() verify(windowController, times(2)).setNotificationShadeFocusable(false) } private fun TestScope.prepareState( isDeviceUnlocked: Boolean = false, isBypassEnabled: Boolean = false, Loading
packages/SystemUI/src/com/android/systemui/scene/domain/startable/SceneContainerStartable.kt +17 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICA import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_VISIBLE import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_QUICK_SETTINGS_EXPANDED import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING import com.android.systemui.statusbar.NotificationShadeWindowController import com.android.systemui.statusbar.notification.stack.shared.flexiNotifsEnabled import com.android.systemui.util.asIndenting import com.android.systemui.util.printSection Loading Loading @@ -83,6 +84,7 @@ constructor( private val powerInteractor: PowerInteractor, private val simBouncerInteractor: Lazy<SimBouncerInteractor>, private val authenticationInteractor: Lazy<AuthenticationInteractor>, private val windowController: NotificationShadeWindowController, ) : CoreStartable { override fun start() { Loading @@ -92,6 +94,7 @@ constructor( automaticallySwitchScenes() hydrateSystemUiState() collectFalsingSignals() hydrateWindowFocus() } else { sceneLogger.logFrameworkEnabled( isEnabled = false, Loading Loading @@ -348,6 +351,20 @@ constructor( } } /** Keeps the focus state of the window view up-to-date. */ private fun hydrateWindowFocus() { applicationScope.launch { sceneInteractor.transitionState .mapNotNull { transitionState -> (transitionState as? ObservableTransitionState.Idle)?.scene } .distinctUntilChanged() .collect { sceneKey -> windowController.setNotificationShadeFocusable(sceneKey != SceneKey.Gone) } } } private fun switchToScene(targetSceneKey: SceneKey, loggingReason: String) { sceneInteractor.changeScene( scene = SceneModel(targetSceneKey), Loading