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     int DISMISSED_BUTTON_CONTENT_VIEW_MORE_OPTIONS = 8;
36 
37     @IntDef({DISMISSED_USER_CANCELED,
38             DISMISSED_BUTTON_NEGATIVE,
39             DISMISSED_BUTTON_POSITIVE,
40             DISMISSED_BIOMETRIC_AUTHENTICATED,
41             DISMISSED_ERROR,
42             DISMISSED_BY_SYSTEM_SERVER,
43             DISMISSED_CREDENTIAL_AUTHENTICATED,
44             DISMISSED_BUTTON_CONTENT_VIEW_MORE_OPTIONS})
45     @interface DismissedReason {}
46 
47     /**
48      * Invoked when the dialog is dismissed
49      * @param reason
50      * @param credentialAttestation the HAT received from LockSettingsService upon verification
51      */
onDismissed(@ismissedReason int reason, @Nullable byte[] credentialAttestation, long requestId)52     void onDismissed(@DismissedReason int reason,
53                      @Nullable byte[] credentialAttestation, long requestId);
54 
55     /**
56      * Invoked when the "try again" button is clicked
57      */
onTryAgainPressed(long requestId)58     void onTryAgainPressed(long requestId);
59 
60     /**
61      * Invoked when the "use password" button is clicked
62      */
onDeviceCredentialPressed(long requestId)63     void onDeviceCredentialPressed(long requestId);
64 
65     /**
66      * See {@link android.hardware.biometrics.BiometricPrompt.Builder
67      * #setReceiveSystemEvents(boolean)}
68      * @param event
69      */
onSystemEvent(int event, long requestId)70     void onSystemEvent(int event, long requestId);
71 
72     /**
73      * Notifies when the dialog has finished animating.
74      */
onDialogAnimatedIn(long requestId, boolean startFingerprintNow)75     void onDialogAnimatedIn(long requestId, boolean startFingerprintNow);
76 
77     /**
78      * Notifies that the fingerprint sensor should be started now.
79      */
onStartFingerprintNow(long requestId)80     void onStartFingerprintNow(long requestId);
81 }
82