Merge "Rename KeyguardFaceAuthManager to DeviceEntryFaceAuthManager" into udc-dev
This commit is contained in:
@@ -73,7 +73,7 @@ import kotlinx.coroutines.withContext
|
||||
* API to run face authentication and detection for device entry / on keyguard (as opposed to the
|
||||
* biometric prompt).
|
||||
*/
|
||||
interface KeyguardFaceAuthManager {
|
||||
interface DeviceEntryFaceAuthRepository {
|
||||
/** Provide the current face authentication state for device entry. */
|
||||
val isAuthenticated: Flow<Boolean>
|
||||
|
||||
@@ -108,7 +108,7 @@ interface KeyguardFaceAuthManager {
|
||||
}
|
||||
|
||||
@SysUISingleton
|
||||
class KeyguardFaceAuthManagerImpl
|
||||
class DeviceEntryFaceAuthRepositoryImpl
|
||||
@Inject
|
||||
constructor(
|
||||
context: Context,
|
||||
@@ -127,7 +127,7 @@ constructor(
|
||||
private val keyguardInteractor: KeyguardInteractor,
|
||||
private val alternateBouncerInteractor: AlternateBouncerInteractor,
|
||||
dumpManager: DumpManager,
|
||||
) : KeyguardFaceAuthManager, Dumpable {
|
||||
) : DeviceEntryFaceAuthRepository, Dumpable {
|
||||
private var authCancellationSignal: CancellationSignal? = null
|
||||
private var detectCancellationSignal: CancellationSignal? = null
|
||||
private var faceAcquiredInfoIgnoreList: Set<Int>
|
||||
@@ -144,13 +144,13 @@ constructor(
|
||||
get() = _detectionStatus.filterNotNull()
|
||||
|
||||
private val _isLockedOut = MutableStateFlow(false)
|
||||
override val isLockedOut: Flow<Boolean> = _isLockedOut
|
||||
override val isLockedOut: StateFlow<Boolean> = _isLockedOut
|
||||
|
||||
val isDetectionSupported =
|
||||
faceManager?.sensorPropertiesInternal?.firstOrNull()?.supportsFaceDetection ?: false
|
||||
|
||||
private val _isAuthRunning = MutableStateFlow(false)
|
||||
override val isAuthRunning: Flow<Boolean>
|
||||
override val isAuthRunning: StateFlow<Boolean>
|
||||
get() = _isAuthRunning
|
||||
|
||||
private val keyguardSessionId: InstanceId?
|
||||
@@ -199,7 +199,7 @@ constructor(
|
||||
)
|
||||
.boxed()
|
||||
.collect(Collectors.toSet())
|
||||
dumpManager.registerCriticalDumpable("KeyguardFaceAuthManagerImpl", this)
|
||||
dumpManager.registerCriticalDumpable("DeviceEntryFaceAuthRepositoryImpl", this)
|
||||
|
||||
observeFaceAuthGatingChecks()
|
||||
observeFaceDetectGatingChecks()
|
||||
@@ -495,7 +495,7 @@ constructor(
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TAG = "KeyguardFaceAuthManager"
|
||||
const val TAG = "DeviceEntryFaceAuthRepository"
|
||||
|
||||
/**
|
||||
* If no cancel signal has been received after this amount of time, assume that it is
|
||||
@@ -505,7 +505,7 @@ constructor(
|
||||
}
|
||||
|
||||
override fun dump(pw: PrintWriter, args: Array<out String>) {
|
||||
pw.println("KeyguardFaceAuthManagerImpl state:")
|
||||
pw.println("DeviceEntryFaceAuthRepositoryImpl state:")
|
||||
pw.println(" cancellationInProgress: $cancellationInProgress")
|
||||
pw.println(" _isLockedOut.value: ${_isLockedOut.value}")
|
||||
pw.println(" _isAuthRunning.value: ${_isAuthRunning.value}")
|
||||
@@ -22,7 +22,10 @@ import dagger.Module
|
||||
|
||||
@Module
|
||||
interface KeyguardFaceAuthModule {
|
||||
@Binds fun faceAuthManager(impl: KeyguardFaceAuthManagerImpl): KeyguardFaceAuthManager
|
||||
@Binds
|
||||
fun deviceEntryFaceAuthRepository(
|
||||
impl: DeviceEntryFaceAuthRepositoryImpl
|
||||
): DeviceEntryFaceAuthRepository
|
||||
|
||||
@Binds fun trustRepository(impl: TrustRepositoryImpl): TrustRepository
|
||||
}
|
||||
|
||||
@@ -18,7 +18,10 @@ package com.android.systemui.keyguard.shared.model
|
||||
|
||||
import android.hardware.face.FaceManager
|
||||
|
||||
/** Authentication status provided by [com.android.keyguard.faceauth.KeyguardFaceAuthManager] */
|
||||
/**
|
||||
* Authentication status provided by
|
||||
* [com.android.systemui.keyguard.data.repository.DeviceEntryFaceAuthRepository]
|
||||
*/
|
||||
sealed class AuthenticationStatus
|
||||
|
||||
/** Success authentication status. */
|
||||
|
||||
@@ -9,15 +9,15 @@ import com.android.systemui.plugins.log.LogBuffer
|
||||
import com.android.systemui.plugins.log.LogLevel.DEBUG
|
||||
import javax.inject.Inject
|
||||
|
||||
private const val TAG = "KeyguardFaceAuthManagerLog"
|
||||
private const val TAG = "DeviceEntryFaceAuthRepositoryLog"
|
||||
|
||||
/**
|
||||
* Helper class for logging for
|
||||
* [com.android.systemui.keyguard.data.repository.KeyguardFaceAuthManager]
|
||||
* [com.android.systemui.keyguard.data.repository.DeviceEntryFaceAuthRepository]
|
||||
*
|
||||
* To enable logcat echoing for an entire buffer:
|
||||
* ```
|
||||
* adb shell settings put global systemui/buffer/KeyguardFaceAuthManagerLog <logLevel>
|
||||
* adb shell settings put global systemui/buffer/DeviceEntryFaceAuthRepositoryLog <logLevel>
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
|
||||
@@ -367,13 +367,13 @@ public class LogModule {
|
||||
|
||||
/**
|
||||
* Provides a {@link LogBuffer} for use by
|
||||
* {@link com.android.keyguard.faceauth.KeyguardFaceAuthManagerImpl}.
|
||||
* {@link com.android.systemui.keyguard.data.repository.DeviceEntryFaceAuthRepositoryImpl}.
|
||||
*/
|
||||
@Provides
|
||||
@SysUISingleton
|
||||
@FaceAuthLog
|
||||
public static LogBuffer provideFaceAuthLog(LogBufferFactory factory) {
|
||||
return factory.create("KeyguardFaceAuthManagerLog", 300);
|
||||
return factory.create("DeviceEntryFaceAuthRepositoryLog", 300);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -92,8 +92,8 @@ import org.mockito.MockitoAnnotations
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
@SmallTest
|
||||
@RunWith(JUnit4::class)
|
||||
class KeyguardFaceAuthManagerTest : SysuiTestCase() {
|
||||
private lateinit var underTest: KeyguardFaceAuthManagerImpl
|
||||
class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {
|
||||
private lateinit var underTest: DeviceEntryFaceAuthRepositoryImpl
|
||||
|
||||
@Mock private lateinit var faceManager: FaceManager
|
||||
@Mock private lateinit var bypassController: KeyguardBypassController
|
||||
@@ -174,14 +174,14 @@ class KeyguardFaceAuthManagerTest : SysuiTestCase() {
|
||||
whenever(faceManager.sensorPropertiesInternal)
|
||||
.thenReturn(listOf(createFaceSensorProperties(supportsFaceDetection = true)))
|
||||
whenever(bypassController.bypassEnabled).thenReturn(true)
|
||||
underTest = createFaceAuthManagerImpl(faceManager, bypassController)
|
||||
underTest = createDeviceEntryFaceAuthRepositoryImpl(faceManager, bypassController)
|
||||
}
|
||||
|
||||
private fun createFaceAuthManagerImpl(
|
||||
private fun createDeviceEntryFaceAuthRepositoryImpl(
|
||||
fmOverride: FaceManager? = faceManager,
|
||||
bypassControllerOverride: KeyguardBypassController? = bypassController
|
||||
) =
|
||||
KeyguardFaceAuthManagerImpl(
|
||||
DeviceEntryFaceAuthRepositoryImpl(
|
||||
mContext,
|
||||
fmOverride,
|
||||
fakeUserRepository,
|
||||
@@ -190,7 +190,7 @@ class KeyguardFaceAuthManagerTest : SysuiTestCase() {
|
||||
testDispatcher,
|
||||
sessionTracker,
|
||||
uiEventLogger,
|
||||
FaceAuthenticationLogger(logcatLogBuffer("KeyguardFaceAuthManagerLog")),
|
||||
FaceAuthenticationLogger(logcatLogBuffer("DeviceEntryFaceAuthRepositoryLog")),
|
||||
biometricSettingsRepository,
|
||||
deviceEntryFingerprintAuthRepository,
|
||||
trustRepository,
|
||||
@@ -270,17 +270,20 @@ class KeyguardFaceAuthManagerTest : SysuiTestCase() {
|
||||
@Test
|
||||
fun faceDetectionSupportIsTheCorrectValue() =
|
||||
testScope.runTest {
|
||||
assertThat(createFaceAuthManagerImpl(fmOverride = null).isDetectionSupported).isFalse()
|
||||
assertThat(
|
||||
createDeviceEntryFaceAuthRepositoryImpl(fmOverride = null).isDetectionSupported
|
||||
)
|
||||
.isFalse()
|
||||
|
||||
whenever(faceManager.sensorPropertiesInternal).thenReturn(null)
|
||||
assertThat(createFaceAuthManagerImpl().isDetectionSupported).isFalse()
|
||||
assertThat(createDeviceEntryFaceAuthRepositoryImpl().isDetectionSupported).isFalse()
|
||||
|
||||
whenever(faceManager.sensorPropertiesInternal).thenReturn(listOf())
|
||||
assertThat(createFaceAuthManagerImpl().isDetectionSupported).isFalse()
|
||||
assertThat(createDeviceEntryFaceAuthRepositoryImpl().isDetectionSupported).isFalse()
|
||||
|
||||
whenever(faceManager.sensorPropertiesInternal)
|
||||
.thenReturn(listOf(createFaceSensorProperties(supportsFaceDetection = false)))
|
||||
assertThat(createFaceAuthManagerImpl().isDetectionSupported).isFalse()
|
||||
assertThat(createDeviceEntryFaceAuthRepositoryImpl().isDetectionSupported).isFalse()
|
||||
|
||||
whenever(faceManager.sensorPropertiesInternal)
|
||||
.thenReturn(
|
||||
@@ -289,7 +292,7 @@ class KeyguardFaceAuthManagerTest : SysuiTestCase() {
|
||||
createFaceSensorProperties(supportsFaceDetection = true)
|
||||
)
|
||||
)
|
||||
assertThat(createFaceAuthManagerImpl().isDetectionSupported).isFalse()
|
||||
assertThat(createDeviceEntryFaceAuthRepositoryImpl().isDetectionSupported).isFalse()
|
||||
|
||||
whenever(faceManager.sensorPropertiesInternal)
|
||||
.thenReturn(
|
||||
@@ -298,7 +301,7 @@ class KeyguardFaceAuthManagerTest : SysuiTestCase() {
|
||||
createFaceSensorProperties(supportsFaceDetection = false)
|
||||
)
|
||||
)
|
||||
assertThat(createFaceAuthManagerImpl().isDetectionSupported).isTrue()
|
||||
assertThat(createDeviceEntryFaceAuthRepositoryImpl().isDetectionSupported).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -325,7 +328,7 @@ class KeyguardFaceAuthManagerTest : SysuiTestCase() {
|
||||
testScope.runTest {
|
||||
whenever(faceManager.sensorPropertiesInternal)
|
||||
.thenReturn(listOf(createFaceSensorProperties(supportsFaceDetection = true)))
|
||||
underTest = createFaceAuthManagerImpl()
|
||||
underTest = createDeviceEntryFaceAuthRepositoryImpl()
|
||||
initCollectors()
|
||||
|
||||
underTest.detect()
|
||||
@@ -341,13 +344,14 @@ class KeyguardFaceAuthManagerTest : SysuiTestCase() {
|
||||
testScope.runTest {
|
||||
whenever(faceManager.sensorPropertiesInternal)
|
||||
.thenReturn(listOf(createFaceSensorProperties(supportsFaceDetection = false)))
|
||||
underTest = createFaceAuthManagerImpl()
|
||||
underTest = createDeviceEntryFaceAuthRepositoryImpl()
|
||||
initCollectors()
|
||||
clearInvocations(faceManager)
|
||||
|
||||
underTest.detect()
|
||||
|
||||
verify(faceManager, never()).detectFace(any(), any(), any())
|
||||
verify(faceManager, never())
|
||||
.detectFace(any(), any(), any(FaceAuthenticateOptions::class.java))
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -395,7 +399,7 @@ class KeyguardFaceAuthManagerTest : SysuiTestCase() {
|
||||
|
||||
clearInvocations(faceManager)
|
||||
underTest.cancel()
|
||||
advanceTimeBy(KeyguardFaceAuthManagerImpl.DEFAULT_CANCEL_SIGNAL_TIMEOUT + 1)
|
||||
advanceTimeBy(DeviceEntryFaceAuthRepositoryImpl.DEFAULT_CANCEL_SIGNAL_TIMEOUT + 1)
|
||||
|
||||
underTest.authenticate(FACE_AUTH_TRIGGERED_SWIPE_UP_ON_BOUNCER)
|
||||
faceAuthenticateIsCalled()
|
||||
@@ -408,7 +412,7 @@ class KeyguardFaceAuthManagerTest : SysuiTestCase() {
|
||||
R.array.config_face_acquire_device_entry_ignorelist,
|
||||
intArrayOf(10, 11)
|
||||
)
|
||||
underTest = createFaceAuthManagerImpl()
|
||||
underTest = createDeviceEntryFaceAuthRepositoryImpl()
|
||||
initCollectors()
|
||||
|
||||
underTest.authenticate(FACE_AUTH_TRIGGERED_SWIPE_UP_ON_BOUNCER)
|
||||
@@ -428,7 +432,10 @@ class KeyguardFaceAuthManagerTest : SysuiTestCase() {
|
||||
underTest.dump(PrintWriter(StringWriter()), emptyArray())
|
||||
|
||||
underTest =
|
||||
createFaceAuthManagerImpl(fmOverride = null, bypassControllerOverride = null)
|
||||
createDeviceEntryFaceAuthRepositoryImpl(
|
||||
fmOverride = null,
|
||||
bypassControllerOverride = null
|
||||
)
|
||||
fakeUserRepository.setSelectedUserInfo(primaryUser)
|
||||
|
||||
underTest.dump(PrintWriter(StringWriter()), emptyArray())
|
||||
@@ -547,7 +554,7 @@ class KeyguardFaceAuthManagerTest : SysuiTestCase() {
|
||||
whenever(faceManager.sensorPropertiesInternal)
|
||||
.thenReturn(listOf(createFaceSensorProperties(supportsFaceDetection = true)))
|
||||
whenever(bypassController.bypassEnabled).thenReturn(true)
|
||||
underTest = createFaceAuthManagerImpl()
|
||||
underTest = createDeviceEntryFaceAuthRepositoryImpl()
|
||||
initCollectors()
|
||||
allPreconditionsToRunFaceAuthAreTrue()
|
||||
|
||||
@@ -568,7 +575,7 @@ class KeyguardFaceAuthManagerTest : SysuiTestCase() {
|
||||
testScope.runTest {
|
||||
featureFlags.set(FACE_AUTH_REFACTOR, false)
|
||||
|
||||
underTest = createFaceAuthManagerImpl()
|
||||
underTest = createDeviceEntryFaceAuthRepositoryImpl()
|
||||
initCollectors()
|
||||
|
||||
// Collecting any flows exposed in the public API doesn't throw any error
|
||||
Reference in New Issue
Block a user