Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit db0cb63e authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix KeyguardStatusBarViewModel to only use the new flow that tells us...

Merge "Fix KeyguardStatusBarViewModel to only use the new flow that tells us we are showing heads up status bar when the flag for that refactor is enabled." into main
parents 9480ba26 a6220a56
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import com.android.systemui.scene.domain.interactor.SceneInteractor
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.statusbar.domain.interactor.KeyguardStatusBarInteractor
import com.android.systemui.statusbar.notification.domain.interactor.HeadsUpNotificationInteractor
import com.android.systemui.statusbar.notification.shared.NotificationsHeadsUpRefactor
import com.android.systemui.statusbar.policy.BatteryController
import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback
import javax.inject.Inject
@@ -33,6 +34,7 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.stateIn

/**
@@ -54,12 +56,20 @@ constructor(
    keyguardStatusBarInteractor: KeyguardStatusBarInteractor,
    batteryController: BatteryController,
) {

    private val showingHeadsUpStatusBar: Flow<Boolean> =
        if (NotificationsHeadsUpRefactor.isEnabled) {
            headsUpNotificationInteractor.showHeadsUpStatusBar
        } else {
            flowOf(false)
        }

    /** True if this view should be visible and false otherwise. */
    val isVisible: StateFlow<Boolean> =
        combine(
                sceneInteractor.currentScene,
                keyguardInteractor.isDozing,
                headsUpNotificationInteractor.showHeadsUpStatusBar,
                showingHeadsUpStatusBar,
            ) { currentScene, isDozing, showHeadsUpStatusBar ->
                currentScene == Scenes.Lockscreen && !isDozing && !showHeadsUpStatusBar
            }