• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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.deviceentry.domain.interactor
18 
19 import com.android.systemui.biometrics.data.repository.FingerprintPropertyRepository
20 import com.android.systemui.biometrics.shared.model.FingerprintSensorType
21 import com.android.systemui.dagger.SysUISingleton
22 import com.android.systemui.keyguard.data.repository.DeviceEntryFingerprintAuthRepository
23 import com.android.systemui.keyguard.shared.model.ErrorFingerprintAuthenticationStatus
24 import com.android.systemui.keyguard.shared.model.FailFingerprintAuthenticationStatus
25 import com.android.systemui.keyguard.shared.model.FingerprintAuthenticationStatus
26 import com.android.systemui.keyguard.shared.model.HelpFingerprintAuthenticationStatus
27 import com.android.systemui.keyguard.shared.model.SuccessFingerprintAuthenticationStatus
28 import javax.inject.Inject
29 import kotlinx.coroutines.flow.Flow
30 import kotlinx.coroutines.flow.StateFlow
31 import kotlinx.coroutines.flow.filterIsInstance
32 import kotlinx.coroutines.flow.map
33 
34 @SysUISingleton
35 class DeviceEntryFingerprintAuthInteractor
36 @Inject
37 constructor(
38     repository: DeviceEntryFingerprintAuthRepository,
39     biometricSettingsInteractor: DeviceEntryBiometricSettingsInteractor,
40     fingerprintPropertyRepository: FingerprintPropertyRepository,
41 ) {
42     /**
43      * Whether fingerprint authentication is currently running or not. This does not mean the user
44      * [isEngaged] with the fingerprint.
45      */
46     val isRunning: Flow<Boolean> = repository.isRunning
47 
48     /** Whether the user is actively engaging with the fingerprint sensor */
49     val isEngaged: StateFlow<Boolean> = repository.isEngaged
50 
51     /** Provide the current status of fingerprint authentication. */
52     val authenticationStatus: Flow<FingerprintAuthenticationStatus> =
53         repository.authenticationStatus
54 
55     val isLockedOut: StateFlow<Boolean> = repository.isLockedOut
56 
57     val fingerprintFailure: Flow<FailFingerprintAuthenticationStatus> =
58         repository.authenticationStatus.filterIsInstance<FailFingerprintAuthenticationStatus>()
59     val fingerprintError: Flow<ErrorFingerprintAuthenticationStatus> =
60         repository.authenticationStatus.filterIsInstance<ErrorFingerprintAuthenticationStatus>()
61     val fingerprintHelp: Flow<HelpFingerprintAuthenticationStatus> =
62         repository.authenticationStatus.filterIsInstance<HelpFingerprintAuthenticationStatus>()
63 
64     val fingerprintSuccess: Flow<SuccessFingerprintAuthenticationStatus> =
65         repository.authenticationStatus.filterIsInstance<SuccessFingerprintAuthenticationStatus>()
66 
67     /**
68      * Whether the fingerprint sensor is present under the display as opposed to being on the power
69      * button or behind/rear of the phone.
70      */
71     val isSensorUnderDisplay =
72         fingerprintPropertyRepository.sensorType.map(FingerprintSensorType::isUdfps)
73 }
74