Loading services/core/java/com/android/server/LockSettingsStorage.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -401,7 +401,8 @@ class LockSettingsStorage { return getLockCredentialFilePathForUser(userId, BASE_ZERO_LOCK_PATTERN_FILE); return getLockCredentialFilePathForUser(userId, BASE_ZERO_LOCK_PATTERN_FILE); } } private String getChildProfileLockFile(int userId) { @VisibleForTesting String getChildProfileLockFile(int userId) { return getLockCredentialFilePathForUser(userId, CHILD_PROFILE_LOCK_FILE); return getLockCredentialFilePathForUser(userId, CHILD_PROFILE_LOCK_FILE); } } Loading services/tests/servicestests/src/com/android/server/LockSettingsStorageTests.java +27 −0 Original line number Original line Diff line number Diff line Loading @@ -87,6 +87,12 @@ public class LockSettingsStorageTests extends AndroidTestCase { return new File(mStorageDir, return new File(mStorageDir, super.getLockPasswordFilename(userId).replace('/', '-')).getAbsolutePath(); super.getLockPasswordFilename(userId).replace('/', '-')).getAbsolutePath(); } } @Override String getChildProfileLockFile(int userId) { return new File(mStorageDir, super.getChildProfileLockFile(userId).replace('/', '-')).getAbsolutePath(); } }; }; } } Loading Loading @@ -235,6 +241,27 @@ public class LockSettingsStorageTests extends AndroidTestCase { assertArrayEquals("profilepassword".getBytes(), mStorage.readPasswordHash(2).hash); assertArrayEquals("profilepassword".getBytes(), mStorage.readPasswordHash(2).hash); } } public void testLockType_WriteProfileWritesParent() { mStorage.writePasswordHash("parentpassword".getBytes(), 10); mStorage.writePatternHash("12345678".getBytes(), 20); assertEquals(2, mStorage.getStoredCredentialType(10)); assertEquals(1, mStorage.getStoredCredentialType(20)); mStorage.clearCache(); assertEquals(2, mStorage.getStoredCredentialType(10)); assertEquals(1, mStorage.getStoredCredentialType(20)); } public void testProfileLock_ReadWriteChildProfileLock() { assertFalse(mStorage.hasChildProfileLock(20)); mStorage.writeChildProfileLock(20, "profilepassword".getBytes()); assertArrayEquals("profilepassword".getBytes(), mStorage.readChildProfileLock(20)); assertTrue(mStorage.hasChildProfileLock(20)); mStorage.clearCache(); assertArrayEquals("profilepassword".getBytes(), mStorage.readChildProfileLock(20)); assertTrue(mStorage.hasChildProfileLock(20)); } public void testPassword_WriteParentWritesProfile() { public void testPassword_WriteParentWritesProfile() { mStorage.writePasswordHash("profilepassword".getBytes(), 2); mStorage.writePasswordHash("profilepassword".getBytes(), 2); mStorage.writePasswordHash("parentpasswordd".getBytes(), 1); mStorage.writePasswordHash("parentpasswordd".getBytes(), 1); Loading Loading
services/core/java/com/android/server/LockSettingsStorage.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -401,7 +401,8 @@ class LockSettingsStorage { return getLockCredentialFilePathForUser(userId, BASE_ZERO_LOCK_PATTERN_FILE); return getLockCredentialFilePathForUser(userId, BASE_ZERO_LOCK_PATTERN_FILE); } } private String getChildProfileLockFile(int userId) { @VisibleForTesting String getChildProfileLockFile(int userId) { return getLockCredentialFilePathForUser(userId, CHILD_PROFILE_LOCK_FILE); return getLockCredentialFilePathForUser(userId, CHILD_PROFILE_LOCK_FILE); } } Loading
services/tests/servicestests/src/com/android/server/LockSettingsStorageTests.java +27 −0 Original line number Original line Diff line number Diff line Loading @@ -87,6 +87,12 @@ public class LockSettingsStorageTests extends AndroidTestCase { return new File(mStorageDir, return new File(mStorageDir, super.getLockPasswordFilename(userId).replace('/', '-')).getAbsolutePath(); super.getLockPasswordFilename(userId).replace('/', '-')).getAbsolutePath(); } } @Override String getChildProfileLockFile(int userId) { return new File(mStorageDir, super.getChildProfileLockFile(userId).replace('/', '-')).getAbsolutePath(); } }; }; } } Loading Loading @@ -235,6 +241,27 @@ public class LockSettingsStorageTests extends AndroidTestCase { assertArrayEquals("profilepassword".getBytes(), mStorage.readPasswordHash(2).hash); assertArrayEquals("profilepassword".getBytes(), mStorage.readPasswordHash(2).hash); } } public void testLockType_WriteProfileWritesParent() { mStorage.writePasswordHash("parentpassword".getBytes(), 10); mStorage.writePatternHash("12345678".getBytes(), 20); assertEquals(2, mStorage.getStoredCredentialType(10)); assertEquals(1, mStorage.getStoredCredentialType(20)); mStorage.clearCache(); assertEquals(2, mStorage.getStoredCredentialType(10)); assertEquals(1, mStorage.getStoredCredentialType(20)); } public void testProfileLock_ReadWriteChildProfileLock() { assertFalse(mStorage.hasChildProfileLock(20)); mStorage.writeChildProfileLock(20, "profilepassword".getBytes()); assertArrayEquals("profilepassword".getBytes(), mStorage.readChildProfileLock(20)); assertTrue(mStorage.hasChildProfileLock(20)); mStorage.clearCache(); assertArrayEquals("profilepassword".getBytes(), mStorage.readChildProfileLock(20)); assertTrue(mStorage.hasChildProfileLock(20)); } public void testPassword_WriteParentWritesProfile() { public void testPassword_WriteParentWritesProfile() { mStorage.writePasswordHash("profilepassword".getBytes(), 2); mStorage.writePasswordHash("profilepassword".getBytes(), 2); mStorage.writePasswordHash("parentpasswordd".getBytes(), 1); mStorage.writePasswordHash("parentpasswordd".getBytes(), 1); Loading