Lines Matching refs:userId

108     public void writeKeyValue(String key, String value, int userId) {
109 writeKeyValue(mOpenHelper.getWritableDatabase(), key, value, userId);
112 public void writeKeyValue(SQLiteDatabase db, String key, String value, int userId) {
115 cv.put(COLUMN_USERID, userId);
121 new String[] {key, Integer.toString(userId)});
124 mCache.putKeyValue(key, value, userId);
131 public String readKeyValue(String key, String defaultValue, int userId) {
134 if (mCache.hasKeyValue(key, userId)) {
135 return mCache.peekKeyValue(key, defaultValue, userId);
145 new String[] { Integer.toString(userId), key },
152 mCache.putKeyValueIfUnchanged(key, result, userId, version);
156 public void prefetchUser(int userId) {
159 if (mCache.isFetched(userId)) {
162 mCache.setFetched(userId);
170 new String[] { Integer.toString(userId) },
175 mCache.putKeyValueIfUnchanged(key, value, userId, version);
181 readPasswordHash(userId);
182 readPatternHash(userId);
185 public int getStoredCredentialType(int userId) {
186 final Integer cachedStoredCredentialType = mStoredCredentialType.get(userId);
192 CredentialHash pattern = readPatternHash(userId);
194 if (readPasswordHash(userId) != null) {
200 CredentialHash password = readPasswordHash(userId);
212 mStoredCredentialType.put(userId, storedCredentialType);
217 public CredentialHash readPasswordHash(int userId) {
218 byte[] stored = readFile(getLockPasswordFilename(userId));
223 stored = readFile(getLegacyLockPasswordFilename(userId));
231 public CredentialHash readPatternHash(int userId) {
232 byte[] stored = readFile(getLockPatternFilename(userId));
237 stored = readFile(getBaseZeroLockPatternFilename(userId));
242 stored = readFile(getLegacyLockPatternFilename(userId));
250 public void removeChildProfileLock(int userId) {
252 Slog.e(TAG, "Remove child profile lock for user: " + userId);
254 deleteFile(getChildProfileLockFile(userId));
260 public void writeChildProfileLock(int userId, byte[] lock) {
261 writeFile(getChildProfileLockFile(userId), lock);
264 public byte[] readChildProfileLock(int userId) {
265 return readFile(getChildProfileLockFile(userId));
268 public boolean hasChildProfileLock(int userId) {
269 return hasFile(getChildProfileLockFile(userId));
272 public boolean hasPassword(int userId) {
273 return hasFile(getLockPasswordFilename(userId)) ||
274 hasFile(getLegacyLockPasswordFilename(userId));
277 public boolean hasPattern(int userId) {
278 return hasFile(getLockPatternFilename(userId)) ||
279 hasFile(getBaseZeroLockPatternFilename(userId)) ||
280 hasFile(getLegacyLockPatternFilename(userId));
358 public void writePatternHash(byte[] hash, int userId) {
359 mStoredCredentialType.put(userId, hash == null ? CredentialHash.TYPE_NONE
361 writeFile(getLockPatternFilename(userId), hash);
362 clearPasswordHash(userId);
365 private void clearPatternHash(int userId) {
366 writeFile(getLockPatternFilename(userId), null);
369 public void writePasswordHash(byte[] hash, int userId) {
370 mStoredCredentialType.put(userId, hash == null ? CredentialHash.TYPE_NONE
372 writeFile(getLockPasswordFilename(userId), hash);
373 clearPatternHash(userId);
376 private void clearPasswordHash(int userId) {
377 writeFile(getLockPasswordFilename(userId), null);
381 String getLockPatternFilename(int userId) {
382 return getLockCredentialFilePathForUser(userId, LOCK_PATTERN_FILE);
386 String getLockPasswordFilename(int userId) {
387 return getLockCredentialFilePathForUser(userId, LOCK_PASSWORD_FILE);
391 String getLegacyLockPatternFilename(int userId) {
392 return getLockCredentialFilePathForUser(userId, LEGACY_LOCK_PATTERN_FILE);
396 String getLegacyLockPasswordFilename(int userId) {
397 return getLockCredentialFilePathForUser(userId, LEGACY_LOCK_PASSWORD_FILE);
400 private String getBaseZeroLockPatternFilename(int userId) {
401 return getLockCredentialFilePathForUser(userId, BASE_ZERO_LOCK_PATTERN_FILE);
405 String getChildProfileLockFile(int userId) {
406 return getLockCredentialFilePathForUser(userId, CHILD_PROFILE_LOCK_FILE);
409 private String getLockCredentialFilePathForUser(int userId, String basename) {
413 if (userId == 0) {
417 return new File(Environment.getUserSystemDirectory(userId), basename).getAbsolutePath();
421 public void removeUser(int userId) {
425 final UserInfo parentInfo = um.getProfileParent(userId);
430 String name = getLockPasswordFilename(userId);
436 name = getLockPatternFilename(userId);
445 removeChildProfileLock(userId);
450 db.delete(TABLE, COLUMN_USERID + "='" + userId + "'", null);
452 mCache.removeUser(userId);
534 String peekKeyValue(String key, String defaultValue, int userId) {
535 Object cached = peek(CacheKey.TYPE_KEY_VALUE, key, userId);
539 boolean hasKeyValue(String key, int userId) {
540 return contains(CacheKey.TYPE_KEY_VALUE, key, userId);
543 void putKeyValue(String key, String value, int userId) {
544 put(CacheKey.TYPE_KEY_VALUE, key, value, userId);
547 void putKeyValueIfUnchanged(String key, Object value, int userId, int version) {
548 putIfUnchanged(CacheKey.TYPE_KEY_VALUE, key, value, userId, version);
552 return (byte[]) peek(CacheKey.TYPE_FILE, fileName, -1 /* userId */);
556 return contains(CacheKey.TYPE_FILE, fileName, -1 /* userId */);
560 put(CacheKey.TYPE_FILE, key, value, -1 /* userId */);
564 putIfUnchanged(CacheKey.TYPE_FILE, key, value, -1 /* userId */, version);
567 void setFetched(int userId) {
568 put(CacheKey.TYPE_FETCHED, "isFetched", "true", userId);
571 boolean isFetched(int userId) {
572 return contains(CacheKey.TYPE_FETCHED, "", userId);
576 private synchronized void put(int type, String key, Object value, int userId) {
578 mCache.put(new CacheKey().set(type, key, userId), value);
582 private synchronized void putIfUnchanged(int type, String key, Object value, int userId,
584 if (!contains(type, key, userId) && mVersion == version) {
585 put(type, key, value, userId);
589 private synchronized boolean contains(int type, String key, int userId) {
590 return mCache.containsKey(mCacheKey.set(type, key, userId));
593 private synchronized Object peek(int type, String key, int userId) {
594 return mCache.get(mCacheKey.set(type, key, userId));
601 synchronized void removeUser(int userId) {
603 if (mCache.keyAt(i).userId == userId) {
623 int userId;
626 public CacheKey set(int type, String key, int userId) {
629 this.userId = userId;
638 return userId == o.userId && type == o.type && key.equals(o.key);
643 return key.hashCode() ^ userId ^ type;