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

Commit 3bac3e05 authored by Austin Delgado's avatar Austin Delgado
Browse files

Prevent UdfpsController missing touches when an Up event is missed

Bug: 318591010
Test: UdfpsControllerTest
Flag: None
Change-Id: I73ba1dd5d20dfb0bb97ccf178c2e19862469c12a
parent bcb712f1
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -1218,6 +1218,40 @@ public class UdfpsControllerTest extends SysuiTestCase {
        verify(mInputManager, never()).pilferPointers(any());
    }

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

        mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, mOpticalProps.sensorId,
                BiometricRequestConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback);
        mFgExecutor.runAllReady();

        verify(mUdfpsView).setOnTouchListener(mTouchListenerCaptor.capture());

        // WHEN ACTION_DOWN is received and touch is within sensor
        when(mSinglePointerTouchProcessor.processTouch(any(), anyInt(), any())).thenReturn(
                processorResultDown);
        MotionEvent firstDownEvent = MotionEvent.obtain(0, 0, ACTION_DOWN, 0, 0, 0);
        mTouchListenerCaptor.getValue().onTouch(mUdfpsView, firstDownEvent);
        mBiometricExecutor.runAllReady();
        firstDownEvent.recycle();

        // And another ACTION_DOWN is received without an ACTION_UP before
        MotionEvent secondDownEvent = MotionEvent.obtain(0, 0, ACTION_DOWN, 0, 0, 0);
        mTouchListenerCaptor.getValue().onTouch(mUdfpsView, secondDownEvent);
        mBiometricExecutor.runAllReady();
        secondDownEvent.recycle();

        // THEN the touch is still processed
        verify(mFingerprintManager, times(2)).onPointerDown(anyLong(), anyInt(), anyInt(),
                anyFloat(), anyFloat(), anyFloat(), anyFloat(), anyFloat(), anyLong(), anyLong(),
                anyBoolean());
    }

    @Test
    public void onTouch_pilferPointerWhenAltBouncerShowing()
            throws RemoteException {
+12 −8
Original line number Diff line number Diff line
@@ -187,7 +187,7 @@ public class UdfpsController implements DozeReceiver, Dumpable {
    @Nullable private UdfpsDisplayModeProvider mUdfpsDisplayMode;

    // The ID of the pointer for which ACTION_DOWN has occurred. -1 means no pointer is active.
    private int mActivePointerId = -1;
    private int mActivePointerId = MotionEvent.INVALID_POINTER_ID;
    // Whether a pointer has been pilfered for current gesture
    private boolean mPointerPilfered = false;
    // The timestamp of the most recent touch log.
@@ -510,7 +510,16 @@ public class UdfpsController implements DozeReceiver, Dumpable {
                    + mOverlay.getRequestId());
            return false;
        }
        if (!DeviceEntryUdfpsRefactor.isEnabled()) {
        if (event.getAction() == MotionEvent.ACTION_DOWN
                || event.getAction() == MotionEvent.ACTION_HOVER_ENTER) {
            // Reset on ACTION_DOWN, start of new gesture
            mPointerPilfered = false;
            if (mActivePointerId != MotionEvent.INVALID_POINTER_ID) {
                Log.w(TAG, "onTouch down received without a preceding up");
            }
            mActivePointerId = MotionEvent.INVALID_POINTER_ID;
            mOnFingerDown = false;
        } else if (!DeviceEntryUdfpsRefactor.isEnabled()) {
            if ((mLockscreenShadeTransitionController.getQSDragProgress() != 0f
                    && !mAlternateBouncerInteractor.isVisibleState())
                    || mPrimaryBouncerInteractor.isInTransit()) {
@@ -518,11 +527,6 @@ public class UdfpsController implements DozeReceiver, Dumpable {
                return false;
            }
        }
        if (event.getAction() == MotionEvent.ACTION_DOWN
                || event.getAction() == MotionEvent.ACTION_HOVER_ENTER) {
            // Reset on ACTION_DOWN, start of new gesture
            mPointerPilfered = false;
        }

        final TouchProcessorResult result = mTouchProcessor.processTouch(event, mActivePointerId,
                mOverlayParams);
@@ -1080,7 +1084,7 @@ public class UdfpsController implements DozeReceiver, Dumpable {
            long gestureStart,
            boolean isAod) {
        mExecution.assertIsMainThread();
        mActivePointerId = -1;
        mActivePointerId = MotionEvent.INVALID_POINTER_ID;
        mAcquiredReceived = false;
        if (mOnFingerDown) {
            mFingerprintManager.onPointerUp(requestId, mSensorProps.sensorId, pointerId, x,