[LockSettings] pipe through HW throttle timeout
Bug: 21118563 Change-Id: I23f5af2ebef9dac981281fb04c055a02f3b159b8
This commit is contained in:
@@ -41,6 +41,7 @@ import android.text.Selection;
|
|||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -61,6 +62,8 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
public static final String PASSWORD_MIN_SYMBOLS_KEY = "lockscreen.password_min_symbols";
|
public static final String PASSWORD_MIN_SYMBOLS_KEY = "lockscreen.password_min_symbols";
|
||||||
public static final String PASSWORD_MIN_NONLETTER_KEY = "lockscreen.password_min_nonletter";
|
public static final String PASSWORD_MIN_NONLETTER_KEY = "lockscreen.password_min_nonletter";
|
||||||
|
|
||||||
|
private static final String TAG = "ChooseLockPassword";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Intent getIntent() {
|
public Intent getIntent() {
|
||||||
Intent modIntent = new Intent(super.getIntent());
|
Intent modIntent = new Intent(super.getIntent());
|
||||||
@@ -533,7 +536,11 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
UserHandle.myUserId(),
|
UserHandle.myUserId(),
|
||||||
new LockPatternChecker.OnVerifyCallback() {
|
new LockPatternChecker.OnVerifyCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onVerified(byte[] token) {
|
public void onVerified(byte[] token, int timeoutMs) {
|
||||||
|
if (token == null) {
|
||||||
|
Log.e(TAG, "critical: no token returned from known good password");
|
||||||
|
}
|
||||||
|
|
||||||
mPasswordEntryInputDisabler.setInputEnabled(true);
|
mPasswordEntryInputDisabler.setInputEnabled(true);
|
||||||
setNextEnabled(true);
|
setNextEnabled(true);
|
||||||
mPendingLockCheck = null;
|
mPendingLockCheck = null;
|
||||||
|
@@ -34,6 +34,7 @@ import android.content.Intent;
|
|||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -64,6 +65,8 @@ public class ChooseLockPattern extends SettingsActivity {
|
|||||||
*/
|
*/
|
||||||
static final int RESULT_FINISHED = RESULT_FIRST_USER;
|
static final int RESULT_FINISHED = RESULT_FIRST_USER;
|
||||||
|
|
||||||
|
private static final String TAG = "ChooseLockPattern";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Intent getIntent() {
|
public Intent getIntent() {
|
||||||
Intent modIntent = new Intent(super.getIntent());
|
Intent modIntent = new Intent(super.getIntent());
|
||||||
@@ -663,7 +666,11 @@ public class ChooseLockPattern extends SettingsActivity {
|
|||||||
UserHandle.myUserId(),
|
UserHandle.myUserId(),
|
||||||
new LockPatternChecker.OnVerifyCallback() {
|
new LockPatternChecker.OnVerifyCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onVerified(byte[] token) {
|
public void onVerified(byte[] token, int timeoutMs) {
|
||||||
|
if (token == null) {
|
||||||
|
Log.e(TAG, "critical: no token returned for known good pattern");
|
||||||
|
}
|
||||||
|
|
||||||
mLockPatternView.enableInput();
|
mLockPatternView.enableInput();
|
||||||
mPendingLockCheck = null;
|
mPendingLockCheck = null;
|
||||||
|
|
||||||
|
@@ -248,7 +248,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
onPasswordChecked(false, intent);
|
onPasswordChecked(false, intent, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isInternalActivity() {
|
private boolean isInternalActivity() {
|
||||||
@@ -265,7 +265,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
|
|||||||
UserHandle.myUserId(),
|
UserHandle.myUserId(),
|
||||||
new LockPatternChecker.OnVerifyCallback() {
|
new LockPatternChecker.OnVerifyCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onVerified(byte[] token) {
|
public void onVerified(byte[] token, int timeoutMs) {
|
||||||
mPendingLockCheck = null;
|
mPendingLockCheck = null;
|
||||||
boolean matched = false;
|
boolean matched = false;
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
@@ -274,7 +274,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
|
|||||||
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN,
|
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN,
|
||||||
token);
|
token);
|
||||||
}
|
}
|
||||||
onPasswordChecked(matched, intent);
|
onPasswordChecked(matched, intent, timeoutMs);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -286,7 +286,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
|
|||||||
UserHandle.myUserId(),
|
UserHandle.myUserId(),
|
||||||
new LockPatternChecker.OnCheckCallback() {
|
new LockPatternChecker.OnCheckCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onChecked(boolean matched) {
|
public void onChecked(boolean matched, int timeoutMs) {
|
||||||
mPendingLockCheck = null;
|
mPendingLockCheck = null;
|
||||||
if (matched && isInternalActivity()) {
|
if (matched && isInternalActivity()) {
|
||||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_TYPE,
|
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_TYPE,
|
||||||
@@ -295,20 +295,20 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
|
|||||||
intent.putExtra(
|
intent.putExtra(
|
||||||
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, pin);
|
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, pin);
|
||||||
}
|
}
|
||||||
onPasswordChecked(matched, intent);
|
onPasswordChecked(matched, intent, timeoutMs);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onPasswordChecked(boolean matched, Intent intent) {
|
private void onPasswordChecked(boolean matched, Intent intent, int timeoutMs) {
|
||||||
mPasswordEntryInputDisabler.setInputEnabled(true);
|
mPasswordEntryInputDisabler.setInputEnabled(true);
|
||||||
if (matched) {
|
if (matched) {
|
||||||
getActivity().setResult(RESULT_OK, intent);
|
getActivity().setResult(RESULT_OK, intent);
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
} else {
|
} else {
|
||||||
if (++mNumWrongConfirmAttempts >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) {
|
if (timeoutMs > 0) {
|
||||||
long deadline = mLockPatternUtils.setLockoutAttemptDeadline(
|
long deadline = mLockPatternUtils.setLockoutAttemptDeadline(
|
||||||
UserHandle.myUserId());
|
UserHandle.myUserId(), timeoutMs);
|
||||||
handleAttemptLockout(deadline);
|
handleAttemptLockout(deadline);
|
||||||
} else {
|
} else {
|
||||||
showError(getErrorMessage());
|
showError(getErrorMessage());
|
||||||
|
@@ -295,7 +295,7 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
onPatternChecked(pattern, false, intent);
|
onPatternChecked(pattern, false, intent, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isInternalActivity() {
|
private boolean isInternalActivity() {
|
||||||
@@ -313,7 +313,7 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
|
|||||||
UserHandle.myUserId(),
|
UserHandle.myUserId(),
|
||||||
new LockPatternChecker.OnVerifyCallback() {
|
new LockPatternChecker.OnVerifyCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onVerified(byte[] token) {
|
public void onVerified(byte[] token, int timeoutMs) {
|
||||||
mPendingLockCheck = null;
|
mPendingLockCheck = null;
|
||||||
boolean matched = false;
|
boolean matched = false;
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
@@ -322,20 +322,25 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
|
|||||||
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN,
|
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN,
|
||||||
token);
|
token);
|
||||||
}
|
}
|
||||||
onPatternChecked(pattern, matched, intent);
|
onPatternChecked(pattern, matched, intent, timeoutMs);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startCheckPattern(final List<LockPatternView.Cell> pattern,
|
private void startCheckPattern(final List<LockPatternView.Cell> pattern,
|
||||||
final Intent intent) {
|
final Intent intent) {
|
||||||
|
if (pattern.size() <= LockPatternUtils.MIN_PATTERN_REGISTER_FAIL) {
|
||||||
|
onPatternChecked(pattern, false, intent, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
mPendingLockCheck = LockPatternChecker.checkPattern(
|
mPendingLockCheck = LockPatternChecker.checkPattern(
|
||||||
mLockPatternUtils,
|
mLockPatternUtils,
|
||||||
pattern,
|
pattern,
|
||||||
UserHandle.myUserId(),
|
UserHandle.myUserId(),
|
||||||
new LockPatternChecker.OnCheckCallback() {
|
new LockPatternChecker.OnCheckCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onChecked(boolean matched) {
|
public void onChecked(boolean matched, int timeoutMs) {
|
||||||
mPendingLockCheck = null;
|
mPendingLockCheck = null;
|
||||||
if (matched && isInternalActivity()) {
|
if (matched && isInternalActivity()) {
|
||||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_TYPE,
|
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_TYPE,
|
||||||
@@ -343,24 +348,21 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
|
|||||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD,
|
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD,
|
||||||
LockPatternUtils.patternToString(pattern));
|
LockPatternUtils.patternToString(pattern));
|
||||||
}
|
}
|
||||||
onPatternChecked(pattern, matched, intent);
|
onPatternChecked(pattern, matched, intent, timeoutMs);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onPatternChecked(List<LockPatternView.Cell> pattern,
|
private void onPatternChecked(List<LockPatternView.Cell> pattern,
|
||||||
boolean matched,
|
boolean matched, Intent intent, int timeoutMs) {
|
||||||
Intent intent) {
|
|
||||||
mLockPatternView.setEnabled(true);
|
mLockPatternView.setEnabled(true);
|
||||||
if (matched) {
|
if (matched) {
|
||||||
getActivity().setResult(Activity.RESULT_OK, intent);
|
getActivity().setResult(Activity.RESULT_OK, intent);
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
} else {
|
} else {
|
||||||
if (pattern.size() >= LockPatternUtils.MIN_PATTERN_REGISTER_FAIL &&
|
if (timeoutMs > 0) {
|
||||||
++mNumWrongConfirmAttempts
|
|
||||||
>= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) {
|
|
||||||
long deadline = mLockPatternUtils.setLockoutAttemptDeadline(
|
long deadline = mLockPatternUtils.setLockoutAttemptDeadline(
|
||||||
UserHandle.myUserId());
|
UserHandle.myUserId(), timeoutMs);
|
||||||
handleAttemptLockout(deadline);
|
handleAttemptLockout(deadline);
|
||||||
} else {
|
} else {
|
||||||
updateStage(Stage.NeedToUnlockWrong);
|
updateStage(Stage.NeedToUnlockWrong);
|
||||||
|
Reference in New Issue
Block a user