Loading packages/SystemUI/src/com/android/systemui/display/data/repository/DisplayRepository.kt +9 −1 Original line number Original line Diff line number Diff line Loading @@ -178,7 +178,15 @@ constructor( .mapElementsLazily { displayId -> getDisplay(displayId) } .mapElementsLazily { displayId -> getDisplay(displayId) } .flowOn(backgroundCoroutineDispatcher) .flowOn(backgroundCoroutineDispatcher) .debugLog("enabledDisplays") .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 { } else { oldEnabledDisplays oldEnabledDisplays } } Loading packages/SystemUI/tests/src/com/android/systemui/display/data/repository/DisplayRepositoryTest.kt +11 −0 Original line number Original line Diff line number Diff line Loading @@ -126,6 +126,7 @@ class DisplayRepositoryTest : SysuiTestCase() { // All subscribers are done, unregister should have been called. // All subscribers are done, unregister should have been called. verify(displayManager).unregisterDisplayListener(any()) verify(displayManager).unregisterDisplayListener(any()) } } @Test @Test fun onDisplayAdded_propagated() = fun onDisplayAdded_propagated() = testScope.runTest { testScope.runTest { Loading Loading @@ -457,6 +458,16 @@ class DisplayRepositoryTest : SysuiTestCase() { assertThat(defaultDisplayOff).isFalse() 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 } private fun Iterable<Display>.ids(): List<Int> = map { it.displayId } // Wrapper to capture the displayListener. // Wrapper to capture the displayListener. Loading Loading
packages/SystemUI/src/com/android/systemui/display/data/repository/DisplayRepository.kt +9 −1 Original line number Original line Diff line number Diff line Loading @@ -178,7 +178,15 @@ constructor( .mapElementsLazily { displayId -> getDisplay(displayId) } .mapElementsLazily { displayId -> getDisplay(displayId) } .flowOn(backgroundCoroutineDispatcher) .flowOn(backgroundCoroutineDispatcher) .debugLog("enabledDisplays") .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 { } else { oldEnabledDisplays oldEnabledDisplays } } Loading
packages/SystemUI/tests/src/com/android/systemui/display/data/repository/DisplayRepositoryTest.kt +11 −0 Original line number Original line Diff line number Diff line Loading @@ -126,6 +126,7 @@ class DisplayRepositoryTest : SysuiTestCase() { // All subscribers are done, unregister should have been called. // All subscribers are done, unregister should have been called. verify(displayManager).unregisterDisplayListener(any()) verify(displayManager).unregisterDisplayListener(any()) } } @Test @Test fun onDisplayAdded_propagated() = fun onDisplayAdded_propagated() = testScope.runTest { testScope.runTest { Loading Loading @@ -457,6 +458,16 @@ class DisplayRepositoryTest : SysuiTestCase() { assertThat(defaultDisplayOff).isFalse() 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 } private fun Iterable<Display>.ids(): List<Int> = map { it.displayId } // Wrapper to capture the displayListener. // Wrapper to capture the displayListener. Loading