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

Commit 021c1a9a authored by Nicolo' Mazzucato's avatar Nicolo' Mazzucato
Browse files

Convert enableDisplays to a StateFlow in the background

This should reduce the number of coroutine continuations related to this from the main thread

Flag: None
Test: DisplayRepositoryTest
Bug: 307593813
Change-Id: Ibac62793ec0c047dba7f7ff624d04a1168d06f8a
parent be58e91c
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ import com.android.app.tracing.FlowTracing.traceEach
import com.android.app.tracing.traceSection
import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCallbackFlow
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.display.data.DisplayEvent
import com.android.systemui.util.Compile
@@ -93,7 +92,6 @@ class DisplayRepositoryImpl
constructor(
    private val displayManager: DisplayManager,
    @Background backgroundHandler: Handler,
    @Application applicationScope: CoroutineScope,
    @Background bgApplicationScope: CoroutineScope,
    @Background backgroundCoroutineDispatcher: CoroutineDispatcher
) : DisplayRepository {
@@ -142,8 +140,7 @@ constructor(
    private val enabledDisplays =
        allDisplayEvents
            .map { getDisplays() }
            .flowOn(backgroundCoroutineDispatcher)
            .shareIn(applicationScope, started = SharingStarted.WhileSubscribed(), replay = 1)
            .shareIn(bgApplicationScope, started = SharingStarted.WhileSubscribed(), replay = 1)

    override val displays: Flow<Set<Display>> = enabledDisplays

+0 −1
Original line number Diff line number Diff line
@@ -69,7 +69,6 @@ class DisplayRepositoryTest : SysuiTestCase() {
                displayManager,
                testHandler,
                TestScope(UnconfinedTestDispatcher()),
                TestScope(UnconfinedTestDispatcher()),
                UnconfinedTestDispatcher()
            )
        verify(displayManager, never()).registerDisplayListener(any(), any())