• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
<lambda>null2  * Copyright (C) 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.systemui.bouncer.log
18 
19 import android.os.Build
20 import com.android.systemui.CoreStartable
21 import com.android.systemui.dagger.qualifiers.Application
22 import com.android.systemui.deviceentry.domain.interactor.DeviceEntryBiometricSettingsInteractor
23 import com.android.systemui.deviceentry.domain.interactor.DeviceEntryBiometricsAllowedInteractor
24 import com.android.systemui.deviceentry.domain.interactor.DeviceEntryFaceAuthInteractor
25 import com.android.systemui.deviceentry.domain.interactor.DeviceEntryFingerprintAuthInteractor
26 import com.android.systemui.log.BouncerLogger
27 import javax.inject.Inject
28 import kotlinx.coroutines.CoroutineScope
29 import kotlinx.coroutines.flow.collectLatest
30 import com.android.app.tracing.coroutines.launchTraced as launch
31 
32 /** Startable that logs the flows that bouncer depends on. */
33 class BouncerLoggerStartable
34 @Inject
35 constructor(
36     @Application private val applicationScope: CoroutineScope,
37     private val biometricSettingsInteractor: DeviceEntryBiometricSettingsInteractor,
38     private val faceAuthInteractor: DeviceEntryFaceAuthInteractor,
39     private val fingerprintAuthInteractor: DeviceEntryFingerprintAuthInteractor,
40     private val bouncerLogger: BouncerLogger,
41     private val deviceEntryBiometricsAllowedInteractor: DeviceEntryBiometricsAllowedInteractor,
42 ) : CoreStartable {
43     override fun start() {
44         if (!Build.isDebuggable()) {
45             return
46         }
47         applicationScope.launch {
48             biometricSettingsInteractor.isFaceAuthEnrolledAndEnabled.collectLatest { newValue ->
49                 bouncerLogger.interestedStateChanged("isFaceAuthEnrolledAndEnabled", newValue)
50             }
51         }
52         applicationScope.launch {
53             biometricSettingsInteractor.isFingerprintAuthEnrolledAndEnabled.collectLatest { newValue
54                 ->
55                 bouncerLogger.interestedStateChanged(
56                     "isFingerprintAuthEnrolledAndEnabled",
57                     newValue
58                 )
59             }
60         }
61         applicationScope.launch {
62             faceAuthInteractor.isLockedOut.collectLatest { newValue ->
63                 bouncerLogger.interestedStateChanged("faceAuthLockedOut", newValue)
64             }
65         }
66         applicationScope.launch {
67             fingerprintAuthInteractor.isLockedOut.collectLatest { newValue ->
68                 bouncerLogger.interestedStateChanged("fingerprintLockedOut", newValue)
69             }
70         }
71         applicationScope.launch {
72             deviceEntryBiometricsAllowedInteractor.isFingerprintCurrentlyAllowedOnBouncer
73                 .collectLatest { newValue ->
74                     bouncerLogger.interestedStateChanged(
75                         "fingerprintCurrentlyAllowedOnBouncer",
76                         newValue
77                     )
78                 }
79         }
80     }
81 }
82