return trust;
}
- /**
- * @param contentResolver Used to look up and save settings.
- */
public LockPatternUtils(Context context) {
mContext = context;
mContentResolver = context.getContentResolver();
return activePasswordQuality;
}
+ public void clearLock(boolean isFallback) {
+ clearLock(isFallback, getCurrentOrCallingUserId());
+ }
+
/**
* Clear any lock pattern or password.
*/
- public void clearLock(boolean isFallback) {
- if(!isFallback) deleteGallery();
- saveLockPassword(null, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
- setLockPatternEnabled(false);
- saveLockPattern(null);
- setLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED);
- setLong(PASSWORD_TYPE_ALTERNATE_KEY, DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED);
- onAfterChangingPassword();
+ public void clearLock(boolean isFallback, int userHandle) {
+ if(!isFallback) deleteGallery(userHandle);
+ saveLockPassword(null, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING, isFallback,
+ userHandle);
+ setLockPatternEnabled(false, userHandle);
+ saveLockPattern(null, isFallback, userHandle);
+ setLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED, userHandle);
+ setLong(PASSWORD_TYPE_ALTERNATE_KEY, DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED,
+ userHandle);
+ onAfterChangingPassword(userHandle);
}
/**
/**
* Calls back SetupFaceLock to delete the gallery file when the lock type is changed
*/
- void deleteGallery() {
- if(usingBiometricWeak()) {
+ void deleteGallery(int userId) {
+ if(usingBiometricWeak(userId)) {
Intent intent = new Intent().setAction("com.android.facelock.DELETE_GALLERY");
intent.putExtra("deleteGallery", true);
- mContext.sendBroadcast(intent);
+ mContext.sendBroadcastAsUser(intent, new UserHandle(userId));
}
}
/**
* Save a lock pattern.
* @param pattern The new pattern to save.
- * @param isFallback Specifies if this is a fallback to biometric weak
*/
public void saveLockPattern(List<LockPatternView.Cell> pattern, boolean isFallback) {
+ this.saveLockPattern(pattern, isFallback, getCurrentOrCallingUserId());
+ }
+
+ /**
+ * Save a lock pattern.
+ * @param pattern The new pattern to save.
+ * @param isFallback Specifies if this is a fallback to biometric weak
+ * @param userId the user whose pattern is to be saved.
+ */
+ public void saveLockPattern(List<LockPatternView.Cell> pattern, boolean isFallback,
+ int userId) {
try {
- int userId = getCurrentOrCallingUserId();
getLockSettings().setLockPattern(patternToString(pattern), userId);
DevicePolicyManager dpm = getDevicePolicyManager();
if (pattern != null) {
}
}
- setBoolean(PATTERN_EVER_CHOSEN_KEY, true);
+ setBoolean(PATTERN_EVER_CHOSEN_KEY, true, userId);
if (!isFallback) {
- deleteGallery();
- setLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
+ deleteGallery(userId);
+ setLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING, userId);
dpm.setActivePasswordState(DevicePolicyManager.PASSWORD_QUALITY_SOMETHING,
pattern.size(), 0, 0, 0, 0, 0, 0, userId);
} else {
- setLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK);
+ setLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK, userId);
setLong(PASSWORD_TYPE_ALTERNATE_KEY,
- DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
- finishBiometricWeak();
+ DevicePolicyManager.PASSWORD_QUALITY_SOMETHING, userId);
+ finishBiometricWeak(userId);
dpm.setActivePasswordState(DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK,
0, 0, 0, 0, 0, 0, 0, userId);
}
dpm.setActivePasswordState(DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED, 0, 0,
0, 0, 0, 0, 0, userId);
}
- onAfterChangingPassword();
+ onAfterChangingPassword(userId);
} catch (RemoteException re) {
Log.e(TAG, "Couldn't save lock pattern " + re);
}
}
if (!isFallback) {
- deleteGallery();
+ deleteGallery(userHandle);
setLong(PASSWORD_TYPE_KEY, Math.max(quality, computedQuality), userHandle);
if (computedQuality != DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
int letters = 0;
userHandle);
setLong(PASSWORD_TYPE_ALTERNATE_KEY, Math.max(quality, computedQuality),
userHandle);
- finishBiometricWeak();
+ finishBiometricWeak(userHandle);
dpm.setActivePasswordState(DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK,
0, 0, 0, 0, 0, 0, 0, userHandle);
}
// password hashes have the same length for simplicity of implementation.
String passwordHistory = getString(PASSWORD_HISTORY_KEY, userHandle);
if (passwordHistory == null) {
- passwordHistory = new String();
+ passwordHistory = "";
}
int passwordHistoryLength = getRequestedPasswordHistoryLength();
if (passwordHistoryLength == 0) {
DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED, 0, 0, 0, 0, 0, 0, 0,
userHandle);
}
- onAfterChangingPassword();
+ onAfterChangingPassword(userHandle);
} catch (RemoteException re) {
// Cant do much
Log.e(TAG, "Unable to save lock password " + re);
* Set whether the lock pattern is enabled.
*/
public void setLockPatternEnabled(boolean enabled) {
- setBoolean(Settings.Secure.LOCK_PATTERN_ENABLED, enabled);
+ setLockPatternEnabled(enabled, getCurrentOrCallingUserId());
+ }
+
+ /**
+ * Set whether the lock pattern is enabled.
+ */
+ public void setLockPatternEnabled(boolean enabled, int userHandle) {
+ setBoolean(Settings.Secure.LOCK_PATTERN_ENABLED, enabled, userHandle);
}
/**
return (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
}
- private void finishBiometricWeak() {
- setBoolean(BIOMETRIC_WEAK_EVER_CHOSEN_KEY, true);
+ private void finishBiometricWeak(int userId) {
+ setBoolean(BIOMETRIC_WEAK_EVER_CHOSEN_KEY, true, userId);
// Launch intent to show final screen, this also
// moves the temporary gallery to the actual gallery
Intent intent = new Intent();
intent.setClassName("com.android.facelock",
"com.android.facelock.SetupEndScreen");
- mContext.startActivity(intent);
+ mContext.startActivityAsUser(intent, new UserHandle(userId));
}
public void setPowerButtonInstantlyLocks(boolean enabled) {
getTrustManager().reportRequireCredentialEntry(userId);
}
- private void onAfterChangingPassword() {
- getTrustManager().reportEnabledTrustAgentsChanged(getCurrentOrCallingUserId());
+ private void onAfterChangingPassword(int userHandle) {
+ getTrustManager().reportEnabledTrustAgentsChanged(userHandle);
}
public boolean isCredentialRequiredToDecrypt(boolean defaultValue) {