Merge "Increase power-press timeout" into tm-qpr-dev

This commit is contained in:
TreeHugger Robot
2022-12-08 08:56:02 +00:00
committed by Android (Google) Code Review
3 changed files with 27 additions and 9 deletions

View File

@@ -397,6 +397,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
private static final int HAL_ERROR_RETRY_TIMEOUT = 500; // ms private static final int HAL_ERROR_RETRY_TIMEOUT = 500; // ms
private static final int HAL_ERROR_RETRY_MAX = 20; private static final int HAL_ERROR_RETRY_MAX = 20;
@VisibleForTesting
protected static final int HAL_POWER_PRESS_TIMEOUT = 50; // ms
@VisibleForTesting @VisibleForTesting
protected final Runnable mFpCancelNotReceived = this::onFingerprintCancelNotReceived; protected final Runnable mFpCancelNotReceived = this::onFingerprintCancelNotReceived;
@@ -918,7 +921,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
} }
} }
private final Runnable mRetryFingerprintAuthentication = new Runnable() { private final Runnable mRetryFingerprintAuthenticationAfterHwUnavailable = new Runnable() {
@SuppressLint("MissingPermission") @SuppressLint("MissingPermission")
@Override @Override
public void run() { public void run() {
@@ -927,7 +930,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
updateFingerprintListeningState(BIOMETRIC_ACTION_UPDATE); updateFingerprintListeningState(BIOMETRIC_ACTION_UPDATE);
} else if (mHardwareFingerprintUnavailableRetryCount < HAL_ERROR_RETRY_MAX) { } else if (mHardwareFingerprintUnavailableRetryCount < HAL_ERROR_RETRY_MAX) {
mHardwareFingerprintUnavailableRetryCount++; mHardwareFingerprintUnavailableRetryCount++;
mHandler.postDelayed(mRetryFingerprintAuthentication, HAL_ERROR_RETRY_TIMEOUT); mHandler.postDelayed(mRetryFingerprintAuthenticationAfterHwUnavailable,
HAL_ERROR_RETRY_TIMEOUT);
} }
} }
}; };
@@ -957,12 +961,16 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
if (msgId == FingerprintManager.FINGERPRINT_ERROR_HW_UNAVAILABLE) { if (msgId == FingerprintManager.FINGERPRINT_ERROR_HW_UNAVAILABLE) {
mLogger.logRetryAfterFpErrorWithDelay(msgId, errString, HAL_ERROR_RETRY_TIMEOUT); mLogger.logRetryAfterFpErrorWithDelay(msgId, errString, HAL_ERROR_RETRY_TIMEOUT);
mHandler.postDelayed(mRetryFingerprintAuthentication, HAL_ERROR_RETRY_TIMEOUT); mHandler.postDelayed(mRetryFingerprintAuthenticationAfterHwUnavailable,
HAL_ERROR_RETRY_TIMEOUT);
} }
if (msgId == FingerprintManager.BIOMETRIC_ERROR_POWER_PRESSED) { if (msgId == FingerprintManager.BIOMETRIC_ERROR_POWER_PRESSED) {
mLogger.logRetryAfterFpErrorWithDelay(msgId, errString, 0); mLogger.logRetryAfterFpErrorWithDelay(msgId, errString, HAL_POWER_PRESS_TIMEOUT);
updateFingerprintListeningState(BIOMETRIC_ACTION_START); mHandler.postDelayed(() -> {
mLogger.d("Retrying fingerprint listening after power pressed error.");
updateFingerprintListeningState(BIOMETRIC_ACTION_START);
}, HAL_POWER_PRESS_TIMEOUT);
} }
boolean lockedOutStateChanged = false; boolean lockedOutStateChanged = false;

View File

@@ -231,7 +231,7 @@ class KeyguardUpdateMonitorLogger @Inject constructor(
int2 = delay int2 = delay
str1 = "$errString" str1 = "$errString"
}, { }, {
"Fingerprint retrying auth after $int2 ms due to($int1) -> $str1" "Fingerprint scheduling retry auth after $int2 ms due to($int1) -> $str1"
}) })
} }

View File

@@ -30,6 +30,7 @@ import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STR
import static com.android.keyguard.FaceAuthApiRequestReason.NOTIFICATION_PANEL_CLICKED; import static com.android.keyguard.FaceAuthApiRequestReason.NOTIFICATION_PANEL_CLICKED;
import static com.android.keyguard.KeyguardUpdateMonitor.BIOMETRIC_STATE_CANCELLING_RESTARTING; import static com.android.keyguard.KeyguardUpdateMonitor.BIOMETRIC_STATE_CANCELLING_RESTARTING;
import static com.android.keyguard.KeyguardUpdateMonitor.DEFAULT_CANCEL_SIGNAL_TIMEOUT; import static com.android.keyguard.KeyguardUpdateMonitor.DEFAULT_CANCEL_SIGNAL_TIMEOUT;
import static com.android.keyguard.KeyguardUpdateMonitor.HAL_POWER_PRESS_TIMEOUT;
import static com.android.keyguard.KeyguardUpdateMonitor.getCurrentUser; import static com.android.keyguard.KeyguardUpdateMonitor.getCurrentUser;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
@@ -855,12 +856,21 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
} }
@Test @Test
public void testFingerprintPowerPressed_restartsFingerprintListeningStateImmediately() { public void testFingerprintPowerPressed_restartsFingerprintListeningStateWithDelay() {
mKeyguardUpdateMonitor.mFingerprintAuthenticationCallback mKeyguardUpdateMonitor.mFingerprintAuthenticationCallback
.onAuthenticationError(FingerprintManager.BIOMETRIC_ERROR_POWER_PRESSED, ""); .onAuthenticationError(FingerprintManager.BIOMETRIC_ERROR_POWER_PRESSED, "");
verify(mFingerprintManager).authenticate(any(), any(), any(), any(), anyInt(), anyInt(), // THEN doesn't authenticate immediately
anyInt()); verify(mFingerprintManager, never()).authenticate(any(),
any(), any(), any(), anyInt(), anyInt(), anyInt());
// WHEN all messages (with delays) are processed
mTestableLooper.moveTimeForward(HAL_POWER_PRESS_TIMEOUT);
mTestableLooper.processAllMessages();
// THEN fingerprint manager attempts to authenticate again
verify(mFingerprintManager).authenticate(any(),
any(), any(), any(), anyInt(), anyInt(), anyInt());
} }
@Test @Test