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

Commit db8118b6 authored by Fiona Campbell's avatar Fiona Campbell Committed by Android (Google) Code Review
Browse files

Merge "Change defaultDisplayOff from flow to stateflow" into main

parents f412c23b 13c29903
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ interface DisplayRepository {
    val pendingDisplay: Flow<PendingDisplay?>

    /** Whether the default display is currently off. */
    val defaultDisplayOff: Flow<Boolean>
    val defaultDisplayOff: StateFlow<Boolean>

    /**
     * Given a display ID int, return the corresponding Display object, or null if none exist.
@@ -426,11 +426,15 @@ constructor(
            }
            .debugLog("pendingDisplay")

    override val defaultDisplayOff: Flow<Boolean> =
    override val defaultDisplayOff: StateFlow<Boolean> =
        displayChangeEvent
            .filter { it == Display.DEFAULT_DISPLAY }
            .map { defaultDisplay.state == Display.STATE_OFF }
            .distinctUntilChanged()
            .stateIn(
                bgApplicationScope,
                SharingStarted.WhileSubscribed(),
                defaultDisplay.state == Display.STATE_OFF,
            )

    override fun getDisplay(displayId: Int): Display? {
        val cachedDisplay = getCachedDisplay(displayId)