• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.android.systemui.log
2 
3 import android.hardware.face.FaceManager
4 import android.hardware.face.FaceSensorPropertiesInternal
5 import com.android.systemui.dagger.SysUISingleton
6 import com.android.systemui.deviceentry.shared.FaceAuthUiEvent
7 import com.android.systemui.deviceentry.shared.model.ErrorFaceAuthenticationStatus
8 import com.android.systemui.log.core.LogLevel.DEBUG
9 import com.android.systemui.log.dagger.FaceAuthLog
10 import com.android.systemui.power.shared.model.WakeSleepReason
11 import com.android.systemui.power.shared.model.WakefulnessModel
12 import com.google.errorprone.annotations.CompileTimeConstant
13 import javax.inject.Inject
14 
15 private const val TAG = "DeviceEntryFaceAuthRepositoryLog"
16 
17 /**
18  * Helper class for logging for
19  * [com.android.systemui.keyguard.data.repository.DeviceEntryFaceAuthRepository]
20  *
21  * To enable logcat echoing for an entire buffer:
22  * ```
23  *   adb shell settings put global systemui/buffer/DeviceEntryFaceAuthRepositoryLog <logLevel>
24  *
25  * ```
26  */
27 @SysUISingleton
28 class FaceAuthenticationLogger
29 @Inject
30 constructor(
31     @FaceAuthLog private val logBuffer: LogBuffer,
32 ) {
33 
ignoredWakeupReasonnull34     fun ignoredWakeupReason(lastWakeReason: WakeSleepReason) {
35         logBuffer.log(
36             TAG,
37             DEBUG,
38             { str1 = "$lastWakeReason" },
39             {
40                 "Ignoring off/aod/dozing -> Lockscreen transition " +
41                     "because the last wake up reason is not allow-listed: $str1"
42             }
43         )
44     }
ignoredFaceAuthTriggernull45     fun ignoredFaceAuthTrigger(uiEvent: FaceAuthUiEvent?, ignoredReason: String) {
46         logBuffer.log(
47             TAG,
48             DEBUG,
49             {
50                 str1 = "${uiEvent?.reason}"
51                 str2 = ignoredReason
52             },
53             { "Ignoring trigger because $str2, Trigger reason: $str1" }
54         )
55     }
56 
authenticatingnull57     fun authenticating(uiEvent: FaceAuthUiEvent) {
58         logBuffer.log(TAG, DEBUG, { str1 = uiEvent.reason }, { "Running authenticate for $str1" })
59     }
60 
detectionNotSupportednull61     fun detectionNotSupported(
62         faceManager: FaceManager?,
63         sensorPropertiesInternal: MutableList<FaceSensorPropertiesInternal>?
64     ) {
65         logBuffer.log(
66             TAG,
67             DEBUG,
68             {
69                 bool1 = faceManager == null
70                 bool2 = sensorPropertiesInternal.isNullOrEmpty()
71                 bool2 = sensorPropertiesInternal?.firstOrNull()?.supportsFaceDetection ?: false
72             },
73             {
74                 "skipping detection request because it is not supported, " +
75                     "faceManager isNull: $bool1, " +
76                     "sensorPropertiesInternal isNullOrEmpty: $bool2, " +
77                     "supportsFaceDetection: $bool3"
78             }
79         )
80     }
81 
skippingDetectionnull82     fun skippingDetection(isAuthRunning: Boolean, detectCancellationNotNull: Boolean) {
83         logBuffer.log(
84             TAG,
85             DEBUG,
86             {
87                 bool1 = isAuthRunning
88                 bool2 = detectCancellationNotNull
89             },
90             {
91                 "Skipping running detection: isAuthRunning: $bool1, " +
92                     "detectCancellationNotNull: $bool2"
93             }
94         )
95     }
96 
faceDetectionStartednull97     fun faceDetectionStarted() {
98         logBuffer.log(TAG, DEBUG, "Face detection started.")
99     }
100 
faceDetectednull101     fun faceDetected() {
102         logBuffer.log(TAG, DEBUG, "Face detected")
103     }
104 
cancelSignalNotReceivednull105     fun cancelSignalNotReceived(
106         isAuthRunning: Boolean,
107         isLockedOut: Boolean,
108         cancellationInProgress: Boolean,
109         faceAuthRequestedWhileCancellation: FaceAuthUiEvent?
110     ) {
111         logBuffer.log(
112             TAG,
113             DEBUG,
114             {
115                 bool1 = isAuthRunning
116                 bool2 = isLockedOut
117                 bool3 = cancellationInProgress
118                 str1 = "${faceAuthRequestedWhileCancellation?.reason}"
119             },
120             {
121                 "Cancel signal was not received, running timeout handler to reset state. " +
122                     "State before reset: " +
123                     "isAuthRunning: $bool1, " +
124                     "isLockedOut: $bool2, " +
125                     "cancellationInProgress: $bool3, " +
126                     "faceAuthRequestedWhileCancellation: $str1"
127             }
128         )
129     }
130 
authenticationFailednull131     fun authenticationFailed() {
132         logBuffer.log(TAG, DEBUG, "Face authentication failed")
133     }
134 
clearFaceRecognizednull135     fun clearFaceRecognized() {
136         logBuffer.log(TAG, DEBUG, "Clear face recognized")
137     }
138 
authenticationErrornull139     fun authenticationError(
140         errorCode: Int,
141         errString: CharSequence?,
142         lockoutError: Boolean,
143         cancellationError: Boolean
144     ) {
145         logBuffer.log(
146             TAG,
147             DEBUG,
148             {
149                 int1 = errorCode
150                 str1 = "$errString"
151                 bool1 = lockoutError
152                 bool2 = cancellationError
153             },
154             {
155                 "Received authentication error: errorCode: $int1, " +
156                     "errString: $str1, " +
157                     "isLockoutError: $bool1, " +
158                     "isCancellationError: $bool2"
159             }
160         )
161     }
162 
faceAuthSuccessnull163     fun faceAuthSuccess(result: FaceManager.AuthenticationResult) {
164         logBuffer.log(
165             TAG,
166             DEBUG,
167             {
168                 int1 = result.userId
169                 bool1 = result.isStrongBiometric
170             },
171             { "Face authenticated successfully: userId: $int1, isStrongBiometric: $bool1" }
172         )
173     }
174 
canFaceAuthRunChangednull175     fun canFaceAuthRunChanged(canRun: Boolean) {
176         logBuffer.log(TAG, DEBUG, { bool1 = canRun }, { "canFaceAuthRun value changed to $bool1" })
177     }
178 
cancellingFaceAuthnull179     fun cancellingFaceAuth() {
180         logBuffer.log(TAG, DEBUG, "cancelling face auth because a gating condition became false")
181     }
182 
interactorStartednull183     fun interactorStarted() {
184         logBuffer.log(TAG, DEBUG, "KeyguardFaceAuthInteractor started")
185     }
186 
bouncerVisibilityChangednull187     fun bouncerVisibilityChanged() {
188         logBuffer.log(TAG, DEBUG, "Triggering face auth because primary bouncer is visible")
189     }
190 
alternateBouncerVisibilityChangednull191     fun alternateBouncerVisibilityChanged() {
192         logBuffer.log(TAG, DEBUG, "Triggering face auth because alternate bouncer is visible")
193     }
194 
lockscreenBecameVisiblenull195     fun lockscreenBecameVisible(wake: WakefulnessModel?) {
196         logBuffer.log(
197             TAG,
198             DEBUG,
199             { str1 = "${wake?.lastWakeReason}" },
200             { "Triggering face auth because lockscreen became visible due to wake reason: $str1" }
201         )
202     }
203 
addLockoutResetCallbackDonenull204     fun addLockoutResetCallbackDone() {
205         logBuffer.log(TAG, DEBUG, {}, { "addlockoutResetCallback done" })
206     }
207 
authRequestednull208     fun authRequested(uiEvent: FaceAuthUiEvent) {
209         logBuffer.log(
210             TAG,
211             DEBUG,
212             { str1 = uiEvent.reason },
213             { "Requesting face auth for trigger: $str1" }
214         )
215     }
216 
hardwareErrornull217     fun hardwareError(errorStatus: ErrorFaceAuthenticationStatus) {
218         logBuffer.log(
219             TAG,
220             DEBUG,
221             {
222                 str1 = "${errorStatus.msg}"
223                 int1 = errorStatus.msgId
224             },
225             { "Received face hardware error: $str1 , code: $int1" }
226         )
227     }
228 
attemptingRetryAfterHardwareErrornull229     fun attemptingRetryAfterHardwareError(retryCount: Int) {
230         logBuffer.log(
231             TAG,
232             DEBUG,
233             { int1 = retryCount },
234             { "Attempting face auth again because of HW error: retry attempt $int1" }
235         )
236     }
237 
watchdogSchedulednull238     fun watchdogScheduled() {
239         logBuffer.log(TAG, DEBUG, "FaceManager Biometric watchdog scheduled.")
240     }
241 
faceLockedOutnull242     fun faceLockedOut(@CompileTimeConstant reason: String) {
243         logBuffer.log(TAG, DEBUG, "Face auth has been locked out: $reason")
244     }
245 
queueingRequestnull246     fun queueingRequest(uiEvent: FaceAuthUiEvent, fallbackToDetection: Boolean) {
247         logBuffer.log(
248             TAG,
249             DEBUG,
250             {
251                 str1 = "$uiEvent"
252                 bool1 = fallbackToDetection
253             },
254             { "Queueing $str1 request for face auth, fallbackToDetection: $bool1" }
255         )
256     }
257 
notProcessingRequestYetnull258     fun notProcessingRequestYet(
259         uiEvent: FaceAuthUiEvent?,
260         canRunAuth: Boolean,
261         canRunDetect: Boolean,
262         cancelInProgress: Boolean
263     ) {
264         uiEvent?.let {
265             logBuffer.log(
266                 TAG,
267                 DEBUG,
268                 {
269                     str1 = uiEvent.reason
270                     bool1 = canRunAuth
271                     bool2 = canRunDetect
272                     bool3 = cancelInProgress
273                 },
274                 {
275                     "Waiting to process request: reason: $str1, " +
276                         "canRunAuth: $bool1, " +
277                         "canRunDetect: $bool2, " +
278                         "cancelInProgress: $bool3"
279                 }
280             )
281         }
282     }
283 
processingRequestnull284     fun processingRequest(uiEvent: FaceAuthUiEvent?, fallbackToDetection: Boolean) {
285         logBuffer.log(
286             TAG,
287             DEBUG,
288             {
289                 str1 = "${uiEvent?.reason}"
290                 bool1 = fallbackToDetection
291             },
292             { "Processing face auth request: $str1, fallbackToDetect: $bool1" }
293         )
294     }
295 
clearingPendingAuthRequestnull296     fun clearingPendingAuthRequest(
297         @CompileTimeConstant loggingContext: String,
298         uiEvent: FaceAuthUiEvent?,
299         fallbackToDetection: Boolean?
300     ) {
301         uiEvent?.let {
302             logBuffer.log(
303                 TAG,
304                 DEBUG,
305                 {
306                     str1 = uiEvent.reason
307                     str2 = "$fallbackToDetection"
308                     str3 = loggingContext
309                 },
310                 {
311                     "Clearing pending auth: $str1, " +
312                         "fallbackToDetection: $str2, " +
313                         "reason: $str3"
314                 }
315             )
316         }
317     }
318 }
319