Loading services/core/java/com/android/server/locksettings/LockSettingsStorage.java +6 −2 Original line number Diff line number Diff line Loading @@ -62,6 +62,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Objects; /** * Storage for the lock settings service. Loading Loading @@ -886,12 +887,15 @@ class LockSettingsStorage { if (!(obj instanceof CacheKey)) return false; CacheKey o = (CacheKey) obj; return userId == o.userId && type == o.type && key.equals(o.key); return userId == o.userId && type == o.type && Objects.equals(key, o.key); } @Override public int hashCode() { return key.hashCode() ^ userId ^ type; int hashCode = Objects.hashCode(key); hashCode = 31 * hashCode + userId; hashCode = 31 * hashCode + type; return hashCode; } } } Loading services/tests/servicestests/src/com/android/server/locksettings/LockSettingsStorageTests.java +14 −0 Original line number Diff line number Diff line Loading @@ -265,6 +265,20 @@ public class LockSettingsStorageTests { assertEquals("Cached value didn't match stored value", storage, cached); } @Test public void testNullKey() { mStorage.setString(null, "value", 0); // Verify that this doesn't throw an exception. assertEquals("value", mStorage.readKeyValue(null, null, 0)); // The read that happens as part of prefetchUser shouldn't throw an exception either. mStorage.clearCache(); mStorage.prefetchUser(0); assertEquals("value", mStorage.readKeyValue(null, null, 0)); } @Test public void testRemoveUser() { mStorage.writeKeyValue("key", "value", 0); Loading Loading
services/core/java/com/android/server/locksettings/LockSettingsStorage.java +6 −2 Original line number Diff line number Diff line Loading @@ -62,6 +62,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Objects; /** * Storage for the lock settings service. Loading Loading @@ -886,12 +887,15 @@ class LockSettingsStorage { if (!(obj instanceof CacheKey)) return false; CacheKey o = (CacheKey) obj; return userId == o.userId && type == o.type && key.equals(o.key); return userId == o.userId && type == o.type && Objects.equals(key, o.key); } @Override public int hashCode() { return key.hashCode() ^ userId ^ type; int hashCode = Objects.hashCode(key); hashCode = 31 * hashCode + userId; hashCode = 31 * hashCode + type; return hashCode; } } } Loading
services/tests/servicestests/src/com/android/server/locksettings/LockSettingsStorageTests.java +14 −0 Original line number Diff line number Diff line Loading @@ -265,6 +265,20 @@ public class LockSettingsStorageTests { assertEquals("Cached value didn't match stored value", storage, cached); } @Test public void testNullKey() { mStorage.setString(null, "value", 0); // Verify that this doesn't throw an exception. assertEquals("value", mStorage.readKeyValue(null, null, 0)); // The read that happens as part of prefetchUser shouldn't throw an exception either. mStorage.clearCache(); mStorage.prefetchUser(0); assertEquals("value", mStorage.readKeyValue(null, null, 0)); } @Test public void testRemoveUser() { mStorage.writeKeyValue("key", "value", 0); Loading