1 /*
2  * Copyright (C) 2021 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.annotation.IntDef;
20 
21 import java.lang.annotation.Retention;
22 import java.lang.annotation.RetentionPolicy;
23 
24 /**
25  * Interface for handling state changes in biometric sensors.
26  * @hide
27  */
28 public abstract class BiometricStateListener extends IBiometricStateListener.Stub {
29     // Operation has not started yet.
30     public static final int STATE_IDLE = 0;
31 
32     // Enrollment is in progress.
33     public static final int STATE_ENROLLING = 1;
34 
35     // Lockscreen authentication in progress.
36     public static final int STATE_KEYGUARD_AUTH = 2;
37 
38     // BiometricPrompt authentication in progress.
39     public static final int STATE_BP_AUTH = 3;
40 
41     // Other Authentication State
42     public static final int STATE_AUTH_OTHER = 4;
43 
44     @IntDef({STATE_IDLE, STATE_ENROLLING, STATE_KEYGUARD_AUTH, STATE_BP_AUTH, STATE_AUTH_OTHER})
45     @Retention(RetentionPolicy.SOURCE)
46     public @interface State {
47     }
48 
49     // The sensor received a touch.
50     public static final int ACTION_SENSOR_TOUCH = 0;
51 
52     @IntDef({ACTION_SENSOR_TOUCH})
53     @Retention(RetentionPolicy.SOURCE)
54     public @interface Action {
55     }
56 
57     /**
58      * Defines behavior in response to state update
59      * @param newState new state of the biometric sensor
60      */
onStateChanged(@iometricStateListener.State int newState)61     public void onStateChanged(@BiometricStateListener.State int newState) {
62     }
63 
64 
65     /**
66      * Invoked when a biometric action has occurred.
67      */
onBiometricAction(@iometricStateListener.Action int action)68     public void onBiometricAction(@BiometricStateListener.Action int action) {
69     }
70 
71     /**
72      * Invoked when enrollment state changes for the specified user
73      */
onEnrollmentsChanged(int userId, int sensorId, boolean hasEnrollments)74     public void onEnrollmentsChanged(int userId, int sensorId, boolean hasEnrollments) {
75     }
76 
77 }
78