summaryrefslogtreecommitdiff
path: root/packages/Keyguard
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2016-11-29 16:41:06 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-11-29 16:41:10 +0000
commit26b4494808b043717fbc3663b081cb5b3ecc1183 (patch)
tree243734a3a4f646cb671b49622feedcba5aecedb9 /packages/Keyguard
parentb57bd791bf55215110839322ef7c0f72ed915a7b (diff)
parent5be868c590257f6cdccc19770051bf54552216df (diff)
Merge "Improve "Try again in 1 seconds" behavior in lockscreen"
Diffstat (limited to 'packages/Keyguard')
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java11
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java7
2 files changed, 13 insertions, 5 deletions
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java
index 94286ec6a785..5aa673b40124 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java
@@ -44,6 +44,7 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
protected View mEcaView;
protected boolean mEnableHaptics;
private boolean mDismissing;
+ private CountDownTimer mCountdownTimer = null;
// To avoid accidental lockout due to events while the device in in the pocket, ignore
// any passwords with length less than or equal to this length.
@@ -215,11 +216,13 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
protected void handleAttemptLockout(long elapsedRealtimeDeadline) {
setPasswordEntryEnabled(false);
long elapsedRealtime = SystemClock.elapsedRealtime();
- new CountDownTimer(elapsedRealtimeDeadline - elapsedRealtime, 1000) {
+ long secondsInFuture = (long) Math.ceil(
+ (elapsedRealtimeDeadline - elapsedRealtime) / 1000.0);
+ mCountdownTimer = new CountDownTimer(secondsInFuture * 1000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
- int secondsRemaining = (int) (millisUntilFinished / 1000);
+ int secondsRemaining = (int) Math.round(millisUntilFinished / 1000.0);
mSecurityMessageDisplay.formatMessage(
R.string.kg_too_many_failed_attempts_countdown, secondsRemaining);
}
@@ -252,6 +255,10 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
@Override
public void onPause() {
+ if (mCountdownTimer != null) {
+ mCountdownTimer.cancel();
+ mCountdownTimer = null;
+ }
if (mPendingLockCheck != null) {
mPendingLockCheck.cancel(false);
mPendingLockCheck = null;
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java
index 330632b701f1..c2b57ffa6113 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java
@@ -325,12 +325,13 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
mLockPatternView.clearPattern();
mLockPatternView.setEnabled(false);
final long elapsedRealtime = SystemClock.elapsedRealtime();
-
- mCountdownTimer = new CountDownTimer(elapsedRealtimeDeadline - elapsedRealtime, 1000) {
+ final long secondsInFuture = (long) Math.ceil(
+ (elapsedRealtimeDeadline - elapsedRealtime) / 1000.0);
+ mCountdownTimer = new CountDownTimer(secondsInFuture * 1000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
- final int secondsRemaining = (int) (millisUntilFinished / 1000);
+ final int secondsRemaining = (int) Math.round(millisUntilFinished / 1000.0);
mSecurityMessageDisplay.formatMessage(
R.string.kg_too_many_failed_attempts_countdown, secondsRemaining);
}