Loading packages/SystemUI/multivalentTests/src/com/android/systemui/deviceentry/domain/interactor/DeviceEntryFaceAuthInteractorTest.kt +20 −0 Original line number Diff line number Diff line Loading @@ -322,6 +322,26 @@ class DeviceEntryFaceAuthInteractorTest : SysuiTestCase() { .isEqualTo(Pair(FaceAuthUiEvent.FACE_AUTH_UPDATED_PRIMARY_BOUNCER_SHOWN, false)) } @Test fun faceAuthIsRequestedWhenPrimaryBouncerIsAboutToShow() = testScope.runTest { underTest.start() bouncerRepository.setPrimaryShowingSoon(false) runCurrent() bouncerRepository.setPrimaryShowingSoon(true) runCurrent() assertThat(faceAuthRepository.runningAuthRequest.value) .isEqualTo( Pair( FaceAuthUiEvent.FACE_AUTH_UPDATED_PRIMARY_BOUNCER_SHOWN_OR_WILL_BE_SHOWN, false, ) ) } @Test @EnableSceneContainer fun withSceneContainerEnabled_faceAuthIsRequestedWhenPrimaryBouncerIsVisible() = Loading packages/SystemUI/src/com/android/systemui/bouncer/domain/interactor/PrimaryBouncerInteractor.kt +1 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,7 @@ constructor( val userRequestedBouncerWhenAlreadyAuthenticated: Flow<Int> = repository.userRequestedBouncerWhenAlreadyAuthenticated.filterNotNull() val isShowing: StateFlow<Boolean> = repository.primaryBouncerShow val isShowingSoon: StateFlow<Boolean> = repository.primaryBouncerShowingSoon val startingToHide: Flow<Unit> = repository.primaryBouncerStartingToHide.filter { it }.map {} val isBackButtonEnabled: Flow<Boolean> = repository.isBackButtonEnabled.filterNotNull() val showMessage: Flow<BouncerShowMessageModel> = repository.showMessage.filterNotNull() Loading packages/SystemUI/src/com/android/systemui/deviceentry/domain/interactor/SystemUIDeviceEntryFaceAuthInteractor.kt +15 −0 Original line number Diff line number Diff line Loading @@ -127,6 +127,17 @@ constructor( } .launchIn(applicationScope) isBouncerShowingSoon .whenItFlipsToTrue() .onEach { faceAuthenticationLogger.bouncerShowingSoon() runFaceAuth( FaceAuthUiEvent.FACE_AUTH_UPDATED_PRIMARY_BOUNCER_SHOWN_OR_WILL_BE_SHOWN, fallbackToDetect = false, ) } .launchIn(applicationScope) alternateBouncerInteractor.isVisible .whenItFlipsToTrue() .onEach { Loading Loading @@ -254,6 +265,10 @@ constructor( } } private val isBouncerShowingSoon: Flow<Boolean> by lazy { primaryBouncerInteractor.get().isShowingSoon } private suspend fun resetLockedOutState(currentUserId: Int) { val lockoutMode = facePropertyRepository.getLockoutMode(currentUserId) repository.setLockedOut( Loading packages/SystemUI/src/com/android/systemui/deviceentry/shared/FaceAuthReason.kt +4 −3 Original line number Diff line number Diff line Loading @@ -95,7 +95,8 @@ private object InternalFaceAuthReasons { const val ALTERNATE_BIOMETRIC_BOUNCER_SHOWN = "Face auth due to alternate bouncer shown." const val PRIMARY_BOUNCER_SHOWN = "Face auth started/stopped due to primary bouncer shown." const val PRIMARY_BOUNCER_SHOWN_OR_WILL_BE_SHOWN = "Face auth started/stopped due to bouncer being shown or will be shown." "Face auth started/stopped due to bouncer being shown or will be shown. For example," + "the bouncer contents may show with an intentional delay." const val TRUST_DISABLED = "Face auth started due to trust disabled." const val TRUST_ENABLED = "Face auth stopped due to trust enabled." const val KEYGUARD_OCCLUSION_CHANGED = Loading Loading @@ -164,7 +165,7 @@ constructor(private val id: Int, val reason: String, var extraInfo: Int = 0) : @UiEvent(doc = PRIMARY_BOUNCER_SHOWN_OR_WILL_BE_SHOWN) FACE_AUTH_UPDATED_PRIMARY_BOUNCER_SHOWN_OR_WILL_BE_SHOWN( 1197, PRIMARY_BOUNCER_SHOWN_OR_WILL_BE_SHOWN PRIMARY_BOUNCER_SHOWN_OR_WILL_BE_SHOWN, ), @UiEvent(doc = RETRY_AFTER_HW_UNAVAILABLE) FACE_AUTH_TRIGGERED_RETRY_AFTER_HW_UNAVAILABLE(1156, RETRY_AFTER_HW_UNAVAILABLE), Loading @@ -186,7 +187,7 @@ constructor(private val id: Int, val reason: String, var extraInfo: Int = 0) : ReplaceWith( "FACE_AUTH_UPDATED_STARTED_WAKING_UP, " + "extraInfo=PowerManager.WAKE_REASON_DREAM_FINISHED" ) ), ) @UiEvent(doc = DREAM_STOPPED) FACE_AUTH_TRIGGERED_DREAM_STOPPED(1162, DREAM_STOPPED), Loading packages/SystemUI/src/com/android/systemui/log/FaceAuthenticationLogger.kt +26 −25 Original line number Diff line number Diff line Loading @@ -25,11 +25,7 @@ private const val TAG = "DeviceEntryFaceAuthRepositoryLog" * ``` */ @SysUISingleton class FaceAuthenticationLogger @Inject constructor( @FaceAuthLog private val logBuffer: LogBuffer, ) { class FaceAuthenticationLogger @Inject constructor(@FaceAuthLog private val logBuffer: LogBuffer) { fun ignoredWakeupReason(lastWakeReason: WakeSleepReason) { logBuffer.log( Loading @@ -39,9 +35,10 @@ constructor( { "Ignoring off/aod/dozing -> Lockscreen transition " + "because the last wake up reason is not allow-listed: $str1" } }, ) } fun ignoredFaceAuthTrigger(uiEvent: FaceAuthUiEvent?, ignoredReason: String) { logBuffer.log( TAG, Loading @@ -50,7 +47,7 @@ constructor( str1 = "${uiEvent?.reason}" str2 = ignoredReason }, { "Ignoring trigger because $str2, Trigger reason: $str1" } { "Ignoring trigger because $str2, Trigger reason: $str1" }, ) } Loading @@ -60,7 +57,7 @@ constructor( fun detectionNotSupported( faceManager: FaceManager?, sensorPropertiesInternal: MutableList<FaceSensorPropertiesInternal>? sensorPropertiesInternal: MutableList<FaceSensorPropertiesInternal>?, ) { logBuffer.log( TAG, Loading @@ -75,7 +72,7 @@ constructor( "faceManager isNull: $bool1, " + "sensorPropertiesInternal isNullOrEmpty: $bool2, " + "supportsFaceDetection: $bool3" } }, ) } Loading @@ -90,7 +87,7 @@ constructor( { "Skipping running detection: isAuthRunning: $bool1, " + "detectCancellationNotNull: $bool2" } }, ) } Loading @@ -106,7 +103,7 @@ constructor( isAuthRunning: Boolean, isLockedOut: Boolean, cancellationInProgress: Boolean, faceAuthRequestedWhileCancellation: FaceAuthUiEvent? faceAuthRequestedWhileCancellation: FaceAuthUiEvent?, ) { logBuffer.log( TAG, Loading @@ -124,7 +121,7 @@ constructor( "isLockedOut: $bool2, " + "cancellationInProgress: $bool3, " + "faceAuthRequestedWhileCancellation: $str1" } }, ) } Loading @@ -140,7 +137,7 @@ constructor( errorCode: Int, errString: CharSequence?, lockoutError: Boolean, cancellationError: Boolean cancellationError: Boolean, ) { logBuffer.log( TAG, Loading @@ -156,7 +153,7 @@ constructor( "errString: $str1, " + "isLockoutError: $bool1, " + "isCancellationError: $bool2" } }, ) } Loading @@ -168,7 +165,7 @@ constructor( int1 = result.userId bool1 = result.isStrongBiometric }, { "Face authenticated successfully: userId: $int1, isStrongBiometric: $bool1" } { "Face authenticated successfully: userId: $int1, isStrongBiometric: $bool1" }, ) } Loading @@ -188,6 +185,10 @@ constructor( logBuffer.log(TAG, DEBUG, "Triggering face auth because primary bouncer is visible") } fun bouncerShowingSoon() { logBuffer.log(TAG, DEBUG, "Triggering face auth because primary bouncer will show soon") } fun alternateBouncerVisibilityChanged() { logBuffer.log(TAG, DEBUG, "Triggering face auth because alternate bouncer is visible") } Loading @@ -197,7 +198,7 @@ constructor( TAG, DEBUG, { str1 = "${wake?.lastWakeReason}" }, { "Triggering face auth because lockscreen became visible due to wake reason: $str1" } { "Triggering face auth because lockscreen became visible due to wake reason: $str1" }, ) } Loading @@ -210,7 +211,7 @@ constructor( TAG, DEBUG, { str1 = uiEvent.reason }, { "Requesting face auth for trigger: $str1" } { "Requesting face auth for trigger: $str1" }, ) } Loading @@ -222,7 +223,7 @@ constructor( str1 = "${errorStatus.msg}" int1 = errorStatus.msgId }, { "Received face hardware error: $str1 , code: $int1" } { "Received face hardware error: $str1 , code: $int1" }, ) } Loading @@ -231,7 +232,7 @@ constructor( TAG, DEBUG, { int1 = retryCount }, { "Attempting face auth again because of HW error: retry attempt $int1" } { "Attempting face auth again because of HW error: retry attempt $int1" }, ) } Loading @@ -251,7 +252,7 @@ constructor( str1 = "$uiEvent" bool1 = fallbackToDetection }, { "Queueing $str1 request for face auth, fallbackToDetection: $bool1" } { "Queueing $str1 request for face auth, fallbackToDetection: $bool1" }, ) } Loading @@ -259,7 +260,7 @@ constructor( uiEvent: FaceAuthUiEvent?, canRunAuth: Boolean, canRunDetect: Boolean, cancelInProgress: Boolean cancelInProgress: Boolean, ) { uiEvent?.let { logBuffer.log( Loading @@ -276,7 +277,7 @@ constructor( "canRunAuth: $bool1, " + "canRunDetect: $bool2, " + "cancelInProgress: $bool3" } }, ) } } Loading @@ -289,14 +290,14 @@ constructor( str1 = "${uiEvent?.reason}" bool1 = fallbackToDetection }, { "Processing face auth request: $str1, fallbackToDetect: $bool1" } { "Processing face auth request: $str1, fallbackToDetect: $bool1" }, ) } fun clearingPendingAuthRequest( @CompileTimeConstant loggingContext: String, uiEvent: FaceAuthUiEvent?, fallbackToDetection: Boolean? fallbackToDetection: Boolean?, ) { uiEvent?.let { logBuffer.log( Loading @@ -311,7 +312,7 @@ constructor( "Clearing pending auth: $str1, " + "fallbackToDetection: $str2, " + "reason: $str3" } }, ) } } Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/deviceentry/domain/interactor/DeviceEntryFaceAuthInteractorTest.kt +20 −0 Original line number Diff line number Diff line Loading @@ -322,6 +322,26 @@ class DeviceEntryFaceAuthInteractorTest : SysuiTestCase() { .isEqualTo(Pair(FaceAuthUiEvent.FACE_AUTH_UPDATED_PRIMARY_BOUNCER_SHOWN, false)) } @Test fun faceAuthIsRequestedWhenPrimaryBouncerIsAboutToShow() = testScope.runTest { underTest.start() bouncerRepository.setPrimaryShowingSoon(false) runCurrent() bouncerRepository.setPrimaryShowingSoon(true) runCurrent() assertThat(faceAuthRepository.runningAuthRequest.value) .isEqualTo( Pair( FaceAuthUiEvent.FACE_AUTH_UPDATED_PRIMARY_BOUNCER_SHOWN_OR_WILL_BE_SHOWN, false, ) ) } @Test @EnableSceneContainer fun withSceneContainerEnabled_faceAuthIsRequestedWhenPrimaryBouncerIsVisible() = Loading
packages/SystemUI/src/com/android/systemui/bouncer/domain/interactor/PrimaryBouncerInteractor.kt +1 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,7 @@ constructor( val userRequestedBouncerWhenAlreadyAuthenticated: Flow<Int> = repository.userRequestedBouncerWhenAlreadyAuthenticated.filterNotNull() val isShowing: StateFlow<Boolean> = repository.primaryBouncerShow val isShowingSoon: StateFlow<Boolean> = repository.primaryBouncerShowingSoon val startingToHide: Flow<Unit> = repository.primaryBouncerStartingToHide.filter { it }.map {} val isBackButtonEnabled: Flow<Boolean> = repository.isBackButtonEnabled.filterNotNull() val showMessage: Flow<BouncerShowMessageModel> = repository.showMessage.filterNotNull() Loading
packages/SystemUI/src/com/android/systemui/deviceentry/domain/interactor/SystemUIDeviceEntryFaceAuthInteractor.kt +15 −0 Original line number Diff line number Diff line Loading @@ -127,6 +127,17 @@ constructor( } .launchIn(applicationScope) isBouncerShowingSoon .whenItFlipsToTrue() .onEach { faceAuthenticationLogger.bouncerShowingSoon() runFaceAuth( FaceAuthUiEvent.FACE_AUTH_UPDATED_PRIMARY_BOUNCER_SHOWN_OR_WILL_BE_SHOWN, fallbackToDetect = false, ) } .launchIn(applicationScope) alternateBouncerInteractor.isVisible .whenItFlipsToTrue() .onEach { Loading Loading @@ -254,6 +265,10 @@ constructor( } } private val isBouncerShowingSoon: Flow<Boolean> by lazy { primaryBouncerInteractor.get().isShowingSoon } private suspend fun resetLockedOutState(currentUserId: Int) { val lockoutMode = facePropertyRepository.getLockoutMode(currentUserId) repository.setLockedOut( Loading
packages/SystemUI/src/com/android/systemui/deviceentry/shared/FaceAuthReason.kt +4 −3 Original line number Diff line number Diff line Loading @@ -95,7 +95,8 @@ private object InternalFaceAuthReasons { const val ALTERNATE_BIOMETRIC_BOUNCER_SHOWN = "Face auth due to alternate bouncer shown." const val PRIMARY_BOUNCER_SHOWN = "Face auth started/stopped due to primary bouncer shown." const val PRIMARY_BOUNCER_SHOWN_OR_WILL_BE_SHOWN = "Face auth started/stopped due to bouncer being shown or will be shown." "Face auth started/stopped due to bouncer being shown or will be shown. For example," + "the bouncer contents may show with an intentional delay." const val TRUST_DISABLED = "Face auth started due to trust disabled." const val TRUST_ENABLED = "Face auth stopped due to trust enabled." const val KEYGUARD_OCCLUSION_CHANGED = Loading Loading @@ -164,7 +165,7 @@ constructor(private val id: Int, val reason: String, var extraInfo: Int = 0) : @UiEvent(doc = PRIMARY_BOUNCER_SHOWN_OR_WILL_BE_SHOWN) FACE_AUTH_UPDATED_PRIMARY_BOUNCER_SHOWN_OR_WILL_BE_SHOWN( 1197, PRIMARY_BOUNCER_SHOWN_OR_WILL_BE_SHOWN PRIMARY_BOUNCER_SHOWN_OR_WILL_BE_SHOWN, ), @UiEvent(doc = RETRY_AFTER_HW_UNAVAILABLE) FACE_AUTH_TRIGGERED_RETRY_AFTER_HW_UNAVAILABLE(1156, RETRY_AFTER_HW_UNAVAILABLE), Loading @@ -186,7 +187,7 @@ constructor(private val id: Int, val reason: String, var extraInfo: Int = 0) : ReplaceWith( "FACE_AUTH_UPDATED_STARTED_WAKING_UP, " + "extraInfo=PowerManager.WAKE_REASON_DREAM_FINISHED" ) ), ) @UiEvent(doc = DREAM_STOPPED) FACE_AUTH_TRIGGERED_DREAM_STOPPED(1162, DREAM_STOPPED), Loading
packages/SystemUI/src/com/android/systemui/log/FaceAuthenticationLogger.kt +26 −25 Original line number Diff line number Diff line Loading @@ -25,11 +25,7 @@ private const val TAG = "DeviceEntryFaceAuthRepositoryLog" * ``` */ @SysUISingleton class FaceAuthenticationLogger @Inject constructor( @FaceAuthLog private val logBuffer: LogBuffer, ) { class FaceAuthenticationLogger @Inject constructor(@FaceAuthLog private val logBuffer: LogBuffer) { fun ignoredWakeupReason(lastWakeReason: WakeSleepReason) { logBuffer.log( Loading @@ -39,9 +35,10 @@ constructor( { "Ignoring off/aod/dozing -> Lockscreen transition " + "because the last wake up reason is not allow-listed: $str1" } }, ) } fun ignoredFaceAuthTrigger(uiEvent: FaceAuthUiEvent?, ignoredReason: String) { logBuffer.log( TAG, Loading @@ -50,7 +47,7 @@ constructor( str1 = "${uiEvent?.reason}" str2 = ignoredReason }, { "Ignoring trigger because $str2, Trigger reason: $str1" } { "Ignoring trigger because $str2, Trigger reason: $str1" }, ) } Loading @@ -60,7 +57,7 @@ constructor( fun detectionNotSupported( faceManager: FaceManager?, sensorPropertiesInternal: MutableList<FaceSensorPropertiesInternal>? sensorPropertiesInternal: MutableList<FaceSensorPropertiesInternal>?, ) { logBuffer.log( TAG, Loading @@ -75,7 +72,7 @@ constructor( "faceManager isNull: $bool1, " + "sensorPropertiesInternal isNullOrEmpty: $bool2, " + "supportsFaceDetection: $bool3" } }, ) } Loading @@ -90,7 +87,7 @@ constructor( { "Skipping running detection: isAuthRunning: $bool1, " + "detectCancellationNotNull: $bool2" } }, ) } Loading @@ -106,7 +103,7 @@ constructor( isAuthRunning: Boolean, isLockedOut: Boolean, cancellationInProgress: Boolean, faceAuthRequestedWhileCancellation: FaceAuthUiEvent? faceAuthRequestedWhileCancellation: FaceAuthUiEvent?, ) { logBuffer.log( TAG, Loading @@ -124,7 +121,7 @@ constructor( "isLockedOut: $bool2, " + "cancellationInProgress: $bool3, " + "faceAuthRequestedWhileCancellation: $str1" } }, ) } Loading @@ -140,7 +137,7 @@ constructor( errorCode: Int, errString: CharSequence?, lockoutError: Boolean, cancellationError: Boolean cancellationError: Boolean, ) { logBuffer.log( TAG, Loading @@ -156,7 +153,7 @@ constructor( "errString: $str1, " + "isLockoutError: $bool1, " + "isCancellationError: $bool2" } }, ) } Loading @@ -168,7 +165,7 @@ constructor( int1 = result.userId bool1 = result.isStrongBiometric }, { "Face authenticated successfully: userId: $int1, isStrongBiometric: $bool1" } { "Face authenticated successfully: userId: $int1, isStrongBiometric: $bool1" }, ) } Loading @@ -188,6 +185,10 @@ constructor( logBuffer.log(TAG, DEBUG, "Triggering face auth because primary bouncer is visible") } fun bouncerShowingSoon() { logBuffer.log(TAG, DEBUG, "Triggering face auth because primary bouncer will show soon") } fun alternateBouncerVisibilityChanged() { logBuffer.log(TAG, DEBUG, "Triggering face auth because alternate bouncer is visible") } Loading @@ -197,7 +198,7 @@ constructor( TAG, DEBUG, { str1 = "${wake?.lastWakeReason}" }, { "Triggering face auth because lockscreen became visible due to wake reason: $str1" } { "Triggering face auth because lockscreen became visible due to wake reason: $str1" }, ) } Loading @@ -210,7 +211,7 @@ constructor( TAG, DEBUG, { str1 = uiEvent.reason }, { "Requesting face auth for trigger: $str1" } { "Requesting face auth for trigger: $str1" }, ) } Loading @@ -222,7 +223,7 @@ constructor( str1 = "${errorStatus.msg}" int1 = errorStatus.msgId }, { "Received face hardware error: $str1 , code: $int1" } { "Received face hardware error: $str1 , code: $int1" }, ) } Loading @@ -231,7 +232,7 @@ constructor( TAG, DEBUG, { int1 = retryCount }, { "Attempting face auth again because of HW error: retry attempt $int1" } { "Attempting face auth again because of HW error: retry attempt $int1" }, ) } Loading @@ -251,7 +252,7 @@ constructor( str1 = "$uiEvent" bool1 = fallbackToDetection }, { "Queueing $str1 request for face auth, fallbackToDetection: $bool1" } { "Queueing $str1 request for face auth, fallbackToDetection: $bool1" }, ) } Loading @@ -259,7 +260,7 @@ constructor( uiEvent: FaceAuthUiEvent?, canRunAuth: Boolean, canRunDetect: Boolean, cancelInProgress: Boolean cancelInProgress: Boolean, ) { uiEvent?.let { logBuffer.log( Loading @@ -276,7 +277,7 @@ constructor( "canRunAuth: $bool1, " + "canRunDetect: $bool2, " + "cancelInProgress: $bool3" } }, ) } } Loading @@ -289,14 +290,14 @@ constructor( str1 = "${uiEvent?.reason}" bool1 = fallbackToDetection }, { "Processing face auth request: $str1, fallbackToDetect: $bool1" } { "Processing face auth request: $str1, fallbackToDetect: $bool1" }, ) } fun clearingPendingAuthRequest( @CompileTimeConstant loggingContext: String, uiEvent: FaceAuthUiEvent?, fallbackToDetection: Boolean? fallbackToDetection: Boolean?, ) { uiEvent?.let { logBuffer.log( Loading @@ -311,7 +312,7 @@ constructor( "Clearing pending auth: $str1, " + "fallbackToDetection: $str2, " + "reason: $str3" } }, ) } } Loading