FP auth window starts with acquire
Test: atest FingerprintAuthenticationClientTest Fixes: 243421977 Change-Id: I67975ba1d0bd4dab09c36de676f6bfb8264828a7 Merged-In: I67975ba1d0bd4dab09c36de676f6bfb8264828a7
This commit is contained in:
committed by
Joshua Mccloskey
parent
20987e7f2b
commit
ae84de69b0
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.server.biometrics.sensors.fingerprint.aidl;
|
||||
|
||||
import static android.hardware.biometrics.BiometricFingerprintConstants.FINGERPRINT_ACQUIRED_START;
|
||||
import static android.hardware.biometrics.BiometricFingerprintConstants.FINGERPRINT_ACQUIRED_VENDOR;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
@@ -57,6 +58,7 @@ import com.android.server.biometrics.sensors.SensorOverlays;
|
||||
import com.android.server.biometrics.sensors.fingerprint.PowerPressHandler;
|
||||
import com.android.server.biometrics.sensors.fingerprint.Udfps;
|
||||
|
||||
import java.time.Clock;
|
||||
import java.util.ArrayList;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@@ -88,7 +90,9 @@ class FingerprintAuthenticationClient extends AuthenticationClient<AidlSession>
|
||||
private long mWaitForAuthKeyguard;
|
||||
private long mWaitForAuthBp;
|
||||
private long mIgnoreAuthFor;
|
||||
private long mSideFpsLastAcquireStartTime;
|
||||
private Runnable mAuthSuccessRunnable;
|
||||
private final Clock mClock;
|
||||
|
||||
FingerprintAuthenticationClient(
|
||||
@NonNull Context context,
|
||||
@@ -112,7 +116,8 @@ class FingerprintAuthenticationClient extends AuthenticationClient<AidlSession>
|
||||
@Nullable ISidefpsController sidefpsController,
|
||||
boolean allowBackgroundAuthentication,
|
||||
@NonNull FingerprintSensorPropertiesInternal sensorProps,
|
||||
@NonNull Handler handler) {
|
||||
@NonNull Handler handler,
|
||||
@NonNull Clock clock) {
|
||||
super(
|
||||
context,
|
||||
lazyDaemon,
|
||||
@@ -154,6 +159,8 @@ class FingerprintAuthenticationClient extends AuthenticationClient<AidlSession>
|
||||
mSkipWaitForPowerVendorAcquireMessage =
|
||||
context.getResources().getInteger(
|
||||
R.integer.config_sidefpsSkipWaitForPowerVendorAcquireMessage);
|
||||
mSideFpsLastAcquireStartTime = -1;
|
||||
mClock = clock;
|
||||
|
||||
if (mSensorProps.isAnySidefpsType()) {
|
||||
if (Build.isDebuggable()) {
|
||||
@@ -235,8 +242,14 @@ class FingerprintAuthenticationClient extends AuthenticationClient<AidlSession>
|
||||
return;
|
||||
}
|
||||
delay = isKeyguard() ? mWaitForAuthKeyguard : mWaitForAuthBp;
|
||||
Slog.i(TAG, "(sideFPS) Auth succeeded, sideFps waiting for power for: "
|
||||
+ delay + "ms");
|
||||
|
||||
if (mSideFpsLastAcquireStartTime != -1) {
|
||||
delay = Math.max(0,
|
||||
delay - (mClock.millis() - mSideFpsLastAcquireStartTime));
|
||||
}
|
||||
|
||||
Slog.i(TAG, "(sideFPS) Auth succeeded, sideFps "
|
||||
+ "waiting for power until: " + delay + "ms");
|
||||
}
|
||||
|
||||
if (mHandler.hasMessages(MESSAGE_FINGER_UP)) {
|
||||
@@ -260,6 +273,9 @@ class FingerprintAuthenticationClient extends AuthenticationClient<AidlSession>
|
||||
mSensorOverlays.ifUdfps(controller -> controller.onAcquired(getSensorId(), acquiredInfo));
|
||||
super.onAcquired(acquiredInfo, vendorCode);
|
||||
if (mSensorProps.isAnySidefpsType()) {
|
||||
if (acquiredInfo == FINGERPRINT_ACQUIRED_START) {
|
||||
mSideFpsLastAcquireStartTime = mClock.millis();
|
||||
}
|
||||
final boolean shouldLookForVendor =
|
||||
mSkipWaitForPowerAcquireMessage == FINGERPRINT_ACQUIRED_VENDOR;
|
||||
final boolean acquireMessageMatch = acquiredInfo == mSkipWaitForPowerAcquireMessage;
|
||||
|
||||
@@ -47,6 +47,7 @@ import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.SystemClock;
|
||||
import android.os.UserManager;
|
||||
import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
@@ -447,7 +448,8 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
|
||||
mBiometricContext, isStrongBiometric,
|
||||
mTaskStackListener, mSensors.get(sensorId).getLockoutCache(),
|
||||
mUdfpsOverlayController, mSidefpsController, allowBackgroundAuthentication,
|
||||
mSensors.get(sensorId).getSensorProperties(), mHandler);
|
||||
mSensors.get(sensorId).getSensorProperties(), mHandler,
|
||||
SystemClock.elapsedRealtimeClock());
|
||||
scheduleForSensor(sensorId, client, mBiometricStateCallback);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
|
||||
import java.time.Clock;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
@@ -128,6 +129,8 @@ public class FingerprintAuthenticationClientTest {
|
||||
private ICancellationSignal mCancellationSignal;
|
||||
@Mock
|
||||
private Probe mLuxProbe;
|
||||
@Mock
|
||||
private Clock mClock;
|
||||
@Captor
|
||||
private ArgumentCaptor<OperationContext> mOperationContextCaptor;
|
||||
@Captor
|
||||
@@ -516,6 +519,79 @@ public class FingerprintAuthenticationClientTest {
|
||||
verify(mCallback).onClientFinished(any(), eq(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sideFingerprintPowerWindowStartsOnAcquireStart() throws Exception {
|
||||
final int powerWindow = 500;
|
||||
final long authStart = 300;
|
||||
|
||||
when(mSensorProps.isAnySidefpsType()).thenReturn(true);
|
||||
mContext.getOrCreateTestableResources().addOverride(
|
||||
R.integer.config_sidefpsBpPowerPressWindow, powerWindow);
|
||||
|
||||
final FingerprintAuthenticationClient client = createClient(1);
|
||||
client.start(mCallback);
|
||||
|
||||
// Acquire start occurs at time = 0ms
|
||||
when(mClock.millis()).thenReturn(0L);
|
||||
client.onAcquired(FingerprintManager.FINGERPRINT_ACQUIRED_START, 0 /* vendorCode */);
|
||||
|
||||
// Auth occurs at time = 300
|
||||
when(mClock.millis()).thenReturn(authStart);
|
||||
// At this point the delay should be 500 - (300 - 0) == 200 milliseconds.
|
||||
client.onAuthenticated(new Fingerprint("friendly", 4 /* fingerId */, 5 /* deviceId */),
|
||||
true /* authenticated */, new ArrayList<>());
|
||||
mLooper.dispatchAll();
|
||||
verify(mCallback, never()).onClientFinished(any(), anyBoolean());
|
||||
|
||||
// After waiting 200 milliseconds, auth should succeed.
|
||||
mLooper.moveTimeForward(powerWindow - authStart);
|
||||
mLooper.dispatchAll();
|
||||
verify(mCallback).onClientFinished(any(), eq(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sideFingerprintPowerWindowStartsOnLastAcquireStart() throws Exception {
|
||||
final int powerWindow = 500;
|
||||
|
||||
when(mSensorProps.isAnySidefpsType()).thenReturn(true);
|
||||
mContext.getOrCreateTestableResources().addOverride(
|
||||
R.integer.config_sidefpsBpPowerPressWindow, powerWindow);
|
||||
|
||||
final FingerprintAuthenticationClient client = createClient(1);
|
||||
client.start(mCallback);
|
||||
// Acquire start occurs at time = 0ms
|
||||
when(mClock.millis()).thenReturn(0L);
|
||||
client.onAcquired(FingerprintManager.FINGERPRINT_ACQUIRED_START, 0 /* vendorCode */);
|
||||
|
||||
// Auth reject occurs at time = 300ms
|
||||
when(mClock.millis()).thenReturn(300L);
|
||||
client.onAuthenticated(new Fingerprint("friendly", 4 /* fingerId */, 5 /* deviceId */),
|
||||
false /* authenticated */, new ArrayList<>());
|
||||
mLooper.dispatchAll();
|
||||
|
||||
mLooper.moveTimeForward(300);
|
||||
mLooper.dispatchAll();
|
||||
verify(mCallback, never()).onClientFinished(any(), anyBoolean());
|
||||
|
||||
when(mClock.millis()).thenReturn(1300L);
|
||||
client.onAcquired(FingerprintManager.FINGERPRINT_ACQUIRED_START, 0 /* vendorCode */);
|
||||
|
||||
// If code is correct, the new acquired start timestamp should be used
|
||||
// and the code should only have to wait 500 - (1500-1300)ms.
|
||||
when(mClock.millis()).thenReturn(1500L);
|
||||
client.onAuthenticated(new Fingerprint("friendly", 4 /* fingerId */, 5 /* deviceId */),
|
||||
true /* authenticated */, new ArrayList<>());
|
||||
mLooper.dispatchAll();
|
||||
|
||||
mLooper.moveTimeForward(299);
|
||||
mLooper.dispatchAll();
|
||||
verify(mCallback, never()).onClientFinished(any(), anyBoolean());
|
||||
|
||||
mLooper.moveTimeForward(1);
|
||||
mLooper.dispatchAll();
|
||||
verify(mCallback).onClientFinished(any(), eq(true));
|
||||
}
|
||||
|
||||
private FingerprintAuthenticationClient createClient() throws RemoteException {
|
||||
return createClient(100 /* version */, true /* allowBackgroundAuthentication */);
|
||||
}
|
||||
@@ -543,7 +619,7 @@ public class FingerprintAuthenticationClientTest {
|
||||
null /* taskStackListener */, mLockoutCache,
|
||||
mUdfpsOverlayController, mSideFpsController, allowBackgroundAuthentication,
|
||||
mSensorProps,
|
||||
new Handler(mLooper.getLooper())) {
|
||||
new Handler(mLooper.getLooper()), mClock) {
|
||||
@Override
|
||||
protected ActivityTaskManager getActivityTaskManager() {
|
||||
return mActivityTaskManager;
|
||||
|
||||
Reference in New Issue
Block a user