diff options
| author | 2015-02-05 18:44:14 +0000 | |
|---|---|---|
| committer | 2015-02-05 18:44:15 +0000 | |
| commit | 5bb72554549c5cc722d5666180d1219b33e1f70a (patch) | |
| tree | 4ee7af6c9ac86ef05e17183df640b33515fd01e0 | |
| parent | 26bf3ea56ef661185b9d07ae9bcb1411f1c605b9 (diff) | |
| parent | f80e66ce9a57c4d3abf97e582c89292623b3904d (diff) | |
Merge "Ensure new credentails are valid"
| -rw-r--r-- | core/java/com/android/internal/widget/LockPatternUtils.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java index bf0a3a0e0804..90821dc702b1 100644 --- a/core/java/com/android/internal/widget/LockPatternUtils.java +++ b/core/java/com/android/internal/widget/LockPatternUtils.java @@ -95,6 +95,11 @@ public class LockPatternUtils { public static final int MIN_LOCK_PATTERN_SIZE = 4; /** + * The minimum size of a valid password. + */ + public static final int MIN_LOCK_PASSWORD_SIZE = 4; + + /** * The minimum number of dots the user must include in a wrong pattern * attempt for it to be counted against the counts that affect * {@link #FAILED_ATTEMPTS_BEFORE_TIMEOUT} and {@link #FAILED_ATTEMPTS_BEFORE_RESET} @@ -484,8 +489,9 @@ public class LockPatternUtils { */ public void saveLockPattern(List<LockPatternView.Cell> pattern, int userId) { try { - if (pattern == null) { - throw new IllegalArgumentException("pattern must not be null"); + if (pattern == null || pattern.size() < MIN_LOCK_PATTERN_SIZE) { + throw new IllegalArgumentException("pattern must not be null and at least " + + MIN_LOCK_PATTERN_SIZE + " dots long."); } getLockSettings().setLockPattern(patternToString(pattern), userId); @@ -696,8 +702,9 @@ public class LockPatternUtils { public void saveLockPassword(String password, int quality, int userHandle) { try { DevicePolicyManager dpm = getDevicePolicyManager(); - if (TextUtils.isEmpty(password)) { - throw new IllegalArgumentException("password must not be null nor empty"); + if (password == null || password.length() < MIN_LOCK_PASSWORD_SIZE) { + throw new IllegalArgumentException("password must not be null and at least " + + "of length " + MIN_LOCK_PASSWORD_SIZE); } getLockSettings().setLockPassword(password, userHandle); |