Merge "Fix display of BiometricPrompt wipe warning dialogs" into rvc-dev am: 8c28971edc
Change-Id: I9f5b881f339253efa2062f9c21fdad95bc26149f
This commit is contained in:
@@ -374,9 +374,31 @@
|
|||||||
<string name="biometric_dialog_wrong_password">Wrong password</string>
|
<string name="biometric_dialog_wrong_password">Wrong password</string>
|
||||||
<!-- Error string shown when the user enters too many incorrect attempts [CHAR LIMIT=120]-->
|
<!-- Error string shown when the user enters too many incorrect attempts [CHAR LIMIT=120]-->
|
||||||
<string name="biometric_dialog_credential_too_many_attempts">Too many incorrect attempts.\nTry again in <xliff:g id="number">%d</xliff:g> seconds.</string>
|
<string name="biometric_dialog_credential_too_many_attempts">Too many incorrect attempts.\nTry again in <xliff:g id="number">%d</xliff:g> seconds.</string>
|
||||||
|
|
||||||
<!-- Error string shown when the user enters an incorrect PIN/pattern/password and it counts towards the max attempts before the data on the device is wiped. [CHAR LIMIT=NONE]-->
|
<!-- Error string shown when the user enters an incorrect PIN/pattern/password and it counts towards the max attempts before the data on the device is wiped. [CHAR LIMIT=NONE]-->
|
||||||
<string name="biometric_dialog_credential_attempts_before_wipe">Try again. Attempt <xliff:g id="attempts" example="1">%1$d</xliff:g> of <xliff:g id="max_attempts" example="3">%2$d</xliff:g>.</string>
|
<string name="biometric_dialog_credential_attempts_before_wipe">Try again. Attempt <xliff:g id="attempts" example="1">%1$d</xliff:g> of <xliff:g id="max_attempts" example="3">%2$d</xliff:g>.</string>
|
||||||
|
|
||||||
|
<!-- Title of a dialog shown when the user only has one attempt left to provide the correct PIN/pattern/password before the device, one of its users, or a work profile is wiped. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="biometric_dialog_last_attempt_before_wipe_dialog_title">Your data will be deleted</string>
|
||||||
|
<!-- Content of a dialog shown when the user only has one attempt left to provide the correct lock pattern before the device is wiped. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="biometric_dialog_last_pattern_attempt_before_wipe_device">If you enter an incorrect pattern on the next attempt, this device\u2019s data will be deleted.</string>
|
||||||
|
<!-- Content of a dialog shown when the user only has one attempt left to provide the correct PIN before the device is wiped. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="biometric_dialog_last_pin_attempt_before_wipe_device">If you enter an incorrect PIN on the next attempt, this device\u2019s data will be deleted.</string>
|
||||||
|
<!-- Content of a dialog shown when the user only has one attempt left to provide the correct password before the device is wiped. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="biometric_dialog_last_password_attempt_before_wipe_device">If you enter an incorrect password on the next attempt, this device\u2019s data will be deleted.</string>
|
||||||
|
<!-- Content of a dialog shown when the user only has one attempt left to provide the correct lock pattern before the user is removed. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="biometric_dialog_last_pattern_attempt_before_wipe_user">If you enter an incorrect pattern on the next attempt, this user will be deleted.</string>
|
||||||
|
<!-- Content of a dialog shown when the user only has one attempt left to provide the correct PIN before the user is removed. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="biometric_dialog_last_pin_attempt_before_wipe_user">If you enter an incorrect PIN on the next attempt, this user will be deleted.</string>
|
||||||
|
<!-- Content of a dialog shown when the user only has one attempt left to provide the correct password before the user is removed. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="biometric_dialog_last_password_attempt_before_wipe_user">If you enter an incorrect password on the next attempt, this user will be deleted.</string>
|
||||||
|
<!-- Content of a dialog shown when the user only has one attempt left to provide the correct pattern before the work profile is removed. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="biometric_dialog_last_pattern_attempt_before_wipe_profile">If you enter an incorrect pattern on the next attempt, your work profile and its data will be deleted.</string>
|
||||||
|
<!-- Content of a dialog shown when the user only has one attempt left to provide the correct PIN before the work profile is removed. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="biometric_dialog_last_pin_attempt_before_wipe_profile">If you enter an incorrect PIN on the next attempt, your work profile and its data will be deleted.</string>
|
||||||
|
<!-- Content of a dialog shown when the user only has one attempt left to provide the correct password before the work profile is removed. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="biometric_dialog_last_password_attempt_before_wipe_profile">If you enter an incorrect password on the next attempt, your work profile and its data will be deleted.</string>
|
||||||
|
|
||||||
<!-- Content of a dialog shown when the user has failed to provide the device lock too many times and the device is wiped. [CHAR LIMIT=NONE] -->
|
<!-- Content of a dialog shown when the user has failed to provide the device lock too many times and the device is wiped. [CHAR LIMIT=NONE] -->
|
||||||
<string name="biometric_dialog_failed_attempts_now_wiping_device">Too many incorrect attempts. This device\u2019s data will be deleted.</string>
|
<string name="biometric_dialog_failed_attempts_now_wiping_device">Too many incorrect attempts. This device\u2019s data will be deleted.</string>
|
||||||
<!-- Content of a dialog shown when the user has failed to provide the user lock too many times and the user is removed. [CHAR LIMIT=NONE] -->
|
<!-- Content of a dialog shown when the user has failed to provide the user lock too many times and the user is removed. [CHAR LIMIT=NONE] -->
|
||||||
|
|||||||
@@ -347,21 +347,35 @@ public abstract class AuthCredentialView extends LinearLayout {
|
|||||||
showError(message);
|
showError(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only show popup dialog before wipe.
|
// Only show dialog if <=1 attempts are left before wiping.
|
||||||
final int remainingAttempts = maxAttempts - numAttempts;
|
final int remainingAttempts = maxAttempts - numAttempts;
|
||||||
if (remainingAttempts <= 0) {
|
if (remainingAttempts == 1) {
|
||||||
showNowWipingMessage();
|
showLastAttemptBeforeWipeDialog();
|
||||||
mContainerView.animateAway(AuthDialogCallback.DISMISSED_ERROR);
|
} else if (remainingAttempts <= 0) {
|
||||||
|
showNowWipingDialog();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showNowWipingMessage() {
|
private void showLastAttemptBeforeWipeDialog() {
|
||||||
|
final AlertDialog alertDialog = new AlertDialog.Builder(mContext)
|
||||||
|
.setTitle(R.string.biometric_dialog_last_attempt_before_wipe_dialog_title)
|
||||||
|
.setMessage(
|
||||||
|
getLastAttemptBeforeWipeMessageRes(getUserTypeForWipe(), mCredentialType))
|
||||||
|
.setPositiveButton(android.R.string.ok, null)
|
||||||
|
.create();
|
||||||
|
alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL);
|
||||||
|
alertDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showNowWipingDialog() {
|
||||||
final AlertDialog alertDialog = new AlertDialog.Builder(mContext)
|
final AlertDialog alertDialog = new AlertDialog.Builder(mContext)
|
||||||
.setMessage(getNowWipingMessageRes(getUserTypeForWipe()))
|
.setMessage(getNowWipingMessageRes(getUserTypeForWipe()))
|
||||||
.setPositiveButton(R.string.biometric_dialog_now_wiping_dialog_dismiss, null)
|
.setPositiveButton(R.string.biometric_dialog_now_wiping_dialog_dismiss, null)
|
||||||
|
.setOnDismissListener(
|
||||||
|
dialog -> mContainerView.animateAway(AuthDialogCallback.DISMISSED_ERROR))
|
||||||
.create();
|
.create();
|
||||||
alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
|
alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL);
|
||||||
alertDialog.show();
|
alertDialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -377,6 +391,59 @@ public abstract class AuthCredentialView extends LinearLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static @StringRes int getLastAttemptBeforeWipeMessageRes(
|
||||||
|
@UserType int userType, @Utils.CredentialType int credentialType) {
|
||||||
|
switch (userType) {
|
||||||
|
case USER_TYPE_PRIMARY:
|
||||||
|
return getLastAttemptBeforeWipeDeviceMessageRes(credentialType);
|
||||||
|
case USER_TYPE_MANAGED_PROFILE:
|
||||||
|
return getLastAttemptBeforeWipeProfileMessageRes(credentialType);
|
||||||
|
case USER_TYPE_SECONDARY:
|
||||||
|
return getLastAttemptBeforeWipeUserMessageRes(credentialType);
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Unrecognized user type:" + userType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static @StringRes int getLastAttemptBeforeWipeDeviceMessageRes(
|
||||||
|
@Utils.CredentialType int credentialType) {
|
||||||
|
switch (credentialType) {
|
||||||
|
case Utils.CREDENTIAL_PIN:
|
||||||
|
return R.string.biometric_dialog_last_pin_attempt_before_wipe_device;
|
||||||
|
case Utils.CREDENTIAL_PATTERN:
|
||||||
|
return R.string.biometric_dialog_last_pattern_attempt_before_wipe_device;
|
||||||
|
case Utils.CREDENTIAL_PASSWORD:
|
||||||
|
default:
|
||||||
|
return R.string.biometric_dialog_last_password_attempt_before_wipe_device;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static @StringRes int getLastAttemptBeforeWipeProfileMessageRes(
|
||||||
|
@Utils.CredentialType int credentialType) {
|
||||||
|
switch (credentialType) {
|
||||||
|
case Utils.CREDENTIAL_PIN:
|
||||||
|
return R.string.biometric_dialog_last_pin_attempt_before_wipe_profile;
|
||||||
|
case Utils.CREDENTIAL_PATTERN:
|
||||||
|
return R.string.biometric_dialog_last_pattern_attempt_before_wipe_profile;
|
||||||
|
case Utils.CREDENTIAL_PASSWORD:
|
||||||
|
default:
|
||||||
|
return R.string.biometric_dialog_last_password_attempt_before_wipe_profile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static @StringRes int getLastAttemptBeforeWipeUserMessageRes(
|
||||||
|
@Utils.CredentialType int credentialType) {
|
||||||
|
switch (credentialType) {
|
||||||
|
case Utils.CREDENTIAL_PIN:
|
||||||
|
return R.string.biometric_dialog_last_pin_attempt_before_wipe_user;
|
||||||
|
case Utils.CREDENTIAL_PATTERN:
|
||||||
|
return R.string.biometric_dialog_last_pattern_attempt_before_wipe_user;
|
||||||
|
case Utils.CREDENTIAL_PASSWORD:
|
||||||
|
default:
|
||||||
|
return R.string.biometric_dialog_last_password_attempt_before_wipe_user;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static @StringRes int getNowWipingMessageRes(@UserType int userType) {
|
private static @StringRes int getNowWipingMessageRes(@UserType int userType) {
|
||||||
switch (userType) {
|
switch (userType) {
|
||||||
case USER_TYPE_PRIMARY:
|
case USER_TYPE_PRIMARY:
|
||||||
|
|||||||
Reference in New Issue
Block a user