Add tests for the FingerprintManager path in UdfpsController

Bug: 218388821
Test: atest UdfpsControllerTest
Change-Id: I0de372b2897231ee2832a07d660e233f4ed9fd05
This commit is contained in:
Ilya Matyukhin
2022-11-08 07:12:25 +00:00
parent 58de71a4a9
commit 2e38249906

View File

@@ -114,10 +114,8 @@ public class UdfpsControllerTest extends SysuiTestCase {
@Rule
public MockitoRule rule = MockitoJUnit.rule();
// Unit under test
private UdfpsController mUdfpsController;
// Dependencies
private FakeExecutor mBiometricsExecutor;
@Mock
@@ -171,7 +169,6 @@ public class UdfpsControllerTest extends SysuiTestCase {
private UdfpsDisplayMode mUdfpsDisplayMode;
@Mock
private FeatureFlags mFeatureFlags;
// Stuff for configuring mocks
@Mock
private UdfpsView mUdfpsView;
@@ -249,54 +246,42 @@ public class UdfpsControllerTest extends SysuiTestCase {
FingerprintSensorProperties.TYPE_UDFPS_ULTRASONIC,
true /* resetLockoutRequiresHardwareAuthToken */);
List<FingerprintSensorPropertiesInternal> props = new ArrayList<>();
props.add(mOpticalProps);
props.add(mUltrasonicProps);
when(mFingerprintManager.getSensorPropertiesInternal()).thenReturn(props);
mFgExecutor = new FakeExecutor(new FakeSystemClock());
// Create a fake background executor.
mBiometricsExecutor = new FakeExecutor(new FakeSystemClock());
mUdfpsController = new UdfpsController(
mContext,
execution,
mLayoutInflater,
mFingerprintManager,
mWindowManager,
mStatusBarStateController,
mFgExecutor,
new ShadeExpansionStateManager(),
mStatusBarKeyguardViewManager,
mDumpManager,
mKeyguardUpdateMonitor,
mFeatureFlags,
mFalsingManager,
mPowerManager,
mAccessibilityManager,
mLockscreenShadeTransitionController,
mScreenLifecycle,
mVibrator,
mUdfpsHapticsSimulator,
mUdfpsShell,
mKeyguardStateController,
mDisplayManager,
mHandler,
mConfigurationController,
mSystemClock,
mUnlockedScreenOffAnimationController,
mSystemUIDialogManager,
mLatencyTracker,
mActivityLaunchAnimator,
Optional.of(mAlternateTouchProvider),
mBiometricsExecutor,
initUdfpsController(true /* hasAlternateTouchProvider */);
}
private void initUdfpsController(boolean hasAlternateTouchProvider) {
initUdfpsController(mOpticalProps, hasAlternateTouchProvider);
}
private void initUdfpsController(FingerprintSensorPropertiesInternal sensorProps,
boolean hasAlternateTouchProvider) {
reset(mFingerprintManager);
reset(mScreenLifecycle);
final Optional<AlternateUdfpsTouchProvider> alternateTouchProvider =
hasAlternateTouchProvider ? Optional.of(mAlternateTouchProvider) : Optional.empty();
mUdfpsController = new UdfpsController(mContext, new FakeExecution(), mLayoutInflater,
mFingerprintManager, mWindowManager, mStatusBarStateController, mFgExecutor,
new ShadeExpansionStateManager(), mStatusBarKeyguardViewManager, mDumpManager,
mKeyguardUpdateMonitor, mFeatureFlags, mFalsingManager, mPowerManager,
mAccessibilityManager, mLockscreenShadeTransitionController, mScreenLifecycle,
mVibrator, mUdfpsHapticsSimulator, mUdfpsShell, mKeyguardStateController,
mDisplayManager, mHandler, mConfigurationController, mSystemClock,
mUnlockedScreenOffAnimationController, mSystemUIDialogManager, mLatencyTracker,
mActivityLaunchAnimator, alternateTouchProvider, mBiometricsExecutor,
mPrimaryBouncerInteractor);
verify(mFingerprintManager).setUdfpsOverlayController(mOverlayCaptor.capture());
mOverlayController = mOverlayCaptor.getValue();
verify(mScreenLifecycle).addObserver(mScreenObserverCaptor.capture());
mScreenObserver = mScreenObserverCaptor.getValue();
mUdfpsController.updateOverlayParams(mOpticalProps, new UdfpsOverlayParams());
mUdfpsController.updateOverlayParams(sensorProps, new UdfpsOverlayParams());
mUdfpsController.setUdfpsDisplayMode(mUdfpsDisplayMode);
}
@@ -333,8 +318,7 @@ public class UdfpsControllerTest extends SysuiTestCase {
}
@Test
public void onActionMoveTouch_whenCanDismissLockScreen_entersDevice()
throws RemoteException {
public void onActionMoveTouch_whenCanDismissLockScreen_entersDevice() throws RemoteException {
onActionMoveTouch_whenCanDismissLockScreen_entersDevice(false /* stale */);
}
@@ -521,8 +505,37 @@ public class UdfpsControllerTest extends SysuiTestCase {
new MotionEvent.PointerCoords[]{pc}, 0, 0, 1f, 1f, 0, 0, 0, 0);
}
private static class TestParams {
public final FingerprintSensorPropertiesInternal sensorProps;
public final boolean hasAlternateTouchProvider;
TestParams(FingerprintSensorPropertiesInternal sensorProps,
boolean hasAlternateTouchProvider) {
this.sensorProps = sensorProps;
this.hasAlternateTouchProvider = hasAlternateTouchProvider;
}
}
private void runWithAllParams(ThrowingConsumer<TestParams> testParamsConsumer) {
for (FingerprintSensorPropertiesInternal sensorProps : List.of(mOpticalProps,
mUltrasonicProps)) {
for (boolean hasAlternateTouchProvider : new boolean[]{false, true}) {
initUdfpsController(sensorProps, hasAlternateTouchProvider);
testParamsConsumer.accept(new TestParams(sensorProps, hasAlternateTouchProvider));
}
}
}
@Test
public void onTouch_propagatesTouchInNativeOrientationAndResolution() throws RemoteException {
public void onTouch_propagatesTouchInNativeOrientationAndResolution() {
runWithAllParams(
this::onTouch_propagatesTouchInNativeOrientationAndResolutionParameterized);
}
private void onTouch_propagatesTouchInNativeOrientationAndResolutionParameterized(
TestParams testParams) throws RemoteException {
reset(mUdfpsView);
final Rect sensorBounds = new Rect(1000, 1900, 1080, 1920); // Bottom right corner.
final int displayWidth = 1080;
final int displayHeight = 1920;
@@ -541,13 +554,13 @@ public class UdfpsControllerTest extends SysuiTestCase {
when(mUdfpsView.isWithinSensorArea(anyFloat(), anyFloat())).thenReturn(true);
// Show the overlay.
mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, mOpticalProps.sensorId,
mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, testParams.sensorProps.sensorId,
BiometricOverlayConstants.REASON_ENROLL_ENROLLING, mUdfpsOverlayControllerCallback);
mFgExecutor.runAllReady();
verify(mUdfpsView).setOnTouchListener(mTouchListenerCaptor.capture());
// Test ROTATION_0
mUdfpsController.updateOverlayParams(mOpticalProps,
mUdfpsController.updateOverlayParams(testParams.sensorProps,
new UdfpsOverlayParams(sensorBounds, sensorBounds, displayWidth, displayHeight,
scaleFactor, Surface.ROTATION_0));
MotionEvent event = obtainMotionEvent(ACTION_DOWN, displayWidth, displayHeight, touchMinor,
@@ -559,12 +572,19 @@ public class UdfpsControllerTest extends SysuiTestCase {
mTouchListenerCaptor.getValue().onTouch(mUdfpsView, event);
mBiometricsExecutor.runAllReady();
event.recycle();
verify(mAlternateTouchProvider).onPointerDown(eq(TEST_REQUEST_ID), eq(expectedX),
eq(expectedY), eq(expectedMinor), eq(expectedMajor));
if (testParams.hasAlternateTouchProvider) {
verify(mAlternateTouchProvider).onPointerDown(eq(TEST_REQUEST_ID), eq(expectedX),
eq(expectedY), eq(expectedMinor), eq(expectedMajor));
} else {
verify(mFingerprintManager).onPointerDown(eq(TEST_REQUEST_ID),
eq(testParams.sensorProps.sensorId), eq(expectedX), eq(expectedY),
eq(expectedMinor), eq(expectedMajor));
}
// Test ROTATION_90
reset(mAlternateTouchProvider);
mUdfpsController.updateOverlayParams(mOpticalProps,
reset(mFingerprintManager);
mUdfpsController.updateOverlayParams(testParams.sensorProps,
new UdfpsOverlayParams(sensorBounds, sensorBounds, displayWidth, displayHeight,
scaleFactor, Surface.ROTATION_90));
event = obtainMotionEvent(ACTION_DOWN, displayHeight, 0, touchMinor, touchMajor);
@@ -575,12 +595,19 @@ public class UdfpsControllerTest extends SysuiTestCase {
mTouchListenerCaptor.getValue().onTouch(mUdfpsView, event);
mBiometricsExecutor.runAllReady();
event.recycle();
verify(mAlternateTouchProvider).onPointerDown(eq(TEST_REQUEST_ID), eq(expectedX),
eq(expectedY), eq(expectedMinor), eq(expectedMajor));
if (testParams.hasAlternateTouchProvider) {
verify(mAlternateTouchProvider).onPointerDown(eq(TEST_REQUEST_ID), eq(expectedX),
eq(expectedY), eq(expectedMinor), eq(expectedMajor));
} else {
verify(mFingerprintManager).onPointerDown(eq(TEST_REQUEST_ID),
eq(testParams.sensorProps.sensorId), eq(expectedX), eq(expectedY),
eq(expectedMinor), eq(expectedMajor));
}
// Test ROTATION_270
reset(mAlternateTouchProvider);
mUdfpsController.updateOverlayParams(mOpticalProps,
reset(mFingerprintManager);
mUdfpsController.updateOverlayParams(testParams.sensorProps,
new UdfpsOverlayParams(sensorBounds, sensorBounds, displayWidth, displayHeight,
scaleFactor, Surface.ROTATION_270));
event = obtainMotionEvent(ACTION_DOWN, 0, displayWidth, touchMinor, touchMajor);
@@ -591,12 +618,19 @@ public class UdfpsControllerTest extends SysuiTestCase {
mTouchListenerCaptor.getValue().onTouch(mUdfpsView, event);
mBiometricsExecutor.runAllReady();
event.recycle();
verify(mAlternateTouchProvider).onPointerDown(eq(TEST_REQUEST_ID), eq(expectedX),
eq(expectedY), eq(expectedMinor), eq(expectedMajor));
if (testParams.hasAlternateTouchProvider) {
verify(mAlternateTouchProvider).onPointerDown(eq(TEST_REQUEST_ID), eq(expectedX),
eq(expectedY), eq(expectedMinor), eq(expectedMajor));
} else {
verify(mFingerprintManager).onPointerDown(eq(TEST_REQUEST_ID),
eq(testParams.sensorProps.sensorId), eq(expectedX), eq(expectedY),
eq(expectedMinor), eq(expectedMajor));
}
// Test ROTATION_180
reset(mAlternateTouchProvider);
mUdfpsController.updateOverlayParams(mOpticalProps,
reset(mFingerprintManager);
mUdfpsController.updateOverlayParams(testParams.sensorProps,
new UdfpsOverlayParams(sensorBounds, sensorBounds, displayWidth, displayHeight,
scaleFactor, Surface.ROTATION_180));
// ROTATION_180 is not supported. It should be treated like ROTATION_0.
@@ -608,26 +642,22 @@ public class UdfpsControllerTest extends SysuiTestCase {
mTouchListenerCaptor.getValue().onTouch(mUdfpsView, event);
mBiometricsExecutor.runAllReady();
event.recycle();
verify(mAlternateTouchProvider).onPointerDown(eq(TEST_REQUEST_ID), eq(expectedX),
eq(expectedY), eq(expectedMinor), eq(expectedMajor));
}
private void runForAllUdfpsTypes(
ThrowingConsumer<FingerprintSensorPropertiesInternal> sensorPropsConsumer) {
for (FingerprintSensorPropertiesInternal sensorProps : List.of(mOpticalProps,
mUltrasonicProps)) {
mUdfpsController.updateOverlayParams(sensorProps, new UdfpsOverlayParams());
sensorPropsConsumer.accept(sensorProps);
if (testParams.hasAlternateTouchProvider) {
verify(mAlternateTouchProvider).onPointerDown(eq(TEST_REQUEST_ID), eq(expectedX),
eq(expectedY), eq(expectedMinor), eq(expectedMajor));
} else {
verify(mFingerprintManager).onPointerDown(eq(TEST_REQUEST_ID),
eq(testParams.sensorProps.sensorId), eq(expectedX), eq(expectedY),
eq(expectedMinor), eq(expectedMajor));
}
}
@Test
public void fingerDown() {
runForAllUdfpsTypes(this::fingerDownForSensor);
runWithAllParams(this::fingerDownParameterized);
}
private void fingerDownForSensor(FingerprintSensorPropertiesInternal sensorProps)
throws RemoteException {
private void fingerDownParameterized(TestParams testParams) throws RemoteException {
reset(mUdfpsView, mAlternateTouchProvider, mFingerprintManager, mLatencyTracker,
mKeyguardUpdateMonitor);
@@ -637,7 +667,7 @@ public class UdfpsControllerTest extends SysuiTestCase {
when(mKeyguardUpdateMonitor.isFingerprintDetectionRunning()).thenReturn(true);
// GIVEN that the overlay is showing
mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, sensorProps.sensorId,
mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, testParams.sensorProps.sensorId,
BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback);
mFgExecutor.runAllReady();
verify(mUdfpsView).setOnTouchListener(mTouchListenerCaptor.capture());
@@ -655,14 +685,22 @@ public class UdfpsControllerTest extends SysuiTestCase {
mFgExecutor.runAllReady();
// THEN FingerprintManager is notified about onPointerDown
verify(mAlternateTouchProvider).onPointerDown(eq(TEST_REQUEST_ID), eq(0), eq(0), eq(0f),
eq(0f));
verify(mFingerprintManager, never()).onPointerDown(anyLong(), anyInt(), anyInt(), anyInt(),
anyFloat(), anyFloat());
// THEN the touch provider is notified about onPointerDown.
if (testParams.hasAlternateTouchProvider) {
verify(mAlternateTouchProvider).onPointerDown(eq(TEST_REQUEST_ID), eq(0), eq(0), eq(0f),
eq(0f));
verify(mFingerprintManager, never()).onPointerDown(anyLong(), anyInt(), anyInt(),
anyInt(), anyFloat(), anyFloat());
verify(mKeyguardUpdateMonitor).onUdfpsPointerDown(eq((int) TEST_REQUEST_ID));
} else {
verify(mFingerprintManager).onPointerDown(eq(TEST_REQUEST_ID),
eq(testParams.sensorProps.sensorId), eq(0), eq(0), eq(0f), eq(0f));
verify(mAlternateTouchProvider, never()).onPointerDown(anyInt(), anyInt(), anyInt(),
anyFloat(), anyFloat());
}
// AND display configuration begins
if (sensorProps.sensorType == FingerprintSensorProperties.TYPE_UDFPS_OPTICAL) {
if (testParams.sensorProps.sensorType == FingerprintSensorProperties.TYPE_UDFPS_OPTICAL) {
verify(mLatencyTracker).onActionStart(eq(LatencyTracker.ACTION_UDFPS_ILLUMINATE));
verify(mUdfpsView).configureDisplay(mOnDisplayConfiguredCaptor.capture());
} else {
@@ -671,16 +709,27 @@ public class UdfpsControllerTest extends SysuiTestCase {
verify(mUdfpsView, never()).configureDisplay(any());
}
verify(mLatencyTracker, never()).onActionEnd(eq(LatencyTracker.ACTION_UDFPS_ILLUMINATE));
verify(mKeyguardUpdateMonitor).onUdfpsPointerDown(eq((int) TEST_REQUEST_ID));
if (sensorProps.sensorType == FingerprintSensorProperties.TYPE_UDFPS_OPTICAL) {
if (testParams.sensorProps.sensorType == FingerprintSensorProperties.TYPE_UDFPS_OPTICAL) {
// AND onDisplayConfigured notifies FingerprintManager about onUiReady
mOnDisplayConfiguredCaptor.getValue().run();
mBiometricsExecutor.runAllReady();
InOrder inOrder = inOrder(mAlternateTouchProvider, mLatencyTracker);
inOrder.verify(mAlternateTouchProvider).onUiReady();
inOrder.verify(mLatencyTracker).onActionEnd(eq(LatencyTracker.ACTION_UDFPS_ILLUMINATE));
if (testParams.hasAlternateTouchProvider) {
InOrder inOrder = inOrder(mAlternateTouchProvider, mLatencyTracker);
inOrder.verify(mAlternateTouchProvider).onUiReady();
inOrder.verify(mLatencyTracker).onActionEnd(
eq(LatencyTracker.ACTION_UDFPS_ILLUMINATE));
verify(mFingerprintManager, never()).onUiReady(anyLong(), anyInt());
} else {
InOrder inOrder = inOrder(mFingerprintManager, mLatencyTracker);
inOrder.verify(mFingerprintManager).onUiReady(eq(TEST_REQUEST_ID),
eq(testParams.sensorProps.sensorId));
inOrder.verify(mLatencyTracker).onActionEnd(
eq(LatencyTracker.ACTION_UDFPS_ILLUMINATE));
verify(mAlternateTouchProvider, never()).onUiReady();
}
} else {
verify(mFingerprintManager, never()).onUiReady(anyLong(), anyInt());
verify(mAlternateTouchProvider, never()).onUiReady();
verify(mLatencyTracker, never()).onActionEnd(
eq(LatencyTracker.ACTION_UDFPS_ILLUMINATE));
@@ -689,24 +738,23 @@ public class UdfpsControllerTest extends SysuiTestCase {
@Test
public void aodInterrupt() {
runForAllUdfpsTypes(this::aodInterruptForSensor);
runWithAllParams(this::aodInterruptParameterized);
}
private void aodInterruptForSensor(FingerprintSensorPropertiesInternal sensorProps)
throws RemoteException {
private void aodInterruptParameterized(TestParams testParams) throws RemoteException {
mUdfpsController.cancelAodInterrupt();
reset(mUdfpsView, mAlternateTouchProvider, mFingerprintManager, mKeyguardUpdateMonitor);
when(mKeyguardUpdateMonitor.isFingerprintDetectionRunning()).thenReturn(true);
// GIVEN that the overlay is showing and screen is on and fp is running
mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, sensorProps.sensorId,
mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, testParams.sensorProps.sensorId,
BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback);
mScreenObserver.onScreenTurnedOn();
mFgExecutor.runAllReady();
// WHEN fingerprint is requested because of AOD interrupt
mUdfpsController.onAodInterrupt(0, 0, 2f, 3f);
mFgExecutor.runAllReady();
if (sensorProps.sensorType == FingerprintSensorProperties.TYPE_UDFPS_OPTICAL) {
if (testParams.sensorProps.sensorType == FingerprintSensorProperties.TYPE_UDFPS_OPTICAL) {
// THEN display configuration begins
// AND onDisplayConfigured notifies FingerprintManager about onUiReady
verify(mUdfpsView).configureDisplay(mOnDisplayConfiguredCaptor.capture());
@@ -715,29 +763,37 @@ public class UdfpsControllerTest extends SysuiTestCase {
verify(mUdfpsView, never()).configureDisplay(mOnDisplayConfiguredCaptor.capture());
}
mBiometricsExecutor.runAllReady();
verify(mAlternateTouchProvider).onPointerDown(eq(TEST_REQUEST_ID),
eq(0), eq(0), eq(3f) /* minor */, eq(2f) /* major */);
verify(mFingerprintManager, never()).onPointerDown(anyLong(), anyInt(), anyInt(), anyInt(),
anyFloat(), anyFloat());
verify(mKeyguardUpdateMonitor).onUdfpsPointerDown(eq((int) TEST_REQUEST_ID));
if (testParams.hasAlternateTouchProvider) {
verify(mAlternateTouchProvider).onPointerDown(eq(TEST_REQUEST_ID), eq(0), eq(0),
eq(3f) /* minor */, eq(2f) /* major */);
verify(mFingerprintManager, never()).onPointerDown(anyLong(), anyInt(), anyInt(),
anyInt(), anyFloat(), anyFloat());
verify(mKeyguardUpdateMonitor).onUdfpsPointerDown(eq((int) TEST_REQUEST_ID));
} else {
verify(mFingerprintManager).onPointerDown(eq(TEST_REQUEST_ID),
eq(testParams.sensorProps.sensorId), eq(0), eq(0), eq(3f) /* minor */,
eq(2f) /* major */);
verify(mAlternateTouchProvider, never()).onPointerDown(anyLong(), anyInt(), anyInt(),
anyFloat(), anyFloat());
}
}
@Test
public void cancelAodInterrupt() {
runForAllUdfpsTypes(this::cancelAodInterruptForSensor);
runWithAllParams(this::cancelAodInterruptParameterized);
}
private void cancelAodInterruptForSensor(FingerprintSensorPropertiesInternal sensorProps)
throws RemoteException {
private void cancelAodInterruptParameterized(TestParams testParams) throws RemoteException {
reset(mUdfpsView);
// GIVEN AOD interrupt
mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, sensorProps.sensorId,
mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, testParams.sensorProps.sensorId,
BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback);
mScreenObserver.onScreenTurnedOn();
mFgExecutor.runAllReady();
mUdfpsController.onAodInterrupt(0, 0, 0f, 0f);
if (sensorProps.sensorType == FingerprintSensorProperties.TYPE_UDFPS_OPTICAL) {
if (testParams.sensorProps.sensorType == FingerprintSensorProperties.TYPE_UDFPS_OPTICAL) {
when(mUdfpsView.isDisplayConfigured()).thenReturn(true);
// WHEN it is cancelled
mUdfpsController.cancelAodInterrupt();
@@ -754,21 +810,20 @@ public class UdfpsControllerTest extends SysuiTestCase {
@Test
public void aodInterruptTimeout() {
runForAllUdfpsTypes(this::aodInterruptTimeoutForSensor);
runWithAllParams(this::aodInterruptTimeoutParameterized);
}
private void aodInterruptTimeoutForSensor(FingerprintSensorPropertiesInternal sensorProps)
throws RemoteException {
private void aodInterruptTimeoutParameterized(TestParams testParams) throws RemoteException {
reset(mUdfpsView);
// GIVEN AOD interrupt
mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, sensorProps.sensorId,
mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, testParams.sensorProps.sensorId,
BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback);
mScreenObserver.onScreenTurnedOn();
mFgExecutor.runAllReady();
mUdfpsController.onAodInterrupt(0, 0, 0f, 0f);
mFgExecutor.runAllReady();
if (sensorProps.sensorType == FingerprintSensorProperties.TYPE_UDFPS_OPTICAL) {
if (testParams.sensorProps.sensorType == FingerprintSensorProperties.TYPE_UDFPS_OPTICAL) {
when(mUdfpsView.isDisplayConfigured()).thenReturn(true);
} else {
when(mUdfpsView.isDisplayConfigured()).thenReturn(false);
@@ -776,7 +831,7 @@ public class UdfpsControllerTest extends SysuiTestCase {
// WHEN it times out
mFgExecutor.advanceClockToNext();
mFgExecutor.runAllReady();
if (sensorProps.sensorType == FingerprintSensorProperties.TYPE_UDFPS_OPTICAL) {
if (testParams.sensorProps.sensorType == FingerprintSensorProperties.TYPE_UDFPS_OPTICAL) {
// THEN the display is unconfigured.
verify(mUdfpsView).unconfigureDisplay();
} else {
@@ -787,23 +842,23 @@ public class UdfpsControllerTest extends SysuiTestCase {
@Test
public void aodInterruptCancelTimeoutActionOnFingerUp() {
runForAllUdfpsTypes(this::aodInterruptCancelTimeoutActionOnFingerUpForSensor);
runWithAllParams(this::aodInterruptCancelTimeoutActionOnFingerUpParameterized);
}
private void aodInterruptCancelTimeoutActionOnFingerUpForSensor(
FingerprintSensorPropertiesInternal sensorProps) throws RemoteException {
private void aodInterruptCancelTimeoutActionOnFingerUpParameterized(TestParams testParams)
throws RemoteException {
reset(mUdfpsView);
when(mUdfpsView.isWithinSensorArea(anyFloat(), anyFloat())).thenReturn(true);
// GIVEN AOD interrupt
mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, sensorProps.sensorId,
mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, testParams.sensorProps.sensorId,
BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback);
mScreenObserver.onScreenTurnedOn();
mFgExecutor.runAllReady();
mUdfpsController.onAodInterrupt(0, 0, 0f, 0f);
mFgExecutor.runAllReady();
if (sensorProps.sensorType == FingerprintSensorProperties.TYPE_UDFPS_OPTICAL) {
if (testParams.sensorProps.sensorType == FingerprintSensorProperties.TYPE_UDFPS_OPTICAL) {
// Configure UdfpsView to accept the ACTION_UP event
when(mUdfpsView.isDisplayConfigured()).thenReturn(true);
} else {
@@ -833,7 +888,7 @@ public class UdfpsControllerTest extends SysuiTestCase {
moveEvent.recycle();
mFgExecutor.runAllReady();
if (sensorProps.sensorType == FingerprintSensorProperties.TYPE_UDFPS_OPTICAL) {
if (testParams.sensorProps.sensorType == FingerprintSensorProperties.TYPE_UDFPS_OPTICAL) {
// Configure UdfpsView to accept the finger up event
when(mUdfpsView.isDisplayConfigured()).thenReturn(true);
} else {
@@ -844,7 +899,7 @@ public class UdfpsControllerTest extends SysuiTestCase {
mFgExecutor.advanceClockToNext();
mFgExecutor.runAllReady();
if (sensorProps.sensorType == FingerprintSensorProperties.TYPE_UDFPS_OPTICAL) {
if (testParams.sensorProps.sensorType == FingerprintSensorProperties.TYPE_UDFPS_OPTICAL) {
// THEN the display should be unconfigured once. If the timeout action is not
// cancelled, the display would be unconfigured twice which would cause two
// FP attempts.
@@ -856,23 +911,23 @@ public class UdfpsControllerTest extends SysuiTestCase {
@Test
public void aodInterruptCancelTimeoutActionOnAcquired() {
runForAllUdfpsTypes(this::aodInterruptCancelTimeoutActionOnAcquiredForSensor);
runWithAllParams(this::aodInterruptCancelTimeoutActionOnAcquiredParameterized);
}
private void aodInterruptCancelTimeoutActionOnAcquiredForSensor(
FingerprintSensorPropertiesInternal sensorProps) throws RemoteException {
private void aodInterruptCancelTimeoutActionOnAcquiredParameterized(TestParams testParams)
throws RemoteException {
reset(mUdfpsView);
when(mUdfpsView.isWithinSensorArea(anyFloat(), anyFloat())).thenReturn(true);
// GIVEN AOD interrupt
mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, sensorProps.sensorId,
mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, testParams.sensorProps.sensorId,
BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback);
mScreenObserver.onScreenTurnedOn();
mFgExecutor.runAllReady();
mUdfpsController.onAodInterrupt(0, 0, 0f, 0f);
mFgExecutor.runAllReady();
if (sensorProps.sensorType == FingerprintSensorProperties.TYPE_UDFPS_OPTICAL) {
if (testParams.sensorProps.sensorType == FingerprintSensorProperties.TYPE_UDFPS_OPTICAL) {
// Configure UdfpsView to accept the acquired event
when(mUdfpsView.isDisplayConfigured()).thenReturn(true);
} else {
@@ -880,7 +935,7 @@ public class UdfpsControllerTest extends SysuiTestCase {
}
// WHEN acquired is received
mOverlayController.onAcquired(sensorProps.sensorId,
mOverlayController.onAcquired(testParams.sensorProps.sensorId,
BiometricFingerprintConstants.FINGERPRINT_ACQUIRED_GOOD);
// Configure UdfpsView to accept the ACTION_DOWN event
@@ -900,7 +955,7 @@ public class UdfpsControllerTest extends SysuiTestCase {
moveEvent.recycle();
mFgExecutor.runAllReady();
if (sensorProps.sensorType == FingerprintSensorProperties.TYPE_UDFPS_OPTICAL) {
if (testParams.sensorProps.sensorType == FingerprintSensorProperties.TYPE_UDFPS_OPTICAL) {
// Configure UdfpsView to accept the finger up event
when(mUdfpsView.isDisplayConfigured()).thenReturn(true);
} else {
@@ -911,7 +966,7 @@ public class UdfpsControllerTest extends SysuiTestCase {
mFgExecutor.advanceClockToNext();
mFgExecutor.runAllReady();
if (sensorProps.sensorType == FingerprintSensorProperties.TYPE_UDFPS_OPTICAL) {
if (testParams.sensorProps.sensorType == FingerprintSensorProperties.TYPE_UDFPS_OPTICAL) {
// THEN the display should be unconfigured once. If the timeout action is not
// cancelled, the display would be unconfigured twice which would cause two
// FP attempts.
@@ -923,15 +978,14 @@ public class UdfpsControllerTest extends SysuiTestCase {
@Test
public void aodInterruptScreenOff() {
runForAllUdfpsTypes(this::aodInterruptScreenOffForSensor);
runWithAllParams(this::aodInterruptScreenOffParameterized);
}
private void aodInterruptScreenOffForSensor(FingerprintSensorPropertiesInternal sensorProps)
throws RemoteException {
private void aodInterruptScreenOffParameterized(TestParams testParams) throws RemoteException {
reset(mUdfpsView);
// GIVEN screen off
mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, sensorProps.sensorId,
mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, testParams.sensorProps.sensorId,
BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback);
mScreenObserver.onScreenTurnedOff();
mFgExecutor.runAllReady();
@@ -945,17 +999,16 @@ public class UdfpsControllerTest extends SysuiTestCase {
@Test
public void aodInterrupt_fingerprintNotRunning() {
runForAllUdfpsTypes(this::aodInterrupt_fingerprintNotRunningForSensor);
runWithAllParams(this::aodInterrupt_fingerprintNotRunningParameterized);
}
private void aodInterrupt_fingerprintNotRunningForSensor(
FingerprintSensorPropertiesInternal sensorProps) throws RemoteException {
private void aodInterrupt_fingerprintNotRunningParameterized(TestParams testParams)
throws RemoteException {
reset(mUdfpsView);
// GIVEN showing overlay
mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, sensorProps.sensorId,
BiometricOverlayConstants.REASON_AUTH_KEYGUARD,
mUdfpsOverlayControllerCallback);
mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, testParams.sensorProps.sensorId,
BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback);
mScreenObserver.onScreenTurnedOn();
mFgExecutor.runAllReady();