Show countdown of remaining decrypt attempts before wiping device
Bug: 16496992
Change-Id: Ibdd4bbbf9a9eeafee5e0e5ed48464d524628cf12
diff --git a/res/layout/crypt_keeper_status.xml b/res/layout/crypt_keeper_status.xml
index 72f7aec..c366b57 100644
--- a/res/layout/crypt_keeper_status.xml
+++ b/res/layout/crypt_keeper_status.xml
@@ -25,6 +25,8 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
+ <!-- We need android:gravity="center_horizontal" to make multi line
+ status strings look good -->
<TextView
android:id="@+id/status"
android:layout_width="wrap_content"
@@ -35,7 +37,8 @@
android:textSize="18sp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/enter_password"
- android:layout_gravity="center_horizontal" />
+ android:layout_gravity="center_horizontal"
+ android:gravity="center_horizontal" />
<TextView
android:id="@+id/owner_info"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1d91076..f114a26 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -867,6 +867,11 @@
<!-- Informational text on the password entry screen when password entry fails-->
<string name="crypt_keeper_cooldown">Try again in <xliff:g id="delay" example="15">^1</xliff:g> seconds.</string>
+ <!-- Warn user their device will be wiped if they make x more failed attempts -->
+ <string name="crypt_keeper_warn_wipe">Warning: Your device will be wiped after
+ <xliff:g id="count" example="7">^1</xliff:g> more failed attempts to be unlocked!
+ </string>
+
<!-- Informational text on the password entry screen prompting the user for their password -->
<string name="crypt_keeper_enter_password">Type your password</string>
diff --git a/src/com/android/settings/CryptKeeper.java b/src/com/android/settings/CryptKeeper.java
index b82c02a..129b201 100644
--- a/src/com/android/settings/CryptKeeper.java
+++ b/src/com/android/settings/CryptKeeper.java
@@ -182,7 +182,17 @@
cooldown();
} else {
final TextView status = (TextView) findViewById(R.id.status);
- status.setText(R.string.try_again);
+
+ int remainingAttempts = MAX_FAILED_ATTEMPTS - failedAttempts;
+ if (remainingAttempts < COOL_DOWN_ATTEMPTS) {
+ CharSequence warningTemplate = getText(R.string.crypt_keeper_warn_wipe);
+ CharSequence warning = TextUtils.expandTemplate(warningTemplate,
+ Integer.toString(remainingAttempts));
+ status.setText(warning);
+ } else {
+ status.setText(R.string.try_again);
+ }
+
if (mLockPatternView != null) {
mLockPatternView.setDisplayMode(DisplayMode.Wrong);
}