Loading packages/SystemUI/src/com/android/systemui/display/data/repository/DisplayRepository.kt +9 −1 Original line number Diff line number Diff line Loading @@ -178,7 +178,15 @@ constructor( .mapElementsLazily { displayId -> getDisplay(displayId) } .flowOn(backgroundCoroutineDispatcher) .debugLog("enabledDisplays") .stateIn(bgApplicationScope, SharingStarted.WhileSubscribed(), emptySet()) .stateIn( bgApplicationScope, started = SharingStarted.WhileSubscribed(), initialValue = setOf( getDisplay(Display.DEFAULT_DISPLAY) ?: error("Unable to get default display.") ) ) } else { oldEnabledDisplays } Loading packages/SystemUI/tests/src/com/android/systemui/display/data/repository/DisplayRepositoryTest.kt +11 −0 Original line number Diff line number Diff line Loading @@ -126,6 +126,7 @@ class DisplayRepositoryTest : SysuiTestCase() { // All subscribers are done, unregister should have been called. verify(displayManager).unregisterDisplayListener(any()) } @Test fun onDisplayAdded_propagated() = testScope.runTest { Loading Loading @@ -457,6 +458,16 @@ class DisplayRepositoryTest : SysuiTestCase() { assertThat(defaultDisplayOff).isFalse() } @Test fun displayFlow_startsWithDefaultDisplayBeforeAnyEvent() = testScope.runTest { setDisplays(Display.DEFAULT_DISPLAY) val value by latestDisplayFlowValue() assertThat(value?.ids()).containsExactly(Display.DEFAULT_DISPLAY) } private fun Iterable<Display>.ids(): List<Int> = map { it.displayId } // Wrapper to capture the displayListener. Loading Loading
packages/SystemUI/src/com/android/systemui/display/data/repository/DisplayRepository.kt +9 −1 Original line number Diff line number Diff line Loading @@ -178,7 +178,15 @@ constructor( .mapElementsLazily { displayId -> getDisplay(displayId) } .flowOn(backgroundCoroutineDispatcher) .debugLog("enabledDisplays") .stateIn(bgApplicationScope, SharingStarted.WhileSubscribed(), emptySet()) .stateIn( bgApplicationScope, started = SharingStarted.WhileSubscribed(), initialValue = setOf( getDisplay(Display.DEFAULT_DISPLAY) ?: error("Unable to get default display.") ) ) } else { oldEnabledDisplays } Loading
packages/SystemUI/tests/src/com/android/systemui/display/data/repository/DisplayRepositoryTest.kt +11 −0 Original line number Diff line number Diff line Loading @@ -126,6 +126,7 @@ class DisplayRepositoryTest : SysuiTestCase() { // All subscribers are done, unregister should have been called. verify(displayManager).unregisterDisplayListener(any()) } @Test fun onDisplayAdded_propagated() = testScope.runTest { Loading Loading @@ -457,6 +458,16 @@ class DisplayRepositoryTest : SysuiTestCase() { assertThat(defaultDisplayOff).isFalse() } @Test fun displayFlow_startsWithDefaultDisplayBeforeAnyEvent() = testScope.runTest { setDisplays(Display.DEFAULT_DISPLAY) val value by latestDisplayFlowValue() assertThat(value?.ids()).containsExactly(Display.DEFAULT_DISPLAY) } private fun Iterable<Display>.ids(): List<Int> = map { it.displayId } // Wrapper to capture the displayListener. Loading