@Override
 public void setLockPattern(String pattern, int userId) throws RemoteException {
   Log.d(TAG, "setLockPattern(pt = " + pattern + ")");
   mService.setLockPattern(pattern, userId);
   boolean result = (pattern != null);
   Log.d(TAG, "setLockPattern() - set val = " + result);
   setBoolean(HAS_LOCK_PATTERN_CACHE_KEY, result, userId);
 }
 public String getString(String key, String defaultValue, int userId) throws RemoteException {
   Object value = peekCache(key, userId);
   if (value instanceof String) {
     return (String) value;
   }
   String result = mService.getString(key, defaultValue, userId);
   putCache(key, userId, result);
   return result;
 }
  @Override
  public void setLockPassword(String password, int userId) throws RemoteException {
    if (TextUtils.isEmpty(password)) {
      password = null;
    }

    mService.setLockPassword(password, userId);
    setBoolean(HAS_LOCK_PASSWORD_CACHE_KEY, password != null, userId);
  }
 public boolean getBoolean(String key, boolean defaultValue, int userId) throws RemoteException {
   Object value = peekCache(key, userId);
   if (value instanceof Boolean) {
     return (boolean) value;
   }
   boolean result = mService.getBoolean(key, defaultValue, userId);
   putCache(key, userId, result);
   return result;
 }
 private LockPatternUtilsCache(ILockSettings service) {
   mService = service;
   try {
     service.registerObserver(mObserver);
   } catch (RemoteException e) {
     // Not safe to do caching without the observer. System process has probably died
     // anyway, so crashing here is fine.
     throw new RuntimeException(e);
   }
 }
 @Override
 public boolean havePassword(int userId) throws RemoteException {
   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
  public boolean havePattern(int userId) throws RemoteException {
    Object value = peekCache(HAS_LOCK_PATTERN_CACHE_KEY, userId);
    if (value instanceof Boolean) {
      Log.d(TAG, "havePattern() - cache = " + (boolean) value);
      return (boolean) value;
    }

    boolean result = mService.havePattern(userId);
    Log.d(TAG, "havePattern() - service = " + result);
    putCache(HAS_LOCK_PATTERN_CACHE_KEY, userId, result);

    return result;
  }
 public void setString(String key, String value, int userId) throws RemoteException {
   invalidateCache(key, userId);
   mService.setString(key, value, userId);
   putCache(key, userId, value);
 }
 @Override
 public IBinder asBinder() {
   return mService.asBinder();
 }
 @Override
 public void unregisterObserver(ILockSettingsObserver observer) throws RemoteException {
   mService.unregisterObserver(observer);
 }
 @Override
 public void removeUser(int userId) throws RemoteException {
   mService.removeUser(userId);
 }
 @Override
 public boolean checkVoldPassword(int userId) throws RemoteException {
   return mService.checkVoldPassword(userId);
 }
 @Override
 public boolean checkPassword(String password, int userId) throws RemoteException {
   return mService.checkPassword(password, userId);
 }
 @Override
 public boolean checkPattern(String pattern, int userId) throws RemoteException {
   return mService.checkPattern(pattern, userId);
 }