diff options
author | Jorim Jaggi <jjaggi@google.com> | 2014-05-28 17:52:55 +0200 |
---|---|---|
committer | Jorim Jaggi <jjaggi@google.com> | 2014-05-28 17:52:55 +0200 |
commit | 232b1bf55018e1c519cc795cddf9fa4c39370885 (patch) | |
tree | 2b5a1ed5c1f14b38bf810cbca5a3597ce7099c01 /core | |
parent | 15a77f7da856cbed19cb67c75268505a333352f1 (diff) | |
download | frameworks_base-232b1bf55018e1c519cc795cddf9fa4c39370885.zip frameworks_base-232b1bf55018e1c519cc795cddf9fa4c39370885.tar.gz frameworks_base-232b1bf55018e1c519cc795cddf9fa4c39370885.tar.bz2 |
Cache whether a password/pattern is set.
Bug: 15163546
Change-Id: I15df5111942f0609872a18bd75846900759e49b1
Diffstat (limited to 'core')
-rw-r--r-- | core/java/com/android/internal/widget/LockPatternUtilsCache.java | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/core/java/com/android/internal/widget/LockPatternUtilsCache.java b/core/java/com/android/internal/widget/LockPatternUtilsCache.java index 550aa6d..624f67c 100644 --- a/core/java/com/android/internal/widget/LockPatternUtilsCache.java +++ b/core/java/com/android/internal/widget/LockPatternUtilsCache.java @@ -28,6 +28,11 @@ import android.util.ArrayMap; */ public class LockPatternUtilsCache implements ILockSettings { + private static final String HAS_LOCK_PATTERN_CACHE_KEY + = "LockPatternUtils.Cache.HasLockPatternCacheKey"; + private static final String HAS_LOCK_PASSWORD_CACHE_KEY + = "LockPatternUtils.Cache.HasLockPasswordCacheKey"; + private static LockPatternUtilsCache sInstance; private final ILockSettings mService; @@ -109,7 +114,9 @@ public class LockPatternUtilsCache implements ILockSettings { @Override public void setLockPattern(String pattern, int userId) throws RemoteException { + invalidateCache(HAS_LOCK_PATTERN_CACHE_KEY, userId); mService.setLockPattern(pattern, userId); + putCache(HAS_LOCK_PATTERN_CACHE_KEY, userId, pattern != null); } @Override @@ -119,7 +126,9 @@ public class LockPatternUtilsCache implements ILockSettings { @Override public void setLockPassword(String password, int userId) throws RemoteException { + invalidateCache(HAS_LOCK_PASSWORD_CACHE_KEY, userId); mService.setLockPassword(password, userId); + putCache(HAS_LOCK_PASSWORD_CACHE_KEY, userId, password != null); } @Override @@ -134,12 +143,24 @@ public class LockPatternUtilsCache implements ILockSettings { @Override public boolean havePattern(int userId) throws RemoteException { - return mService.havePattern(userId); + Object value = peekCache(HAS_LOCK_PATTERN_CACHE_KEY, userId); + if (value instanceof Boolean) { + return (boolean) value; + } + boolean result = mService.havePattern(userId); + putCache(HAS_LOCK_PATTERN_CACHE_KEY, userId, result); + return result; } @Override public boolean havePassword(int userId) throws RemoteException { - return mService.havePassword(userId); + Object value = peekCache(HAS_LOCK_PASSWORD_CACHE_KEY, userId); + if (value instanceof Boolean) { + return (boolean) value; + } + boolean result = mService.havePassword(userId); + putCache(HAS_LOCK_PASSWORD_CACHE_KEY, userId, result); + return result; } @Override |