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.hardware.biometrics.BiometricManager.Authenticators;
21 import android.hardware.face.FaceManager;
22 
23 /**
24  * Interface containing all of the face-specific constants.
25  *
26  * NOTE: The error messages must be consistent between BiometricConstants, Biometric*Constants,
27  *       and the frameworks/support/biometric/.../BiometricConstants files.
28  *
29  * @hide
30  */
31 public interface BiometricFaceConstants {
32     //
33     // Accessibility constants
34     //
35     /**
36      * Require the user to look at the device during enrollment and
37      * authentication. Note this is to accommodate people who have limited
38      * vision.
39      */
40     int FEATURE_REQUIRE_ATTENTION = 1;
41     /**
42      * Require a diverse set of poses during enrollment. Note this is to
43      * accommodate people with limited mobility.
44      */
45     int FEATURE_REQUIRE_REQUIRE_DIVERSITY = 2;
46 
47     //
48     // Error messages from face authentication hardware during initialization, enrollment,
49     // authentication or removal. Must agree with the list in HAL h file
50     //
51     /**
52      * The hardware is unavailable. Try again later.
53      */
54     int FACE_ERROR_HW_UNAVAILABLE = 1;
55 
56     /**
57      * Error state returned when the sensor was unable to process the current image.
58      */
59     int FACE_ERROR_UNABLE_TO_PROCESS = 2;
60 
61     /**
62      * Error state returned when the current request has been running too long. This is intended to
63      * prevent programs from waiting for the face authentication sensor indefinitely. The timeout is
64      * platform and sensor-specific, but is generally on the order of 30 seconds.
65      */
66     int FACE_ERROR_TIMEOUT = 3;
67 
68     /**
69      * Error state returned for operations like enrollment; the operation cannot be completed
70      * because there's not enough storage remaining to complete the operation.
71      */
72     int FACE_ERROR_NO_SPACE = 4;
73 
74     /**
75      * The operation was canceled because the face authentication sensor is unavailable. For
76      * example, this may happen when the user is switched, the device is locked or another pending
77      * operation prevents or disables it.
78      */
79     int FACE_ERROR_CANCELED = 5;
80 
81     /**
82      * The {@link FaceManager#remove} call failed. Typically this will happen when the
83      * provided face id was incorrect.
84      *
85      * @hide
86      */
87     int FACE_ERROR_UNABLE_TO_REMOVE = 6;
88 
89     /**
90      * The operation was canceled because the API is locked out due to too many attempts.
91      * This occurs after 5 failed attempts, and lasts for 30 seconds.
92      */
93     int FACE_ERROR_LOCKOUT = 7;
94 
95     /**
96      * Hardware vendors may extend this list if there are conditions that do not fall under one of
97      * the above categories. Vendors are responsible for providing error strings for these errors.
98      * These messages are typically reserved for internal operations such as enrollment, but may be
99      * used to express vendor errors not covered by the ones in HAL h file. Applications are
100      * expected to show the error message string if they happen, but are advised not to rely on the
101      * message id since they will be device and vendor-specific
102      */
103     int FACE_ERROR_VENDOR = 8;
104 
105     /**
106      * The operation was canceled because FACE_ERROR_LOCKOUT occurred too many times.
107      * Face authentication is disabled until the user unlocks with strong authentication
108      * (PIN/Pattern/Password)
109      */
110     int FACE_ERROR_LOCKOUT_PERMANENT = 9;
111 
112     /**
113      * The user canceled the operation. Upon receiving this, applications should use alternate
114      * authentication (e.g. a password). The application should also provide the means to return
115      * to face authentication, such as a "use face authentication" button.
116      */
117     int FACE_ERROR_USER_CANCELED = 10;
118 
119     /**
120      * The user does not have a face enrolled.
121      */
122     int FACE_ERROR_NOT_ENROLLED = 11;
123 
124     /**
125      * The device does not have a face sensor. This message will propagate if the calling app
126      * ignores the result from PackageManager.hasFeature(FEATURE_FACE) and calls
127      * this API anyway. Apps should always check for the feature before calling this API.
128      */
129     int FACE_ERROR_HW_NOT_PRESENT = 12;
130 
131     /**
132      * The user pressed the negative button. This is a placeholder that is currently only used
133      * by the support library.
134      *
135      * @hide
136      */
137     int FACE_ERROR_NEGATIVE_BUTTON = 13;
138 
139     /**
140      * The device does not have pin, pattern, or password set up. See
141      * {@link BiometricPrompt.Builder#setDeviceCredentialAllowed(boolean)} and
142      * {@link KeyguardManager#isDeviceSecure()}
143      */
144     int BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL = 14;
145 
146     /**
147      * A security vulnerability has been discovered and the sensor is unavailable until a
148      * security update has addressed this issue. This error can be received if for example,
149      * authentication was requested with {@link Authenticators#BIOMETRIC_STRONG}, but the
150      * sensor's strength can currently only meet {@link Authenticators#BIOMETRIC_WEAK}.
151      * @hide
152      */
153     int BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED = 15;
154 
155     /**
156      * @hide
157      */
158     int FACE_ERROR_VENDOR_BASE = 1000;
159 
160     //
161     // Image acquisition messages. These will not be sent to the user, since they conflict with
162     // existing constants. These must agree with face@1.0/types.hal.
163     //
164 
165     /**
166      * The image acquired was good.
167      */
168     int FACE_ACQUIRED_GOOD = 0;
169 
170     /**
171      * The face image was not good enough to process due to a detected condition.
172      * (See {@link #FACE_ACQUIRED_TOO_BRIGHT or @link #FACE_ACQUIRED_TOO_DARK}).
173      */
174     int FACE_ACQUIRED_INSUFFICIENT = 1;
175 
176     /**
177      * The face image was too bright due to too much ambient light.
178      * For example, it's reasonable to return this after multiple
179      * {@link #FACE_ACQUIRED_INSUFFICIENT}
180      * The user is expected to take action to retry in better lighting conditions
181      * when this is returned.
182      */
183     int FACE_ACQUIRED_TOO_BRIGHT = 2;
184 
185     /**
186      * The face image was too dark due to illumination light obscured.
187      * For example, it's reasonable to return this after multiple
188      * {@link #FACE_ACQUIRED_INSUFFICIENT}
189      * The user is expected to take action to retry in better lighting conditions
190      * when this is returned.
191      */
192     int FACE_ACQUIRED_TOO_DARK = 3;
193 
194     /**
195      * The detected face is too close to the sensor, and the image can't be processed.
196      * The user should be informed to move farther from the sensor when this is returned.
197      */
198     int FACE_ACQUIRED_TOO_CLOSE = 4;
199 
200     /**
201      * The detected face is too small, as the user might be too far from the sensor.
202      * The user should be informed to move closer to the sensor when this is returned.
203      */
204     int FACE_ACQUIRED_TOO_FAR = 5;
205 
206     /**
207      * Only the upper part of the face was detected. The sensor field of view is too high.
208      * The user should be informed to move up with respect to the sensor when this is returned.
209      */
210     int FACE_ACQUIRED_TOO_HIGH = 6;
211 
212     /**
213      * Only the lower part of the face was detected. The sensor field of view is too low.
214      * The user should be informed to move down with respect to the sensor when this is returned.
215      */
216     int FACE_ACQUIRED_TOO_LOW = 7;
217 
218     /**
219      * Only the right part of the face was detected. The sensor field of view is too far right.
220      * The user should be informed to move to the right with respect to the sensor
221      * when this is returned.
222      */
223     int FACE_ACQUIRED_TOO_RIGHT = 8;
224 
225     /**
226      * Only the left part of the face was detected. The sensor field of view is too far left.
227      * The user should be informed to move to the left with respect to the sensor
228      * when this is returned.
229      */
230     int FACE_ACQUIRED_TOO_LEFT = 9;
231 
232     /**
233      * The user's eyes have strayed away from the sensor. If this message is sent, the user should
234      * be informed to look at the device. If the user can't be found in the frame, one of the other
235      * acquisition messages should be sent, e.g. FACE_ACQUIRED_NOT_DETECTED.
236      */
237     int FACE_ACQUIRED_POOR_GAZE = 10;
238 
239     /**
240      * No face was detected in front of the sensor.
241      * The user should be informed to point the sensor to a face when this is returned.
242      */
243     int FACE_ACQUIRED_NOT_DETECTED = 11;
244 
245     /**
246      * Too much motion was detected.
247      * The user should be informed to keep their face steady relative to the
248      * sensor.
249      */
250     int FACE_ACQUIRED_TOO_MUCH_MOTION = 12;
251 
252     /**
253      * The sensor needs to be re-calibrated. This is an unexpected condition, and should only be
254      * sent if a serious, uncorrectable, and unrecoverable calibration issue is detected which
255      * requires user intervention, e.g. re-enrolling. The expected response to this message is to
256      * direct the user to re-enroll.
257      */
258     int FACE_ACQUIRED_RECALIBRATE = 13;
259 
260     /**
261      * The face is too different from a previous acquisition. This condition
262      * only applies to enrollment. This can happen if the user passes the
263      * device to someone else in the middle of enrollment.
264      */
265     int FACE_ACQUIRED_TOO_DIFFERENT = 14;
266 
267     /**
268      * The face is too similar to a previous acquisition. This condition only
269      * applies to enrollment. The user should change their pose.
270      */
271     int FACE_ACQUIRED_TOO_SIMILAR = 15;
272 
273     /**
274      * The magnitude of the pan angle of the user’s face with respect to the sensor’s
275      * capture plane is too high.
276      *
277      * The pan angle is defined as the angle swept out by the user’s face turning
278      * their neck left and right. The pan angle would be zero if the user faced the
279      * camera directly.
280      *
281      * The user should be informed to look more directly at the camera.
282      */
283     int FACE_ACQUIRED_PAN_TOO_EXTREME = 16;
284 
285     /**
286      * The magnitude of the tilt angle of the user’s face with respect to the sensor’s
287      * capture plane is too high.
288      *
289      * The tilt angle is defined as the angle swept out by the user’s face looking up
290      * and down. The tilt angle would be zero if the user faced the camera directly.
291      *
292      * The user should be informed to look more directly at the camera.
293      */
294     int FACE_ACQUIRED_TILT_TOO_EXTREME = 17;
295 
296     /**
297      * The magnitude of the roll angle of the user’s face with respect to the sensor’s
298      * capture plane is too high.
299      *
300      * The roll angle is defined as the angle swept out by the user’s face tilting their head
301      * towards their shoulders to the left and right. The roll angle would be zero if the user's
302      * head is vertically aligned with the camera.
303      *
304      * The user should be informed to look more directly at the camera.
305      */
306     int FACE_ACQUIRED_ROLL_TOO_EXTREME = 18;
307 
308     /**
309      * The user’s face has been obscured by some object.
310      *
311      * The user should be informed to remove any objects from the line of sight from
312      * the sensor to the user’s face.
313      */
314     int FACE_ACQUIRED_FACE_OBSCURED = 19;
315 
316     /**
317      * This message represents the earliest message sent at the beginning of the authentication
318      * pipeline. It is expected to be used to measure latency. For example, in a camera-based
319      * authentication system it's expected to be sent prior to camera initialization. Note this
320      * should be sent whenever authentication is restarted (see IBiometricsFace#userActivity).
321      * The framework will measure latency based on the time between the last START message and the
322      * onAuthenticated callback.
323      */
324     int FACE_ACQUIRED_START = 20;
325 
326     /**
327      * The sensor is dirty. The user should be informed to clean the sensor.
328      */
329     int FACE_ACQUIRED_SENSOR_DIRTY = 21;
330 
331     /**
332      * Hardware vendors may extend this list if there are conditions that do not fall under one of
333      * the above categories. Vendors are responsible for providing error strings for these errors.
334      *
335      * @hide
336      */
337     int FACE_ACQUIRED_VENDOR = 22;
338 
339     /**
340      * @hide
341      */
342     int FACE_ACQUIRED_VENDOR_BASE = 1000;
343 }
344