Loading packages/SystemUI/src/com/android/systemui/biometrics/data/repository/DisplayStateRepository.kt +8 −2 Original line number Diff line number Diff line Loading @@ -30,13 +30,16 @@ import com.android.systemui.common.coroutine.ChannelExt.trySendWithFailureLoggin 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.dagger.qualifiers.Main import java.util.concurrent.Executor import javax.inject.Inject import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.stateIn /** Repository for the current state of the display */ Loading Loading @@ -66,7 +69,8 @@ constructor( deviceStateManager: DeviceStateManager, displayManager: DisplayManager, @Main handler: Handler, @Main mainExecutor: Executor @Background backgroundExecutor: Executor, @Background backgroundDispatcher: CoroutineDispatcher, ) : DisplayStateRepository { override val isReverseDefaultRotation = context.resources.getBoolean(com.android.internal.R.bool.config_reverseDefaultRotation) Loading Loading @@ -94,9 +98,10 @@ constructor( } sendRearDisplayStateUpdate(false) deviceStateManager.registerCallback(mainExecutor, callback) deviceStateManager.registerCallback(backgroundExecutor, callback) awaitClose { deviceStateManager.unregisterCallback(callback) } } .flowOn(backgroundDispatcher) .stateIn( applicationScope, started = SharingStarted.Eagerly, Loading Loading @@ -137,6 +142,7 @@ constructor( ) awaitClose { displayManager.unregisterDisplayListener(callback) } } .flowOn(backgroundDispatcher) .stateIn( applicationScope, started = SharingStarted.Eagerly, Loading packages/SystemUI/tests/src/com/android/systemui/biometrics/data/repository/DisplayStateRepositoryTest.kt +3 −1 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.StandardTestDispatcher import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.UnconfinedTestDispatcher import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.Before Loading Loading @@ -97,7 +98,8 @@ class DisplayStateRepositoryTest : SysuiTestCase() { deviceStateManager, displayManager, handler, fakeExecutor fakeExecutor, UnconfinedTestDispatcher(), ) } Loading Loading
packages/SystemUI/src/com/android/systemui/biometrics/data/repository/DisplayStateRepository.kt +8 −2 Original line number Diff line number Diff line Loading @@ -30,13 +30,16 @@ import com.android.systemui.common.coroutine.ChannelExt.trySendWithFailureLoggin 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.dagger.qualifiers.Main import java.util.concurrent.Executor import javax.inject.Inject import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.stateIn /** Repository for the current state of the display */ Loading Loading @@ -66,7 +69,8 @@ constructor( deviceStateManager: DeviceStateManager, displayManager: DisplayManager, @Main handler: Handler, @Main mainExecutor: Executor @Background backgroundExecutor: Executor, @Background backgroundDispatcher: CoroutineDispatcher, ) : DisplayStateRepository { override val isReverseDefaultRotation = context.resources.getBoolean(com.android.internal.R.bool.config_reverseDefaultRotation) Loading Loading @@ -94,9 +98,10 @@ constructor( } sendRearDisplayStateUpdate(false) deviceStateManager.registerCallback(mainExecutor, callback) deviceStateManager.registerCallback(backgroundExecutor, callback) awaitClose { deviceStateManager.unregisterCallback(callback) } } .flowOn(backgroundDispatcher) .stateIn( applicationScope, started = SharingStarted.Eagerly, Loading Loading @@ -137,6 +142,7 @@ constructor( ) awaitClose { displayManager.unregisterDisplayListener(callback) } } .flowOn(backgroundDispatcher) .stateIn( applicationScope, started = SharingStarted.Eagerly, Loading
packages/SystemUI/tests/src/com/android/systemui/biometrics/data/repository/DisplayStateRepositoryTest.kt +3 −1 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.StandardTestDispatcher import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.UnconfinedTestDispatcher import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.Before Loading Loading @@ -97,7 +98,8 @@ class DisplayStateRepositoryTest : SysuiTestCase() { deviceStateManager, displayManager, handler, fakeExecutor fakeExecutor, UnconfinedTestDispatcher(), ) } Loading