diff options
14 files changed, 99 insertions, 184 deletions
diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java index 1096e34..53c0184 100644 --- a/core/java/com/android/internal/widget/LockPatternUtils.java +++ b/core/java/com/android/internal/widget/LockPatternUtils.java @@ -20,6 +20,7 @@ import android.Manifest; import android.app.ActivityManagerNative; import android.app.admin.DevicePolicyManager; import android.app.trust.TrustManager; +import android.bluetooth.BluetoothClass; import android.content.ComponentName; import android.content.ContentResolver; import android.content.Context; @@ -188,67 +189,55 @@ public class LockPatternUtils { return mLockSettingsService; } - public int getRequestedMinimumPasswordLength() { - return getDevicePolicyManager().getPasswordMinimumLength(null, getCurrentOrCallingUserId()); + public int getRequestedMinimumPasswordLength(int userId) { + return getDevicePolicyManager().getPasswordMinimumLength(null, userId); } /** * Gets the device policy password mode. If the mode is non-specific, returns * MODE_PATTERN which allows the user to choose anything. */ - public int getRequestedPasswordQuality() { - return getDevicePolicyManager().getPasswordQuality(null, getCurrentOrCallingUserId()); - } - - public int getRequestedPasswordHistoryLength() { - return getRequestedPasswordHistoryLength(getCurrentOrCallingUserId()); + public int getRequestedPasswordQuality(int userId) { + return getDevicePolicyManager().getPasswordQuality(null, userId); } private int getRequestedPasswordHistoryLength(int userId) { return getDevicePolicyManager().getPasswordHistoryLength(null, userId); } - public int getRequestedPasswordMinimumLetters() { - return getDevicePolicyManager().getPasswordMinimumLetters(null, - getCurrentOrCallingUserId()); + public int getRequestedPasswordMinimumLetters(int userId) { + return getDevicePolicyManager().getPasswordMinimumLetters(null, userId); } - public int getRequestedPasswordMinimumUpperCase() { - return getDevicePolicyManager().getPasswordMinimumUpperCase(null, - getCurrentOrCallingUserId()); + public int getRequestedPasswordMinimumUpperCase(int userId) { + return getDevicePolicyManager().getPasswordMinimumUpperCase(null, userId); } - public int getRequestedPasswordMinimumLowerCase() { - return getDevicePolicyManager().getPasswordMinimumLowerCase(null, - getCurrentOrCallingUserId()); + public int getRequestedPasswordMinimumLowerCase(int userId) { + return getDevicePolicyManager().getPasswordMinimumLowerCase(null, userId); } - public int getRequestedPasswordMinimumNumeric() { - return getDevicePolicyManager().getPasswordMinimumNumeric(null, - getCurrentOrCallingUserId()); + public int getRequestedPasswordMinimumNumeric(int userId) { + return getDevicePolicyManager().getPasswordMinimumNumeric(null, userId); } - public int getRequestedPasswordMinimumSymbols() { - return getDevicePolicyManager().getPasswordMinimumSymbols(null, - getCurrentOrCallingUserId()); + public int getRequestedPasswordMinimumSymbols(int userId) { + return getDevicePolicyManager().getPasswordMinimumSymbols(null, userId); } - public int getRequestedPasswordMinimumNonLetter() { - return getDevicePolicyManager().getPasswordMinimumNonLetter(null, - getCurrentOrCallingUserId()); + public int getRequestedPasswordMinimumNonLetter(int userId) { + return getDevicePolicyManager().getPasswordMinimumNonLetter(null, userId); } - public void reportFailedPasswordAttempt() { - int userId = getCurrentOrCallingUserId(); + public void reportFailedPasswordAttempt(int userId) { getDevicePolicyManager().reportFailedPasswordAttempt(userId); getTrustManager().reportUnlockAttempt(false /* authenticated */, userId); getTrustManager().reportRequireCredentialEntry(userId); } - public void reportSuccessfulPasswordAttempt() { - getDevicePolicyManager().reportSuccessfulPasswordAttempt(getCurrentOrCallingUserId()); - getTrustManager().reportUnlockAttempt(true /* authenticated */, - getCurrentOrCallingUserId()); + public void reportSuccessfulPasswordAttempt(int userId) { + getDevicePolicyManager().reportSuccessfulPasswordAttempt(userId); + getTrustManager().reportUnlockAttempt(true /* authenticated */, userId); } public void setCurrentUser(int userId) { @@ -267,15 +256,15 @@ public class LockPatternUtils { } } - private int getCurrentOrCallingUserId() { - if (mMultiUserMode) { - // TODO: This is a little inefficient. See if all users of this are able to - // handle USER_CURRENT and pass that instead. - return getCurrentUser(); - } else { - return UserHandle.getCallingUserId(); - } - } +// private int getCurrentOrCallingUserId() { +// if (mMultiUserMode) { +// // TODO: This is a little inefficient. See if all users of this are able to +// // handle USER_CURRENT and pass that instead. +// return getCurrentUser(); +// } else { +// return UserHandle.getCallingUserId(); +// } +// } /** * Check to see if a pattern matches the saved pattern. @@ -286,8 +275,7 @@ public class LockPatternUtils { * @param challenge The challenge to verify against the pattern * @return the attestation that the challenge was verified, or null. */ - public byte[] verifyPattern(List<LockPatternView.Cell> pattern, long challenge) { - final int userId = getCurrentOrCallingUserId(); + public byte[] verifyPattern(List<LockPatternView.Cell> pattern, long challenge, int userId) { try { return getLockSettings().verifyPattern(patternToString(pattern), challenge, userId); } catch (RemoteException re) { @@ -301,8 +289,7 @@ public class LockPatternUtils { * @param pattern The pattern to check. * @return Whether the pattern matches the stored one. */ - public boolean checkPattern(List<LockPatternView.Cell> pattern) { - final int userId = getCurrentOrCallingUserId(); + public boolean checkPattern(List<LockPatternView.Cell> pattern, int userId) { try { return getLockSettings().checkPattern(patternToString(pattern), userId); } catch (RemoteException re) { @@ -319,8 +306,7 @@ public class LockPatternUtils { * @param challenge The challenge to verify against the password * @return the attestation that the challenge was verified, or null. */ - public byte[] verifyPassword(String password, long challenge) { - final int userId = getCurrentOrCallingUserId(); + public byte[] verifyPassword(String password, long challenge, int userId) { try { return getLockSettings().verifyPassword(password, challenge, userId); } catch (RemoteException re) { @@ -334,8 +320,7 @@ public class LockPatternUtils { * @param password The password to check. * @return Whether the password matches the stored one. */ - public boolean checkPassword(String password) { - final int userId = getCurrentOrCallingUserId(); + public boolean checkPassword(String password, int userId) { try { return getLockSettings().checkPassword(password, userId); } catch (RemoteException re) { @@ -348,8 +333,7 @@ public class LockPatternUtils { * Note that this also clears vold's copy of the password. * @return Whether the vold password matches or not. */ - public boolean checkVoldPassword() { - final int userId = getCurrentOrCallingUserId(); + public boolean checkVoldPassword(int userId) { try { return getLockSettings().checkVoldPassword(userId); } catch (RemoteException re) { @@ -364,8 +348,7 @@ public class LockPatternUtils { * @param password The password to check. * @return Whether the password matches any in the history. */ - public boolean checkPasswordHistory(String password) { - int userId = getCurrentOrCallingUserId(); + public boolean checkPasswordHistory(String password, int userId) { String passwordHashString = new String( passwordToHash(password, userId), StandardCharsets.UTF_8); String passwordHistory = getString(PASSWORD_HISTORY_KEY, userId); @@ -374,7 +357,7 @@ public class LockPatternUtils { } // Password History may be too long... int passwordHashLength = passwordHashString.length(); - int passwordHistoryLength = getRequestedPasswordHistoryLength(); + int passwordHistoryLength = getRequestedPasswordHistoryLength(userId); if(passwordHistoryLength == 0) { return false; } @@ -416,16 +399,8 @@ public class LockPatternUtils { * * @return True if the user has ever chosen a pattern. */ - public boolean isPatternEverChosen() { - return getBoolean(PATTERN_EVER_CHOSEN_KEY, false, getCurrentOrCallingUserId()); - } - - /** - * Used by device policy manager to validate the current password - * information it has. - */ - public int getActivePasswordQuality() { - return getActivePasswordQuality(getCurrentOrCallingUserId()); + public boolean isPatternEverChosen(int userId) { + return getBoolean(PATTERN_EVER_CHOSEN_KEY, false, userId); } /** @@ -448,10 +423,6 @@ public class LockPatternUtils { return DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED; } - public void clearLock() { - clearLock(getCurrentOrCallingUserId()); - } - /** * Clear any lock pattern or password. */ @@ -479,16 +450,6 @@ public class LockPatternUtils { } /** - * Disable showing lock screen at all when the DevicePolicyManager allows it. - * This is only meaningful if pattern, pin or password are not set. - * - * @param disable Disables lock screen when true - */ - public void setLockScreenDisabled(boolean disable) { - setLockScreenDisabled(disable, getCurrentOrCallingUserId()); - } - - /** * Disable showing lock screen at all for a given user. * This is only meaningful if pattern, pin or password are not set. * @@ -505,21 +466,16 @@ public class LockPatternUtils { * * @return true if lock screen is disabled */ - public boolean isLockScreenDisabled() { - return !isSecure() && - getBoolean(DISABLE_LOCKSCREEN_KEY, false, getCurrentOrCallingUserId()); + public boolean isLockScreenDisabled(int userId) { + return !isSecure(userId) && + getBoolean(DISABLE_LOCKSCREEN_KEY, false, userId); } /** * Save a lock pattern. * @param pattern The new pattern to save. - * @param savedPattern The previously saved pattern, or null if none + * @param userId the user whose pattern is to be saved. */ - public void saveLockPattern(List<LockPatternView.Cell> pattern, - String savedPattern) { - this.saveLockPattern(pattern, savedPattern, getCurrentOrCallingUserId()); - } - public void saveLockPattern(List<LockPatternView.Cell> pattern, int userId) { this.saveLockPattern(pattern, null, userId); } @@ -588,8 +544,7 @@ public class LockPatternUtils { updateCryptoUserInfo(userId); } - public void setOwnerInfoEnabled(boolean enabled) { - int userId = getCurrentOrCallingUserId(); + public void setOwnerInfoEnabled(boolean enabled, int userId) { setBoolean(LOCK_SCREEN_OWNER_INFO_ENABLED, enabled, userId); updateCryptoUserInfo(userId); } @@ -598,11 +553,7 @@ public class LockPatternUtils { return getString(LOCK_SCREEN_OWNER_INFO, userId); } - public boolean isOwnerInfoEnabled() { - return isOwnerInfoEnabled(getCurrentOrCallingUserId()); - } - - private boolean isOwnerInfoEnabled(int userId) { + public boolean isOwnerInfoEnabled(int userId) { return getBoolean(LOCK_SCREEN_OWNER_INFO_ENABLED, false, userId); } @@ -724,21 +675,10 @@ public class LockPatternUtils { /** * Save a lock password. Does not ensure that the password is as good * as the requested mode, but will adjust the mode to be as good as the - * pattern. + * password. * @param password The password to save * @param savedPassword The previously saved lock password, or null if none * @param quality {@see DevicePolicyManager#getPasswordQuality(android.content.ComponentName)} - */ - public void saveLockPassword(String password, String savedPassword, int quality) { - saveLockPassword(password, savedPassword, quality, getCurrentOrCallingUserId()); - } - - /** - * Save a lock password. Does not ensure that the password is as good - * as the requested mode, but will adjust the mode to be as good as the - * pattern. - * @param password The password to save - * @param quality {@see DevicePolicyManager#getPasswordQuality(android.content.ComponentName)} * @param userHandle The userId of the user to change the password for */ public void saveLockPassword(String password, String savedPassword, int quality, @@ -865,16 +805,6 @@ public class LockPatternUtils { } /** - * Retrieves the quality mode we're in. - * {@see DevicePolicyManager#getPasswordQuality(android.content.ComponentName)} - * - * @return stored password quality - */ - public int getKeyguardStoredPasswordQuality() { - return getKeyguardStoredPasswordQuality(getCurrentOrCallingUserId()); - } - - /** * Retrieves the quality mode for {@param userHandle}. * {@see DevicePolicyManager#getPasswordQuality(android.content.ComponentName)} * @@ -997,13 +927,6 @@ public class LockPatternUtils { } /** - * @return Whether the lock screen is secured. - */ - public boolean isSecure() { - return isSecure(getCurrentOrCallingUserId()); - } - - /** * @param userId the user for which to report the value * @return Whether the lock screen is secured. */ @@ -1012,13 +935,6 @@ public class LockPatternUtils { return isLockPatternEnabled(mode, userId) || isLockPasswordEnabled(mode, userId); } - /** - * @return Whether the lock password is enabled - */ - public boolean isLockPasswordEnabled() { - return isLockPasswordEnabled(getCurrentOrCallingUserId()); - } - public boolean isLockPasswordEnabled(int userId) { return isLockPasswordEnabled(getKeyguardStoredPasswordQuality(userId), userId); } @@ -1035,10 +951,6 @@ public class LockPatternUtils { /** * @return Whether the lock pattern is enabled */ - public boolean isLockPatternEnabled() { - return isLockPatternEnabled(getCurrentOrCallingUserId()); - } - public boolean isLockPatternEnabled(int userId) { return isLockPatternEnabled(getKeyguardStoredPasswordQuality(userId), userId); } @@ -1051,16 +963,14 @@ public class LockPatternUtils { /** * @return Whether the visible pattern is enabled. */ - public boolean isVisiblePatternEnabled() { - return getBoolean(Settings.Secure.LOCK_PATTERN_VISIBLE, false, getCurrentOrCallingUserId()); + public boolean isVisiblePatternEnabled(int userId) { + return getBoolean(Settings.Secure.LOCK_PATTERN_VISIBLE, false, userId); } /** * Set whether the visible pattern is enabled. */ - public void setVisiblePatternEnabled(boolean enabled) { - int userId = getCurrentOrCallingUserId(); - + public void setVisiblePatternEnabled(boolean enabled, int userId) { setBoolean(Settings.Secure.LOCK_PATTERN_VISIBLE, enabled, userId); // Update for crypto if owner @@ -1095,9 +1005,9 @@ public class LockPatternUtils { * pattern until the deadline has passed. * @return the chosen deadline. */ - public long setLockoutAttemptDeadline() { + public long setLockoutAttemptDeadline(int userId) { final long deadline = SystemClock.elapsedRealtime() + FAILED_ATTEMPT_TIMEOUT_MS; - setLong(LOCKOUT_ATTEMPT_DEADLINE, deadline, getCurrentOrCallingUserId()); + setLong(LOCKOUT_ATTEMPT_DEADLINE, deadline, userId); return deadline; } @@ -1106,8 +1016,8 @@ public class LockPatternUtils { * attempt to enter his/her lock pattern, or 0 if the user is welcome to * enter a pattern. */ - public long getLockoutAttemptDeadline() { - final long deadline = getLong(LOCKOUT_ATTEMPT_DEADLINE, 0L, getCurrentOrCallingUserId()); + public long getLockoutAttemptDeadline(int userId) { + final long deadline = getLong(LOCKOUT_ATTEMPT_DEADLINE, 0L, userId); final long now = SystemClock.elapsedRealtime(); if (deadline < now || deadline > (now + FAILED_ATTEMPT_TIMEOUT_MS)) { return 0L; @@ -1166,21 +1076,12 @@ public class LockPatternUtils { } } - public void setPowerButtonInstantlyLocks(boolean enabled) { - setBoolean(LOCKSCREEN_POWER_BUTTON_INSTANTLY_LOCKS, enabled, getCurrentOrCallingUserId()); - } - - public boolean getPowerButtonInstantlyLocks() { - return getBoolean(LOCKSCREEN_POWER_BUTTON_INSTANTLY_LOCKS, true, - getCurrentOrCallingUserId()); - } - - public void setEnabledTrustAgents(Collection<ComponentName> activeTrustAgents) { - setEnabledTrustAgents(activeTrustAgents, getCurrentOrCallingUserId()); + public void setPowerButtonInstantlyLocks(boolean enabled, int userId) { + setBoolean(LOCKSCREEN_POWER_BUTTON_INSTANTLY_LOCKS, enabled, userId); } - public List<ComponentName> getEnabledTrustAgents() { - return getEnabledTrustAgents(getCurrentOrCallingUserId()); + public boolean getPowerButtonInstantlyLocks(int userId) { + return getBoolean(LOCKSCREEN_POWER_BUTTON_INSTANTLY_LOCKS, true, userId); } public void setEnabledTrustAgents(Collection<ComponentName> activeTrustAgents, int userId) { @@ -1192,7 +1093,7 @@ public class LockPatternUtils { sb.append(cn.flattenToShortString()); } setString(ENABLED_TRUST_AGENTS, sb.toString(), userId); - getTrustManager().reportEnabledTrustAgentsChanged(getCurrentOrCallingUserId()); + getTrustManager().reportEnabledTrustAgentsChanged(userId); } public List<ComponentName> getEnabledTrustAgents(int userId) { diff --git a/packages/Keyguard/src/com/android/keyguard/EmergencyButton.java b/packages/Keyguard/src/com/android/keyguard/EmergencyButton.java index 1699809..5bc7da9 100644 --- a/packages/Keyguard/src/com/android/keyguard/EmergencyButton.java +++ b/packages/Keyguard/src/com/android/keyguard/EmergencyButton.java @@ -138,7 +138,7 @@ public class EmergencyButton extends Button { visible = mEnableEmergencyCallWhileSimLocked; } else { // Only show if there is a secure screen (pin/pattern/SIM pin/SIM puk); - visible = mLockPatternUtils.isSecure(); + visible = mLockPatternUtils.isSecure(mLockPatternUtils.getCurrentUser()); } } } diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java index 322be91..db4db13 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java @@ -63,7 +63,8 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout // start fresh resetPasswordText(false /* animate */); // if the user is currently locked out, enforce it. - long deadline = mLockPatternUtils.getLockoutAttemptDeadline(); + long deadline = mLockPatternUtils.getLockoutAttemptDeadline( + mLockPatternUtils.getCurrentUser()); if (shouldLockout(deadline)) { handleAttemptLockout(deadline); } else { @@ -106,7 +107,7 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout protected void verifyPasswordAndUnlock() { String entry = getPasswordText(); - if (mLockPatternUtils.checkPassword(entry)) { + if (mLockPatternUtils.checkPassword(entry, mLockPatternUtils.getCurrentUser())) { mCallback.reportUnlockAttempt(true); mCallback.dismiss(true); } else { @@ -116,7 +117,8 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout mCallback.reportUnlockAttempt(false); int attempts = KeyguardUpdateMonitor.getInstance(mContext).getFailedUnlockAttempts(); if (0 == (attempts % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) { - long deadline = mLockPatternUtils.setLockoutAttemptDeadline(); + long deadline = mLockPatternUtils.setLockoutAttemptDeadline( + mLockPatternUtils.getCurrentUser()); handleAttemptLockout(deadline); } } diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java index 9aa5729..00a5140 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java @@ -130,7 +130,8 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit mLockPatternView.setOnPatternListener(new UnlockPatternListener()); // stealth mode will be the same for the life of this screen - mLockPatternView.setInStealthMode(!mLockPatternUtils.isVisiblePatternEnabled()); + mLockPatternView.setInStealthMode(!mLockPatternUtils.isVisiblePatternEnabled( + mLockPatternUtils.getCurrentUser())); // vibrate mode will be the same for the life of this screen mLockPatternView.setTactileFeedbackEnabled(mLockPatternUtils.isTactileFeedbackEnabled()); @@ -176,7 +177,8 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit mLockPatternView.clearPattern(); // if the user is currently locked out, enforce it. - long deadline = mLockPatternUtils.getLockoutAttemptDeadline(); + long deadline = mLockPatternUtils.getLockoutAttemptDeadline( + mLockPatternUtils.getCurrentUser()); if (deadline != 0) { handleAttemptLockout(deadline); } else { @@ -213,7 +215,7 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit } public void onPatternDetected(List<LockPatternView.Cell> pattern) { - if (mLockPatternUtils.checkPattern(pattern)) { + if (mLockPatternUtils.checkPattern(pattern, mLockPatternUtils.getCurrentUser())) { mCallback.reportUnlockAttempt(true); mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Correct); mCallback.dismiss(true); @@ -230,7 +232,8 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit int attempts = mKeyguardUpdateMonitor.getFailedUnlockAttempts(); if (registeredAttempt && 0 == (attempts % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) { - long deadline = mLockPatternUtils.setLockoutAttemptDeadline(); + long deadline = mLockPatternUtils.setLockoutAttemptDeadline( + mLockPatternUtils.getCurrentUser()); handleAttemptLockout(deadline); } else { mSecurityMessageDisplay.setMessage(R.string.kg_wrong_pattern, true); diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java index 5af7783..1cced15 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java @@ -296,7 +296,7 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe (failedAttempts % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) == 0; } monitor.reportFailedUnlockAttempt(); - mLockPatternUtils.reportFailedPasswordAttempt(); + mLockPatternUtils.reportFailedPasswordAttempt(mLockPatternUtils.getCurrentUser()); if (showTimeout) { showTimeoutDialog(); } @@ -430,7 +430,8 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(mContext); if (success) { monitor.clearFailedUnlockAttempts(); - mLockPatternUtils.reportSuccessfulPasswordAttempt(); + mLockPatternUtils.reportSuccessfulPasswordAttempt( + mLockPatternUtils.getCurrentUser()); } else { KeyguardSecurityContainer.this.reportFailedUnlockAttempt(); } diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java index 3eb31ad..e582811 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java @@ -67,7 +67,8 @@ public class KeyguardSecurityModel { return SecurityMode.SimPuk; } - final int security = mLockPatternUtils.getActivePasswordQuality(); + final int security = mLockPatternUtils.getActivePasswordQuality( + mLockPatternUtils.getCurrentUser()); switch (security) { case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC: case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX: diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardStatusView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardStatusView.java index af6360a..7cd9c7c 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardStatusView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardStatusView.java @@ -200,7 +200,8 @@ public class KeyguardStatusView extends GridLayout { private String getOwnerInfo() { ContentResolver res = getContext().getContentResolver(); String info = null; - final boolean ownerInfoEnabled = mLockPatternUtils.isOwnerInfoEnabled(); + final boolean ownerInfoEnabled = mLockPatternUtils.isOwnerInfoEnabled( + mLockPatternUtils.getCurrentUser()); if (ownerInfoEnabled) { info = mLockPatternUtils.getOwnerInfo(mLockPatternUtils.getCurrentUser()); } diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java index 870f043..7bf2223 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java @@ -2066,7 +2066,7 @@ class DatabaseHelper extends SQLiteOpenHelper { LockPatternUtils lpu = new LockPatternUtils(mContext); List<LockPatternView.Cell> cellPattern = LockPatternUtils.stringToPattern(lockPattern); - lpu.saveLockPattern(cellPattern, null); + lpu.saveLockPattern(cellPattern, null, UserHandle.USER_OWNER); } catch (IllegalArgumentException e) { // Don't want corrupted lock pattern to hang the reboot process } diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java index 7f826ef..d99f741 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java @@ -754,7 +754,7 @@ public class SettingsBackupAgent extends BackupAgentHelper { */ private byte[] getLockSettings() { final LockPatternUtils lockPatternUtils = new LockPatternUtils(this); - final boolean ownerInfoEnabled = lockPatternUtils.isOwnerInfoEnabled(); + final boolean ownerInfoEnabled = lockPatternUtils.isOwnerInfoEnabled(UserHandle.myUserId()); final String ownerInfo = lockPatternUtils.getOwnerInfo(UserHandle.myUserId()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -871,7 +871,8 @@ public class SettingsBackupAgent extends BackupAgentHelper { } switch (key) { case KEY_LOCK_SETTINGS_OWNER_INFO_ENABLED: - lockPatternUtils.setOwnerInfoEnabled("1".equals(value)); + lockPatternUtils.setOwnerInfoEnabled("1".equals(value), + UserHandle.myUserId()); break; case KEY_LOCK_SETTINGS_OWNER_INFO: lockPatternUtils.setOwnerInfo(value, UserHandle.myUserId()); diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index 7b555fc..e24e88e 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -542,7 +542,8 @@ public class KeyguardViewMediator extends SystemUI { mLockPatternUtils.setCurrentUser(ActivityManager.getCurrentUser()); // Assume keyguard is showing (unless it's disabled) until we know for sure... - setShowingLocked(!shouldWaitForProvisioning() && !mLockPatternUtils.isLockScreenDisabled()); + setShowingLocked(!shouldWaitForProvisioning() && !mLockPatternUtils.isLockScreenDisabled( + mLockPatternUtils.getCurrentUser())); mTrustManager.reportKeyguardShowingChanged(); mStatusBarKeyguardViewManager = new StatusBarKeyguardViewManager(mContext, @@ -623,8 +624,10 @@ public class KeyguardViewMediator extends SystemUI { // Lock immediately based on setting if secure (user has a pin/pattern/password). // This also "locks" the device when not secure to provide easy access to the // camera while preventing unwanted input. + int currentUser = mLockPatternUtils.getCurrentUser(); final boolean lockImmediately = - mLockPatternUtils.getPowerButtonInstantlyLocks() || !mLockPatternUtils.isSecure(); + mLockPatternUtils.getPowerButtonInstantlyLocks(currentUser) + || !mLockPatternUtils.isSecure(currentUser); notifyScreenOffLocked(); @@ -719,7 +722,8 @@ public class KeyguardViewMediator extends SystemUI { } private void maybeSendUserPresentBroadcast() { - if (mSystemReady && mLockPatternUtils.isLockScreenDisabled()) { + if (mSystemReady && mLockPatternUtils.isLockScreenDisabled( + mLockPatternUtils.getCurrentUser())) { // Lock screen is disabled because the user has set the preference to "None". // In this case, send out ACTION_USER_PRESENT here instead of in // handleKeyguardDone() @@ -733,7 +737,7 @@ public class KeyguardViewMediator extends SystemUI { */ public void onDreamingStarted() { synchronized (this) { - if (mScreenOn && mLockPatternUtils.isSecure()) { + if (mScreenOn && mLockPatternUtils.isSecure(mLockPatternUtils.getCurrentUser())) { doKeyguardLaterLocked(); } } @@ -974,12 +978,13 @@ public class KeyguardViewMediator extends SystemUI { return; } - if (mLockPatternUtils.isLockScreenDisabled() && !lockedOrMissing) { + if (mLockPatternUtils.isLockScreenDisabled(mLockPatternUtils.getCurrentUser()) + && !lockedOrMissing) { if (DEBUG) Log.d(TAG, "doKeyguard: not showing because lockscreen is off"); return; } - if (mLockPatternUtils.checkVoldPassword()) { + if (mLockPatternUtils.checkVoldPassword(mLockPatternUtils.getCurrentUser())) { if (DEBUG) Log.d(TAG, "Not showing lock screen since just decrypted"); // Without this, settings is not enabled until the lock screen first appears setShowingLocked(false); @@ -1072,7 +1077,7 @@ public class KeyguardViewMediator extends SystemUI { } public boolean isSecure() { - return mLockPatternUtils.isSecure() + return mLockPatternUtils.isSecure(mLockPatternUtils.getCurrentUser()) || KeyguardUpdateMonitor.getInstance(mContext).isSimPinSecure(); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index 92bd0df..cf54fbc 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -639,7 +639,7 @@ public abstract class BaseStatusBar extends SystemUI implements Settings.Secure.SHOW_NOTE_ABOUT_NOTIFICATION_HIDING, 1)) { Log.d(TAG, "user hasn't seen notification about hidden notifications"); final LockPatternUtils lockPatternUtils = new LockPatternUtils(mContext); - if (!lockPatternUtils.isSecure()) { + if (!lockPatternUtils.isSecure(lockPatternUtils.getCurrentUser())) { Log.d(TAG, "insecure lockscreen, skipping notification"); Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.SHOW_NOTE_ABOUT_NOTIFICATION_HIDING, 0); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java index e5ef6ff..a213160 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java @@ -234,8 +234,8 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext); boolean currentUserHasTrust = updateMonitor.getUserHasTrust( mLockPatternUtils.getCurrentUser()); - return mLockPatternUtils.isSecure() && !currentUserHasTrust - ? SECURE_CAMERA_INTENT : INSECURE_CAMERA_INTENT; + boolean secure = mLockPatternUtils.isSecure(mLockPatternUtils.getCurrentUser()); + return (secure && !currentUserHasTrust) ? SECURE_CAMERA_INTENT : INSECURE_CAMERA_INTENT; } private void updateCameraVisibility() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java index 65cd268..75b2c741 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java @@ -81,7 +81,7 @@ public class UnlockMethodCache { private void update(boolean updateAlways) { int user = mLockPatternUtils.getCurrentUser(); - boolean secure = mLockPatternUtils.isSecure(); + boolean secure = mLockPatternUtils.isSecure(user); boolean currentlyInsecure = !secure || mKeyguardUpdateMonitor.getUserHasTrust(user); boolean trustManaged = mKeyguardUpdateMonitor.getUserTrustIsManaged(user); boolean faceUnlockRunning = mKeyguardUpdateMonitor.isFaceUnlockRunning(user) diff --git a/services/core/java/com/android/server/policy/keyguard/KeyguardStateMonitor.java b/services/core/java/com/android/server/policy/keyguard/KeyguardStateMonitor.java index 926090e..f2d9a3a 100644 --- a/services/core/java/com/android/server/policy/keyguard/KeyguardStateMonitor.java +++ b/services/core/java/com/android/server/policy/keyguard/KeyguardStateMonitor.java @@ -58,7 +58,7 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub { } public boolean isSecure() { - return mLockPatternUtils.isSecure() || mSimSecure; + return mLockPatternUtils.isSecure(mLockPatternUtils.getCurrentUser()) || mSimSecure; } public boolean isInputRestricted() { |