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:
@@ -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,21 +186,29 @@ 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) {
|
|
||||||
if (mLockPatternView != null) {
|
|
||||||
mLockPatternView.clearPattern();
|
|
||||||
}
|
|
||||||
mCooldown = COOL_DOWN_INTERVAL;
|
|
||||||
cooldown();
|
|
||||||
} else {
|
} else {
|
||||||
final TextView status = (TextView) findViewById(R.id.status);
|
// Wrong entry. Handle pattern case.
|
||||||
status.setText(R.string.try_again);
|
|
||||||
// Reenable the password entry
|
|
||||||
if (mPasswordEntry != null) {
|
|
||||||
mPasswordEntry.setEnabled(true);
|
|
||||||
}
|
|
||||||
if (mLockPatternView != null) {
|
if (mLockPatternView != null) {
|
||||||
mLockPatternView.setEnabled(true);
|
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;
|
||||||
|
cooldown();
|
||||||
|
} else {
|
||||||
|
final TextView status = (TextView) findViewById(R.id.status);
|
||||||
|
status.setText(R.string.try_again);
|
||||||
|
if (mLockPatternView != null) {
|
||||||
|
mLockPatternView.setDisplayMode(DisplayMode.Wrong);
|
||||||
|
}
|
||||||
|
// Reenable the password entry
|
||||||
|
if (mPasswordEntry != null) {
|
||||||
|
mPasswordEntry.setEnabled(true);
|
||||||
|
}
|
||||||
|
if (mLockPatternView != null) {
|
||||||
|
mLockPatternView.setEnabled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -583,25 +602,26 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected LockPatternView.OnPatternListener mChooseNewLockPatternListener =
|
protected LockPatternView.OnPatternListener mChooseNewLockPatternListener =
|
||||||
new LockPatternView.OnPatternListener() {
|
new LockPatternView.OnPatternListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPatternStart() {
|
public void onPatternStart() {
|
||||||
}
|
mLockPatternView.removeCallbacks(mClearPatternRunnable);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPatternCleared() {
|
public void onPatternCleared() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPatternDetected(List<LockPatternView.Cell> pattern) {
|
public void onPatternDetected(List<LockPatternView.Cell> pattern) {
|
||||||
mLockPatternView.setEnabled(false);
|
mLockPatternView.setEnabled(false);
|
||||||
new DecryptTask().execute(LockPatternUtils.patternToString(pattern));
|
new DecryptTask().execute(LockPatternUtils.patternToString(pattern));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPatternCellAdded(List<Cell> pattern) {
|
public void onPatternCellAdded(List<Cell> pattern) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private void passwordEntryInit() {
|
private void passwordEntryInit() {
|
||||||
|
Reference in New Issue
Block a user