• 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.biometrics.domain.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 fingerprint authentication is available (and [faceProperties] is non-null). */
37     val hasFace: Boolean
38         get() = faceProperties != null
39 
40     /** If only face authentication is enabled. */
41     val hasFaceOnly: Boolean
42         get() = hasFace && !hasFingerprint
43 
44     /** If only fingerprint authentication is enabled. */
45     val hasFingerprintOnly: Boolean
46         get() = hasFingerprint && !hasFace
47 
48     /** If face & fingerprint authentication is enabled (coex). */
49     val hasFaceAndFingerprint: Boolean
50         get() = hasFingerprint && hasFace
51 
52     /** If [hasFace] and it is configured as a STRONG class 3 biometric. */
53     val isFaceStrong: Boolean
54         get() = faceProperties?.sensorStrength == SensorProperties.STRENGTH_STRONG
55 }
56