summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Kevin Chyn <kchyn@google.com> 2019-03-14 14:41:46 -0700
committer Kevin Chyn <kchyn@google.com> 2019-03-15 15:26:05 -0700
commit4511eb424f18e0b5cae185a00b31e7046ba8f3b3 (patch)
treefdc23f32b0067a3f3d7dd5a018f611db7e889b0d
parent235f8d3b052188a351fcd09751a4d8229d561ccc (diff)
Ensure new dialogs do not cause orphaned windows
Fixes: 128452510 Test: BiometricPromptDemo Test: Verified with b/128452510#comment1 Change-Id: I67db0a393ee9f21570dc6499f8ddeb42c0f4f790
-rw-r--r--packages/SystemUI/src/com/android/systemui/biometrics/BiometricDialogImpl.java41
1 files changed, 25 insertions, 16 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/BiometricDialogImpl.java b/packages/SystemUI/src/com/android/systemui/biometrics/BiometricDialogImpl.java
index 016b8fe93093..402810902d39 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/BiometricDialogImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/BiometricDialogImpl.java
@@ -191,32 +191,41 @@ public class BiometricDialogImpl extends SystemUI implements CommandQueue.Callba
mCurrentDialogArgs = args;
final int type = args.argi1;
+ // Create a new dialog but do not replace the current one yet.
+ BiometricDialogView newDialog;
if (type == BiometricAuthenticator.TYPE_FINGERPRINT) {
- mCurrentDialog = new FingerprintDialogView(mContext, mCallback);
+ newDialog = new FingerprintDialogView(mContext, mCallback);
} else if (type == BiometricAuthenticator.TYPE_FACE) {
- mCurrentDialog = new FaceDialogView(mContext, mCallback);
+ newDialog = new FaceDialogView(mContext, mCallback);
} else {
Log.e(TAG, "Unsupported type: " + type);
+ return;
}
- if (savedState != null) {
- mCurrentDialog.restoreState(savedState);
- }
-
- if (DEBUG) Log.d(TAG, "handleShowDialog, isAnimatingAway: "
- + mCurrentDialog.isAnimatingAway() + " type: " + type);
+ if (DEBUG) Log.d(TAG, "handleShowDialog, "
+ + " savedState: " + savedState
+ + " mCurrentDialog: " + mCurrentDialog
+ + " newDialog: " + newDialog
+ + " type: " + type);
- if (mCurrentDialog.isAnimatingAway()) {
+ if (savedState != null) {
+ // SavedState is only non-null if it's from onConfigurationChanged. Restore the state
+ // even though it may be removed / re-created again
+ newDialog.restoreState(savedState);
+ } else if (mCurrentDialog != null && mDialogShowing) {
+ // If somehow we're asked to show a dialog, the old one doesn't need to be animated
+ // away. This can happen if the app cancels and re-starts auth during configuration
+ // change. This is ugly because we also have to do things on onConfigurationChanged
+ // here.
mCurrentDialog.forceRemove();
- } else if (mDialogShowing) {
- Log.w(TAG, "Dialog already showing");
- return;
}
+
mReceiver = (IBiometricServiceReceiverInternal) args.arg2;
- mCurrentDialog.setBundle((Bundle)args.arg1);
- mCurrentDialog.setRequireConfirmation((boolean) args.arg3);
- mCurrentDialog.setUserId(args.argi2);
- mCurrentDialog.setSkipIntro(skipAnimation);
+ newDialog.setBundle((Bundle) args.arg1);
+ newDialog.setRequireConfirmation((boolean) args.arg3);
+ newDialog.setUserId(args.argi2);
+ newDialog.setSkipIntro(skipAnimation);
+ mCurrentDialog = newDialog;
mWindowManager.addView(mCurrentDialog, mCurrentDialog.getLayoutParams());
mDialogShowing = true;
}