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

Commit a6220a56 authored by Jeff DeCew's avatar Jeff DeCew
Browse files

Fix KeyguardStatusBarViewModel to only use the new flow that tells us we are...

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.

Change-Id: I5dfbe10168db1c71720e70efeaa878c42aebba89
Fixes: 355367655
Flag: com.android.systemui.notifications_heads_up_refactor
Test: atest KeyguardStatusBarViewModelTest
parent 40477f9b
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
            }