summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/com/android/internal/widget/LockPatternUtils.java19
-rw-r--r--services/core/java/com/android/server/locksettings/LockSettingsService.java17
-rw-r--r--services/core/java/com/android/server/locksettings/LockSettingsStorage.java35
-rw-r--r--services/tests/servicestests/src/com/android/server/locksettings/LockSettingsStorageTests.java2
4 files changed, 7 insertions, 66 deletions
diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java
index dc45f7834748..32867a8949e6 100644
--- a/core/java/com/android/internal/widget/LockPatternUtils.java
+++ b/core/java/com/android/internal/widget/LockPatternUtils.java
@@ -558,7 +558,7 @@ public class LockPatternUtils {
/**
* Returns the password history hash factor, needed to check new password against password
- * history with {@link #checkPasswordHistory(String, byte[], int)}
+ * history with {@link #checkPasswordHistory(byte[], byte[], int)}
*/
public byte[] getPasswordHistoryHashFactor(byte[] currentPassword, int userId) {
try {
@@ -1242,23 +1242,6 @@ public class LockPatternUtils {
return res;
}
- /**
- * Transform a pattern byte array to base zero form.
- * @param bytes pattern byte array.
- * @return The pattern in base zero form.
- */
- public static byte[] patternByteArrayToBaseZero(byte[] bytes) {
- if (bytes == null) {
- return new byte[0];
- }
- final int patternSize = bytes.length;
- byte[] res = new byte[patternSize];
- for (int i = 0; i < patternSize; i++) {
- res[i] = (byte) (bytes[i] - '1');
- }
- return res;
- }
-
/*
* Generate an SHA-1 hash for the pattern. Not the most secure, but it is
* at least a second level of protection. First level is that the file
diff --git a/services/core/java/com/android/server/locksettings/LockSettingsService.java b/services/core/java/com/android/server/locksettings/LockSettingsService.java
index 15207f747729..f1f6d502d575 100644
--- a/services/core/java/com/android/server/locksettings/LockSettingsService.java
+++ b/services/core/java/com/android/server/locksettings/LockSettingsService.java
@@ -1853,26 +1853,11 @@ public class LockSettingsService extends ILockSettings.Stub {
return VerifyCredentialResponse.ERROR;
}
- boolean shouldReEnrollBaseZero = storedHash.type == CREDENTIAL_TYPE_PATTERN
- && storedHash.isBaseZeroPattern;
-
- byte[] credentialToVerify;
- if (shouldReEnrollBaseZero) {
- credentialToVerify = LockPatternUtils.patternByteArrayToBaseZero(credential);
- } else {
- credentialToVerify = credential;
- }
-
- response = verifyCredential(userId, storedHash, credentialToVerify,
+ response = verifyCredential(userId, storedHash, credential,
challengeType, challenge, progressCallback);
if (response.getResponseCode() == VerifyCredentialResponse.RESPONSE_OK) {
mStrongAuth.reportSuccessfulStrongAuthUnlock(userId);
- if (shouldReEnrollBaseZero) {
- setLockCredentialInternal(credential, storedHash.type, credentialToVerify,
- DevicePolicyManager.PASSWORD_QUALITY_SOMETHING, userId, false,
- /* isLockTiedToParent= */ false);
- }
}
return response;
diff --git a/services/core/java/com/android/server/locksettings/LockSettingsStorage.java b/services/core/java/com/android/server/locksettings/LockSettingsStorage.java
index c8c185521bc4..29b8aa2e12f4 100644
--- a/services/core/java/com/android/server/locksettings/LockSettingsStorage.java
+++ b/services/core/java/com/android/server/locksettings/LockSettingsStorage.java
@@ -77,7 +77,6 @@ class LockSettingsStorage {
private static final String SYSTEM_DIRECTORY = "/system/";
private static final String LOCK_PATTERN_FILE = "gatekeeper.pattern.key";
- private static final String BASE_ZERO_LOCK_PATTERN_FILE = "gatekeeper.gesture.key";
private static final String LOCK_PASSWORD_FILE = "gatekeeper.password.key";
private static final String CHILD_PROFILE_LOCK_FILE = "gatekeeper.profile.key";
@@ -98,33 +97,23 @@ class LockSettingsStorage {
private static final int VERSION_GATEKEEPER = 1;
private CredentialHash(byte[] hash, @CredentialType int type) {
- this(hash, type, false /* isBaseZeroPattern */);
- }
-
- private CredentialHash(
- byte[] hash, @CredentialType int type, boolean isBaseZeroPattern) {
if (type != LockPatternUtils.CREDENTIAL_TYPE_NONE) {
if (hash == null) {
- throw new RuntimeException("Empty hash for CredentialHash");
+ throw new IllegalArgumentException("Empty hash for CredentialHash");
}
} else /* type == LockPatternUtils.CREDENTIAL_TYPE_NONE */ {
if (hash != null) {
- throw new RuntimeException("None type CredentialHash should not have hash");
+ throw new IllegalArgumentException(
+ "None type CredentialHash should not have hash");
}
}
this.hash = hash;
this.type = type;
- this.isBaseZeroPattern = isBaseZeroPattern;
- }
-
- private static CredentialHash createBaseZeroPattern(byte[] hash) {
- return new CredentialHash(hash, LockPatternUtils.CREDENTIAL_TYPE_PATTERN,
- true /* isBaseZeroPattern */);
}
static CredentialHash create(byte[] hash, int type) {
if (type == LockPatternUtils.CREDENTIAL_TYPE_NONE) {
- throw new RuntimeException("Bad type for CredentialHash");
+ throw new IllegalArgumentException("Bad type for CredentialHash");
}
return new CredentialHash(hash, type);
}
@@ -135,11 +124,8 @@ class LockSettingsStorage {
byte[] hash;
@CredentialType int type;
- boolean isBaseZeroPattern;
public byte[] toBytes() {
- Preconditions.checkState(!isBaseZeroPattern, "base zero patterns are not serializable");
-
try {
ByteArrayOutputStream os = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(os);
@@ -274,12 +260,6 @@ class LockSettingsStorage {
if (!ArrayUtils.isEmpty(stored)) {
return new CredentialHash(stored, LockPatternUtils.CREDENTIAL_TYPE_PATTERN);
}
-
- stored = readFile(getBaseZeroLockPatternFilename(userId));
- if (!ArrayUtils.isEmpty(stored)) {
- return CredentialHash.createBaseZeroPattern(stored);
- }
-
return null;
}
@@ -323,8 +303,7 @@ class LockSettingsStorage {
}
public boolean hasPattern(int userId) {
- return hasFile(getLockPatternFilename(userId)) ||
- hasFile(getBaseZeroLockPatternFilename(userId));
+ return hasFile(getLockPatternFilename(userId));
}
public boolean hasCredential(int userId) {
@@ -444,10 +423,6 @@ class LockSettingsStorage {
return getLockCredentialFilePathForUser(userId, LOCK_PASSWORD_FILE);
}
- private String getBaseZeroLockPatternFilename(int userId) {
- return getLockCredentialFilePathForUser(userId, BASE_ZERO_LOCK_PATTERN_FILE);
- }
-
@VisibleForTesting
String getChildProfileLockFile(int userId) {
return getLockCredentialFilePathForUser(userId, CHILD_PROFILE_LOCK_FILE);
diff --git a/services/tests/servicestests/src/com/android/server/locksettings/LockSettingsStorageTests.java b/services/tests/servicestests/src/com/android/server/locksettings/LockSettingsStorageTests.java
index 27f695751542..8e0d7be5f44f 100644
--- a/services/tests/servicestests/src/com/android/server/locksettings/LockSettingsStorageTests.java
+++ b/services/tests/servicestests/src/com/android/server/locksettings/LockSettingsStorageTests.java
@@ -436,7 +436,6 @@ public class LockSettingsStorageTests extends AndroidTestCase {
assertEquals(LockPatternUtils.CREDENTIAL_TYPE_PASSWORD, deserialized.type);
assertArrayEquals(PAYLOAD, deserialized.hash);
- assertFalse(deserialized.isBaseZeroPattern);
}
public void testCredentialHash_unserialize_versionGatekeeper() {
@@ -452,7 +451,6 @@ public class LockSettingsStorageTests extends AndroidTestCase {
assertEquals(LockPatternUtils.CREDENTIAL_TYPE_PASSWORD, deserialized.type);
assertArrayEquals(PAYLOAD, deserialized.hash);
- assertFalse(deserialized.isBaseZeroPattern);
// Make sure the constants we use on the wire do not change.
assertEquals(-1, LockPatternUtils.CREDENTIAL_TYPE_NONE);