Merge "Update bouncer fingerprint lockout logic" into rvc-dev am: f7ef70e669 am: 6085e49a5a am: c4387c331f

Change-Id: I0c30f4ed65ac9b0a1b82e5911dc5d37c524b7e60
This commit is contained in:
Lucas Dupin
2020-04-07 17:20:35 +00:00
committed by Automerger Merge Worker
3 changed files with 34 additions and 2 deletions

View File

@@ -34,6 +34,7 @@ import com.android.internal.util.LatencyTracker;
import com.android.internal.widget.LockPatternChecker; import com.android.internal.widget.LockPatternChecker;
import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockscreenCredential; import com.android.internal.widget.LockscreenCredential;
import com.android.systemui.Dependency;
import com.android.systemui.R; import com.android.systemui.R;
/** /**
@@ -50,6 +51,7 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
private boolean mDismissing; private boolean mDismissing;
protected boolean mResumed; protected boolean mResumed;
private CountDownTimer mCountdownTimer = null; private CountDownTimer mCountdownTimer = null;
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
// To avoid accidental lockout due to events while the device in in the pocket, ignore // 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. // any passwords with length less than or equal to this length.
@@ -61,6 +63,7 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
public KeyguardAbsKeyInputView(Context context, AttributeSet attrs) { public KeyguardAbsKeyInputView(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
mKeyguardUpdateMonitor = Dependency.get(KeyguardUpdateMonitor.class);
} }
@Override @Override
@@ -151,6 +154,8 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
LatencyTracker.getInstance(mContext).onActionStart(ACTION_CHECK_CREDENTIAL); LatencyTracker.getInstance(mContext).onActionStart(ACTION_CHECK_CREDENTIAL);
LatencyTracker.getInstance(mContext).onActionStart(ACTION_CHECK_CREDENTIAL_UNLOCKED); LatencyTracker.getInstance(mContext).onActionStart(ACTION_CHECK_CREDENTIAL_UNLOCKED);
} }
mKeyguardUpdateMonitor.setCredentialAttempted();
mPendingLockCheck = LockPatternChecker.checkCredential( mPendingLockCheck = LockPatternChecker.checkCredential(
mLockPatternUtils, mLockPatternUtils,
password, password,

View File

@@ -282,6 +282,7 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
@Override @Override
public void onPatternDetected(final List<LockPatternView.Cell> pattern) { public void onPatternDetected(final List<LockPatternView.Cell> pattern) {
mKeyguardUpdateMonitor.setCredentialAttempted();
mLockPatternView.disableInput(); mLockPatternView.disableInput();
if (mPendingLockCheck != null) { if (mPendingLockCheck != null) {
mPendingLockCheck.cancel(false); mPendingLockCheck.cancel(false);

View File

@@ -223,6 +223,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
private int mRingMode; private int mRingMode;
private int mPhoneState; private int mPhoneState;
private boolean mKeyguardIsVisible; private boolean mKeyguardIsVisible;
private boolean mCredentialAttempted;
private boolean mKeyguardGoingAway; private boolean mKeyguardGoingAway;
private boolean mGoingToSleep; private boolean mGoingToSleep;
private boolean mBouncer; private boolean mBouncer;
@@ -497,12 +498,22 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
} }
} }
/**
* Updates KeyguardUpdateMonitor's internal state to know if credential was attempted on
* bouncer. Note that this does not care if the credential was correct/incorrect. This is
* cleared when the user leaves the bouncer (unlocked, screen off, back to lockscreen, etc)
*/
public void setCredentialAttempted() {
mCredentialAttempted = true;
updateBiometricListeningState();
}
/** /**
* Updates KeyguardUpdateMonitor's internal state to know if keyguard is goingAway * Updates KeyguardUpdateMonitor's internal state to know if keyguard is goingAway
*/ */
public void setKeyguardGoingAway(boolean goingAway) { public void setKeyguardGoingAway(boolean goingAway) {
mKeyguardGoingAway = goingAway; mKeyguardGoingAway = goingAway;
updateFingerprintListeningState(); updateBiometricListeningState();
} }
/** /**
@@ -664,6 +675,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
updateFingerprintListeningState(); updateFingerprintListeningState();
} else { } else {
setFingerprintRunningState(BIOMETRIC_STATE_STOPPED); setFingerprintRunningState(BIOMETRIC_STATE_STOPPED);
mFingerprintCancelSignal = null;
mFaceCancelSignal = null;
} }
if (msgId == FingerprintManager.FINGERPRINT_ERROR_HW_UNAVAILABLE) { if (msgId == FingerprintManager.FINGERPRINT_ERROR_HW_UNAVAILABLE) {
@@ -679,6 +692,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
getCurrentUser()); getCurrentUser());
} }
if (msgId == FingerprintManager.FINGERPRINT_ERROR_LOCKOUT
|| msgId == FingerprintManager.FINGERPRINT_ERROR_LOCKOUT_PERMANENT) {
mFingerprintLockedOut = true;
}
for (int i = 0; i < mCallbacks.size(); i++) { for (int i = 0; i < mCallbacks.size(); i++) {
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get(); KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
if (cb != null) { if (cb != null) {
@@ -688,6 +706,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
} }
private void handleFingerprintLockoutReset() { private void handleFingerprintLockoutReset() {
mFingerprintLockedOut = false;
updateFingerprintListeningState(); updateFingerprintListeningState();
} }
@@ -1274,6 +1293,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
private CancellationSignal mFaceCancelSignal; private CancellationSignal mFaceCancelSignal;
private FingerprintManager mFpm; private FingerprintManager mFpm;
private FaceManager mFaceManager; private FaceManager mFaceManager;
private boolean mFingerprintLockedOut;
/** /**
* When we receive a * When we receive a
@@ -1820,13 +1840,17 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
} }
private boolean shouldListenForFingerprint() { private boolean shouldListenForFingerprint() {
final boolean allowedOnBouncer =
!(mFingerprintLockedOut && mBouncer && mCredentialAttempted);
// Only listen if this KeyguardUpdateMonitor belongs to the primary user. There is an // Only listen if this KeyguardUpdateMonitor belongs to the primary user. There is an
// instance of KeyguardUpdateMonitor for each user but KeyguardUpdateMonitor is user-aware. // instance of KeyguardUpdateMonitor for each user but KeyguardUpdateMonitor is user-aware.
final boolean shouldListen = (mKeyguardIsVisible || !mDeviceInteractive || final boolean shouldListen = (mKeyguardIsVisible || !mDeviceInteractive ||
(mBouncer && !mKeyguardGoingAway) || mGoingToSleep || (mBouncer && !mKeyguardGoingAway) || mGoingToSleep ||
shouldListenForFingerprintAssistant() || (mKeyguardOccluded && mIsDreaming)) shouldListenForFingerprintAssistant() || (mKeyguardOccluded && mIsDreaming))
&& !mSwitchingUser && !isFingerprintDisabled(getCurrentUser()) && !mSwitchingUser && !isFingerprintDisabled(getCurrentUser())
&& (!mKeyguardGoingAway || !mDeviceInteractive) && mIsPrimaryUser; && (!mKeyguardGoingAway || !mDeviceInteractive) && mIsPrimaryUser
&& allowedOnBouncer;
return shouldListen; return shouldListen;
} }
@@ -2372,6 +2396,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
// camera requests dismiss keyguard (tapping on photos for example). When these happen, // camera requests dismiss keyguard (tapping on photos for example). When these happen,
// face auth should resume. // face auth should resume.
mSecureCameraLaunched = false; mSecureCameraLaunched = false;
} else {
mCredentialAttempted = false;
} }
for (int i = 0; i < mCallbacks.size(); i++) { for (int i = 0; i < mCallbacks.size(); i++) {