FP auth window starts with acquire
Test: atest FingerprintAuthenticationClientTest Fixes: 243421977 Change-Id: I67975ba1d0bd4dab09c36de676f6bfb8264828a7
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.server.biometrics.sensors.fingerprint.aidl;
|
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 static android.hardware.biometrics.BiometricFingerprintConstants.FINGERPRINT_ACQUIRED_VENDOR;
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
@@ -59,6 +60,7 @@ import com.android.server.biometrics.sensors.SensorOverlays;
|
|||||||
import com.android.server.biometrics.sensors.fingerprint.PowerPressHandler;
|
import com.android.server.biometrics.sensors.fingerprint.PowerPressHandler;
|
||||||
import com.android.server.biometrics.sensors.fingerprint.Udfps;
|
import com.android.server.biometrics.sensors.fingerprint.Udfps;
|
||||||
|
|
||||||
|
import java.time.Clock;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
@@ -92,7 +94,9 @@ class FingerprintAuthenticationClient extends AuthenticationClient<AidlSession>
|
|||||||
private long mWaitForAuthKeyguard;
|
private long mWaitForAuthKeyguard;
|
||||||
private long mWaitForAuthBp;
|
private long mWaitForAuthBp;
|
||||||
private long mIgnoreAuthFor;
|
private long mIgnoreAuthFor;
|
||||||
|
private long mSideFpsLastAcquireStartTime;
|
||||||
private Runnable mAuthSuccessRunnable;
|
private Runnable mAuthSuccessRunnable;
|
||||||
|
private final Clock mClock;
|
||||||
|
|
||||||
FingerprintAuthenticationClient(
|
FingerprintAuthenticationClient(
|
||||||
@NonNull Context context,
|
@NonNull Context context,
|
||||||
@@ -117,7 +121,8 @@ class FingerprintAuthenticationClient extends AuthenticationClient<AidlSession>
|
|||||||
boolean allowBackgroundAuthentication,
|
boolean allowBackgroundAuthentication,
|
||||||
@NonNull FingerprintSensorPropertiesInternal sensorProps,
|
@NonNull FingerprintSensorPropertiesInternal sensorProps,
|
||||||
@NonNull Handler handler,
|
@NonNull Handler handler,
|
||||||
@Authenticators.Types int biometricStrength) {
|
@Authenticators.Types int biometricStrength,
|
||||||
|
@NonNull Clock clock) {
|
||||||
super(
|
super(
|
||||||
context,
|
context,
|
||||||
lazyDaemon,
|
lazyDaemon,
|
||||||
@@ -161,6 +166,8 @@ class FingerprintAuthenticationClient extends AuthenticationClient<AidlSession>
|
|||||||
R.integer.config_sidefpsSkipWaitForPowerVendorAcquireMessage);
|
R.integer.config_sidefpsSkipWaitForPowerVendorAcquireMessage);
|
||||||
mBiometricStrength = biometricStrength;
|
mBiometricStrength = biometricStrength;
|
||||||
mAuthSessionCoordinator = biometricContext.getAuthSessionCoordinator();
|
mAuthSessionCoordinator = biometricContext.getAuthSessionCoordinator();
|
||||||
|
mSideFpsLastAcquireStartTime = -1;
|
||||||
|
mClock = clock;
|
||||||
|
|
||||||
if (mSensorProps.isAnySidefpsType()) {
|
if (mSensorProps.isAnySidefpsType()) {
|
||||||
if (Build.isDebuggable()) {
|
if (Build.isDebuggable()) {
|
||||||
@@ -246,8 +253,14 @@ class FingerprintAuthenticationClient extends AuthenticationClient<AidlSession>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
delay = isKeyguard() ? mWaitForAuthKeyguard : mWaitForAuthBp;
|
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)) {
|
if (mHandler.hasMessages(MESSAGE_FINGER_UP)) {
|
||||||
@@ -271,6 +284,9 @@ class FingerprintAuthenticationClient extends AuthenticationClient<AidlSession>
|
|||||||
mSensorOverlays.ifUdfps(controller -> controller.onAcquired(getSensorId(), acquiredInfo));
|
mSensorOverlays.ifUdfps(controller -> controller.onAcquired(getSensorId(), acquiredInfo));
|
||||||
super.onAcquired(acquiredInfo, vendorCode);
|
super.onAcquired(acquiredInfo, vendorCode);
|
||||||
if (mSensorProps.isAnySidefpsType()) {
|
if (mSensorProps.isAnySidefpsType()) {
|
||||||
|
if (acquiredInfo == FINGERPRINT_ACQUIRED_START) {
|
||||||
|
mSideFpsLastAcquireStartTime = mClock.millis();
|
||||||
|
}
|
||||||
final boolean shouldLookForVendor =
|
final boolean shouldLookForVendor =
|
||||||
mSkipWaitForPowerAcquireMessage == FINGERPRINT_ACQUIRED_VENDOR;
|
mSkipWaitForPowerAcquireMessage == FINGERPRINT_ACQUIRED_VENDOR;
|
||||||
final boolean acquireMessageMatch = acquiredInfo == mSkipWaitForPowerAcquireMessage;
|
final boolean acquireMessageMatch = acquiredInfo == mSkipWaitForPowerAcquireMessage;
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ import android.os.IBinder;
|
|||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
|
import android.os.SystemClock;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
@@ -449,7 +450,8 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
|
|||||||
mTaskStackListener, mSensors.get(sensorId).getLockoutCache(),
|
mTaskStackListener, mSensors.get(sensorId).getLockoutCache(),
|
||||||
mUdfpsOverlayController, mSidefpsController, allowBackgroundAuthentication,
|
mUdfpsOverlayController, mSidefpsController, allowBackgroundAuthentication,
|
||||||
mSensors.get(sensorId).getSensorProperties(), mHandler,
|
mSensors.get(sensorId).getSensorProperties(), mHandler,
|
||||||
Utils.getCurrentStrength(sensorId));
|
Utils.getCurrentStrength(sensorId),
|
||||||
|
SystemClock.elapsedRealtimeClock());
|
||||||
scheduleForSensor(sensorId, client, mBiometricStateCallback);
|
scheduleForSensor(sensorId, client, mBiometricStateCallback);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ import org.mockito.Mock;
|
|||||||
import org.mockito.junit.MockitoJUnit;
|
import org.mockito.junit.MockitoJUnit;
|
||||||
import org.mockito.junit.MockitoRule;
|
import org.mockito.junit.MockitoRule;
|
||||||
|
|
||||||
|
import java.time.Clock;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@@ -132,6 +133,8 @@ public class FingerprintAuthenticationClientTest {
|
|||||||
private Probe mLuxProbe;
|
private Probe mLuxProbe;
|
||||||
@Mock
|
@Mock
|
||||||
private AuthSessionCoordinator mAuthSessionCoordinator;
|
private AuthSessionCoordinator mAuthSessionCoordinator;
|
||||||
|
@Mock
|
||||||
|
private Clock mClock;
|
||||||
@Captor
|
@Captor
|
||||||
private ArgumentCaptor<OperationContext> mOperationContextCaptor;
|
private ArgumentCaptor<OperationContext> mOperationContextCaptor;
|
||||||
@Captor
|
@Captor
|
||||||
@@ -544,6 +547,79 @@ public class FingerprintAuthenticationClientTest {
|
|||||||
verify(mCallback).onClientFinished(any(), eq(true));
|
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 {
|
private FingerprintAuthenticationClient createClient() throws RemoteException {
|
||||||
return createClient(100 /* version */, true /* allowBackgroundAuthentication */);
|
return createClient(100 /* version */, true /* allowBackgroundAuthentication */);
|
||||||
}
|
}
|
||||||
@@ -571,7 +647,7 @@ public class FingerprintAuthenticationClientTest {
|
|||||||
null /* taskStackListener */, mLockoutCache,
|
null /* taskStackListener */, mLockoutCache,
|
||||||
mUdfpsOverlayController, mSideFpsController, allowBackgroundAuthentication,
|
mUdfpsOverlayController, mSideFpsController, allowBackgroundAuthentication,
|
||||||
mSensorProps,
|
mSensorProps,
|
||||||
new Handler(mLooper.getLooper()), 0 /* biometricStrength */) {
|
new Handler(mLooper.getLooper()), 0 /* biometricStrength */, mClock) {
|
||||||
@Override
|
@Override
|
||||||
protected ActivityTaskManager getActivityTaskManager() {
|
protected ActivityTaskManager getActivityTaskManager() {
|
||||||
return mActivityTaskManager;
|
return mActivityTaskManager;
|
||||||
|
|||||||
Reference in New Issue
Block a user