1 /*
2  * Copyright (C) 2018 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 android.hardware.biometrics;
18 
19 import android.app.KeyguardManager;
20 import android.compat.annotation.UnsupportedAppUsage;
21 import android.hardware.biometrics.BiometricManager.Authenticators;
22 import android.hardware.fingerprint.FingerprintManager;
23 
24 /**
25  * Interface containing all of the fingerprint-specific constants.
26  *
27  * NOTE: The error messages must be consistent between BiometricConstants, Biometric*Constants,
28  *       and the frameworks/support/biometric/.../BiometricConstants files.
29  *
30  * @hide
31  */
32 public interface BiometricFingerprintConstants {
33     //
34     // Error messages from fingerprint hardware during initilization, enrollment, authentication or
35     // removal. Must agree with the list in fingerprint.h
36     //
37 
38     /**
39      * The hardware is unavailable. Try again later.
40      */
41     int FINGERPRINT_ERROR_HW_UNAVAILABLE = 1;
42 
43     /**
44      * Error state returned when the sensor was unable to process the current image.
45      */
46     int FINGERPRINT_ERROR_UNABLE_TO_PROCESS = 2;
47 
48     /**
49      * Error state returned when the current request has been running too long. This is intended to
50      * prevent programs from waiting for the fingerprint sensor indefinitely. The timeout is
51      * platform and sensor-specific, but is generally on the order of 30 seconds.
52      */
53     int FINGERPRINT_ERROR_TIMEOUT = 3;
54 
55     /**
56      * Error state returned for operations like enrollment; the operation cannot be completed
57      * because there's not enough storage remaining to complete the operation.
58      */
59     int FINGERPRINT_ERROR_NO_SPACE = 4;
60 
61     /**
62      * The operation was canceled because the fingerprint sensor is unavailable. For example,
63      * this may happen when the user is switched, the device is locked or another pending operation
64      * prevents or disables it.
65      */
66     int FINGERPRINT_ERROR_CANCELED = 5;
67 
68     /**
69      * The {@link FingerprintManager#remove} call failed. Typically this will happen when the
70      * provided fingerprint id was incorrect.
71      *
72      * @hide
73      */
74     int FINGERPRINT_ERROR_UNABLE_TO_REMOVE = 6;
75 
76     /**
77      * The operation was canceled because the API is locked out due to too many attempts.
78      * This occurs after 5 failed attempts, and lasts for 30 seconds.
79      */
80     int FINGERPRINT_ERROR_LOCKOUT = 7;
81 
82     /**
83      * Hardware vendors may extend this list if there are conditions that do not fall under one of
84      * the above categories. Vendors are responsible for providing error strings for these errors.
85      * These messages are typically reserved for internal operations such as enrollment, but may be
86      * used to express vendor errors not covered by the ones in fingerprint.h. Applications are
87      * expected to show the error message string if they happen, but are advised not to rely on the
88      * message id since they will be device and vendor-specific
89      */
90     int FINGERPRINT_ERROR_VENDOR = 8;
91 
92     /**
93      * The operation was canceled because FINGERPRINT_ERROR_LOCKOUT occurred too many times.
94      * Fingerprint authentication is disabled until the user unlocks with strong authentication
95      * (PIN/Pattern/Password)
96      */
97     int FINGERPRINT_ERROR_LOCKOUT_PERMANENT = 9;
98 
99     /**
100      * The user canceled the operation. Upon receiving this, applications should use alternate
101      * authentication (e.g. a password). The application should also provide the means to return
102      * to fingerprint authentication, such as a "use fingerprint" button.
103      */
104     int FINGERPRINT_ERROR_USER_CANCELED = 10;
105 
106     /**
107      * The user does not have any fingerprints enrolled.
108      */
109     int FINGERPRINT_ERROR_NO_FINGERPRINTS = 11;
110 
111     /**
112      * The device does not have a fingerprint sensor.
113      */
114     int FINGERPRINT_ERROR_HW_NOT_PRESENT = 12;
115 
116     /**
117      * The user pressed the negative button. This is a placeholder that is currently only used
118      * by the support library.
119      *
120      * @hide
121      */
122     int FINGERPRINT_ERROR_NEGATIVE_BUTTON = 13;
123 
124     /**
125      * The device does not have pin, pattern, or password set up. See
126      * {@link BiometricPrompt.Builder#setDeviceCredentialAllowed(boolean)} and
127      * {@link KeyguardManager#isDeviceSecure()}
128      *
129      * @hide
130      */
131     int BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL = 14;
132 
133     /**
134      * A security vulnerability has been discovered and the sensor is unavailable until a
135      * security update has addressed this issue. This error can be received if for example,
136      * authentication was requested with {@link Authenticators#BIOMETRIC_STRONG}, but the
137      * sensor's strength can currently only meet {@link Authenticators#BIOMETRIC_WEAK}.
138      * @hide
139      */
140     public static final int BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED = 15;
141 
142     /**
143      * @hide
144      */
145     @UnsupportedAppUsage
146     int FINGERPRINT_ERROR_VENDOR_BASE = 1000;
147 
148     //
149     // Image acquisition messages. Must agree with those in fingerprint.h
150     //
151 
152     /**
153      * The image acquired was good.
154      */
155     int FINGERPRINT_ACQUIRED_GOOD = 0;
156 
157     /**
158      * Only a partial fingerprint image was detected. During enrollment, the user should be
159      * informed on what needs to happen to resolve this problem, e.g. "press firmly on sensor."
160      */
161     int FINGERPRINT_ACQUIRED_PARTIAL = 1;
162 
163     /**
164      * The fingerprint image was too noisy to process due to a detected condition (i.e. dry skin) or
165      * a possibly dirty sensor (See {@link #FINGERPRINT_ACQUIRED_IMAGER_DIRTY}).
166      */
167     int FINGERPRINT_ACQUIRED_INSUFFICIENT = 2;
168 
169     /**
170      * The fingerprint image was too noisy due to suspected or detected dirt on the sensor.
171      * For example, it's reasonable return this after multiple
172      * {@link #FINGERPRINT_ACQUIRED_INSUFFICIENT} or actual detection of dirt on the sensor
173      * (stuck pixels, swaths, etc.). The user is expected to take action to clean the sensor
174      * when this is returned.
175      */
176     int FINGERPRINT_ACQUIRED_IMAGER_DIRTY = 3;
177 
178     /**
179      * The fingerprint image was unreadable due to lack of motion. This is most appropriate for
180      * linear array sensors that require a swipe motion.
181      */
182     int FINGERPRINT_ACQUIRED_TOO_SLOW = 4;
183 
184     /**
185      * The fingerprint image was incomplete due to quick motion. While mostly appropriate for
186      * linear array sensors,  this could also happen if the finger was moved during acquisition.
187      * The user should be asked to move the finger slower (linear) or leave the finger on the sensor
188      * longer.
189      */
190     int FINGERPRINT_ACQUIRED_TOO_FAST = 5;
191 
192     /**
193      * Hardware vendors may extend this list if there are conditions that do not fall under one of
194      * the above categories. Vendors are responsible for providing error strings for these errors.
195      *
196      * @hide
197      */
198     int FINGERPRINT_ACQUIRED_VENDOR = 6;
199 
200     /**
201      * This message represents the earliest message sent at the beginning of the authentication
202      * pipeline. It is expected to be used to measure latency. Note this should be sent whenever
203      * authentication is restarted.
204      * The framework will measure latency based on the time between the last START message and the
205      * onAuthenticated callback.
206      *
207      * @hide
208      */
209     int FINGERPRINT_ACQUIRED_START = 7;
210 
211     /**
212      * @hide
213      */
214     int FINGERPRINT_ACQUIRED_VENDOR_BASE = 1000;
215 }
216