summaryrefslogtreecommitdiffstats
path: root/packages/Keyguard
diff options
context:
space:
mode:
Diffstat (limited to 'packages/Keyguard')
-rw-r--r--packages/Keyguard/res/values/strings.xml64
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java73
2 files changed, 113 insertions, 24 deletions
diff --git a/packages/Keyguard/res/values/strings.xml b/packages/Keyguard/res/values/strings.xml
index a136acf..21d8dc5 100644
--- a/packages/Keyguard/res/values/strings.xml
+++ b/packages/Keyguard/res/values/strings.xml
@@ -290,28 +290,76 @@
You have incorrectly drawn your unlock pattern <xliff:g id="number">%d</xliff:g> times.
\n\nTry again in <xliff:g id="number">%d</xliff:g> seconds.
</string>
- <!-- Message shown when user is almost at the limit of password attempts where the device will be wiped. -->
+
+ <!-- Message shown when user is almost at the limit of password attempts where the device will be wiped. [CHAR LIMIT=none] -->
<string name="kg_failed_attempts_almost_at_wipe" product="tablet">
You have incorrectly attempted to unlock the tablet <xliff:g id="number">%d</xliff:g> times.
After <xliff:g id="number">%d</xliff:g> more unsuccessful attempts,
- the tablet will be reset to factory default and all user data will be lost.
+ this tablet will be reset, which will delete all its data.
</string>
- <!-- Message shown when user is almost at the limit of password attempts where the device will be wiped. -->
+ <!-- Message shown when user is almost at the limit of password attempts where the device will be wiped. [CHAR LIMIT=none] -->
<string name="kg_failed_attempts_almost_at_wipe" product="default">
You have incorrectly attempted to unlock the phone <xliff:g id="number">%d</xliff:g> times.
After <xliff:g id="number">%d</xliff:g> more unsuccessful attempts,
- the phone will be reset to factory default and all user data will be lost.
+ this phone will be reset, which will delete all its data.
</string>
- <!-- Message shown in dialog when user has exceeded the maximum attempts and the device will now be wiped -->
+ <!-- Message shown in dialog when user has exceeded the maximum attempts and the device will now be wiped [CHAR LIMIT=none] -->
<string name="kg_failed_attempts_now_wiping" product="tablet">
You have incorrectly attempted to unlock the tablet <xliff:g id="number">%d</xliff:g> times.
- The tablet will now be reset to factory default.
+ This tablet will be reset, which will delete all its data.
</string>
- <!-- Message shown in dialog when user has exceeded the maximum attempts and the device will now be wiped -->
+ <!-- Message shown in dialog when user has exceeded the maximum attempts and the device will now be wiped [CHAR LIMIT=none] -->
<string name="kg_failed_attempts_now_wiping" product="default">
You have incorrectly attempted to unlock the phone <xliff:g id="number">%d</xliff:g> times.
- The phone will now be reset to factory default.
+ This phone will be reset, which will delete all its data.
+ </string>
+
+ <!-- Message shown when user is almost at the limit of password attempts where the user will be removed. [CHAR LIMIT=none] -->
+ <string name="kg_failed_attempts_almost_at_erase_user" product="tablet">
+ You have incorrectly attempted to unlock the tablet <xliff:g id="number">%d</xliff:g> times.
+ After <xliff:g id="number">%d</xliff:g> more unsuccessful attempts,
+ this user will be removed, which will delete all user data.
+ </string>
+ <!-- Message shown when user is almost at the limit of password attempts where the user will be removed. [CHAR LIMIT=none] -->
+ <string name="kg_failed_attempts_almost_at_erase_user" product="default">
+ You have incorrectly attempted to unlock the phone <xliff:g id="number">%d</xliff:g> times.
+ After <xliff:g id="number">%d</xliff:g> more unsuccessful attempts,
+ this user will be removed, which will delete all user data.
+ </string>
+ <!-- Message shown in dialog when user has exceeded the maximum attempts and the user will be removed. [CHAR LIMIT=none] -->
+ <string name="kg_failed_attempts_now_erasing_user" product="tablet">
+ You have incorrectly attempted to unlock the tablet <xliff:g id="number">%d</xliff:g> times.
+ This user will be removed, which will delete all user data.
+ </string>
+ <!-- Message shown in dialog when user has exceeded the maximum attempts and the user will be removed. [CHAR LIMIT=none] -->
+ <string name="kg_failed_attempts_now_erasing_user" product="default">
+ You have incorrectly attempted to unlock the phone <xliff:g id="number">%d</xliff:g> times.
+ This user will be removed, which will delete all user data.
</string>
+
+ <!-- Message shown when user is almost at the limit of password attempts where the profile will be removed. [CHAR LIMIT=none] -->
+ <string name="kg_failed_attempts_almost_at_erase_profile" product="tablet">
+ You have incorrectly attempted to unlock the tablet <xliff:g id="number">%d</xliff:g> times.
+ After <xliff:g id="number">%d</xliff:g> more unsuccessful attempts,
+ the work profile will be removed, which will delete all profile data.
+ </string>
+ <!-- Message shown when user is almost at the limit of password attempts where the profile will be removed. [CHAR LIMIT=none] -->
+ <string name="kg_failed_attempts_almost_at_erase_profile" product="default">
+ You have incorrectly attempted to unlock the phone <xliff:g id="number">%d</xliff:g> times.
+ After <xliff:g id="number">%d</xliff:g> more unsuccessful attempts,
+ the work profile will be removed, which will delete all profile data.
+ </string>
+ <!-- Message shown in dialog when user has exceeded the maximum attempts and the profile will be removed. [CHAR LIMIT=none] -->
+ <string name="kg_failed_attempts_now_erasing_profile" product="tablet">
+ You have incorrectly attempted to unlock the tablet <xliff:g id="number">%d</xliff:g> times.
+ The work profile will be removed, which will delete all profile data.
+ </string>
+ <!-- Message shown in dialog when user has exceeded the maximum attempts and the profile will be removed. [CHAR LIMIT=none] -->
+ <string name="kg_failed_attempts_now_erasing_profile" product="default">
+ You have incorrectly attempted to unlock the phone <xliff:g id="number">%d</xliff:g> times.
+ The work profile will be removed, which will delete all profile data.
+ </string>
+
<!-- Message shown in dialog when user is almost at the limit where they will be
locked out and may have to enter an alternate username/password to unlock the phone -->
<string name="kg_failed_attempts_almost_at_login" product="tablet">
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java
index 119471b..979c377 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java
@@ -17,7 +17,10 @@ package com.android.keyguard;
import android.app.Activity;
import android.app.AlertDialog;
+import android.app.admin.DevicePolicyManager;
import android.content.Context;
+import android.os.UserHandle;
+import android.os.UserManager;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Slog;
@@ -32,6 +35,11 @@ import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSecurityView {
private static final boolean DEBUG = KeyguardConstants.DEBUG;
private static final String TAG = "KeyguardSecurityView";
+
+ private static final int USER_TYPE_PRIMARY = 1;
+ private static final int USER_TYPE_WORK_PROFILE = 2;
+ private static final int USER_TYPE_SECONDARY_USER = 3;
+
private KeyguardSecurityModel mSecurityModel;
private boolean mEnableFallback; // TODO: This should get the value from KeyguardPatternView
private LockPatternUtils mLockPatternUtils;
@@ -207,14 +215,41 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
}
}
- private void showAlmostAtWipeDialog(int attempts, int remaining) {
- String message = mContext.getString(R.string.kg_failed_attempts_almost_at_wipe,
- attempts, remaining);
+ private void showAlmostAtWipeDialog(int attempts, int remaining, int userType) {
+ String message = null;
+ switch (userType) {
+ case USER_TYPE_PRIMARY:
+ message = mContext.getString(R.string.kg_failed_attempts_almost_at_wipe,
+ attempts, remaining);
+ break;
+ case USER_TYPE_SECONDARY_USER:
+ message = mContext.getString(R.string.kg_failed_attempts_almost_at_erase_user,
+ attempts, remaining);
+ break;
+ case USER_TYPE_WORK_PROFILE:
+ message = mContext.getString(R.string.kg_failed_attempts_almost_at_erase_profile,
+ attempts, remaining);
+ break;
+ }
showDialog(null, message);
}
- private void showWipeDialog(int attempts) {
- String message = mContext.getString(R.string.kg_failed_attempts_now_wiping, attempts);
+ private void showWipeDialog(int attempts, int userType) {
+ String message = null;
+ switch (userType) {
+ case USER_TYPE_PRIMARY:
+ message = mContext.getString(R.string.kg_failed_attempts_now_wiping,
+ attempts);
+ break;
+ case USER_TYPE_SECONDARY_USER:
+ message = mContext.getString(R.string.kg_failed_attempts_now_erasing_user,
+ attempts);
+ break;
+ case USER_TYPE_WORK_PROFILE:
+ message = mContext.getString(R.string.kg_failed_attempts_now_erasing_profile,
+ attempts);
+ break;
+ }
showDialog(null, message);
}
@@ -235,9 +270,10 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
SecurityMode mode = mSecurityModel.getSecurityMode();
final boolean usingPattern = mode == KeyguardSecurityModel.SecurityMode.Pattern;
-
- final int failedAttemptsBeforeWipe = mLockPatternUtils.getDevicePolicyManager()
- .getMaximumFailedPasswordsForWipe(null, mLockPatternUtils.getCurrentUser());
+ final int currentUser = mLockPatternUtils.getCurrentUser();
+ final DevicePolicyManager dpm = mLockPatternUtils.getDevicePolicyManager();
+ final int failedAttemptsBeforeWipe =
+ dpm.getMaximumFailedPasswordsForWipe(null, currentUser);
final int failedAttemptWarning = LockPatternUtils.FAILED_ATTEMPTS_BEFORE_RESET
- LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT;
@@ -245,22 +281,27 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
final int remainingBeforeWipe = failedAttemptsBeforeWipe > 0 ?
(failedAttemptsBeforeWipe - failedAttempts)
: Integer.MAX_VALUE; // because DPM returns 0 if no restriction
-
boolean showTimeout = false;
if (remainingBeforeWipe < LockPatternUtils.FAILED_ATTEMPTS_BEFORE_WIPE_GRACE) {
// The user has installed a DevicePolicyManager that requests a user/profile to be wiped
// N attempts. Once we get below the grace period, we post this dialog every time as a
// clear warning until the deletion fires.
- //
- // TODO: Show a different dialog depending on whether the device will be completely
- // wiped (i.e. policy is set for the primary profile of the USER_OWNER) or a single
- // secondary user or managed profile will be removed.
+ // Check which profile has the strictest policy for failed password attempts
+ final int expiringUser = dpm.getProfileWithMinimumFailedPasswordsForWipe(currentUser);
+ int userType = USER_TYPE_PRIMARY;
+ if (expiringUser == currentUser) {
+ if (expiringUser != UserHandle.USER_OWNER) {
+ userType = USER_TYPE_SECONDARY_USER;
+ }
+ } else if (expiringUser != UserHandle.USER_NULL) {
+ userType = USER_TYPE_WORK_PROFILE;
+ } // If USER_NULL, which shouldn't happen, leave it as USER_TYPE_PRIMARY
if (remainingBeforeWipe > 0) {
- showAlmostAtWipeDialog(failedAttempts, remainingBeforeWipe);
+ showAlmostAtWipeDialog(failedAttempts, remainingBeforeWipe, userType);
} else {
// Too many attempts. The device will be wiped shortly.
- Slog.i(TAG, "Too many unlock attempts; device will be wiped!");
- showWipeDialog(failedAttempts);
+ Slog.i(TAG, "Too many unlock attempts; user " + expiringUser + " will be wiped!");
+ showWipeDialog(failedAttempts, userType);
}
} else {
showTimeout =