Remove crypto pattern after two seconds

Currently pattern is left on after a failed attempt. This change removes
it after a timeout.

Change-Id: I77830510b17396f6e64a482816f6041af0fdc166
This commit is contained in:
Paul Lawrence
2014-06-12 08:26:08 -07:00
parent c91d4d9341
commit f6cda3b176

View File

@@ -65,6 +65,8 @@ import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockPatternView; import com.android.internal.widget.LockPatternView;
import com.android.internal.widget.LockPatternView.Cell; import com.android.internal.widget.LockPatternView.Cell;
import static com.android.internal.widget.LockPatternView.DisplayMode;
import java.util.List; import java.util.List;
/** /**
@@ -123,6 +125,15 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
/** Number of calls to {@link #notifyUser()} before we release the wakelock */ /** Number of calls to {@link #notifyUser()} before we release the wakelock */
private int mReleaseWakeLockCountdown = 0; private int mReleaseWakeLockCountdown = 0;
// how long we wait to clear a wrong pattern
private static final int WRONG_PATTERN_CLEAR_TIMEOUT_MS = 1500;
private Runnable mClearPatternRunnable = new Runnable() {
public void run() {
mLockPatternView.clearPattern();
}
};
/** /**
* Used to propagate state through configuration changes (e.g. screen rotation) * Used to propagate state through configuration changes (e.g. screen rotation)
*/ */
@@ -175,15 +186,22 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
} else if (failedAttempts == MAX_FAILED_ATTEMPTS) { } else if (failedAttempts == MAX_FAILED_ATTEMPTS) {
// Factory reset the device. // Factory reset the device.
sendBroadcast(new Intent("android.intent.action.MASTER_CLEAR")); sendBroadcast(new Intent("android.intent.action.MASTER_CLEAR"));
} else if ((failedAttempts % COOL_DOWN_ATTEMPTS) == 0) { } else {
// Wrong entry. Handle pattern case.
if (mLockPatternView != null) { if (mLockPatternView != null) {
mLockPatternView.clearPattern(); mLockPatternView.setDisplayMode(DisplayMode.Wrong);
mLockPatternView.removeCallbacks(mClearPatternRunnable);
mLockPatternView.postDelayed(mClearPatternRunnable, WRONG_PATTERN_CLEAR_TIMEOUT_MS);
} }
if ((failedAttempts % COOL_DOWN_ATTEMPTS) == 0) {
mCooldown = COOL_DOWN_INTERVAL; mCooldown = COOL_DOWN_INTERVAL;
cooldown(); cooldown();
} else { } else {
final TextView status = (TextView) findViewById(R.id.status); final TextView status = (TextView) findViewById(R.id.status);
status.setText(R.string.try_again); status.setText(R.string.try_again);
if (mLockPatternView != null) {
mLockPatternView.setDisplayMode(DisplayMode.Wrong);
}
// Reenable the password entry // Reenable the password entry
if (mPasswordEntry != null) { if (mPasswordEntry != null) {
mPasswordEntry.setEnabled(true); mPasswordEntry.setEnabled(true);
@@ -194,6 +212,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
} }
} }
} }
}
private class ValidationTask extends AsyncTask<Void, Void, Boolean> { private class ValidationTask extends AsyncTask<Void, Void, Boolean> {
@Override @Override
@@ -587,6 +606,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
@Override @Override
public void onPatternStart() { public void onPatternStart() {
mLockPatternView.removeCallbacks(mClearPatternRunnable);
} }
@Override @Override