Merge "Fix disappearing biometric prompt for the managed profile" into rvc-dev
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
index 3c81eb8..64812fd 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
@@ -107,6 +107,7 @@
private int mUserId;
private int mCredentialMode;
private boolean mGoingToBackground;
+ private boolean mWaitingForBiometricCallback;
private Executor mExecutor = (runnable -> {
mHandler.post(runnable);
@@ -116,6 +117,7 @@
@Override
public void onAuthenticationError(int errorCode, @NonNull CharSequence errString) {
if (!mGoingToBackground) {
+ mWaitingForBiometricCallback = false;
if (errorCode == BiometricPrompt.BIOMETRIC_ERROR_USER_CANCELED
|| errorCode == BiometricPrompt.BIOMETRIC_ERROR_CANCELED) {
finish();
@@ -123,11 +125,15 @@
// All other errors go to some version of CC
showConfirmCredentials();
}
+ } else if (mWaitingForBiometricCallback) { // mGoingToBackground is true
+ mWaitingForBiometricCallback = false;
+ finish();
}
}
@Override
public void onAuthenticationSucceeded(BiometricPrompt.AuthenticationResult result) {
+ mWaitingForBiometricCallback = false;
mTrustManager.setDeviceLockedForUser(mUserId, false);
final boolean isStrongAuth = result.getAuthenticationType()
== BiometricPrompt.AUTHENTICATION_RESULT_TYPE_DEVICE_CREDENTIAL;
@@ -142,6 +148,7 @@
@Override
public void onAuthenticationFailed() {
+ mWaitingForBiometricCallback = false;
mDevicePolicyManager.reportFailedBiometricAttempt(mUserId);
}
@@ -262,6 +269,7 @@
finish();
} else if (launchedBiometric) {
// Keep this activity alive until BiometricPrompt goes away
+ mWaitingForBiometricCallback = true;
} else {
Log.d(TAG, "No pattern, password or PIN set.");
setResult(Activity.RESULT_OK);
@@ -320,7 +328,9 @@
super.onPause();
if (!isChangingConfigurations()) {
mGoingToBackground = true;
- finish();
+ if (!mWaitingForBiometricCallback) {
+ finish();
+ }
} else {
mGoingToBackground = false;
}