blob: 446ed2572bab20bddbbbdaf505ac0a633b1c359b [file] [log] [blame]
Kevin Chynaae4a152018-01-18 11:48:09 -08001/*
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
Kevin Chynf8688a02019-08-27 17:04:05 -070014 * limitations under the License.
Kevin Chynaae4a152018-01-18 11:48:09 -080015 */
16
Kevin Chyne9275662018-07-23 16:42:06 -070017package com.android.systemui.biometrics;
Kevin Chynaae4a152018-01-18 11:48:09 -080018
Ilya Matyukhin0f9da352019-10-03 14:10:01 -070019import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FACE;
20import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FINGERPRINT;
21
Kevin Chyn050315f2019-08-08 14:22:54 -070022import android.app.ActivityManager;
23import android.app.ActivityTaskManager;
24import android.app.IActivityTaskManager;
25import android.app.TaskStackListener;
Kevin Chyn42653e82018-01-19 14:15:46 -080026import android.content.Context;
Kevin Chynaae4a152018-01-18 11:48:09 -080027import android.content.pm.PackageManager;
Gus Prevasa7df7b22018-10-30 10:29:34 -040028import android.content.res.Configuration;
Kevin Chyn86f1b8e2019-09-24 19:00:49 -070029import android.hardware.biometrics.Authenticator;
Kevin Chyn8429da22019-09-24 12:42:35 -070030import android.hardware.biometrics.BiometricConstants;
Vishwath Mohanecf00ce2018-04-05 10:28:24 -070031import android.hardware.biometrics.BiometricPrompt;
Kevin Chyn23289ef2018-11-28 16:32:36 -080032import android.hardware.biometrics.IBiometricServiceReceiverInternal;
Ilya Matyukhin0f9da352019-10-03 14:10:01 -070033import android.hardware.face.FaceManager;
34import android.hardware.fingerprint.FingerprintManager;
Kevin Chynaae4a152018-01-18 11:48:09 -080035import android.os.Bundle;
Kevin Chyn050315f2019-08-08 14:22:54 -070036import android.os.Handler;
37import android.os.Looper;
Kevin Chyn42653e82018-01-19 14:15:46 -080038import android.os.RemoteException;
Kevin Chynaae4a152018-01-18 11:48:09 -080039import android.util.Log;
Kevin Chyn42653e82018-01-19 14:15:46 -080040import android.view.WindowManager;
Kevin Chynaae4a152018-01-18 11:48:09 -080041
Ilya Matyukhin0f9da352019-10-03 14:10:01 -070042import com.android.internal.R;
Kevin Chyn050315f2019-08-08 14:22:54 -070043import com.android.internal.annotations.VisibleForTesting;
Kevin Chyn42653e82018-01-19 14:15:46 -080044import com.android.internal.os.SomeArgs;
Kevin Chynaae4a152018-01-18 11:48:09 -080045import com.android.systemui.SystemUI;
46import com.android.systemui.statusbar.CommandQueue;
47
Kevin Chyn050315f2019-08-08 14:22:54 -070048import java.util.List;
49
Kevin Chyne9275662018-07-23 16:42:06 -070050/**
Kevin Chync53d9812019-07-30 18:10:30 -070051 * Receives messages sent from {@link com.android.server.biometrics.BiometricService} and shows the
52 * appropriate biometric UI (e.g. BiometricDialogView).
Kevin Chyne9275662018-07-23 16:42:06 -070053 */
Kevin Chynf8688a02019-08-27 17:04:05 -070054public class AuthController extends SystemUI implements CommandQueue.Callbacks,
55 AuthDialogCallback {
Kevin Chynfc468262019-08-20 17:17:11 -070056
Kevin Chynf8688a02019-08-27 17:04:05 -070057 private static final String TAG = "BiometricPrompt/AuthController";
Kevin Chyn42653e82018-01-19 14:15:46 -080058 private static final boolean DEBUG = true;
59
Kevin Chyn050315f2019-08-08 14:22:54 -070060 private final Injector mInjector;
61
Kevin Chync53d9812019-07-30 18:10:30 -070062 // TODO: These should just be saved from onSaveState
Gus Prevasa7df7b22018-10-30 10:29:34 -040063 private SomeArgs mCurrentDialogArgs;
Kevin Chyn050315f2019-08-08 14:22:54 -070064 @VisibleForTesting
Kevin Chynf8688a02019-08-27 17:04:05 -070065 AuthDialog mCurrentDialog;
Kevin Chync53d9812019-07-30 18:10:30 -070066
Kevin Chyn050315f2019-08-08 14:22:54 -070067 private Handler mHandler = new Handler(Looper.getMainLooper());
Kevin Chyn42653e82018-01-19 14:15:46 -080068 private WindowManager mWindowManager;
Kevin Chyn050315f2019-08-08 14:22:54 -070069 @VisibleForTesting
70 IActivityTaskManager mActivityTaskManager;
71 @VisibleForTesting
72 BiometricTaskStackListener mTaskStackListener;
73 @VisibleForTesting
74 IBiometricServiceReceiverInternal mReceiver;
75
76 public class BiometricTaskStackListener extends TaskStackListener {
77 @Override
78 public void onTaskStackChanged() {
79 mHandler.post(mTaskStackChangedRunnable);
80 }
81 }
82
83 private final Runnable mTaskStackChangedRunnable = () -> {
84 if (mCurrentDialog != null) {
85 try {
86 final String clientPackage = mCurrentDialog.getOpPackageName();
87 Log.w(TAG, "Task stack changed, current client: " + clientPackage);
88 final List<ActivityManager.RunningTaskInfo> runningTasks =
89 mActivityTaskManager.getTasks(1);
90 if (!runningTasks.isEmpty()) {
91 final String topPackage = runningTasks.get(0).topActivity.getPackageName();
92 if (!topPackage.contentEquals(clientPackage)) {
93 Log.w(TAG, "Evicting client due to: " + topPackage);
94 mCurrentDialog.dismissWithoutCallback(true /* animate */);
95 mCurrentDialog = null;
Curtis Belmonteffa9d872019-10-24 12:55:01 -070096 if (mReceiver != null) {
97 mReceiver.onDialogDismissed(
98 BiometricPrompt.DISMISSED_REASON_USER_CANCEL);
99 mReceiver = null;
100 }
Kevin Chyn050315f2019-08-08 14:22:54 -0700101 }
102 }
103 } catch (RemoteException e) {
104 Log.e(TAG, "Remote exception", e);
105 }
106 }
107 };
Kevin Chyn42653e82018-01-19 14:15:46 -0800108
Kevin Chync53d9812019-07-30 18:10:30 -0700109 @Override
110 public void onTryAgainPressed() {
Curtis Belmonteffa9d872019-10-24 12:55:01 -0700111 if (mReceiver == null) {
112 Log.e(TAG, "onTryAgainPressed: Receiver is null");
113 return;
114 }
Kevin Chync53d9812019-07-30 18:10:30 -0700115 try {
116 mReceiver.onTryAgainPressed();
117 } catch (RemoteException e) {
118 Log.e(TAG, "RemoteException when handling try again", e);
Kevin Chyn5906c172018-07-23 15:43:02 -0700119 }
120 }
121
Kevin Chync53d9812019-07-30 18:10:30 -0700122 @Override
Kevin Chynff168dc2019-09-16 16:04:38 -0700123 public void onDeviceCredentialPressed() {
Curtis Belmonteffa9d872019-10-24 12:55:01 -0700124 if (mReceiver == null) {
125 Log.e(TAG, "onDeviceCredentialPressed: Receiver is null");
126 return;
127 }
Kevin Chynff168dc2019-09-16 16:04:38 -0700128 try {
129 mReceiver.onDeviceCredentialPressed();
130 } catch (RemoteException e) {
131 Log.e(TAG, "RemoteException when handling credential button", e);
132 }
133 }
134
135 @Override
Kevin Chyn050315f2019-08-08 14:22:54 -0700136 public void onDismissed(@DismissedReason int reason) {
Kevin Chync53d9812019-07-30 18:10:30 -0700137 switch (reason) {
Kevin Chynf8688a02019-08-27 17:04:05 -0700138 case AuthDialogCallback.DISMISSED_USER_CANCELED:
Kevin Chync53d9812019-07-30 18:10:30 -0700139 sendResultAndCleanUp(BiometricPrompt.DISMISSED_REASON_USER_CANCEL);
140 break;
141
Kevin Chynf8688a02019-08-27 17:04:05 -0700142 case AuthDialogCallback.DISMISSED_BUTTON_NEGATIVE:
Kevin Chync53d9812019-07-30 18:10:30 -0700143 sendResultAndCleanUp(BiometricPrompt.DISMISSED_REASON_NEGATIVE);
144 break;
145
Kevin Chynf8688a02019-08-27 17:04:05 -0700146 case AuthDialogCallback.DISMISSED_BUTTON_POSITIVE:
Kevin Chynff168dc2019-09-16 16:04:38 -0700147 sendResultAndCleanUp(BiometricPrompt.DISMISSED_REASON_BIOMETRIC_CONFIRMED);
Kevin Chync53d9812019-07-30 18:10:30 -0700148 break;
149
Kevin Chynff168dc2019-09-16 16:04:38 -0700150 case AuthDialogCallback.DISMISSED_BIOMETRIC_AUTHENTICATED:
151 sendResultAndCleanUp(
152 BiometricPrompt.DISMISSED_REASON_BIOMETRIC_CONFIRM_NOT_REQUIRED);
Kevin Chync53d9812019-07-30 18:10:30 -0700153 break;
154
Kevin Chynf8688a02019-08-27 17:04:05 -0700155 case AuthDialogCallback.DISMISSED_ERROR:
Kevin Chync53d9812019-07-30 18:10:30 -0700156 sendResultAndCleanUp(BiometricPrompt.DISMISSED_REASON_ERROR);
Kevin Chync53d9812019-07-30 18:10:30 -0700157 break;
Kevin Chyn050315f2019-08-08 14:22:54 -0700158
Kevin Chynf8688a02019-08-27 17:04:05 -0700159 case AuthDialogCallback.DISMISSED_BY_SYSTEM_SERVER:
Kevin Chyn050315f2019-08-08 14:22:54 -0700160 sendResultAndCleanUp(BiometricPrompt.DISMISSED_REASON_SERVER_REQUESTED);
161 break;
162
Kevin Chynff168dc2019-09-16 16:04:38 -0700163 case AuthDialogCallback.DISMISSED_CREDENTIAL_AUTHENTICATED:
164 sendResultAndCleanUp(BiometricPrompt.DISMISSED_REASON_CREDENTIAL_CONFIRMED);
165 break;
166
Kevin Chync53d9812019-07-30 18:10:30 -0700167 default:
168 Log.e(TAG, "Unhandled reason: " + reason);
169 break;
Kevin Chync94b7db2019-05-15 17:28:16 -0700170 }
Kevin Chync53d9812019-07-30 18:10:30 -0700171 }
172
Kevin Chyn050315f2019-08-08 14:22:54 -0700173 private void sendResultAndCleanUp(@DismissedReason int reason) {
Kevin Chync53d9812019-07-30 18:10:30 -0700174 if (mReceiver == null) {
Curtis Belmonteffa9d872019-10-24 12:55:01 -0700175 Log.e(TAG, "sendResultAndCleanUp: Receiver is null");
Kevin Chync53d9812019-07-30 18:10:30 -0700176 return;
177 }
178 try {
Kevin Chyn050315f2019-08-08 14:22:54 -0700179 mReceiver.onDialogDismissed(reason);
Kevin Chync53d9812019-07-30 18:10:30 -0700180 } catch (RemoteException e) {
181 Log.w(TAG, "Remote exception", e);
182 }
Kevin Chyn050315f2019-08-08 14:22:54 -0700183 onDialogDismissed(reason);
184 }
185
186 public static class Injector {
187 IActivityTaskManager getActivityTaskManager() {
188 return ActivityTaskManager.getService();
189 }
190 }
191
Dave Mankoffa5d8a392019-10-10 12:21:09 -0400192 public AuthController(Context context) {
193 this(context, new Injector());
Kevin Chyn050315f2019-08-08 14:22:54 -0700194 }
195
196 @VisibleForTesting
Dave Mankoffa5d8a392019-10-10 12:21:09 -0400197 AuthController(Context context, Injector injector) {
198 super(context);
Kevin Chyn050315f2019-08-08 14:22:54 -0700199 mInjector = injector;
Kevin Chync53d9812019-07-30 18:10:30 -0700200 }
Kevin Chync94b7db2019-05-15 17:28:16 -0700201
Kevin Chynaae4a152018-01-18 11:48:09 -0800202 @Override
203 public void start() {
Kevin Chyne1912712019-01-04 14:22:34 -0800204 final PackageManager pm = mContext.getPackageManager();
205 if (pm.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)
206 || pm.hasSystemFeature(PackageManager.FEATURE_FACE)
207 || pm.hasSystemFeature(PackageManager.FEATURE_IRIS)) {
Jason Monkd7c98552018-12-04 11:14:50 -0500208 getComponent(CommandQueue.class).addCallback(this);
Gus Prevasa7df7b22018-10-30 10:29:34 -0400209 mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
Kevin Chyn050315f2019-08-08 14:22:54 -0700210 mActivityTaskManager = mInjector.getActivityTaskManager();
211
212 try {
213 mTaskStackListener = new BiometricTaskStackListener();
214 mActivityTaskManager.registerTaskStackListener(mTaskStackListener);
215 } catch (RemoteException e) {
216 Log.w(TAG, "Unable to register task stack listener", e);
217 }
Gus Prevasa7df7b22018-10-30 10:29:34 -0400218 }
219 }
220
Kevin Chynaae4a152018-01-18 11:48:09 -0800221 @Override
Kevin Chyn86f1b8e2019-09-24 19:00:49 -0700222 public void showAuthenticationDialog(Bundle bundle, IBiometricServiceReceiverInternal receiver,
223 int biometricModality, boolean requireConfirmation, int userId, String opPackageName) {
224 final int authenticators = Utils.getAuthenticators(bundle);
225
Kevin Chyn158fefb2019-01-03 18:59:05 -0800226 if (DEBUG) {
Kevin Chyn86f1b8e2019-09-24 19:00:49 -0700227 Log.d(TAG, "showAuthenticationDialog, authenticators: " + authenticators
228 + ", biometricModality: " + biometricModality
Kevin Chyn158fefb2019-01-03 18:59:05 -0800229 + ", requireConfirmation: " + requireConfirmation);
230 }
Kevin Chyn42653e82018-01-19 14:15:46 -0800231 SomeArgs args = SomeArgs.obtain();
232 args.arg1 = bundle;
233 args.arg2 = receiver;
Kevin Chyn86f1b8e2019-09-24 19:00:49 -0700234 args.argi1 = biometricModality;
Kevin Chyn6cf54e82018-09-18 19:13:27 -0700235 args.arg3 = requireConfirmation;
Kevin Chyn1b9f8df2018-11-12 19:04:55 -0800236 args.argi2 = userId;
Kevin Chyn050315f2019-08-08 14:22:54 -0700237 args.arg4 = opPackageName;
Kevin Chync53d9812019-07-30 18:10:30 -0700238
239 boolean skipAnimation = false;
240 if (mCurrentDialog != null) {
241 Log.w(TAG, "mCurrentDialog: " + mCurrentDialog);
242 skipAnimation = true;
243 }
Kevin Chyn86f1b8e2019-09-24 19:00:49 -0700244
245 showDialog(args, skipAnimation, null /* savedState */);
Kevin Chynaae4a152018-01-18 11:48:09 -0800246 }
247
248 @Override
Ilya Matyukhin0f9da352019-10-03 14:10:01 -0700249 public void onBiometricAuthenticated() {
250 mCurrentDialog.onAuthenticationSucceeded();
Kevin Chyn42653e82018-01-19 14:15:46 -0800251 }
252
Kevin Chync53d9812019-07-30 18:10:30 -0700253 @Override
254 public void onBiometricHelp(String message) {
255 if (DEBUG) Log.d(TAG, "onBiometricHelp: " + message);
256
257 mCurrentDialog.onHelp(message);
Kevin Chyn42653e82018-01-19 14:15:46 -0800258 }
259
Ilya Matyukhin0f9da352019-10-03 14:10:01 -0700260 private String getErrorString(int modality, int error, int vendorCode) {
261 switch (modality) {
262 case TYPE_FACE:
263 return FaceManager.getErrorString(mContext, error, vendorCode);
Kevin Chyn8429da22019-09-24 12:42:35 -0700264
Ilya Matyukhin0f9da352019-10-03 14:10:01 -0700265 case TYPE_FINGERPRINT:
266 return FingerprintManager.getErrorString(mContext, error, vendorCode);
267
268 default:
269 return "";
270 }
271 }
272
273 @Override
274 public void onBiometricError(int modality, int error, int vendorCode) {
275 if (DEBUG) {
276 Log.d(TAG, String.format("onBiometricError(%d, %d, %d)", modality, error, vendorCode));
277 }
278
279 final boolean isLockout = (error == BiometricConstants.BIOMETRIC_ERROR_LOCKOUT)
280 || (error == BiometricConstants.BIOMETRIC_ERROR_LOCKOUT_PERMANENT);
281
282 // TODO(b/141025588): Create separate methods for handling hard and soft errors.
283 final boolean isSoftError = (error == BiometricConstants.BIOMETRIC_PAUSED_REJECTED
284 || error == BiometricConstants.BIOMETRIC_ERROR_TIMEOUT);
285
Kevin Chyn8429da22019-09-24 12:42:35 -0700286 if (mCurrentDialog.isAllowDeviceCredentials() && isLockout) {
Ilya Matyukhin0f9da352019-10-03 14:10:01 -0700287 if (DEBUG) Log.d(TAG, "onBiometricError, lockout");
Kevin Chyn8429da22019-09-24 12:42:35 -0700288 mCurrentDialog.animateToCredentialUI();
Ilya Matyukhin0f9da352019-10-03 14:10:01 -0700289 } else if (isSoftError) {
290 final String errorMessage = (error == BiometricConstants.BIOMETRIC_PAUSED_REJECTED)
291 ? mContext.getString(R.string.biometric_not_recognized)
292 : getErrorString(modality, error, vendorCode);
293 if (DEBUG) Log.d(TAG, "onBiometricError, soft error: " + errorMessage);
294 mCurrentDialog.onAuthenticationFailed(errorMessage);
Kevin Chyn8429da22019-09-24 12:42:35 -0700295 } else {
Ilya Matyukhin0f9da352019-10-03 14:10:01 -0700296 final String errorMessage = getErrorString(modality, error, vendorCode);
297 if (DEBUG) Log.d(TAG, "onBiometricError, hard error: " + errorMessage);
298 mCurrentDialog.onError(errorMessage);
Kevin Chyn8429da22019-09-24 12:42:35 -0700299 }
Kevin Chyn42653e82018-01-19 14:15:46 -0800300 }
301
Kevin Chync53d9812019-07-30 18:10:30 -0700302 @Override
Kevin Chyn86f1b8e2019-09-24 19:00:49 -0700303 public void hideAuthenticationDialog() {
304 if (DEBUG) Log.d(TAG, "hideAuthenticationDialog");
Kevin Chync53d9812019-07-30 18:10:30 -0700305
Kevin Chyn050315f2019-08-08 14:22:54 -0700306 mCurrentDialog.dismissFromSystemServer();
Kevin Chync53d9812019-07-30 18:10:30 -0700307 }
308
Kevin Chyn86f1b8e2019-09-24 19:00:49 -0700309 private void showDialog(SomeArgs args, boolean skipAnimation, Bundle savedState) {
Kevin Chync53d9812019-07-30 18:10:30 -0700310 mCurrentDialogArgs = args;
311 final int type = args.argi1;
Kevin Chyn050315f2019-08-08 14:22:54 -0700312 final Bundle biometricPromptBundle = (Bundle) args.arg1;
313 final boolean requireConfirmation = (boolean) args.arg3;
314 final int userId = args.argi2;
315 final String opPackageName = (String) args.arg4;
Kevin Chync53d9812019-07-30 18:10:30 -0700316
317 // Create a new dialog but do not replace the current one yet.
Kevin Chynf8688a02019-08-27 17:04:05 -0700318 final AuthDialog newDialog = buildDialog(
Kevin Chyn050315f2019-08-08 14:22:54 -0700319 biometricPromptBundle,
320 requireConfirmation,
321 userId,
322 type,
Kevin Chynfc468262019-08-20 17:17:11 -0700323 opPackageName,
Kevin Chyn86f1b8e2019-09-24 19:00:49 -0700324 skipAnimation);
Kevin Chync53d9812019-07-30 18:10:30 -0700325
326 if (newDialog == null) {
327 Log.e(TAG, "Unsupported type: " + type);
Kevin Chyn42653e82018-01-19 14:15:46 -0800328 return;
329 }
Kevin Chync53d9812019-07-30 18:10:30 -0700330
331 if (DEBUG) {
Kevin Chyn86f1b8e2019-09-24 19:00:49 -0700332 Log.d(TAG, "showDialog: " + args
Kevin Chync53d9812019-07-30 18:10:30 -0700333 + " savedState: " + savedState
334 + " mCurrentDialog: " + mCurrentDialog
335 + " newDialog: " + newDialog
Kevin Chyn86f1b8e2019-09-24 19:00:49 -0700336 + " type: " + type);
Kevin Chync53d9812019-07-30 18:10:30 -0700337 }
338
Kevin Chyn9cf89912019-08-30 13:33:58 -0700339 if (mCurrentDialog != null) {
Kevin Chync53d9812019-07-30 18:10:30 -0700340 // If somehow we're asked to show a dialog, the old one doesn't need to be animated
341 // away. This can happen if the app cancels and re-starts auth during configuration
342 // change. This is ugly because we also have to do things on onConfigurationChanged
343 // here.
344 mCurrentDialog.dismissWithoutCallback(false /* animate */);
345 }
346
347 mReceiver = (IBiometricServiceReceiverInternal) args.arg2;
348 mCurrentDialog = newDialog;
Kevin Chyn9cf89912019-08-30 13:33:58 -0700349 mCurrentDialog.show(mWindowManager, savedState);
Kevin Chync53d9812019-07-30 18:10:30 -0700350 }
351
Kevin Chyn050315f2019-08-08 14:22:54 -0700352 private void onDialogDismissed(@DismissedReason int reason) {
353 if (DEBUG) Log.d(TAG, "onDialogDismissed: " + reason);
Kevin Chync53d9812019-07-30 18:10:30 -0700354 if (mCurrentDialog == null) {
355 Log.w(TAG, "Dialog already dismissed");
Kevin Chyn42653e82018-01-19 14:15:46 -0800356 }
357 mReceiver = null;
Kevin Chync53d9812019-07-30 18:10:30 -0700358 mCurrentDialog = null;
Kevin Chyn23289ef2018-11-28 16:32:36 -0800359 }
360
Gus Prevasa7df7b22018-10-30 10:29:34 -0400361 @Override
362 protected void onConfigurationChanged(Configuration newConfig) {
Kevin Chyn02129b12018-11-01 16:47:12 -0700363 super.onConfigurationChanged(newConfig);
Kevin Chyne1912712019-01-04 14:22:34 -0800364
365 // Save the state of the current dialog (buttons showing, etc)
Kevin Chyne1912712019-01-04 14:22:34 -0800366 if (mCurrentDialog != null) {
Kevin Chync53d9812019-07-30 18:10:30 -0700367 final Bundle savedState = new Bundle();
Kevin Chyne1912712019-01-04 14:22:34 -0800368 mCurrentDialog.onSaveState(savedState);
Kevin Chync53d9812019-07-30 18:10:30 -0700369 mCurrentDialog.dismissWithoutCallback(false /* animate */);
370 mCurrentDialog = null;
Kevin Chyne1912712019-01-04 14:22:34 -0800371
Kevin Chyn27da7182019-09-11 12:17:55 -0700372 // Only show the dialog if necessary. If it was animating out, the dialog is supposed
373 // to send its pending callback immediately.
374 if (savedState.getInt(AuthDialog.KEY_CONTAINER_STATE)
375 != AuthContainerView.STATE_ANIMATING_OUT) {
Kevin Chyn8cbb4882019-09-19 16:49:02 -0700376 final boolean credentialShowing =
377 savedState.getBoolean(AuthDialog.KEY_CREDENTIAL_SHOWING);
Kevin Chyn86f1b8e2019-09-24 19:00:49 -0700378 if (credentialShowing) {
379 // TODO: Clean this up
380 Bundle bundle = (Bundle) mCurrentDialogArgs.arg1;
381 bundle.putInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED,
382 Authenticator.TYPE_CREDENTIAL);
383 }
Kevin Chyn8cbb4882019-09-19 16:49:02 -0700384
Kevin Chyn86f1b8e2019-09-24 19:00:49 -0700385 showDialog(mCurrentDialogArgs, true /* skipAnimation */, savedState);
Kevin Chyn27da7182019-09-11 12:17:55 -0700386 }
Gus Prevasa7df7b22018-10-30 10:29:34 -0400387 }
Kevin Chync53d9812019-07-30 18:10:30 -0700388 }
Kevin Chyne1912712019-01-04 14:22:34 -0800389
Kevin Chynf8688a02019-08-27 17:04:05 -0700390 protected AuthDialog buildDialog(Bundle biometricPromptBundle, boolean requireConfirmation,
Kevin Chyn86f1b8e2019-09-24 19:00:49 -0700391 int userId, int type, String opPackageName, boolean skipIntro) {
Kevin Chynd837ced2019-09-11 16:09:43 -0700392 return new AuthContainerView.Builder(mContext)
393 .setCallback(this)
394 .setBiometricPromptBundle(biometricPromptBundle)
395 .setRequireConfirmation(requireConfirmation)
396 .setUserId(userId)
397 .setOpPackageName(opPackageName)
398 .setSkipIntro(skipIntro)
399 .build(type);
Gus Prevasa7df7b22018-10-30 10:29:34 -0400400 }
Kevin Chynaae4a152018-01-18 11:48:09 -0800401}