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

Commit 13c29903 authored by Fiona Campbell's avatar Fiona Campbell
Browse files

Change defaultDisplayOff from flow to stateflow

Needed for UnlockedScreenOffAnimationController.

Bug: 425275163
Bug: 436832920
Flag: com.android.server.power.feature.flags.separate_timeouts_flicker
Test: atest DisplayServiceTests
Change-Id: Ic5d9d912be22fdaf10cac3cfd3e3a4bd43a530cb
parent 5fea47ac
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)