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.biometrics.shared.model
18 
19 import android.hardware.biometrics.SensorProperties
20 import android.hardware.face.FaceSensorPropertiesInternal
21 import android.hardware.fingerprint.FingerprintSensorPropertiesInternal
22 
23 /** The available modalities for an operation. */
24 data class BiometricModalities(
25     val fingerprintProperties: FingerprintSensorPropertiesInternal? = null,
26     val faceProperties: FaceSensorPropertiesInternal? = null,
27 ) {
28     /** If there are no available modalities. */
29     val isEmpty: Boolean
30         get() = !hasFingerprint && !hasFace
31 
32     /** If fingerprint authentication is available (and [fingerprintProperties] is non-null). */
33     val hasFingerprint: Boolean
34         get() = fingerprintProperties != null
35 
36     /** If SFPS authentication is available. */
37     val hasSfps: Boolean
38         get() = hasFingerprint && fingerprintProperties!!.isAnySidefpsType
39 
40     /** If UDFPS authentication is available. */
41     val hasUdfps: Boolean
42         get() = hasFingerprint && fingerprintProperties!!.isAnyUdfpsType
43 
44     /** If fingerprint authentication is available (and [faceProperties] is non-null). */
45     val hasFace: Boolean
46         get() = faceProperties != null
47 
48     /** If only face authentication is enabled. */
49     val hasFaceOnly: Boolean
50         get() = hasFace && !hasFingerprint
51 
52     /** If only fingerprint authentication is enabled. */
53     val hasFingerprintOnly: Boolean
54         get() = hasFingerprint && !hasFace
55 
56     /** If face & fingerprint authentication is enabled (coex). */
57     val hasFaceAndFingerprint: Boolean
58         get() = hasFingerprint && hasFace
59 
60     /** If [hasFace] and it is configured as a STRONG class 3 biometric. */
61     val isFaceStrong: Boolean
62         get() = faceProperties?.sensorStrength == SensorProperties.STRENGTH_STRONG
63 }
64