13/n: persist device credential across configuration changes
1) AuthContainerView can be started in either `biometric` or `credential`
views. This is to potentially support an API where only credential
is allowed/requested.
2) When onSaveState, AuthContainerView saves both the states of
`biometric` and `credential` visibility. In the case of configuration
change, AuthController is responsibile for checking the visibility
and creating a AuthContainerView with the correct initial view.
3) When AuthCredentialView is the initial view, it owns the panel
expansion.
4) Added landscape layout
Bug: 140127687
Test: atest com.android.systemui.biometrics
Test: BiometricPromptDemo, use pattern, rotate device. auth, cancel,
demo logs are correct.
Change-Id: I1f501cf13b924353f251a69757fdb9d7e0bf1d21
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java
index eb87834..1e8c26d 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java
@@ -218,7 +218,8 @@
Log.w(TAG, "mCurrentDialog: " + mCurrentDialog);
skipAnimation = true;
}
- showDialog(args, skipAnimation, null /* savedState */);
+ showDialog(args, skipAnimation, null /* savedState */,
+ AuthContainerView.Builder.INITIAL_VIEW_BIOMETRIC);
}
@Override
@@ -253,7 +254,8 @@
mCurrentDialog.dismissFromSystemServer();
}
- private void showDialog(SomeArgs args, boolean skipAnimation, Bundle savedState) {
+ private void showDialog(SomeArgs args, boolean skipAnimation, Bundle savedState,
+ @AuthContainerView.Builder.InitialView int initialView) {
mCurrentDialogArgs = args;
final int type = args.argi1;
final Bundle biometricPromptBundle = (Bundle) args.arg1;
@@ -268,7 +270,8 @@
userId,
type,
opPackageName,
- skipAnimation);
+ skipAnimation,
+ initialView);
if (newDialog == null) {
Log.e(TAG, "Unsupported type: " + type);
@@ -280,7 +283,8 @@
+ " savedState: " + savedState
+ " mCurrentDialog: " + mCurrentDialog
+ " newDialog: " + newDialog
- + " type: " + type);
+ + " type: " + type
+ + " initialView: " + initialView);
}
if (mCurrentDialog != null) {
@@ -320,13 +324,23 @@
// to send its pending callback immediately.
if (savedState.getInt(AuthDialog.KEY_CONTAINER_STATE)
!= AuthContainerView.STATE_ANIMATING_OUT) {
- showDialog(mCurrentDialogArgs, true /* skipAnimation */, savedState);
+ final boolean credentialShowing =
+ savedState.getBoolean(AuthDialog.KEY_CREDENTIAL_SHOWING);
+
+ // We can assume if credential is showing, then biometric doesn't need to be shown,
+ // since credential is always after biometric.
+ final int initialView = credentialShowing
+ ? AuthContainerView.Builder.INITIAL_VIEW_CREDENTIAL
+ : AuthContainerView.Builder.INITIAL_VIEW_BIOMETRIC;
+
+ showDialog(mCurrentDialogArgs, true /* skipAnimation */, savedState, initialView);
}
}
}
protected AuthDialog buildDialog(Bundle biometricPromptBundle, boolean requireConfirmation,
- int userId, int type, String opPackageName, boolean skipIntro) {
+ int userId, int type, String opPackageName, boolean skipIntro,
+ @AuthContainerView.Builder.InitialView int initialView) {
return new AuthContainerView.Builder(mContext)
.setCallback(this)
.setBiometricPromptBundle(biometricPromptBundle)
@@ -334,6 +348,7 @@
.setUserId(userId)
.setOpPackageName(opPackageName)
.setSkipIntro(skipIntro)
+ .setInitialView(initialView)
.build(type);
}
}