diff options
| author | 2023-11-27 15:28:43 +0000 | |
|---|---|---|
| committer | 2023-11-27 15:28:43 +0000 | |
| commit | 021c1a9ad298282176b26d15ed02dcfc4b0c0222 (patch) | |
| tree | 4d0108c00b7ff6f513a12acacc9f0ebcab709095 | |
| parent | be58e91c18099f14326da4328ce5a2f9f8215fb7 (diff) | |
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
2 files changed, 1 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/display/data/repository/DisplayRepository.kt b/packages/SystemUI/src/com/android/systemui/display/data/repository/DisplayRepository.kt index d3def315f131..c93b8e1a48f2 100644 --- a/packages/SystemUI/src/com/android/systemui/display/data/repository/DisplayRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/display/data/repository/DisplayRepository.kt @@ -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 diff --git a/packages/SystemUI/tests/src/com/android/systemui/display/data/repository/DisplayRepositoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/display/data/repository/DisplayRepositoryTest.kt index 447265d806ed..806930d091b1 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/display/data/repository/DisplayRepositoryTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/display/data/repository/DisplayRepositoryTest.kt @@ -69,7 +69,6 @@ class DisplayRepositoryTest : SysuiTestCase() { displayManager, testHandler, TestScope(UnconfinedTestDispatcher()), - TestScope(UnconfinedTestDispatcher()), UnconfinedTestDispatcher() ) verify(displayManager, never()).registerDisplayListener(any(), any()) |