• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 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.NonNull;
21 import android.annotation.Nullable;
22 import android.hardware.biometrics.BiometricAuthenticator.Modality;
23 import android.os.Bundle;
24 import android.view.WindowManager;
25 
26 import com.android.systemui.Dumpable;
27 
28 import java.lang.annotation.Retention;
29 import java.lang.annotation.RetentionPolicy;
30 
31 /**
32  * Interface for the biometric dialog UI.
33  */
34 public interface AuthDialog extends Dumpable {
35 
36     String KEY_CONTAINER_GOING_AWAY = "container_going_away";
37     String KEY_BIOMETRIC_SHOWING = "biometric_showing";
38     String KEY_CREDENTIAL_SHOWING = "credential_showing";
39 
40     String KEY_BIOMETRIC_CONFIRM_VISIBILITY = "confirm_visibility";
41     String KEY_BIOMETRIC_TRY_AGAIN_VISIBILITY = "try_agian_visibility";
42     String KEY_BIOMETRIC_STATE = "state";
43     String KEY_BIOMETRIC_INDICATOR_STRING = "indicator_string"; // error / help / hint
44     String KEY_BIOMETRIC_INDICATOR_ERROR_SHOWING = "error_is_temporary";
45     String KEY_BIOMETRIC_INDICATOR_HELP_SHOWING = "hint_is_temporary";
46     String KEY_BIOMETRIC_DIALOG_SIZE = "size";
47 
48     String KEY_BIOMETRIC_SENSOR_TYPE = "sensor_type";
49     String KEY_BIOMETRIC_SENSOR_PROPS = "sensor_props";
50 
51     String KEY_BIOMETRIC_ORIENTATION_CHANGED = "orientation_changed";
52 
53     int SIZE_UNKNOWN = 0;
54     /**
55      * Minimal UI, showing only biometric icon.
56      */
57     int SIZE_SMALL = 1;
58     /**
59      * Normal-sized biometric UI, showing title, icon, buttons, etc.
60      */
61     int SIZE_MEDIUM = 2;
62     /**
63      * Full-screen credential UI.
64      */
65     int SIZE_LARGE = 3;
66     @Retention(RetentionPolicy.SOURCE)
67     @IntDef({SIZE_UNKNOWN, SIZE_SMALL, SIZE_MEDIUM, SIZE_LARGE})
68     @interface DialogSize {}
69 
70     /**
71      * Parameters used when laying out {@link AuthBiometricView}, its subclasses, and
72      * {@link AuthPanelController}.
73      */
74     class LayoutParams {
75         final int mMediumHeight;
76         final int mMediumWidth;
77 
LayoutParams(int mediumWidth, int mediumHeight)78         LayoutParams(int mediumWidth, int mediumHeight) {
79             mMediumWidth = mediumWidth;
80             mMediumHeight = mediumHeight;
81         }
82     }
83 
84     /**
85      * Animation duration, from small to medium dialog, including back panel, icon translation, etc
86      */
87     int ANIMATE_SMALL_TO_MEDIUM_DURATION_MS = 150;
88     /**
89      * Animation duration from medium to large dialog, including biometric fade out, back panel, etc
90      */
91     int ANIMATE_MEDIUM_TO_LARGE_DURATION_MS = 450;
92     /**
93      * Delay before notifying {@link AuthCredentialView} to start animating in.
94      */
95     int ANIMATE_CREDENTIAL_START_DELAY_MS = ANIMATE_MEDIUM_TO_LARGE_DURATION_MS * 2 / 3;
96     /**
97      * Animation duration when sliding in credential UI
98      */
99     int ANIMATE_CREDENTIAL_INITIAL_DURATION_MS = 150;
100 
101     /**
102      * Show the dialog.
103      * @param wm
104      */
show(WindowManager wm, @Nullable Bundle savedState)105     void show(WindowManager wm, @Nullable Bundle savedState);
106 
107     /**
108      * Dismiss the dialog without sending a callback.
109      */
dismissWithoutCallback(boolean animate)110     void dismissWithoutCallback(boolean animate);
111 
112     /**
113      * Dismiss the dialog. Animate away.
114      */
dismissFromSystemServer()115     void dismissFromSystemServer();
116 
117     /**
118      * Biometric authenticated. May be pending user confirmation, or completed.
119      */
onAuthenticationSucceeded(@odality int modality)120     void onAuthenticationSucceeded(@Modality int modality);
121 
122     /**
123      * Authentication failed (reject, timeout). Dialog stays showing.
124      * @param modality sensor modality that triggered the error
125      * @param failureReason message
126      */
onAuthenticationFailed(@odality int modality, String failureReason)127     void onAuthenticationFailed(@Modality int modality, String failureReason);
128 
129     /**
130      * Authentication rejected, or help message received.
131      * @param modality sensor modality that triggered the help message
132      * @param help message
133      */
onHelp(@odality int modality, String help)134     void onHelp(@Modality int modality, String help);
135 
136     /**
137      * Authentication failed. Dialog going away.
138      * @param modality sensor modality that triggered the error
139      * @param error message
140      */
onError(@odality int modality, String error)141     void onError(@Modality int modality, String error);
142 
143     /** UDFPS pointer down event. */
onPointerDown()144     void onPointerDown();
145 
146     /**
147      * Save the current state.
148      * @param outState
149      */
onSaveState(@onNull Bundle outState)150     void onSaveState(@NonNull Bundle outState);
151 
152     /**
153      * Get the client's package name
154      */
getOpPackageName()155     String getOpPackageName();
156 
157     /** The requestId of the underlying operation within the framework. */
getRequestId()158     long getRequestId();
159 
160     /**
161      * Animate to credential UI. Typically called after biometric is locked out.
162      */
animateToCredentialUI()163     void animateToCredentialUI();
164 
165     /**
166      * @return true if device credential is allowed.
167      */
isAllowDeviceCredentials()168     boolean isAllowDeviceCredentials();
169 
170     /**
171      * Called when the device's orientation changed and the dialog may need to do another
172      * layout. This is most relevant to UDFPS since configuration changes are not sent by
173      * the framework in equivalent cases (landscape to reverse landscape) but the dialog
174      * must remain fixed on the physical sensor location.
175      */
onOrientationChanged()176     void onOrientationChanged();
177 }
178