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 com.android.systemui.biometrics;
18 
19 import android.annotation.IntDef;
20 import android.annotation.Nullable;
21 
22 /**
23  * Callback interface for dialog views. These should be implemented by the controller (e.g.
24  * FingerprintDialogImpl) and passed into their views (e.g. FingerprintDialogView).
25  */
26 public interface AuthDialogCallback {
27 
28     int DISMISSED_USER_CANCELED = 1;
29     int DISMISSED_BUTTON_NEGATIVE = 2;
30     int DISMISSED_BUTTON_POSITIVE = 3;
31     int DISMISSED_BIOMETRIC_AUTHENTICATED = 4;
32     int DISMISSED_ERROR = 5;
33     int DISMISSED_BY_SYSTEM_SERVER = 6;
34     int DISMISSED_CREDENTIAL_AUTHENTICATED = 7;
35 
36     @IntDef({DISMISSED_USER_CANCELED,
37             DISMISSED_BUTTON_NEGATIVE,
38             DISMISSED_BUTTON_POSITIVE,
39             DISMISSED_BIOMETRIC_AUTHENTICATED,
40             DISMISSED_ERROR,
41             DISMISSED_BY_SYSTEM_SERVER,
42             DISMISSED_CREDENTIAL_AUTHENTICATED})
43     @interface DismissedReason {}
44 
45     /**
46      * Invoked when the dialog is dismissed
47      * @param reason
48      * @param credentialAttestation the HAT received from LockSettingsService upon verification
49      */
onDismissed(@ismissedReason int reason, @Nullable byte[] credentialAttestation, long requestId)50     void onDismissed(@DismissedReason int reason,
51                      @Nullable byte[] credentialAttestation, long requestId);
52 
53     /**
54      * Invoked when the "try again" button is clicked
55      */
onTryAgainPressed(long requestId)56     void onTryAgainPressed(long requestId);
57 
58     /**
59      * Invoked when the "use password" button is clicked
60      */
onDeviceCredentialPressed(long requestId)61     void onDeviceCredentialPressed(long requestId);
62 
63     /**
64      * See {@link android.hardware.biometrics.BiometricPrompt.Builder
65      * #setReceiveSystemEvents(boolean)}
66      * @param event
67      */
onSystemEvent(int event, long requestId)68     void onSystemEvent(int event, long requestId);
69 
70     /**
71      * Notifies when the dialog has finished animating.
72      */
onDialogAnimatedIn(long requestId, boolean startFingerprintNow)73     void onDialogAnimatedIn(long requestId, boolean startFingerprintNow);
74 
75     /**
76      * Notifies that the fingerprint sensor should be started now.
77      */
onStartFingerprintNow(long requestId)78     void onStartFingerprintNow(long requestId);
79 }
80