am 59a1e117: Merge changes from topic \'roosa-lpu\' into mnc-dev
* commit '59a1e117ac00b71756abce44afe96002d4de3fa4': Remove LockPatternUtils.getCurrentUser() Require explicit userId in LockPatternUtils
This commit is contained in:
@@ -17,9 +17,11 @@
|
||||
package com.android.internal.widget;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.ActivityManager;
|
||||
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;
|
||||
@@ -142,11 +144,6 @@ public class LockPatternUtils {
|
||||
private DevicePolicyManager mDevicePolicyManager;
|
||||
private ILockSettings mLockSettingsService;
|
||||
|
||||
private final boolean mMultiUserMode;
|
||||
|
||||
// The current user is set by KeyguardViewMediator and shared by all LockPatternUtils.
|
||||
private static volatile int sCurrentUserId = UserHandle.USER_NULL;
|
||||
|
||||
public DevicePolicyManager getDevicePolicyManager() {
|
||||
if (mDevicePolicyManager == null) {
|
||||
mDevicePolicyManager =
|
||||
@@ -171,12 +168,6 @@ public class LockPatternUtils {
|
||||
public LockPatternUtils(Context context) {
|
||||
mContext = context;
|
||||
mContentResolver = context.getContentResolver();
|
||||
|
||||
// If this is being called by the system or by an application like keyguard that
|
||||
// has permision INTERACT_ACROSS_USERS, then LockPatternUtils will operate in multi-user
|
||||
// mode where calls are for the current user rather than the user of the calling process.
|
||||
mMultiUserMode = context.checkCallingOrSelfPermission(
|
||||
Manifest.permission.INTERACT_ACROSS_USERS_FULL) == PackageManager.PERMISSION_GRANTED;
|
||||
}
|
||||
|
||||
private ILockSettings getLockSettings() {
|
||||
@@ -188,93 +179,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 setCurrentUser(int userId) {
|
||||
sCurrentUserId = userId;
|
||||
}
|
||||
|
||||
public int getCurrentUser() {
|
||||
if (sCurrentUserId != UserHandle.USER_NULL) {
|
||||
// Someone is regularly updating using setCurrentUser() use that value.
|
||||
return sCurrentUserId;
|
||||
}
|
||||
try {
|
||||
return ActivityManagerNative.getDefault().getCurrentUser().id;
|
||||
} catch (RemoteException re) {
|
||||
return UserHandle.USER_OWNER;
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
public void reportSuccessfulPasswordAttempt(int userId) {
|
||||
getDevicePolicyManager().reportSuccessfulPasswordAttempt(userId);
|
||||
getTrustManager().reportUnlockAttempt(true /* authenticated */, userId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -286,8 +239,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 +253,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 +270,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 +284,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 +297,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 +312,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 +321,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 +363,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 +387,6 @@ public class LockPatternUtils {
|
||||
return DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
|
||||
}
|
||||
|
||||
public void clearLock() {
|
||||
clearLock(getCurrentOrCallingUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear any lock pattern or password.
|
||||
*/
|
||||
@@ -478,16 +413,6 @@ public class LockPatternUtils {
|
||||
onAfterChangingPassword(userHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 +430,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 +508,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 +517,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 +639,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,
|
||||
@@ -864,16 +768,6 @@ public class LockPatternUtils {
|
||||
updateEncryptionPassword(StorageManager.CRYPT_TYPE_DEFAULT, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)}
|
||||
@@ -996,13 +890,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 +899,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 +915,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 +927,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 +969,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 +980,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 +1040,12 @@ public class LockPatternUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public void setPowerButtonInstantlyLocks(boolean enabled) {
|
||||
setBoolean(LOCKSCREEN_POWER_BUTTON_INSTANTLY_LOCKS, enabled, getCurrentOrCallingUserId());
|
||||
public void setPowerButtonInstantlyLocks(boolean enabled, int userId) {
|
||||
setBoolean(LOCKSCREEN_POWER_BUTTON_INSTANTLY_LOCKS, enabled, userId);
|
||||
}
|
||||
|
||||
public boolean getPowerButtonInstantlyLocks() {
|
||||
return getBoolean(LOCKSCREEN_POWER_BUTTON_INSTANTLY_LOCKS, true,
|
||||
getCurrentOrCallingUserId());
|
||||
}
|
||||
|
||||
public void setEnabledTrustAgents(Collection<ComponentName> activeTrustAgents) {
|
||||
setEnabledTrustAgents(activeTrustAgents, getCurrentOrCallingUserId());
|
||||
}
|
||||
|
||||
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 +1057,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) {
|
||||
@@ -1228,7 +1093,7 @@ public class LockPatternUtils {
|
||||
}
|
||||
|
||||
public void setCredentialRequiredToDecrypt(boolean required) {
|
||||
if (getCurrentUser() != UserHandle.USER_OWNER) {
|
||||
if (ActivityManager.getCurrentUser() != UserHandle.USER_OWNER) {
|
||||
Log.w(TAG, "Only device owner may call setCredentialRequiredForDecrypt()");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ public class EmergencyButton extends Button {
|
||||
KeyguardUpdateMonitor.getInstance(mContext).reportEmergencyCallAction(
|
||||
true /* bypassHandler */);
|
||||
getContext().startActivityAsUser(INTENT_EMERGENCY_DIAL,
|
||||
new UserHandle(mLockPatternUtils.getCurrentUser()));
|
||||
new UserHandle(KeyguardUpdateMonitor.getCurrentUser()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(KeyguardUpdateMonitor.getCurrentUser());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
KeyguardUpdateMonitor.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, KeyguardUpdateMonitor.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(
|
||||
KeyguardUpdateMonitor.getCurrentUser());
|
||||
handleAttemptLockout(deadline);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class KeyguardHostView extends FrameLayout implements SecurityCallback {
|
||||
|
||||
@Override
|
||||
public void onTrustGrantedWithFlags(int flags, int userId) {
|
||||
if (userId != mLockPatternUtils.getCurrentUser()) return;
|
||||
if (userId != KeyguardUpdateMonitor.getCurrentUser()) return;
|
||||
if (!isAttachedToWindow()) return;
|
||||
boolean bouncerVisible = isVisibleToUser();
|
||||
boolean initiatedByUser =
|
||||
|
||||
@@ -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(
|
||||
KeyguardUpdateMonitor.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(
|
||||
KeyguardUpdateMonitor.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, KeyguardUpdateMonitor.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(
|
||||
KeyguardUpdateMonitor.getCurrentUser());
|
||||
handleAttemptLockout(deadline);
|
||||
} else {
|
||||
mSecurityMessageDisplay.setMessage(R.string.kg_wrong_pattern, true);
|
||||
|
||||
@@ -261,7 +261,7 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
|
||||
|
||||
SecurityMode mode = mSecurityModel.getSecurityMode();
|
||||
final boolean usingPattern = mode == KeyguardSecurityModel.SecurityMode.Pattern;
|
||||
final int currentUser = mLockPatternUtils.getCurrentUser();
|
||||
final int currentUser = KeyguardUpdateMonitor.getCurrentUser();
|
||||
final DevicePolicyManager dpm = mLockPatternUtils.getDevicePolicyManager();
|
||||
final int failedAttemptsBeforeWipe =
|
||||
dpm.getMaximumFailedPasswordsForWipe(null, currentUser);
|
||||
@@ -296,7 +296,7 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
|
||||
(failedAttempts % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) == 0;
|
||||
}
|
||||
monitor.reportFailedUnlockAttempt();
|
||||
mLockPatternUtils.reportFailedPasswordAttempt();
|
||||
mLockPatternUtils.reportFailedPasswordAttempt(KeyguardUpdateMonitor.getCurrentUser());
|
||||
if (showTimeout) {
|
||||
showTimeoutDialog();
|
||||
}
|
||||
@@ -321,7 +321,7 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
|
||||
boolean showNextSecurityScreenOrFinish(boolean authenticated) {
|
||||
if (DEBUG) Log.d(TAG, "showNextSecurityScreenOrFinish(" + authenticated + ")");
|
||||
boolean finish = false;
|
||||
if (mUpdateMonitor.getUserHasTrust(mLockPatternUtils.getCurrentUser())) {
|
||||
if (mUpdateMonitor.getUserHasTrust(KeyguardUpdateMonitor.getCurrentUser())) {
|
||||
finish = true;
|
||||
} else if (SecurityMode.None == mCurrentSecuritySelection) {
|
||||
SecurityMode securityMode = mSecurityModel.getSecurityMode();
|
||||
@@ -430,7 +430,8 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
|
||||
KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(mContext);
|
||||
if (success) {
|
||||
monitor.clearFailedUnlockAttempts();
|
||||
mLockPatternUtils.reportSuccessfulPasswordAttempt();
|
||||
mLockPatternUtils.reportSuccessfulPasswordAttempt(
|
||||
KeyguardUpdateMonitor.getCurrentUser());
|
||||
} else {
|
||||
KeyguardSecurityContainer.this.reportFailedUnlockAttempt();
|
||||
}
|
||||
|
||||
@@ -67,7 +67,8 @@ public class KeyguardSecurityModel {
|
||||
return SecurityMode.SimPuk;
|
||||
}
|
||||
|
||||
final int security = mLockPatternUtils.getActivePasswordQuality();
|
||||
final int security = mLockPatternUtils.getActivePasswordQuality(
|
||||
KeyguardUpdateMonitor.getCurrentUser());
|
||||
switch (security) {
|
||||
case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC:
|
||||
case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX:
|
||||
|
||||
@@ -200,9 +200,10 @@ 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(
|
||||
KeyguardUpdateMonitor.getCurrentUser());
|
||||
if (ownerInfoEnabled) {
|
||||
info = mLockPatternUtils.getOwnerInfo(mLockPatternUtils.getCurrentUser());
|
||||
info = mLockPatternUtils.getOwnerInfo(KeyguardUpdateMonitor.getCurrentUser());
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
@@ -244,6 +244,16 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
|
||||
private SparseBooleanArray mUserFingerprintAuthenticated = new SparseBooleanArray();
|
||||
private SparseBooleanArray mUserFaceUnlockRunning = new SparseBooleanArray();
|
||||
|
||||
private static int sCurrentUser;
|
||||
|
||||
public synchronized static void setCurrentUser(int currentUser) {
|
||||
sCurrentUser = currentUser;
|
||||
}
|
||||
|
||||
public synchronized static int getCurrentUser() {
|
||||
return sCurrentUser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTrustChanged(boolean enabled, int userId, int flags) {
|
||||
mUserHasTrust.put(userId, enabled);
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -539,10 +539,11 @@ public class KeyguardViewMediator extends SystemUI {
|
||||
mUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
|
||||
|
||||
mLockPatternUtils = new LockPatternUtils(mContext);
|
||||
mLockPatternUtils.setCurrentUser(ActivityManager.getCurrentUser());
|
||||
KeyguardUpdateMonitor.setCurrentUser(ActivityManager.getCurrentUser());
|
||||
|
||||
// Assume keyguard is showing (unless it's disabled) until we know for sure...
|
||||
setShowingLocked(!shouldWaitForProvisioning() && !mLockPatternUtils.isLockScreenDisabled());
|
||||
setShowingLocked(!shouldWaitForProvisioning() && !mLockPatternUtils.isLockScreenDisabled(
|
||||
KeyguardUpdateMonitor.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 = KeyguardUpdateMonitor.getCurrentUser();
|
||||
final boolean lockImmediately =
|
||||
mLockPatternUtils.getPowerButtonInstantlyLocks() || !mLockPatternUtils.isSecure();
|
||||
mLockPatternUtils.getPowerButtonInstantlyLocks(currentUser)
|
||||
|| !mLockPatternUtils.isSecure(currentUser);
|
||||
|
||||
notifyScreenOffLocked();
|
||||
|
||||
@@ -670,7 +673,7 @@ public class KeyguardViewMediator extends SystemUI {
|
||||
|
||||
// From DevicePolicyAdmin
|
||||
final long policyTimeout = mLockPatternUtils.getDevicePolicyManager()
|
||||
.getMaximumTimeToLock(null, mLockPatternUtils.getCurrentUser());
|
||||
.getMaximumTimeToLock(null, KeyguardUpdateMonitor.getCurrentUser());
|
||||
|
||||
long timeout;
|
||||
if (policyTimeout > 0) {
|
||||
@@ -719,7 +722,8 @@ public class KeyguardViewMediator extends SystemUI {
|
||||
}
|
||||
|
||||
private void maybeSendUserPresentBroadcast() {
|
||||
if (mSystemReady && mLockPatternUtils.isLockScreenDisabled()) {
|
||||
if (mSystemReady && mLockPatternUtils.isLockScreenDisabled(
|
||||
KeyguardUpdateMonitor.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(KeyguardUpdateMonitor.getCurrentUser())) {
|
||||
doKeyguardLaterLocked();
|
||||
}
|
||||
}
|
||||
@@ -974,12 +978,13 @@ public class KeyguardViewMediator extends SystemUI {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mLockPatternUtils.isLockScreenDisabled() && !lockedOrMissing) {
|
||||
if (mLockPatternUtils.isLockScreenDisabled(KeyguardUpdateMonitor.getCurrentUser())
|
||||
&& !lockedOrMissing) {
|
||||
if (DEBUG) Log.d(TAG, "doKeyguard: not showing because lockscreen is off");
|
||||
return;
|
||||
}
|
||||
|
||||
if (mLockPatternUtils.checkVoldPassword()) {
|
||||
if (mLockPatternUtils.checkVoldPassword(KeyguardUpdateMonitor.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(KeyguardUpdateMonitor.getCurrentUser())
|
||||
|| KeyguardUpdateMonitor.getInstance(mContext).isSimPinSecure();
|
||||
}
|
||||
|
||||
@@ -1083,7 +1088,7 @@ public class KeyguardViewMediator extends SystemUI {
|
||||
* @param newUserId The id of the incoming user.
|
||||
*/
|
||||
public void setCurrentUser(int newUserId) {
|
||||
mLockPatternUtils.setCurrentUser(newUserId);
|
||||
KeyguardUpdateMonitor.setCurrentUser(newUserId);
|
||||
}
|
||||
|
||||
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
|
||||
@@ -1213,7 +1218,7 @@ public class KeyguardViewMediator extends SystemUI {
|
||||
private void sendUserPresentBroadcast() {
|
||||
synchronized (this) {
|
||||
if (mBootCompleted) {
|
||||
final UserHandle currentUser = new UserHandle(mLockPatternUtils.getCurrentUser());
|
||||
final UserHandle currentUser = new UserHandle(KeyguardUpdateMonitor.getCurrentUser());
|
||||
final UserManager um = (UserManager) mContext.getSystemService(
|
||||
Context.USER_SERVICE);
|
||||
List <UserInfo> userHandles = um.getProfiles(currentUser.getIdentifier());
|
||||
|
||||
@@ -87,6 +87,7 @@ import com.android.internal.statusbar.StatusBarIcon;
|
||||
import com.android.internal.statusbar.StatusBarIconList;
|
||||
import com.android.internal.util.NotificationColorUtil;
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.keyguard.KeyguardUpdateMonitor;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.RecentsComponent;
|
||||
import com.android.systemui.SwipeHelper;
|
||||
@@ -639,7 +640,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(KeyguardUpdateMonitor.getCurrentUser())) {
|
||||
Log.d(TAG, "insecure lockscreen, skipping notification");
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.SHOW_NOTE_ABOUT_NOTIFICATION_HIDING, 0);
|
||||
|
||||
@@ -233,9 +233,9 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
|
||||
private Intent getCameraIntent() {
|
||||
KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
|
||||
boolean currentUserHasTrust = updateMonitor.getUserHasTrust(
|
||||
mLockPatternUtils.getCurrentUser());
|
||||
return mLockPatternUtils.isSecure() && !currentUserHasTrust
|
||||
? SECURE_CAMERA_INTENT : INSECURE_CAMERA_INTENT;
|
||||
KeyguardUpdateMonitor.getCurrentUser());
|
||||
boolean secure = mLockPatternUtils.isSecure(KeyguardUpdateMonitor.getCurrentUser());
|
||||
return (secure && !currentUserHasTrust) ? SECURE_CAMERA_INTENT : INSECURE_CAMERA_INTENT;
|
||||
}
|
||||
|
||||
private void updateCameraVisibility() {
|
||||
@@ -245,7 +245,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
|
||||
}
|
||||
ResolveInfo resolved = mContext.getPackageManager().resolveActivityAsUser(getCameraIntent(),
|
||||
PackageManager.MATCH_DEFAULT_ONLY,
|
||||
mLockPatternUtils.getCurrentUser());
|
||||
KeyguardUpdateMonitor.getCurrentUser());
|
||||
boolean visible = !isCameraDisabledByDpm() && resolved != null
|
||||
&& getResources().getBoolean(R.bool.config_keyguardShowCameraAffordance);
|
||||
mCameraImageView.setVisibility(visible ? View.VISIBLE : View.GONE);
|
||||
@@ -339,13 +339,13 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
|
||||
0 /* velocityDp - N/A */);
|
||||
mIndicationController.showTransientIndication(
|
||||
R.string.keyguard_indication_trust_disabled);
|
||||
mLockPatternUtils.requireCredentialEntry(mLockPatternUtils.getCurrentUser());
|
||||
mLockPatternUtils.requireCredentialEntry(KeyguardUpdateMonitor.getCurrentUser());
|
||||
}
|
||||
|
||||
public void prewarmCamera() {
|
||||
Intent intent = getCameraIntent();
|
||||
String targetPackage = PreviewInflater.getTargetPackage(mContext, intent,
|
||||
mLockPatternUtils.getCurrentUser());
|
||||
KeyguardUpdateMonitor.getCurrentUser());
|
||||
if (targetPackage != null) {
|
||||
Intent prewarm = new Intent(MediaStore.ACTION_STILL_IMAGE_CAMERA_PREWARM);
|
||||
prewarm.setPackage(targetPackage);
|
||||
@@ -361,7 +361,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
|
||||
mPrewarmSent = false;
|
||||
Intent intent = getCameraIntent();
|
||||
String targetPackage = PreviewInflater.getTargetPackage(mContext, intent,
|
||||
mLockPatternUtils.getCurrentUser());
|
||||
KeyguardUpdateMonitor.getCurrentUser());
|
||||
if (targetPackage != null) {
|
||||
Intent prewarm = new Intent(MediaStore.ACTION_STILL_IMAGE_CAMERA_COOLDOWN);
|
||||
prewarm.setPackage(targetPackage);
|
||||
@@ -375,7 +375,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
|
||||
mPrewarmSent = false;
|
||||
final Intent intent = getCameraIntent();
|
||||
boolean wouldLaunchResolverActivity = PreviewInflater.wouldLaunchResolverActivity(
|
||||
mContext, intent, mLockPatternUtils.getCurrentUser());
|
||||
mContext, intent, KeyguardUpdateMonitor.getCurrentUser());
|
||||
if (intent == SECURE_CAMERA_INTENT && !wouldLaunchResolverActivity) {
|
||||
AsyncTask.execute(new Runnable() {
|
||||
@Override
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.provider.MediaStore;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.keyguard.KeyguardUpdateMonitor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -228,7 +229,7 @@ public class SecureCameraLaunchManager {
|
||||
|
||||
// Get the list of applications that can handle the intent.
|
||||
final List<ResolveInfo> appList = packageManager.queryIntentActivitiesAsUser(
|
||||
intent, PackageManager.MATCH_DEFAULT_ONLY, mLockPatternUtils.getCurrentUser());
|
||||
intent, PackageManager.MATCH_DEFAULT_ONLY, KeyguardUpdateMonitor.getCurrentUser());
|
||||
if (appList.size() == 0) {
|
||||
if (DEBUG) Log.d(TAG, "No targets found for secure camera intent");
|
||||
return false;
|
||||
@@ -237,7 +238,7 @@ public class SecureCameraLaunchManager {
|
||||
// Get the application that the intent resolves to.
|
||||
ResolveInfo resolved = packageManager.resolveActivityAsUser(intent,
|
||||
PackageManager.MATCH_DEFAULT_ONLY | PackageManager.GET_META_DATA,
|
||||
mLockPatternUtils.getCurrentUser());
|
||||
KeyguardUpdateMonitor.getCurrentUser());
|
||||
|
||||
if (resolved == null || resolved.activityInfo == null) {
|
||||
return false;
|
||||
|
||||
@@ -80,8 +80,8 @@ public class UnlockMethodCache {
|
||||
}
|
||||
|
||||
private void update(boolean updateAlways) {
|
||||
int user = mLockPatternUtils.getCurrentUser();
|
||||
boolean secure = mLockPatternUtils.isSecure();
|
||||
int user = KeyguardUpdateMonitor.getCurrentUser();
|
||||
boolean secure = mLockPatternUtils.isSecure(user);
|
||||
boolean currentlyInsecure = !secure || mKeyguardUpdateMonitor.getUserHasTrust(user);
|
||||
boolean trustManaged = mKeyguardUpdateMonitor.getUserTrustIsManaged(user);
|
||||
boolean faceUnlockRunning = mKeyguardUpdateMonitor.isFaceUnlockRunning(user)
|
||||
|
||||
@@ -26,6 +26,7 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.keyguard.KeyguardUpdateMonitor;
|
||||
import com.android.systemui.statusbar.phone.KeyguardPreviewContainer;
|
||||
|
||||
import java.util.List;
|
||||
@@ -80,13 +81,13 @@ public class PreviewInflater {
|
||||
WidgetInfo info = new WidgetInfo();
|
||||
PackageManager packageManager = mContext.getPackageManager();
|
||||
final List<ResolveInfo> appList = packageManager.queryIntentActivitiesAsUser(
|
||||
intent, PackageManager.MATCH_DEFAULT_ONLY, mLockPatternUtils.getCurrentUser());
|
||||
intent, PackageManager.MATCH_DEFAULT_ONLY, KeyguardUpdateMonitor.getCurrentUser());
|
||||
if (appList.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
ResolveInfo resolved = packageManager.resolveActivityAsUser(intent,
|
||||
PackageManager.MATCH_DEFAULT_ONLY | PackageManager.GET_META_DATA,
|
||||
mLockPatternUtils.getCurrentUser());
|
||||
KeyguardUpdateMonitor.getCurrentUser());
|
||||
if (wouldLaunchResolverActivity(resolved, appList)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -41,11 +41,13 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub {
|
||||
private volatile boolean mSimSecure;
|
||||
private volatile boolean mInputRestricted;
|
||||
|
||||
private int mCurrentUserId;
|
||||
|
||||
private final LockPatternUtils mLockPatternUtils;
|
||||
|
||||
public KeyguardStateMonitor(Context context, IKeyguardService service) {
|
||||
mLockPatternUtils = new LockPatternUtils(context);
|
||||
mLockPatternUtils.setCurrentUser(ActivityManager.getCurrentUser());
|
||||
mCurrentUserId = ActivityManager.getCurrentUser();
|
||||
try {
|
||||
service.addStateMonitorCallback(this);
|
||||
} catch (RemoteException e) {
|
||||
@@ -58,7 +60,7 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub {
|
||||
}
|
||||
|
||||
public boolean isSecure() {
|
||||
return mLockPatternUtils.isSecure() || mSimSecure;
|
||||
return mLockPatternUtils.isSecure(getCurrentUser()) || mSimSecure;
|
||||
}
|
||||
|
||||
public boolean isInputRestricted() {
|
||||
@@ -75,8 +77,12 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub {
|
||||
mSimSecure = simSecure;
|
||||
}
|
||||
|
||||
public void setCurrentUser(int userId) {
|
||||
mLockPatternUtils.setCurrentUser(userId);
|
||||
public synchronized void setCurrentUser(int userId) {
|
||||
mCurrentUserId = userId;
|
||||
}
|
||||
|
||||
private synchronized int getCurrentUser() {
|
||||
return mCurrentUserId;
|
||||
}
|
||||
|
||||
@Override // Binder interface
|
||||
|
||||
Reference in New Issue
Block a user