Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 83a1ff7e authored by Austin Delgado's avatar Austin Delgado
Browse files

Fix duplicate onFingerDown calls in UdfpsController

On certain devices, touches are received by both AOD and
UdfpsOverlay. Add check for mOnFingerDown to prevent sending duplicate
onFingerDown calls to HAL.

Bug: 293749415
Test: Manual, verified expected behavior on AOD and Keyguard
Test: atest UdfpsControllerTest

Change-Id: I28b5d736a234ef8c8cff4fbce6b6bf771f75917a
parent 24fc870f
Loading
Loading
Loading
Loading
+12 −10
Original line number Diff line number Diff line
@@ -586,6 +586,7 @@ public class UdfpsController implements DozeReceiver, Dumpable {
                if (shouldTryToDismissKeyguard()) {
                    tryDismissingKeyguard();
                }
                if (!mOnFingerDown) {
                    onFingerDown(requestId,
                            data.getPointerId(),
                            data.getX(),
@@ -596,6 +597,7 @@ public class UdfpsController implements DozeReceiver, Dumpable {
                            data.getTime(),
                            data.getGestureStart(),
                            mStatusBarStateController.isDozing());
                }

                // Pilfer if valid overlap, don't allow following events to reach keyguard
                shouldPilfer = true;
+39 −0
Original line number Diff line number Diff line
@@ -1616,4 +1616,43 @@ public class UdfpsControllerTest extends SysuiTestCase {
        // THEN vibrate is used
        verify(mVibrator).performHapticFeedback(any(), eq(UdfpsController.LONG_PRESS));
    }

    @Test
    public void aodInterrupt_withNewTouchDetection() throws RemoteException {
        mUdfpsController.cancelAodSendFingerUpAction();
        final NormalizedTouchData touchData = new NormalizedTouchData(0, 0f, 0f, 0f, 0f, 0f, 0L,
                0L);
        final TouchProcessorResult processorResultDown =
                new TouchProcessorResult.ProcessedTouch(InteractionEvent.DOWN,
                        1 /* pointerId */, touchData);

        // Enable new touch detection.
        when(mFeatureFlags.isEnabled(Flags.UDFPS_NEW_TOUCH_DETECTION)).thenReturn(true);

        // Configure UdfpsController to use FingerprintManager as opposed to AlternateTouchProvider.
        initUdfpsController(mOpticalProps, false /* hasAlternateTouchProvider */);

        // GIVEN that the overlay is showing and screen is on and fp is running
        mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, 0,
                BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback);
        mScreenObserver.onScreenTurnedOn();
        mFgExecutor.runAllReady();

        // WHEN fingerprint is requested because of AOD interrupt
        mUdfpsController.onAodInterrupt(0, 0, 2f, 3f);

        // Check case where touch driver sends touch to UdfpsView as well
        verify(mUdfpsView).setOnTouchListener(mTouchListenerCaptor.capture());
        when(mUdfpsView.isWithinSensorArea(anyFloat(), anyFloat())).thenReturn(true);
        when(mSinglePointerTouchProcessor.processTouch(any(), anyInt(), any())).thenReturn(
                processorResultDown);
        MotionEvent downEvent = MotionEvent.obtain(0, 0, ACTION_DOWN, 0, 0, 0);
        mTouchListenerCaptor.getValue().onTouch(mUdfpsView, downEvent);

        mBiometricExecutor.runAllReady();

        // THEN only one onPointerDown is sent
        verify(mFingerprintManager).onPointerDown(anyLong(), anyInt(), anyInt(), anyFloat(),
                anyFloat(), anyFloat(), anyFloat(), anyFloat(), anyLong(), anyLong(), anyBoolean());
    }
}