Loading packages/SystemUI/multivalentTests/src/com/android/systemui/communal/data/repository/CommunalSceneRepositoryImplTest.kt +0 −2 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.applicationCoroutineScope import com.android.systemui.kosmos.backgroundScope import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runTest Loading @@ -49,7 +48,6 @@ class CommunalSceneRepositoryImplTest : SysuiTestCase() { private val Kosmos.underTest by Kosmos.Fixture { CommunalSceneRepositoryImpl( applicationScope = applicationCoroutineScope, backgroundScope = backgroundScope, sceneDataSource = delegator, delegator = delegator, Loading packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalSceneRepository.kt +10 −17 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ package com.android.systemui.communal.data.repository import android.content.res.Configuration import com.android.app.tracing.coroutines.launchTraced as launch import androidx.annotation.MainThread import com.android.compose.animation.scene.ObservableTransitionState import com.android.compose.animation.scene.OverlayKey import com.android.compose.animation.scene.SceneKey Loading @@ -25,7 +25,6 @@ import com.android.compose.animation.scene.TransitionKey import com.android.systemui.communal.dagger.Communal 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 import com.android.systemui.scene.shared.model.SceneDataSource import com.android.systemui.scene.shared.model.SceneDataSourceDelegator Loading Loading @@ -54,13 +53,13 @@ interface CommunalSceneRepository { val communalContainerOrientation: StateFlow<Int> /** Updates the requested scene. */ fun changeScene(toScene: SceneKey, transitionKey: TransitionKey? = null) @MainThread fun changeScene(toScene: SceneKey, transitionKey: TransitionKey? = null) /** Immediately snaps to the desired scene. */ fun snapToScene(toScene: SceneKey) @MainThread fun snapToScene(toScene: SceneKey) /** Shows the hub from a power button press. */ suspend fun showHubFromPowerButton() @MainThread fun showHubFromPowerButton() /** * Updates the transition state of the hub [SceneTransitionLayout]. Loading @@ -77,7 +76,6 @@ interface CommunalSceneRepository { class CommunalSceneRepositoryImpl @Inject constructor( @Application private val applicationScope: CoroutineScope, @Background backgroundScope: CoroutineScope, @Communal private val sceneDataSource: SceneDataSource, @Communal private val delegator: SceneDataSourceDelegator, Loading @@ -101,27 +99,22 @@ constructor( override val communalContainerOrientation: StateFlow<Int> = _communalContainerOrientation.asStateFlow() @MainThread override fun changeScene(toScene: SceneKey, transitionKey: TransitionKey?) { applicationScope.launch { // SceneTransitionLayout state updates must be triggered on the thread the STL was // created on. sceneDataSource.changeScene(toScene, transitionKey) } } @MainThread override fun snapToScene(toScene: SceneKey) { applicationScope.launch { // SceneTransitionLayout state updates must be triggered on the thread the STL was // created on. sceneDataSource.snapToScene(toScene) } } override fun setCommunalContainerOrientation(orientation: Int) { _communalContainerOrientation.value = orientation } override suspend fun showHubFromPowerButton() { @MainThread override fun showHubFromPowerButton() { // If keyguard is not showing yet, the hub view is not ready and the // [SceneDataSourceDelegator] will still be using the default [NoOpSceneDataSource] // and initial key, which is Blank. This means that when the hub container loads, it Loading packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSceneInteractor.kt +6 −3 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import com.android.systemui.communal.shared.model.CommunalScenes.toSceneContaine import com.android.systemui.communal.shared.model.EditModeState import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.scene.domain.interactor.SceneInteractor import com.android.systemui.scene.shared.flag.SceneContainerFlag Loading @@ -37,6 +38,7 @@ import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.util.kotlin.BooleanFlowOperators.allOf import com.android.systemui.util.kotlin.pairwiseBy import javax.inject.Inject import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow Loading @@ -57,6 +59,7 @@ class CommunalSceneInteractor @Inject constructor( @Application private val applicationScope: CoroutineScope, @Main private val mainImmediateDispatcher: CoroutineDispatcher, private val repository: CommunalSceneRepository, private val logger: CommunalSceneLogger, private val sceneInteractor: SceneInteractor, Loading Loading @@ -123,7 +126,7 @@ constructor( transitionKey: TransitionKey? = null, keyguardState: KeyguardState? = null, ) { applicationScope.launch("$TAG#changeScene") { applicationScope.launch("$TAG#changeScene", mainImmediateDispatcher) { if (SceneContainerFlag.isEnabled) { sceneInteractor.changeScene( toScene = newScene.toSceneContainerSceneKey(), Loading Loading @@ -153,7 +156,7 @@ constructor( delayMillis: Long = 0, keyguardState: KeyguardState? = null, ) { applicationScope.launch("$TAG#snapToScene") { applicationScope.launch("$TAG#snapToScene", mainImmediateDispatcher) { if (SceneContainerFlag.isEnabled) { sceneInteractor.snapToScene( toScene = newScene.toSceneContainerSceneKey(), Loading @@ -177,7 +180,7 @@ constructor( fun showHubFromPowerButton() { val loggingReason = "showing hub from power button" applicationScope.launch("$TAG#showHubFromPowerButton") { applicationScope.launch("$TAG#showHubFromPowerButton", mainImmediateDispatcher) { if (SceneContainerFlag.isEnabled) { sceneInteractor.changeScene( toScene = CommunalScenes.Communal.toSceneContainerSceneKey(), Loading packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSceneTransitionInteractor.kt +12 −2 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import com.android.systemui.communal.data.repository.CommunalSceneTransitionRepo 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.Main import com.android.systemui.keyguard.domain.interactor.InternalKeyguardTransitionInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor Loading @@ -37,6 +38,7 @@ import com.android.systemui.scene.shared.flag.SceneContainerFlag import com.android.systemui.util.kotlin.pairwise import java.util.UUID import javax.inject.Inject import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job import kotlinx.coroutines.flow.SharingStarted Loading Loading @@ -64,6 +66,7 @@ constructor( val internalTransitionInteractor: InternalKeyguardTransitionInteractor, private val settingsInteractor: CommunalSettingsInteractor, @Application private val applicationScope: CoroutineScope, @Main private val mainImmediateDispatcher: CoroutineDispatcher, private val sceneInteractor: CommunalSceneInteractor, private val repository: CommunalSceneTransitionRepository, private val powerInteractor: PowerInteractor, Loading Loading @@ -143,7 +146,7 @@ constructor( /** Monitors [SceneTransitionLayout] state and updates KTF state accordingly. */ private fun listenForSceneTransitionProgress() { applicationScope.launch { applicationScope.launch("$TAG#listenForSceneTransitionProgress", mainImmediateDispatcher) { sceneInteractor.transitionState .pairwise(ObservableTransitionState.Idle(CommunalScenes.Blank)) .collect { (prevTransition, transition) -> Loading Loading @@ -256,7 +259,10 @@ constructor( private fun collectProgress(transition: ObservableTransitionState.Transition) { progressJob?.cancel() progressJob = applicationScope.launch { transition.progress.collect { updateProgress(it) } } progressJob = applicationScope.launch("$TAG#collectProgress", mainImmediateDispatcher) { transition.progress.collect { updateProgress(it) } } } private suspend fun startTransitionFromGlanceableHub() { Loading Loading @@ -300,4 +306,8 @@ constructor( TransitionState.RUNNING, ) } private companion object { const val TAG = "CommunalSceneTransitionInteractor" } } packages/SystemUI/tests/utils/src/com/android/systemui/communal/data/repository/FakeCommunalSceneRepository.kt +1 −1 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ class FakeCommunalSceneRepository( } } override suspend fun showHubFromPowerButton() { override fun showHubFromPowerButton() { snapToScene(CommunalScenes.Communal) } Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/communal/data/repository/CommunalSceneRepositoryImplTest.kt +0 −2 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.applicationCoroutineScope import com.android.systemui.kosmos.backgroundScope import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runTest Loading @@ -49,7 +48,6 @@ class CommunalSceneRepositoryImplTest : SysuiTestCase() { private val Kosmos.underTest by Kosmos.Fixture { CommunalSceneRepositoryImpl( applicationScope = applicationCoroutineScope, backgroundScope = backgroundScope, sceneDataSource = delegator, delegator = delegator, Loading
packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalSceneRepository.kt +10 −17 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ package com.android.systemui.communal.data.repository import android.content.res.Configuration import com.android.app.tracing.coroutines.launchTraced as launch import androidx.annotation.MainThread import com.android.compose.animation.scene.ObservableTransitionState import com.android.compose.animation.scene.OverlayKey import com.android.compose.animation.scene.SceneKey Loading @@ -25,7 +25,6 @@ import com.android.compose.animation.scene.TransitionKey import com.android.systemui.communal.dagger.Communal 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 import com.android.systemui.scene.shared.model.SceneDataSource import com.android.systemui.scene.shared.model.SceneDataSourceDelegator Loading Loading @@ -54,13 +53,13 @@ interface CommunalSceneRepository { val communalContainerOrientation: StateFlow<Int> /** Updates the requested scene. */ fun changeScene(toScene: SceneKey, transitionKey: TransitionKey? = null) @MainThread fun changeScene(toScene: SceneKey, transitionKey: TransitionKey? = null) /** Immediately snaps to the desired scene. */ fun snapToScene(toScene: SceneKey) @MainThread fun snapToScene(toScene: SceneKey) /** Shows the hub from a power button press. */ suspend fun showHubFromPowerButton() @MainThread fun showHubFromPowerButton() /** * Updates the transition state of the hub [SceneTransitionLayout]. Loading @@ -77,7 +76,6 @@ interface CommunalSceneRepository { class CommunalSceneRepositoryImpl @Inject constructor( @Application private val applicationScope: CoroutineScope, @Background backgroundScope: CoroutineScope, @Communal private val sceneDataSource: SceneDataSource, @Communal private val delegator: SceneDataSourceDelegator, Loading @@ -101,27 +99,22 @@ constructor( override val communalContainerOrientation: StateFlow<Int> = _communalContainerOrientation.asStateFlow() @MainThread override fun changeScene(toScene: SceneKey, transitionKey: TransitionKey?) { applicationScope.launch { // SceneTransitionLayout state updates must be triggered on the thread the STL was // created on. sceneDataSource.changeScene(toScene, transitionKey) } } @MainThread override fun snapToScene(toScene: SceneKey) { applicationScope.launch { // SceneTransitionLayout state updates must be triggered on the thread the STL was // created on. sceneDataSource.snapToScene(toScene) } } override fun setCommunalContainerOrientation(orientation: Int) { _communalContainerOrientation.value = orientation } override suspend fun showHubFromPowerButton() { @MainThread override fun showHubFromPowerButton() { // If keyguard is not showing yet, the hub view is not ready and the // [SceneDataSourceDelegator] will still be using the default [NoOpSceneDataSource] // and initial key, which is Blank. This means that when the hub container loads, it Loading
packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSceneInteractor.kt +6 −3 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import com.android.systemui.communal.shared.model.CommunalScenes.toSceneContaine import com.android.systemui.communal.shared.model.EditModeState import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.scene.domain.interactor.SceneInteractor import com.android.systemui.scene.shared.flag.SceneContainerFlag Loading @@ -37,6 +38,7 @@ import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.util.kotlin.BooleanFlowOperators.allOf import com.android.systemui.util.kotlin.pairwiseBy import javax.inject.Inject import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow Loading @@ -57,6 +59,7 @@ class CommunalSceneInteractor @Inject constructor( @Application private val applicationScope: CoroutineScope, @Main private val mainImmediateDispatcher: CoroutineDispatcher, private val repository: CommunalSceneRepository, private val logger: CommunalSceneLogger, private val sceneInteractor: SceneInteractor, Loading Loading @@ -123,7 +126,7 @@ constructor( transitionKey: TransitionKey? = null, keyguardState: KeyguardState? = null, ) { applicationScope.launch("$TAG#changeScene") { applicationScope.launch("$TAG#changeScene", mainImmediateDispatcher) { if (SceneContainerFlag.isEnabled) { sceneInteractor.changeScene( toScene = newScene.toSceneContainerSceneKey(), Loading Loading @@ -153,7 +156,7 @@ constructor( delayMillis: Long = 0, keyguardState: KeyguardState? = null, ) { applicationScope.launch("$TAG#snapToScene") { applicationScope.launch("$TAG#snapToScene", mainImmediateDispatcher) { if (SceneContainerFlag.isEnabled) { sceneInteractor.snapToScene( toScene = newScene.toSceneContainerSceneKey(), Loading @@ -177,7 +180,7 @@ constructor( fun showHubFromPowerButton() { val loggingReason = "showing hub from power button" applicationScope.launch("$TAG#showHubFromPowerButton") { applicationScope.launch("$TAG#showHubFromPowerButton", mainImmediateDispatcher) { if (SceneContainerFlag.isEnabled) { sceneInteractor.changeScene( toScene = CommunalScenes.Communal.toSceneContainerSceneKey(), Loading
packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSceneTransitionInteractor.kt +12 −2 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import com.android.systemui.communal.data.repository.CommunalSceneTransitionRepo 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.Main import com.android.systemui.keyguard.domain.interactor.InternalKeyguardTransitionInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor Loading @@ -37,6 +38,7 @@ import com.android.systemui.scene.shared.flag.SceneContainerFlag import com.android.systemui.util.kotlin.pairwise import java.util.UUID import javax.inject.Inject import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job import kotlinx.coroutines.flow.SharingStarted Loading Loading @@ -64,6 +66,7 @@ constructor( val internalTransitionInteractor: InternalKeyguardTransitionInteractor, private val settingsInteractor: CommunalSettingsInteractor, @Application private val applicationScope: CoroutineScope, @Main private val mainImmediateDispatcher: CoroutineDispatcher, private val sceneInteractor: CommunalSceneInteractor, private val repository: CommunalSceneTransitionRepository, private val powerInteractor: PowerInteractor, Loading Loading @@ -143,7 +146,7 @@ constructor( /** Monitors [SceneTransitionLayout] state and updates KTF state accordingly. */ private fun listenForSceneTransitionProgress() { applicationScope.launch { applicationScope.launch("$TAG#listenForSceneTransitionProgress", mainImmediateDispatcher) { sceneInteractor.transitionState .pairwise(ObservableTransitionState.Idle(CommunalScenes.Blank)) .collect { (prevTransition, transition) -> Loading Loading @@ -256,7 +259,10 @@ constructor( private fun collectProgress(transition: ObservableTransitionState.Transition) { progressJob?.cancel() progressJob = applicationScope.launch { transition.progress.collect { updateProgress(it) } } progressJob = applicationScope.launch("$TAG#collectProgress", mainImmediateDispatcher) { transition.progress.collect { updateProgress(it) } } } private suspend fun startTransitionFromGlanceableHub() { Loading Loading @@ -300,4 +306,8 @@ constructor( TransitionState.RUNNING, ) } private companion object { const val TAG = "CommunalSceneTransitionInteractor" } }
packages/SystemUI/tests/utils/src/com/android/systemui/communal/data/repository/FakeCommunalSceneRepository.kt +1 −1 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ class FakeCommunalSceneRepository( } } override suspend fun showHubFromPowerButton() { override fun showHubFromPowerButton() { snapToScene(CommunalScenes.Communal) } Loading