summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalInteractor.kt44
-rw-r--r--packages/SystemUI/src/com/android/systemui/dreams/ui/viewmodel/DreamViewModel.kt10
2 files changed, 32 insertions, 22 deletions
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 b4e6e9348b3d..237a19cb31c4 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
@@ -186,28 +186,32 @@ constructor(
* Whether communal hub should be shown automatically, depending on the user's [WhenToDream]
* state.
*/
- val shouldShowCommunal: Flow<Boolean> =
+ val shouldShowCommunal: StateFlow<Boolean> =
allOf(
- isCommunalAvailable,
- communalSettingsInteractor.whenToDream
- .flatMapLatest { whenToDream ->
- when (whenToDream) {
- WhenToDream.NEVER -> flowOf(false)
-
- WhenToDream.WHILE_CHARGING -> batteryInteractor.isDevicePluggedIn
-
- WhenToDream.WHILE_DOCKED ->
- allOf(
- batteryInteractor.isDevicePluggedIn,
- dockManager.retrieveIsDocked(),
- )
-
- WhenToDream.WHILE_POSTURED ->
- allOf(batteryInteractor.isDevicePluggedIn, posturingInteractor.postured)
+ isCommunalAvailable,
+ communalSettingsInteractor.whenToDream
+ .flatMapLatest { whenToDream ->
+ when (whenToDream) {
+ WhenToDream.NEVER -> flowOf(false)
+
+ WhenToDream.WHILE_CHARGING -> batteryInteractor.isDevicePluggedIn
+
+ WhenToDream.WHILE_DOCKED ->
+ allOf(
+ batteryInteractor.isDevicePluggedIn,
+ dockManager.retrieveIsDocked(),
+ )
+
+ WhenToDream.WHILE_POSTURED ->
+ allOf(
+ batteryInteractor.isDevicePluggedIn,
+ posturingInteractor.postured,
+ )
+ }
}
- }
- .flowOn(bgDispatcher),
- )
+ .flowOn(bgDispatcher),
+ )
+ .stateIn(scope = bgScope, started = SharingStarted.Eagerly, initialValue = false)
private val _isDisclaimerDismissed = MutableStateFlow(false)
val isDisclaimerDismissed: Flow<Boolean> = _isDisclaimerDismissed.asStateFlow()
diff --git a/packages/SystemUI/src/com/android/systemui/dreams/ui/viewmodel/DreamViewModel.kt b/packages/SystemUI/src/com/android/systemui/dreams/ui/viewmodel/DreamViewModel.kt
index 02e1824dc7dd..11b7e9dfe319 100644
--- a/packages/SystemUI/src/com/android/systemui/dreams/ui/viewmodel/DreamViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/dreams/ui/viewmodel/DreamViewModel.kt
@@ -20,6 +20,7 @@ import com.android.keyguard.KeyguardUpdateMonitor
import com.android.systemui.Flags.glanceableHubAllowKeyguardWhenDreaming
import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractor
import com.android.systemui.communal.domain.interactor.CommunalInteractor
+import com.android.systemui.communal.domain.interactor.CommunalSettingsInteractor
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dump.DumpManager
import com.android.systemui.keyguard.domain.interactor.FromDreamingTransitionInteractor
@@ -51,6 +52,7 @@ constructor(
private val toLockscreenTransitionViewModel: DreamingToLockscreenTransitionViewModel,
private val fromDreamingTransitionInteractor: FromDreamingTransitionInteractor,
private val communalInteractor: CommunalInteractor,
+ private val communalSettingsInteractor: CommunalSettingsInteractor,
private val keyguardUpdateMonitor: KeyguardUpdateMonitor,
private val userTracker: UserTracker,
dumpManager: DumpManager,
@@ -58,8 +60,12 @@ constructor(
fun startTransitionFromDream() {
val showGlanceableHub =
- communalInteractor.isCommunalEnabled.value &&
- !keyguardUpdateMonitor.isEncryptedOrLockdown(userTracker.userId)
+ if (communalSettingsInteractor.isV2FlagEnabled()) {
+ communalInteractor.shouldShowCommunal.value
+ } else {
+ communalInteractor.isCommunalEnabled.value &&
+ !keyguardUpdateMonitor.isEncryptedOrLockdown(userTracker.userId)
+ }
fromDreamingTransitionInteractor.startToLockscreenOrGlanceableHubTransition(
showGlanceableHub && !glanceableHubAllowKeyguardWhenDreaming()
)