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.hardware.fingerprint.FingerprintManager;
20 
21 /**
22  * Interface containing all of the fingerprint-specific constants.
23  * @hide
24  */
25 public interface BiometricFingerprintConstants {
26     //
27     // Error messages from fingerprint hardware during initilization, enrollment, authentication or
28     // removal. Must agree with the list in fingerprint.h
29     //
30 
31     /**
32      * The hardware is unavailable. Try again later.
33      */
34     public static final int FINGERPRINT_ERROR_HW_UNAVAILABLE = 1;
35 
36     /**
37      * Error state returned when the sensor was unable to process the current image.
38      */
39     public static final int FINGERPRINT_ERROR_UNABLE_TO_PROCESS = 2;
40 
41     /**
42      * Error state returned when the current request has been running too long. This is intended to
43      * prevent programs from waiting for the fingerprint sensor indefinitely. The timeout is
44      * platform and sensor-specific, but is generally on the order of 30 seconds.
45      */
46     public static final int FINGERPRINT_ERROR_TIMEOUT = 3;
47 
48     /**
49      * Error state returned for operations like enrollment; the operation cannot be completed
50      * because there's not enough storage remaining to complete the operation.
51      */
52     public static final int FINGERPRINT_ERROR_NO_SPACE = 4;
53 
54     /**
55      * The operation was canceled because the fingerprint sensor is unavailable. For example,
56      * this may happen when the user is switched, the device is locked or another pending operation
57      * prevents or disables it.
58      */
59     public static final int FINGERPRINT_ERROR_CANCELED = 5;
60 
61     /**
62      * The {@link FingerprintManager#remove} call failed. Typically this will happen when the
63      * provided fingerprint id was incorrect.
64      *
65      * @hide
66      */
67     public static final int FINGERPRINT_ERROR_UNABLE_TO_REMOVE = 6;
68 
69     /**
70      * The operation was canceled because the API is locked out due to too many attempts.
71      * This occurs after 5 failed attempts, and lasts for 30 seconds.
72      */
73     public static final int FINGERPRINT_ERROR_LOCKOUT = 7;
74 
75     /**
76      * Hardware vendors may extend this list if there are conditions that do not fall under one of
77      * the above categories. Vendors are responsible for providing error strings for these errors.
78      * These messages are typically reserved for internal operations such as enrollment, but may be
79      * used to express vendor errors not covered by the ones in fingerprint.h. Applications are
80      * expected to show the error message string if they happen, but are advised not to rely on the
81      * message id since they will be device and vendor-specific
82      */
83     public static final int FINGERPRINT_ERROR_VENDOR = 8;
84 
85     /**
86      * The operation was canceled because FINGERPRINT_ERROR_LOCKOUT occurred too many times.
87      * Fingerprint authentication is disabled until the user unlocks with strong authentication
88      * (PIN/Pattern/Password)
89      */
90     public static final int FINGERPRINT_ERROR_LOCKOUT_PERMANENT = 9;
91 
92     /**
93      * The user canceled the operation. Upon receiving this, applications should use alternate
94      * authentication (e.g. a password). The application should also provide the means to return
95      * to fingerprint authentication, such as a "use fingerprint" button.
96      */
97     public static final int FINGERPRINT_ERROR_USER_CANCELED = 10;
98 
99     /**
100      * The user does not have any fingerprints enrolled.
101      */
102     public static final int FINGERPRINT_ERROR_NO_FINGERPRINTS = 11;
103 
104     /**
105      * The device does not have a fingerprint sensor.
106      */
107     public static final int FINGERPRINT_ERROR_HW_NOT_PRESENT = 12;
108 
109     /**
110      * @hide
111      */
112     public static final int FINGERPRINT_ERROR_VENDOR_BASE = 1000;
113 
114     //
115     // Image acquisition messages. Must agree with those in fingerprint.h
116     //
117 
118     /**
119      * The image acquired was good.
120      */
121     public static final int FINGERPRINT_ACQUIRED_GOOD = 0;
122 
123     /**
124      * Only a partial fingerprint image was detected. During enrollment, the user should be
125      * informed on what needs to happen to resolve this problem, e.g. "press firmly on sensor."
126      */
127     public static final int FINGERPRINT_ACQUIRED_PARTIAL = 1;
128 
129     /**
130      * The fingerprint image was too noisy to process due to a detected condition (i.e. dry skin) or
131      * a possibly dirty sensor (See {@link #FINGERPRINT_ACQUIRED_IMAGER_DIRTY}).
132      */
133     public static final int FINGERPRINT_ACQUIRED_INSUFFICIENT = 2;
134 
135     /**
136      * The fingerprint image was too noisy due to suspected or detected dirt on the sensor.
137      * For example, it's reasonable return this after multiple
138      * {@link #FINGERPRINT_ACQUIRED_INSUFFICIENT} or actual detection of dirt on the sensor
139      * (stuck pixels, swaths, etc.). The user is expected to take action to clean the sensor
140      * when this is returned.
141      */
142     public static final int FINGERPRINT_ACQUIRED_IMAGER_DIRTY = 3;
143 
144     /**
145      * The fingerprint image was unreadable due to lack of motion. This is most appropriate for
146      * linear array sensors that require a swipe motion.
147      */
148     public static final int FINGERPRINT_ACQUIRED_TOO_SLOW = 4;
149 
150     /**
151      * The fingerprint image was incomplete due to quick motion. While mostly appropriate for
152      * linear array sensors,  this could also happen if the finger was moved during acquisition.
153      * The user should be asked to move the finger slower (linear) or leave the finger on the sensor
154      * longer.
155      */
156     public static final int FINGERPRINT_ACQUIRED_TOO_FAST = 5;
157 
158     /**
159      * Hardware vendors may extend this list if there are conditions that do not fall under one of
160      * the above categories. Vendors are responsible for providing error strings for these errors.
161      * @hide
162      */
163     public static final int FINGERPRINT_ACQUIRED_VENDOR = 6;
164     /**
165      * @hide
166      */
167     public static final int FINGERPRINT_ACQUIRED_VENDOR_BASE = 1000;
168 }
169