Fix PIN/password lock UI update when locked out.
The ConfirmLockPassword screen (responsible for both PIN and password locks) should not accept any input during the lock-out period after consecutive incorrect unlock attempts. However, this is broken if the activity is resumed from a paused state (e.g. from Recents). In this CL, we clean up the logic around updating the UI controls, which fixes the issue above and also hopefully simplifies potential future work. Bug: 63277910 Test: make RunSettingsRoboTests Test: manual, both unified and separate work challenge Change-Id: I752a5911d4445bf0caeea299ca3eb182e1defc62
This commit is contained in:
@@ -109,7 +109,6 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
|
||||
private boolean mUsingFingerprint = false;
|
||||
private AppearAnimationUtils mAppearAnimationUtils;
|
||||
private DisappearAnimationUtils mDisappearAnimationUtils;
|
||||
private boolean mBlockImm;
|
||||
|
||||
// required constructor for fragments
|
||||
public ConfirmLockPasswordFragment() {
|
||||
@@ -241,8 +240,8 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
|
||||
mDetailsTextView.setAlpha(0f);
|
||||
mCancelButton.setAlpha(0f);
|
||||
mPasswordEntry.setAlpha(0f);
|
||||
mErrorTextView.setAlpha(0f);
|
||||
mFingerprintIcon.setAlpha(0f);
|
||||
mBlockImm = true;
|
||||
}
|
||||
|
||||
private View[] getActiveViews() {
|
||||
@@ -253,6 +252,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
|
||||
result.add(mCancelButton);
|
||||
}
|
||||
result.add(mPasswordEntry);
|
||||
result.add(mErrorTextView);
|
||||
if (mFingerprintIcon.getVisibility() == View.VISIBLE) {
|
||||
result.add(mFingerprintIcon);
|
||||
}
|
||||
@@ -262,13 +262,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
|
||||
@Override
|
||||
public void startEnterAnimation() {
|
||||
super.startEnterAnimation();
|
||||
mAppearAnimationUtils.startAnimation(getActiveViews(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mBlockImm = false;
|
||||
resetState();
|
||||
}
|
||||
});
|
||||
mAppearAnimationUtils.startAnimation(getActiveViews(), this::updatePasswordEntry);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -294,7 +288,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
|
||||
mCredentialCheckResultTracker.clearResult();
|
||||
handleAttemptLockout(deadline);
|
||||
} else {
|
||||
resetState();
|
||||
updatePasswordEntry();
|
||||
mErrorTextView.setText("");
|
||||
updateErrorMessage(
|
||||
mLockPatternUtils.getCurrentFailedPasswordAttempts(mEffectiveUserId));
|
||||
@@ -312,36 +306,24 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
|
||||
mUsingFingerprint = visible;
|
||||
}
|
||||
|
||||
private void resetState() {
|
||||
if (mBlockImm) return;
|
||||
mPasswordEntry.setEnabled(true);
|
||||
mPasswordEntryInputDisabler.setInputEnabled(true);
|
||||
if (shouldAutoShowSoftKeyboard()) {
|
||||
private void updatePasswordEntry() {
|
||||
final boolean isLockedOut =
|
||||
mLockPatternUtils.getLockoutAttemptDeadline(mEffectiveUserId) != 0;
|
||||
mPasswordEntry.setEnabled(!isLockedOut);
|
||||
mPasswordEntryInputDisabler.setInputEnabled(!isLockedOut);
|
||||
if (isLockedOut || mUsingFingerprint) {
|
||||
mImm.hideSoftInputFromWindow(mPasswordEntry.getWindowToken(), 0 /*flags*/);
|
||||
} else {
|
||||
mPasswordEntry.scheduleShowSoftInput();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldAutoShowSoftKeyboard() {
|
||||
return mPasswordEntry.isEnabled() && !mUsingFingerprint;
|
||||
}
|
||||
|
||||
public void onWindowFocusChanged(boolean hasFocus) {
|
||||
if (!hasFocus || mBlockImm) {
|
||||
if (!hasFocus) {
|
||||
return;
|
||||
}
|
||||
// Post to let window focus logic to finish to allow soft input show/hide properly.
|
||||
mPasswordEntry.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (shouldAutoShowSoftKeyboard()) {
|
||||
resetState();
|
||||
return;
|
||||
}
|
||||
|
||||
mImm.hideSoftInputFromWindow(mPasswordEntry.getWindowToken(),
|
||||
InputMethodManager.HIDE_IMPLICIT_ONLY);
|
||||
}
|
||||
});
|
||||
mPasswordEntry.post(this::updatePasswordEntry);
|
||||
}
|
||||
|
||||
private void handleNext() {
|
||||
@@ -396,7 +378,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
|
||||
}
|
||||
}
|
||||
mCredentialCheckResultTracker.setResult(matched, intent, timeoutMs,
|
||||
localUserId);
|
||||
localEffectiveUserId);
|
||||
}
|
||||
};
|
||||
mPendingLockCheck = (localEffectiveUserId == localUserId)
|
||||
@@ -491,10 +473,8 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
|
||||
}
|
||||
|
||||
private void handleAttemptLockout(long elapsedRealtimeDeadline) {
|
||||
long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||
mPasswordEntry.setEnabled(false);
|
||||
mCountdownTimer = new CountDownTimer(
|
||||
elapsedRealtimeDeadline - elapsedRealtime,
|
||||
elapsedRealtimeDeadline - SystemClock.elapsedRealtime(),
|
||||
LockPatternUtils.FAILED_ATTEMPT_COUNTDOWN_INTERVAL_MS) {
|
||||
|
||||
@Override
|
||||
@@ -507,12 +487,13 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
resetState();
|
||||
updatePasswordEntry();
|
||||
mErrorTextView.setText("");
|
||||
updateErrorMessage(
|
||||
mLockPatternUtils.getCurrentFailedPasswordAttempts(mEffectiveUserId));
|
||||
}
|
||||
}.start();
|
||||
updatePasswordEntry();
|
||||
}
|
||||
|
||||
public void onClick(View v) {
|
||||
|
Reference in New Issue
Block a user