• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 static android.hardware.biometrics.BiometricManager.Authenticators;
20 
21 import android.annotation.IntDef;
22 import android.compat.annotation.UnsupportedAppUsage;
23 import android.os.Build;
24 
25 import java.lang.annotation.Retention;
26 import java.lang.annotation.RetentionPolicy;
27 
28 /**
29  * Interface containing all of the biometric modality agnostic constants.
30  *
31  * NOTE: The error messages must be consistent between BiometricConstants, Biometric*Constants,
32  *       and the frameworks/support/biometric/.../BiometricConstants files.
33  *
34  * @hide
35  */
36 public interface BiometricConstants {
37     //
38     // Error messages from biometric hardware during initilization, enrollment, authentication or
39     // removal.
40     //
41 
42     /**
43      * This was not added here since it would update BiometricPrompt API. But, is used in
44      * BiometricManager.
45      * @hide
46      */
47     int BIOMETRIC_SUCCESS = 0;
48 
49     /**
50      * The hardware is unavailable. Try again later.
51      */
52     int BIOMETRIC_ERROR_HW_UNAVAILABLE = 1;
53 
54     /**
55      * Error state returned when the sensor was unable to process the current image.
56      */
57     int BIOMETRIC_ERROR_UNABLE_TO_PROCESS = 2;
58 
59     /**
60      * Error state returned when the current request has been running too long. This is intended to
61      * prevent programs from waiting for the biometric sensor indefinitely. The timeout is platform
62      * and sensor-specific, but is generally on the order of 30 seconds.
63      */
64     int BIOMETRIC_ERROR_TIMEOUT = 3;
65 
66     /**
67      * Error state returned for operations like enrollment; the operation cannot be completed
68      * because there's not enough storage remaining to complete the operation.
69      */
70     int BIOMETRIC_ERROR_NO_SPACE = 4;
71 
72     /**
73      * The operation was canceled because the biometric sensor is unavailable. For example, this may
74      * happen when the user is switched, the device is locked or another pending operation prevents
75      * or disables it.
76      */
77     int BIOMETRIC_ERROR_CANCELED = 5;
78 
79     /**
80      * The {@link BiometricManager#remove} call failed. Typically this will happen when the provided
81      * biometric id was incorrect.
82      *
83      * @hide
84      */
85     int BIOMETRIC_ERROR_UNABLE_TO_REMOVE = 6;
86 
87     /**
88      * The operation was canceled because the API is locked out due to too many attempts.
89      * This occurs after 5 failed attempts, and lasts for 30 seconds.
90      */
91     int BIOMETRIC_ERROR_LOCKOUT = 7;
92 
93     /**
94      * OEMs should use this constant if there are conditions that do not fit under any of the other
95      * publicly defined constants, and must provide appropriate strings for these
96      * errors to the {@link BiometricPrompt.AuthenticationCallback#onAuthenticationError(int,
97      * CharSequence)} callback. OEMs should expect that the error message will be shown to users.
98      */
99     int BIOMETRIC_ERROR_VENDOR = 8;
100 
101     /**
102      * The operation was canceled because BIOMETRIC_ERROR_LOCKOUT occurred too many times.
103      * Biometric authentication is disabled until the user unlocks with strong authentication
104      * (PIN/Pattern/Password)
105      */
106     int BIOMETRIC_ERROR_LOCKOUT_PERMANENT = 9;
107 
108     /**
109      * The user canceled the operation. Upon receiving this, applications should use alternate
110      * authentication (e.g. a password). The application should also provide the means to return to
111      * biometric authentication, such as a "use <biometric>" button.
112      */
113     int BIOMETRIC_ERROR_USER_CANCELED = 10;
114 
115     /**
116      * The user does not have any biometrics enrolled.
117      */
118     int BIOMETRIC_ERROR_NO_BIOMETRICS = 11;
119 
120     /**
121      * The device does not have a biometric sensor.
122      */
123     int BIOMETRIC_ERROR_HW_NOT_PRESENT = 12;
124 
125     /**
126      * The user pressed the negative button. This is a placeholder that is currently only used
127      * by the support library.
128      * @hide
129      */
130     int BIOMETRIC_ERROR_NEGATIVE_BUTTON = 13;
131 
132     /**
133      * The device does not have pin, pattern, or password set up. See
134      * {@link BiometricPrompt.Builder#setAllowedAuthenticators(int)},
135      * {@link Authenticators#DEVICE_CREDENTIAL}, and {@link BiometricManager#canAuthenticate(int)}.
136      */
137     int BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL = 14;
138 
139     /**
140      * A security vulnerability has been discovered and the sensor is unavailable until a
141      * security update has addressed this issue. This error can be received if for example,
142      * authentication was requested with {@link Authenticators#BIOMETRIC_STRONG}, but the
143      * sensor's strength can currently only meet {@link Authenticators#BIOMETRIC_WEAK}.
144      */
145     int BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED = 15;
146 
147     /**
148      * Authentication cannot proceed because re-enrollment is required.
149      * @hide
150      */
151     int BIOMETRIC_ERROR_RE_ENROLL = 16;
152 
153     /**
154      * This constant is only used by SystemUI. It notifies SystemUI that authentication was paused
155      * because the authentication attempt was unsuccessful.
156      * @hide
157      */
158     int BIOMETRIC_PAUSED_REJECTED = 100;
159 
160     /**
161      * @hide
162      */
163     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
164     int BIOMETRIC_ERROR_VENDOR_BASE = 1000;
165 
166     @IntDef({BIOMETRIC_SUCCESS,
167             BIOMETRIC_ERROR_HW_UNAVAILABLE,
168             BIOMETRIC_ERROR_UNABLE_TO_PROCESS,
169             BIOMETRIC_ERROR_TIMEOUT,
170             BIOMETRIC_ERROR_NO_SPACE,
171             BIOMETRIC_ERROR_CANCELED,
172             BIOMETRIC_ERROR_UNABLE_TO_REMOVE,
173             BIOMETRIC_ERROR_LOCKOUT,
174             BIOMETRIC_ERROR_VENDOR,
175             BIOMETRIC_ERROR_LOCKOUT_PERMANENT,
176             BIOMETRIC_ERROR_USER_CANCELED,
177             BIOMETRIC_ERROR_NO_BIOMETRICS,
178             BIOMETRIC_ERROR_HW_NOT_PRESENT,
179             BIOMETRIC_ERROR_NEGATIVE_BUTTON,
180             BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL,
181             BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED,
182             BIOMETRIC_PAUSED_REJECTED})
183     @Retention(RetentionPolicy.SOURCE)
184     @interface Errors {}
185 
186     //
187     // Image acquisition messages.
188     //
189 
190     /**
191      * @hide
192      */
193     @IntDef({BIOMETRIC_ACQUIRED_GOOD,
194             BIOMETRIC_ACQUIRED_PARTIAL,
195             BIOMETRIC_ACQUIRED_INSUFFICIENT,
196             BIOMETRIC_ACQUIRED_IMAGER_DIRTY,
197             BIOMETRIC_ACQUIRED_TOO_SLOW,
198             BIOMETRIC_ACQUIRED_TOO_FAST,
199             BIOMETRIC_ACQUIRED_VENDOR})
200     @Retention(RetentionPolicy.SOURCE)
201     @interface Acquired {}
202 
203     /**
204      * The image acquired was good.
205      */
206     int BIOMETRIC_ACQUIRED_GOOD = 0;
207 
208     /**
209      * Only a partial biometric image was detected. During enrollment, the user should be informed
210      * on what needs to happen to resolve this problem, e.g. "press firmly on sensor." (for
211      * fingerprint)
212      */
213     int BIOMETRIC_ACQUIRED_PARTIAL = 1;
214 
215     /**
216      * The biometric image was too noisy to process due to a detected condition or a possibly dirty
217      * sensor (See {@link #BIOMETRIC_ACQUIRED_IMAGER_DIRTY}).
218      */
219     int BIOMETRIC_ACQUIRED_INSUFFICIENT = 2;
220 
221     /**
222      * The biometric image was too noisy due to suspected or detected dirt on the sensor.  For
223      * example, it's reasonable return this after multiple {@link #BIOMETRIC_ACQUIRED_INSUFFICIENT}
224      * or actual detection of dirt on the sensor (stuck pixels, swaths, etc.). The user is expected
225      * to take action to clean the sensor when this is returned.
226      */
227     int BIOMETRIC_ACQUIRED_IMAGER_DIRTY = 3;
228 
229     /**
230      * The biometric image was unreadable due to lack of motion.
231      */
232     int BIOMETRIC_ACQUIRED_TOO_SLOW = 4;
233 
234     /**
235      * The biometric image was incomplete due to quick motion. For example, this could also happen
236      * if the user moved during acquisition. The user should be asked to repeat the operation more
237      * slowly.
238      */
239     int BIOMETRIC_ACQUIRED_TOO_FAST = 5;
240 
241     /**
242      * Hardware vendors may extend this list if there are conditions that do not fall under one of
243      * the above categories. Vendors are responsible for providing error strings for these errors.
244      * @hide
245      */
246     int BIOMETRIC_ACQUIRED_VENDOR = 6;
247     /**
248      * @hide
249      */
250     int BIOMETRIC_ACQUIRED_VENDOR_BASE = 1000;
251 
252     //
253     // Internal messages.
254     //
255 
256     /**
257      * See {@link BiometricPrompt.Builder#setReceiveSystemEvents(boolean)}. This message is sent
258      * immediately when the user cancels authentication for example by tapping the back button or
259      * tapping the scrim. This is before {@link #BIOMETRIC_ERROR_USER_CANCELED}, which is sent when
260      * dismissal animation completes.
261      * @hide
262      */
263     int BIOMETRIC_SYSTEM_EVENT_EARLY_USER_CANCEL = 1;
264 
265 }
266