1 package com.android.systemui.log 2 3 import android.hardware.face.FaceManager 4 import android.hardware.face.FaceSensorPropertiesInternal 5 import com.android.keyguard.FaceAuthUiEvent 6 import com.android.systemui.dagger.SysUISingleton 7 import com.android.systemui.log.dagger.FaceAuthLog 8 import com.android.systemui.plugins.log.LogBuffer 9 import com.android.systemui.plugins.log.LogLevel.DEBUG 10 import com.google.errorprone.annotations.CompileTimeConstant 11 import javax.inject.Inject 12 13 private const val TAG = "KeyguardFaceAuthManagerLog" 14 15 /** 16 * Helper class for logging for [com.android.keyguard.faceauth.KeyguardFaceAuthManager] 17 * 18 * To enable logcat echoing for an entire buffer: 19 * ``` 20 * adb shell settings put global systemui/buffer/KeyguardFaceAuthManagerLog <logLevel> 21 * 22 * ``` 23 */ 24 @SysUISingleton 25 class FaceAuthenticationLogger 26 @Inject 27 constructor( 28 @FaceAuthLog private val logBuffer: LogBuffer, 29 ) { ignoredFaceAuthTriggernull30 fun ignoredFaceAuthTrigger(uiEvent: FaceAuthUiEvent) { 31 logBuffer.log( 32 TAG, 33 DEBUG, 34 { str1 = uiEvent.reason }, 35 { 36 "Ignoring trigger because face auth is currently running. " + 37 "Trigger reason: $str1" 38 } 39 ) 40 } 41 queuingRequestWhileCancellingnull42 fun queuingRequestWhileCancelling( 43 alreadyQueuedRequest: FaceAuthUiEvent?, 44 newRequest: FaceAuthUiEvent 45 ) { 46 logBuffer.log( 47 TAG, 48 DEBUG, 49 { 50 str1 = alreadyQueuedRequest?.reason 51 str2 = newRequest.reason 52 }, 53 { 54 "Face auth requested while previous request is being cancelled, " + 55 "already queued request: $str1 queueing the new request: $str2" 56 } 57 ) 58 } 59 authenticatingnull60 fun authenticating(uiEvent: FaceAuthUiEvent) { 61 logBuffer.log(TAG, DEBUG, { str1 = uiEvent.reason }, { "Running authenticate for $str1" }) 62 } 63 detectionNotSupportednull64 fun detectionNotSupported( 65 faceManager: FaceManager?, 66 sensorPropertiesInternal: MutableList<FaceSensorPropertiesInternal>? 67 ) { 68 logBuffer.log( 69 TAG, 70 DEBUG, 71 { 72 bool1 = faceManager == null 73 bool2 = sensorPropertiesInternal.isNullOrEmpty() 74 bool2 = sensorPropertiesInternal?.firstOrNull()?.supportsFaceDetection ?: false 75 }, 76 { 77 "skipping detection request because it is not supported, " + 78 "faceManager isNull: $bool1, " + 79 "sensorPropertiesInternal isNullOrEmpty: $bool2, " + 80 "supportsFaceDetection: $bool3" 81 } 82 ) 83 } 84 skippingBecauseAlreadyRunningnull85 fun skippingBecauseAlreadyRunning(@CompileTimeConstant operation: String) { 86 logBuffer.log(TAG, DEBUG, "isAuthRunning is true, skipping $operation") 87 } 88 faceDetectionStartednull89 fun faceDetectionStarted() { 90 logBuffer.log(TAG, DEBUG, "Face detection started.") 91 } 92 faceDetectednull93 fun faceDetected() { 94 logBuffer.log(TAG, DEBUG, "Face detected") 95 } 96 cancelSignalNotReceivednull97 fun cancelSignalNotReceived( 98 isAuthRunning: Boolean, 99 isLockedOut: Boolean, 100 cancellationInProgress: Boolean, 101 faceAuthRequestedWhileCancellation: FaceAuthUiEvent? 102 ) { 103 logBuffer.log( 104 TAG, 105 DEBUG, 106 { 107 bool1 = isAuthRunning 108 bool2 = isLockedOut 109 bool3 = cancellationInProgress 110 str1 = "${faceAuthRequestedWhileCancellation?.reason}" 111 }, 112 { 113 "Cancel signal was not received, running timeout handler to reset state. " + 114 "State before reset: " + 115 "isAuthRunning: $bool1, " + 116 "isLockedOut: $bool2, " + 117 "cancellationInProgress: $bool3, " + 118 "faceAuthRequestedWhileCancellation: $str1" 119 } 120 ) 121 } 122 authenticationFailednull123 fun authenticationFailed() { 124 logBuffer.log(TAG, DEBUG, "Face authentication failed") 125 } 126 authenticationAcquirednull127 fun authenticationAcquired(acquireInfo: Int) { 128 logBuffer.log( 129 TAG, 130 DEBUG, 131 { int1 = acquireInfo }, 132 { "Face acquired during face authentication: acquireInfo: $int1 " } 133 ) 134 } 135 authenticationErrornull136 fun authenticationError( 137 errorCode: Int, 138 errString: CharSequence?, 139 lockoutError: Boolean, 140 cancellationError: Boolean 141 ) { 142 logBuffer.log( 143 TAG, 144 DEBUG, 145 { 146 int1 = errorCode 147 str1 = "$errString" 148 bool1 = lockoutError 149 bool2 = cancellationError 150 }, 151 { 152 "Received authentication error: errorCode: $int1, " + 153 "errString: $str1, " + 154 "isLockoutError: $bool1, " + 155 "isCancellationError: $bool2" 156 } 157 ) 158 } 159 launchingQueuedFaceAuthRequestnull160 fun launchingQueuedFaceAuthRequest(faceAuthRequestedWhileCancellation: FaceAuthUiEvent?) { 161 logBuffer.log( 162 TAG, 163 DEBUG, 164 { str1 = "${faceAuthRequestedWhileCancellation?.reason}" }, 165 { "Received cancellation error and starting queued face auth request: $str1" } 166 ) 167 } 168 faceAuthSuccessnull169 fun faceAuthSuccess(result: FaceManager.AuthenticationResult) { 170 logBuffer.log( 171 TAG, 172 DEBUG, 173 { 174 int1 = result.userId 175 bool1 = result.isStrongBiometric 176 }, 177 { "Face authenticated successfully: userId: $int1, isStrongBiometric: $bool1" } 178 ) 179 } 180 } 181