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.DeviceEntryFaceAuthInteractor 24 import com.android.systemui.deviceentry.domain.interactor.DeviceEntryFingerprintAuthInteractor 25 import com.android.systemui.log.BouncerLogger 26 import javax.inject.Inject 27 import kotlinx.coroutines.CoroutineScope 28 import kotlinx.coroutines.ExperimentalCoroutinesApi 29 import kotlinx.coroutines.flow.collectLatest 30 import kotlinx.coroutines.launch 31 32 /** Startable that logs the flows that bouncer depends on. */ 33 @OptIn(ExperimentalCoroutinesApi::class) 34 class BouncerLoggerStartable 35 @Inject 36 constructor( 37 @Application private val applicationScope: CoroutineScope, 38 private val biometricSettingsInteractor: DeviceEntryBiometricSettingsInteractor, 39 private val faceAuthInteractor: DeviceEntryFaceAuthInteractor, 40 private val fingerprintAuthInteractor: DeviceEntryFingerprintAuthInteractor, 41 private val bouncerLogger: BouncerLogger, 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 fingerprintAuthInteractor.isFingerprintCurrentlyAllowedOnBouncer.collectLatest { 73 newValue -> 74 bouncerLogger.interestedStateChanged( 75 "fingerprintCurrentlyAllowedOnBouncer", 76 newValue 77 ) 78 } 79 } 80 } 81 } 82