use of com.android.keyguard.KeyguardSecurityModel.SecurityMode in project android_frameworks_base by crdroidandroid.
the class KeyguardSecurityContainer method reportFailedUnlockAttempt.
private void reportFailedUnlockAttempt(int userId, int timeoutMs) {
final KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(mContext);
// +1 for this time
final int failedAttempts = monitor.getFailedUnlockAttempts(userId) + 1;
if (DEBUG)
Log.d(TAG, "reportFailedPatternAttempt: #" + failedAttempts);
SecurityMode mode = mSecurityModel.getSecurityMode();
final DevicePolicyManager dpm = mLockPatternUtils.getDevicePolicyManager();
final int failedAttemptsBeforeWipe = dpm.getMaximumFailedPasswordsForWipe(null, userId);
final int remainingBeforeWipe = failedAttemptsBeforeWipe > 0 ? (failedAttemptsBeforeWipe - failedAttempts) : // because DPM returns 0 if no restriction
Integer.MAX_VALUE;
final boolean usingPattern = mode == KeyguardSecurityModel.SecurityMode.Pattern;
final boolean usingPIN = mode == KeyguardSecurityModel.SecurityMode.PIN;
final boolean usingPassword = mode == KeyguardSecurityModel.SecurityMode.Password;
final int maxCountdownTimes = mContext.getResources().getInteger(R.integer.config_max_unlock_countdown_times);
final boolean enableTimesCounter = maxCountdownTimes > 0 && (usingPattern || usingPIN || usingPassword);
if (enableTimesCounter && (failedAttempts >= maxCountdownTimes)) {
showCountdownWipeDialog(failedAttempts);
} else if (remainingBeforeWipe < LockPatternUtils.FAILED_ATTEMPTS_BEFORE_WIPE_GRACE) {
// The user has installed a DevicePolicyManager that requests a user/profile to be wiped
// N attempts. Once we get below the grace period, we post this dialog every time as a
// clear warning until the deletion fires.
// Check which profile has the strictest policy for failed password attempts
final int expiringUser = dpm.getProfileWithMinimumFailedPasswordsForWipe(userId);
int userType = USER_TYPE_PRIMARY;
if (expiringUser == userId) {
// TODO: http://b/23522538
if (expiringUser != UserHandle.USER_SYSTEM) {
userType = USER_TYPE_SECONDARY_USER;
}
} else if (expiringUser != UserHandle.USER_NULL) {
userType = USER_TYPE_WORK_PROFILE;
}
// If USER_NULL, which shouldn't happen, leave it as USER_TYPE_PRIMARY
if (remainingBeforeWipe > 0) {
showAlmostAtWipeDialog(failedAttempts, remainingBeforeWipe, userType);
} else {
// Too many attempts. The device will be wiped shortly.
Slog.i(TAG, "Too many unlock attempts; user " + expiringUser + " will be wiped!");
showWipeDialog(failedAttempts, userType);
}
}
monitor.reportFailedStrongAuthUnlockAttempt(userId);
mLockPatternUtils.reportFailedPasswordAttempt(userId);
if (!enableTimesCounter && (timeoutMs > 0)) {
showTimeoutDialog(timeoutMs);
}
}
use of com.android.keyguard.KeyguardSecurityModel.SecurityMode in project android_frameworks_base by crdroidandroid.
the class KeyguardSecurityContainer method showPrimarySecurityScreen.
/**
* Shows the primary security screen for the user. This will be either the multi-selector
* or the user's security method.
* @param turningOff true if the device is being turned off
*/
void showPrimarySecurityScreen(boolean turningOff) {
SecurityMode securityMode = mSecurityModel.getSecurityMode();
if (DEBUG)
Log.v(TAG, "showPrimarySecurityScreen(turningOff=" + turningOff + ")");
showSecurityScreen(securityMode);
}
use of com.android.keyguard.KeyguardSecurityModel.SecurityMode in project android_frameworks_base by ResurrectionRemix.
the class KeyguardSecurityContainer method reportFailedUnlockAttempt.
private void reportFailedUnlockAttempt(int userId, int timeoutMs) {
final KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(mContext);
// +1 for this time
final int failedAttempts = monitor.getFailedUnlockAttempts(userId) + 1;
if (DEBUG)
Log.d(TAG, "reportFailedPatternAttempt: #" + failedAttempts);
SecurityMode mode = mSecurityModel.getSecurityMode();
final DevicePolicyManager dpm = mLockPatternUtils.getDevicePolicyManager();
final int failedAttemptsBeforeWipe = dpm.getMaximumFailedPasswordsForWipe(null, userId);
final int remainingBeforeWipe = failedAttemptsBeforeWipe > 0 ? (failedAttemptsBeforeWipe - failedAttempts) : // because DPM returns 0 if no restriction
Integer.MAX_VALUE;
final boolean usingPattern = mode == KeyguardSecurityModel.SecurityMode.Pattern;
final boolean usingPIN = mode == KeyguardSecurityModel.SecurityMode.PIN;
final boolean usingPassword = mode == KeyguardSecurityModel.SecurityMode.Password;
final int maxCountdownTimes = mContext.getResources().getInteger(R.integer.config_max_unlock_countdown_times);
final boolean enableTimesCounter = maxCountdownTimes > 0 && (usingPattern || usingPIN || usingPassword);
if (enableTimesCounter && (failedAttempts >= maxCountdownTimes)) {
showCountdownWipeDialog(failedAttempts);
} else if (remainingBeforeWipe < LockPatternUtils.FAILED_ATTEMPTS_BEFORE_WIPE_GRACE) {
// The user has installed a DevicePolicyManager that requests a user/profile to be wiped
// N attempts. Once we get below the grace period, we post this dialog every time as a
// clear warning until the deletion fires.
// Check which profile has the strictest policy for failed password attempts
final int expiringUser = dpm.getProfileWithMinimumFailedPasswordsForWipe(userId);
int userType = USER_TYPE_PRIMARY;
if (expiringUser == userId) {
// TODO: http://b/23522538
if (expiringUser != UserHandle.USER_SYSTEM) {
userType = USER_TYPE_SECONDARY_USER;
}
} else if (expiringUser != UserHandle.USER_NULL) {
userType = USER_TYPE_WORK_PROFILE;
}
// If USER_NULL, which shouldn't happen, leave it as USER_TYPE_PRIMARY
if (remainingBeforeWipe > 0) {
showAlmostAtWipeDialog(failedAttempts, remainingBeforeWipe, userType);
} else {
// Too many attempts. The device will be wiped shortly.
Slog.i(TAG, "Too many unlock attempts; user " + expiringUser + " will be wiped!");
showWipeDialog(failedAttempts, userType);
}
}
monitor.reportFailedStrongAuthUnlockAttempt(userId);
mLockPatternUtils.reportFailedPasswordAttempt(userId);
if (!enableTimesCounter && (timeoutMs > 0)) {
showTimeoutDialog(timeoutMs);
}
}
use of com.android.keyguard.KeyguardSecurityModel.SecurityMode in project android_frameworks_base by ResurrectionRemix.
the class KeyguardSecurityContainer method showPrimarySecurityScreen.
/**
* Shows the primary security screen for the user. This will be either the multi-selector
* or the user's security method.
* @param turningOff true if the device is being turned off
*/
void showPrimarySecurityScreen(boolean turningOff) {
SecurityMode securityMode = mSecurityModel.getSecurityMode();
if (DEBUG)
Log.v(TAG, "showPrimarySecurityScreen(turningOff=" + turningOff + ")");
showSecurityScreen(securityMode);
}
use of com.android.keyguard.KeyguardSecurityModel.SecurityMode in project android_frameworks_base by AOSPA.
the class KeyguardSecurityContainer method showPrimarySecurityScreen.
/**
* Shows the primary security screen for the user. This will be either the multi-selector
* or the user's security method.
* @param turningOff true if the device is being turned off
*/
void showPrimarySecurityScreen(boolean turningOff) {
SecurityMode securityMode = mSecurityModel.getSecurityMode();
if (DEBUG)
Log.v(TAG, "showPrimarySecurityScreen(turningOff=" + turningOff + ")");
showSecurityScreen(securityMode);
}
Aggregations