diff options
| author | 2024-03-04 16:18:58 +0000 | |
|---|---|---|
| committer | 2024-03-04 16:18:58 +0000 | |
| commit | c5c483029449eea04d1a7dee6f8043f66b2f320b (patch) | |
| tree | e53d77377aaafc15d291ccd25b25a902591b829f | |
| parent | 91a71acceffb3d3663b8ee00c6236eabb5ba1ef6 (diff) | |
| parent | b1ee802f69ba7d0d056898b5f3441425b2c13269 (diff) | |
Merge changes Ib09d61eb,I2678c1d2,I125610c1,I554517b7,I48e12cdb, ... into main
* changes:
Remove the fork of STL UserActionResult
Remove the Communal fork of STL ObservableTransitionState
Remove the fork of STL ObservableTransitionState
Remove the fork of STL TransitionKey
Remove the Communal fork of STL SceneKey
Remove the fork of STL SceneKey
Rename CommunalSceneKey.Foo to CommunalScenes.Foo
Rename SceneKey.Foo to Scenes.Foo
103 files changed, 1020 insertions, 1306 deletions
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/bouncer/ui/composable/BouncerScene.kt b/packages/SystemUI/compose/features/src/com/android/systemui/bouncer/ui/composable/BouncerScene.kt index 0469cbe519ea..c1bdaf169bc7 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/bouncer/ui/composable/BouncerScene.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/bouncer/ui/composable/BouncerScene.kt @@ -24,13 +24,13 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import com.android.compose.animation.scene.ElementKey import com.android.compose.animation.scene.SceneScope +import com.android.compose.animation.scene.UserActionResult import com.android.systemui.bouncer.ui.BouncerDialogFactory import com.android.systemui.bouncer.ui.viewmodel.BouncerViewModel import com.android.systemui.dagger.SysUISingleton import com.android.systemui.scene.shared.model.Direction -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.UserAction -import com.android.systemui.scene.shared.model.UserActionResult import com.android.systemui.scene.ui.composable.ComposableScene import javax.inject.Inject import kotlinx.coroutines.flow.MutableStateFlow @@ -52,13 +52,13 @@ constructor( private val viewModel: BouncerViewModel, private val dialogFactory: BouncerDialogFactory, ) : ComposableScene { - override val key = SceneKey.Bouncer + override val key = Scenes.Bouncer override val destinationScenes: StateFlow<Map<UserAction, UserActionResult>> = MutableStateFlow( mapOf( - UserAction.Back to UserActionResult(SceneKey.Lockscreen), - UserAction.Swipe(Direction.DOWN) to UserActionResult(SceneKey.Lockscreen), + UserAction.Back to UserActionResult(Scenes.Lockscreen), + UserAction.Swipe(Direction.DOWN) to UserActionResult(Scenes.Lockscreen), ) ) .asStateFlow() diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalContainer.kt b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalContainer.kt index 7535a51675e3..9ee69bc065f6 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalContainer.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalContainer.kt @@ -14,7 +14,6 @@ import com.android.compose.animation.scene.Edge import com.android.compose.animation.scene.ElementKey import com.android.compose.animation.scene.FixedSizeEdgeDetector import com.android.compose.animation.scene.LowestZIndexScenePicker -import com.android.compose.animation.scene.ObservableTransitionState import com.android.compose.animation.scene.SceneKey import com.android.compose.animation.scene.SceneScope import com.android.compose.animation.scene.SceneTransitionLayout @@ -24,14 +23,11 @@ import com.android.compose.animation.scene.observableTransitionState import com.android.compose.animation.scene.transitions import com.android.compose.animation.scene.updateSceneTransitionLayoutState import com.android.compose.theme.LocalAndroidColorScheme -import com.android.systemui.communal.shared.model.CommunalSceneKey -import com.android.systemui.communal.shared.model.ObservableCommunalTransitionState +import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.communal.ui.compose.extensions.allowGestures import com.android.systemui.communal.ui.viewmodel.BaseCommunalViewModel import com.android.systemui.communal.ui.viewmodel.CommunalViewModel import com.android.systemui.res.R -import kotlinx.coroutines.flow.map -import kotlinx.coroutines.flow.transform object Communal { object Elements { @@ -41,7 +37,7 @@ object Communal { } val sceneTransitions = transitions { - to(TransitionSceneKey.Communal) { + to(CommunalScenes.Communal) { spec = tween(durationMillis = 1000) translate(Communal.Elements.Content, Edge.Right) timestampRange(startMillis = 167, endMillis = 334) { @@ -49,7 +45,7 @@ val sceneTransitions = transitions { fade(Communal.Elements.Content) } } - to(TransitionSceneKey.Blank) { + to(CommunalScenes.Blank) { spec = tween(durationMillis = 1000) translate(Communal.Elements.Content, Edge.Right) timestampRange(endMillis = 167) { fade(Communal.Elements.Content) } @@ -68,14 +64,11 @@ fun CommunalContainer( modifier: Modifier = Modifier, viewModel: CommunalViewModel, ) { - val currentScene: SceneKey by - viewModel.currentScene - .transform { value -> emit(value.toTransitionSceneKey()) } - .collectAsState(TransitionSceneKey.Blank) + val currentScene: SceneKey by viewModel.currentScene.collectAsState(CommunalScenes.Blank) val sceneTransitionLayoutState = updateSceneTransitionLayoutState( currentScene, - onChangeScene = { viewModel.onSceneChanged(it.toCommunalSceneKey()) }, + onChangeScene = { viewModel.onSceneChanged(it) }, transitions = sceneTransitions, ) val touchesAllowed by viewModel.touchesAllowed.collectAsState(initial = false) @@ -83,9 +76,7 @@ fun CommunalContainer( // This effect exposes the SceneTransitionLayout's observable transition state to the rest of // the system, and unsets it when the view is disposed to avoid a memory leak. DisposableEffect(viewModel, sceneTransitionLayoutState) { - viewModel.setTransitionState( - sceneTransitionLayoutState.observableTransitionState().map { it.toModel() } - ) + viewModel.setTransitionState(sceneTransitionLayoutState.observableTransitionState()) onDispose { viewModel.setTransitionState(null) } } @@ -98,11 +89,10 @@ fun CommunalContainer( ), ) { scene( - TransitionSceneKey.Blank, + CommunalScenes.Blank, userActions = mapOf( - Swipe(SwipeDirection.Left, fromSource = Edge.Right) to - TransitionSceneKey.Communal + Swipe(SwipeDirection.Left, fromSource = Edge.Right) to CommunalScenes.Communal ) ) { // This scene shows nothing only allowing for transitions to the communal scene. @@ -110,11 +100,9 @@ fun CommunalContainer( } scene( - TransitionSceneKey.Communal, + CommunalScenes.Communal, userActions = - mapOf( - Swipe(SwipeDirection.Right, fromSource = Edge.Left) to TransitionSceneKey.Blank - ), + mapOf(Swipe(SwipeDirection.Right, fromSource = Edge.Left) to CommunalScenes.Blank), ) { CommunalScene(viewModel, modifier = modifier) } @@ -135,39 +123,3 @@ private fun SceneScope.CommunalScene( ) Box(modifier.element(Communal.Elements.Content)) { CommunalHub(viewModel = viewModel) } } - -// TODO(b/315490861): Remove these conversions once Compose can be used throughout SysUI. -object TransitionSceneKey { - val Blank = CommunalSceneKey.Blank.toTransitionSceneKey() - val Communal = CommunalSceneKey.Communal.toTransitionSceneKey() -} - -// TODO(b/315490861): Remove these conversions once Compose can be used throughout SysUI. -fun SceneKey.toCommunalSceneKey(): CommunalSceneKey { - return this.identity as CommunalSceneKey -} - -// TODO(b/315490861): Remove these conversions once Compose can be used throughout SysUI. -fun CommunalSceneKey.toTransitionSceneKey(): SceneKey { - return SceneKey(debugName = toString(), identity = this) -} - -/** - * Converts between the [SceneTransitionLayout] state class and our forked data class that can be - * used throughout SysUI. - */ -// TODO(b/315490861): Remove these conversions once Compose can be used throughout SysUI. -fun ObservableTransitionState.toModel(): ObservableCommunalTransitionState { - return when (this) { - is ObservableTransitionState.Idle -> - ObservableCommunalTransitionState.Idle(scene.toCommunalSceneKey()) - is ObservableTransitionState.Transition -> - ObservableCommunalTransitionState.Transition( - fromScene = fromScene.toCommunalSceneKey(), - toScene = toScene.toCommunalSceneKey(), - progress = progress, - isInitiatedByUserInput = isInitiatedByUserInput, - isUserInputOngoing = isUserInputOngoing, - ) - } -} diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalScene.kt b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalScene.kt index 11a38f92c234..a339309a5fbb 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalScene.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalScene.kt @@ -19,12 +19,12 @@ package com.android.systemui.communal.ui.compose import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import com.android.compose.animation.scene.SceneScope +import com.android.compose.animation.scene.UserActionResult import com.android.systemui.communal.ui.viewmodel.CommunalViewModel import com.android.systemui.dagger.SysUISingleton import com.android.systemui.scene.shared.model.Direction -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.UserAction -import com.android.systemui.scene.shared.model.UserActionResult import com.android.systemui.scene.ui.composable.ComposableScene import javax.inject.Inject import kotlinx.coroutines.flow.MutableStateFlow @@ -38,12 +38,12 @@ class CommunalScene constructor( private val viewModel: CommunalViewModel, ) : ComposableScene { - override val key = SceneKey.Communal + override val key = Scenes.Communal override val destinationScenes: StateFlow<Map<UserAction, UserActionResult>> = MutableStateFlow<Map<UserAction, UserActionResult>>( mapOf( - UserAction.Swipe(Direction.RIGHT) to UserActionResult(SceneKey.Lockscreen), + UserAction.Swipe(Direction.RIGHT) to UserActionResult(Scenes.Lockscreen), ) ) .asStateFlow() diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenScene.kt b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenScene.kt index dd043dbebaa6..a7abeeaef366 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenScene.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenScene.kt @@ -18,9 +18,10 @@ package com.android.systemui.keyguard.ui.composable import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier +import com.android.compose.animation.scene.SceneKey import com.android.compose.animation.scene.SceneScope +import com.android.compose.animation.scene.UserActionResult import com.android.compose.animation.scene.animateSceneFloatAsState import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application @@ -28,9 +29,8 @@ import com.android.systemui.keyguard.ui.viewmodel.LockscreenSceneViewModel import com.android.systemui.qs.ui.composable.QuickSettings import com.android.systemui.scene.shared.model.Direction import com.android.systemui.scene.shared.model.Edge -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.UserAction -import com.android.systemui.scene.shared.model.UserActionResult import com.android.systemui.scene.ui.composable.ComposableScene import dagger.Lazy import javax.inject.Inject @@ -50,7 +50,7 @@ constructor( viewModel: LockscreenSceneViewModel, private val lockscreenContent: Lazy<LockscreenContent>, ) : ComposableScene { - override val key = SceneKey.Lockscreen + override val key = Scenes.Lockscreen override val destinationScenes: StateFlow<Map<UserAction, UserActionResult>> = combine(viewModel.upDestinationSceneKey, viewModel.leftDestinationSceneKey, ::Pair) @@ -83,8 +83,8 @@ constructor( up?.let { this[UserAction.Swipe(Direction.UP)] = UserActionResult(up) } left?.let { this[UserAction.Swipe(Direction.LEFT)] = UserActionResult(left) } this[UserAction.Swipe(fromEdge = Edge.TOP, direction = Direction.DOWN)] = - UserActionResult(SceneKey.QuickSettings) - this[UserAction.Swipe(direction = Direction.DOWN)] = UserActionResult(SceneKey.Shade) + UserActionResult(Scenes.QuickSettings) + this[UserAction.Swipe(direction = Direction.DOWN)] = UserActionResult(Scenes.Shade) } } } diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/Notifications.kt b/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/Notifications.kt index ef6ae2ecfec9..791d629179e6 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/Notifications.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/Notifications.kt @@ -71,8 +71,7 @@ import com.android.systemui.common.ui.compose.windowinsets.LocalScreenCornerRadi import com.android.systemui.notifications.ui.composable.Notifications.Form import com.android.systemui.notifications.ui.composable.Notifications.TransitionThresholds.EXPANSION_FOR_MAX_CORNER_RADIUS import com.android.systemui.notifications.ui.composable.Notifications.TransitionThresholds.EXPANSION_FOR_MAX_SCRIM_ALPHA -import com.android.systemui.scene.ui.composable.Gone -import com.android.systemui.scene.ui.composable.Shade +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.shade.ui.composable.ShadeHeader import com.android.systemui.statusbar.notification.stack.ui.viewbinder.NotificationStackAppearanceViewBinder.SCRIM_CORNER_RADIUS import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationsPlaceholderViewModel @@ -214,7 +213,7 @@ fun SceneScope.NotificationScrollingStack( // in step with the transition so that it is 0 when it completes. if ( scrimOffset.value < 0 && - layoutState.isTransitioning(from = Shade, to = Gone) + layoutState.isTransitioning(from = Scenes.Shade, to = Scenes.Gone) ) { IntOffset(x = 0, y = (scrimOffset.value * expansionFraction).roundToInt()) } else { @@ -226,7 +225,7 @@ fun SceneScope.NotificationScrollingStack( calculateCornerRadius( screenCornerRadius, { expansionFraction }, - layoutState.isTransitioningBetween(Gone, Shade) + layoutState.isTransitioningBetween(Scenes.Gone, Scenes.Shade) ) .let { RoundedCornerShape( @@ -250,7 +249,7 @@ fun SceneScope.NotificationScrollingStack( Modifier.fillMaxSize() .graphicsLayer { alpha = - if (layoutState.isTransitioningBetween(Gone, Shade)) { + if (layoutState.isTransitioningBetween(Scenes.Gone, Scenes.Shade)) { (expansionFraction / EXPANSION_FOR_MAX_SCRIM_ALPHA).coerceAtMost(1f) } else 1f } diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettings.kt b/packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettings.kt index 5d0b9ba2c736..91b737d33418 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettings.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettings.kt @@ -37,14 +37,13 @@ import com.android.systemui.qs.ui.adapter.QSSceneAdapter import com.android.systemui.qs.ui.adapter.QSSceneAdapter.State.Companion.Collapsing import com.android.systemui.qs.ui.adapter.QSSceneAdapter.State.Expanding import com.android.systemui.qs.ui.adapter.QSSceneAdapter.State.Unsquishing -import com.android.systemui.scene.ui.composable.QuickSettings as QuickSettingsSceneKey -import com.android.systemui.scene.ui.composable.Shade +import com.android.systemui.scene.shared.model.Scenes object QuickSettings { private val SCENES = setOf( - QuickSettingsSceneKey, - Shade, + Scenes.QuickSettings, + Scenes.Shade, ) object Elements { @@ -69,18 +68,20 @@ private fun SceneScope.stateForQuickSettingsContent( return when (val transitionState = layoutState.transitionState) { is TransitionState.Idle -> { when (transitionState.currentScene) { - Shade -> QSSceneAdapter.State.QQS - QuickSettingsSceneKey -> QSSceneAdapter.State.QS + Scenes.Shade -> QSSceneAdapter.State.QQS + Scenes.QuickSettings -> QSSceneAdapter.State.QS else -> QSSceneAdapter.State.CLOSED } } is TransitionState.Transition -> with(transitionState) { when { - fromScene == Shade && toScene == QuickSettingsSceneKey -> Expanding(progress) - fromScene == QuickSettingsSceneKey && toScene == Shade -> Collapsing(progress) - fromScene == Shade || toScene == Shade -> Unsquishing(squishiness) - fromScene == QuickSettingsSceneKey || toScene == QuickSettingsSceneKey -> { + fromScene == Scenes.Shade && toScene == Scenes.QuickSettings -> + Expanding(progress) + fromScene == Scenes.QuickSettings && toScene == Scenes.Shade -> + Collapsing(progress) + fromScene == Scenes.Shade || toScene == Scenes.Shade -> Unsquishing(squishiness) + fromScene == Scenes.QuickSettings || toScene == Scenes.QuickSettings -> { QSSceneAdapter.State.QS } else -> diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettingsScene.kt b/packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettingsScene.kt index 6875bc544a55..3b8b863fdde2 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettingsScene.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettingsScene.kt @@ -63,9 +63,8 @@ import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.qs.footer.ui.compose.FooterActions import com.android.systemui.qs.ui.viewmodel.QuickSettingsSceneViewModel import com.android.systemui.res.R -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.ui.composable.ComposableScene -import com.android.systemui.scene.ui.composable.asComposeAware import com.android.systemui.shade.ui.composable.CollapsedShadeHeader import com.android.systemui.shade.ui.composable.ExpandedShadeHeader import com.android.systemui.shade.ui.composable.Shade @@ -89,7 +88,7 @@ constructor( private val batteryMeterViewControllerFactory: BatteryMeterViewController.Factory, private val statusBarIconController: StatusBarIconController, ) : ComposableScene { - override val key = SceneKey.QuickSettings + override val key = Scenes.QuickSettings override val destinationScenes = viewModel.destinationScenes.stateIn( @@ -140,9 +139,7 @@ private fun SceneScope.QuickSettingsScene( val isScrollable = when (val state = layoutState.transitionState) { is TransitionState.Idle -> true - is TransitionState.Transition -> { - state.fromScene == SceneKey.QuickSettings.asComposeAware() - } + is TransitionState.Transition -> state.fromScene == Scenes.QuickSettings } LaunchedEffect(isCustomizing, scrollState) { diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/ComposeAwareExtensions.kt b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/ComposeAwareExtensions.kt index 0de4650f1248..2dea06625899 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/ComposeAwareExtensions.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/ComposeAwareExtensions.kt @@ -18,35 +18,15 @@ package com.android.systemui.scene.ui.composable import com.android.compose.animation.scene.Back import com.android.compose.animation.scene.Edge as ComposeAwareEdge -import com.android.compose.animation.scene.SceneKey as ComposeAwareSceneKey import com.android.compose.animation.scene.Swipe import com.android.compose.animation.scene.SwipeDirection -import com.android.compose.animation.scene.TransitionKey as ComposeAwareTransitionKey import com.android.compose.animation.scene.UserAction as ComposeAwareUserAction -import com.android.compose.animation.scene.UserActionResult as ComposeAwareUserActionResult import com.android.systemui.scene.shared.model.Direction import com.android.systemui.scene.shared.model.Edge -import com.android.systemui.scene.shared.model.SceneKey -import com.android.systemui.scene.shared.model.TransitionKey import com.android.systemui.scene.shared.model.UserAction -import com.android.systemui.scene.shared.model.UserActionResult // TODO(b/293899074): remove this file once we can use the types from SceneTransitionLayout. -fun SceneKey.asComposeAware(): ComposeAwareSceneKey { - return ComposeAwareSceneKey( - debugName = toString(), - identity = this, - ) -} - -fun TransitionKey.asComposeAware(): ComposeAwareTransitionKey { - return ComposeAwareTransitionKey( - debugName = debugName, - identity = this, - ) -} - fun UserAction.asComposeAware(): ComposeAwareUserAction { return when (this) { is UserAction.Swipe -> @@ -71,11 +51,3 @@ fun UserAction.asComposeAware(): ComposeAwareUserAction { is UserAction.Back -> Back } } - -fun UserActionResult.asComposeAware(): ComposeAwareUserActionResult { - val composeUnaware = this - return ComposeAwareUserActionResult( - toScene = composeUnaware.toScene.asComposeAware(), - transitionKey = composeUnaware.transitionKey?.asComposeAware(), - ) -} diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/ComposeUnawareExtensions.kt b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/ComposeUnawareExtensions.kt deleted file mode 100644 index 4c03664fc244..000000000000 --- a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/ComposeUnawareExtensions.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2024 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.scene.ui.composable - -import com.android.compose.animation.scene.ObservableTransitionState as ComposeAwareObservableTransitionState -import com.android.compose.animation.scene.SceneKey as ComposeAwareSceneKey -import com.android.systemui.scene.shared.model.ObservableTransitionState -import com.android.systemui.scene.shared.model.SceneKey - -fun ComposeAwareSceneKey.asComposeUnaware(): SceneKey { - return this.identity as SceneKey -} - -fun ComposeAwareObservableTransitionState.asComposeUnaware(): ObservableTransitionState { - return when (this) { - is ComposeAwareObservableTransitionState.Idle -> - ObservableTransitionState.Idle(scene.asComposeUnaware()) - is ComposeAwareObservableTransitionState.Transition -> - ObservableTransitionState.Transition( - fromScene = fromScene.asComposeUnaware(), - toScene = toScene.asComposeUnaware(), - progress = progress, - isInitiatedByUserInput = isInitiatedByUserInput, - isUserInputOngoing = isUserInputOngoing, - ) - } -} diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/GoneScene.kt b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/GoneScene.kt index 9ca751e81eed..8ca93d2ad6cf 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/GoneScene.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/GoneScene.kt @@ -19,17 +19,16 @@ package com.android.systemui.scene.ui.composable import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier import com.android.compose.animation.scene.SceneScope +import com.android.compose.animation.scene.UserActionResult import com.android.compose.animation.scene.animateSceneFloatAsState import com.android.systemui.dagger.SysUISingleton import com.android.systemui.qs.ui.composable.QuickSettings import com.android.systemui.scene.shared.model.Direction import com.android.systemui.scene.shared.model.Edge -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.UserAction -import com.android.systemui.scene.shared.model.UserActionResult import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationsPlaceholderViewModel import javax.inject.Inject import kotlinx.coroutines.flow.MutableStateFlow @@ -46,7 +45,7 @@ class GoneScene constructor( private val notificationsViewModel: NotificationsPlaceholderViewModel, ) : ComposableScene { - override val key = SceneKey.Gone + override val key = Scenes.Gone override val destinationScenes: StateFlow<Map<UserAction, UserActionResult>> = MutableStateFlow<Map<UserAction, UserActionResult>>( @@ -55,9 +54,8 @@ constructor( pointerCount = 2, fromEdge = Edge.TOP, direction = Direction.DOWN, - ) to UserActionResult(SceneKey.QuickSettings), - UserAction.Swipe(direction = Direction.DOWN) to - UserActionResult(SceneKey.Shade), + ) to UserActionResult(Scenes.QuickSettings), + UserAction.Swipe(direction = Direction.DOWN) to UserActionResult(Scenes.Shade), ) ) .asStateFlow() diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneContainer.kt b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneContainer.kt index 9779d7170d0d..da3caf68bbc6 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneContainer.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneContainer.kt @@ -35,15 +35,14 @@ import androidx.compose.ui.input.pointer.PointerEventPass import androidx.compose.ui.input.pointer.motionEventSpy import androidx.compose.ui.input.pointer.pointerInput import com.android.compose.animation.scene.MutableSceneTransitionLayoutState +import com.android.compose.animation.scene.SceneKey import com.android.compose.animation.scene.SceneTransitionLayout +import com.android.compose.animation.scene.UserActionResult import com.android.compose.animation.scene.observableTransitionState import com.android.systemui.ribbon.ui.composable.BottomRightCornerRibbon import com.android.systemui.scene.shared.model.SceneDataSourceDelegator -import com.android.systemui.scene.shared.model.SceneKey import com.android.systemui.scene.shared.model.UserAction -import com.android.systemui.scene.shared.model.UserActionResult import com.android.systemui.scene.ui.viewmodel.SceneContainerViewModel -import kotlinx.coroutines.flow.map /** * Renders a container of a collection of "scenes" that the user can switch between using certain @@ -77,8 +76,8 @@ fun SceneContainer( currentScene.destinationScenes.collectAsState() val state: MutableSceneTransitionLayoutState = remember { MutableSceneTransitionLayoutState( - initialScene = currentSceneKey.asComposeAware(), - canChangeScene = { toScene -> viewModel.canChangeScene(toScene.asComposeUnaware()) }, + initialScene = currentSceneKey, + canChangeScene = { toScene -> viewModel.canChangeScene(toScene) }, transitions = SceneContainerTransitions, ) } @@ -90,9 +89,7 @@ fun SceneContainer( } DisposableEffect(viewModel, state) { - viewModel.setTransitionState( - state.observableTransitionState().map { it.asComposeUnaware() } - ) + viewModel.setTransitionState(state.observableTransitionState()) onDispose { viewModel.setTransitionState(null) } } @@ -116,7 +113,7 @@ fun SceneContainer( ) { sceneByKey.forEach { (sceneKey, composableScene) -> scene( - key = sceneKey.asComposeAware(), + key = sceneKey, userActions = if (sceneKey == currentSceneKey) { currentDestinations @@ -124,15 +121,13 @@ fun SceneContainer( composableScene.destinationScenes.value } .map { (userAction, userActionResult) -> - userAction.asComposeAware() to userActionResult.asComposeAware() + userAction.asComposeAware() to userActionResult } .toMap(), ) { with(composableScene) { this@scene.Content( - modifier = - Modifier.element(sceneKey.asComposeAware().rootElementKey) - .fillMaxSize(), + modifier = Modifier.element(sceneKey.rootElementKey).fillMaxSize(), ) } } diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneContainerTransitions.kt b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneContainerTransitions.kt index 61f81209ad7e..dea9485e916c 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneContainerTransitions.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneContainerTransitions.kt @@ -1,6 +1,7 @@ package com.android.systemui.scene.ui.composable import com.android.compose.animation.scene.transitions +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.TransitionKeys.CollapseShadeInstantly import com.android.systemui.scene.shared.model.TransitionKeys.SlightlyFasterShadeCollapse import com.android.systemui.scene.ui.composable.transitions.bouncerToGoneTransition @@ -26,41 +27,41 @@ import com.android.systemui.scene.ui.composable.transitions.shadeToQuickSettings * Please keep the list sorted alphabetically. */ val SceneContainerTransitions = transitions { - from(Bouncer, to = Gone) { bouncerToGoneTransition() } - from(Gone, to = Shade) { goneToShadeTransition() } + from(Scenes.Bouncer, to = Scenes.Gone) { bouncerToGoneTransition() } + from(Scenes.Gone, to = Scenes.Shade) { goneToShadeTransition() } from( - Gone, - to = Shade, - key = CollapseShadeInstantly.asComposeAware(), + Scenes.Gone, + to = Scenes.Shade, + key = CollapseShadeInstantly, ) { goneToShadeTransition(durationScale = 0.0) } from( - Gone, - to = Shade, - key = SlightlyFasterShadeCollapse.asComposeAware(), + Scenes.Gone, + to = Scenes.Shade, + key = SlightlyFasterShadeCollapse, ) { goneToShadeTransition(durationScale = 0.9) } - from(Gone, to = QuickSettings) { goneToQuickSettingsTransition() } - from(Lockscreen, to = Bouncer) { lockscreenToBouncerTransition() } - from(Lockscreen, to = Communal) { lockscreenToCommunalTransition() } - from(Lockscreen, to = Shade) { lockscreenToShadeTransition() } + from(Scenes.Gone, to = Scenes.QuickSettings) { goneToQuickSettingsTransition() } + from(Scenes.Lockscreen, to = Scenes.Bouncer) { lockscreenToBouncerTransition() } + from(Scenes.Lockscreen, to = Scenes.Communal) { lockscreenToCommunalTransition() } + from(Scenes.Lockscreen, to = Scenes.Shade) { lockscreenToShadeTransition() } from( - Lockscreen, - to = Shade, - key = CollapseShadeInstantly.asComposeAware(), + Scenes.Lockscreen, + to = Scenes.Shade, + key = CollapseShadeInstantly, ) { lockscreenToShadeTransition(durationScale = 0.0) } from( - Lockscreen, - to = Shade, - key = SlightlyFasterShadeCollapse.asComposeAware(), + Scenes.Lockscreen, + to = Scenes.Shade, + key = SlightlyFasterShadeCollapse, ) { lockscreenToShadeTransition(durationScale = 0.9) } - from(Lockscreen, to = QuickSettings) { lockscreenToQuickSettingsTransition() } - from(Lockscreen, to = Gone) { lockscreenToGoneTransition() } - from(Shade, to = QuickSettings) { shadeToQuickSettingsTransition() } + from(Scenes.Lockscreen, to = Scenes.QuickSettings) { lockscreenToQuickSettingsTransition() } + from(Scenes.Lockscreen, to = Scenes.Gone) { lockscreenToGoneTransition() } + from(Scenes.Shade, to = Scenes.QuickSettings) { shadeToQuickSettingsTransition() } } diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneTransitionLayoutDataSource.kt b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneTransitionLayoutDataSource.kt index 60c0b7719a25..a54994df3dc9 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneTransitionLayoutDataSource.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneTransitionLayoutDataSource.kt @@ -20,10 +20,10 @@ package com.android.systemui.scene.ui.composable import com.android.compose.animation.scene.MutableSceneTransitionLayoutState import com.android.compose.animation.scene.ObservableTransitionState +import com.android.compose.animation.scene.SceneKey +import com.android.compose.animation.scene.TransitionKey import com.android.compose.animation.scene.observableTransitionState import com.android.systemui.scene.shared.model.SceneDataSource -import com.android.systemui.scene.shared.model.SceneKey -import com.android.systemui.scene.shared.model.TransitionKey import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.SharingStarted @@ -61,11 +61,10 @@ class SceneTransitionLayoutDataSource( } } } - .map { it.asComposeUnaware() } .stateIn( scope = coroutineScope, started = SharingStarted.WhileSubscribed(), - initialValue = state.transitionState.currentScene.asComposeUnaware(), + initialValue = state.transitionState.currentScene, ) override fun changeScene( @@ -73,8 +72,8 @@ class SceneTransitionLayoutDataSource( transitionKey: TransitionKey?, ) { state.setTargetScene( - targetScene = toScene.asComposeAware(), - transitionKey = transitionKey?.asComposeAware(), + targetScene = toScene, + transitionKey = transitionKey, coroutineScope = coroutineScope, ) } diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/TransitionSceneKeys.kt b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/TransitionSceneKeys.kt deleted file mode 100644 index 5a9add1ad587..000000000000 --- a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/TransitionSceneKeys.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.android.systemui.scene.ui.composable - -import com.android.systemui.scene.shared.model.SceneKey - -val Lockscreen = SceneKey.Lockscreen.asComposeAware() -val Bouncer = SceneKey.Bouncer.asComposeAware() -val Shade = SceneKey.Shade.asComposeAware() -val QuickSettings = SceneKey.QuickSettings.asComposeAware() -val Gone = SceneKey.Gone.asComposeAware() -val Communal = SceneKey.Communal.asComposeAware() diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromBouncerToGoneTransition.kt b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromBouncerToGoneTransition.kt index 1a9facea7518..5eefe490ab5b 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromBouncerToGoneTransition.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromBouncerToGoneTransition.kt @@ -2,10 +2,10 @@ package com.android.systemui.scene.ui.composable.transitions import androidx.compose.animation.core.tween import com.android.compose.animation.scene.TransitionBuilder -import com.android.systemui.scene.ui.composable.Bouncer +import com.android.systemui.scene.shared.model.Scenes fun TransitionBuilder.bouncerToGoneTransition() { spec = tween(durationMillis = 500) - fade(Bouncer.rootElementKey) + fade(Scenes.Bouncer.rootElementKey) } diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromGoneToQuickSettingsTransition.kt b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromGoneToQuickSettingsTransition.kt index 291617f8edde..5bd158349f5e 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromGoneToQuickSettingsTransition.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromGoneToQuickSettingsTransition.kt @@ -3,10 +3,10 @@ package com.android.systemui.scene.ui.composable.transitions import androidx.compose.animation.core.tween import com.android.compose.animation.scene.Edge import com.android.compose.animation.scene.TransitionBuilder -import com.android.systemui.scene.ui.composable.QuickSettings +import com.android.systemui.scene.shared.model.Scenes fun TransitionBuilder.goneToQuickSettingsTransition() { spec = tween(durationMillis = 500) - translate(QuickSettings.rootElementKey, Edge.Top, true) + translate(Scenes.QuickSettings.rootElementKey, Edge.Top, true) } diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromLockscreenToCommunalTransition.kt b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromLockscreenToCommunalTransition.kt index ea8110ad8518..0021bf59d875 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromLockscreenToCommunalTransition.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromLockscreenToCommunalTransition.kt @@ -19,15 +19,14 @@ package com.android.systemui.scene.ui.composable.transitions import androidx.compose.animation.core.tween import com.android.compose.animation.scene.Edge import com.android.compose.animation.scene.TransitionBuilder -import com.android.systemui.scene.ui.composable.Communal -import com.android.systemui.scene.ui.composable.Lockscreen +import com.android.systemui.scene.shared.model.Scenes fun TransitionBuilder.lockscreenToCommunalTransition() { spec = tween(durationMillis = 500) // Translate lockscreen to the left. - translate(Lockscreen.rootElementKey, Edge.Left) + translate(Scenes.Lockscreen.rootElementKey, Edge.Left) // Translate communal from the right. - translate(Communal.rootElementKey, Edge.Right) + translate(Scenes.Communal.rootElementKey, Edge.Right) } diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromLockscreenToGoneTransition.kt b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromLockscreenToGoneTransition.kt index da6306dc656d..3e576bc9d538 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromLockscreenToGoneTransition.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromLockscreenToGoneTransition.kt @@ -2,10 +2,10 @@ package com.android.systemui.scene.ui.composable.transitions import androidx.compose.animation.core.tween import com.android.compose.animation.scene.TransitionBuilder -import com.android.systemui.scene.ui.composable.Lockscreen +import com.android.systemui.scene.shared.model.Scenes fun TransitionBuilder.lockscreenToGoneTransition() { spec = tween(durationMillis = 500) - fade(Lockscreen.rootElementKey) + fade(Scenes.Lockscreen.rootElementKey) } diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromLockscreenToQuickSettingsTransition.kt b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromLockscreenToQuickSettingsTransition.kt index e63bc4e458eb..962d8227a016 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromLockscreenToQuickSettingsTransition.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromLockscreenToQuickSettingsTransition.kt @@ -3,10 +3,10 @@ package com.android.systemui.scene.ui.composable.transitions import androidx.compose.animation.core.tween import com.android.compose.animation.scene.Edge import com.android.compose.animation.scene.TransitionBuilder -import com.android.systemui.scene.ui.composable.QuickSettings +import com.android.systemui.scene.shared.model.Scenes fun TransitionBuilder.lockscreenToQuickSettingsTransition() { spec = tween(durationMillis = 500) - translate(QuickSettings.rootElementKey, Edge.Top, true) + translate(Scenes.QuickSettings.rootElementKey, Edge.Top, true) } diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeHeader.kt b/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeHeader.kt index d7911eac8a61..12b07a3a69c2 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeHeader.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeHeader.kt @@ -63,8 +63,7 @@ import com.android.systemui.common.ui.compose.windowinsets.CutoutLocation import com.android.systemui.common.ui.compose.windowinsets.LocalDisplayCutout import com.android.systemui.privacy.OngoingPrivacyChip import com.android.systemui.res.R -import com.android.systemui.scene.ui.composable.QuickSettings -import com.android.systemui.scene.ui.composable.Shade as ShadeKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.shade.ui.composable.ShadeHeader.Dimensions.CollapsedHeight import com.android.systemui.shade.ui.composable.ShadeHeader.Values.ClockScale import com.android.systemui.shade.ui.viewmodel.ShadeHeaderViewModel @@ -443,7 +442,7 @@ private fun SceneScope.StatusIcons( }, update = { iconContainer -> iconContainer.setQsExpansionTransitioning( - layoutState.isTransitioningBetween(ShadeKey, QuickSettings) + layoutState.isTransitioningBetween(Scenes.Shade, Scenes.QuickSettings) ) if (isSingleCarrier || !useExpandedFormat) { iconContainer.removeIgnoredSlots(carrierIconSlots) diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeScene.kt b/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeScene.kt index 8484b7f5273f..094a2fa6819b 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeScene.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeScene.kt @@ -41,7 +41,9 @@ import androidx.compose.ui.res.dimensionResource import androidx.compose.ui.unit.dp import com.android.compose.animation.scene.ElementKey import com.android.compose.animation.scene.LowestZIndexScenePicker +import com.android.compose.animation.scene.SceneKey import com.android.compose.animation.scene.SceneScope +import com.android.compose.animation.scene.UserActionResult import com.android.compose.animation.scene.animateSceneFloatAsState import com.android.compose.modifiers.thenIf import com.android.systemui.battery.BatteryMeterViewController @@ -57,9 +59,8 @@ import com.android.systemui.notifications.ui.composable.NotificationScrollingSta import com.android.systemui.qs.ui.composable.QuickSettings import com.android.systemui.res.R import com.android.systemui.scene.shared.model.Direction -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.UserAction -import com.android.systemui.scene.shared.model.UserActionResult import com.android.systemui.scene.ui.composable.ComposableScene import com.android.systemui.shade.ui.viewmodel.ShadeSceneViewModel import com.android.systemui.statusbar.phone.StatusBarIconController @@ -109,7 +110,7 @@ constructor( private val mediaCarouselController: MediaCarouselController, @Named(QUICK_QS_PANEL) private val mediaHost: MediaHost, ) : ComposableScene { - override val key = SceneKey.Shade + override val key = Scenes.Shade override val destinationScenes: StateFlow<Map<UserAction, UserActionResult>> = viewModel.upDestinationSceneKey @@ -145,7 +146,7 @@ constructor( ): Map<UserAction, UserActionResult> { return mapOf( UserAction.Swipe(Direction.UP) to UserActionResult(up), - UserAction.Swipe(Direction.DOWN) to UserActionResult(SceneKey.QuickSettings), + UserAction.Swipe(Direction.DOWN) to UserActionResult(Scenes.QuickSettings), ) } } diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayout.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayout.kt index 1e3842a1de68..b7e2dd13f321 100644 --- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayout.kt +++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayout.kt @@ -391,7 +391,7 @@ interface SwipeSourceDetector { } /** The result of performing a [UserAction]. */ -class UserActionResult( +data class UserActionResult( /** The scene we should be transitioning to during the [UserAction]. */ val toScene: SceneKey, diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.kt index 38dc24ed2f5f..9dbeeda42986 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.kt @@ -31,6 +31,7 @@ import android.view.WindowInsetsController import android.widget.FrameLayout import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest +import com.android.compose.animation.scene.ObservableTransitionState import com.android.internal.logging.MetricsLogger import com.android.internal.logging.UiEventLogger import com.android.internal.widget.LockPatternUtils @@ -65,8 +66,7 @@ import com.android.systemui.scene.domain.interactor.SceneInteractor import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.flag.fakeSceneContainerFlags import com.android.systemui.scene.shared.model.FakeSceneDataSource -import com.android.systemui.scene.shared.model.ObservableTransitionState -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.fakeSceneDataSource import com.android.systemui.shared.Flags.FLAG_SIDEFPS_CONTROLLER_REFACTOR import com.android.systemui.statusbar.policy.ConfigurationController @@ -244,7 +244,7 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() { sceneInteractor = kosmos.sceneInteractor keyguardTransitionInteractor = kosmos.keyguardTransitionInteractor sceneTransitionStateFlow = - MutableStateFlow(ObservableTransitionState.Idle(SceneKey.Lockscreen)) + MutableStateFlow(ObservableTransitionState.Idle(Scenes.Lockscreen)) sceneInteractor.setTransitionState(sceneTransitionStateFlow) deviceEntryInteractor = kosmos.deviceEntryInteractor @@ -815,18 +815,18 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() { // not enough to trigger a dismissal of the keyguard. underTest.onViewAttached() fakeSceneDataSource.pause() - sceneInteractor.changeScene(SceneKey.Bouncer, "reason") + sceneInteractor.changeScene(Scenes.Bouncer, "reason") sceneTransitionStateFlow.value = ObservableTransitionState.Transition( - SceneKey.Lockscreen, - SceneKey.Bouncer, + Scenes.Lockscreen, + Scenes.Bouncer, flowOf(.5f), false, isUserInputOngoing = flowOf(false), ) runCurrent() - fakeSceneDataSource.unpause(expectedScene = SceneKey.Bouncer) - sceneTransitionStateFlow.value = ObservableTransitionState.Idle(SceneKey.Bouncer) + fakeSceneDataSource.unpause(expectedScene = Scenes.Bouncer) + sceneTransitionStateFlow.value = ObservableTransitionState.Idle(Scenes.Bouncer) runCurrent() verify(viewMediatorCallback, never()).keyguardDone(anyInt()) @@ -835,18 +835,18 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() { kosmos.fakeDeviceEntryRepository.setUnlocked(true) runCurrent() fakeSceneDataSource.pause() - sceneInteractor.changeScene(SceneKey.Gone, "reason") + sceneInteractor.changeScene(Scenes.Gone, "reason") sceneTransitionStateFlow.value = ObservableTransitionState.Transition( - SceneKey.Bouncer, - SceneKey.Gone, + Scenes.Bouncer, + Scenes.Gone, flowOf(.5f), false, isUserInputOngoing = flowOf(false), ) runCurrent() - fakeSceneDataSource.unpause(expectedScene = SceneKey.Gone) - sceneTransitionStateFlow.value = ObservableTransitionState.Idle(SceneKey.Gone) + fakeSceneDataSource.unpause(expectedScene = Scenes.Gone) + sceneTransitionStateFlow.value = ObservableTransitionState.Idle(Scenes.Gone) runCurrent() verify(viewMediatorCallback).keyguardDone(anyInt()) @@ -854,18 +854,18 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() { // again. clearInvocations(viewMediatorCallback) fakeSceneDataSource.pause() - sceneInteractor.changeScene(SceneKey.Bouncer, "reason") + sceneInteractor.changeScene(Scenes.Bouncer, "reason") sceneTransitionStateFlow.value = ObservableTransitionState.Transition( - SceneKey.Gone, - SceneKey.Bouncer, + Scenes.Gone, + Scenes.Bouncer, flowOf(.5f), false, isUserInputOngoing = flowOf(false), ) runCurrent() - fakeSceneDataSource.unpause(expectedScene = SceneKey.Bouncer) - sceneTransitionStateFlow.value = ObservableTransitionState.Idle(SceneKey.Bouncer) + fakeSceneDataSource.unpause(expectedScene = Scenes.Bouncer) + sceneTransitionStateFlow.value = ObservableTransitionState.Idle(Scenes.Bouncer) runCurrent() verify(viewMediatorCallback, never()).keyguardDone(anyInt()) @@ -874,35 +874,35 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() { // does not dismiss the keyguard while we're not listening. underTest.onViewDetached() fakeSceneDataSource.pause() - sceneInteractor.changeScene(SceneKey.Gone, "reason") + sceneInteractor.changeScene(Scenes.Gone, "reason") sceneTransitionStateFlow.value = ObservableTransitionState.Transition( - SceneKey.Bouncer, - SceneKey.Gone, + Scenes.Bouncer, + Scenes.Gone, flowOf(.5f), false, isUserInputOngoing = flowOf(false), ) runCurrent() - fakeSceneDataSource.unpause(expectedScene = SceneKey.Gone) - sceneTransitionStateFlow.value = ObservableTransitionState.Idle(SceneKey.Gone) + fakeSceneDataSource.unpause(expectedScene = Scenes.Gone) + sceneTransitionStateFlow.value = ObservableTransitionState.Idle(Scenes.Gone) runCurrent() verify(viewMediatorCallback, never()).keyguardDone(anyInt()) // While not listening, moving to the lockscreen does not dismiss the keyguard. fakeSceneDataSource.pause() - sceneInteractor.changeScene(SceneKey.Lockscreen, "reason") + sceneInteractor.changeScene(Scenes.Lockscreen, "reason") sceneTransitionStateFlow.value = ObservableTransitionState.Transition( - SceneKey.Gone, - SceneKey.Lockscreen, + Scenes.Gone, + Scenes.Lockscreen, flowOf(.5f), false, isUserInputOngoing = flowOf(false), ) runCurrent() - fakeSceneDataSource.unpause(expectedScene = SceneKey.Lockscreen) - sceneTransitionStateFlow.value = ObservableTransitionState.Idle(SceneKey.Lockscreen) + fakeSceneDataSource.unpause(expectedScene = Scenes.Lockscreen) + sceneTransitionStateFlow.value = ObservableTransitionState.Idle(Scenes.Lockscreen) runCurrent() verify(viewMediatorCallback, never()).keyguardDone(anyInt()) @@ -910,18 +910,18 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() { // gone scene now does dismiss the keyguard again, this time from lockscreen. underTest.onViewAttached() fakeSceneDataSource.pause() - sceneInteractor.changeScene(SceneKey.Gone, "reason") + sceneInteractor.changeScene(Scenes.Gone, "reason") sceneTransitionStateFlow.value = ObservableTransitionState.Transition( - SceneKey.Lockscreen, - SceneKey.Gone, + Scenes.Lockscreen, + Scenes.Gone, flowOf(.5f), false, isUserInputOngoing = flowOf(false), ) runCurrent() - fakeSceneDataSource.unpause(expectedScene = SceneKey.Gone) - sceneTransitionStateFlow.value = ObservableTransitionState.Idle(SceneKey.Gone) + fakeSceneDataSource.unpause(expectedScene = Scenes.Gone) + sceneTransitionStateFlow.value = ObservableTransitionState.Idle(Scenes.Gone) runCurrent() verify(viewMediatorCallback).keyguardDone(anyInt()) } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/bouncer/ui/viewmodel/PasswordBouncerViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/bouncer/ui/viewmodel/PasswordBouncerViewModelTest.kt index ad29e68f1bbf..df50eb64f8b6 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/bouncer/ui/viewmodel/PasswordBouncerViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/bouncer/ui/viewmodel/PasswordBouncerViewModelTest.kt @@ -19,6 +19,7 @@ package com.android.systemui.bouncer.ui.viewmodel import android.content.pm.UserInfo import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest +import com.android.compose.animation.scene.SceneKey import com.android.systemui.SysuiTestCase import com.android.systemui.authentication.data.repository.fakeAuthenticationRepository import com.android.systemui.authentication.domain.interactor.authenticationInteractor @@ -33,7 +34,7 @@ import com.android.systemui.inputmethod.domain.interactor.inputMethodInteractor import com.android.systemui.kosmos.testScope import com.android.systemui.res.R import com.android.systemui.scene.domain.interactor.sceneInteractor -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.testKosmos import com.android.systemui.user.data.model.SelectedUserModel import com.android.systemui.user.data.model.SelectionStatus @@ -93,7 +94,7 @@ class PasswordBouncerViewModelTest : SysuiTestCase() { assertThat(message?.text).isEqualTo(ENTER_YOUR_PASSWORD) assertThat(password).isEmpty() - assertThat(currentScene).isEqualTo(SceneKey.Bouncer) + assertThat(currentScene).isEqualTo(Scenes.Bouncer) assertThat(underTest.authenticationMethod).isEqualTo(AuthenticationMethodModel.Password) } @@ -125,7 +126,7 @@ class PasswordBouncerViewModelTest : SysuiTestCase() { assertThat(message?.text).isEmpty() assertThat(password).isEqualTo("password") - assertThat(currentScene).isEqualTo(SceneKey.Bouncer) + assertThat(currentScene).isEqualTo(Scenes.Bouncer) } @Test @@ -163,7 +164,7 @@ class PasswordBouncerViewModelTest : SysuiTestCase() { AuthenticationMethodModel.Password ) kosmos.fakeDeviceEntryRepository.setUnlocked(false) - switchToScene(SceneKey.Bouncer) + switchToScene(Scenes.Bouncer) // No input entered. @@ -209,14 +210,14 @@ class PasswordBouncerViewModelTest : SysuiTestCase() { assertThat(password).isEqualTo("password") // The user doesn't confirm the password, but navigates back to the lockscreen instead. - switchToScene(SceneKey.Lockscreen) + switchToScene(Scenes.Lockscreen) // The user navigates to the bouncer again. - switchToScene(SceneKey.Bouncer) + switchToScene(Scenes.Bouncer) // Ensure the previously-entered password is not shown. assertThat(password).isEmpty() - assertThat(currentScene).isEqualTo(SceneKey.Bouncer) + assertThat(currentScene).isEqualTo(Scenes.Bouncer) } @Test @@ -330,8 +331,8 @@ class PasswordBouncerViewModelTest : SysuiTestCase() { private fun TestScope.switchToScene(toScene: SceneKey) { val currentScene by collectLastValue(sceneInteractor.currentScene) - val bouncerShown = currentScene != SceneKey.Bouncer && toScene == SceneKey.Bouncer - val bouncerHidden = currentScene == SceneKey.Bouncer && toScene != SceneKey.Bouncer + val bouncerShown = currentScene != Scenes.Bouncer && toScene == Scenes.Bouncer + val bouncerHidden = currentScene == Scenes.Bouncer && toScene != Scenes.Bouncer sceneInteractor.changeScene(toScene, "reason") if (bouncerShown) underTest.onShown() if (bouncerHidden) underTest.onHidden() @@ -345,7 +346,7 @@ class PasswordBouncerViewModelTest : SysuiTestCase() { AuthenticationMethodModel.Password ) kosmos.fakeDeviceEntryRepository.setUnlocked(false) - switchToScene(SceneKey.Bouncer) + switchToScene(Scenes.Bouncer) } private suspend fun TestScope.setLockout( diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/bouncer/ui/viewmodel/PatternBouncerViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/bouncer/ui/viewmodel/PatternBouncerViewModelTest.kt index 32de1f2a892c..91a056ddd685 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/bouncer/ui/viewmodel/PatternBouncerViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/bouncer/ui/viewmodel/PatternBouncerViewModelTest.kt @@ -18,6 +18,7 @@ package com.android.systemui.bouncer.ui.viewmodel import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest +import com.android.compose.animation.scene.SceneKey import com.android.systemui.SysuiTestCase import com.android.systemui.authentication.data.repository.FakeAuthenticationRepository import com.android.systemui.authentication.data.repository.authenticationRepository @@ -31,7 +32,7 @@ import com.android.systemui.deviceentry.data.repository.fakeDeviceEntryRepositor import com.android.systemui.kosmos.testScope import com.android.systemui.res.R import com.android.systemui.scene.domain.interactor.sceneInteractor -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertWithMessage @@ -86,7 +87,7 @@ class PatternBouncerViewModelTest : SysuiTestCase() { assertThat(message?.text).isEqualTo(ENTER_YOUR_PATTERN) assertThat(selectedDots).isEmpty() assertThat(currentDot).isNull() - assertThat(currentScene).isEqualTo(SceneKey.Bouncer) + assertThat(currentScene).isEqualTo(Scenes.Bouncer) assertThat(underTest.authenticationMethod).isEqualTo(AuthenticationMethodModel.Pattern) } @@ -104,7 +105,7 @@ class PatternBouncerViewModelTest : SysuiTestCase() { assertThat(message?.text).isEmpty() assertThat(selectedDots).isEmpty() assertThat(currentDot).isNull() - assertThat(currentScene).isEqualTo(SceneKey.Bouncer) + assertThat(currentScene).isEqualTo(Scenes.Bouncer) } @Test @@ -159,7 +160,7 @@ class PatternBouncerViewModelTest : SysuiTestCase() { assertThat(selectedDots).isEmpty() assertThat(currentDot).isNull() assertThat(message?.text).isEqualTo(WRONG_PATTERN) - assertThat(currentScene).isEqualTo(SceneKey.Bouncer) + assertThat(currentScene).isEqualTo(Scenes.Bouncer) } @Test @@ -369,8 +370,8 @@ class PatternBouncerViewModelTest : SysuiTestCase() { private fun TestScope.switchToScene(toScene: SceneKey) { val currentScene by collectLastValue(sceneInteractor.currentScene) - val bouncerShown = currentScene != SceneKey.Bouncer && toScene == SceneKey.Bouncer - val bouncerHidden = currentScene == SceneKey.Bouncer && toScene != SceneKey.Bouncer + val bouncerShown = currentScene != Scenes.Bouncer && toScene == Scenes.Bouncer + val bouncerHidden = currentScene == Scenes.Bouncer && toScene != Scenes.Bouncer sceneInteractor.changeScene(toScene, "reason") if (bouncerShown) underTest.onShown() if (bouncerHidden) underTest.onHidden() @@ -384,7 +385,7 @@ class PatternBouncerViewModelTest : SysuiTestCase() { AuthenticationMethodModel.Pattern ) kosmos.fakeDeviceEntryRepository.setUnlocked(false) - switchToScene(SceneKey.Bouncer) + switchToScene(Scenes.Bouncer) } companion object { diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/bouncer/ui/viewmodel/PinBouncerViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/bouncer/ui/viewmodel/PinBouncerViewModelTest.kt index ccf7094e2bf7..7b75a3715415 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/bouncer/ui/viewmodel/PinBouncerViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/bouncer/ui/viewmodel/PinBouncerViewModelTest.kt @@ -18,6 +18,7 @@ package com.android.systemui.bouncer.ui.viewmodel import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest +import com.android.compose.animation.scene.SceneKey import com.android.systemui.SysuiTestCase import com.android.systemui.authentication.data.repository.FakeAuthenticationRepository import com.android.systemui.authentication.data.repository.fakeAuthenticationRepository @@ -31,7 +32,7 @@ import com.android.systemui.deviceentry.data.repository.fakeDeviceEntryRepositor import com.android.systemui.kosmos.testScope import com.android.systemui.res.R import com.android.systemui.scene.domain.interactor.sceneInteractor -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -196,7 +197,7 @@ class PinBouncerViewModelTest : SysuiTestCase() { assertThat(message?.text).isEmpty() assertThat(pin).isEmpty() - assertThat(currentScene).isEqualTo(SceneKey.Bouncer) + assertThat(currentScene).isEqualTo(Scenes.Bouncer) } @Test @@ -230,7 +231,7 @@ class PinBouncerViewModelTest : SysuiTestCase() { assertThat(pin).isEmpty() assertThat(message?.text).ignoringCase().isEqualTo(WRONG_PIN) - assertThat(currentScene).isEqualTo(SceneKey.Bouncer) + assertThat(currentScene).isEqualTo(Scenes.Bouncer) } @Test @@ -290,7 +291,7 @@ class PinBouncerViewModelTest : SysuiTestCase() { assertThat(pin).isEmpty() assertThat(message?.text).ignoringCase().isEqualTo(WRONG_PIN) - assertThat(currentScene).isEqualTo(SceneKey.Bouncer) + assertThat(currentScene).isEqualTo(Scenes.Bouncer) } @Test @@ -304,10 +305,10 @@ class PinBouncerViewModelTest : SysuiTestCase() { assertThat(pin).isNotEmpty() // The user doesn't confirm the PIN, but navigates back to the lockscreen instead. - switchToScene(SceneKey.Lockscreen) + switchToScene(Scenes.Lockscreen) // The user navigates to the bouncer again. - switchToScene(SceneKey.Bouncer) + switchToScene(Scenes.Bouncer) // Ensure the previously-entered PIN is not shown. assertThat(pin).isEmpty() @@ -389,8 +390,8 @@ class PinBouncerViewModelTest : SysuiTestCase() { private fun TestScope.switchToScene(toScene: SceneKey) { val currentScene by collectLastValue(sceneInteractor.currentScene) - val bouncerShown = currentScene != SceneKey.Bouncer && toScene == SceneKey.Bouncer - val bouncerHidden = currentScene == SceneKey.Bouncer && toScene != SceneKey.Bouncer + val bouncerShown = currentScene != Scenes.Bouncer && toScene == Scenes.Bouncer + val bouncerHidden = currentScene == Scenes.Bouncer && toScene != Scenes.Bouncer sceneInteractor.changeScene(toScene, "reason") if (bouncerShown) underTest.onShown() if (bouncerHidden) underTest.onHidden() @@ -402,7 +403,7 @@ class PinBouncerViewModelTest : SysuiTestCase() { private fun TestScope.lockDeviceAndOpenPinBouncer() { kosmos.fakeAuthenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin) kosmos.fakeDeviceEntryRepository.setUnlocked(false) - switchToScene(SceneKey.Bouncer) + switchToScene(Scenes.Bouncer) } companion object { diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalSceneStartableTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalSceneStartableTest.kt index 92396e0bcdef..37b135eaf3e9 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalSceneStartableTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalSceneStartableTest.kt @@ -21,7 +21,7 @@ import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.communal.domain.interactor.communalInteractor import com.android.systemui.communal.domain.interactor.setCommunalAvailable -import com.android.systemui.communal.shared.model.CommunalSceneKey +import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.coroutines.collectLastValue import com.android.systemui.dock.DockManager import com.android.systemui.dock.dockManager @@ -79,8 +79,8 @@ class CommunalSceneStartableTest : SysuiTestCase() { testScope.runTest { val scene by collectLastValue(communalInteractor.desiredScene) - communalInteractor.onSceneChanged(CommunalSceneKey.Communal) - assertThat(scene).isEqualTo(CommunalSceneKey.Communal) + communalInteractor.onSceneChanged(CommunalScenes.Communal) + assertThat(scene).isEqualTo(CommunalScenes.Communal) fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.PRIMARY_BOUNCER, @@ -88,7 +88,7 @@ class CommunalSceneStartableTest : SysuiTestCase() { testScope = this ) - assertThat(scene).isEqualTo(CommunalSceneKey.Blank) + assertThat(scene).isEqualTo(CommunalScenes.Blank) } } @@ -97,7 +97,7 @@ class CommunalSceneStartableTest : SysuiTestCase() { with(kosmos) { testScope.runTest { val scene by collectLastValue(communalInteractor.desiredScene) - assertThat(scene).isEqualTo(CommunalSceneKey.Blank) + assertThat(scene).isEqualTo(CommunalScenes.Blank) updateDocked(true) fakeKeyguardTransitionRepository.sendTransitionSteps( @@ -105,7 +105,7 @@ class CommunalSceneStartableTest : SysuiTestCase() { to = KeyguardState.LOCKSCREEN, testScope = this ) - assertThat(scene).isEqualTo(CommunalSceneKey.Communal) + assertThat(scene).isEqualTo(CommunalScenes.Communal) } } @@ -114,7 +114,7 @@ class CommunalSceneStartableTest : SysuiTestCase() { with(kosmos) { testScope.runTest { val scene by collectLastValue(communalInteractor.desiredScene) - assertThat(scene).isEqualTo(CommunalSceneKey.Blank) + assertThat(scene).isEqualTo(CommunalScenes.Blank) updateDocked(true) fakeKeyguardTransitionRepository.sendTransitionSteps( @@ -122,7 +122,7 @@ class CommunalSceneStartableTest : SysuiTestCase() { to = KeyguardState.LOCKSCREEN, testScope = this ) - assertThat(scene).isEqualTo(CommunalSceneKey.Blank) + assertThat(scene).isEqualTo(CommunalScenes.Blank) } } @@ -131,19 +131,19 @@ class CommunalSceneStartableTest : SysuiTestCase() { with(kosmos) { testScope.runTest { val scene by collectLastValue(communalInteractor.desiredScene) - communalInteractor.onSceneChanged(CommunalSceneKey.Communal) - assertThat(scene).isEqualTo(CommunalSceneKey.Communal) + communalInteractor.onSceneChanged(CommunalScenes.Communal) + assertThat(scene).isEqualTo(CommunalScenes.Communal) fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.GLANCEABLE_HUB, to = KeyguardState.OFF, testScope = this ) - assertThat(scene).isEqualTo(CommunalSceneKey.Communal) + assertThat(scene).isEqualTo(CommunalScenes.Communal) advanceTimeBy(CommunalSceneStartable.AWAKE_DEBOUNCE_DELAY) - assertThat(scene).isEqualTo(CommunalSceneKey.Blank) + assertThat(scene).isEqualTo(CommunalScenes.Blank) } } @@ -152,17 +152,17 @@ class CommunalSceneStartableTest : SysuiTestCase() { with(kosmos) { testScope.runTest { val scene by collectLastValue(communalInteractor.desiredScene) - communalInteractor.onSceneChanged(CommunalSceneKey.Communal) - assertThat(scene).isEqualTo(CommunalSceneKey.Communal) + communalInteractor.onSceneChanged(CommunalScenes.Communal) + assertThat(scene).isEqualTo(CommunalScenes.Communal) fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.GLANCEABLE_HUB, to = KeyguardState.OFF, testScope = this ) - assertThat(scene).isEqualTo(CommunalSceneKey.Communal) + assertThat(scene).isEqualTo(CommunalScenes.Communal) advanceTimeBy(CommunalSceneStartable.AWAKE_DEBOUNCE_DELAY / 2) - assertThat(scene).isEqualTo(CommunalSceneKey.Communal) + assertThat(scene).isEqualTo(CommunalScenes.Communal) fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.OFF, @@ -171,7 +171,7 @@ class CommunalSceneStartableTest : SysuiTestCase() { ) advanceTimeBy(CommunalSceneStartable.AWAKE_DEBOUNCE_DELAY) - assertThat(scene).isEqualTo(CommunalSceneKey.Communal) + assertThat(scene).isEqualTo(CommunalScenes.Communal) } } @@ -179,7 +179,7 @@ class CommunalSceneStartableTest : SysuiTestCase() { fun dockingOnLockscreen_forcesCommunal() = with(kosmos) { testScope.runTest { - communalInteractor.onSceneChanged(CommunalSceneKey.Blank) + communalInteractor.onSceneChanged(CommunalScenes.Blank) val scene by collectLastValue(communalInteractor.desiredScene) // device is docked while on the lockscreen @@ -190,9 +190,9 @@ class CommunalSceneStartableTest : SysuiTestCase() { ) updateDocked(true) - assertThat(scene).isEqualTo(CommunalSceneKey.Blank) + assertThat(scene).isEqualTo(CommunalScenes.Blank) advanceTimeBy(CommunalSceneStartable.DOCK_DEBOUNCE_DELAY) - assertThat(scene).isEqualTo(CommunalSceneKey.Communal) + assertThat(scene).isEqualTo(CommunalScenes.Communal) } } @@ -200,7 +200,7 @@ class CommunalSceneStartableTest : SysuiTestCase() { fun dockingOnLockscreen_doesNotForceCommunalIfDreamStarts() = with(kosmos) { testScope.runTest { - communalInteractor.onSceneChanged(CommunalSceneKey.Blank) + communalInteractor.onSceneChanged(CommunalScenes.Blank) val scene by collectLastValue(communalInteractor.desiredScene) // device is docked while on the lockscreen @@ -211,9 +211,9 @@ class CommunalSceneStartableTest : SysuiTestCase() { ) updateDocked(true) - assertThat(scene).isEqualTo(CommunalSceneKey.Blank) + assertThat(scene).isEqualTo(CommunalScenes.Blank) advanceTimeBy(CommunalSceneStartable.DOCK_DEBOUNCE_DELAY / 2) - assertThat(scene).isEqualTo(CommunalSceneKey.Blank) + assertThat(scene).isEqualTo(CommunalScenes.Blank) // dream starts shortly after docking fakeKeyguardTransitionRepository.sendTransitionSteps( @@ -222,7 +222,7 @@ class CommunalSceneStartableTest : SysuiTestCase() { testScope = this ) advanceTimeBy(CommunalSceneStartable.DOCK_DEBOUNCE_DELAY) - assertThat(scene).isEqualTo(CommunalSceneKey.Blank) + assertThat(scene).isEqualTo(CommunalScenes.Blank) } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/data/repository/CommunalRepositoryImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/data/repository/CommunalRepositoryImplTest.kt index 06b3806cb382..43acf3197fb1 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/data/repository/CommunalRepositoryImplTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/data/repository/CommunalRepositoryImplTest.kt @@ -18,9 +18,9 @@ package com.android.systemui.communal.data.repository import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest +import com.android.compose.animation.scene.ObservableTransitionState import com.android.systemui.SysuiTestCase -import com.android.systemui.communal.shared.model.CommunalSceneKey -import com.android.systemui.communal.shared.model.ObservableCommunalTransitionState +import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.testScope import com.android.systemui.scene.data.repository.sceneContainerRepository @@ -60,20 +60,17 @@ class CommunalRepositoryImplTest : SysuiTestCase() { testScope.runTest { val transitionState by collectLastValue(underTest.transitionState) assertThat(transitionState) - .isEqualTo(ObservableCommunalTransitionState.Idle(CommunalSceneKey.DEFAULT)) + .isEqualTo(ObservableTransitionState.Idle(CommunalScenes.Default)) } @Test fun transitionState_setTransitionState_returnsNewValue() = testScope.runTest { - val expectedSceneKey = CommunalSceneKey.Communal - underTest.setTransitionState( - flowOf(ObservableCommunalTransitionState.Idle(expectedSceneKey)) - ) + val expectedSceneKey = CommunalScenes.Communal + underTest.setTransitionState(flowOf(ObservableTransitionState.Idle(expectedSceneKey))) val transitionState by collectLastValue(underTest.transitionState) - assertThat(transitionState) - .isEqualTo(ObservableCommunalTransitionState.Idle(expectedSceneKey)) + assertThat(transitionState).isEqualTo(ObservableTransitionState.Idle(expectedSceneKey)) } @Test @@ -81,7 +78,7 @@ class CommunalRepositoryImplTest : SysuiTestCase() { testScope.runTest { // Set a value for the transition state flow. underTest.setTransitionState( - flowOf(ObservableCommunalTransitionState.Idle(CommunalSceneKey.Communal)) + flowOf(ObservableTransitionState.Idle(CommunalScenes.Communal)) ) // Set the transition state flow back to null. @@ -90,6 +87,6 @@ class CommunalRepositoryImplTest : SysuiTestCase() { // Flow returns default scene key. val transitionState by collectLastValue(underTest.transitionState) assertThat(transitionState) - .isEqualTo(ObservableCommunalTransitionState.Idle(CommunalSceneKey.DEFAULT)) + .isEqualTo(ObservableTransitionState.Idle(CommunalScenes.Default)) } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalInteractorTest.kt index 6e3573b64f9a..eafd5038759c 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalInteractorTest.kt @@ -25,6 +25,7 @@ import android.provider.Settings.Secure.HUB_MODE_TUTORIAL_COMPLETED import android.widget.RemoteViews import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest +import com.android.compose.animation.scene.ObservableTransitionState import com.android.systemui.Flags.FLAG_COMMUNAL_HUB import com.android.systemui.SysuiTestCase import com.android.systemui.communal.data.repository.CommunalSettingsRepositoryImpl @@ -40,9 +41,8 @@ import com.android.systemui.communal.data.repository.fakeCommunalTutorialReposit import com.android.systemui.communal.data.repository.fakeCommunalWidgetRepository import com.android.systemui.communal.domain.model.CommunalContentModel import com.android.systemui.communal.shared.model.CommunalContentSize -import com.android.systemui.communal.shared.model.CommunalSceneKey +import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.communal.shared.model.CommunalWidgetContentModel -import com.android.systemui.communal.shared.model.ObservableCommunalTransitionState import com.android.systemui.communal.widgets.EditWidgetsActivityStarter import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.Flags @@ -53,7 +53,7 @@ import com.android.systemui.kosmos.testScope import com.android.systemui.scene.domain.interactor.SceneInteractor import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.flag.fakeSceneContainerFlags -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.settings.FakeUserTracker import com.android.systemui.settings.fakeUserTracker import com.android.systemui.smartspace.data.repository.FakeSmartspaceRepository @@ -462,9 +462,9 @@ class CommunalInteractorTest : SysuiTestCase() { var desiredScene = collectLastValue(underTest.desiredScene) runCurrent() - assertThat(desiredScene()).isEqualTo(CommunalSceneKey.Blank) + assertThat(desiredScene()).isEqualTo(CommunalScenes.Blank) - val targetScene = CommunalSceneKey.Communal + val targetScene = CommunalScenes.Communal communalRepository.setDesiredScene(targetScene) desiredScene = collectLastValue(underTest.desiredScene) runCurrent() @@ -474,7 +474,7 @@ class CommunalInteractorTest : SysuiTestCase() { @Test fun updatesScene() = testScope.runTest { - val targetScene = CommunalSceneKey.Communal + val targetScene = CommunalScenes.Communal underTest.onSceneChanged(targetScene) @@ -491,32 +491,32 @@ class CommunalInteractorTest : SysuiTestCase() { val desiredScene by collectLastValue(underTest.desiredScene) - underTest.onSceneChanged(CommunalSceneKey.Communal) - assertThat(desiredScene).isEqualTo(CommunalSceneKey.Communal) + underTest.onSceneChanged(CommunalScenes.Communal) + assertThat(desiredScene).isEqualTo(CommunalScenes.Communal) kosmos.setCommunalAvailable(false) runCurrent() // Scene returns blank when communal is not available. - assertThat(desiredScene).isEqualTo(CommunalSceneKey.Blank) + assertThat(desiredScene).isEqualTo(CommunalScenes.Blank) kosmos.setCommunalAvailable(true) runCurrent() // After re-enabling, scene goes back to Communal. - assertThat(desiredScene).isEqualTo(CommunalSceneKey.Communal) + assertThat(desiredScene).isEqualTo(CommunalScenes.Communal) } @Test fun transitionProgress_onTargetScene_fullProgress() = testScope.runTest { - val targetScene = CommunalSceneKey.Blank + val targetScene = CommunalScenes.Blank val transitionProgressFlow = underTest.transitionProgressToScene(targetScene) val transitionProgress by collectLastValue(transitionProgressFlow) val transitionState = - MutableStateFlow<ObservableCommunalTransitionState>( - ObservableCommunalTransitionState.Idle(targetScene) + MutableStateFlow<ObservableTransitionState>( + ObservableTransitionState.Idle(targetScene) ) underTest.setTransitionState(transitionState) @@ -527,14 +527,14 @@ class CommunalInteractorTest : SysuiTestCase() { @Test fun transitionProgress_notOnTargetScene_noProgress() = testScope.runTest { - val targetScene = CommunalSceneKey.Blank - val currentScene = CommunalSceneKey.Communal + val targetScene = CommunalScenes.Blank + val currentScene = CommunalScenes.Communal val transitionProgressFlow = underTest.transitionProgressToScene(targetScene) val transitionProgress by collectLastValue(transitionProgressFlow) val transitionState = - MutableStateFlow<ObservableCommunalTransitionState>( - ObservableCommunalTransitionState.Idle(currentScene) + MutableStateFlow<ObservableTransitionState>( + ObservableTransitionState.Idle(currentScene) ) underTest.setTransitionState(transitionState) @@ -545,14 +545,14 @@ class CommunalInteractorTest : SysuiTestCase() { @Test fun transitionProgress_transitioningToTrackedScene() = testScope.runTest { - val currentScene = CommunalSceneKey.Communal - val targetScene = CommunalSceneKey.Blank + val currentScene = CommunalScenes.Communal + val targetScene = CommunalScenes.Blank val transitionProgressFlow = underTest.transitionProgressToScene(targetScene) val transitionProgress by collectLastValue(transitionProgressFlow) var transitionState = - MutableStateFlow<ObservableCommunalTransitionState>( - ObservableCommunalTransitionState.Idle(currentScene) + MutableStateFlow<ObservableTransitionState>( + ObservableTransitionState.Idle(currentScene) ) underTest.setTransitionState(transitionState) @@ -562,7 +562,7 @@ class CommunalInteractorTest : SysuiTestCase() { val progress = MutableStateFlow(0f) transitionState = MutableStateFlow( - ObservableCommunalTransitionState.Transition( + ObservableTransitionState.Transition( fromScene = currentScene, toScene = targetScene, progress = progress, @@ -581,7 +581,7 @@ class CommunalInteractorTest : SysuiTestCase() { assertThat(transitionProgress).isEqualTo(CommunalTransitionProgress.Transition(1f)) // Transition finishes. - transitionState = MutableStateFlow(ObservableCommunalTransitionState.Idle(targetScene)) + transitionState = MutableStateFlow(ObservableTransitionState.Idle(targetScene)) underTest.setTransitionState(transitionState) assertThat(transitionProgress).isEqualTo(CommunalTransitionProgress.Idle(targetScene)) } @@ -589,14 +589,14 @@ class CommunalInteractorTest : SysuiTestCase() { @Test fun transitionProgress_transitioningAwayFromTrackedScene() = testScope.runTest { - val currentScene = CommunalSceneKey.Blank - val targetScene = CommunalSceneKey.Communal + val currentScene = CommunalScenes.Blank + val targetScene = CommunalScenes.Communal val transitionProgressFlow = underTest.transitionProgressToScene(currentScene) val transitionProgress by collectLastValue(transitionProgressFlow) var transitionState = - MutableStateFlow<ObservableCommunalTransitionState>( - ObservableCommunalTransitionState.Idle(currentScene) + MutableStateFlow<ObservableTransitionState>( + ObservableTransitionState.Idle(currentScene) ) underTest.setTransitionState(transitionState) @@ -606,7 +606,7 @@ class CommunalInteractorTest : SysuiTestCase() { val progress = MutableStateFlow(0f) transitionState = MutableStateFlow( - ObservableCommunalTransitionState.Transition( + ObservableTransitionState.Transition( fromScene = currentScene, toScene = targetScene, progress = progress, @@ -627,7 +627,7 @@ class CommunalInteractorTest : SysuiTestCase() { assertThat(transitionProgress).isEqualTo(CommunalTransitionProgress.OtherTransition) // Transition finishes. - transitionState = MutableStateFlow(ObservableCommunalTransitionState.Idle(targetScene)) + transitionState = MutableStateFlow(ObservableTransitionState.Idle(targetScene)) underTest.setTransitionState(transitionState) assertThat(transitionProgress).isEqualTo(CommunalTransitionProgress.Idle(targetScene)) } @@ -642,7 +642,7 @@ class CommunalInteractorTest : SysuiTestCase() { runCurrent() assertThat(isCommunalShowing()).isEqualTo(false) - underTest.onSceneChanged(CommunalSceneKey.Communal) + underTest.onSceneChanged(CommunalScenes.Communal) isCommunalShowing = collectLastValue(underTest.isCommunalShowing) runCurrent() @@ -661,17 +661,17 @@ class CommunalInteractorTest : SysuiTestCase() { assertThat(isCommunalShowing).isFalse() // Verify scene changes with the flag doesn't have any impact - sceneInteractor.changeScene(SceneKey.Communal, loggingReason = "") + sceneInteractor.changeScene(Scenes.Communal, loggingReason = "") runCurrent() assertThat(isCommunalShowing).isFalse() // Verify scene changes (without the flag) to communal sets the value to true - underTest.onSceneChanged(CommunalSceneKey.Communal) + underTest.onSceneChanged(CommunalScenes.Communal) runCurrent() assertThat(isCommunalShowing).isTrue() // Verify scene changes (without the flag) to blank sets the value back to false - underTest.onSceneChanged(CommunalSceneKey.Blank) + underTest.onSceneChanged(CommunalScenes.Blank) runCurrent() assertThat(isCommunalShowing).isFalse() } @@ -687,17 +687,17 @@ class CommunalInteractorTest : SysuiTestCase() { assertThat(isCommunalShowing).isFalse() // Verify scene changes without the flag doesn't have any impact - underTest.onSceneChanged(CommunalSceneKey.Communal) + underTest.onSceneChanged(CommunalScenes.Communal) runCurrent() assertThat(isCommunalShowing).isFalse() // Verify scene changes (with the flag) to communal sets the value to true - sceneInteractor.changeScene(SceneKey.Communal, loggingReason = "") + sceneInteractor.changeScene(Scenes.Communal, loggingReason = "") runCurrent() assertThat(isCommunalShowing).isTrue() // Verify scene changes (with the flag) to lockscreen sets the value to false - sceneInteractor.changeScene(SceneKey.Lockscreen, loggingReason = "") + sceneInteractor.changeScene(Scenes.Lockscreen, loggingReason = "") runCurrent() assertThat(isCommunalShowing).isFalse() } @@ -706,8 +706,8 @@ class CommunalInteractorTest : SysuiTestCase() { fun isIdleOnCommunal() = testScope.runTest { val transitionState = - MutableStateFlow<ObservableCommunalTransitionState>( - ObservableCommunalTransitionState.Idle(CommunalSceneKey.Blank) + MutableStateFlow<ObservableTransitionState>( + ObservableTransitionState.Idle(CommunalScenes.Blank) ) communalRepository.setTransitionState(transitionState) @@ -717,8 +717,7 @@ class CommunalInteractorTest : SysuiTestCase() { assertThat(isIdleOnCommunal).isEqualTo(false) // Transition to communal. - transitionState.value = - ObservableCommunalTransitionState.Idle(CommunalSceneKey.Communal) + transitionState.value = ObservableTransitionState.Idle(CommunalScenes.Communal) runCurrent() // isIdleOnCommunal is now true since we're on communal. @@ -726,9 +725,9 @@ class CommunalInteractorTest : SysuiTestCase() { // Start transition away from communal. transitionState.value = - ObservableCommunalTransitionState.Transition( - fromScene = CommunalSceneKey.Communal, - toScene = CommunalSceneKey.Blank, + ObservableTransitionState.Transition( + fromScene = CommunalScenes.Communal, + toScene = CommunalScenes.Blank, progress = flowOf(0f), isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), @@ -743,8 +742,8 @@ class CommunalInteractorTest : SysuiTestCase() { fun isCommunalVisible() = testScope.runTest { val transitionState = - MutableStateFlow<ObservableCommunalTransitionState>( - ObservableCommunalTransitionState.Idle(CommunalSceneKey.Blank) + MutableStateFlow<ObservableTransitionState>( + ObservableTransitionState.Idle(CommunalScenes.Blank) ) communalRepository.setTransitionState(transitionState) @@ -754,9 +753,9 @@ class CommunalInteractorTest : SysuiTestCase() { // Start transition to communal. transitionState.value = - ObservableCommunalTransitionState.Transition( - fromScene = CommunalSceneKey.Blank, - toScene = CommunalSceneKey.Communal, + ObservableTransitionState.Transition( + fromScene = CommunalScenes.Blank, + toScene = CommunalScenes.Communal, progress = flowOf(0f), isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), @@ -766,17 +765,16 @@ class CommunalInteractorTest : SysuiTestCase() { assertThat(isCommunalVisible).isEqualTo(true) // Finish transition to communal - transitionState.value = - ObservableCommunalTransitionState.Idle(CommunalSceneKey.Communal) + transitionState.value = ObservableTransitionState.Idle(CommunalScenes.Communal) // isCommunalVisible is true since we're on communal. assertThat(isCommunalVisible).isEqualTo(true) // Start transition away from communal. transitionState.value = - ObservableCommunalTransitionState.Transition( - fromScene = CommunalSceneKey.Communal, - toScene = CommunalSceneKey.Blank, + ObservableTransitionState.Transition( + fromScene = CommunalScenes.Communal, + toScene = CommunalScenes.Blank, progress = flowOf(1.0f), isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalTutorialInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalTutorialInteractorTest.kt index 8b785927ba5e..50b8da62b3f0 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalTutorialInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalTutorialInteractorTest.kt @@ -25,7 +25,7 @@ import com.android.systemui.Flags.FLAG_COMMUNAL_HUB import com.android.systemui.SysuiTestCase import com.android.systemui.communal.data.repository.FakeCommunalTutorialRepository import com.android.systemui.communal.data.repository.fakeCommunalTutorialRepository -import com.android.systemui.communal.shared.model.CommunalSceneKey +import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.Flags import com.android.systemui.flags.fakeFeatureFlagsClassic @@ -158,7 +158,7 @@ class CommunalTutorialInteractorTest : SysuiTestCase() { kosmos.setCommunalAvailable(true) communalTutorialRepository.setTutorialSettingState(HUB_MODE_TUTORIAL_NOT_STARTED) - communalInteractor.onSceneChanged(CommunalSceneKey.Blank) + communalInteractor.onSceneChanged(CommunalScenes.Blank) assertThat(tutorialSettingState).isEqualTo(HUB_MODE_TUTORIAL_NOT_STARTED) } @@ -171,7 +171,7 @@ class CommunalTutorialInteractorTest : SysuiTestCase() { goToCommunal() communalTutorialRepository.setTutorialSettingState(HUB_MODE_TUTORIAL_STARTED) - communalInteractor.onSceneChanged(CommunalSceneKey.Blank) + communalInteractor.onSceneChanged(CommunalScenes.Blank) assertThat(tutorialSettingState).isEqualTo(HUB_MODE_TUTORIAL_COMPLETED) } @@ -184,13 +184,13 @@ class CommunalTutorialInteractorTest : SysuiTestCase() { goToCommunal() communalTutorialRepository.setTutorialSettingState(HUB_MODE_TUTORIAL_COMPLETED) - communalInteractor.onSceneChanged(CommunalSceneKey.Blank) + communalInteractor.onSceneChanged(CommunalScenes.Blank) assertThat(tutorialSettingState).isEqualTo(HUB_MODE_TUTORIAL_COMPLETED) } private suspend fun goToCommunal() { kosmos.setCommunalAvailable(true) - communalInteractor.onSceneChanged(CommunalSceneKey.Communal) + communalInteractor.onSceneChanged(CommunalScenes.Communal) } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/log/CommunalLoggerStartableTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/log/CommunalLoggerStartableTest.kt index 6b1b93777fbc..a51315bd96b8 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/log/CommunalLoggerStartableTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/log/CommunalLoggerStartableTest.kt @@ -18,13 +18,14 @@ package com.android.systemui.communal.log import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest +import com.android.compose.animation.scene.ObservableTransitionState +import com.android.compose.animation.scene.SceneKey import com.android.internal.logging.UiEventLogger import com.android.systemui.SysuiTestCase import com.android.systemui.communal.domain.interactor.CommunalInteractor import com.android.systemui.communal.domain.interactor.communalInteractor import com.android.systemui.communal.shared.log.CommunalUiEvent -import com.android.systemui.communal.shared.model.CommunalSceneKey -import com.android.systemui.communal.shared.model.ObservableCommunalTransitionState +import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.kosmos.testScope import com.android.systemui.testKosmos import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -73,7 +74,7 @@ class CommunalLoggerStartableTest : SysuiTestCase() { testScope.runTest { // Transition state is default (non-communal) val transitionState = - MutableStateFlow<ObservableCommunalTransitionState>(idle(CommunalSceneKey.DEFAULT)) + MutableStateFlow<ObservableTransitionState>(idle(CommunalScenes.Default)) communalInteractor.setTransitionState(transitionState) runCurrent() @@ -81,14 +82,14 @@ class CommunalLoggerStartableTest : SysuiTestCase() { verify(uiEventLogger, never()).log(any()) // Start transition to communal - transitionState.value = transition(to = CommunalSceneKey.Communal) + transitionState.value = transition(to = CommunalScenes.Communal) runCurrent() // Verify UiEvent logged verify(uiEventLogger).log(CommunalUiEvent.COMMUNAL_HUB_SWIPE_TO_ENTER_START) // Finish transition to communal - transitionState.value = idle(CommunalSceneKey.Communal) + transitionState.value = idle(CommunalScenes.Communal) runCurrent() // Verify UiEvent logged @@ -101,7 +102,7 @@ class CommunalLoggerStartableTest : SysuiTestCase() { testScope.runTest { // Transition state is default (non-communal) val transitionState = - MutableStateFlow<ObservableCommunalTransitionState>(idle(CommunalSceneKey.DEFAULT)) + MutableStateFlow<ObservableTransitionState>(idle(CommunalScenes.Default)) communalInteractor.setTransitionState(transitionState) runCurrent() @@ -109,14 +110,14 @@ class CommunalLoggerStartableTest : SysuiTestCase() { verify(uiEventLogger, never()).log(any()) // Start transition to communal - transitionState.value = transition(to = CommunalSceneKey.Communal) + transitionState.value = transition(to = CommunalScenes.Communal) runCurrent() // Verify UiEvent logged verify(uiEventLogger).log(CommunalUiEvent.COMMUNAL_HUB_SWIPE_TO_ENTER_START) // Cancel the transition - transitionState.value = idle(CommunalSceneKey.DEFAULT) + transitionState.value = idle(CommunalScenes.Default) runCurrent() // Verify UiEvent logged @@ -132,7 +133,7 @@ class CommunalLoggerStartableTest : SysuiTestCase() { testScope.runTest { // Transition state is communal val transitionState = - MutableStateFlow<ObservableCommunalTransitionState>(idle(CommunalSceneKey.Communal)) + MutableStateFlow<ObservableTransitionState>(idle(CommunalScenes.Communal)) communalInteractor.setTransitionState(transitionState) runCurrent() @@ -140,14 +141,14 @@ class CommunalLoggerStartableTest : SysuiTestCase() { verify(uiEventLogger).log(CommunalUiEvent.COMMUNAL_HUB_SHOWN) // Start transition from communal - transitionState.value = transition(from = CommunalSceneKey.Communal) + transitionState.value = transition(from = CommunalScenes.Communal) runCurrent() // Verify UiEvent logged verify(uiEventLogger).log(CommunalUiEvent.COMMUNAL_HUB_SWIPE_TO_EXIT_START) // Finish transition to communal - transitionState.value = idle(CommunalSceneKey.DEFAULT) + transitionState.value = idle(CommunalScenes.Default) runCurrent() // Verify UiEvent logged @@ -160,7 +161,7 @@ class CommunalLoggerStartableTest : SysuiTestCase() { testScope.runTest { // Transition state is communal val transitionState = - MutableStateFlow<ObservableCommunalTransitionState>(idle(CommunalSceneKey.Communal)) + MutableStateFlow<ObservableTransitionState>(idle(CommunalScenes.Communal)) communalInteractor.setTransitionState(transitionState) runCurrent() @@ -168,14 +169,14 @@ class CommunalLoggerStartableTest : SysuiTestCase() { clearInvocations(uiEventLogger) // Start transition from communal - transitionState.value = transition(from = CommunalSceneKey.Communal) + transitionState.value = transition(from = CommunalScenes.Communal) runCurrent() // Verify UiEvent logged verify(uiEventLogger).log(CommunalUiEvent.COMMUNAL_HUB_SWIPE_TO_EXIT_START) // Cancel the transition - transitionState.value = idle(CommunalSceneKey.Communal) + transitionState.value = idle(CommunalScenes.Communal) runCurrent() // Verify UiEvent logged @@ -187,10 +188,10 @@ class CommunalLoggerStartableTest : SysuiTestCase() { } private fun transition( - from: CommunalSceneKey = CommunalSceneKey.DEFAULT, - to: CommunalSceneKey = CommunalSceneKey.DEFAULT, - ): ObservableCommunalTransitionState.Transition { - return ObservableCommunalTransitionState.Transition( + from: SceneKey = CommunalScenes.Default, + to: SceneKey = CommunalScenes.Default, + ): ObservableTransitionState.Transition { + return ObservableTransitionState.Transition( fromScene = from, toScene = to, progress = emptyFlow(), @@ -199,7 +200,7 @@ class CommunalLoggerStartableTest : SysuiTestCase() { ) } - private fun idle(sceneKey: CommunalSceneKey): ObservableCommunalTransitionState.Idle { - return ObservableCommunalTransitionState.Idle(sceneKey) + private fun idle(sceneKey: SceneKey): ObservableTransitionState.Idle { + return ObservableTransitionState.Idle(sceneKey) } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/deviceentry/domain/interactor/DeviceEntryInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/deviceentry/domain/interactor/DeviceEntryInteractorTest.kt index 98719dd32e5a..4f44705b7e72 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/deviceentry/domain/interactor/DeviceEntryInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/deviceentry/domain/interactor/DeviceEntryInteractorTest.kt @@ -18,6 +18,7 @@ package com.android.systemui.deviceentry.domain.interactor import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest +import com.android.compose.animation.scene.SceneKey import com.android.systemui.SysuiTestCase import com.android.systemui.authentication.data.repository.FakeAuthenticationRepository import com.android.systemui.authentication.data.repository.fakeAuthenticationRepository @@ -31,7 +32,7 @@ import com.android.systemui.keyguard.data.repository.fakeTrustRepository import com.android.systemui.kosmos.testScope import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.flag.fakeSceneContainerFlags -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -120,7 +121,7 @@ class DeviceEntryInteractorTest : SysuiTestCase() { testScope.runTest { val isDeviceEntered by collectLastValue(underTest.isDeviceEntered) setupSwipeDeviceEntryMethod() - switchToScene(SceneKey.Lockscreen) + switchToScene(Scenes.Lockscreen) assertThat(isDeviceEntered).isFalse() } @@ -130,9 +131,9 @@ class DeviceEntryInteractorTest : SysuiTestCase() { testScope.runTest { val isDeviceEntered by collectLastValue(underTest.isDeviceEntered) setupSwipeDeviceEntryMethod() - switchToScene(SceneKey.Lockscreen) + switchToScene(Scenes.Lockscreen) runCurrent() - switchToScene(SceneKey.Shade) + switchToScene(Scenes.Shade) assertThat(isDeviceEntered).isFalse() } @@ -142,9 +143,9 @@ class DeviceEntryInteractorTest : SysuiTestCase() { testScope.runTest { val isDeviceEntered by collectLastValue(underTest.isDeviceEntered) setupSwipeDeviceEntryMethod() - switchToScene(SceneKey.Lockscreen) + switchToScene(Scenes.Lockscreen) runCurrent() - switchToScene(SceneKey.Gone) + switchToScene(Scenes.Gone) assertThat(isDeviceEntered).isTrue() } @@ -154,11 +155,11 @@ class DeviceEntryInteractorTest : SysuiTestCase() { testScope.runTest { val isDeviceEntered by collectLastValue(underTest.isDeviceEntered) setupSwipeDeviceEntryMethod() - switchToScene(SceneKey.Lockscreen) + switchToScene(Scenes.Lockscreen) runCurrent() - switchToScene(SceneKey.Gone) + switchToScene(Scenes.Gone) runCurrent() - switchToScene(SceneKey.Shade) + switchToScene(Scenes.Shade) assertThat(isDeviceEntered).isTrue() } @@ -170,9 +171,9 @@ class DeviceEntryInteractorTest : SysuiTestCase() { AuthenticationMethodModel.Pattern ) kosmos.fakeDeviceEntryRepository.setLockscreenEnabled(true) - switchToScene(SceneKey.Lockscreen) + switchToScene(Scenes.Lockscreen) runCurrent() - switchToScene(SceneKey.Bouncer) + switchToScene(Scenes.Bouncer) val isDeviceEntered by collectLastValue(underTest.isDeviceEntered) assertThat(isDeviceEntered).isFalse() @@ -182,7 +183,7 @@ class DeviceEntryInteractorTest : SysuiTestCase() { fun canSwipeToEnter_onLockscreenWithSwipe_isTrue() = testScope.runTest { setupSwipeDeviceEntryMethod() - switchToScene(SceneKey.Lockscreen) + switchToScene(Scenes.Lockscreen) val canSwipeToEnter by collectLastValue(underTest.canSwipeToEnter) assertThat(canSwipeToEnter).isTrue() @@ -195,7 +196,7 @@ class DeviceEntryInteractorTest : SysuiTestCase() { AuthenticationMethodModel.Pin ) kosmos.fakeDeviceEntryRepository.setLockscreenEnabled(true) - switchToScene(SceneKey.Lockscreen) + switchToScene(Scenes.Lockscreen) val canSwipeToEnter by collectLastValue(underTest.canSwipeToEnter) assertThat(canSwipeToEnter).isFalse() @@ -205,9 +206,9 @@ class DeviceEntryInteractorTest : SysuiTestCase() { fun canSwipeToEnter_afterLockscreenDismissedInSwipeMode_isFalse() = testScope.runTest { setupSwipeDeviceEntryMethod() - switchToScene(SceneKey.Lockscreen) + switchToScene(Scenes.Lockscreen) runCurrent() - switchToScene(SceneKey.Gone) + switchToScene(Scenes.Gone) val canSwipeToEnter by collectLastValue(underTest.canSwipeToEnter) assertThat(canSwipeToEnter).isFalse() @@ -225,7 +226,7 @@ class DeviceEntryInteractorTest : SysuiTestCase() { kosmos.fakeAuthenticationRepository.setAuthenticationMethod( AuthenticationMethodModel.Password ) - switchToScene(SceneKey.Lockscreen) + switchToScene(Scenes.Lockscreen) assertThat(canSwipeToEnter).isFalse() trustRepository.setCurrentUserTrusted(true) @@ -242,7 +243,7 @@ class DeviceEntryInteractorTest : SysuiTestCase() { kosmos.fakeAuthenticationRepository.setAuthenticationMethod( AuthenticationMethodModel.Password ) - switchToScene(SceneKey.Lockscreen) + switchToScene(Scenes.Lockscreen) assertThat(canSwipeToEnter).isFalse() faceAuthRepository.isAuthenticated.value = true @@ -311,8 +312,8 @@ class DeviceEntryInteractorTest : SysuiTestCase() { fun showOrUnlockDevice_notLocked_switchesToGoneScene() = testScope.runTest { val currentScene by collectLastValue(sceneInteractor.currentScene) - switchToScene(SceneKey.Lockscreen) - assertThat(currentScene).isEqualTo(SceneKey.Lockscreen) + switchToScene(Scenes.Lockscreen) + assertThat(currentScene).isEqualTo(Scenes.Lockscreen) kosmos.fakeAuthenticationRepository.setAuthenticationMethod( AuthenticationMethodModel.Pin @@ -322,15 +323,15 @@ class DeviceEntryInteractorTest : SysuiTestCase() { underTest.attemptDeviceEntry() - assertThat(currentScene).isEqualTo(SceneKey.Gone) + assertThat(currentScene).isEqualTo(Scenes.Gone) } @Test fun showOrUnlockDevice_authMethodNotSecure_switchesToGoneScene() = testScope.runTest { val currentScene by collectLastValue(sceneInteractor.currentScene) - switchToScene(SceneKey.Lockscreen) - assertThat(currentScene).isEqualTo(SceneKey.Lockscreen) + switchToScene(Scenes.Lockscreen) + assertThat(currentScene).isEqualTo(Scenes.Lockscreen) kosmos.fakeAuthenticationRepository.setAuthenticationMethod( AuthenticationMethodModel.None @@ -339,15 +340,15 @@ class DeviceEntryInteractorTest : SysuiTestCase() { underTest.attemptDeviceEntry() - assertThat(currentScene).isEqualTo(SceneKey.Gone) + assertThat(currentScene).isEqualTo(Scenes.Gone) } @Test fun showOrUnlockDevice_authMethodSwipe_switchesToGoneScene() = testScope.runTest { val currentScene by collectLastValue(sceneInteractor.currentScene) - switchToScene(SceneKey.Lockscreen) - assertThat(currentScene).isEqualTo(SceneKey.Lockscreen) + switchToScene(Scenes.Lockscreen) + assertThat(currentScene).isEqualTo(Scenes.Lockscreen) kosmos.fakeDeviceEntryRepository.setLockscreenEnabled(true) kosmos.fakeAuthenticationRepository.setAuthenticationMethod( @@ -357,7 +358,7 @@ class DeviceEntryInteractorTest : SysuiTestCase() { underTest.attemptDeviceEntry() - assertThat(currentScene).isEqualTo(SceneKey.Gone) + assertThat(currentScene).isEqualTo(Scenes.Gone) } @Test diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorTest.kt index ef2b6f0805d6..f9ec3d161bb0 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorTest.kt @@ -20,6 +20,7 @@ package com.android.systemui.keyguard.domain.interactor import android.app.StatusBarManager import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest +import com.android.compose.animation.scene.ObservableTransitionState import com.android.systemui.SysuiTestCase import com.android.systemui.bouncer.data.repository.FakeKeyguardBouncerRepository import com.android.systemui.common.ui.data.repository.FakeConfigurationRepository @@ -35,8 +36,7 @@ import com.android.systemui.kosmos.testScope import com.android.systemui.power.domain.interactor.PowerInteractorFactory import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.flag.fakeSceneContainerFlags -import com.android.systemui.scene.shared.model.ObservableTransitionState -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.shade.data.repository.FakeShadeRepository import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat @@ -64,7 +64,7 @@ class KeyguardInteractorTest : SysuiTestCase() { private val shadeRepository = FakeShadeRepository() private val keyguardTransitionRepository = kosmos.fakeKeyguardTransitionRepository private val transitionState: MutableStateFlow<ObservableTransitionState> = - MutableStateFlow(ObservableTransitionState.Idle(SceneKey.Gone)) + MutableStateFlow(ObservableTransitionState.Idle(Scenes.Gone)) private val underTest by lazy { KeyguardInteractor( @@ -250,8 +250,8 @@ class KeyguardInteractorTest : SysuiTestCase() { underTest.setAnimateDozingTransitions(true) transitionState.value = ObservableTransitionState.Transition( - fromScene = SceneKey.Gone, - toScene = SceneKey.Lockscreen, + fromScene = Scenes.Gone, + toScene = Scenes.Lockscreen, progress = flowOf(0f), isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelTest.kt index 8e15b5d5657f..979d50463a04 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelTest.kt @@ -22,12 +22,12 @@ package com.android.systemui.keyguard.ui.viewmodel import android.view.View import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest +import com.android.compose.animation.scene.ObservableTransitionState import com.android.systemui.Flags as AConfigFlags import com.android.systemui.Flags.FLAG_NEW_AOD_TRANSITION import com.android.systemui.SysuiTestCase import com.android.systemui.communal.data.repository.communalRepository -import com.android.systemui.communal.shared.model.CommunalSceneKey -import com.android.systemui.communal.shared.model.ObservableCommunalTransitionState +import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.coroutines.collectLastValue import com.android.systemui.deviceentry.data.repository.fakeDeviceEntryRepository import com.android.systemui.flags.Flags @@ -262,7 +262,7 @@ class KeyguardRootViewModelTest : SysuiTestCase() { // Hub transition state is idle with hub open. communalRepository.setTransitionState( - flowOf(ObservableCommunalTransitionState.Idle(CommunalSceneKey.Communal)) + flowOf(ObservableTransitionState.Idle(CommunalScenes.Communal)) ) runCurrent() diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModelTest.kt index 3104842a9c2a..9ff76be30f79 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModelTest.kt @@ -32,7 +32,7 @@ import com.android.systemui.deviceentry.data.repository.fakeDeviceEntryRepositor import com.android.systemui.deviceentry.domain.interactor.deviceEntryInteractor import com.android.systemui.kosmos.testScope import com.android.systemui.scene.domain.interactor.sceneInteractor -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.statusbar.notification.stack.ui.viewmodel.notificationsPlaceholderViewModel import com.android.systemui.testKosmos import com.android.systemui.util.mockito.mock @@ -62,9 +62,9 @@ class LockscreenSceneViewModelTest : SysuiTestCase() { ) kosmos.fakeDeviceEntryRepository.setLockscreenEnabled(true) kosmos.fakeDeviceEntryRepository.setUnlocked(true) - sceneInteractor.changeScene(SceneKey.Lockscreen, "reason") + sceneInteractor.changeScene(Scenes.Lockscreen, "reason") - assertThat(upTransitionSceneKey).isEqualTo(SceneKey.Gone) + assertThat(upTransitionSceneKey).isEqualTo(Scenes.Gone) } @Test @@ -75,9 +75,9 @@ class LockscreenSceneViewModelTest : SysuiTestCase() { AuthenticationMethodModel.Pin ) kosmos.fakeDeviceEntryRepository.setUnlocked(false) - sceneInteractor.changeScene(SceneKey.Lockscreen, "reason") + sceneInteractor.changeScene(Scenes.Lockscreen, "reason") - assertThat(upTransitionSceneKey).isEqualTo(SceneKey.Bouncer) + assertThat(upTransitionSceneKey).isEqualTo(Scenes.Bouncer) } @EnableFlags(FLAG_COMMUNAL_HUB) @@ -89,7 +89,7 @@ class LockscreenSceneViewModelTest : SysuiTestCase() { kosmos.setCommunalAvailable(true) runCurrent() - assertThat(leftDestinationSceneKey).isEqualTo(SceneKey.Communal) + assertThat(leftDestinationSceneKey).isEqualTo(Scenes.Communal) } private fun createLockscreenSceneViewModel(): LockscreenSceneViewModel { diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsSceneViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsSceneViewModelTest.kt index 1eb9adb8c004..6db5a2cd5212 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsSceneViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsSceneViewModelTest.kt @@ -18,6 +18,7 @@ package com.android.systemui.qs.ui.viewmodel import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest +import com.android.compose.animation.scene.UserActionResult import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.FakeFeatureFlagsClassic @@ -27,9 +28,8 @@ import com.android.systemui.qs.FooterActionsController import com.android.systemui.qs.footer.ui.viewmodel.FooterActionsViewModel import com.android.systemui.qs.ui.adapter.FakeQSSceneAdapter import com.android.systemui.scene.shared.model.Direction -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.UserAction -import com.android.systemui.scene.shared.model.UserActionResult import com.android.systemui.shade.domain.interactor.privacyChipInteractor import com.android.systemui.shade.domain.interactor.shadeHeaderClockInteractor import com.android.systemui.shade.ui.viewmodel.ShadeHeaderViewModel @@ -121,8 +121,8 @@ class QuickSettingsSceneViewModelTest : SysuiTestCase() { assertThat(destinations) .isEqualTo( mapOf( - UserAction.Back to UserActionResult(SceneKey.Shade), - UserAction.Swipe(Direction.UP) to UserActionResult(SceneKey.Shade), + UserAction.Back to UserActionResult(Scenes.Shade), + UserAction.Swipe(Direction.UP) to UserActionResult(Scenes.Shade), ) ) } @@ -136,7 +136,7 @@ class QuickSettingsSceneViewModelTest : SysuiTestCase() { assertThat(destinations) .isEqualTo( mapOf( - UserAction.Back to UserActionResult(SceneKey.QuickSettings), + UserAction.Back to UserActionResult(Scenes.QuickSettings), ) ) } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/SceneFrameworkIntegrationTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/SceneFrameworkIntegrationTest.kt index 667f516317be..a2c4f4e63c19 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/SceneFrameworkIntegrationTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/SceneFrameworkIntegrationTest.kt @@ -22,6 +22,8 @@ import android.telecom.TelecomManager import android.telephony.TelephonyManager import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest +import com.android.compose.animation.scene.ObservableTransitionState +import com.android.compose.animation.scene.SceneKey import com.android.internal.R import com.android.internal.util.EmergencyAffordanceManager import com.android.internal.util.emergencyAffordanceManager @@ -61,8 +63,7 @@ import com.android.systemui.qs.ui.adapter.FakeQSSceneAdapter import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.domain.startable.SceneContainerStartable import com.android.systemui.scene.shared.flag.fakeSceneContainerFlags -import com.android.systemui.scene.shared.model.ObservableTransitionState -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.fakeSceneDataSource import com.android.systemui.scene.ui.viewmodel.SceneContainerViewModel import com.android.systemui.settings.FakeDisplayTracker @@ -287,19 +288,19 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { } @Test - fun startsInLockscreenScene() = testScope.runTest { assertCurrentScene(SceneKey.Lockscreen) } + fun startsInLockscreenScene() = testScope.runTest { assertCurrentScene(Scenes.Lockscreen) } @Test fun clickLockButtonAndEnterCorrectPin_unlocksDevice() = testScope.runTest { - emulateUserDrivenTransition(SceneKey.Bouncer) + emulateUserDrivenTransition(Scenes.Bouncer) fakeSceneDataSource.pause() enterPin() emulatePendingTransitionProgress( expectedVisible = false, ) - assertCurrentScene(SceneKey.Gone) + assertCurrentScene(Scenes.Gone) } @Test @@ -307,7 +308,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { testScope.runTest { val upDestinationSceneKey by collectLastValue(lockscreenSceneViewModel.upDestinationSceneKey) - assertThat(upDestinationSceneKey).isEqualTo(SceneKey.Bouncer) + assertThat(upDestinationSceneKey).isEqualTo(Scenes.Bouncer) emulateUserDrivenTransition( to = upDestinationSceneKey, ) @@ -317,7 +318,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { emulatePendingTransitionProgress( expectedVisible = false, ) - assertCurrentScene(SceneKey.Gone) + assertCurrentScene(Scenes.Gone) } @Test @@ -327,7 +328,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { val upDestinationSceneKey by collectLastValue(lockscreenSceneViewModel.upDestinationSceneKey) - assertThat(upDestinationSceneKey).isEqualTo(SceneKey.Gone) + assertThat(upDestinationSceneKey).isEqualTo(Scenes.Gone) emulateUserDrivenTransition( to = upDestinationSceneKey, ) @@ -338,13 +339,13 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { testScope.runTest { val upDestinationSceneKey by collectLastValue(shadeSceneViewModel.upDestinationSceneKey) setAuthMethod(AuthenticationMethodModel.None, enableLockscreen = true) - assertCurrentScene(SceneKey.Lockscreen) + assertCurrentScene(Scenes.Lockscreen) // Emulate a user swipe to the shade scene. - emulateUserDrivenTransition(to = SceneKey.Shade) - assertCurrentScene(SceneKey.Shade) + emulateUserDrivenTransition(to = Scenes.Shade) + assertCurrentScene(Scenes.Shade) - assertThat(upDestinationSceneKey).isEqualTo(SceneKey.Lockscreen) + assertThat(upDestinationSceneKey).isEqualTo(Scenes.Lockscreen) emulateUserDrivenTransition( to = upDestinationSceneKey, ) @@ -356,17 +357,17 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { val upDestinationSceneKey by collectLastValue(shadeSceneViewModel.upDestinationSceneKey) setAuthMethod(AuthenticationMethodModel.None, enableLockscreen = true) assertThat(deviceEntryInteractor.canSwipeToEnter.value).isTrue() - assertCurrentScene(SceneKey.Lockscreen) + assertCurrentScene(Scenes.Lockscreen) // Emulate a user swipe to dismiss the lockscreen. - emulateUserDrivenTransition(to = SceneKey.Gone) - assertCurrentScene(SceneKey.Gone) + emulateUserDrivenTransition(to = Scenes.Gone) + assertCurrentScene(Scenes.Gone) // Emulate a user swipe to the shade scene. - emulateUserDrivenTransition(to = SceneKey.Shade) - assertCurrentScene(SceneKey.Shade) + emulateUserDrivenTransition(to = Scenes.Shade) + assertCurrentScene(Scenes.Shade) - assertThat(upDestinationSceneKey).isEqualTo(SceneKey.Gone) + assertThat(upDestinationSceneKey).isEqualTo(Scenes.Gone) emulateUserDrivenTransition( to = upDestinationSceneKey, ) @@ -377,10 +378,10 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { testScope.runTest { setAuthMethod(AuthenticationMethodModel.None, enableLockscreen = false) putDeviceToSleep(instantlyLockDevice = false) - assertCurrentScene(SceneKey.Lockscreen) + assertCurrentScene(Scenes.Lockscreen) wakeUpDevice() - assertCurrentScene(SceneKey.Gone) + assertCurrentScene(Scenes.Gone) } @Test @@ -388,45 +389,45 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { testScope.runTest { setAuthMethod(AuthenticationMethodModel.None, enableLockscreen = true) putDeviceToSleep(instantlyLockDevice = false) - assertCurrentScene(SceneKey.Lockscreen) + assertCurrentScene(Scenes.Lockscreen) wakeUpDevice() - assertCurrentScene(SceneKey.Lockscreen) + assertCurrentScene(Scenes.Lockscreen) } @Test fun deviceGoesToSleep_switchesToLockscreen() = testScope.runTest { unlockDevice() - assertCurrentScene(SceneKey.Gone) + assertCurrentScene(Scenes.Gone) putDeviceToSleep() - assertCurrentScene(SceneKey.Lockscreen) + assertCurrentScene(Scenes.Lockscreen) } @Test fun deviceGoesToSleep_wakeUp_unlock() = testScope.runTest { unlockDevice() - assertCurrentScene(SceneKey.Gone) + assertCurrentScene(Scenes.Gone) putDeviceToSleep() - assertCurrentScene(SceneKey.Lockscreen) + assertCurrentScene(Scenes.Lockscreen) wakeUpDevice() - assertCurrentScene(SceneKey.Lockscreen) + assertCurrentScene(Scenes.Lockscreen) unlockDevice() - assertCurrentScene(SceneKey.Gone) + assertCurrentScene(Scenes.Gone) } @Test fun deviceWakesUpWhileUnlocked_dismissesLockscreen() = testScope.runTest { unlockDevice() - assertCurrentScene(SceneKey.Gone) + assertCurrentScene(Scenes.Gone) putDeviceToSleep(instantlyLockDevice = false) - assertCurrentScene(SceneKey.Lockscreen) + assertCurrentScene(Scenes.Lockscreen) wakeUpDevice() - assertCurrentScene(SceneKey.Gone) + assertCurrentScene(Scenes.Gone) } @Test @@ -435,20 +436,20 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { unlockDevice() val upDestinationSceneKey by collectLastValue(lockscreenSceneViewModel.upDestinationSceneKey) - assertThat(upDestinationSceneKey).isEqualTo(SceneKey.Gone) + assertThat(upDestinationSceneKey).isEqualTo(Scenes.Gone) } @Test fun deviceGoesToSleep_withLockTimeout_staysOnLockscreen() = testScope.runTest { unlockDevice() - assertCurrentScene(SceneKey.Gone) + assertCurrentScene(Scenes.Gone) putDeviceToSleep(instantlyLockDevice = false) - assertCurrentScene(SceneKey.Lockscreen) + assertCurrentScene(Scenes.Lockscreen) // Pretend like the timeout elapsed and now lock the device. lockDevice() - assertCurrentScene(SceneKey.Lockscreen) + assertCurrentScene(Scenes.Lockscreen) } @Test @@ -457,7 +458,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { setAuthMethod(AuthenticationMethodModel.Password) val upDestinationSceneKey by collectLastValue(lockscreenSceneViewModel.upDestinationSceneKey) - assertThat(upDestinationSceneKey).isEqualTo(SceneKey.Bouncer) + assertThat(upDestinationSceneKey).isEqualTo(Scenes.Bouncer) emulateUserDrivenTransition( to = upDestinationSceneKey, ) @@ -466,7 +467,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { dismissIme() emulatePendingTransitionProgress() - assertCurrentScene(SceneKey.Lockscreen) + assertCurrentScene(Scenes.Lockscreen) } @Test @@ -475,7 +476,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { setAuthMethod(AuthenticationMethodModel.Password) val upDestinationSceneKey by collectLastValue(lockscreenSceneViewModel.upDestinationSceneKey) - assertThat(upDestinationSceneKey).isEqualTo(SceneKey.Bouncer) + assertThat(upDestinationSceneKey).isEqualTo(Scenes.Bouncer) emulateUserDrivenTransition(to = upDestinationSceneKey) val bouncerActionButton by collectLastValue(bouncerViewModel.actionButton) @@ -495,7 +496,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { startPhoneCall() val upDestinationSceneKey by collectLastValue(lockscreenSceneViewModel.upDestinationSceneKey) - assertThat(upDestinationSceneKey).isEqualTo(SceneKey.Bouncer) + assertThat(upDestinationSceneKey).isEqualTo(Scenes.Bouncer) emulateUserDrivenTransition(to = upDestinationSceneKey) val bouncerActionButton by collectLastValue(bouncerViewModel.actionButton) @@ -513,7 +514,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { testScope.runTest { setAuthMethod(AuthenticationMethodModel.None) introduceLockedSim() - assertCurrentScene(SceneKey.Bouncer) + assertCurrentScene(Scenes.Bouncer) } @Test @@ -523,7 +524,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { introduceLockedSim() emulatePendingTransitionProgress(expectedVisible = true) enterSimPin(authMethodAfterSimUnlock = AuthenticationMethodModel.None) - assertCurrentScene(SceneKey.Gone) + assertCurrentScene(Scenes.Gone) } @Test @@ -533,7 +534,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { introduceLockedSim() emulatePendingTransitionProgress(expectedVisible = true) enterSimPin(authMethodAfterSimUnlock = AuthenticationMethodModel.Pin) - assertCurrentScene(SceneKey.Lockscreen) + assertCurrentScene(Scenes.Lockscreen) } @Test @@ -657,7 +658,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { assertThat(sceneContainerViewModel.currentScene.value).isEqualTo(to) bouncerSceneJob = - if (to == SceneKey.Bouncer) { + if (to == Scenes.Bouncer) { testScope.backgroundScope.launch { bouncerViewModel.authMethodViewModel.collect { // Do nothing. Need this to turn this otherwise cold flow, hot. @@ -688,7 +689,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { sceneInteractor.changeScene(to, "reason") emulatePendingTransitionProgress( - expectedVisible = to != SceneKey.Gone, + expectedVisible = to != Scenes.Gone, ) } @@ -715,7 +716,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { .that(deviceEntryInteractor.isUnlocked.value) .isFalse() - emulateUserDrivenTransition(SceneKey.Bouncer) + emulateUserDrivenTransition(Scenes.Bouncer) fakeSceneDataSource.pause() enterPin() // This repository state is not changed by the AuthInteractor, it relies on @@ -729,7 +730,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { /** * Enters the correct PIN in the bouncer UI. * - * Asserts that the current scene is [SceneKey.Bouncer] and that the current bouncer UI is a PIN + * Asserts that the current scene is [Scenes.Bouncer] and that the current bouncer UI is a PIN * before proceeding. * * Does not assert that the device is locked or unlocked. @@ -737,7 +738,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { private fun TestScope.enterPin() { assertWithMessage("Cannot enter PIN when not on the Bouncer scene!") .that(getCurrentSceneInUi()) - .isEqualTo(SceneKey.Bouncer) + .isEqualTo(Scenes.Bouncer) val authMethodViewModel by collectLastValue(bouncerViewModel.authMethodViewModel) assertWithMessage("Cannot enter PIN when not using a PIN authentication method!") .that(authMethodViewModel) @@ -754,7 +755,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { /** * Enters the correct PIN in the sim bouncer UI. * - * Asserts that the current scene is [SceneKey.Bouncer] and that the current bouncer UI is a PIN + * Asserts that the current scene is [Scenes.Bouncer] and that the current bouncer UI is a PIN * before proceeding. * * Does not assert that the device is locked or unlocked. @@ -764,7 +765,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { ) { assertWithMessage("Cannot enter PIN when not on the Bouncer scene!") .that(getCurrentSceneInUi()) - .isEqualTo(SceneKey.Bouncer) + .isEqualTo(Scenes.Bouncer) val authMethodViewModel by collectLastValue(bouncerViewModel.authMethodViewModel) assertWithMessage("Cannot enter PIN when not using a PIN authentication method!") .that(authMethodViewModel) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/data/repository/SceneContainerRepositoryTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/data/repository/SceneContainerRepositoryTest.kt index 1da3bc1aeda8..3d6619272dbe 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/data/repository/SceneContainerRepositoryTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/data/repository/SceneContainerRepositoryTest.kt @@ -20,14 +20,14 @@ package com.android.systemui.scene.data.repository import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest +import com.android.compose.animation.scene.ObservableTransitionState import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.testScope import com.android.systemui.scene.sceneContainerConfig import com.android.systemui.scene.sceneKeys import com.android.systemui.scene.shared.flag.fakeSceneContainerFlags -import com.android.systemui.scene.shared.model.ObservableTransitionState -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -51,12 +51,12 @@ class SceneContainerRepositoryTest : SysuiTestCase() { assertThat(underTest.allSceneKeys()) .isEqualTo( listOf( - SceneKey.QuickSettings, - SceneKey.Shade, - SceneKey.Lockscreen, - SceneKey.Bouncer, - SceneKey.Gone, - SceneKey.Communal, + Scenes.QuickSettings, + Scenes.Shade, + Scenes.Lockscreen, + Scenes.Bouncer, + Scenes.Gone, + Scenes.Communal, ) ) } @@ -66,17 +66,17 @@ class SceneContainerRepositoryTest : SysuiTestCase() { testScope.runTest { val underTest = kosmos.sceneContainerRepository val currentScene by collectLastValue(underTest.currentScene) - assertThat(currentScene).isEqualTo(SceneKey.Lockscreen) + assertThat(currentScene).isEqualTo(Scenes.Lockscreen) - underTest.changeScene(SceneKey.Shade) - assertThat(currentScene).isEqualTo(SceneKey.Shade) + underTest.changeScene(Scenes.Shade) + assertThat(currentScene).isEqualTo(Scenes.Shade) } @Test(expected = IllegalStateException::class) fun changeScene_noSuchSceneInContainer_throws() { - kosmos.sceneKeys = listOf(SceneKey.QuickSettings, SceneKey.Lockscreen) + kosmos.sceneKeys = listOf(Scenes.QuickSettings, Scenes.Lockscreen) val underTest = kosmos.sceneContainerRepository - underTest.changeScene(SceneKey.Shade) + underTest.changeScene(Scenes.Shade) } @Test @@ -111,7 +111,7 @@ class SceneContainerRepositoryTest : SysuiTestCase() { val underTest = kosmos.sceneContainerRepository val transitionState = MutableStateFlow<ObservableTransitionState>( - ObservableTransitionState.Idle(SceneKey.Lockscreen) + ObservableTransitionState.Idle(Scenes.Lockscreen) ) underTest.setTransitionState(transitionState) val reflectedTransitionState by collectLastValue(underTest.transitionState) @@ -120,8 +120,8 @@ class SceneContainerRepositoryTest : SysuiTestCase() { val progress = MutableStateFlow(1f) transitionState.value = ObservableTransitionState.Transition( - fromScene = SceneKey.Lockscreen, - toScene = SceneKey.Shade, + fromScene = Scenes.Lockscreen, + toScene = Scenes.Shade, progress = progress, isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/interactor/PanelExpansionInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/interactor/PanelExpansionInteractorTest.kt index 9b0adb172e8d..6b5997fc21c4 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/interactor/PanelExpansionInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/interactor/PanelExpansionInteractorTest.kt @@ -21,6 +21,8 @@ package com.android.systemui.scene.domain.interactor import android.platform.test.annotations.DisableFlags import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest +import com.android.compose.animation.scene.ObservableTransitionState +import com.android.compose.animation.scene.SceneKey import com.android.systemui.Flags.FLAG_SCENE_CONTAINER import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue @@ -28,8 +30,7 @@ import com.android.systemui.deviceentry.data.repository.fakeDeviceEntryRepositor import com.android.systemui.deviceentry.domain.interactor.deviceUnlockedInteractor import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.kosmos.testScope -import com.android.systemui.scene.shared.model.ObservableTransitionState -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.fakeSceneDataSource import com.android.systemui.shade.data.repository.fakeShadeRepository import com.android.systemui.statusbar.notification.stack.ui.viewmodel.panelExpansionInteractor @@ -56,7 +57,7 @@ class PanelExpansionInteractorTest : SysuiTestCase() { private val sceneInteractor = kosmos.sceneInteractor private val transitionState = MutableStateFlow<ObservableTransitionState>( - ObservableTransitionState.Idle(SceneKey.Lockscreen) + ObservableTransitionState.Idle(Scenes.Lockscreen) ) private val fakeSceneDataSource = kosmos.fakeSceneDataSource private val fakeShadeRepository = kosmos.fakeShadeRepository @@ -76,19 +77,19 @@ class PanelExpansionInteractorTest : SysuiTestCase() { setUnlocked(false) val panelExpansion by collectLastValue(underTest.legacyPanelExpansion) - changeScene(SceneKey.Lockscreen) { assertThat(panelExpansion).isEqualTo(1f) } + changeScene(Scenes.Lockscreen) { assertThat(panelExpansion).isEqualTo(1f) } assertThat(panelExpansion).isEqualTo(1f) - changeScene(SceneKey.Bouncer) { assertThat(panelExpansion).isEqualTo(1f) } + changeScene(Scenes.Bouncer) { assertThat(panelExpansion).isEqualTo(1f) } assertThat(panelExpansion).isEqualTo(1f) - changeScene(SceneKey.Shade) { assertThat(panelExpansion).isEqualTo(1f) } + changeScene(Scenes.Shade) { assertThat(panelExpansion).isEqualTo(1f) } assertThat(panelExpansion).isEqualTo(1f) - changeScene(SceneKey.QuickSettings) { assertThat(panelExpansion).isEqualTo(1f) } + changeScene(Scenes.QuickSettings) { assertThat(panelExpansion).isEqualTo(1f) } assertThat(panelExpansion).isEqualTo(1f) - changeScene(SceneKey.Communal) { assertThat(panelExpansion).isEqualTo(1f) } + changeScene(Scenes.Communal) { assertThat(panelExpansion).isEqualTo(1f) } assertThat(panelExpansion).isEqualTo(1f) } @@ -100,21 +101,19 @@ class PanelExpansionInteractorTest : SysuiTestCase() { setUnlocked(true) val panelExpansion by collectLastValue(underTest.legacyPanelExpansion) - changeScene(SceneKey.Gone) { assertThat(panelExpansion).isEqualTo(0f) } + changeScene(Scenes.Gone) { assertThat(panelExpansion).isEqualTo(0f) } assertThat(panelExpansion).isEqualTo(0f) - changeScene(SceneKey.Shade) { progress -> - assertThat(panelExpansion).isEqualTo(progress) - } + changeScene(Scenes.Shade) { progress -> assertThat(panelExpansion).isEqualTo(progress) } assertThat(panelExpansion).isEqualTo(1f) - changeScene(SceneKey.QuickSettings) { + changeScene(Scenes.QuickSettings) { // Shade's already expanded, so moving to QS should also be 1f. assertThat(panelExpansion).isEqualTo(1f) } assertThat(panelExpansion).isEqualTo(1f) - changeScene(SceneKey.Communal) { assertThat(panelExpansion).isEqualTo(1f) } + changeScene(Scenes.Communal) { assertThat(panelExpansion).isEqualTo(1f) } assertThat(panelExpansion).isEqualTo(1f) } @@ -128,19 +127,19 @@ class PanelExpansionInteractorTest : SysuiTestCase() { setUnlocked(false) val panelExpansion by collectLastValue(underTest.legacyPanelExpansion) - changeScene(SceneKey.Lockscreen) + changeScene(Scenes.Lockscreen) assertThat(panelExpansion).isEqualTo(leet) - changeScene(SceneKey.Bouncer) + changeScene(Scenes.Bouncer) assertThat(panelExpansion).isEqualTo(leet) - changeScene(SceneKey.Shade) + changeScene(Scenes.Shade) assertThat(panelExpansion).isEqualTo(leet) - changeScene(SceneKey.QuickSettings) + changeScene(Scenes.QuickSettings) assertThat(panelExpansion).isEqualTo(leet) - changeScene(SceneKey.Communal) + changeScene(Scenes.Communal) assertThat(panelExpansion).isEqualTo(leet) } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/interactor/SceneInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/interactor/SceneInteractorTest.kt index db94c39e1cb1..f645f1cc4369 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/interactor/SceneInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/interactor/SceneInteractorTest.kt @@ -20,6 +20,7 @@ package com.android.systemui.scene.domain.interactor import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest +import com.android.compose.animation.scene.ObservableTransitionState import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.deviceentry.data.repository.fakeDeviceEntryRepository @@ -28,8 +29,7 @@ import com.android.systemui.scene.data.repository.sceneContainerRepository import com.android.systemui.scene.sceneContainerConfig import com.android.systemui.scene.sceneKeys import com.android.systemui.scene.shared.flag.fakeSceneContainerFlags -import com.android.systemui.scene.shared.model.ObservableTransitionState -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.fakeSceneDataSource import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat @@ -67,23 +67,23 @@ class SceneInteractorTest : SysuiTestCase() { fun changeScene() = testScope.runTest { val currentScene by collectLastValue(underTest.currentScene) - assertThat(currentScene).isEqualTo(SceneKey.Lockscreen) + assertThat(currentScene).isEqualTo(Scenes.Lockscreen) - underTest.changeScene(SceneKey.Shade, "reason") - assertThat(currentScene).isEqualTo(SceneKey.Shade) + underTest.changeScene(Scenes.Shade, "reason") + assertThat(currentScene).isEqualTo(Scenes.Shade) } @Test fun changeScene_toGoneWhenUnl_doesNotThrow() = testScope.runTest { val currentScene by collectLastValue(underTest.currentScene) - assertThat(currentScene).isEqualTo(SceneKey.Lockscreen) + assertThat(currentScene).isEqualTo(Scenes.Lockscreen) kosmos.fakeDeviceEntryRepository.setUnlocked(true) runCurrent() - underTest.changeScene(SceneKey.Gone, "reason") - assertThat(currentScene).isEqualTo(SceneKey.Gone) + underTest.changeScene(Scenes.Gone, "reason") + assertThat(currentScene).isEqualTo(Scenes.Gone) } @Test(expected = IllegalStateException::class) @@ -91,18 +91,18 @@ class SceneInteractorTest : SysuiTestCase() { testScope.runTest { kosmos.fakeDeviceEntryRepository.setUnlocked(false) - underTest.changeScene(SceneKey.Gone, "reason") + underTest.changeScene(Scenes.Gone, "reason") } @Test fun sceneChanged_inDataSource() = testScope.runTest { val currentScene by collectLastValue(underTest.currentScene) - assertThat(currentScene).isEqualTo(SceneKey.Lockscreen) + assertThat(currentScene).isEqualTo(Scenes.Lockscreen) - fakeSceneDataSource.changeScene(SceneKey.Shade) + fakeSceneDataSource.changeScene(Scenes.Shade) - assertThat(currentScene).isEqualTo(SceneKey.Shade) + assertThat(currentScene).isEqualTo(Scenes.Shade) } @Test @@ -111,7 +111,7 @@ class SceneInteractorTest : SysuiTestCase() { val underTest = kosmos.sceneContainerRepository val transitionState = MutableStateFlow<ObservableTransitionState>( - ObservableTransitionState.Idle(SceneKey.Lockscreen) + ObservableTransitionState.Idle(Scenes.Lockscreen) ) underTest.setTransitionState(transitionState) val reflectedTransitionState by collectLastValue(underTest.transitionState) @@ -120,8 +120,8 @@ class SceneInteractorTest : SysuiTestCase() { val progress = MutableStateFlow(1f) transitionState.value = ObservableTransitionState.Transition( - fromScene = SceneKey.Lockscreen, - toScene = SceneKey.Shade, + fromScene = Scenes.Lockscreen, + toScene = Scenes.Shade, progress = progress, isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), @@ -153,27 +153,27 @@ class SceneInteractorTest : SysuiTestCase() { val transitionTo by collectLastValue(underTest.transitioningTo) assertThat(transitionTo).isNull() - underTest.changeScene(SceneKey.Shade, "reason") + underTest.changeScene(Scenes.Shade, "reason") assertThat(transitionTo).isNull() val progress = MutableStateFlow(0f) transitionState.value = ObservableTransitionState.Transition( fromScene = underTest.currentScene.value, - toScene = SceneKey.Shade, + toScene = Scenes.Shade, progress = progress, isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), ) - assertThat(transitionTo).isEqualTo(SceneKey.Shade) + assertThat(transitionTo).isEqualTo(Scenes.Shade) progress.value = 0.5f - assertThat(transitionTo).isEqualTo(SceneKey.Shade) + assertThat(transitionTo).isEqualTo(Scenes.Shade) progress.value = 1f - assertThat(transitionTo).isEqualTo(SceneKey.Shade) + assertThat(transitionTo).isEqualTo(Scenes.Shade) - transitionState.value = ObservableTransitionState.Idle(SceneKey.Shade) + transitionState.value = ObservableTransitionState.Idle(Scenes.Shade) assertThat(transitionTo).isNull() } @@ -182,7 +182,7 @@ class SceneInteractorTest : SysuiTestCase() { testScope.runTest { val transitionState = MutableStateFlow<ObservableTransitionState>( - ObservableTransitionState.Idle(SceneKey.Shade) + ObservableTransitionState.Idle(Scenes.Shade) ) val isTransitionUserInputOngoing by collectLastValue(underTest.isTransitionUserInputOngoing) @@ -197,8 +197,8 @@ class SceneInteractorTest : SysuiTestCase() { val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Transition( - fromScene = SceneKey.Shade, - toScene = SceneKey.Lockscreen, + fromScene = Scenes.Shade, + toScene = Scenes.Lockscreen, progress = flowOf(0.5f), isInitiatedByUserInput = true, isUserInputOngoing = flowOf(true), @@ -217,8 +217,8 @@ class SceneInteractorTest : SysuiTestCase() { val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Transition( - fromScene = SceneKey.Shade, - toScene = SceneKey.Lockscreen, + fromScene = Scenes.Shade, + toScene = Scenes.Lockscreen, progress = flowOf(0.5f), isInitiatedByUserInput = true, isUserInputOngoing = flowOf(true), @@ -232,8 +232,8 @@ class SceneInteractorTest : SysuiTestCase() { transitionState.value = ObservableTransitionState.Transition( - fromScene = SceneKey.Shade, - toScene = SceneKey.Lockscreen, + fromScene = Scenes.Shade, + toScene = Scenes.Lockscreen, progress = flowOf(0.6f), isInitiatedByUserInput = true, isUserInputOngoing = flowOf(false), @@ -248,8 +248,8 @@ class SceneInteractorTest : SysuiTestCase() { val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Transition( - fromScene = SceneKey.Shade, - toScene = SceneKey.Lockscreen, + fromScene = Scenes.Shade, + toScene = Scenes.Lockscreen, progress = flowOf(0.5f), isInitiatedByUserInput = true, isUserInputOngoing = flowOf(true), @@ -261,7 +261,7 @@ class SceneInteractorTest : SysuiTestCase() { assertThat(isTransitionUserInputOngoing).isTrue() - transitionState.value = ObservableTransitionState.Idle(scene = SceneKey.Lockscreen) + transitionState.value = ObservableTransitionState.Idle(scene = Scenes.Lockscreen) assertThat(isTransitionUserInputOngoing).isFalse() } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/startable/SceneContainerStartableTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/startable/SceneContainerStartableTest.kt index 4e1623661a58..cc66f8b2f387 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/startable/SceneContainerStartableTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/startable/SceneContainerStartableTest.kt @@ -24,6 +24,8 @@ import android.platform.test.annotations.EnableFlags import android.view.Display import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest +import com.android.compose.animation.scene.ObservableTransitionState +import com.android.compose.animation.scene.SceneKey import com.android.systemui.Flags as AconfigFlags import com.android.systemui.SysuiTestCase import com.android.systemui.authentication.data.repository.fakeAuthenticationRepository @@ -46,8 +48,7 @@ import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.se import com.android.systemui.power.domain.interactor.PowerInteractorFactory import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.flag.fakeSceneContainerFlags -import com.android.systemui.scene.shared.model.ObservableTransitionState -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.fakeSceneDataSource import com.android.systemui.statusbar.NotificationShadeWindowController import com.android.systemui.statusbar.notification.stack.data.repository.headsUpNotificationRepository @@ -136,42 +137,42 @@ class SceneContainerStartableTest : SysuiTestCase() { val transitionStateFlow = prepareState( isDeviceUnlocked = true, - initialSceneKey = SceneKey.Gone, + initialSceneKey = Scenes.Gone, ) - assertThat(currentDesiredSceneKey).isEqualTo(SceneKey.Gone) + assertThat(currentDesiredSceneKey).isEqualTo(Scenes.Gone) assertThat(isVisible).isTrue() underTest.start() assertThat(isVisible).isFalse() fakeSceneDataSource.pause() - sceneInteractor.changeScene(SceneKey.Shade, "reason") + sceneInteractor.changeScene(Scenes.Shade, "reason") transitionStateFlow.value = ObservableTransitionState.Transition( - fromScene = SceneKey.Gone, - toScene = SceneKey.Shade, + fromScene = Scenes.Gone, + toScene = Scenes.Shade, progress = flowOf(0.5f), isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), ) assertThat(isVisible).isTrue() - fakeSceneDataSource.unpause(expectedScene = SceneKey.Shade) - transitionStateFlow.value = ObservableTransitionState.Idle(SceneKey.Shade) + fakeSceneDataSource.unpause(expectedScene = Scenes.Shade) + transitionStateFlow.value = ObservableTransitionState.Idle(Scenes.Shade) assertThat(isVisible).isTrue() fakeSceneDataSource.pause() - sceneInteractor.changeScene(SceneKey.Gone, "reason") + sceneInteractor.changeScene(Scenes.Gone, "reason") transitionStateFlow.value = ObservableTransitionState.Transition( - fromScene = SceneKey.Shade, - toScene = SceneKey.Gone, + fromScene = Scenes.Shade, + toScene = Scenes.Gone, progress = flowOf(0.5f), isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), ) assertThat(isVisible).isTrue() - fakeSceneDataSource.unpause(expectedScene = SceneKey.Gone) - transitionStateFlow.value = ObservableTransitionState.Idle(SceneKey.Gone) + fakeSceneDataSource.unpause(expectedScene = Scenes.Gone) + transitionStateFlow.value = ObservableTransitionState.Idle(Scenes.Gone) assertThat(isVisible).isFalse() kosmos.headsUpNotificationRepository.hasPinnedHeadsUp.value = true @@ -187,7 +188,7 @@ class SceneContainerStartableTest : SysuiTestCase() { val isVisible by collectLastValue(sceneInteractor.isVisible) prepareState( isDeviceUnlocked = true, - initialSceneKey = SceneKey.Lockscreen, + initialSceneKey = Scenes.Lockscreen, isDeviceProvisioned = false, isFrpActive = true, ) @@ -214,7 +215,7 @@ class SceneContainerStartableTest : SysuiTestCase() { underTest.start() runCurrent() - assertThat(currentSceneKey).isEqualTo(SceneKey.Lockscreen) + assertThat(currentSceneKey).isEqualTo(Scenes.Lockscreen) } @Test @@ -223,14 +224,14 @@ class SceneContainerStartableTest : SysuiTestCase() { val currentSceneKey by collectLastValue(sceneInteractor.currentScene) prepareState( isDeviceUnlocked = true, - initialSceneKey = SceneKey.Gone, + initialSceneKey = Scenes.Gone, ) - assertThat(currentSceneKey).isEqualTo(SceneKey.Gone) + assertThat(currentSceneKey).isEqualTo(Scenes.Gone) underTest.start() kosmos.fakeDeviceEntryRepository.setUnlocked(false) - assertThat(currentSceneKey).isEqualTo(SceneKey.Lockscreen) + assertThat(currentSceneKey).isEqualTo(Scenes.Lockscreen) } @Test @@ -239,14 +240,14 @@ class SceneContainerStartableTest : SysuiTestCase() { val currentSceneKey by collectLastValue(sceneInteractor.currentScene) prepareState( isDeviceUnlocked = false, - initialSceneKey = SceneKey.Bouncer, + initialSceneKey = Scenes.Bouncer, ) - assertThat(currentSceneKey).isEqualTo(SceneKey.Bouncer) + assertThat(currentSceneKey).isEqualTo(Scenes.Bouncer) underTest.start() kosmos.fakeDeviceEntryRepository.setUnlocked(true) - assertThat(currentSceneKey).isEqualTo(SceneKey.Gone) + assertThat(currentSceneKey).isEqualTo(Scenes.Gone) } @Test @@ -255,14 +256,14 @@ class SceneContainerStartableTest : SysuiTestCase() { val currentSceneKey by collectLastValue(sceneInteractor.currentScene) prepareState( isBypassEnabled = true, - initialSceneKey = SceneKey.Lockscreen, + initialSceneKey = Scenes.Lockscreen, ) - assertThat(currentSceneKey).isEqualTo(SceneKey.Lockscreen) + assertThat(currentSceneKey).isEqualTo(Scenes.Lockscreen) underTest.start() kosmos.fakeDeviceEntryRepository.setUnlocked(true) - assertThat(currentSceneKey).isEqualTo(SceneKey.Gone) + assertThat(currentSceneKey).isEqualTo(Scenes.Gone) } @Test @@ -271,16 +272,16 @@ class SceneContainerStartableTest : SysuiTestCase() { val currentSceneKey by collectLastValue(sceneInteractor.currentScene) prepareState( isBypassEnabled = false, - initialSceneKey = SceneKey.Lockscreen, + initialSceneKey = Scenes.Lockscreen, ) - assertThat(currentSceneKey).isEqualTo(SceneKey.Lockscreen) + assertThat(currentSceneKey).isEqualTo(Scenes.Lockscreen) underTest.start() // Authenticate using a passive auth method like face auth while bypass is disabled. faceAuthRepository.isAuthenticated.value = true kosmos.fakeDeviceEntryRepository.setUnlocked(true) - assertThat(currentSceneKey).isEqualTo(SceneKey.Lockscreen) + assertThat(currentSceneKey).isEqualTo(Scenes.Lockscreen) } @Test @@ -291,19 +292,19 @@ class SceneContainerStartableTest : SysuiTestCase() { prepareState( isBypassEnabled = true, authenticationMethod = AuthenticationMethodModel.Pin, - initialSceneKey = SceneKey.Lockscreen, + initialSceneKey = Scenes.Lockscreen, ) underTest.start() runCurrent() - sceneInteractor.changeScene(SceneKey.Shade, "switch to shade") - transitionStateFlowValue.value = ObservableTransitionState.Idle(SceneKey.Shade) - assertThat(currentSceneKey).isEqualTo(SceneKey.Shade) + sceneInteractor.changeScene(Scenes.Shade, "switch to shade") + transitionStateFlowValue.value = ObservableTransitionState.Idle(Scenes.Shade) + assertThat(currentSceneKey).isEqualTo(Scenes.Shade) kosmos.fakeDeviceEntryRepository.setUnlocked(true) runCurrent() - assertThat(currentSceneKey).isEqualTo(SceneKey.Shade) + assertThat(currentSceneKey).isEqualTo(Scenes.Shade) } @Test @@ -312,16 +313,16 @@ class SceneContainerStartableTest : SysuiTestCase() { val currentSceneKey by collectLastValue(sceneInteractor.currentScene) prepareState( isBypassEnabled = false, - initialSceneKey = SceneKey.Bouncer, + initialSceneKey = Scenes.Bouncer, ) - assertThat(currentSceneKey).isEqualTo(SceneKey.Bouncer) + assertThat(currentSceneKey).isEqualTo(Scenes.Bouncer) underTest.start() // Authenticate using a passive auth method like face auth while bypass is disabled. faceAuthRepository.isAuthenticated.value = true kosmos.fakeDeviceEntryRepository.setUnlocked(true) - assertThat(currentSceneKey).isEqualTo(SceneKey.Gone) + assertThat(currentSceneKey).isEqualTo(Scenes.Gone) } @Test @@ -330,13 +331,13 @@ class SceneContainerStartableTest : SysuiTestCase() { val currentSceneKey by collectLastValue(sceneInteractor.currentScene) prepareState( isDeviceUnlocked = false, - initialSceneKey = SceneKey.Shade, + initialSceneKey = Scenes.Shade, ) - assertThat(currentSceneKey).isEqualTo(SceneKey.Shade) + assertThat(currentSceneKey).isEqualTo(Scenes.Shade) underTest.start() powerInteractor.setAsleepForTest() - assertThat(currentSceneKey).isEqualTo(SceneKey.Lockscreen) + assertThat(currentSceneKey).isEqualTo(Scenes.Lockscreen) } @Test @@ -348,14 +349,14 @@ class SceneContainerStartableTest : SysuiTestCase() { clearInvocations(sysUiState) listOf( - SceneKey.Gone, - SceneKey.Lockscreen, - SceneKey.Bouncer, - SceneKey.Shade, - SceneKey.QuickSettings, + Scenes.Gone, + Scenes.Lockscreen, + Scenes.Bouncer, + Scenes.Shade, + Scenes.QuickSettings, ) .forEachIndexed { index, sceneKey -> - if (sceneKey == SceneKey.Gone) { + if (sceneKey == Scenes.Gone) { kosmos.fakeDeviceEntryRepository.setUnlocked(true) runCurrent() } @@ -379,15 +380,15 @@ class SceneContainerStartableTest : SysuiTestCase() { testScope.runTest { val currentSceneKey by collectLastValue(sceneInteractor.currentScene) prepareState( - initialSceneKey = SceneKey.Lockscreen, + initialSceneKey = Scenes.Lockscreen, authenticationMethod = AuthenticationMethodModel.None, isLockscreenEnabled = false, ) - assertThat(currentSceneKey).isEqualTo(SceneKey.Lockscreen) + assertThat(currentSceneKey).isEqualTo(Scenes.Lockscreen) underTest.start() powerInteractor.setAwakeForTest() - assertThat(currentSceneKey).isEqualTo(SceneKey.Gone) + assertThat(currentSceneKey).isEqualTo(Scenes.Gone) } @Test @@ -395,15 +396,15 @@ class SceneContainerStartableTest : SysuiTestCase() { testScope.runTest { val currentSceneKey by collectLastValue(sceneInteractor.currentScene) prepareState( - initialSceneKey = SceneKey.Lockscreen, + initialSceneKey = Scenes.Lockscreen, authenticationMethod = AuthenticationMethodModel.None, isLockscreenEnabled = true, ) - assertThat(currentSceneKey).isEqualTo(SceneKey.Lockscreen) + assertThat(currentSceneKey).isEqualTo(Scenes.Lockscreen) underTest.start() powerInteractor.setAwakeForTest() - assertThat(currentSceneKey).isEqualTo(SceneKey.Lockscreen) + assertThat(currentSceneKey).isEqualTo(Scenes.Lockscreen) } @Test @@ -411,14 +412,14 @@ class SceneContainerStartableTest : SysuiTestCase() { testScope.runTest { val currentSceneKey by collectLastValue(sceneInteractor.currentScene) prepareState( - initialSceneKey = SceneKey.Lockscreen, + initialSceneKey = Scenes.Lockscreen, authenticationMethod = AuthenticationMethodModel.Pin, ) - assertThat(currentSceneKey).isEqualTo(SceneKey.Lockscreen) + assertThat(currentSceneKey).isEqualTo(Scenes.Lockscreen) underTest.start() powerInteractor.setAwakeForTest() - assertThat(currentSceneKey).isEqualTo(SceneKey.Lockscreen) + assertThat(currentSceneKey).isEqualTo(Scenes.Lockscreen) } @Test @@ -426,12 +427,12 @@ class SceneContainerStartableTest : SysuiTestCase() { testScope.runTest { val currentSceneKey by collectLastValue(sceneInteractor.currentScene) prepareState( - initialSceneKey = SceneKey.Lockscreen, + initialSceneKey = Scenes.Lockscreen, authenticationMethod = AuthenticationMethodModel.Pin, isDeviceUnlocked = false, startsAwake = false ) - assertThat(currentSceneKey).isEqualTo(SceneKey.Lockscreen) + assertThat(currentSceneKey).isEqualTo(Scenes.Lockscreen) underTest.start() kosmos.fakeDeviceEntryRepository.setUnlocked(true) @@ -439,14 +440,14 @@ class SceneContainerStartableTest : SysuiTestCase() { powerInteractor.setAwakeForTest() runCurrent() - assertThat(currentSceneKey).isEqualTo(SceneKey.Gone) + assertThat(currentSceneKey).isEqualTo(Scenes.Gone) } @Test fun collectFalsingSignals_onSuccessfulUnlock() = testScope.runTest { prepareState( - initialSceneKey = SceneKey.Lockscreen, + initialSceneKey = Scenes.Lockscreen, authenticationMethod = AuthenticationMethodModel.Pin, isDeviceUnlocked = false, ) @@ -456,11 +457,11 @@ class SceneContainerStartableTest : SysuiTestCase() { // Move around scenes without unlocking. listOf( - SceneKey.Shade, - SceneKey.QuickSettings, - SceneKey.Shade, - SceneKey.Lockscreen, - SceneKey.Bouncer, + Scenes.Shade, + Scenes.QuickSettings, + Scenes.Shade, + Scenes.Lockscreen, + Scenes.Bouncer, ) .forEach { sceneKey -> sceneInteractor.changeScene(sceneKey, "reason") @@ -471,17 +472,17 @@ class SceneContainerStartableTest : SysuiTestCase() { // Changing to the Gone scene should report a successful unlock. kosmos.fakeDeviceEntryRepository.setUnlocked(true) runCurrent() - sceneInteractor.changeScene(SceneKey.Gone, "reason") + sceneInteractor.changeScene(Scenes.Gone, "reason") runCurrent() verify(falsingCollector).onSuccessfulUnlock() // Move around scenes without changing back to Lockscreen, shouldn't report another // unlock. listOf( - SceneKey.Shade, - SceneKey.QuickSettings, - SceneKey.Shade, - SceneKey.Gone, + Scenes.Shade, + Scenes.QuickSettings, + Scenes.Shade, + Scenes.Gone, ) .forEach { sceneKey -> sceneInteractor.changeScene(sceneKey, "reason") @@ -490,17 +491,17 @@ class SceneContainerStartableTest : SysuiTestCase() { } // Changing to the Lockscreen scene shouldn't report a successful unlock. - sceneInteractor.changeScene(SceneKey.Lockscreen, "reason") + sceneInteractor.changeScene(Scenes.Lockscreen, "reason") runCurrent() verify(falsingCollector, times(1)).onSuccessfulUnlock() // Move around scenes without unlocking. listOf( - SceneKey.Shade, - SceneKey.QuickSettings, - SceneKey.Shade, - SceneKey.Lockscreen, - SceneKey.Bouncer, + Scenes.Shade, + Scenes.QuickSettings, + Scenes.Shade, + Scenes.Lockscreen, + Scenes.Bouncer, ) .forEach { sceneKey -> sceneInteractor.changeScene(sceneKey, "reason") @@ -509,7 +510,7 @@ class SceneContainerStartableTest : SysuiTestCase() { } // Changing to the Gone scene should report a second successful unlock. - sceneInteractor.changeScene(SceneKey.Gone, "reason") + sceneInteractor.changeScene(Scenes.Gone, "reason") runCurrent() verify(falsingCollector, times(2)).onSuccessfulUnlock() } @@ -518,7 +519,7 @@ class SceneContainerStartableTest : SysuiTestCase() { fun collectFalsingSignals_setShowingAod() = testScope.runTest { prepareState( - initialSceneKey = SceneKey.Lockscreen, + initialSceneKey = Scenes.Lockscreen, authenticationMethod = AuthenticationMethodModel.Pin, isDeviceUnlocked = false, ) @@ -540,7 +541,7 @@ class SceneContainerStartableTest : SysuiTestCase() { testScope.runTest { val currentSceneKey by collectLastValue(sceneInteractor.currentScene) prepareState( - initialSceneKey = SceneKey.Lockscreen, + initialSceneKey = Scenes.Lockscreen, authenticationMethod = AuthenticationMethodModel.Password, isDeviceUnlocked = false, ) @@ -550,7 +551,7 @@ class SceneContainerStartableTest : SysuiTestCase() { bouncerInteractor.onImeHiddenByUser() runCurrent() - assertThat(currentSceneKey).isEqualTo(SceneKey.Lockscreen) + assertThat(currentSceneKey).isEqualTo(Scenes.Lockscreen) } @Test @@ -559,7 +560,7 @@ class SceneContainerStartableTest : SysuiTestCase() { kosmos.fakeKeyguardRepository.setAodAvailable(false) runCurrent() prepareState( - initialSceneKey = SceneKey.Lockscreen, + initialSceneKey = Scenes.Lockscreen, authenticationMethod = AuthenticationMethodModel.Pin, isDeviceUnlocked = false, startsAwake = false, @@ -607,7 +608,7 @@ class SceneContainerStartableTest : SysuiTestCase() { kosmos.fakeKeyguardRepository.setAodAvailable(true) runCurrent() prepareState( - initialSceneKey = SceneKey.Lockscreen, + initialSceneKey = Scenes.Lockscreen, authenticationMethod = AuthenticationMethodModel.Pin, isDeviceUnlocked = false, ) @@ -652,7 +653,7 @@ class SceneContainerStartableTest : SysuiTestCase() { fun collectFalsingSignals_bouncerVisibility() = testScope.runTest { prepareState( - initialSceneKey = SceneKey.Lockscreen, + initialSceneKey = Scenes.Lockscreen, authenticationMethod = AuthenticationMethodModel.Pin, isDeviceUnlocked = false, ) @@ -660,13 +661,13 @@ class SceneContainerStartableTest : SysuiTestCase() { runCurrent() verify(falsingCollector).onBouncerHidden() - sceneInteractor.changeScene(SceneKey.Bouncer, "reason") + sceneInteractor.changeScene(Scenes.Bouncer, "reason") runCurrent() verify(falsingCollector).onBouncerShown() kosmos.fakeDeviceEntryRepository.setUnlocked(true) runCurrent() - sceneInteractor.changeScene(SceneKey.Gone, "reason") + sceneInteractor.changeScene(Scenes.Gone, "reason") runCurrent() verify(falsingCollector, times(2)).onBouncerHidden() } @@ -677,7 +678,7 @@ class SceneContainerStartableTest : SysuiTestCase() { val currentSceneKey by collectLastValue(sceneInteractor.currentScene) prepareState( - initialSceneKey = SceneKey.Lockscreen, + initialSceneKey = Scenes.Lockscreen, authenticationMethod = AuthenticationMethodModel.Pin, isDeviceUnlocked = false, ) @@ -687,7 +688,7 @@ class SceneContainerStartableTest : SysuiTestCase() { kosmos.fakeMobileConnectionsRepository.isAnySimSecure.value = true runCurrent() - assertThat(currentSceneKey).isEqualTo(SceneKey.Bouncer) + assertThat(currentSceneKey).isEqualTo(Scenes.Bouncer) } @Test @@ -697,7 +698,7 @@ class SceneContainerStartableTest : SysuiTestCase() { val currentSceneKey by collectLastValue(sceneInteractor.currentScene) prepareState( - initialSceneKey = SceneKey.Bouncer, + initialSceneKey = Scenes.Bouncer, authenticationMethod = AuthenticationMethodModel.Pin, isDeviceUnlocked = false, ) @@ -706,7 +707,7 @@ class SceneContainerStartableTest : SysuiTestCase() { kosmos.fakeMobileConnectionsRepository.isAnySimSecure.value = false runCurrent() - assertThat(currentSceneKey).isEqualTo(SceneKey.Lockscreen) + assertThat(currentSceneKey).isEqualTo(Scenes.Lockscreen) } @Test @@ -716,7 +717,7 @@ class SceneContainerStartableTest : SysuiTestCase() { val currentSceneKey by collectLastValue(sceneInteractor.currentScene) prepareState( - initialSceneKey = SceneKey.Lockscreen, + initialSceneKey = Scenes.Lockscreen, authenticationMethod = AuthenticationMethodModel.None, isDeviceUnlocked = true, isLockscreenEnabled = false, @@ -726,7 +727,7 @@ class SceneContainerStartableTest : SysuiTestCase() { kosmos.fakeMobileConnectionsRepository.isAnySimSecure.value = false runCurrent() - assertThat(currentSceneKey).isEqualTo(SceneKey.Gone) + assertThat(currentSceneKey).isEqualTo(Scenes.Gone) } @Test @@ -736,9 +737,9 @@ class SceneContainerStartableTest : SysuiTestCase() { val transitionStateFlow = prepareState( isDeviceUnlocked = true, - initialSceneKey = SceneKey.Gone, + initialSceneKey = Scenes.Gone, ) - assertThat(currentDesiredSceneKey).isEqualTo(SceneKey.Gone) + assertThat(currentDesiredSceneKey).isEqualTo(Scenes.Gone) verify(windowController, never()).setNotificationShadeFocusable(anyBoolean()) underTest.start() @@ -746,11 +747,11 @@ class SceneContainerStartableTest : SysuiTestCase() { verify(windowController, times(1)).setNotificationShadeFocusable(false) fakeSceneDataSource.pause() - sceneInteractor.changeScene(SceneKey.Shade, "reason") + sceneInteractor.changeScene(Scenes.Shade, "reason") transitionStateFlow.value = ObservableTransitionState.Transition( - fromScene = SceneKey.Gone, - toScene = SceneKey.Shade, + fromScene = Scenes.Gone, + toScene = Scenes.Shade, progress = flowOf(0.5f), isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), @@ -758,17 +759,17 @@ class SceneContainerStartableTest : SysuiTestCase() { runCurrent() verify(windowController, times(1)).setNotificationShadeFocusable(false) - fakeSceneDataSource.unpause(expectedScene = SceneKey.Shade) - transitionStateFlow.value = ObservableTransitionState.Idle(SceneKey.Shade) + fakeSceneDataSource.unpause(expectedScene = Scenes.Shade) + transitionStateFlow.value = ObservableTransitionState.Idle(Scenes.Shade) runCurrent() verify(windowController, times(1)).setNotificationShadeFocusable(true) fakeSceneDataSource.pause() - sceneInteractor.changeScene(SceneKey.Gone, "reason") + sceneInteractor.changeScene(Scenes.Gone, "reason") transitionStateFlow.value = ObservableTransitionState.Transition( - fromScene = SceneKey.Shade, - toScene = SceneKey.Gone, + fromScene = Scenes.Shade, + toScene = Scenes.Gone, progress = flowOf(0.5f), isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), @@ -776,8 +777,8 @@ class SceneContainerStartableTest : SysuiTestCase() { runCurrent() verify(windowController, times(1)).setNotificationShadeFocusable(true) - fakeSceneDataSource.unpause(expectedScene = SceneKey.Gone) - transitionStateFlow.value = ObservableTransitionState.Idle(SceneKey.Gone) + fakeSceneDataSource.unpause(expectedScene = Scenes.Gone) + transitionStateFlow.value = ObservableTransitionState.Idle(Scenes.Gone) runCurrent() verify(windowController, times(2)).setNotificationShadeFocusable(false) } @@ -787,7 +788,7 @@ class SceneContainerStartableTest : SysuiTestCase() { testScope.runTest { val transitionStateFlow = prepareState( - initialSceneKey = SceneKey.Lockscreen, + initialSceneKey = Scenes.Lockscreen, ) underTest.start() runCurrent() @@ -796,7 +797,7 @@ class SceneContainerStartableTest : SysuiTestCase() { clearInvocations(centralSurfaces) emulateSceneTransition( transitionStateFlow = transitionStateFlow, - toScene = SceneKey.Bouncer, + toScene = Scenes.Bouncer, verifyBeforeTransition = { verify(centralSurfaces, never()).setInteracting(anyInt(), anyBoolean()) }, @@ -815,7 +816,7 @@ class SceneContainerStartableTest : SysuiTestCase() { clearInvocations(centralSurfaces) emulateSceneTransition( transitionStateFlow = transitionStateFlow, - toScene = SceneKey.Lockscreen, + toScene = Scenes.Lockscreen, verifyBeforeTransition = { verify(centralSurfaces, never()).setInteracting(anyInt(), anyBoolean()) }, @@ -834,7 +835,7 @@ class SceneContainerStartableTest : SysuiTestCase() { clearInvocations(centralSurfaces) emulateSceneTransition( transitionStateFlow = transitionStateFlow, - toScene = SceneKey.Shade, + toScene = Scenes.Shade, verifyBeforeTransition = { verify(centralSurfaces, never()).setInteracting(anyInt(), anyBoolean()) }, @@ -853,7 +854,7 @@ class SceneContainerStartableTest : SysuiTestCase() { clearInvocations(centralSurfaces) emulateSceneTransition( transitionStateFlow = transitionStateFlow, - toScene = SceneKey.Lockscreen, + toScene = Scenes.Lockscreen, verifyBeforeTransition = { verify(centralSurfaces, never()).setInteracting(anyInt(), anyBoolean()) }, @@ -872,7 +873,7 @@ class SceneContainerStartableTest : SysuiTestCase() { clearInvocations(centralSurfaces) emulateSceneTransition( transitionStateFlow = transitionStateFlow, - toScene = SceneKey.QuickSettings, + toScene = Scenes.QuickSettings, verifyBeforeTransition = { verify(centralSurfaces, never()).setInteracting(anyInt(), anyBoolean()) }, @@ -891,7 +892,7 @@ class SceneContainerStartableTest : SysuiTestCase() { val transitionStateFlow = prepareState( isDeviceUnlocked = true, - initialSceneKey = SceneKey.Gone, + initialSceneKey = Scenes.Gone, ) underTest.start() verify(centralSurfaces, never()).setInteracting(anyInt(), anyBoolean()) @@ -899,7 +900,7 @@ class SceneContainerStartableTest : SysuiTestCase() { clearInvocations(centralSurfaces) emulateSceneTransition( transitionStateFlow = transitionStateFlow, - toScene = SceneKey.Bouncer, + toScene = Scenes.Bouncer, verifyBeforeTransition = { verify(centralSurfaces, never()).setInteracting(anyInt(), anyBoolean()) }, @@ -914,7 +915,7 @@ class SceneContainerStartableTest : SysuiTestCase() { clearInvocations(centralSurfaces) emulateSceneTransition( transitionStateFlow = transitionStateFlow, - toScene = SceneKey.Lockscreen, + toScene = Scenes.Lockscreen, verifyBeforeTransition = { verify(centralSurfaces, never()).setInteracting(anyInt(), anyBoolean()) }, @@ -929,7 +930,7 @@ class SceneContainerStartableTest : SysuiTestCase() { clearInvocations(centralSurfaces) emulateSceneTransition( transitionStateFlow = transitionStateFlow, - toScene = SceneKey.Shade, + toScene = Scenes.Shade, verifyBeforeTransition = { verify(centralSurfaces, never()).setInteracting(anyInt(), anyBoolean()) }, @@ -944,7 +945,7 @@ class SceneContainerStartableTest : SysuiTestCase() { clearInvocations(centralSurfaces) emulateSceneTransition( transitionStateFlow = transitionStateFlow, - toScene = SceneKey.Lockscreen, + toScene = Scenes.Lockscreen, verifyBeforeTransition = { verify(centralSurfaces, never()).setInteracting(anyInt(), anyBoolean()) }, @@ -959,7 +960,7 @@ class SceneContainerStartableTest : SysuiTestCase() { clearInvocations(centralSurfaces) emulateSceneTransition( transitionStateFlow = transitionStateFlow, - toScene = SceneKey.QuickSettings, + toScene = Scenes.QuickSettings, verifyBeforeTransition = { verify(centralSurfaces, never()).setInteracting(anyInt(), anyBoolean()) }, @@ -978,12 +979,12 @@ class SceneContainerStartableTest : SysuiTestCase() { val currentScene by collectLastValue(sceneInteractor.currentScene) val transitionStateFlow = prepareState() underTest.start() - emulateSceneTransition(transitionStateFlow, toScene = SceneKey.Bouncer) - assertThat(currentScene).isNotEqualTo(SceneKey.Lockscreen) + emulateSceneTransition(transitionStateFlow, toScene = Scenes.Bouncer) + assertThat(currentScene).isNotEqualTo(Scenes.Lockscreen) kosmos.falsingManager.sendFalsingBelief() - assertThat(currentScene).isEqualTo(SceneKey.Lockscreen) + assertThat(currentScene).isEqualTo(Scenes.Lockscreen) } private fun TestScope.emulateSceneTransition( @@ -1033,7 +1034,7 @@ class SceneContainerStartableTest : SysuiTestCase() { } } - check(initialSceneKey != SceneKey.Gone || isDeviceUnlocked) { + check(initialSceneKey != Scenes.Gone || isDeviceUnlocked) { "Cannot start on the Gone scene and have the device be locked at the same time." } @@ -1043,7 +1044,7 @@ class SceneContainerStartableTest : SysuiTestCase() { runCurrent() val transitionStateFlow = MutableStateFlow<ObservableTransitionState>( - ObservableTransitionState.Idle(SceneKey.Lockscreen) + ObservableTransitionState.Idle(Scenes.Lockscreen) ) sceneInteractor.setTransitionState(transitionStateFlow) initialSceneKey?.let { diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/shared/model/SceneDataSourceDelegatorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/shared/model/SceneDataSourceDelegatorTest.kt index ed4b1e6a43c9..32c0172071f6 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/shared/model/SceneDataSourceDelegatorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/shared/model/SceneDataSourceDelegatorTest.kt @@ -53,9 +53,9 @@ class SceneDataSourceDelegatorTest : SysuiTestCase() { testScope.runTest { val currentScene by collectLastValue(underTest.currentScene) underTest.setDelegate(null) - assertThat(currentScene).isNotEqualTo(SceneKey.Bouncer) + assertThat(currentScene).isNotEqualTo(Scenes.Bouncer) - underTest.changeScene(toScene = SceneKey.Bouncer) + underTest.changeScene(toScene = Scenes.Bouncer) assertThat(currentScene).isEqualTo(initialSceneKey) } @@ -71,11 +71,11 @@ class SceneDataSourceDelegatorTest : SysuiTestCase() { fun currentScene_withDelegate_changesScenes() = testScope.runTest { val currentScene by collectLastValue(underTest.currentScene) - assertThat(currentScene).isNotEqualTo(SceneKey.Bouncer) + assertThat(currentScene).isNotEqualTo(Scenes.Bouncer) - underTest.changeScene(toScene = SceneKey.Bouncer) + underTest.changeScene(toScene = Scenes.Bouncer) - assertThat(currentScene).isEqualTo(SceneKey.Bouncer) + assertThat(currentScene).isEqualTo(Scenes.Bouncer) } @Test @@ -83,8 +83,8 @@ class SceneDataSourceDelegatorTest : SysuiTestCase() { testScope.runTest { val currentScene by collectLastValue(underTest.currentScene) - fakeSceneDataSource.changeScene(toScene = SceneKey.Bouncer) + fakeSceneDataSource.changeScene(toScene = Scenes.Bouncer) - assertThat(currentScene).isEqualTo(SceneKey.Bouncer) + assertThat(currentScene).isEqualTo(Scenes.Bouncer) } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModelTest.kt index 27ae8b60009c..7b0127e94fb7 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModelTest.kt @@ -30,7 +30,7 @@ import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.sceneContainerConfig import com.android.systemui.scene.sceneKeys import com.android.systemui.scene.shared.flag.fakeSceneContainerFlags -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.fakeSceneDataSource import com.android.systemui.testKosmos import com.android.systemui.util.mockito.mock @@ -89,20 +89,20 @@ class SceneContainerViewModelTest : SysuiTestCase() { fun sceneTransition() = testScope.runTest { val currentScene by collectLastValue(underTest.currentScene) - assertThat(currentScene).isEqualTo(SceneKey.Lockscreen) + assertThat(currentScene).isEqualTo(Scenes.Lockscreen) - fakeSceneDataSource.changeScene(SceneKey.Shade) + fakeSceneDataSource.changeScene(Scenes.Shade) - assertThat(currentScene).isEqualTo(SceneKey.Shade) + assertThat(currentScene).isEqualTo(Scenes.Shade) } @Test fun canChangeScene_whenAllowed_switchingFromGone_returnsTrue() = testScope.runTest { val currentScene by collectLastValue(underTest.currentScene) - fakeSceneDataSource.changeScene(toScene = SceneKey.Gone) + fakeSceneDataSource.changeScene(toScene = Scenes.Gone) runCurrent() - assertThat(currentScene).isEqualTo(SceneKey.Gone) + assertThat(currentScene).isEqualTo(Scenes.Gone) sceneContainerConfig.sceneKeys .filter { it != currentScene } @@ -117,9 +117,9 @@ class SceneContainerViewModelTest : SysuiTestCase() { fun canChangeScene_whenAllowed_switchingFromLockscreen_returnsTrue() = testScope.runTest { val currentScene by collectLastValue(underTest.currentScene) - fakeSceneDataSource.changeScene(toScene = SceneKey.Lockscreen) + fakeSceneDataSource.changeScene(toScene = Scenes.Lockscreen) runCurrent() - assertThat(currentScene).isEqualTo(SceneKey.Lockscreen) + assertThat(currentScene).isEqualTo(Scenes.Lockscreen) sceneContainerConfig.sceneKeys .filter { it != currentScene } @@ -135,15 +135,15 @@ class SceneContainerViewModelTest : SysuiTestCase() { testScope.runTest { falsingManager.setIsFalseTouch(true) val currentScene by collectLastValue(underTest.currentScene) - fakeSceneDataSource.changeScene(toScene = SceneKey.Lockscreen) + fakeSceneDataSource.changeScene(toScene = Scenes.Lockscreen) runCurrent() - assertThat(currentScene).isEqualTo(SceneKey.Lockscreen) + assertThat(currentScene).isEqualTo(Scenes.Lockscreen) sceneContainerConfig.sceneKeys .filter { it != currentScene } .filter { // Moving to the Communal scene is not currently falsing protected. - it != SceneKey.Communal + it != Scenes.Communal } .forEach { toScene -> assertWithMessage("Protected scene $toScene not properly protected") @@ -157,14 +157,14 @@ class SceneContainerViewModelTest : SysuiTestCase() { testScope.runTest { falsingManager.setIsFalseTouch(true) val currentScene by collectLastValue(underTest.currentScene) - fakeSceneDataSource.changeScene(toScene = SceneKey.Lockscreen) + fakeSceneDataSource.changeScene(toScene = Scenes.Lockscreen) runCurrent() - assertThat(currentScene).isEqualTo(SceneKey.Lockscreen) + assertThat(currentScene).isEqualTo(Scenes.Lockscreen) sceneContainerConfig.sceneKeys .filter { // Moving to the Communal scene is not currently falsing protected. - it == SceneKey.Communal + it == Scenes.Communal } .forEach { toScene -> assertWithMessage("Unprotected scene $toScene is incorrectly protected") @@ -178,9 +178,9 @@ class SceneContainerViewModelTest : SysuiTestCase() { testScope.runTest { falsingManager.setIsFalseTouch(true) val currentScene by collectLastValue(underTest.currentScene) - fakeSceneDataSource.changeScene(toScene = SceneKey.Gone) + fakeSceneDataSource.changeScene(toScene = Scenes.Gone) runCurrent() - assertThat(currentScene).isEqualTo(SceneKey.Gone) + assertThat(currentScene).isEqualTo(Scenes.Gone) sceneContainerConfig.sceneKeys .filter { it != currentScene } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ShadeControllerSceneImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ShadeControllerSceneImplTest.kt index ec424b05fc06..d3fa3603d722 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ShadeControllerSceneImplTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ShadeControllerSceneImplTest.kt @@ -18,6 +18,8 @@ package com.android.systemui.shade import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest +import com.android.compose.animation.scene.ObservableTransitionState +import com.android.compose.animation.scene.SceneKey import com.android.systemui.SysuiTestCase import com.android.systemui.deviceentry.data.repository.fakeDeviceEntryRepository import com.android.systemui.deviceentry.domain.interactor.deviceEntryInteractor @@ -28,8 +30,7 @@ import com.android.systemui.kosmos.testCase import com.android.systemui.kosmos.testScope import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.flag.fakeSceneContainerFlags -import com.android.systemui.scene.shared.model.ObservableTransitionState -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.shade.domain.interactor.ShadeInteractor import com.android.systemui.shade.domain.interactor.shadeInteractor import com.android.systemui.statusbar.CommandQueue @@ -87,7 +88,7 @@ class ShadeControllerSceneImplTest : SysuiTestCase() { runCurrent() // THEN the shade remains collapsed and the post-collapse action ran - assertThat(sceneInteractor.currentScene.value).isEqualTo(SceneKey.Gone) + assertThat(sceneInteractor.currentScene.value).isEqualTo(Scenes.Gone) verify(testRunnable, times(1)).run() } @@ -105,7 +106,7 @@ class ShadeControllerSceneImplTest : SysuiTestCase() { runCurrent() // THEN the shade remains expanded and the post-collapse action did not run - assertThat(sceneInteractor.currentScene.value).isEqualTo(SceneKey.Shade) + assertThat(sceneInteractor.currentScene.value).isEqualTo(Scenes.Shade) assertThat(shadeInteractor.isAnyFullyExpanded.value).isTrue() verify(testRunnable, never()).run() } @@ -122,7 +123,7 @@ class ShadeControllerSceneImplTest : SysuiTestCase() { runCurrent() // THEN the shade collapses back to lockscreen and the post-collapse action ran - assertThat(sceneInteractor.currentScene.value).isEqualTo(SceneKey.Lockscreen) + assertThat(sceneInteractor.currentScene.value).isEqualTo(Scenes.Lockscreen) } @Test @@ -137,7 +138,7 @@ class ShadeControllerSceneImplTest : SysuiTestCase() { runCurrent() // THEN the shade collapses back to lockscreen and the post-collapse action ran - assertThat(sceneInteractor.currentScene.value).isEqualTo(SceneKey.Gone) + assertThat(sceneInteractor.currentScene.value).isEqualTo(Scenes.Gone) } @Test @@ -181,21 +182,21 @@ class ShadeControllerSceneImplTest : SysuiTestCase() { private fun setDeviceEntered(isEntered: Boolean) { setScene( if (isEntered) { - SceneKey.Gone + Scenes.Gone } else { - SceneKey.Lockscreen + Scenes.Lockscreen } ) assertThat(deviceEntryInteractor.isDeviceEntered.value).isEqualTo(isEntered) } private fun setCollapsed() { - setScene(SceneKey.Gone) + setScene(Scenes.Gone) assertThat(shadeInteractor.isAnyExpanded.value).isFalse() } private fun setShadeFullyExpanded() { - setScene(SceneKey.Shade) + setScene(Scenes.Shade) assertThat(shadeInteractor.isAnyFullyExpanded.value).isTrue() } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeAnimationInteractorSceneContainerImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeAnimationInteractorSceneContainerImplTest.kt index 1ef07facf8d1..bb40591335f4 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeAnimationInteractorSceneContainerImplTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeAnimationInteractorSceneContainerImplTest.kt @@ -18,12 +18,12 @@ package com.android.systemui.shade.domain.interactor import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest +import com.android.compose.animation.scene.ObservableTransitionState import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.testScope import com.android.systemui.scene.domain.interactor.sceneInteractor -import com.android.systemui.scene.shared.model.ObservableTransitionState -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.testKosmos import com.google.common.truth.Truth import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -53,8 +53,8 @@ class ShadeAnimationInteractorSceneContainerImplTest : SysuiTestCase() { val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Transition( - fromScene = SceneKey.QuickSettings, - toScene = SceneKey.Shade, + fromScene = Scenes.QuickSettings, + toScene = Scenes.Shade, progress = MutableStateFlow(.1f), isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), @@ -76,8 +76,8 @@ class ShadeAnimationInteractorSceneContainerImplTest : SysuiTestCase() { val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Transition( - fromScene = SceneKey.QuickSettings, - toScene = SceneKey.Gone, + fromScene = Scenes.QuickSettings, + toScene = Scenes.Gone, progress = MutableStateFlow(.1f), isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), @@ -99,8 +99,8 @@ class ShadeAnimationInteractorSceneContainerImplTest : SysuiTestCase() { val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Transition( - fromScene = SceneKey.QuickSettings, - toScene = SceneKey.Gone, + fromScene = Scenes.QuickSettings, + toScene = Scenes.Gone, progress = MutableStateFlow(.1f), isInitiatedByUserInput = false, isUserInputOngoing = flowOf(true), diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeBackActionInteractorImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeBackActionInteractorImplTest.kt index ec4da0405b6d..b66213330496 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeBackActionInteractorImplTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeBackActionInteractorImplTest.kt @@ -19,13 +19,14 @@ package com.android.systemui.shade.domain.interactor import android.content.applicationContext import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest +import com.android.compose.animation.scene.ObservableTransitionState +import com.android.compose.animation.scene.SceneKey import com.android.systemui.SysuiTestCase import com.android.systemui.deviceentry.data.repository.fakeDeviceEntryRepository import com.android.systemui.kosmos.testScope import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.flag.fakeSceneContainerFlags -import com.android.systemui.scene.shared.model.ObservableTransitionState -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.shared.recents.utilities.Utilities import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat @@ -56,45 +57,45 @@ class ShadeBackActionInteractorImplTest : SysuiTestCase() { @Test fun animateCollapseQs_notOnQs() = testScope.runTest { - setScene(SceneKey.Shade) + setScene(Scenes.Shade) underTest.animateCollapseQs(true) runCurrent() - assertThat(sceneInteractor.currentScene.value).isEqualTo(SceneKey.Shade) + assertThat(sceneInteractor.currentScene.value).isEqualTo(Scenes.Shade) } @Test fun animateCollapseQs_fullyCollapse_entered() = testScope.runTest { enterDevice() - setScene(SceneKey.QuickSettings) + setScene(Scenes.QuickSettings) underTest.animateCollapseQs(true) runCurrent() - assertThat(sceneInteractor.currentScene.value).isEqualTo(SceneKey.Gone) + assertThat(sceneInteractor.currentScene.value).isEqualTo(Scenes.Gone) } @Test fun animateCollapseQs_fullyCollapse_locked() = testScope.runTest { deviceEntryRepository.setUnlocked(false) - setScene(SceneKey.QuickSettings) + setScene(Scenes.QuickSettings) underTest.animateCollapseQs(true) runCurrent() - assertThat(sceneInteractor.currentScene.value).isEqualTo(SceneKey.Lockscreen) + assertThat(sceneInteractor.currentScene.value).isEqualTo(Scenes.Lockscreen) } @Test fun animateCollapseQs_notFullyCollapse() = testScope.runTest { - setScene(SceneKey.QuickSettings) + setScene(Scenes.QuickSettings) underTest.animateCollapseQs(false) runCurrent() - assertThat(sceneInteractor.currentScene.value).isEqualTo(SceneKey.Shade) + assertThat(sceneInteractor.currentScene.value).isEqualTo(Scenes.Shade) } private fun enterDevice() { deviceEntryRepository.setUnlocked(true) testScope.runCurrent() - setScene(SceneKey.Gone) + setScene(Scenes.Gone) } private fun setScene(key: SceneKey) { diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeInteractorSceneContainerImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeInteractorSceneContainerImplTest.kt index bf136cdd817e..4cd2c301d6ee 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeInteractorSceneContainerImplTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeInteractorSceneContainerImplTest.kt @@ -18,6 +18,7 @@ package com.android.systemui.shade.domain.interactor import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest +import com.android.compose.animation.scene.ObservableTransitionState import com.android.systemui.SysuiTestCase import com.android.systemui.common.ui.data.repository.fakeConfigurationRepository import com.android.systemui.coroutines.collectLastValue @@ -27,8 +28,7 @@ import com.android.systemui.keyguard.shared.model.StatusBarState import com.android.systemui.kosmos.testScope import com.android.systemui.res.R import com.android.systemui.scene.domain.interactor.sceneInteractor -import com.android.systemui.scene.shared.model.ObservableTransitionState -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.testKosmos import com.android.systemui.user.data.repository.userRepository import com.google.common.truth.Truth @@ -67,8 +67,8 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Transition( - fromScene = SceneKey.QuickSettings, - toScene = SceneKey.Shade, + fromScene = Scenes.QuickSettings, + toScene = Scenes.Shade, progress = MutableStateFlow(.3f), isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), @@ -96,8 +96,8 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Transition( - fromScene = SceneKey.QuickSettings, - toScene = SceneKey.Shade, + fromScene = Scenes.QuickSettings, + toScene = Scenes.Shade, progress = progress, isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), @@ -120,8 +120,8 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Transition( - fromScene = SceneKey.QuickSettings, - toScene = SceneKey.Shade, + fromScene = Scenes.QuickSettings, + toScene = Scenes.Shade, progress = MutableStateFlow(.3f), isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), @@ -143,7 +143,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { keyguardRepository.setStatusBarState(StatusBarState.SHADE) val transitionState = MutableStateFlow<ObservableTransitionState>( - ObservableTransitionState.Idle(SceneKey.Shade) + ObservableTransitionState.Idle(Scenes.Shade) ) sceneInteractor.setTransitionState(transitionState) runCurrent() @@ -161,7 +161,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { keyguardRepository.setStatusBarState(StatusBarState.SHADE) val transitionState = MutableStateFlow<ObservableTransitionState>( - ObservableTransitionState.Idle(SceneKey.QuickSettings) + ObservableTransitionState.Idle(Scenes.QuickSettings) ) sceneInteractor.setTransitionState(transitionState) runCurrent() @@ -174,7 +174,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { fun lockscreenShadeExpansion_idle_onScene() = testComponent.runTest { // GIVEN an expansion flow based on transitions to and from a scene - val key = SceneKey.Shade + val key = Scenes.Shade val expansion = underTest.sceneBasedExpansion(sceneInteractor, key) val expansionAmount by collectLastValue(expansion) @@ -191,13 +191,13 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { fun lockscreenShadeExpansion_idle_onDifferentScene() = testComponent.runTest { // GIVEN an expansion flow based on transitions to and from a scene - val expansion = underTest.sceneBasedExpansion(sceneInteractor, SceneKey.Shade) + val expansion = underTest.sceneBasedExpansion(sceneInteractor, Scenes.Shade) val expansionAmount by collectLastValue(expansion) // WHEN transition state is idle on a different scene val transitionState = MutableStateFlow<ObservableTransitionState>( - ObservableTransitionState.Idle(SceneKey.Lockscreen) + ObservableTransitionState.Idle(Scenes.Lockscreen) ) sceneInteractor.setTransitionState(transitionState) @@ -209,7 +209,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { fun lockscreenShadeExpansion_transitioning_toScene() = testComponent.runTest { // GIVEN an expansion flow based on transitions to and from a scene - val key = SceneKey.QuickSettings + val key = Scenes.QuickSettings val expansion = underTest.sceneBasedExpansion(sceneInteractor, key) val expansionAmount by collectLastValue(expansion) @@ -218,7 +218,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Transition( - fromScene = SceneKey.Lockscreen, + fromScene = Scenes.Lockscreen, toScene = key, progress = progress, isInitiatedByUserInput = false, @@ -247,7 +247,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { fun lockscreenShadeExpansion_transitioning_fromScene() = testComponent.runTest { // GIVEN an expansion flow based on transitions to and from a scene - val key = SceneKey.QuickSettings + val key = Scenes.QuickSettings val expansion = underTest.sceneBasedExpansion(sceneInteractor, key) val expansionAmount by collectLastValue(expansion) @@ -257,7 +257,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Transition( fromScene = key, - toScene = SceneKey.Lockscreen, + toScene = Scenes.Lockscreen, progress = progress, isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), @@ -290,8 +290,8 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Transition( - fromScene = SceneKey.Gone, - toScene = SceneKey.QuickSettings, + fromScene = Scenes.Gone, + toScene = Scenes.QuickSettings, progress = MutableStateFlow(.1f), isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), @@ -313,8 +313,8 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Transition( - fromScene = SceneKey.Shade, - toScene = SceneKey.QuickSettings, + fromScene = Scenes.Shade, + toScene = Scenes.QuickSettings, progress = MutableStateFlow(.1f), isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), @@ -331,7 +331,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { fun lockscreenShadeExpansion_transitioning_toAndFromDifferentScenes() = testComponent.runTest { // GIVEN an expansion flow based on transitions to and from a scene - val expansion = underTest.sceneBasedExpansion(sceneInteractor, SceneKey.QuickSettings) + val expansion = underTest.sceneBasedExpansion(sceneInteractor, Scenes.QuickSettings) val expansionAmount by collectLastValue(expansion) // WHEN transition state is starting to between different scenes @@ -339,8 +339,8 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Transition( - fromScene = SceneKey.Lockscreen, - toScene = SceneKey.Shade, + fromScene = Scenes.Lockscreen, + toScene = Scenes.Shade, progress = progress, isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), @@ -368,7 +368,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { fun userInteracting_idle() = testComponent.runTest { // GIVEN an interacting flow based on transitions to and from a scene - val key = SceneKey.Shade + val key = Scenes.Shade val interactingFlow = underTest.sceneBasedInteracting(sceneInteractor, key) val interacting by collectLastValue(interactingFlow) @@ -385,7 +385,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { fun userInteracting_transitioning_toScene_programmatic() = testComponent.runTest { // GIVEN an interacting flow based on transitions to and from a scene - val key = SceneKey.QuickSettings + val key = Scenes.QuickSettings val interactingFlow = underTest.sceneBasedInteracting(sceneInteractor, key) val interacting by collectLastValue(interactingFlow) @@ -394,7 +394,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Transition( - fromScene = SceneKey.Lockscreen, + fromScene = Scenes.Lockscreen, toScene = key, progress = progress, isInitiatedByUserInput = false, @@ -423,7 +423,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { fun userInteracting_transitioning_toScene_userInputDriven() = testComponent.runTest { // GIVEN an interacting flow based on transitions to and from a scene - val key = SceneKey.QuickSettings + val key = Scenes.QuickSettings val interactingFlow = underTest.sceneBasedInteracting(sceneInteractor, key) val interacting by collectLastValue(interactingFlow) @@ -432,7 +432,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Transition( - fromScene = SceneKey.Lockscreen, + fromScene = Scenes.Lockscreen, toScene = key, progress = progress, isInitiatedByUserInput = true, @@ -461,7 +461,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { fun userInteracting_transitioning_fromScene_programmatic() = testComponent.runTest { // GIVEN an interacting flow based on transitions to and from a scene - val key = SceneKey.QuickSettings + val key = Scenes.QuickSettings val interactingFlow = underTest.sceneBasedInteracting(sceneInteractor, key) val interacting by collectLastValue(interactingFlow) @@ -471,7 +471,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Transition( fromScene = key, - toScene = SceneKey.Lockscreen, + toScene = Scenes.Lockscreen, progress = progress, isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), @@ -499,7 +499,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { fun userInteracting_transitioning_fromScene_userInputDriven() = testComponent.runTest { // GIVEN an interacting flow based on transitions to and from a scene - val key = SceneKey.QuickSettings + val key = Scenes.QuickSettings val interactingFlow = underTest.sceneBasedInteracting(sceneInteractor, key) val interacting by collectLastValue(interactingFlow) @@ -509,7 +509,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Transition( fromScene = key, - toScene = SceneKey.Lockscreen, + toScene = Scenes.Lockscreen, progress = progress, isInitiatedByUserInput = true, isUserInputOngoing = flowOf(false), @@ -537,7 +537,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { fun userInteracting_transitioning_toAndFromDifferentScenes() = testComponent.runTest { // GIVEN an interacting flow based on transitions to and from a scene - val interactingFlow = underTest.sceneBasedInteracting(sceneInteractor, SceneKey.Shade) + val interactingFlow = underTest.sceneBasedInteracting(sceneInteractor, Scenes.Shade) val interacting by collectLastValue(interactingFlow) // WHEN transition state is starting to between different scenes @@ -545,8 +545,8 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Transition( - fromScene = SceneKey.Lockscreen, - toScene = SceneKey.QuickSettings, + fromScene = Scenes.Lockscreen, + toScene = Scenes.QuickSettings, progress = MutableStateFlow(0f), isInitiatedByUserInput = true, isUserInputOngoing = flowOf(false), diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModelTest.kt index d655ade5cf2c..853b00d345bc 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModelTest.kt @@ -30,7 +30,7 @@ import com.android.systemui.kosmos.testScope import com.android.systemui.media.controls.domain.pipeline.MediaDataManager import com.android.systemui.qs.ui.adapter.FakeQSSceneAdapter import com.android.systemui.scene.domain.interactor.sceneInteractor -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.shade.domain.interactor.privacyChipInteractor import com.android.systemui.shade.domain.interactor.shadeHeaderClockInteractor import com.android.systemui.statusbar.notification.stack.ui.viewmodel.notificationsPlaceholderViewModel @@ -125,7 +125,7 @@ class ShadeSceneViewModelTest : SysuiTestCase() { ) kosmos.fakeDeviceEntryRepository.setUnlocked(false) - assertThat(upTransitionSceneKey).isEqualTo(SceneKey.Lockscreen) + assertThat(upTransitionSceneKey).isEqualTo(Scenes.Lockscreen) } @Test @@ -137,7 +137,7 @@ class ShadeSceneViewModelTest : SysuiTestCase() { ) kosmos.fakeDeviceEntryRepository.setUnlocked(true) - assertThat(upTransitionSceneKey).isEqualTo(SceneKey.Gone) + assertThat(upTransitionSceneKey).isEqualTo(Scenes.Gone) } @Test @@ -148,9 +148,9 @@ class ShadeSceneViewModelTest : SysuiTestCase() { kosmos.fakeAuthenticationRepository.setAuthenticationMethod( AuthenticationMethodModel.None ) - sceneInteractor.changeScene(SceneKey.Lockscreen, "reason") + sceneInteractor.changeScene(Scenes.Lockscreen, "reason") - assertThat(upTransitionSceneKey).isEqualTo(SceneKey.Lockscreen) + assertThat(upTransitionSceneKey).isEqualTo(Scenes.Lockscreen) } @Test @@ -163,9 +163,9 @@ class ShadeSceneViewModelTest : SysuiTestCase() { AuthenticationMethodModel.None ) runCurrent() - sceneInteractor.changeScene(SceneKey.Gone, "reason") + sceneInteractor.changeScene(Scenes.Gone, "reason") - assertThat(upTransitionSceneKey).isEqualTo(SceneKey.Gone) + assertThat(upTransitionSceneKey).isEqualTo(Scenes.Gone) } @Test @@ -206,7 +206,7 @@ class ShadeSceneViewModelTest : SysuiTestCase() { underTest.onContentClicked() - assertThat(currentScene).isEqualTo(SceneKey.Gone) + assertThat(currentScene).isEqualTo(Scenes.Gone) } @Test @@ -221,7 +221,7 @@ class ShadeSceneViewModelTest : SysuiTestCase() { underTest.onContentClicked() - assertThat(currentScene).isEqualTo(SceneKey.Bouncer) + assertThat(currentScene).isEqualTo(Scenes.Bouncer) } @Test diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/NotificationStackAppearanceIntegrationTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/NotificationStackAppearanceIntegrationTest.kt index efd8f000df41..47918c8c1b3d 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/NotificationStackAppearanceIntegrationTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/NotificationStackAppearanceIntegrationTest.kt @@ -20,6 +20,7 @@ package com.android.systemui.statusbar.notification import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest +import com.android.compose.animation.scene.ObservableTransitionState import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.NotificationContainerBounds import com.android.systemui.coroutines.collectLastValue @@ -28,8 +29,7 @@ import com.android.systemui.flags.fakeFeatureFlagsClassic import com.android.systemui.kosmos.testScope import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.flag.fakeSceneContainerFlags -import com.android.systemui.scene.shared.model.ObservableTransitionState -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.fakeSceneDataSource import com.android.systemui.statusbar.notification.stack.ui.viewmodel.notificationStackAppearanceViewModel import com.android.systemui.statusbar.notification.stack.ui.viewmodel.notificationsPlaceholderViewModel @@ -92,19 +92,19 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() { testScope.runTest { val transitionState = MutableStateFlow<ObservableTransitionState>( - ObservableTransitionState.Idle(scene = SceneKey.Gone) + ObservableTransitionState.Idle(scene = Scenes.Gone) ) sceneInteractor.setTransitionState(transitionState) val expandFraction by collectLastValue(appearanceViewModel.expandFraction) assertThat(expandFraction).isEqualTo(0f) fakeSceneDataSource.pause() - sceneInteractor.changeScene(SceneKey.Shade, "reason") + sceneInteractor.changeScene(Scenes.Shade, "reason") val transitionProgress = MutableStateFlow(0f) transitionState.value = ObservableTransitionState.Transition( - fromScene = SceneKey.Gone, - toScene = SceneKey.Shade, + fromScene = Scenes.Gone, + toScene = Scenes.Shade, progress = transitionProgress, isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), @@ -117,7 +117,7 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() { assertThat(expandFraction).isWithin(0.01f).of(progress) } - fakeSceneDataSource.unpause(expectedScene = SceneKey.Shade) + fakeSceneDataSource.unpause(expectedScene = Scenes.Shade) assertThat(expandFraction).isWithin(0.01f).of(1f) } @@ -126,7 +126,7 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() { testScope.runTest { val transitionState = MutableStateFlow<ObservableTransitionState>( - ObservableTransitionState.Idle(scene = SceneKey.Lockscreen) + ObservableTransitionState.Idle(scene = Scenes.Lockscreen) ) sceneInteractor.setTransitionState(transitionState) val expandFraction by collectLastValue(appearanceViewModel.expandFraction) @@ -138,19 +138,19 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() { testScope.runTest { val transitionState = MutableStateFlow<ObservableTransitionState>( - ObservableTransitionState.Idle(scene = SceneKey.Shade) + ObservableTransitionState.Idle(scene = Scenes.Shade) ) sceneInteractor.setTransitionState(transitionState) val expandFraction by collectLastValue(appearanceViewModel.expandFraction) assertThat(expandFraction).isEqualTo(1f) fakeSceneDataSource.pause() - sceneInteractor.changeScene(SceneKey.QuickSettings, "reason") + sceneInteractor.changeScene(Scenes.QuickSettings, "reason") val transitionProgress = MutableStateFlow(0f) transitionState.value = ObservableTransitionState.Transition( - fromScene = SceneKey.Shade, - toScene = SceneKey.QuickSettings, + fromScene = Scenes.Shade, + toScene = Scenes.QuickSettings, progress = transitionProgress, isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), @@ -163,7 +163,7 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() { assertThat(expandFraction).isEqualTo(1f) } - fakeSceneDataSource.unpause(expectedScene = SceneKey.QuickSettings) + fakeSceneDataSource.unpause(expectedScene = Scenes.QuickSettings) assertThat(expandFraction).isEqualTo(1f) } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt index 7f5a658587f3..0de15b8db665 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt @@ -21,13 +21,13 @@ package com.android.systemui.statusbar.notification.stack.ui.viewmodel import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest +import com.android.compose.animation.scene.ObservableTransitionState import com.android.systemui.Flags.FLAG_CENTRALIZED_STATUS_BAR_HEIGHT_FIX import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.NotificationContainerBounds import com.android.systemui.common.ui.data.repository.fakeConfigurationRepository import com.android.systemui.communal.domain.interactor.communalInteractor -import com.android.systemui.communal.shared.model.CommunalSceneKey -import com.android.systemui.communal.shared.model.ObservableCommunalTransitionState +import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.Flags import com.android.systemui.flags.fakeFeatureFlagsClassic @@ -278,8 +278,8 @@ class SharedNotificationContainerViewModelTest : SysuiTestCase() { ) ) val idleTransitionState = - MutableStateFlow<ObservableCommunalTransitionState>( - ObservableCommunalTransitionState.Idle(CommunalSceneKey.Communal) + MutableStateFlow<ObservableTransitionState>( + ObservableTransitionState.Idle(CommunalScenes.Communal) ) communalInteractor.setTransitionState(idleTransitionState) runCurrent() @@ -391,8 +391,8 @@ class SharedNotificationContainerViewModelTest : SysuiTestCase() { // Move to glanceable hub val idleTransitionState = - MutableStateFlow<ObservableCommunalTransitionState>( - ObservableCommunalTransitionState.Idle(CommunalSceneKey.Communal) + MutableStateFlow<ObservableTransitionState>( + ObservableTransitionState.Idle(CommunalScenes.Communal) ) communalInteractor.setTransitionState(idleTransitionState) runCurrent() diff --git a/packages/SystemUI/src/com/android/systemui/communal/CommunalSceneStartable.kt b/packages/SystemUI/src/com/android/systemui/communal/CommunalSceneStartable.kt index 8397372e0735..d5cb4d5a6b2f 100644 --- a/packages/SystemUI/src/com/android/systemui/communal/CommunalSceneStartable.kt +++ b/packages/SystemUI/src/com/android/systemui/communal/CommunalSceneStartable.kt @@ -16,9 +16,10 @@ package com.android.systemui.communal +import com.android.compose.animation.scene.SceneKey import com.android.systemui.CoreStartable import com.android.systemui.communal.domain.interactor.CommunalInteractor -import com.android.systemui.communal.shared.model.CommunalSceneKey +import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Background @@ -74,7 +75,7 @@ constructor( .sample(keyguardTransitionInteractor.startedKeyguardState, ::Pair) .onEach { (docked, lastStartedState) -> if (docked && lastStartedState == KeyguardState.LOCKSCREEN) { - communalInteractor.onSceneChanged(CommunalSceneKey.Communal) + communalInteractor.onSceneChanged(CommunalScenes.Communal) } } .launchIn(bgScope) @@ -82,21 +83,21 @@ constructor( private suspend fun determineSceneAfterTransition( lastStartedTransition: TransitionStep, - ): CommunalSceneKey? { + ): SceneKey? { val to = lastStartedTransition.to val from = lastStartedTransition.from val docked = dockManager.isDocked return when { docked && to == KeyguardState.LOCKSCREEN && from != KeyguardState.GLANCEABLE_HUB -> { - CommunalSceneKey.Communal + CommunalScenes.Communal } - to == KeyguardState.GONE -> CommunalSceneKey.Blank + to == KeyguardState.GONE -> CommunalScenes.Blank !docked && !KeyguardState.deviceIsAwakeInState(to) -> { // If the user taps the screen and wakes the device within this timeout, we don't // want to dismiss the hub delay(AWAKE_DEBOUNCE_DELAY) - CommunalSceneKey.Blank + CommunalScenes.Blank } else -> null } diff --git a/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalRepository.kt b/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalRepository.kt index f4a3bcb7a0fa..201ce832cc41 100644 --- a/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalRepository.kt @@ -16,8 +16,9 @@ package com.android.systemui.communal.data.repository -import com.android.systemui.communal.shared.model.CommunalSceneKey -import com.android.systemui.communal.shared.model.ObservableCommunalTransitionState +import com.android.compose.animation.scene.ObservableTransitionState +import com.android.compose.animation.scene.SceneKey +import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.scene.data.repository.SceneContainerRepository @@ -40,20 +41,20 @@ interface CommunalRepository { * Target scene as requested by the underlying [SceneTransitionLayout] or through * [setDesiredScene]. */ - val desiredScene: StateFlow<CommunalSceneKey> + val desiredScene: StateFlow<SceneKey> /** Exposes the transition state of the communal [SceneTransitionLayout]. */ - val transitionState: StateFlow<ObservableCommunalTransitionState> + val transitionState: StateFlow<ObservableTransitionState> /** Updates the requested scene. */ - fun setDesiredScene(desiredScene: CommunalSceneKey) + fun setDesiredScene(desiredScene: SceneKey) /** * Updates the transition state of the hub [SceneTransitionLayout]. * * Note that you must call is with `null` when the UI is done or risk a memory leak. */ - fun setTransitionState(transitionState: Flow<ObservableCommunalTransitionState>?) + fun setTransitionState(transitionState: Flow<ObservableTransitionState>?) } @OptIn(ExperimentalCoroutinesApi::class) @@ -66,14 +67,12 @@ constructor( sceneContainerRepository: SceneContainerRepository, ) : CommunalRepository { - private val _desiredScene: MutableStateFlow<CommunalSceneKey> = - MutableStateFlow(CommunalSceneKey.DEFAULT) - override val desiredScene: StateFlow<CommunalSceneKey> = _desiredScene.asStateFlow() + private val _desiredScene: MutableStateFlow<SceneKey> = MutableStateFlow(CommunalScenes.Default) + override val desiredScene: StateFlow<SceneKey> = _desiredScene.asStateFlow() - private val defaultTransitionState = - ObservableCommunalTransitionState.Idle(CommunalSceneKey.DEFAULT) - private val _transitionState = MutableStateFlow<Flow<ObservableCommunalTransitionState>?>(null) - override val transitionState: StateFlow<ObservableCommunalTransitionState> = + private val defaultTransitionState = ObservableTransitionState.Idle(CommunalScenes.Default) + private val _transitionState = MutableStateFlow<Flow<ObservableTransitionState>?>(null) + override val transitionState: StateFlow<ObservableTransitionState> = _transitionState .flatMapLatest { innerFlowOrNull -> innerFlowOrNull ?: flowOf(defaultTransitionState) } .stateIn( @@ -82,7 +81,7 @@ constructor( initialValue = defaultTransitionState, ) - override fun setDesiredScene(desiredScene: CommunalSceneKey) { + override fun setDesiredScene(desiredScene: SceneKey) { _desiredScene.value = desiredScene } @@ -91,7 +90,7 @@ constructor( * * Note that you must call is with `null` when the UI is done or risk a memory leak. */ - override fun setTransitionState(transitionState: Flow<ObservableCommunalTransitionState>?) { + override fun setTransitionState(transitionState: Flow<ObservableTransitionState>?) { _transitionState.value = transitionState } } diff --git a/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalInteractor.kt b/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalInteractor.kt index 151e1eeaefc5..814295787b6c 100644 --- a/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalInteractor.kt @@ -19,6 +19,8 @@ package com.android.systemui.communal.domain.interactor import android.app.smartspace.SmartspaceTarget import android.content.ComponentName import android.os.UserHandle +import com.android.compose.animation.scene.ObservableTransitionState +import com.android.compose.animation.scene.SceneKey import com.android.systemui.communal.data.repository.CommunalMediaRepository import com.android.systemui.communal.data.repository.CommunalPrefsRepository import com.android.systemui.communal.data.repository.CommunalRepository @@ -29,9 +31,8 @@ import com.android.systemui.communal.shared.model.CommunalContentSize import com.android.systemui.communal.shared.model.CommunalContentSize.FULL import com.android.systemui.communal.shared.model.CommunalContentSize.HALF import com.android.systemui.communal.shared.model.CommunalContentSize.THIRD -import com.android.systemui.communal.shared.model.CommunalSceneKey +import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.communal.shared.model.CommunalWidgetContentModel -import com.android.systemui.communal.shared.model.ObservableCommunalTransitionState import com.android.systemui.communal.widgets.CommunalAppWidgetHost import com.android.systemui.communal.widgets.EditWidgetsActivityStarter import com.android.systemui.communal.widgets.WidgetConfigurator @@ -46,7 +47,7 @@ import com.android.systemui.log.table.TableLogBuffer import com.android.systemui.log.table.logDiffsForTable import com.android.systemui.scene.domain.interactor.SceneInteractor import com.android.systemui.scene.shared.flag.SceneContainerFlags -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.settings.UserTracker import com.android.systemui.smartspace.data.repository.SmartspaceRepository import com.android.systemui.util.kotlin.BooleanFlowOperators.and @@ -131,34 +132,33 @@ constructor( * Target scene as requested by the underlying [SceneTransitionLayout] or through * [onSceneChanged]. * - * If [isCommunalAvailable] is false, will return [CommunalSceneKey.Blank] + * If [isCommunalAvailable] is false, will return [CommunalScenes.Blank] */ - val desiredScene: Flow<CommunalSceneKey> = + val desiredScene: Flow<SceneKey> = communalRepository.desiredScene.combine(isCommunalAvailable) { scene, available -> - if (available) scene else CommunalSceneKey.Blank + if (available) scene else CommunalScenes.Blank } /** Transition state of the hub mode. */ - val transitionState: StateFlow<ObservableCommunalTransitionState> = - communalRepository.transitionState + val transitionState: StateFlow<ObservableTransitionState> = communalRepository.transitionState /** * Updates the transition state of the hub [SceneTransitionLayout]. * * Note that you must call is with `null` when the UI is done or risk a memory leak. */ - fun setTransitionState(transitionState: Flow<ObservableCommunalTransitionState>?) { + fun setTransitionState(transitionState: Flow<ObservableTransitionState>?) { communalRepository.setTransitionState(transitionState) } /** Returns a flow that tracks the progress of transitions to the given scene from 0-1. */ - fun transitionProgressToScene(targetScene: CommunalSceneKey) = + fun transitionProgressToScene(targetScene: SceneKey) = transitionState .flatMapLatest { state -> when (state) { - is ObservableCommunalTransitionState.Idle -> + is ObservableTransitionState.Idle -> flowOf(CommunalTransitionProgress.Idle(state.scene)) - is ObservableCommunalTransitionState.Transition -> + is ObservableTransitionState.Transition -> if (state.toScene == targetScene) { state.progress.map { CommunalTransitionProgress.Transition( @@ -176,7 +176,7 @@ constructor( /** * Flow that emits a boolean if the communal UI is the target scene, ie. the [desiredScene] is - * the [CommunalSceneKey.Communal]. + * the [CommunalScenes.Communal]. * * This will be true as soon as the desired scene is set programmatically or at whatever point * during a fling that SceneTransitionLayout determines that the end state will be the communal @@ -191,9 +191,9 @@ constructor( flow { emit(sceneContainerFlags.isEnabled()) } .flatMapLatest { sceneContainerEnabled -> if (sceneContainerEnabled) { - sceneInteractor.currentScene.map { it == SceneKey.Communal } + sceneInteractor.currentScene.map { it == Scenes.Communal } } else { - desiredScene.map { it == CommunalSceneKey.Communal } + desiredScene.map { it == CommunalScenes.Communal } } } .distinctUntilChanged() @@ -220,7 +220,7 @@ constructor( */ val isIdleOnCommunal: Flow<Boolean> = communalRepository.transitionState.map { - it is ObservableCommunalTransitionState.Idle && it.scene == CommunalSceneKey.Communal + it is ObservableTransitionState.Idle && it.scene == CommunalScenes.Communal } /** @@ -230,11 +230,11 @@ constructor( */ val isCommunalVisible: Flow<Boolean> = communalRepository.transitionState.map { - !(it is ObservableCommunalTransitionState.Idle && it.scene == CommunalSceneKey.Blank) + !(it is ObservableTransitionState.Idle && it.scene == CommunalScenes.Blank) } /** Callback received whenever the [SceneTransitionLayout] finishes a scene transition. */ - fun onSceneChanged(newScene: CommunalSceneKey) { + fun onSceneChanged(newScene: SceneKey) { communalRepository.setDesiredScene(newScene) } @@ -422,7 +422,7 @@ constructor( /** Simplified transition progress data class for tracking a single transition between scenes. */ sealed class CommunalTransitionProgress { /** No transition/animation is currently running. */ - data class Idle(val scene: CommunalSceneKey) : CommunalTransitionProgress() + data class Idle(val scene: SceneKey) : CommunalTransitionProgress() /** There is a transition animating to the expected scene. */ data class Transition( diff --git a/packages/SystemUI/src/com/android/systemui/communal/log/CommunalLoggerStartable.kt b/packages/SystemUI/src/com/android/systemui/communal/log/CommunalLoggerStartable.kt index 889023e8dab6..f2b473864a78 100644 --- a/packages/SystemUI/src/com/android/systemui/communal/log/CommunalLoggerStartable.kt +++ b/packages/SystemUI/src/com/android/systemui/communal/log/CommunalLoggerStartable.kt @@ -16,12 +16,12 @@ package com.android.systemui.communal.log +import com.android.compose.animation.scene.ObservableTransitionState import com.android.internal.logging.UiEventLogger import com.android.systemui.CoreStartable import com.android.systemui.communal.domain.interactor.CommunalInteractor import com.android.systemui.communal.shared.log.CommunalUiEvent -import com.android.systemui.communal.shared.model.CommunalSceneKey -import com.android.systemui.communal.shared.model.ObservableCommunalTransitionState +import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.util.kotlin.pairwise @@ -87,25 +87,25 @@ constructor( } /** Whether currently in communal scene. */ -private fun ObservableCommunalTransitionState.isOnCommunal(): Boolean { - return this is ObservableCommunalTransitionState.Idle && scene == CommunalSceneKey.Communal +private fun ObservableTransitionState.isOnCommunal(): Boolean { + return this is ObservableTransitionState.Idle && scene == CommunalScenes.Communal } /** Whether currently in a scene other than communal. */ -private fun ObservableCommunalTransitionState.isNotOnCommunal(): Boolean { - return this is ObservableCommunalTransitionState.Idle && scene != CommunalSceneKey.Communal +private fun ObservableTransitionState.isNotOnCommunal(): Boolean { + return this is ObservableTransitionState.Idle && scene != CommunalScenes.Communal } /** Whether currently transitioning from another scene to communal. */ -private fun ObservableCommunalTransitionState.isSwipingToCommunal(): Boolean { - return this is ObservableCommunalTransitionState.Transition && - toScene == CommunalSceneKey.Communal && +private fun ObservableTransitionState.isSwipingToCommunal(): Boolean { + return this is ObservableTransitionState.Transition && + toScene == CommunalScenes.Communal && isInitiatedByUserInput } /** Whether currently transitioning from communal to another scene. */ -private fun ObservableCommunalTransitionState.isSwipingFromCommunal(): Boolean { - return this is ObservableCommunalTransitionState.Transition && - fromScene == CommunalSceneKey.Communal && +private fun ObservableTransitionState.isSwipingFromCommunal(): Boolean { + return this is ObservableTransitionState.Transition && + fromScene == CommunalScenes.Communal && isInitiatedByUserInput } diff --git a/packages/SystemUI/src/com/android/systemui/communal/shared/model/CommunalSceneKey.kt b/packages/SystemUI/src/com/android/systemui/communal/shared/model/CommunalScenes.kt index c68dd4ff271c..d5a56c1e9ee0 100644 --- a/packages/SystemUI/src/com/android/systemui/communal/shared/model/CommunalSceneKey.kt +++ b/packages/SystemUI/src/com/android/systemui/communal/shared/model/CommunalScenes.kt @@ -16,21 +16,15 @@ package com.android.systemui.communal.shared.model -/** Definition of the possible scenes for the communal UI. */ -sealed class CommunalSceneKey( - private val loggingName: String, -) { - /** The communal scene containing the hub UI. */ - object Communal : CommunalSceneKey("communal") +import com.android.compose.animation.scene.SceneKey +/** Definition of the possible scenes for the communal UI. */ +object CommunalScenes { /** The default scene, shows nothing and is only there to allow swiping to communal. */ - object Blank : CommunalSceneKey("blank") + @JvmField val Blank = SceneKey("blank") - override fun toString(): String { - return loggingName - } + /** The communal scene containing the hub UI. */ + @JvmField val Communal = SceneKey("communal") - companion object { - val DEFAULT = Blank - } + @JvmField val Default = Blank } diff --git a/packages/SystemUI/src/com/android/systemui/communal/shared/model/ObservableCommunalTransitionState.kt b/packages/SystemUI/src/com/android/systemui/communal/shared/model/ObservableCommunalTransitionState.kt deleted file mode 100644 index d834715768c9..000000000000 --- a/packages/SystemUI/src/com/android/systemui/communal/shared/model/ObservableCommunalTransitionState.kt +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2023 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.communal.shared.model - -import kotlinx.coroutines.flow.Flow - -/** - * This is a fork of the `com.android.compose.animation.scene.ObservableTransitionState` class. - * - * TODO(b/315490861): remove this fork, once we can compile Compose into System UI. - */ -sealed class ObservableCommunalTransitionState { - /** No transition/animation is currently running. */ - data class Idle(val scene: CommunalSceneKey) : ObservableCommunalTransitionState() - - /** There is a transition animating between two scenes. */ - data class Transition( - val fromScene: CommunalSceneKey, - val toScene: CommunalSceneKey, - val progress: Flow<Float>, - - /** - * Whether the transition was originally triggered by user input rather than being - * programmatic. If this value is initially true, it will remain true until the transition - * fully completes, even if the user input that triggered the transition has ended. Any - * sub-transitions launched by this one will inherit this value. For example, if the user - * drags a pointer but does not exceed the threshold required to transition to another - * scene, this value will remain true after the pointer is no longer touching the screen and - * will be true in any transition created to animate back to the original position. - */ - val isInitiatedByUserInput: Boolean, - - /** - * Whether user input is currently driving the transition. For example, if a user is - * dragging a pointer, this emits true. Once they lift their finger, this emits false while - * the transition completes/settles. - */ - val isUserInputOngoing: Flow<Boolean>, - ) : ObservableCommunalTransitionState() -} diff --git a/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/BaseCommunalViewModel.kt b/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/BaseCommunalViewModel.kt index 3ec9a268f80c..35372cd28c15 100644 --- a/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/BaseCommunalViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/BaseCommunalViewModel.kt @@ -18,10 +18,10 @@ package com.android.systemui.communal.ui.viewmodel import android.content.ComponentName import android.os.UserHandle +import com.android.compose.animation.scene.ObservableTransitionState +import com.android.compose.animation.scene.SceneKey import com.android.systemui.communal.domain.interactor.CommunalInteractor import com.android.systemui.communal.domain.model.CommunalContentModel -import com.android.systemui.communal.shared.model.CommunalSceneKey -import com.android.systemui.communal.shared.model.ObservableCommunalTransitionState import com.android.systemui.communal.widgets.WidgetConfigurator import com.android.systemui.media.controls.ui.view.MediaHost import kotlinx.coroutines.flow.Flow @@ -34,7 +34,7 @@ abstract class BaseCommunalViewModel( private val communalInteractor: CommunalInteractor, val mediaHost: MediaHost, ) { - val currentScene: Flow<CommunalSceneKey> = communalInteractor.desiredScene + val currentScene: Flow<SceneKey> = communalInteractor.desiredScene /** Whether widgets are currently being re-ordered. */ open val reorderingWidgets: StateFlow<Boolean> = MutableStateFlow(false) @@ -45,7 +45,7 @@ abstract class BaseCommunalViewModel( val selectedKey: StateFlow<String?> get() = _selectedKey - fun onSceneChanged(scene: CommunalSceneKey) { + fun onSceneChanged(scene: SceneKey) { communalInteractor.onSceneChanged(scene) } @@ -54,7 +54,7 @@ abstract class BaseCommunalViewModel( * * Note that you must call is with `null` when the UI is done or risk a memory leak. */ - fun setTransitionState(transitionState: Flow<ObservableCommunalTransitionState>?) { + fun setTransitionState(transitionState: Flow<ObservableTransitionState>?) { communalInteractor.setTransitionState(transitionState) } diff --git a/packages/SystemUI/src/com/android/systemui/communal/widgets/EditWidgetsActivity.kt b/packages/SystemUI/src/com/android/systemui/communal/widgets/EditWidgetsActivity.kt index 48b3e4c3616d..b6ad26b24dc7 100644 --- a/packages/SystemUI/src/com/android/systemui/communal/widgets/EditWidgetsActivity.kt +++ b/packages/SystemUI/src/com/android/systemui/communal/widgets/EditWidgetsActivity.kt @@ -36,7 +36,7 @@ import com.android.compose.theme.LocalAndroidColorScheme import com.android.compose.theme.PlatformTheme import com.android.internal.logging.UiEventLogger import com.android.systemui.communal.shared.log.CommunalUiEvent -import com.android.systemui.communal.shared.model.CommunalSceneKey +import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.communal.ui.compose.CommunalHub import com.android.systemui.communal.ui.viewmodel.CommunalEditModeViewModel import com.android.systemui.communal.util.WidgetPickerIntentUtils.getWidgetExtraFromIntent @@ -173,7 +173,7 @@ constructor( private fun onEditDone() { try { - communalViewModel.onSceneChanged(CommunalSceneKey.Communal) + communalViewModel.onSceneChanged(CommunalScenes.Communal) checkNotNull(windowManagerService).lockNow(/* options */ null) finish() } catch (e: RemoteException) { diff --git a/packages/SystemUI/src/com/android/systemui/deviceentry/domain/interactor/DeviceEntryInteractor.kt b/packages/SystemUI/src/com/android/systemui/deviceentry/domain/interactor/DeviceEntryInteractor.kt index 21fd87c1c241..029a4f33cd27 100644 --- a/packages/SystemUI/src/com/android/systemui/deviceentry/domain/interactor/DeviceEntryInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/deviceentry/domain/interactor/DeviceEntryInteractor.kt @@ -25,7 +25,7 @@ import com.android.systemui.deviceentry.data.repository.DeviceEntryRepository import com.android.systemui.keyguard.data.repository.TrustRepository import com.android.systemui.scene.domain.interactor.SceneInteractor import com.android.systemui.scene.shared.flag.SceneContainerFlags -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -81,9 +81,9 @@ constructor( val isDeviceEntered: StateFlow<Boolean> = sceneInteractor.currentScene .filter { currentScene -> - currentScene == SceneKey.Gone || currentScene == SceneKey.Lockscreen + currentScene == Scenes.Gone || currentScene == Scenes.Lockscreen } - .map { it == SceneKey.Gone } + .map { it == Scenes.Gone } .stateIn( scope = applicationScope, started = SharingStarted.Eagerly, @@ -148,12 +148,12 @@ constructor( applicationScope.launch { if (isAuthenticationRequired()) { sceneInteractor.changeScene( - toScene = SceneKey.Bouncer, + toScene = Scenes.Bouncer, loggingReason = "request to unlock device while authentication required", ) } else { sceneInteractor.changeScene( - toScene = SceneKey.Gone, + toScene = Scenes.Gone, loggingReason = "request to unlock device while authentication isn't required", ) } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/GlanceableHubTransitions.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/GlanceableHubTransitions.kt index 6cb1eb493db3..744301019dfc 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/GlanceableHubTransitions.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/GlanceableHubTransitions.kt @@ -20,7 +20,7 @@ import android.animation.ValueAnimator import com.android.app.animation.Interpolators import com.android.systemui.communal.domain.interactor.CommunalInteractor import com.android.systemui.communal.domain.interactor.CommunalTransitionProgress -import com.android.systemui.communal.shared.model.CommunalSceneKey +import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.keyguard.data.repository.KeyguardTransitionRepository import com.android.systemui.keyguard.shared.model.KeyguardState @@ -55,9 +55,9 @@ constructor( ) { val toScene = if (fromState == KeyguardState.GLANCEABLE_HUB) { - CommunalSceneKey.Blank + CommunalScenes.Blank } else { - CommunalSceneKey.Communal + CommunalScenes.Communal } var transitionId: UUID? = null diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt index 8b06b85e70c9..fbf1e22ad3e1 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt @@ -42,7 +42,7 @@ import com.android.systemui.power.domain.interactor.PowerInteractor import com.android.systemui.res.R import com.android.systemui.scene.domain.interactor.SceneInteractor import com.android.systemui.scene.shared.flag.SceneContainerFlags -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.shade.data.repository.ShadeRepository import com.android.systemui.statusbar.CommandQueue import com.android.systemui.util.kotlin.sample @@ -288,7 +288,7 @@ constructor( sceneInteractorProvider .get() .transitioningTo - .map { it == SceneKey.Lockscreen } + .map { it == Scenes.Lockscreen } .distinctUntilChanged() .flatMapLatest { isTransitioningToLockscreenScene -> if (isTransitioningToLockscreenScene) { diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModel.kt index 9afe8fcd93d0..b60e99973348 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModel.kt @@ -16,11 +16,12 @@ package com.android.systemui.keyguard.ui.viewmodel +import com.android.compose.animation.scene.SceneKey import com.android.systemui.communal.domain.interactor.CommunalInteractor import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationsPlaceholderViewModel import javax.inject.Inject import kotlinx.coroutines.CoroutineScope @@ -51,13 +52,13 @@ constructor( ) private fun upDestinationSceneKey(isUnlocked: Boolean): SceneKey { - return if (isUnlocked) SceneKey.Gone else SceneKey.Bouncer + return if (isUnlocked) Scenes.Gone else Scenes.Bouncer } /** The key of the scene we should switch to when swiping left. */ val leftDestinationSceneKey: StateFlow<SceneKey?> = communalInteractor.isCommunalAvailable - .map { available -> if (available) SceneKey.Communal else null } + .map { available -> if (available) Scenes.Communal else null } .stateIn( scope = applicationScope, started = SharingStarted.WhileSubscribed(), diff --git a/packages/SystemUI/src/com/android/systemui/model/SceneContainerPlugin.kt b/packages/SystemUI/src/com/android/systemui/model/SceneContainerPlugin.kt index 6eb62263eb9a..e7b6e6373f1c 100644 --- a/packages/SystemUI/src/com/android/systemui/model/SceneContainerPlugin.kt +++ b/packages/SystemUI/src/com/android/systemui/model/SceneContainerPlugin.kt @@ -16,11 +16,12 @@ package com.android.systemui.model +import com.android.compose.animation.scene.ObservableTransitionState +import com.android.compose.animation.scene.SceneKey import com.android.systemui.dagger.SysUISingleton import com.android.systemui.scene.domain.interactor.SceneInteractor import com.android.systemui.scene.shared.flag.SceneContainerFlag -import com.android.systemui.scene.shared.model.ObservableTransitionState -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BOUNCER_SHOWING import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_VISIBLE @@ -67,11 +68,11 @@ constructor( */ val EvaluatorByFlag = mapOf<Int, (SceneKey) -> Boolean>( - SYSUI_STATE_NOTIFICATION_PANEL_VISIBLE to { it != SceneKey.Gone }, - SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED to { it == SceneKey.Shade }, - SYSUI_STATE_QUICK_SETTINGS_EXPANDED to { it == SceneKey.QuickSettings }, - SYSUI_STATE_BOUNCER_SHOWING to { it == SceneKey.Bouncer }, - SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING to { it == SceneKey.Lockscreen }, + SYSUI_STATE_NOTIFICATION_PANEL_VISIBLE to { it != Scenes.Gone }, + SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED to { it == Scenes.Shade }, + SYSUI_STATE_QUICK_SETTINGS_EXPANDED to { it == Scenes.QuickSettings }, + SYSUI_STATE_BOUNCER_SHOWING to { it == Scenes.Bouncer }, + SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING to { it == Scenes.Lockscreen }, ) } } diff --git a/packages/SystemUI/src/com/android/systemui/model/SysUiStateExt.kt b/packages/SystemUI/src/com/android/systemui/model/SysUiStateExt.kt index c74a71c52260..5c4915689f22 100644 --- a/packages/SystemUI/src/com/android/systemui/model/SysUiStateExt.kt +++ b/packages/SystemUI/src/com/android/systemui/model/SysUiStateExt.kt @@ -25,11 +25,11 @@ import com.android.systemui.dagger.qualifiers.DisplayId * ``` * sysuiState.updateFlags( * displayId, - * SYSUI_STATE_NOTIFICATION_PANEL_VISIBLE to (sceneKey != SceneKey.Gone), - * SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED to (sceneKey == SceneKey.Shade), - * SYSUI_STATE_QUICK_SETTINGS_EXPANDED to (sceneKey == SceneKey.QuickSettings), - * SYSUI_STATE_BOUNCER_SHOWING to (sceneKey == SceneKey.Bouncer), - * SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING to (sceneKey == SceneKey.Lockscreen), + * SYSUI_STATE_NOTIFICATION_PANEL_VISIBLE to (sceneKey != Scenes.Gone), + * SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED to (sceneKey == Scenes.Shade), + * SYSUI_STATE_QUICK_SETTINGS_EXPANDED to (sceneKey == Scenes.QuickSettings), + * SYSUI_STATE_BOUNCER_SHOWING to (sceneKey == Scenes.Bouncer), + * SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING to (sceneKey == Scenes.Lockscreen), * ) * ``` * diff --git a/packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsSceneViewModel.kt b/packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsSceneViewModel.kt index 17454a97f5d2..3aae91d25b74 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsSceneViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsSceneViewModel.kt @@ -17,14 +17,14 @@ package com.android.systemui.qs.ui.viewmodel import androidx.lifecycle.LifecycleOwner +import com.android.compose.animation.scene.UserActionResult import com.android.systemui.dagger.SysUISingleton import com.android.systemui.qs.FooterActionsController import com.android.systemui.qs.footer.ui.viewmodel.FooterActionsViewModel import com.android.systemui.qs.ui.adapter.QSSceneAdapter import com.android.systemui.scene.shared.model.Direction -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.UserAction -import com.android.systemui.scene.shared.model.UserActionResult import com.android.systemui.shade.ui.viewmodel.ShadeHeaderViewModel import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationsPlaceholderViewModel import java.util.concurrent.atomic.AtomicBoolean @@ -46,12 +46,12 @@ constructor( qsSceneAdapter.isCustomizing.map { customizing -> if (customizing) { mapOf<UserAction, UserActionResult>( - UserAction.Back to UserActionResult(SceneKey.QuickSettings) + UserAction.Back to UserActionResult(Scenes.QuickSettings) ) } else { mapOf( - UserAction.Back to UserActionResult(SceneKey.Shade), - UserAction.Swipe(Direction.UP) to UserActionResult(SceneKey.Shade), + UserAction.Back to UserActionResult(Scenes.Shade), + UserAction.Swipe(Direction.UP) to UserActionResult(Scenes.Shade), ) } } diff --git a/packages/SystemUI/src/com/android/systemui/scene/KeyguardlessSceneContainerFrameworkModule.kt b/packages/SystemUI/src/com/android/systemui/scene/KeyguardlessSceneContainerFrameworkModule.kt index 356eb858d78f..afd0746f4696 100644 --- a/packages/SystemUI/src/com/android/systemui/scene/KeyguardlessSceneContainerFrameworkModule.kt +++ b/packages/SystemUI/src/com/android/systemui/scene/KeyguardlessSceneContainerFrameworkModule.kt @@ -18,7 +18,7 @@ package com.android.systemui.scene import com.android.systemui.scene.shared.flag.SceneContainerFlagsModule import com.android.systemui.scene.shared.model.SceneContainerConfig -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import dagger.Module import dagger.Provides @@ -44,11 +44,11 @@ object KeyguardlessSceneContainerFrameworkModule { // last one is top-most. sceneKeys = listOf( - SceneKey.Gone, - SceneKey.QuickSettings, - SceneKey.Shade, + Scenes.Gone, + Scenes.QuickSettings, + Scenes.Shade, ), - initialSceneKey = SceneKey.Gone, + initialSceneKey = Scenes.Gone, ) } } diff --git a/packages/SystemUI/src/com/android/systemui/scene/SceneContainerFrameworkModule.kt b/packages/SystemUI/src/com/android/systemui/scene/SceneContainerFrameworkModule.kt index 7d2468b2f016..62b0914fab79 100644 --- a/packages/SystemUI/src/com/android/systemui/scene/SceneContainerFrameworkModule.kt +++ b/packages/SystemUI/src/com/android/systemui/scene/SceneContainerFrameworkModule.kt @@ -22,7 +22,7 @@ import com.android.systemui.scene.domain.interactor.WindowRootViewVisibilityInte import com.android.systemui.scene.domain.startable.SceneContainerStartable import com.android.systemui.scene.shared.flag.SceneContainerFlagsModule import com.android.systemui.scene.shared.model.SceneContainerConfig -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import dagger.Binds import dagger.Module import dagger.Provides @@ -67,14 +67,14 @@ interface SceneContainerFrameworkModule { // last one is top-most. sceneKeys = listOf( - SceneKey.Gone, - SceneKey.Communal, - SceneKey.Lockscreen, - SceneKey.Bouncer, - SceneKey.QuickSettings, - SceneKey.Shade, + Scenes.Gone, + Scenes.Communal, + Scenes.Lockscreen, + Scenes.Bouncer, + Scenes.QuickSettings, + Scenes.Shade, ), - initialSceneKey = SceneKey.Lockscreen, + initialSceneKey = Scenes.Lockscreen, ) } } diff --git a/packages/SystemUI/src/com/android/systemui/scene/ShadelessSceneContainerFrameworkModule.kt b/packages/SystemUI/src/com/android/systemui/scene/ShadelessSceneContainerFrameworkModule.kt index c10e51b68ba2..0665c9e1b802 100644 --- a/packages/SystemUI/src/com/android/systemui/scene/ShadelessSceneContainerFrameworkModule.kt +++ b/packages/SystemUI/src/com/android/systemui/scene/ShadelessSceneContainerFrameworkModule.kt @@ -18,7 +18,7 @@ package com.android.systemui.scene import com.android.systemui.scene.shared.flag.SceneContainerFlagsModule import com.android.systemui.scene.shared.model.SceneContainerConfig -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import dagger.Module import dagger.Provides @@ -44,11 +44,11 @@ object ShadelessSceneContainerFrameworkModule { // last one is top-most. sceneKeys = listOf( - SceneKey.Gone, - SceneKey.Lockscreen, - SceneKey.Bouncer, + Scenes.Gone, + Scenes.Lockscreen, + Scenes.Bouncer, ), - initialSceneKey = SceneKey.Lockscreen, + initialSceneKey = Scenes.Lockscreen, ) } } diff --git a/packages/SystemUI/src/com/android/systemui/scene/data/repository/SceneContainerRepository.kt b/packages/SystemUI/src/com/android/systemui/scene/data/repository/SceneContainerRepository.kt index e60dff183148..994b01216c22 100644 --- a/packages/SystemUI/src/com/android/systemui/scene/data/repository/SceneContainerRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/scene/data/repository/SceneContainerRepository.kt @@ -18,12 +18,12 @@ package com.android.systemui.scene.data.repository +import com.android.compose.animation.scene.ObservableTransitionState +import com.android.compose.animation.scene.SceneKey +import com.android.compose.animation.scene.TransitionKey import com.android.systemui.dagger.qualifiers.Application -import com.android.systemui.scene.shared.model.ObservableTransitionState import com.android.systemui.scene.shared.model.SceneContainerConfig import com.android.systemui.scene.shared.model.SceneDataSource -import com.android.systemui.scene.shared.model.SceneKey -import com.android.systemui.scene.shared.model.TransitionKey import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/packages/SystemUI/src/com/android/systemui/scene/domain/interactor/PanelExpansionInteractor.kt b/packages/SystemUI/src/com/android/systemui/scene/domain/interactor/PanelExpansionInteractor.kt index 36350f8af455..3a5ea5c6a064 100644 --- a/packages/SystemUI/src/com/android/systemui/scene/domain/interactor/PanelExpansionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/scene/domain/interactor/PanelExpansionInteractor.kt @@ -18,10 +18,11 @@ package com.android.systemui.scene.domain.interactor +import com.android.compose.animation.scene.ObservableTransitionState +import com.android.compose.animation.scene.SceneKey import com.android.systemui.dagger.SysUISingleton import com.android.systemui.scene.shared.flag.SceneContainerFlag -import com.android.systemui.scene.shared.model.ObservableTransitionState -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.shade.data.repository.ShadeRepository import javax.inject.Inject import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -53,7 +54,7 @@ constructor( when (state) { is ObservableTransitionState.Idle -> flowOf( - if (state.scene != SceneKey.Gone) { + if (state.scene != Scenes.Gone) { // When resting on a non-Gone scene, the panel is fully expanded. 1f } else { @@ -64,7 +65,7 @@ constructor( ) is ObservableTransitionState.Transition -> when { - state.fromScene == SceneKey.Gone -> + state.fromScene == Scenes.Gone -> if (state.toScene.isExpandable()) { // Moving from Gone to a scene that can animate-expand has a // panel @@ -77,7 +78,7 @@ constructor( // the panel fully expanded. flowOf(1f) } - state.toScene == SceneKey.Gone -> + state.toScene == Scenes.Gone -> if (state.fromScene.isExpandable()) { // Moving to Gone from a scene that can animate-expand has a // panel @@ -99,6 +100,6 @@ constructor( } private fun SceneKey.isExpandable(): Boolean { - return this == SceneKey.Shade || this == SceneKey.QuickSettings + return this == Scenes.Shade || this == Scenes.QuickSettings } } diff --git a/packages/SystemUI/src/com/android/systemui/scene/domain/interactor/SceneInteractor.kt b/packages/SystemUI/src/com/android/systemui/scene/domain/interactor/SceneInteractor.kt index 6b7c672fbfe0..306aad131624 100644 --- a/packages/SystemUI/src/com/android/systemui/scene/domain/interactor/SceneInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/scene/domain/interactor/SceneInteractor.kt @@ -16,14 +16,15 @@ package com.android.systemui.scene.domain.interactor +import com.android.compose.animation.scene.ObservableTransitionState +import com.android.compose.animation.scene.SceneKey +import com.android.compose.animation.scene.TransitionKey import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.deviceentry.domain.interactor.DeviceUnlockedInteractor import com.android.systemui.scene.data.repository.SceneContainerRepository import com.android.systemui.scene.shared.logger.SceneLogger -import com.android.systemui.scene.shared.model.ObservableTransitionState -import com.android.systemui.scene.shared.model.SceneKey -import com.android.systemui.scene.shared.model.TransitionKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.util.kotlin.pairwiseBy import javax.inject.Inject import kotlinx.coroutines.CoroutineScope @@ -160,7 +161,7 @@ constructor( loggingReason: String, transitionKey: TransitionKey? = null, ) { - check(toScene != SceneKey.Gone || deviceUnlockedInteractor.isDeviceUnlocked.value) { + check(toScene != Scenes.Gone || deviceUnlockedInteractor.isDeviceUnlocked.value) { "Cannot change to the Gone scene while the device is locked. Logging reason for scene" + " change was: $loggingReason" } diff --git a/packages/SystemUI/src/com/android/systemui/scene/domain/interactor/WindowRootViewVisibilityInteractor.kt b/packages/SystemUI/src/com/android/systemui/scene/domain/interactor/WindowRootViewVisibilityInteractor.kt index 1c37908235bd..c736707ecd2d 100644 --- a/packages/SystemUI/src/com/android/systemui/scene/domain/interactor/WindowRootViewVisibilityInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/scene/domain/interactor/WindowRootViewVisibilityInteractor.kt @@ -16,6 +16,7 @@ package com.android.systemui.scene.domain.interactor +import com.android.compose.animation.scene.ObservableTransitionState import com.android.systemui.CoreStartable import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application @@ -24,8 +25,7 @@ import com.android.systemui.keyguard.shared.model.StatusBarState import com.android.systemui.power.domain.interactor.PowerInteractor import com.android.systemui.scene.data.repository.WindowRootViewVisibilityRepository import com.android.systemui.scene.shared.flag.SceneContainerFlags -import com.android.systemui.scene.shared.model.ObservableTransitionState -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.statusbar.NotificationPresenter import com.android.systemui.statusbar.notification.domain.interactor.ActiveNotificationsInteractor import com.android.systemui.statusbar.notification.init.NotificationsController @@ -77,12 +77,12 @@ constructor( .map { state -> when (state) { is ObservableTransitionState.Idle -> - state.scene == SceneKey.Shade || state.scene == SceneKey.Lockscreen + state.scene == Scenes.Shade || state.scene == Scenes.Lockscreen is ObservableTransitionState.Transition -> - state.toScene == SceneKey.Shade || - state.toScene == SceneKey.Lockscreen || - state.fromScene == SceneKey.Shade || - state.fromScene == SceneKey.Lockscreen + state.toScene == Scenes.Shade || + state.toScene == Scenes.Lockscreen || + state.fromScene == Scenes.Shade || + state.fromScene == Scenes.Lockscreen } } .distinctUntilChanged() diff --git a/packages/SystemUI/src/com/android/systemui/scene/domain/startable/SceneContainerStartable.kt b/packages/SystemUI/src/com/android/systemui/scene/domain/startable/SceneContainerStartable.kt index 034f87f4c72f..6df57edd34c3 100644 --- a/packages/SystemUI/src/com/android/systemui/scene/domain/startable/SceneContainerStartable.kt +++ b/packages/SystemUI/src/com/android/systemui/scene/domain/startable/SceneContainerStartable.kt @@ -19,6 +19,8 @@ package com.android.systemui.scene.domain.startable import android.app.StatusBarManager +import com.android.compose.animation.scene.ObservableTransitionState +import com.android.compose.animation.scene.SceneKey import com.android.systemui.CoreStartable import com.android.systemui.authentication.domain.interactor.AuthenticationInteractor import com.android.systemui.authentication.shared.model.AuthenticationMethodModel @@ -41,8 +43,7 @@ import com.android.systemui.power.domain.interactor.PowerInteractor import com.android.systemui.scene.domain.interactor.SceneInteractor import com.android.systemui.scene.shared.flag.SceneContainerFlags import com.android.systemui.scene.shared.logger.SceneLogger -import com.android.systemui.scene.shared.model.ObservableTransitionState -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.statusbar.NotificationShadeWindowController import com.android.systemui.statusbar.notification.domain.interactor.HeadsUpNotificationInteractor import com.android.systemui.statusbar.notification.stack.shared.flexiNotifsEnabled @@ -140,14 +141,14 @@ constructor( .mapNotNull { state -> when (state) { is ObservableTransitionState.Idle -> { - if (state.scene != SceneKey.Gone) { + if (state.scene != Scenes.Gone) { true to "scene is not Gone" } else { false to "scene is Gone" } } is ObservableTransitionState.Transition -> { - if (state.fromScene == SceneKey.Gone) { + if (state.fromScene == Scenes.Gone) { true to "scene transitioning away from Gone" } else { null @@ -180,9 +181,9 @@ constructor( applicationScope.launch { // TODO (b/308001302): Move this to a bouncer specific interactor. bouncerInteractor.onImeHiddenByUser.collectLatest { - if (sceneInteractor.currentScene.value == SceneKey.Bouncer) { + if (sceneInteractor.currentScene.value == Scenes.Bouncer) { sceneInteractor.changeScene( - toScene = SceneKey.Lockscreen, + toScene = Scenes.Lockscreen, loggingReason = "IME hidden", ) } @@ -196,13 +197,13 @@ constructor( when { isAnySimLocked -> { switchToScene( - targetSceneKey = SceneKey.Bouncer, + targetSceneKey = Scenes.Bouncer, loggingReason = "Need to authenticate locked SIM card." ) } isUnlocked && canSwipeToEnter == false -> { switchToScene( - targetSceneKey = SceneKey.Gone, + targetSceneKey = Scenes.Gone, loggingReason = "All SIM cards unlocked and device already" + " unlocked and lockscreen doesn't require a swipe to dismiss." @@ -210,7 +211,7 @@ constructor( } else -> { switchToScene( - targetSceneKey = SceneKey.Lockscreen, + targetSceneKey = Scenes.Lockscreen, loggingReason = "All SIM cards unlocked and device still locked" + " or lockscreen still requires a swipe to dismiss." @@ -231,8 +232,8 @@ constructor( transitionState.toScene, ) } - val isOnLockscreen = renderedScenes.contains(SceneKey.Lockscreen) - val isOnBouncer = renderedScenes.contains(SceneKey.Bouncer) + val isOnLockscreen = renderedScenes.contains(Scenes.Lockscreen) + val isOnBouncer = renderedScenes.contains(Scenes.Bouncer) if (!isUnlocked) { return@mapNotNull if (isOnLockscreen || isOnBouncer) { // Already on lockscreen or bouncer, no need to change scenes. @@ -240,7 +241,7 @@ constructor( } else { // The device locked while on a scene that's not Lockscreen or Bouncer, // go to Lockscreen. - SceneKey.Lockscreen to + Scenes.Lockscreen to "device locked in non-Lockscreen and non-Bouncer scene" } } @@ -250,7 +251,7 @@ constructor( when { isOnBouncer -> // When the device becomes unlocked in Bouncer, go to Gone. - SceneKey.Gone to "device was unlocked in Bouncer scene" + Scenes.Gone to "device was unlocked in Bouncer scene" isOnLockscreen -> // The lockscreen should be dismissed automatically in 2 scenarios: // 1. When face auth bypass is enabled and authentication happens while @@ -262,11 +263,11 @@ constructor( // authentication attempt. when { isBypassEnabled -> - SceneKey.Gone to + Scenes.Gone to "device has been unlocked on lockscreen with bypass" + " enabled" canSwipeToEnter == false -> - SceneKey.Gone to + Scenes.Gone to "device has been unlocked on lockscreen using an active" + " authentication mechanism" else -> null @@ -287,7 +288,7 @@ constructor( powerInteractor.isAsleep.collect { isAsleep -> if (isAsleep) { switchToScene( - targetSceneKey = SceneKey.Lockscreen, + targetSceneKey = Scenes.Lockscreen, loggingReason = "device is starting to sleep", ) } else { @@ -295,7 +296,7 @@ constructor( val isUnlocked = deviceEntryInteractor.isUnlocked.value if (isUnlocked && canSwipeToEnter == false) { switchToScene( - targetSceneKey = SceneKey.Gone, + targetSceneKey = Scenes.Gone, loggingReason = "device is waking up while unlocked without the ability" + " to swipe up on lockscreen to enter.", @@ -305,7 +306,7 @@ constructor( AuthenticationMethodModel.Sim ) { switchToScene( - targetSceneKey = SceneKey.Bouncer, + targetSceneKey = Scenes.Bouncer, loggingReason = "device is starting to wake up with a locked sim" ) } @@ -370,7 +371,7 @@ constructor( applicationScope.launch { sceneInteractor.currentScene - .map { it == SceneKey.Bouncer } + .map { it == Scenes.Bouncer } .distinctUntilChanged() .collect { switchedToBouncerScene -> if (switchedToBouncerScene) { @@ -390,7 +391,7 @@ constructor( falsingManager.addFalsingBeliefListener(listener) awaitClose { falsingManager.removeFalsingBeliefListener(listener) } } - .collect { switchToScene(SceneKey.Lockscreen, "Falsing detected.") } + .collect { switchToScene(Scenes.Lockscreen, "Falsing detected.") } } } @@ -403,7 +404,7 @@ constructor( } .distinctUntilChanged() .collect { sceneKey -> - windowController.setNotificationShadeFocusable(sceneKey != SceneKey.Gone) + windowController.setNotificationShadeFocusable(sceneKey != Scenes.Gone) } } } @@ -427,9 +428,9 @@ constructor( // // This is done here in order to match the legacy // implementation. The real reason why is lost to lore and myth. - SceneKey.Lockscreen -> true - SceneKey.Bouncer -> false - SceneKey.Shade -> false + Scenes.Lockscreen -> true + Scenes.Bouncer -> false + Scenes.Shade -> false else -> null } } diff --git a/packages/SystemUI/src/com/android/systemui/scene/shared/logger/SceneLogger.kt b/packages/SystemUI/src/com/android/systemui/scene/shared/logger/SceneLogger.kt index cbf7b3e7a971..f44779ade8db 100644 --- a/packages/SystemUI/src/com/android/systemui/scene/shared/logger/SceneLogger.kt +++ b/packages/SystemUI/src/com/android/systemui/scene/shared/logger/SceneLogger.kt @@ -16,10 +16,10 @@ package com.android.systemui.scene.shared.logger +import com.android.compose.animation.scene.SceneKey import com.android.systemui.log.LogBuffer import com.android.systemui.log.core.LogLevel import com.android.systemui.log.dagger.SceneFrameworkLog -import com.android.systemui.scene.shared.model.SceneKey import javax.inject.Inject class SceneLogger @Inject constructor(@SceneFrameworkLog private val logBuffer: LogBuffer) { diff --git a/packages/SystemUI/src/com/android/systemui/scene/shared/model/ObservableTransitionState.kt b/packages/SystemUI/src/com/android/systemui/scene/shared/model/ObservableTransitionState.kt deleted file mode 100644 index f704894e56e2..000000000000 --- a/packages/SystemUI/src/com/android/systemui/scene/shared/model/ObservableTransitionState.kt +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2023 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.scene.shared.model - -import kotlinx.coroutines.flow.Flow - -/** - * This is a fork of a class by the same name in the `com.android.compose.animation.scene` package. - * - * TODO(b/293899074): remove this fork, once we can compile Compose into System UI. - */ -sealed class ObservableTransitionState { - /** No transition/animation is currently running. */ - data class Idle(val scene: SceneKey) : ObservableTransitionState() - - /** There is a transition animating between two scenes. */ - data class Transition( - val fromScene: SceneKey, - val toScene: SceneKey, - val progress: Flow<Float>, - - /** - * Whether the transition was originally triggered by user input rather than being - * programmatic. If this value is initially true, it will remain true until the transition - * fully completes, even if the user input that triggered the transition has ended. Any - * sub-transitions launched by this one will inherit this value. For example, if the user - * drags a pointer but does not exceed the threshold required to transition to another - * scene, this value will remain true after the pointer is no longer touching the screen and - * will be true in any transition created to animate back to the original position. - */ - val isInitiatedByUserInput: Boolean, - - /** - * Whether user input is currently driving the transition. For example, if a user is - * dragging a pointer, this emits true. Once they lift their finger, this emits false while - * the transition completes/settles. - */ - val isUserInputOngoing: Flow<Boolean>, - ) : ObservableTransitionState() -} diff --git a/packages/SystemUI/src/com/android/systemui/scene/shared/model/Scene.kt b/packages/SystemUI/src/com/android/systemui/scene/shared/model/Scene.kt index 05056c133ca3..2a7c23c873b8 100644 --- a/packages/SystemUI/src/com/android/systemui/scene/shared/model/Scene.kt +++ b/packages/SystemUI/src/com/android/systemui/scene/shared/model/Scene.kt @@ -16,6 +16,8 @@ package com.android.systemui.scene.shared.model +import com.android.compose.animation.scene.SceneKey +import com.android.compose.animation.scene.UserActionResult import kotlinx.coroutines.flow.StateFlow /** diff --git a/packages/SystemUI/src/com/android/systemui/scene/shared/model/SceneContainerConfig.kt b/packages/SystemUI/src/com/android/systemui/scene/shared/model/SceneContainerConfig.kt index 8204edc33fe4..53cdaaab7478 100644 --- a/packages/SystemUI/src/com/android/systemui/scene/shared/model/SceneContainerConfig.kt +++ b/packages/SystemUI/src/com/android/systemui/scene/shared/model/SceneContainerConfig.kt @@ -16,6 +16,8 @@ package com.android.systemui.scene.shared.model +import com.android.compose.animation.scene.SceneKey + /** Models the configuration of the scene container. */ data class SceneContainerConfig( diff --git a/packages/SystemUI/src/com/android/systemui/scene/shared/model/SceneDataSource.kt b/packages/SystemUI/src/com/android/systemui/scene/shared/model/SceneDataSource.kt index f7b45e547b7f..0e078d5d8064 100644 --- a/packages/SystemUI/src/com/android/systemui/scene/shared/model/SceneDataSource.kt +++ b/packages/SystemUI/src/com/android/systemui/scene/shared/model/SceneDataSource.kt @@ -16,6 +16,8 @@ package com.android.systemui.scene.shared.model +import com.android.compose.animation.scene.SceneKey +import com.android.compose.animation.scene.TransitionKey import kotlinx.coroutines.flow.StateFlow /** Defines interface for classes that provide access to scene state. */ diff --git a/packages/SystemUI/src/com/android/systemui/scene/shared/model/SceneDataSourceDelegator.kt b/packages/SystemUI/src/com/android/systemui/scene/shared/model/SceneDataSourceDelegator.kt index a50830c1f212..69dce83b7136 100644 --- a/packages/SystemUI/src/com/android/systemui/scene/shared/model/SceneDataSourceDelegator.kt +++ b/packages/SystemUI/src/com/android/systemui/scene/shared/model/SceneDataSourceDelegator.kt @@ -18,6 +18,8 @@ package com.android.systemui.scene.shared.model +import com.android.compose.animation.scene.SceneKey +import com.android.compose.animation.scene.TransitionKey import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import javax.inject.Inject diff --git a/packages/SystemUI/src/com/android/systemui/scene/shared/model/SceneKey.kt b/packages/SystemUI/src/com/android/systemui/scene/shared/model/Scenes.kt index 609d2b93a36e..73fcca8c6b7f 100644 --- a/packages/SystemUI/src/com/android/systemui/scene/shared/model/SceneKey.kt +++ b/packages/SystemUI/src/com/android/systemui/scene/shared/model/Scenes.kt @@ -16,41 +16,37 @@ package com.android.systemui.scene.shared.model +import com.android.compose.animation.scene.SceneKey + /** * Keys of all known scenes. * * PLEASE KEEP THE KEYS SORTED ALPHABETICALLY. */ -sealed class SceneKey( - private val loggingName: String, -) { +object Scenes { /** * The bouncer is the scene that displays authentication challenges like PIN, password, or * pattern. */ - object Bouncer : SceneKey("bouncer") + @JvmField val Bouncer = SceneKey("bouncer") /** The communal scene shows the glanceable hub when device is locked and docked. */ - object Communal : SceneKey("communal") + @JvmField val Communal = SceneKey("communal") /** * "Gone" is not a real scene but rather the absence of scenes when we want to skip showing any * content from the scene framework. */ - object Gone : SceneKey("gone") + @JvmField val Gone = SceneKey("gone") /** The lockscreen is the scene that shows when the device is locked. */ - object Lockscreen : SceneKey("lockscreen") + @JvmField val Lockscreen = SceneKey("lockscreen") /** The quick settings scene shows the quick setting tiles. */ - object QuickSettings : SceneKey("quick_settings") + @JvmField val QuickSettings = SceneKey("quick_settings") /** * The shade is the scene whose primary purpose is to show a scrollable list of notifications. */ - object Shade : SceneKey("shade") - - override fun toString(): String { - return loggingName - } + @JvmField val Shade = SceneKey("shade") } diff --git a/packages/SystemUI/src/com/android/systemui/scene/shared/model/TransitionKey.kt b/packages/SystemUI/src/com/android/systemui/scene/shared/model/TransitionKey.kt deleted file mode 100644 index 87332ae8e084..000000000000 --- a/packages/SystemUI/src/com/android/systemui/scene/shared/model/TransitionKey.kt +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2024 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.scene.shared.model - -/** - * Key for a transition. This can be used to specify which transition spec should be used when - * starting the transition between two scenes. - */ -data class TransitionKey( - val debugName: String, - val identity: Any = Object(), -) diff --git a/packages/SystemUI/src/com/android/systemui/scene/shared/model/TransitionKeys.kt b/packages/SystemUI/src/com/android/systemui/scene/shared/model/TransitionKeys.kt index 926878c1870e..b91dd0451808 100644 --- a/packages/SystemUI/src/com/android/systemui/scene/shared/model/TransitionKeys.kt +++ b/packages/SystemUI/src/com/android/systemui/scene/shared/model/TransitionKeys.kt @@ -16,6 +16,8 @@ package com.android.systemui.scene.shared.model +import com.android.compose.animation.scene.TransitionKey + /** * Defines all known named transitions. * diff --git a/packages/SystemUI/src/com/android/systemui/scene/shared/model/UserActionResult.kt b/packages/SystemUI/src/com/android/systemui/scene/shared/model/UserActionResult.kt deleted file mode 100644 index c6ae21505c68..000000000000 --- a/packages/SystemUI/src/com/android/systemui/scene/shared/model/UserActionResult.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2024 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.scene.shared.model - -data class UserActionResult( - - /** The scene we should be transitioning due to the [UserAction]. */ - val toScene: SceneKey, - - /** - * The key of the transition that should be used, if a specific one should be used. - * - * If `null`, the transition used will be the corresponding transition from the collection - * passed into the UI layer. - */ - val transitionKey: TransitionKey? = null, -) diff --git a/packages/SystemUI/src/com/android/systemui/scene/ui/view/SceneWindowRootViewBinder.kt b/packages/SystemUI/src/com/android/systemui/scene/ui/view/SceneWindowRootViewBinder.kt index f2697b4e1c1e..7c31ca269eb9 100644 --- a/packages/SystemUI/src/com/android/systemui/scene/ui/view/SceneWindowRootViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/scene/ui/view/SceneWindowRootViewBinder.kt @@ -31,6 +31,7 @@ import androidx.core.view.isVisible import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope import androidx.lifecycle.repeatOnLifecycle +import com.android.compose.animation.scene.SceneKey import com.android.compose.theme.PlatformTheme import com.android.internal.policy.ScreenDecorationsUtils import com.android.systemui.common.ui.compose.windowinsets.CutoutLocation @@ -42,7 +43,6 @@ import com.android.systemui.scene.shared.flag.SceneContainerFlags import com.android.systemui.scene.shared.model.Scene import com.android.systemui.scene.shared.model.SceneContainerConfig import com.android.systemui.scene.shared.model.SceneDataSourceDelegator -import com.android.systemui.scene.shared.model.SceneKey import com.android.systemui.scene.ui.composable.ComposableScene import com.android.systemui.scene.ui.composable.SceneContainer import com.android.systemui.scene.ui.viewmodel.SceneContainerViewModel diff --git a/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModel.kt b/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModel.kt index 91861aa5c29a..231b28424691 100644 --- a/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModel.kt @@ -17,13 +17,14 @@ package com.android.systemui.scene.ui.viewmodel import android.view.MotionEvent +import com.android.compose.animation.scene.ObservableTransitionState +import com.android.compose.animation.scene.SceneKey import com.android.systemui.classifier.Classifier import com.android.systemui.classifier.domain.interactor.FalsingInteractor import com.android.systemui.dagger.SysUISingleton import com.android.systemui.power.domain.interactor.PowerInteractor import com.android.systemui.scene.domain.interactor.SceneInteractor -import com.android.systemui.scene.shared.model.ObservableTransitionState -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import javax.inject.Inject import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.StateFlow @@ -96,10 +97,10 @@ constructor( fun canChangeScene(toScene: SceneKey): Boolean { val interactionTypeOrNull = when (toScene) { - SceneKey.Bouncer -> Classifier.BOUNCER_UNLOCK - SceneKey.Gone -> Classifier.UNLOCK - SceneKey.Shade -> Classifier.NOTIFICATION_DRAG_DOWN - SceneKey.QuickSettings -> Classifier.QUICK_SETTINGS + Scenes.Bouncer -> Classifier.BOUNCER_UNLOCK + Scenes.Gone -> Classifier.UNLOCK + Scenes.Shade -> Classifier.NOTIFICATION_DRAG_DOWN + Scenes.QuickSettings -> Classifier.QUICK_SETTINGS else -> null } @@ -109,7 +110,7 @@ constructor( val isFalseTouch = falsingInteractor.isFalseTouch(interactionType) // Only enforce falsing if moving from the lockscreen scene to a new scene. - val fromLockscreenScene = currentScene.value == SceneKey.Lockscreen + val fromLockscreenScene = currentScene.value == Scenes.Lockscreen !fromLockscreenScene || !isFalseTouch } diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerSceneImpl.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerSceneImpl.kt index efd9ce0d08b2..27168a799086 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerSceneImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerSceneImpl.kt @@ -17,6 +17,7 @@ package com.android.systemui.shade import android.view.MotionEvent +import com.android.compose.animation.scene.SceneKey import com.android.systemui.assist.AssistManager import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Background @@ -25,7 +26,7 @@ import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor import com.android.systemui.log.LogBuffer import com.android.systemui.log.dagger.ShadeTouchLog import com.android.systemui.scene.domain.interactor.SceneInteractor -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.TransitionKeys.CollapseShadeInstantly import com.android.systemui.scene.shared.model.TransitionKeys.SlightlyFasterShadeCollapse import com.android.systemui.shade.ShadeController.ShadeVisibilityListener @@ -121,7 +122,7 @@ constructor( // release focus immediately to kick off focus change transition notificationShadeWindowController.setNotificationShadeFocusable(false) notificationStackScrollLayout.cancelExpandHelper() - sceneInteractor.changeScene(SceneKey.Shade, "ShadeController.animateExpandShade") + sceneInteractor.changeScene(Scenes.Shade, "ShadeController.animateExpandShade") if (delayed) { scope.launch { delay(125) @@ -148,9 +149,9 @@ constructor( private fun getCollapseDestinationScene(): SceneKey { return if (deviceEntryInteractor.isDeviceEntered.value) { - SceneKey.Gone + Scenes.Gone } else { - SceneKey.Lockscreen + Scenes.Lockscreen } } @@ -188,11 +189,11 @@ constructor( } override fun expandToNotifications() { - sceneInteractor.changeScene(SceneKey.Shade, "ShadeController.animateExpandShade") + sceneInteractor.changeScene(Scenes.Shade, "ShadeController.animateExpandShade") } override fun expandToQs() { - sceneInteractor.changeScene(SceneKey.QuickSettings, "ShadeController.animateExpandQs") + sceneInteractor.changeScene(Scenes.QuickSettings, "ShadeController.animateExpandQs") } override fun setVisibilityListener(listener: ShadeVisibilityListener) { @@ -242,7 +243,7 @@ constructor( } override fun isExpandedVisible(): Boolean { - return sceneInteractor.currentScene.value != SceneKey.Gone + return sceneInteractor.currentScene.value != Scenes.Gone } override fun onStatusBarTouch(event: MotionEvent) { diff --git a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeAnimationInteractorSceneContainerImpl.kt b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeAnimationInteractorSceneContainerImpl.kt index 1ee6d3845553..eaac8ae9dd3a 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeAnimationInteractorSceneContainerImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeAnimationInteractorSceneContainerImpl.kt @@ -16,10 +16,10 @@ package com.android.systemui.shade.domain.interactor +import com.android.compose.animation.scene.ObservableTransitionState import com.android.systemui.dagger.SysUISingleton import com.android.systemui.scene.domain.interactor.SceneInteractor -import com.android.systemui.scene.shared.model.ObservableTransitionState -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.shade.data.repository.ShadeAnimationRepository import javax.inject.Inject import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -44,10 +44,10 @@ constructor( is ObservableTransitionState.Idle -> flowOf(false) is ObservableTransitionState.Transition -> if ( - (state.fromScene == SceneKey.Shade && - state.toScene != SceneKey.QuickSettings) || - (state.fromScene == SceneKey.QuickSettings && - state.toScene != SceneKey.Shade) + (state.fromScene == Scenes.Shade && + state.toScene != Scenes.QuickSettings) || + (state.fromScene == Scenes.QuickSettings && + state.toScene != Scenes.Shade) ) { state.isUserInputOngoing.map { !it } } else { diff --git a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeBackActionInteractorImpl.kt b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeBackActionInteractorImpl.kt index a2e25983e68f..3a8ba7a0696b 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeBackActionInteractorImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeBackActionInteractorImpl.kt @@ -18,7 +18,7 @@ package com.android.systemui.shade.domain.interactor import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor import com.android.systemui.scene.domain.interactor.SceneInteractor -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import javax.inject.Inject import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -36,12 +36,12 @@ constructor( val key = if (fullyCollapse) { if (deviceEntryInteractor.isDeviceEntered.value) { - SceneKey.Gone + Scenes.Gone } else { - SceneKey.Lockscreen + Scenes.Lockscreen } } else { - SceneKey.Shade + Scenes.Shade } sceneInteractor.changeScene(key, "animateCollapseQs") } diff --git a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractorSceneContainerImpl.kt b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractorSceneContainerImpl.kt index 08f2c402f9e9..67cac3d4111c 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractorSceneContainerImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractorSceneContainerImpl.kt @@ -16,11 +16,12 @@ package com.android.systemui.shade.domain.interactor +import com.android.compose.animation.scene.ObservableTransitionState +import com.android.compose.animation.scene.SceneKey import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.scene.domain.interactor.SceneInteractor -import com.android.systemui.scene.shared.model.ObservableTransitionState -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.statusbar.notification.stack.domain.interactor.SharedNotificationContainerInteractor import javax.inject.Inject import kotlinx.coroutines.CoroutineScope @@ -45,9 +46,9 @@ constructor( sceneInteractor: SceneInteractor, sharedNotificationContainerInteractor: SharedNotificationContainerInteractor, ) : BaseShadeInteractor { - override val shadeExpansion: Flow<Float> = sceneBasedExpansion(sceneInteractor, SceneKey.Shade) + override val shadeExpansion: Flow<Float> = sceneBasedExpansion(sceneInteractor, Scenes.Shade) - private val sceneBasedQsExpansion = sceneBasedExpansion(sceneInteractor, SceneKey.QuickSettings) + private val sceneBasedQsExpansion = sceneBasedExpansion(sceneInteractor, Scenes.QuickSettings) override val qsExpansion: StateFlow<Float> = combine( @@ -75,7 +76,7 @@ constructor( when (state) { is ObservableTransitionState.Idle -> false is ObservableTransitionState.Transition -> - state.toScene == SceneKey.QuickSettings && state.fromScene != SceneKey.Shade + state.toScene == Scenes.QuickSettings && state.fromScene != Scenes.Shade } } .distinctUntilChanged() @@ -84,7 +85,7 @@ constructor( sceneInteractor.transitionState .map { state -> when (state) { - is ObservableTransitionState.Idle -> state.scene == SceneKey.QuickSettings + is ObservableTransitionState.Idle -> state.scene == Scenes.QuickSettings is ObservableTransitionState.Transition -> false } } @@ -100,10 +101,10 @@ constructor( .stateIn(scope, SharingStarted.Eagerly, false) override val isUserInteractingWithShade: Flow<Boolean> = - sceneBasedInteracting(sceneInteractor, SceneKey.Shade) + sceneBasedInteracting(sceneInteractor, Scenes.Shade) override val isUserInteractingWithQs: Flow<Boolean> = - sceneBasedInteracting(sceneInteractor, SceneKey.QuickSettings) + sceneBasedInteracting(sceneInteractor, Scenes.QuickSettings) /** * Returns a flow that uses scene transition progress to and from a scene that is pulled down diff --git a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeLockscreenInteractorImpl.kt b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeLockscreenInteractorImpl.kt index 21a782e43b78..1f78ae8b6e99 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeLockscreenInteractorImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeLockscreenInteractorImpl.kt @@ -19,7 +19,7 @@ package com.android.systemui.shade.domain.interactor import com.android.keyguard.LockIconViewController import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.scene.domain.interactor.SceneInteractor -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.shade.ShadeLockscreenInteractor import javax.inject.Inject import kotlinx.coroutines.CoroutineScope @@ -87,7 +87,7 @@ constructor( private fun changeToShadeScene() { sceneInteractor.changeScene( - SceneKey.Shade, + Scenes.Shade, "ShadeLockscreenInteractorImpl.expandToNotifications", ) } diff --git a/packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModel.kt b/packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModel.kt index 38358a8f244e..c9aa51c31060 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModel.kt @@ -16,12 +16,13 @@ package com.android.systemui.shade.ui.viewmodel +import com.android.compose.animation.scene.SceneKey import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor import com.android.systemui.media.controls.domain.pipeline.MediaDataManager import com.android.systemui.qs.ui.adapter.QSSceneAdapter -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationsPlaceholderViewModel import javax.inject.Inject import kotlinx.coroutines.CoroutineScope @@ -67,7 +68,7 @@ constructor( /** Whether or not the shade container should be clickable. */ val isClickable: StateFlow<Boolean> = upDestinationSceneKey - .map { it == SceneKey.Lockscreen } + .map { it == Scenes.Lockscreen } .stateIn( scope = applicationScope, started = SharingStarted.WhileSubscribed(), @@ -82,9 +83,9 @@ constructor( canSwipeToDismiss: Boolean?, ): SceneKey { return when { - canSwipeToDismiss == true -> SceneKey.Lockscreen - isUnlocked -> SceneKey.Gone - else -> SceneKey.Lockscreen + canSwipeToDismiss == true -> Scenes.Lockscreen + isUnlocked -> Scenes.Gone + else -> Scenes.Lockscreen } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java index 36fc9bb3a2da..e0dd7f0603e5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java @@ -36,6 +36,7 @@ import android.view.animation.Interpolator; import androidx.annotation.NonNull; import com.android.app.animation.Interpolators; +import com.android.compose.animation.scene.SceneKey; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.jank.InteractionJankMonitor; @@ -49,7 +50,7 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController.StateList import com.android.systemui.res.R; import com.android.systemui.scene.domain.interactor.SceneInteractor; import com.android.systemui.scene.shared.flag.SceneContainerFlag; -import com.android.systemui.scene.shared.model.SceneKey; +import com.android.systemui.scene.shared.model.Scenes; import com.android.systemui.shade.domain.interactor.ShadeInteractor; import com.android.systemui.statusbar.notification.stack.StackStateAnimator; import com.android.systemui.statusbar.policy.CallbackController; @@ -659,11 +660,11 @@ public class StatusBarStateControllerImpl implements } private static final Map<SceneKey, Integer> sStatusBarStateByLockedSceneKey = Map.of( - SceneKey.Lockscreen.INSTANCE, StatusBarState.KEYGUARD, - SceneKey.Bouncer.INSTANCE, StatusBarState.KEYGUARD, - SceneKey.Communal.INSTANCE, StatusBarState.KEYGUARD, - SceneKey.Shade.INSTANCE, StatusBarState.SHADE_LOCKED, - SceneKey.QuickSettings.INSTANCE, StatusBarState.SHADE_LOCKED + Scenes.Lockscreen, StatusBarState.KEYGUARD, + Scenes.Bouncer, StatusBarState.KEYGUARD, + Scenes.Communal, StatusBarState.KEYGUARD, + Scenes.Shade, StatusBarState.SHADE_LOCKED, + Scenes.QuickSettings, StatusBarState.SHADE_LOCKED ); /** diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationStackAppearanceViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationStackAppearanceViewModel.kt index f68141a4181c..8d1cdfac90c5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationStackAppearanceViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationStackAppearanceViewModel.kt @@ -17,12 +17,12 @@ package com.android.systemui.statusbar.notification.stack.ui.viewmodel +import com.android.compose.animation.scene.ObservableTransitionState import com.android.systemui.common.shared.model.NotificationContainerBounds import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dump.DumpManager import com.android.systemui.scene.domain.interactor.SceneInteractor -import com.android.systemui.scene.shared.model.ObservableTransitionState -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.shade.domain.interactor.ShadeInteractor import com.android.systemui.statusbar.notification.stack.domain.interactor.NotificationStackAppearanceInteractor import com.android.systemui.util.kotlin.FlowDumperImpl @@ -54,7 +54,7 @@ constructor( ) { shadeExpansion, transitionState -> when (transitionState) { is ObservableTransitionState.Idle -> { - if (transitionState.scene == SceneKey.Lockscreen) { + if (transitionState.scene == Scenes.Lockscreen) { 1f } else { shadeExpansion @@ -62,10 +62,10 @@ constructor( } is ObservableTransitionState.Transition -> { if ( - (transitionState.fromScene == SceneKey.Shade && - transitionState.toScene == SceneKey.QuickSettings) || - (transitionState.fromScene == SceneKey.QuickSettings && - transitionState.toScene == SceneKey.Shade) + (transitionState.fromScene == Scenes.Shade && + transitionState.toScene == Scenes.QuickSettings) || + (transitionState.fromScene == Scenes.QuickSettings && + transitionState.toScene == Scenes.Shade) ) { 1f } else { diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt index 72a890d6a5e5..eae04671d581 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt @@ -18,6 +18,7 @@ package com.android.systemui.keyguard.domain.interactor import android.app.StatusBarManager import androidx.test.filters.SmallTest +import com.android.compose.animation.scene.ObservableTransitionState import com.android.keyguard.KeyguardSecurityModel import com.android.keyguard.KeyguardSecurityModel.SecurityMode.PIN import com.android.systemui.Flags.FLAG_COMMUNAL_HUB @@ -25,8 +26,7 @@ import com.android.systemui.Flags.FLAG_KEYGUARD_WM_STATE_REFACTOR import com.android.systemui.SysuiTestCase import com.android.systemui.bouncer.data.repository.fakeKeyguardBouncerRepository import com.android.systemui.communal.domain.interactor.communalInteractor -import com.android.systemui.communal.shared.model.CommunalSceneKey -import com.android.systemui.communal.shared.model.ObservableCommunalTransitionState +import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.flags.FakeFeatureFlags import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository import com.android.systemui.keyguard.data.repository.fakeCommandQueue @@ -688,8 +688,8 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { // GIVEN the device is idle on the glanceable hub val idleTransitionState = - MutableStateFlow<ObservableCommunalTransitionState>( - ObservableCommunalTransitionState.Idle(CommunalSceneKey.Communal) + MutableStateFlow<ObservableTransitionState>( + ObservableTransitionState.Idle(CommunalScenes.Communal) ) communalInteractor.setTransitionState(idleTransitionState) runCurrent() @@ -846,8 +846,8 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { // GIVEN the device is idle on the glanceable hub val idleTransitionState = - MutableStateFlow<ObservableCommunalTransitionState>( - ObservableCommunalTransitionState.Idle(CommunalSceneKey.Communal) + MutableStateFlow<ObservableTransitionState>( + ObservableTransitionState.Idle(CommunalScenes.Communal) ) communalInteractor.setTransitionState(idleTransitionState) runCurrent() @@ -995,8 +995,8 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { // GIVEN the device is idle on the glanceable hub val idleTransitionState = - MutableStateFlow<ObservableCommunalTransitionState>( - ObservableCommunalTransitionState.Idle(CommunalSceneKey.Communal) + MutableStateFlow<ObservableTransitionState>( + ObservableTransitionState.Idle(CommunalScenes.Communal) ) communalInteractor.setTransitionState(idleTransitionState) runCurrent() @@ -1103,8 +1103,8 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { // GIVEN the device is idle on the glanceable hub val idleTransitionState = - MutableStateFlow<ObservableCommunalTransitionState>( - ObservableCommunalTransitionState.Idle(CommunalSceneKey.Communal) + MutableStateFlow<ObservableTransitionState>( + ObservableTransitionState.Idle(CommunalScenes.Communal) ) communalInteractor.setTransitionState(idleTransitionState) runCurrent() @@ -1138,8 +1138,8 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { // GIVEN the device is idle on the glanceable hub val idleTransitionState = - MutableStateFlow<ObservableCommunalTransitionState>( - ObservableCommunalTransitionState.Idle(CommunalSceneKey.Communal) + MutableStateFlow<ObservableTransitionState>( + ObservableTransitionState.Idle(CommunalScenes.Communal) ) communalInteractor.setTransitionState(idleTransitionState) runCurrent() @@ -1256,8 +1256,8 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { // GIVEN the device is idle on the glanceable hub val idleTransitionState = - MutableStateFlow<ObservableCommunalTransitionState>( - ObservableCommunalTransitionState.Idle(CommunalSceneKey.Communal) + MutableStateFlow<ObservableTransitionState>( + ObservableTransitionState.Idle(CommunalScenes.Communal) ) communalInteractor.setTransitionState(idleTransitionState) runCurrent() @@ -1445,13 +1445,13 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { runCurrent() // WHEN a transition to the glanceable hub starts - val currentScene = CommunalSceneKey.Blank - val targetScene = CommunalSceneKey.Communal + val currentScene = CommunalScenes.Blank + val targetScene = CommunalScenes.Communal val progress = MutableStateFlow(0f) val transitionState = - MutableStateFlow<ObservableCommunalTransitionState>( - ObservableCommunalTransitionState.Transition( + MutableStateFlow<ObservableTransitionState>( + ObservableTransitionState.Transition( fromScene = currentScene, toScene = targetScene, progress = progress, @@ -1624,13 +1624,13 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { runCurrent() // WHEN a glanceable hub transition starts - val currentScene = CommunalSceneKey.Blank - val targetScene = CommunalSceneKey.Communal + val currentScene = CommunalScenes.Blank + val targetScene = CommunalScenes.Communal val progress = MutableStateFlow(0f) val transitionState = - MutableStateFlow<ObservableCommunalTransitionState>( - ObservableCommunalTransitionState.Transition( + MutableStateFlow<ObservableTransitionState>( + ObservableTransitionState.Transition( fromScene = currentScene, toScene = targetScene, progress = progress, @@ -1655,8 +1655,8 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { clearInvocations(transitionRepository) runTransitionAndSetWakefulness(KeyguardState.LOCKSCREEN, KeyguardState.GLANCEABLE_HUB) val idleTransitionState = - MutableStateFlow<ObservableCommunalTransitionState>( - ObservableCommunalTransitionState.Idle(currentScene) + MutableStateFlow<ObservableTransitionState>( + ObservableTransitionState.Idle(currentScene) ) communalInteractor.setTransitionState(idleTransitionState) runCurrent() @@ -1680,13 +1680,13 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { runCurrent() // WHEN a transition away from glanceable hub starts - val currentScene = CommunalSceneKey.Communal - val targetScene = CommunalSceneKey.Blank + val currentScene = CommunalScenes.Communal + val targetScene = CommunalScenes.Blank val progress = MutableStateFlow(0f) val transitionState = - MutableStateFlow<ObservableCommunalTransitionState>( - ObservableCommunalTransitionState.Transition( + MutableStateFlow<ObservableTransitionState>( + ObservableTransitionState.Transition( fromScene = currentScene, toScene = targetScene, progress = progress, @@ -1710,8 +1710,8 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { clearInvocations(transitionRepository) runTransitionAndSetWakefulness(KeyguardState.GLANCEABLE_HUB, KeyguardState.LOCKSCREEN) val idleTransitionState = - MutableStateFlow<ObservableCommunalTransitionState>( - ObservableCommunalTransitionState.Idle(currentScene) + MutableStateFlow<ObservableTransitionState>( + ObservableTransitionState.Idle(currentScene) ) communalInteractor.setTransitionState(idleTransitionState) runCurrent() @@ -1797,8 +1797,8 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { // GIVEN the device is idle on the glanceable hub val idleTransitionState = - MutableStateFlow<ObservableCommunalTransitionState>( - ObservableCommunalTransitionState.Idle(CommunalSceneKey.Communal) + MutableStateFlow<ObservableTransitionState>( + ObservableTransitionState.Idle(CommunalScenes.Communal) ) communalInteractor.setTransitionState(idleTransitionState) runCurrent() @@ -1854,12 +1854,12 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { runCurrent() // WHEN a transition away from glanceable hub starts - val currentScene = CommunalSceneKey.Communal - val targetScene = CommunalSceneKey.Blank + val currentScene = CommunalScenes.Communal + val targetScene = CommunalScenes.Blank val transitionState = - MutableStateFlow<ObservableCommunalTransitionState>( - ObservableCommunalTransitionState.Transition( + MutableStateFlow<ObservableTransitionState>( + ObservableTransitionState.Transition( fromScene = currentScene, toScene = targetScene, progress = flowOf(0f, 0.1f), diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/controller/MediaHierarchyManagerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/controller/MediaHierarchyManagerTest.kt index 45f49f01a43e..29820f7a7249 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/controller/MediaHierarchyManagerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/controller/MediaHierarchyManagerTest.kt @@ -28,7 +28,7 @@ import com.android.systemui.Flags import com.android.systemui.SysuiTestCase import com.android.systemui.communal.domain.interactor.communalInteractor import com.android.systemui.communal.domain.interactor.setCommunalAvailable -import com.android.systemui.communal.shared.model.CommunalSceneKey +import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.controls.controller.ControlsControllerImplTest.Companion.eq import com.android.systemui.dreams.DreamOverlayStateController import com.android.systemui.keyguard.WakefulnessLifecycle @@ -514,7 +514,7 @@ class MediaHierarchyManagerTest : SysuiTestCase() { kosmos.setCommunalAvailable(true) runCurrent() - communalInteractor.onSceneChanged(CommunalSceneKey.Communal) + communalInteractor.onSceneChanged(CommunalScenes.Communal) runCurrent() verify(mediaCarouselController) .onDesiredLocationChanged( @@ -526,7 +526,7 @@ class MediaHierarchyManagerTest : SysuiTestCase() { ) clearInvocations(mediaCarouselController) - communalInteractor.onSceneChanged(CommunalSceneKey.Blank) + communalInteractor.onSceneChanged(CommunalScenes.Blank) runCurrent() verify(mediaCarouselController) .onDesiredLocationChanged( @@ -549,7 +549,7 @@ class MediaHierarchyManagerTest : SysuiTestCase() { whenever(statusBarStateController.state).thenReturn(StatusBarState.KEYGUARD) // UMO goes to communal even over the lock screen. - communalInteractor.onSceneChanged(CommunalSceneKey.Communal) + communalInteractor.onSceneChanged(CommunalScenes.Communal) runCurrent() verify(mediaCarouselController) .onDesiredLocationChanged( @@ -571,7 +571,7 @@ class MediaHierarchyManagerTest : SysuiTestCase() { // Device is on lock screen. whenever(statusBarStateController.state).thenReturn(StatusBarState.KEYGUARD) - communalInteractor.onSceneChanged(CommunalSceneKey.Communal) + communalInteractor.onSceneChanged(CommunalScenes.Communal) runCurrent() verify(mediaCarouselController) .onDesiredLocationChanged( diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/GlanceableHubContainerControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/shade/GlanceableHubContainerControllerTest.kt index 96574e245d2d..62d2d0efe24c 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/GlanceableHubContainerControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/GlanceableHubContainerControllerTest.kt @@ -26,6 +26,7 @@ import android.view.View import android.view.WindowManager import android.widget.FrameLayout import androidx.test.filters.SmallTest +import com.android.compose.animation.scene.SceneKey import com.android.systemui.Flags import com.android.systemui.SysuiTestCase import com.android.systemui.communal.data.repository.FakeCommunalRepository @@ -33,7 +34,7 @@ import com.android.systemui.communal.data.repository.fakeCommunalRepository import com.android.systemui.communal.domain.interactor.CommunalInteractor import com.android.systemui.communal.domain.interactor.communalInteractor import com.android.systemui.communal.domain.interactor.setCommunalAvailable -import com.android.systemui.communal.shared.model.CommunalSceneKey +import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.communal.ui.viewmodel.CommunalViewModel import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor import com.android.systemui.kosmos.Kosmos @@ -152,7 +153,7 @@ class GlanceableHubContainerControllerTest : SysuiTestCase() { @Test fun onTouchEvent_communalClosed_doesNotIntercept() { // Communal is closed. - goToScene(CommunalSceneKey.Blank) + goToScene(CommunalScenes.Blank) assertThat(underTest.onTouchEvent(DOWN_EVENT)).isFalse() } @@ -160,7 +161,7 @@ class GlanceableHubContainerControllerTest : SysuiTestCase() { @Test fun onTouchEvent_openGesture_interceptsTouches() { // Communal is closed. - goToScene(CommunalSceneKey.Blank) + goToScene(CommunalScenes.Blank) // Initial touch down is intercepted, and so are touches outside of the region, until an // up event is received. @@ -173,7 +174,7 @@ class GlanceableHubContainerControllerTest : SysuiTestCase() { @Test fun onTouchEvent_communalOpen_interceptsTouches() { // Communal is open. - goToScene(CommunalSceneKey.Communal) + goToScene(CommunalScenes.Communal) // Touch events are intercepted outside of any gesture areas. assertThat(underTest.onTouchEvent(DOWN_EVENT)).isTrue() @@ -184,7 +185,7 @@ class GlanceableHubContainerControllerTest : SysuiTestCase() { @Test fun onTouchEvent_topSwipeWhenCommunalOpen_doesNotIntercept() { // Communal is open. - goToScene(CommunalSceneKey.Communal) + goToScene(CommunalScenes.Communal) // Touch event in the top swipe reqgion is not intercepted. assertThat(underTest.onTouchEvent(DOWN_IN_TOP_SWIPE_REGION_EVENT)).isFalse() @@ -193,7 +194,7 @@ class GlanceableHubContainerControllerTest : SysuiTestCase() { @Test fun onTouchEvent_bottomSwipeWhenCommunalOpen_doesNotIntercept() { // Communal is open. - goToScene(CommunalSceneKey.Communal) + goToScene(CommunalScenes.Communal) // Touch event in the bottom swipe reqgion is not intercepted. assertThat(underTest.onTouchEvent(DOWN_IN_BOTTOM_SWIPE_REGION_EVENT)).isFalse() @@ -202,7 +203,7 @@ class GlanceableHubContainerControllerTest : SysuiTestCase() { @Test fun onTouchEvent_communalAndBouncerShowing_doesNotIntercept() { // Communal is open. - goToScene(CommunalSceneKey.Communal) + goToScene(CommunalScenes.Communal) // Bouncer is visible. bouncerShowingFlow.value = true @@ -217,7 +218,7 @@ class GlanceableHubContainerControllerTest : SysuiTestCase() { @Test fun onTouchEvent_communalAndShadeShowing_doesNotIntercept() { // Communal is open. - goToScene(CommunalSceneKey.Communal) + goToScene(CommunalScenes.Communal) shadeShowingFlow.value = true testableLooper.processAllMessages() @@ -229,7 +230,7 @@ class GlanceableHubContainerControllerTest : SysuiTestCase() { @Test fun onTouchEvent_containerViewDisposed_doesNotIntercept() { // Communal is open. - goToScene(CommunalSceneKey.Communal) + goToScene(CommunalScenes.Communal) // Touch events are intercepted. assertThat(underTest.onTouchEvent(DOWN_EVENT)).isTrue() @@ -262,7 +263,7 @@ class GlanceableHubContainerControllerTest : SysuiTestCase() { wm.updateViewLayout(parentView, lp) } - private fun goToScene(scene: CommunalSceneKey) { + private fun goToScene(scene: SceneKey) { communalRepository.setDesiredScene(scene) testableLooper.processAllMessages() } diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/transition/ShadeTransitionControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/shade/transition/ShadeTransitionControllerTest.kt index 651006dfc953..2f957b09467b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/transition/ShadeTransitionControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/transition/ShadeTransitionControllerTest.kt @@ -5,6 +5,8 @@ package com.android.systemui.shade.transition import android.platform.test.annotations.DisableFlags import android.testing.AndroidTestingRunner import androidx.test.filters.SmallTest +import com.android.compose.animation.scene.ObservableTransitionState +import com.android.compose.animation.scene.SceneKey import com.android.systemui.Flags.FLAG_SCENE_CONTAINER import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue @@ -20,8 +22,7 @@ import com.android.systemui.scene.domain.interactor.PanelExpansionInteractor import com.android.systemui.scene.domain.interactor.SceneInteractor import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.model.FakeSceneDataSource -import com.android.systemui.scene.shared.model.ObservableTransitionState -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.fakeSceneDataSource import com.android.systemui.shade.STATE_OPENING import com.android.systemui.shade.ShadeExpansionChangeEvent @@ -117,13 +118,13 @@ class ShadeTransitionControllerTest : SysuiTestCase() { setUnlocked(true) val transitionState = MutableStateFlow<ObservableTransitionState>( - ObservableTransitionState.Idle(SceneKey.Gone) + ObservableTransitionState.Idle(Scenes.Gone) ) sceneInteractor.setTransitionState(transitionState) - changeScene(SceneKey.Gone, transitionState) + changeScene(Scenes.Gone, transitionState) val currentScene by collectLastValue(sceneInteractor.currentScene) - assertThat(currentScene).isEqualTo(SceneKey.Gone) + assertThat(currentScene).isEqualTo(Scenes.Gone) assertThat(latestChangeEvent) .isEqualTo( @@ -135,7 +136,7 @@ class ShadeTransitionControllerTest : SysuiTestCase() { ) ) - changeScene(SceneKey.Shade, transitionState) { progress -> + changeScene(Scenes.Shade, transitionState) { progress -> assertThat(latestChangeEvent) .isEqualTo( ShadeExpansionChangeEvent( diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/StatusBarStateControllerImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/StatusBarStateControllerImplTest.kt index fe16347fa298..dfbb6ea08f82 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/StatusBarStateControllerImplTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/StatusBarStateControllerImplTest.kt @@ -54,7 +54,6 @@ import com.android.systemui.power.data.repository.FakePowerRepository import com.android.systemui.power.domain.interactor.PowerInteractor import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.flag.FakeSceneContainerFlags -import com.android.systemui.scene.shared.model.SceneKey import com.android.systemui.shade.LargeScreenHeaderHelper import com.android.systemui.shade.data.repository.FakeShadeRepository import com.android.systemui.shade.domain.interactor.ShadeInteractor @@ -87,6 +86,7 @@ import org.mockito.Mockito import org.mockito.Mockito.mock import org.mockito.Mockito.verify import org.mockito.Mockito.`when` as whenever +import com.android.systemui.scene.shared.model.Scenes import org.mockito.MockitoAnnotations @SmallTest @@ -313,48 +313,48 @@ class StatusBarStateControllerImplTest : SysuiTestCase() { kosmos.fakeDeviceEntryRepository.setUnlocked(false) runCurrent() kosmos.sceneInteractor.changeScene( - toScene = SceneKey.Lockscreen, + toScene = Scenes.Lockscreen, loggingReason = "reason" ) runCurrent() assertThat(kosmos.deviceUnlockedInteractor.isDeviceUnlocked.value).isFalse() - assertThat(currentScene).isEqualTo(SceneKey.Lockscreen) + assertThat(currentScene).isEqualTo(Scenes.Lockscreen) // Call start to begin hydrating based on the scene framework: underTest.start() - kosmos.sceneInteractor.changeScene(toScene = SceneKey.Bouncer, loggingReason = "reason") + kosmos.sceneInteractor.changeScene(toScene = Scenes.Bouncer, loggingReason = "reason") runCurrent() - assertThat(currentScene).isEqualTo(SceneKey.Bouncer) + assertThat(currentScene).isEqualTo(Scenes.Bouncer) assertThat(statusBarState).isEqualTo(StatusBarState.KEYGUARD) - kosmos.sceneInteractor.changeScene(toScene = SceneKey.Shade, loggingReason = "reason") + kosmos.sceneInteractor.changeScene(toScene = Scenes.Shade, loggingReason = "reason") runCurrent() - assertThat(currentScene).isEqualTo(SceneKey.Shade) + assertThat(currentScene).isEqualTo(Scenes.Shade) assertThat(statusBarState).isEqualTo(StatusBarState.SHADE_LOCKED) kosmos.sceneInteractor.changeScene( - toScene = SceneKey.QuickSettings, + toScene = Scenes.QuickSettings, loggingReason = "reason" ) runCurrent() - assertThat(currentScene).isEqualTo(SceneKey.QuickSettings) + assertThat(currentScene).isEqualTo(Scenes.QuickSettings) assertThat(statusBarState).isEqualTo(StatusBarState.SHADE_LOCKED) kosmos.sceneInteractor.changeScene( - toScene = SceneKey.Communal, + toScene = Scenes.Communal, loggingReason = "reason" ) runCurrent() - assertThat(currentScene).isEqualTo(SceneKey.Communal) + assertThat(currentScene).isEqualTo(Scenes.Communal) assertThat(statusBarState).isEqualTo(StatusBarState.KEYGUARD) kosmos.sceneInteractor.changeScene( - toScene = SceneKey.Lockscreen, + toScene = Scenes.Lockscreen, loggingReason = "reason" ) runCurrent() - assertThat(currentScene).isEqualTo(SceneKey.Lockscreen) + assertThat(currentScene).isEqualTo(Scenes.Lockscreen) assertThat(statusBarState).isEqualTo(StatusBarState.KEYGUARD) } @@ -377,25 +377,25 @@ class StatusBarStateControllerImplTest : SysuiTestCase() { ) kosmos.fakeDeviceEntryRepository.setUnlocked(true) runCurrent() - kosmos.sceneInteractor.changeScene(toScene = SceneKey.Gone, loggingReason = "reason") + kosmos.sceneInteractor.changeScene(toScene = Scenes.Gone, loggingReason = "reason") runCurrent() assertThat(kosmos.deviceUnlockedInteractor.isDeviceUnlocked.value).isTrue() - assertThat(currentScene).isEqualTo(SceneKey.Gone) + assertThat(currentScene).isEqualTo(Scenes.Gone) // Call start to begin hydrating based on the scene framework: underTest.start() - kosmos.sceneInteractor.changeScene(toScene = SceneKey.Shade, loggingReason = "reason") + kosmos.sceneInteractor.changeScene(toScene = Scenes.Shade, loggingReason = "reason") runCurrent() - assertThat(currentScene).isEqualTo(SceneKey.Shade) + assertThat(currentScene).isEqualTo(Scenes.Shade) assertThat(statusBarState).isEqualTo(StatusBarState.SHADE) kosmos.sceneInteractor.changeScene( - toScene = SceneKey.QuickSettings, + toScene = Scenes.QuickSettings, loggingReason = "reason" ) runCurrent() - assertThat(currentScene).isEqualTo(SceneKey.QuickSettings) + assertThat(currentScene).isEqualTo(Scenes.QuickSettings) assertThat(statusBarState).isEqualTo(StatusBarState.SHADE) } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerWithScenesTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerWithScenesTest.kt index dbf7b6ce145e..012ff2e31562 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerWithScenesTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerWithScenesTest.kt @@ -38,6 +38,7 @@ import android.util.ArraySet import android.view.View import android.view.accessibility.accessibilityManager import androidx.test.filters.SmallTest +import com.android.compose.animation.scene.ObservableTransitionState import com.android.internal.logging.MetricsLogger import com.android.internal.logging.UiEventLogger import com.android.internal.logging.metricsLogger @@ -55,8 +56,7 @@ import com.android.systemui.scene.data.repository.WindowRootViewVisibilityReposi import com.android.systemui.scene.domain.interactor.WindowRootViewVisibilityInteractor import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.flag.fakeSceneContainerFlags -import com.android.systemui.scene.shared.model.ObservableTransitionState -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.settings.UserContextProvider import com.android.systemui.shade.shadeControllerSceneImpl import com.android.systemui.statusbar.NotificationEntryHelper @@ -602,9 +602,9 @@ class NotificationGutsManagerWithScenesTest : SysuiTestCase() { private fun setIsLockscreenOrShadeVisible(isVisible: Boolean) { val key = if (isVisible) { - SceneKey.Lockscreen + Scenes.Lockscreen } else { - SceneKey.Bouncer + Scenes.Bouncer } sceneInteractor.changeScene(key, "test") sceneInteractor.setTransitionState( diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java index 3a94295de668..84156ee1fd53 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java @@ -73,6 +73,7 @@ import android.view.WindowManager; import androidx.test.filters.SmallTest; +import com.android.compose.animation.scene.ObservableTransitionState; import com.android.internal.colorextraction.ColorExtractor; import com.android.internal.logging.UiEventLogger; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; @@ -95,8 +96,7 @@ import com.android.systemui.classifier.FalsingManagerFake; import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.communal.data.repository.CommunalRepository; import com.android.systemui.communal.domain.interactor.CommunalInteractor; -import com.android.systemui.communal.shared.model.CommunalSceneKey; -import com.android.systemui.communal.shared.model.ObservableCommunalTransitionState; +import com.android.systemui.communal.shared.model.CommunalScenes; import com.android.systemui.demomode.DemoModeController; import com.android.systemui.dump.DumpManager; import com.android.systemui.flags.FakeFeatureFlags; @@ -842,16 +842,16 @@ public class CentralSurfacesImplTest extends SysuiTestCase { @Test public void testEnteringGlanceableHub_updatesScrim() { // Transition to the glanceable hub. - mCommunalRepository.setTransitionState(flowOf(new ObservableCommunalTransitionState.Idle( - CommunalSceneKey.Communal.INSTANCE))); + mCommunalRepository.setTransitionState(flowOf(new ObservableTransitionState.Idle( + CommunalScenes.Communal))); mTestScope.getTestScheduler().runCurrent(); // ScrimState also transitions. verify(mScrimController).transitionTo(ScrimState.GLANCEABLE_HUB); // Transition away from the glanceable hub. - mCommunalRepository.setTransitionState(flowOf(new ObservableCommunalTransitionState.Idle( - CommunalSceneKey.Blank.INSTANCE))); + mCommunalRepository.setTransitionState(flowOf(new ObservableTransitionState.Idle( + CommunalScenes.Blank))); mTestScope.getTestScheduler().runCurrent(); // ScrimState goes back to UNLOCKED. diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/communal/data/repository/FakeCommunalRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/communal/data/repository/FakeCommunalRepository.kt index 9d508d23dca7..5ff588f810bd 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/communal/data/repository/FakeCommunalRepository.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/communal/data/repository/FakeCommunalRepository.kt @@ -1,7 +1,8 @@ package com.android.systemui.communal.data.repository -import com.android.systemui.communal.shared.model.CommunalSceneKey -import com.android.systemui.communal.shared.model.ObservableCommunalTransitionState +import com.android.compose.animation.scene.ObservableTransitionState +import com.android.compose.animation.scene.SceneKey +import com.android.systemui.communal.shared.model.CommunalScenes import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow @@ -16,17 +17,16 @@ import kotlinx.coroutines.flow.stateIn @OptIn(ExperimentalCoroutinesApi::class) class FakeCommunalRepository( applicationScope: CoroutineScope, - override val desiredScene: MutableStateFlow<CommunalSceneKey> = - MutableStateFlow(CommunalSceneKey.DEFAULT), + override val desiredScene: MutableStateFlow<SceneKey> = + MutableStateFlow(CommunalScenes.Default), ) : CommunalRepository { - override fun setDesiredScene(desiredScene: CommunalSceneKey) { + override fun setDesiredScene(desiredScene: SceneKey) { this.desiredScene.value = desiredScene } - private val defaultTransitionState = - ObservableCommunalTransitionState.Idle(CommunalSceneKey.DEFAULT) - private val _transitionState = MutableStateFlow<Flow<ObservableCommunalTransitionState>?>(null) - override val transitionState: StateFlow<ObservableCommunalTransitionState> = + private val defaultTransitionState = ObservableTransitionState.Idle(CommunalScenes.Default) + private val _transitionState = MutableStateFlow<Flow<ObservableTransitionState>?>(null) + override val transitionState: StateFlow<ObservableTransitionState> = _transitionState .flatMapLatest { innerFlowOrNull -> innerFlowOrNull ?: flowOf(defaultTransitionState) } .stateIn( @@ -35,7 +35,7 @@ class FakeCommunalRepository( initialValue = defaultTransitionState, ) - override fun setTransitionState(transitionState: Flow<ObservableCommunalTransitionState>?) { + override fun setTransitionState(transitionState: Flow<ObservableTransitionState>?) { _transitionState.value = transitionState } } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/scene/SceneKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/scene/SceneKosmos.kt index 8fc419cadb21..2cdf76d50299 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/scene/SceneKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/scene/SceneKosmos.kt @@ -3,18 +3,18 @@ package com.android.systemui.scene import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.Kosmos.Fixture import com.android.systemui.scene.shared.model.SceneContainerConfig -import com.android.systemui.scene.shared.model.SceneKey +import com.android.systemui.scene.shared.model.Scenes var Kosmos.sceneKeys by Fixture { listOf( - SceneKey.QuickSettings, - SceneKey.Shade, - SceneKey.Lockscreen, - SceneKey.Bouncer, - SceneKey.Gone, - SceneKey.Communal, + Scenes.QuickSettings, + Scenes.Shade, + Scenes.Lockscreen, + Scenes.Bouncer, + Scenes.Gone, + Scenes.Communal, ) } -val Kosmos.initialSceneKey by Fixture { SceneKey.Lockscreen } +val Kosmos.initialSceneKey by Fixture { Scenes.Lockscreen } val Kosmos.sceneContainerConfig by Fixture { SceneContainerConfig(sceneKeys, initialSceneKey) } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/scene/shared/model/FakeSceneDataSource.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/scene/shared/model/FakeSceneDataSource.kt index c208aad78295..59a01cbedc5c 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/scene/shared/model/FakeSceneDataSource.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/scene/shared/model/FakeSceneDataSource.kt @@ -16,6 +16,8 @@ package com.android.systemui.scene.shared.model +import com.android.compose.animation.scene.SceneKey +import com.android.compose.animation.scene.TransitionKey import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow |