Loading packages/SystemUI/src/com/android/systemui/biometrics/data/repository/FacePropertyRepository.kt +8 −2 Original line number Diff line number Diff line Loading @@ -29,13 +29,16 @@ import com.android.systemui.common.coroutine.ChannelExt.trySendWithFailureLoggin import com.android.systemui.common.coroutine.ConflatedCallbackFlow import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Background 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.onEach import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.withContext /** A repository for the global state of Face sensor. */ interface FacePropertyRepository { Loading @@ -56,7 +59,8 @@ class FacePropertyRepositoryImpl @Inject constructor( @Application private val applicationScope: CoroutineScope, private val faceManager: FaceManager? @Background private val backgroundDispatcher: CoroutineDispatcher, private val faceManager: FaceManager?, ) : FacePropertyRepository { override val sensorInfo: StateFlow<FaceSensorInfo?> = Loading @@ -77,7 +81,9 @@ constructor( ) } } withContext(backgroundDispatcher) { faceManager?.addAuthenticatorsRegisteredCallback(callback) } awaitClose {} } .onEach { Log.d(TAG, "sensorProps changed: $it") } Loading packages/SystemUI/src/com/android/systemui/biometrics/data/repository/FingerprintPropertyRepository.kt +7 −1 Original line number Diff line number Diff line Loading @@ -33,7 +33,9 @@ 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 javax.inject.Inject import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow Loading @@ -41,6 +43,7 @@ import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.withContext /** * A repository for the global state of FingerprintProperty. Loading @@ -67,6 +70,7 @@ class FingerprintPropertyRepositoryImpl @Inject constructor( @Application private val applicationScope: CoroutineScope, @Background private val backgroundDispatcher: CoroutineDispatcher, private val fingerprintManager: FingerprintManager?, ) : FingerprintPropertyRepository { Loading @@ -93,7 +97,9 @@ constructor( } } } withContext(backgroundDispatcher) { fingerprintManager?.addAuthenticatorsRegisteredCallback(callback) } awaitClose {} } .stateIn( Loading packages/SystemUI/tests/src/com/android/systemui/biometrics/data/repository/FacePropertyRepositoryImplTest.kt +6 −2 Original line number Diff line number Diff line Loading @@ -32,6 +32,8 @@ import com.android.systemui.coroutines.collectLastValue import com.android.systemui.util.mockito.whenever import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.StandardTestDispatcher import kotlinx.coroutines.test.TestDispatcher import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest Loading @@ -54,18 +56,20 @@ class FacePropertyRepositoryImplTest : SysuiTestCase() { @JvmField @Rule val mockitoRule: MockitoRule = MockitoJUnit.rule() private lateinit var underTest: FacePropertyRepository private lateinit var dispatcher: TestDispatcher private lateinit var testScope: TestScope @Captor private lateinit var callback: ArgumentCaptor<IFaceAuthenticatorsRegisteredCallback> @Mock private lateinit var faceManager: FaceManager @Before fun setup() { testScope = TestScope() dispatcher = StandardTestDispatcher() testScope = TestScope(dispatcher) underTest = createRepository(faceManager) } private fun createRepository(manager: FaceManager? = faceManager) = FacePropertyRepositoryImpl(testScope.backgroundScope, manager) FacePropertyRepositoryImpl(testScope.backgroundScope, dispatcher, manager) @Test fun whenFaceManagerIsNotPresentIsNull() = Loading packages/SystemUI/tests/src/com/android/systemui/biometrics/data/repository/FingerprintRepositoryImplTest.kt +5 −1 Original line number Diff line number Diff line Loading @@ -65,7 +65,11 @@ class FingerprintRepositoryImplTest : SysuiTestCase() { val dispatcher = StandardTestDispatcher() testScope = TestScope(dispatcher) repository = FingerprintPropertyRepositoryImpl(testScope.backgroundScope, fingerprintManager) FingerprintPropertyRepositoryImpl( testScope.backgroundScope, dispatcher, fingerprintManager ) testScope.runCurrent() verify(fingerprintManager) Loading Loading
packages/SystemUI/src/com/android/systemui/biometrics/data/repository/FacePropertyRepository.kt +8 −2 Original line number Diff line number Diff line Loading @@ -29,13 +29,16 @@ import com.android.systemui.common.coroutine.ChannelExt.trySendWithFailureLoggin import com.android.systemui.common.coroutine.ConflatedCallbackFlow import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Background 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.onEach import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.withContext /** A repository for the global state of Face sensor. */ interface FacePropertyRepository { Loading @@ -56,7 +59,8 @@ class FacePropertyRepositoryImpl @Inject constructor( @Application private val applicationScope: CoroutineScope, private val faceManager: FaceManager? @Background private val backgroundDispatcher: CoroutineDispatcher, private val faceManager: FaceManager?, ) : FacePropertyRepository { override val sensorInfo: StateFlow<FaceSensorInfo?> = Loading @@ -77,7 +81,9 @@ constructor( ) } } withContext(backgroundDispatcher) { faceManager?.addAuthenticatorsRegisteredCallback(callback) } awaitClose {} } .onEach { Log.d(TAG, "sensorProps changed: $it") } Loading
packages/SystemUI/src/com/android/systemui/biometrics/data/repository/FingerprintPropertyRepository.kt +7 −1 Original line number Diff line number Diff line Loading @@ -33,7 +33,9 @@ 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 javax.inject.Inject import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow Loading @@ -41,6 +43,7 @@ import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.withContext /** * A repository for the global state of FingerprintProperty. Loading @@ -67,6 +70,7 @@ class FingerprintPropertyRepositoryImpl @Inject constructor( @Application private val applicationScope: CoroutineScope, @Background private val backgroundDispatcher: CoroutineDispatcher, private val fingerprintManager: FingerprintManager?, ) : FingerprintPropertyRepository { Loading @@ -93,7 +97,9 @@ constructor( } } } withContext(backgroundDispatcher) { fingerprintManager?.addAuthenticatorsRegisteredCallback(callback) } awaitClose {} } .stateIn( Loading
packages/SystemUI/tests/src/com/android/systemui/biometrics/data/repository/FacePropertyRepositoryImplTest.kt +6 −2 Original line number Diff line number Diff line Loading @@ -32,6 +32,8 @@ import com.android.systemui.coroutines.collectLastValue import com.android.systemui.util.mockito.whenever import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.StandardTestDispatcher import kotlinx.coroutines.test.TestDispatcher import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest Loading @@ -54,18 +56,20 @@ class FacePropertyRepositoryImplTest : SysuiTestCase() { @JvmField @Rule val mockitoRule: MockitoRule = MockitoJUnit.rule() private lateinit var underTest: FacePropertyRepository private lateinit var dispatcher: TestDispatcher private lateinit var testScope: TestScope @Captor private lateinit var callback: ArgumentCaptor<IFaceAuthenticatorsRegisteredCallback> @Mock private lateinit var faceManager: FaceManager @Before fun setup() { testScope = TestScope() dispatcher = StandardTestDispatcher() testScope = TestScope(dispatcher) underTest = createRepository(faceManager) } private fun createRepository(manager: FaceManager? = faceManager) = FacePropertyRepositoryImpl(testScope.backgroundScope, manager) FacePropertyRepositoryImpl(testScope.backgroundScope, dispatcher, manager) @Test fun whenFaceManagerIsNotPresentIsNull() = Loading
packages/SystemUI/tests/src/com/android/systemui/biometrics/data/repository/FingerprintRepositoryImplTest.kt +5 −1 Original line number Diff line number Diff line Loading @@ -65,7 +65,11 @@ class FingerprintRepositoryImplTest : SysuiTestCase() { val dispatcher = StandardTestDispatcher() testScope = TestScope(dispatcher) repository = FingerprintPropertyRepositoryImpl(testScope.backgroundScope, fingerprintManager) FingerprintPropertyRepositoryImpl( testScope.backgroundScope, dispatcher, fingerprintManager ) testScope.runCurrent() verify(fingerprintManager) Loading