public class LockPatternUtils extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
LockPatternUtils.CheckCredentialProgressCallback
Callback to be notified about progress when checking credentials.
|
static class |
LockPatternUtils.RequestThrottledException |
static class |
LockPatternUtils.StrongAuthTracker
Tracks the global strong authentication state.
|
Modifier and Type | Field and Description |
---|---|
static String |
BIOMETRIC_WEAK_EVER_CHOSEN_KEY
Deprecated.
|
static String |
DISABLE_LOCKSCREEN_KEY |
static long |
FAILED_ATTEMPT_COUNTDOWN_INTERVAL_MS
The interval of the countdown for showing progress of the lockout.
|
static int |
FAILED_ATTEMPTS_BEFORE_RESET
The number of incorrect attempts before which we fall back on an alternative
method of verifying the user, and resetting their lock pattern.
|
static int |
FAILED_ATTEMPTS_BEFORE_WIPE_GRACE
This dictates when we start telling the user that continued failed attempts will wipe
their device.
|
static String |
LEGACY_LOCK_PATTERN_ENABLED
The key to identify when the lock pattern enabled flag is being acccessed for legacy reasons.
|
static String |
LOCK_PASSWORD_SALT_KEY |
static String |
LOCKOUT_ATTEMPT_DEADLINE |
static String |
LOCKOUT_ATTEMPT_TIMEOUT_MS |
static String |
LOCKOUT_PERMANENT_KEY
Deprecated.
|
static String |
LOCKSCREEN_BIOMETRIC_WEAK_FALLBACK
Deprecated.
|
static String |
LOCKSCREEN_OPTIONS |
static String |
LOCKSCREEN_POWER_BUTTON_INSTANTLY_LOCKS |
static String |
LOCKSCREEN_WIDGETS_ENABLED
Deprecated.
|
static int |
MAX_ALLOWED_SEQUENCE |
static int |
MIN_LOCK_PASSWORD_SIZE
The minimum size of a valid password.
|
static int |
MIN_LOCK_PATTERN_SIZE
The minimum number of dots in a valid pattern.
|
static int |
MIN_PATTERN_REGISTER_FAIL
The minimum number of dots the user must include in a wrong pattern
attempt for it to be counted against the counts that affect
#FAILED_ATTEMPTS_BEFORE_TIMEOUT and FAILED_ATTEMPTS_BEFORE_RESET |
static String |
PASSWORD_HISTORY_KEY |
static String |
PASSWORD_TYPE_ALTERNATE_KEY
Deprecated.
|
static String |
PASSWORD_TYPE_KEY |
static String |
PATTERN_EVER_CHOSEN_KEY |
static String |
PROFILE_KEY_NAME_DECRYPT |
static String |
PROFILE_KEY_NAME_ENCRYPT |
Constructor and Description |
---|
LockPatternUtils(Context context) |
Modifier and Type | Method and Description |
---|---|
boolean |
checkPassword(String password,
int userId)
Check to see if a password matches the saved password.
|
boolean |
checkPassword(String password,
int userId,
LockPatternUtils.CheckCredentialProgressCallback progressCallback)
Check to see if a password matches the saved password.
|
boolean |
checkPasswordHistory(String password,
int userId)
Check to see if a password matches any of the passwords stored in the
password history.
|
boolean |
checkPattern(List<LockPatternView.Cell> pattern,
int userId)
Check to see if a pattern matches the saved pattern.
|
boolean |
checkPattern(List<LockPatternView.Cell> pattern,
int userId,
LockPatternUtils.CheckCredentialProgressCallback progressCallback)
Check to see if a pattern matches the saved pattern.
|
boolean |
checkVoldPassword(int userId)
Check to see if vold already has the password.
|
void |
clearEncryptionPassword()
Clears the encryption password.
|
void |
clearLock(int userHandle)
Clear any lock pattern or password.
|
static int |
computePasswordQuality(String password)
Compute the password quality from the given password string.
|
int |
getActivePasswordQuality(int userId)
Used by device policy manager to validate the current password
information it has.
|
int |
getCurrentFailedPasswordAttempts(int userId) |
String |
getDeviceOwnerInfo() |
DevicePolicyManager |
getDevicePolicyManager() |
List<ComponentName> |
getEnabledTrustAgents(int userId) |
int |
getKeyguardStoredPasswordQuality(int userHandle)
Retrieves the quality mode for .
|
long |
getLockoutAttemptDeadline(int userId) |
int |
getMaximumFailedPasswordsForWipe(int userId) |
String |
getOwnerInfo(int userId) |
boolean |
getPowerButtonInstantlyLocks(int userId) |
int |
getRequestedMinimumPasswordLength(int userId) |
int |
getRequestedPasswordMinimumLetters(int userId) |
int |
getRequestedPasswordMinimumLowerCase(int userId) |
int |
getRequestedPasswordMinimumNonLetter(int userId) |
int |
getRequestedPasswordMinimumNumeric(int userId) |
int |
getRequestedPasswordMinimumSymbols(int userId) |
int |
getRequestedPasswordMinimumUpperCase(int userId) |
int |
getRequestedPasswordQuality(int userId)
Gets the device policy password mode.
|
int |
getStrongAuthForUser(int userId) |
boolean |
isCredentialRequiredToDecrypt(boolean defaultValue) |
static boolean |
isDeviceEncryptionEnabled()
Determine if the device supports encryption, even if it's set to default.
|
boolean |
isDeviceOwnerInfoEnabled() |
static boolean |
isFileEncryptionEnabled()
Determine if the device is file encrypted
|
boolean |
isFingerprintAllowedForUser(int userId) |
boolean |
isLegacyLockPatternEnabled(int userId)
Deprecated.
|
boolean |
isLockPasswordEnabled(int userId) |
boolean |
isLockPatternEnabled(int userId) |
boolean |
isLockScreenDisabled(int userId)
Determine if LockScreen is disabled for the current user.
|
boolean |
isOwnerInfoEnabled(int userId) |
boolean |
isPatternEverChosen(int userId)
Return true if the user has ever chosen a pattern.
|
boolean |
isSecure(int userId) |
boolean |
isSeparateProfileChallengeAllowed(int userHandle)
Retrieves whether the current DPM allows use of the Profile Challenge.
|
boolean |
isSeparateProfileChallengeAllowedToUnify(int userHandle)
Retrieves whether the current profile and device locks can be unified.
|
boolean |
isSeparateProfileChallengeEnabled(int userHandle)
Retrieves whether the Separate Profile Challenge is enabled for this .
|
boolean |
isTactileFeedbackEnabled() |
boolean |
isTrustAllowedForUser(int userId) |
boolean |
isTrustUsuallyManaged(int userId)
|
boolean |
isVisiblePatternEnabled(int userId) |
static int |
maxLengthSequence(String string) |
byte[] |
passwordToHash(String password,
int userId) |
static String |
patternStringToBaseZero(String pattern) |
static byte[] |
patternToHash(List<LockPatternView.Cell> pattern) |
static String |
patternToString(List<LockPatternView.Cell> pattern)
Serialize a pattern.
|
void |
registerStrongAuthTracker(LockPatternUtils.StrongAuthTracker strongAuthTracker) |
void |
reportFailedPasswordAttempt(int userId) |
void |
reportSuccessfulPasswordAttempt(int userId) |
void |
requireCredentialEntry(int userId)
Disable trust until credentials have been entered for user .
|
void |
requireStrongAuth(int strongAuthReason,
int userId)
Requests strong authentication for user .
|
void |
resetKeyStore(int userId)
Use it to reset keystore without wiping work profile
|
void |
saveLockPassword(String password,
String savedPassword,
int quality,
int userHandle)
Save a lock password.
|
void |
saveLockPattern(List<LockPatternView.Cell> pattern,
int userId)
Save a lock pattern.
|
void |
saveLockPattern(List<LockPatternView.Cell> pattern,
String savedPattern,
int userId)
Save a lock pattern.
|
void |
setCredentialRequiredToDecrypt(boolean required) |
void |
setDeviceOwnerInfo(String info)
Sets the device owner information.
|
void |
setEnabledTrustAgents(Collection<ComponentName> activeTrustAgents,
int userId) |
void |
setLegacyLockPatternEnabled(int userId)
Deprecated.
|
long |
setLockoutAttemptDeadline(int userId,
int timeoutMs)
Set and store the lockout deadline, meaning the user can't attempt his/her unlock
pattern until the deadline has passed.
|
void |
setLockScreenDisabled(boolean disable,
int userId)
Disable showing lock screen at all for a given user.
|
void |
setOwnerInfo(String info,
int userId) |
void |
setOwnerInfoEnabled(boolean enabled,
int userId) |
void |
setPowerButtonInstantlyLocks(boolean enabled,
int userId) |
void |
setSeparateProfileChallengeEnabled(int userHandle,
boolean enabled,
String managedUserPassword)
Enables/disables the Separate Profile Challenge for this .
|
void |
setTrustUsuallyManaged(boolean managed,
int userId) |
void |
setVisiblePasswordEnabled(boolean enabled,
int userId)
Set whether the visible password is enabled for cryptkeeper screen.
|
void |
setVisiblePatternEnabled(boolean enabled,
int userId)
Set whether the visible pattern is enabled.
|
static List<LockPatternView.Cell> |
stringToPattern(String string)
Deserialize a pattern.
|
void |
unregisterStrongAuthTracker(LockPatternUtils.StrongAuthTracker strongAuthTracker) |
void |
userPresent(int userId) |
byte[] |
verifyPassword(String password,
long challenge,
int userId)
Check to see if a password matches the saved password.
|
byte[] |
verifyPattern(List<LockPatternView.Cell> pattern,
long challenge,
int userId)
Check to see if a pattern matches the saved pattern.
|
byte[] |
verifyTiedProfileChallenge(String password,
boolean isPattern,
long challenge,
int userId)
Check to see if a password matches the saved password.
|
public static final String LEGACY_LOCK_PATTERN_ENABLED
public static final int FAILED_ATTEMPTS_BEFORE_RESET
public static final long FAILED_ATTEMPT_COUNTDOWN_INTERVAL_MS
public static final int FAILED_ATTEMPTS_BEFORE_WIPE_GRACE
public static final int MIN_LOCK_PATTERN_SIZE
public static final int MIN_LOCK_PASSWORD_SIZE
public static final int MIN_PATTERN_REGISTER_FAIL
#FAILED_ATTEMPTS_BEFORE_TIMEOUT
and FAILED_ATTEMPTS_BEFORE_RESET
@Deprecated public static final String LOCKOUT_PERMANENT_KEY
public static final String LOCKOUT_ATTEMPT_DEADLINE
public static final String LOCKOUT_ATTEMPT_TIMEOUT_MS
public static final String PATTERN_EVER_CHOSEN_KEY
public static final String PASSWORD_TYPE_KEY
@Deprecated public static final String PASSWORD_TYPE_ALTERNATE_KEY
public static final String LOCK_PASSWORD_SALT_KEY
public static final String DISABLE_LOCKSCREEN_KEY
public static final String LOCKSCREEN_OPTIONS
@Deprecated public static final String LOCKSCREEN_BIOMETRIC_WEAK_FALLBACK
@Deprecated public static final String BIOMETRIC_WEAK_EVER_CHOSEN_KEY
public static final String LOCKSCREEN_POWER_BUTTON_INSTANTLY_LOCKS
@Deprecated public static final String LOCKSCREEN_WIDGETS_ENABLED
public static final String PASSWORD_HISTORY_KEY
public static final int MAX_ALLOWED_SEQUENCE
public static final String PROFILE_KEY_NAME_ENCRYPT
public static final String PROFILE_KEY_NAME_DECRYPT
public LockPatternUtils(Context context)
public boolean isTrustUsuallyManaged(int userId)
TrustManager.isTrustUsuallyManaged(int)
.
This returns the lazily-peristed value and should only be used by TrustManagerService.public void setTrustUsuallyManaged(boolean managed, int userId)
public void userPresent(int userId)
public DevicePolicyManager getDevicePolicyManager()
public int getRequestedMinimumPasswordLength(int userId)
public int getRequestedPasswordQuality(int userId)
public int getRequestedPasswordMinimumLetters(int userId)
public int getRequestedPasswordMinimumUpperCase(int userId)
public int getRequestedPasswordMinimumLowerCase(int userId)
public int getRequestedPasswordMinimumNumeric(int userId)
public int getRequestedPasswordMinimumSymbols(int userId)
public int getRequestedPasswordMinimumNonLetter(int userId)
public void reportFailedPasswordAttempt(int userId)
public void reportSuccessfulPasswordAttempt(int userId)
public int getCurrentFailedPasswordAttempts(int userId)
public int getMaximumFailedPasswordsForWipe(int userId)
public byte[] verifyPattern(List<LockPatternView.Cell> pattern, long challenge, int userId) throws LockPatternUtils.RequestThrottledException
pattern
- The pattern to check.challenge
- The challenge to verify against the patternLockPatternUtils.RequestThrottledException
public boolean checkPattern(List<LockPatternView.Cell> pattern, int userId) throws LockPatternUtils.RequestThrottledException
pattern
- The pattern to check.LockPatternUtils.RequestThrottledException
public boolean checkPattern(List<LockPatternView.Cell> pattern, int userId, LockPatternUtils.CheckCredentialProgressCallback progressCallback) throws LockPatternUtils.RequestThrottledException
pattern
- The pattern to check.LockPatternUtils.RequestThrottledException
public byte[] verifyPassword(String password, long challenge, int userId) throws LockPatternUtils.RequestThrottledException
password
- The password to check.challenge
- The challenge to verify against the passwordLockPatternUtils.RequestThrottledException
public byte[] verifyTiedProfileChallenge(String password, boolean isPattern, long challenge, int userId) throws LockPatternUtils.RequestThrottledException
password
- The password to check.challenge
- The challenge to verify against the passwordLockPatternUtils.RequestThrottledException
public boolean checkPassword(String password, int userId) throws LockPatternUtils.RequestThrottledException
password
- The password to check.LockPatternUtils.RequestThrottledException
public boolean checkPassword(String password, int userId, LockPatternUtils.CheckCredentialProgressCallback progressCallback) throws LockPatternUtils.RequestThrottledException
password
- The password to check.LockPatternUtils.RequestThrottledException
public boolean checkVoldPassword(int userId)
public boolean checkPasswordHistory(String password, int userId)
password
- The password to check.public boolean isPatternEverChosen(int userId)
public int getActivePasswordQuality(int userId)
public void resetKeyStore(int userId)
public void clearLock(int userHandle)
public void setLockScreenDisabled(boolean disable, int userId)
disable
- Disables lock screen when trueuserId
- User ID of the user this has effect onpublic boolean isLockScreenDisabled(int userId)
public void saveLockPattern(List<LockPatternView.Cell> pattern, int userId)
pattern
- The new pattern to save.userId
- the user whose pattern is to be saved.public void saveLockPattern(List<LockPatternView.Cell> pattern, String savedPattern, int userId)
pattern
- The new pattern to save.savedPattern
- The previously saved pattern, converted to String formatuserId
- the user whose pattern is to be saved.public void setOwnerInfo(String info, int userId)
public void setOwnerInfoEnabled(boolean enabled, int userId)
public String getOwnerInfo(int userId)
public boolean isOwnerInfoEnabled(int userId)
public void setDeviceOwnerInfo(String info)
null
or empty then the
device owner info is cleared.info
- Device owner information which will be displayed instead of the user
owner info.public String getDeviceOwnerInfo()
public boolean isDeviceOwnerInfoEnabled()
public static int computePasswordQuality(String password)
public static int maxLengthSequence(String string)
public void saveLockPassword(String password, String savedPassword, int quality, int userHandle)
password
- The password to savesavedPassword
- The previously saved lock password, or null if nonequality
- DevicePolicyManager.getPasswordQuality(android.content.ComponentName)
userHandle
- The userId of the user to change the password forpublic static boolean isDeviceEncryptionEnabled()
public static boolean isFileEncryptionEnabled()
public void clearEncryptionPassword()
public int getKeyguardStoredPasswordQuality(int userHandle)
DevicePolicyManager.getPasswordQuality(android.content.ComponentName)
public void setSeparateProfileChallengeEnabled(int userHandle, boolean enabled, String managedUserPassword)
userHandle
- Managed profile user idenabled
- True if separate challenge is enabledmanagedUserPassword
- Managed profile previous password. Null when is
truepublic boolean isSeparateProfileChallengeEnabled(int userHandle)
public boolean isSeparateProfileChallengeAllowed(int userHandle)
public boolean isSeparateProfileChallengeAllowedToUnify(int userHandle)
public static List<LockPatternView.Cell> stringToPattern(String string)
string
- The pattern serialized with patternToString(java.util.List<com.android.internal.widget.LockPatternView.Cell>)
public static String patternToString(List<LockPatternView.Cell> pattern)
pattern
- The pattern.public static byte[] patternToHash(List<LockPatternView.Cell> pattern)
public byte[] passwordToHash(String password, int userId)
public boolean isSecure(int userId)
userId
- the user for which to report the valuepublic boolean isLockPasswordEnabled(int userId)
public boolean isLockPatternEnabled(int userId)
@Deprecated public boolean isLegacyLockPatternEnabled(int userId)
@Deprecated public void setLegacyLockPatternEnabled(int userId)
public boolean isVisiblePatternEnabled(int userId)
public void setVisiblePatternEnabled(boolean enabled, int userId)
public void setVisiblePasswordEnabled(boolean enabled, int userId)
public boolean isTactileFeedbackEnabled()
public long setLockoutAttemptDeadline(int userId, int timeoutMs)
public long getLockoutAttemptDeadline(int userId)
public void setPowerButtonInstantlyLocks(boolean enabled, int userId)
public boolean getPowerButtonInstantlyLocks(int userId)
public void setEnabledTrustAgents(Collection<ComponentName> activeTrustAgents, int userId)
public List<ComponentName> getEnabledTrustAgents(int userId)
public void requireCredentialEntry(int userId)
android.Manifest.permission#ACCESS_KEYGUARD_SECURE_STORAGE
permission.userId
- either an explicit user id or UserHandle.USER_ALL
public void requireStrongAuth(int strongAuthReason, int userId)
android.Manifest.permission#ACCESS_KEYGUARD_SECURE_STORAGE
permission.strongAuthReason
- a combination of LockPatternUtils.StrongAuthTracker.StrongAuthFlags
indicating
the reason for and the strength of the requested authentication.userId
- either an explicit user id or UserHandle.USER_ALL
public boolean isCredentialRequiredToDecrypt(boolean defaultValue)
public void setCredentialRequiredToDecrypt(boolean required)
public void registerStrongAuthTracker(LockPatternUtils.StrongAuthTracker strongAuthTracker)
public void unregisterStrongAuthTracker(LockPatternUtils.StrongAuthTracker strongAuthTracker)
public int getStrongAuthForUser(int userId)
public boolean isTrustAllowedForUser(int userId)
public boolean isFingerprintAllowedForUser(int userId)