Kevin Chyn | aae4a15 | 2018-01-18 11:48:09 -0800 | [diff] [blame] | 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 | |
Kevin Chyn | e927566 | 2018-07-23 16:42:06 -0700 | [diff] [blame] | 17 | package com.android.systemui.biometrics; |
Kevin Chyn | aae4a15 | 2018-01-18 11:48:09 -0800 | [diff] [blame] | 18 | |
Kevin Chyn | 050315f | 2019-08-08 14:22:54 -0700 | [diff] [blame] | 19 | import android.app.ActivityManager; |
| 20 | import android.app.ActivityTaskManager; |
| 21 | import android.app.IActivityTaskManager; |
| 22 | import android.app.TaskStackListener; |
Kevin Chyn | 42653e8 | 2018-01-19 14:15:46 -0800 | [diff] [blame] | 23 | import android.content.Context; |
Kevin Chyn | aae4a15 | 2018-01-18 11:48:09 -0800 | [diff] [blame] | 24 | import android.content.pm.PackageManager; |
Gus Prevas | a7df7b2 | 2018-10-30 10:29:34 -0400 | [diff] [blame] | 25 | import android.content.res.Configuration; |
Vishwath Mohan | ecf00ce | 2018-04-05 10:28:24 -0700 | [diff] [blame] | 26 | import android.hardware.biometrics.BiometricPrompt; |
Kevin Chyn | 23289ef | 2018-11-28 16:32:36 -0800 | [diff] [blame] | 27 | import android.hardware.biometrics.IBiometricServiceReceiverInternal; |
Kevin Chyn | aae4a15 | 2018-01-18 11:48:09 -0800 | [diff] [blame] | 28 | import android.os.Bundle; |
Kevin Chyn | 050315f | 2019-08-08 14:22:54 -0700 | [diff] [blame] | 29 | import android.os.Handler; |
| 30 | import android.os.Looper; |
Kevin Chyn | 42653e8 | 2018-01-19 14:15:46 -0800 | [diff] [blame] | 31 | import android.os.RemoteException; |
Kevin Chyn | fc46826 | 2019-08-20 17:17:11 -0700 | [diff] [blame^] | 32 | import android.provider.Settings; |
Kevin Chyn | aae4a15 | 2018-01-18 11:48:09 -0800 | [diff] [blame] | 33 | import android.util.Log; |
Kevin Chyn | 42653e8 | 2018-01-19 14:15:46 -0800 | [diff] [blame] | 34 | import android.view.WindowManager; |
Kevin Chyn | aae4a15 | 2018-01-18 11:48:09 -0800 | [diff] [blame] | 35 | |
Kevin Chyn | 050315f | 2019-08-08 14:22:54 -0700 | [diff] [blame] | 36 | import com.android.internal.annotations.VisibleForTesting; |
Kevin Chyn | 42653e8 | 2018-01-19 14:15:46 -0800 | [diff] [blame] | 37 | import com.android.internal.os.SomeArgs; |
Kevin Chyn | aae4a15 | 2018-01-18 11:48:09 -0800 | [diff] [blame] | 38 | import com.android.systemui.SystemUI; |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 39 | import com.android.systemui.biometrics.ui.BiometricDialogView; |
Kevin Chyn | fc46826 | 2019-08-20 17:17:11 -0700 | [diff] [blame^] | 40 | import com.android.systemui.biometrics.ui.AuthContainerView; |
Kevin Chyn | aae4a15 | 2018-01-18 11:48:09 -0800 | [diff] [blame] | 41 | import com.android.systemui.statusbar.CommandQueue; |
| 42 | |
Kevin Chyn | 050315f | 2019-08-08 14:22:54 -0700 | [diff] [blame] | 43 | import java.util.List; |
| 44 | |
Kevin Chyn | e927566 | 2018-07-23 16:42:06 -0700 | [diff] [blame] | 45 | /** |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 46 | * Receives messages sent from {@link com.android.server.biometrics.BiometricService} and shows the |
| 47 | * appropriate biometric UI (e.g. BiometricDialogView). |
Kevin Chyn | e927566 | 2018-07-23 16:42:06 -0700 | [diff] [blame] | 48 | */ |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 49 | public class BiometricDialogImpl extends SystemUI implements CommandQueue.Callbacks, |
| 50 | DialogViewCallback { |
Kevin Chyn | fc46826 | 2019-08-20 17:17:11 -0700 | [diff] [blame^] | 51 | private static final String USE_NEW_DIALOG = |
| 52 | "com.android.systemui.biometrics.BiometricDialogImpl.USE_NEW_DIALOG"; |
| 53 | |
Kevin Chyn | 5a2ff5d | 2018-08-29 19:07:30 -0700 | [diff] [blame] | 54 | private static final String TAG = "BiometricDialogImpl"; |
Kevin Chyn | 42653e8 | 2018-01-19 14:15:46 -0800 | [diff] [blame] | 55 | private static final boolean DEBUG = true; |
| 56 | |
Kevin Chyn | 050315f | 2019-08-08 14:22:54 -0700 | [diff] [blame] | 57 | private final Injector mInjector; |
| 58 | |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 59 | // TODO: These should just be saved from onSaveState |
Gus Prevas | a7df7b2 | 2018-10-30 10:29:34 -0400 | [diff] [blame] | 60 | private SomeArgs mCurrentDialogArgs; |
Kevin Chyn | 050315f | 2019-08-08 14:22:54 -0700 | [diff] [blame] | 61 | @VisibleForTesting |
| 62 | BiometricDialog mCurrentDialog; |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 63 | |
Kevin Chyn | 050315f | 2019-08-08 14:22:54 -0700 | [diff] [blame] | 64 | private Handler mHandler = new Handler(Looper.getMainLooper()); |
Kevin Chyn | 42653e8 | 2018-01-19 14:15:46 -0800 | [diff] [blame] | 65 | private WindowManager mWindowManager; |
Kevin Chyn | 050315f | 2019-08-08 14:22:54 -0700 | [diff] [blame] | 66 | @VisibleForTesting |
| 67 | IActivityTaskManager mActivityTaskManager; |
| 68 | @VisibleForTesting |
| 69 | BiometricTaskStackListener mTaskStackListener; |
| 70 | @VisibleForTesting |
| 71 | IBiometricServiceReceiverInternal mReceiver; |
| 72 | |
| 73 | public class BiometricTaskStackListener extends TaskStackListener { |
| 74 | @Override |
| 75 | public void onTaskStackChanged() { |
| 76 | mHandler.post(mTaskStackChangedRunnable); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | private final Runnable mTaskStackChangedRunnable = () -> { |
| 81 | if (mCurrentDialog != null) { |
| 82 | try { |
| 83 | final String clientPackage = mCurrentDialog.getOpPackageName(); |
| 84 | Log.w(TAG, "Task stack changed, current client: " + clientPackage); |
| 85 | final List<ActivityManager.RunningTaskInfo> runningTasks = |
| 86 | mActivityTaskManager.getTasks(1); |
| 87 | if (!runningTasks.isEmpty()) { |
| 88 | final String topPackage = runningTasks.get(0).topActivity.getPackageName(); |
| 89 | if (!topPackage.contentEquals(clientPackage)) { |
| 90 | Log.w(TAG, "Evicting client due to: " + topPackage); |
| 91 | mCurrentDialog.dismissWithoutCallback(true /* animate */); |
| 92 | mCurrentDialog = null; |
| 93 | mReceiver.onDialogDismissed(BiometricPrompt.DISMISSED_REASON_USER_CANCEL); |
| 94 | mReceiver = null; |
| 95 | } |
| 96 | } |
| 97 | } catch (RemoteException e) { |
| 98 | Log.e(TAG, "Remote exception", e); |
| 99 | } |
| 100 | } |
| 101 | }; |
Kevin Chyn | 42653e8 | 2018-01-19 14:15:46 -0800 | [diff] [blame] | 102 | |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 103 | @Override |
| 104 | public void onTryAgainPressed() { |
| 105 | try { |
| 106 | mReceiver.onTryAgainPressed(); |
| 107 | } catch (RemoteException e) { |
| 108 | Log.e(TAG, "RemoteException when handling try again", e); |
Kevin Chyn | 5906c17 | 2018-07-23 15:43:02 -0700 | [diff] [blame] | 109 | } |
| 110 | } |
| 111 | |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 112 | @Override |
Kevin Chyn | 050315f | 2019-08-08 14:22:54 -0700 | [diff] [blame] | 113 | public void onDismissed(@DismissedReason int reason) { |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 114 | switch (reason) { |
| 115 | case DialogViewCallback.DISMISSED_USER_CANCELED: |
| 116 | sendResultAndCleanUp(BiometricPrompt.DISMISSED_REASON_USER_CANCEL); |
| 117 | break; |
| 118 | |
| 119 | case DialogViewCallback.DISMISSED_BUTTON_NEGATIVE: |
| 120 | sendResultAndCleanUp(BiometricPrompt.DISMISSED_REASON_NEGATIVE); |
| 121 | break; |
| 122 | |
| 123 | case DialogViewCallback.DISMISSED_BUTTON_POSITIVE: |
| 124 | sendResultAndCleanUp(BiometricPrompt.DISMISSED_REASON_CONFIRMED); |
| 125 | break; |
| 126 | |
| 127 | case DialogViewCallback.DISMISSED_AUTHENTICATED: |
| 128 | sendResultAndCleanUp(BiometricPrompt.DISMISSED_REASON_CONFIRM_NOT_REQUIRED); |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 129 | break; |
| 130 | |
| 131 | case DialogViewCallback.DISMISSED_ERROR: |
| 132 | sendResultAndCleanUp(BiometricPrompt.DISMISSED_REASON_ERROR); |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 133 | break; |
Kevin Chyn | 050315f | 2019-08-08 14:22:54 -0700 | [diff] [blame] | 134 | |
| 135 | case DialogViewCallback.DISMISSED_BY_SYSTEM_SERVER: |
| 136 | sendResultAndCleanUp(BiometricPrompt.DISMISSED_REASON_SERVER_REQUESTED); |
| 137 | break; |
| 138 | |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 139 | default: |
| 140 | Log.e(TAG, "Unhandled reason: " + reason); |
| 141 | break; |
Kevin Chyn | c94b7db | 2019-05-15 17:28:16 -0700 | [diff] [blame] | 142 | } |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 143 | } |
| 144 | |
Kevin Chyn | 050315f | 2019-08-08 14:22:54 -0700 | [diff] [blame] | 145 | private void sendResultAndCleanUp(@DismissedReason int reason) { |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 146 | if (mReceiver == null) { |
| 147 | Log.e(TAG, "Receiver is null"); |
| 148 | return; |
| 149 | } |
| 150 | try { |
Kevin Chyn | 050315f | 2019-08-08 14:22:54 -0700 | [diff] [blame] | 151 | mReceiver.onDialogDismissed(reason); |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 152 | } catch (RemoteException e) { |
| 153 | Log.w(TAG, "Remote exception", e); |
| 154 | } |
Kevin Chyn | 050315f | 2019-08-08 14:22:54 -0700 | [diff] [blame] | 155 | onDialogDismissed(reason); |
| 156 | } |
| 157 | |
| 158 | public static class Injector { |
| 159 | IActivityTaskManager getActivityTaskManager() { |
| 160 | return ActivityTaskManager.getService(); |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | public BiometricDialogImpl() { |
| 165 | this(new Injector()); |
| 166 | } |
| 167 | |
| 168 | @VisibleForTesting |
| 169 | BiometricDialogImpl(Injector injector) { |
| 170 | mInjector = injector; |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 171 | } |
Kevin Chyn | c94b7db | 2019-05-15 17:28:16 -0700 | [diff] [blame] | 172 | |
Kevin Chyn | aae4a15 | 2018-01-18 11:48:09 -0800 | [diff] [blame] | 173 | @Override |
| 174 | public void start() { |
Kevin Chyn | e191271 | 2019-01-04 14:22:34 -0800 | [diff] [blame] | 175 | final PackageManager pm = mContext.getPackageManager(); |
| 176 | if (pm.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT) |
| 177 | || pm.hasSystemFeature(PackageManager.FEATURE_FACE) |
| 178 | || pm.hasSystemFeature(PackageManager.FEATURE_IRIS)) { |
Jason Monk | d7c9855 | 2018-12-04 11:14:50 -0500 | [diff] [blame] | 179 | getComponent(CommandQueue.class).addCallback(this); |
Gus Prevas | a7df7b2 | 2018-10-30 10:29:34 -0400 | [diff] [blame] | 180 | mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); |
Kevin Chyn | 050315f | 2019-08-08 14:22:54 -0700 | [diff] [blame] | 181 | mActivityTaskManager = mInjector.getActivityTaskManager(); |
| 182 | |
| 183 | try { |
| 184 | mTaskStackListener = new BiometricTaskStackListener(); |
| 185 | mActivityTaskManager.registerTaskStackListener(mTaskStackListener); |
| 186 | } catch (RemoteException e) { |
| 187 | Log.w(TAG, "Unable to register task stack listener", e); |
| 188 | } |
Gus Prevas | a7df7b2 | 2018-10-30 10:29:34 -0400 | [diff] [blame] | 189 | } |
| 190 | } |
| 191 | |
Kevin Chyn | aae4a15 | 2018-01-18 11:48:09 -0800 | [diff] [blame] | 192 | @Override |
Kevin Chyn | 23289ef | 2018-11-28 16:32:36 -0800 | [diff] [blame] | 193 | public void showBiometricDialog(Bundle bundle, IBiometricServiceReceiverInternal receiver, |
Kevin Chyn | 050315f | 2019-08-08 14:22:54 -0700 | [diff] [blame] | 194 | int type, boolean requireConfirmation, int userId, String opPackageName) { |
Kevin Chyn | 158fefb | 2019-01-03 18:59:05 -0800 | [diff] [blame] | 195 | if (DEBUG) { |
| 196 | Log.d(TAG, "showBiometricDialog, type: " + type |
| 197 | + ", requireConfirmation: " + requireConfirmation); |
| 198 | } |
Kevin Chyn | 42653e8 | 2018-01-19 14:15:46 -0800 | [diff] [blame] | 199 | SomeArgs args = SomeArgs.obtain(); |
| 200 | args.arg1 = bundle; |
| 201 | args.arg2 = receiver; |
Kevin Chyn | 6cf54e8 | 2018-09-18 19:13:27 -0700 | [diff] [blame] | 202 | args.argi1 = type; |
| 203 | args.arg3 = requireConfirmation; |
Kevin Chyn | 1b9f8df | 2018-11-12 19:04:55 -0800 | [diff] [blame] | 204 | args.argi2 = userId; |
Kevin Chyn | 050315f | 2019-08-08 14:22:54 -0700 | [diff] [blame] | 205 | args.arg4 = opPackageName; |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 206 | |
| 207 | boolean skipAnimation = false; |
| 208 | if (mCurrentDialog != null) { |
| 209 | Log.w(TAG, "mCurrentDialog: " + mCurrentDialog); |
| 210 | skipAnimation = true; |
| 211 | } |
Kevin Chyn | 050315f | 2019-08-08 14:22:54 -0700 | [diff] [blame] | 212 | showDialog(args, skipAnimation, null /* savedState */); |
Kevin Chyn | aae4a15 | 2018-01-18 11:48:09 -0800 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | @Override |
Kevin Chyn | e674e85 | 2019-04-24 12:39:40 -0700 | [diff] [blame] | 216 | public void onBiometricAuthenticated(boolean authenticated, String failureReason) { |
| 217 | if (DEBUG) Log.d(TAG, "onBiometricAuthenticated: " + authenticated |
| 218 | + " reason: " + failureReason); |
| 219 | |
Kevin Chyn | e191271 | 2019-01-04 14:22:34 -0800 | [diff] [blame] | 220 | if (authenticated) { |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 221 | mCurrentDialog.onAuthenticationSucceeded(); |
Kevin Chyn | 6cf54e8 | 2018-09-18 19:13:27 -0700 | [diff] [blame] | 222 | } else { |
Kevin Chyn | 3b53d6f | 2019-05-01 11:49:05 -0700 | [diff] [blame] | 223 | mCurrentDialog.onAuthenticationFailed(failureReason); |
Kevin Chyn | 6cf54e8 | 2018-09-18 19:13:27 -0700 | [diff] [blame] | 224 | } |
Kevin Chyn | 42653e8 | 2018-01-19 14:15:46 -0800 | [diff] [blame] | 225 | } |
| 226 | |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 227 | @Override |
| 228 | public void onBiometricHelp(String message) { |
| 229 | if (DEBUG) Log.d(TAG, "onBiometricHelp: " + message); |
| 230 | |
| 231 | mCurrentDialog.onHelp(message); |
Kevin Chyn | 42653e8 | 2018-01-19 14:15:46 -0800 | [diff] [blame] | 232 | } |
| 233 | |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 234 | @Override |
| 235 | public void onBiometricError(String error) { |
| 236 | if (DEBUG) Log.d(TAG, "onBiometricError: " + error); |
| 237 | mCurrentDialog.onError(error); |
Kevin Chyn | 42653e8 | 2018-01-19 14:15:46 -0800 | [diff] [blame] | 238 | } |
| 239 | |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 240 | @Override |
| 241 | public void hideBiometricDialog() { |
| 242 | if (DEBUG) Log.d(TAG, "hideBiometricDialog"); |
| 243 | |
Kevin Chyn | 050315f | 2019-08-08 14:22:54 -0700 | [diff] [blame] | 244 | mCurrentDialog.dismissFromSystemServer(); |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | private void showDialog(SomeArgs args, boolean skipAnimation, Bundle savedState) { |
| 248 | mCurrentDialogArgs = args; |
| 249 | final int type = args.argi1; |
Kevin Chyn | 050315f | 2019-08-08 14:22:54 -0700 | [diff] [blame] | 250 | final Bundle biometricPromptBundle = (Bundle) args.arg1; |
| 251 | final boolean requireConfirmation = (boolean) args.arg3; |
| 252 | final int userId = args.argi2; |
| 253 | final String opPackageName = (String) args.arg4; |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 254 | |
| 255 | // Create a new dialog but do not replace the current one yet. |
| 256 | final BiometricDialog newDialog = buildDialog( |
Kevin Chyn | 050315f | 2019-08-08 14:22:54 -0700 | [diff] [blame] | 257 | biometricPromptBundle, |
| 258 | requireConfirmation, |
| 259 | userId, |
| 260 | type, |
Kevin Chyn | fc46826 | 2019-08-20 17:17:11 -0700 | [diff] [blame^] | 261 | opPackageName, |
| 262 | skipAnimation); |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 263 | |
| 264 | if (newDialog == null) { |
| 265 | Log.e(TAG, "Unsupported type: " + type); |
Kevin Chyn | 42653e8 | 2018-01-19 14:15:46 -0800 | [diff] [blame] | 266 | return; |
| 267 | } |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 268 | |
| 269 | if (DEBUG) { |
| 270 | Log.d(TAG, "showDialog, " |
| 271 | + " savedState: " + savedState |
| 272 | + " mCurrentDialog: " + mCurrentDialog |
| 273 | + " newDialog: " + newDialog |
| 274 | + " type: " + type); |
| 275 | } |
| 276 | |
| 277 | if (savedState != null) { |
| 278 | // SavedState is only non-null if it's from onConfigurationChanged. Restore the state |
| 279 | // even though it may be removed / re-created again |
| 280 | newDialog.restoreState(savedState); |
| 281 | } else if (mCurrentDialog != null) { |
| 282 | // If somehow we're asked to show a dialog, the old one doesn't need to be animated |
| 283 | // away. This can happen if the app cancels and re-starts auth during configuration |
| 284 | // change. This is ugly because we also have to do things on onConfigurationChanged |
| 285 | // here. |
| 286 | mCurrentDialog.dismissWithoutCallback(false /* animate */); |
| 287 | } |
| 288 | |
| 289 | mReceiver = (IBiometricServiceReceiverInternal) args.arg2; |
| 290 | mCurrentDialog = newDialog; |
Kevin Chyn | fc46826 | 2019-08-20 17:17:11 -0700 | [diff] [blame^] | 291 | mCurrentDialog.show(mWindowManager); |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 292 | } |
| 293 | |
Kevin Chyn | 050315f | 2019-08-08 14:22:54 -0700 | [diff] [blame] | 294 | private void onDialogDismissed(@DismissedReason int reason) { |
| 295 | if (DEBUG) Log.d(TAG, "onDialogDismissed: " + reason); |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 296 | if (mCurrentDialog == null) { |
| 297 | Log.w(TAG, "Dialog already dismissed"); |
Kevin Chyn | 42653e8 | 2018-01-19 14:15:46 -0800 | [diff] [blame] | 298 | } |
| 299 | mReceiver = null; |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 300 | mCurrentDialog = null; |
Kevin Chyn | 23289ef | 2018-11-28 16:32:36 -0800 | [diff] [blame] | 301 | } |
| 302 | |
Gus Prevas | a7df7b2 | 2018-10-30 10:29:34 -0400 | [diff] [blame] | 303 | @Override |
| 304 | protected void onConfigurationChanged(Configuration newConfig) { |
Kevin Chyn | 02129b1 | 2018-11-01 16:47:12 -0700 | [diff] [blame] | 305 | super.onConfigurationChanged(newConfig); |
Kevin Chyn | e191271 | 2019-01-04 14:22:34 -0800 | [diff] [blame] | 306 | |
| 307 | // Save the state of the current dialog (buttons showing, etc) |
Kevin Chyn | e191271 | 2019-01-04 14:22:34 -0800 | [diff] [blame] | 308 | if (mCurrentDialog != null) { |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 309 | final Bundle savedState = new Bundle(); |
Kevin Chyn | e191271 | 2019-01-04 14:22:34 -0800 | [diff] [blame] | 310 | mCurrentDialog.onSaveState(savedState); |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 311 | mCurrentDialog.dismissWithoutCallback(false /* animate */); |
| 312 | mCurrentDialog = null; |
Kevin Chyn | e191271 | 2019-01-04 14:22:34 -0800 | [diff] [blame] | 313 | |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 314 | showDialog(mCurrentDialogArgs, true /* skipAnimation */, savedState); |
Gus Prevas | a7df7b2 | 2018-10-30 10:29:34 -0400 | [diff] [blame] | 315 | } |
Kevin Chyn | c53d981 | 2019-07-30 18:10:30 -0700 | [diff] [blame] | 316 | } |
Kevin Chyn | e191271 | 2019-01-04 14:22:34 -0800 | [diff] [blame] | 317 | |
Kevin Chyn | fc46826 | 2019-08-20 17:17:11 -0700 | [diff] [blame^] | 318 | protected BiometricDialog buildDialog(Bundle biometricPromptBundle, boolean requireConfirmation, |
| 319 | int userId, int type, String opPackageName, boolean skipIntro) { |
| 320 | if (Settings.Secure.getIntForUser( |
| 321 | mContext.getContentResolver(), USE_NEW_DIALOG, userId, 0) != 0) { |
| 322 | return new AuthContainerView.Builder(mContext) |
| 323 | .setCallback(this) |
| 324 | .setBiometricPromptBundle(biometricPromptBundle) |
| 325 | .setRequireConfirmation(requireConfirmation) |
| 326 | .setUserId(userId) |
| 327 | .setOpPackageName(opPackageName) |
| 328 | .setSkipIntro(skipIntro) |
| 329 | .build(type); |
| 330 | } else { |
| 331 | return new BiometricDialogView.Builder(mContext) |
| 332 | .setCallback(this) |
| 333 | .setBiometricPromptBundle(biometricPromptBundle) |
| 334 | .setRequireConfirmation(requireConfirmation) |
| 335 | .setUserId(userId) |
| 336 | .setOpPackageName(opPackageName) |
| 337 | .setSkipIntro(skipIntro) |
| 338 | .build(type); |
| 339 | } |
Gus Prevas | a7df7b2 | 2018-10-30 10:29:34 -0400 | [diff] [blame] | 340 | } |
Kevin Chyn | aae4a15 | 2018-01-18 11:48:09 -0800 | [diff] [blame] | 341 | } |