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