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

Commit a924cab1 authored by Austin Delgado's avatar Austin Delgado
Browse files

RESTRICT AUTOMERGE Fix missed UDFPS attempt after 3 failed auths

Fixes: 302253071
Test: atest UdfpsControllerTest
Change-Id: I0f92cec88eab134eaeaffabfb605c793eb1c809e
parent 7ad6a353
Loading
Loading
Loading
Loading
+3 −7
Original line number Original line Diff line number Diff line
@@ -553,7 +553,9 @@ public class UdfpsController implements DozeReceiver, Dumpable {
            Log.w(TAG, "ignoring onTouch with null overlay or animation view controller");
            Log.w(TAG, "ignoring onTouch with null overlay or animation view controller");
            return false;
            return false;
        }
        }
        if (mOverlay.getAnimationViewController().shouldPauseAuth()) {
        // Wait to receive up or cancel before pausing auth
        if (mActivePointerId == MotionEvent.INVALID_POINTER_ID
                && mOverlay.getAnimationViewController().shouldPauseAuth()) {
            Log.w(TAG, "ignoring onTouch with shouldPauseAuth = true");
            Log.w(TAG, "ignoring onTouch with shouldPauseAuth = true");
            return false;
            return false;
        }
        }
@@ -562,12 +564,6 @@ public class UdfpsController implements DozeReceiver, Dumpable {
                    + mOverlay.getRequestId());
                    + mOverlay.getRequestId());
            return false;
            return false;
        }
        }

        if ((mLockscreenShadeTransitionController.getQSDragProgress() != 0f
                && !mAlternateBouncerInteractor.isVisibleState())
                || mPrimaryBouncerInteractor.isInTransit()) {
            return false;
        }
        if (event.getAction() == MotionEvent.ACTION_DOWN
        if (event.getAction() == MotionEvent.ACTION_DOWN
                || event.getAction() == MotionEvent.ACTION_HOVER_ENTER) {
                || event.getAction() == MotionEvent.ACTION_HOVER_ENTER) {
            // Reset on ACTION_DOWN, start of new gesture
            // Reset on ACTION_DOWN, start of new gesture
+61 −48
Original line number Original line Diff line number Diff line
@@ -1396,7 +1396,7 @@ public class UdfpsControllerTest extends SysuiTestCase {
        // Configure UdfpsController to use FingerprintManager as opposed to AlternateTouchProvider.
        // Configure UdfpsController to use FingerprintManager as opposed to AlternateTouchProvider.
        initUdfpsController(mOpticalProps, false /* hasAlternateTouchProvider */);
        initUdfpsController(mOpticalProps, false /* hasAlternateTouchProvider */);


        // Configure UdfpsView to not accept the ACTION_DOWN event
        // Configure UdfpsView to accept the ACTION_DOWN event
        when(mUdfpsView.isDisplayConfigured()).thenReturn(true);
        when(mUdfpsView.isDisplayConfigured()).thenReturn(true);
        when(mUdfpsView.isWithinSensorArea(anyFloat(), anyFloat())).thenReturn(true);
        when(mUdfpsView.isWithinSensorArea(anyFloat(), anyFloat())).thenReturn(true);


@@ -1426,6 +1426,66 @@ public class UdfpsControllerTest extends SysuiTestCase {
                anyBoolean());
                anyBoolean());
    }
    }


    @Test
    public void onTouch_withNewTouchDetection_ignoreAuthPauseIfFingerDown() throws RemoteException {
        final NormalizedTouchData touchData = new NormalizedTouchData(0, 0f, 0f, 0f, 0f, 0f, 0L,
                0L);
        final TouchProcessorResult processorResultDown =
                new TouchProcessorResult.ProcessedTouch(InteractionEvent.DOWN,
                        0 /* pointerId */, touchData);
        final TouchProcessorResult processorResultUp =
                new TouchProcessorResult.ProcessedTouch(InteractionEvent.UP,
                        -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 */);

        // Configure UdfpsView to accept the ACTION_DOWN event
        when(mUdfpsView.isDisplayConfigured()).thenReturn(true);
        when(mUdfpsView.isWithinSensorArea(anyFloat(), anyFloat())).thenReturn(true);

        // GIVEN that the overlay is showing and a11y touch exploration NOT enabled
        when(mAccessibilityManager.isTouchExplorationEnabled()).thenReturn(false);
        mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, mOpticalProps.sensorId,
                BiometricOverlayConstants.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 event = MotionEvent.obtain(0, 0, ACTION_DOWN, 0, 0, 0);
        mTouchListenerCaptor.getValue().onTouch(mUdfpsView, event);
        mBiometricExecutor.runAllReady();

        // THEN the down touch is received
        verify(mInputManager).pilferPointers(any());
        verify(mFingerprintManager).onPointerDown(anyLong(), anyInt(), anyInt(),
                anyFloat(), anyFloat(), anyFloat(), anyFloat(), anyFloat(), anyLong(), anyLong(),
                anyBoolean());

        // GIVEN that auth is paused
        when(mUdfpsAnimationViewController.shouldPauseAuth()).thenReturn(true);

        // WHEN ACTION_UP is received and touch is within sensor
        when(mSinglePointerTouchProcessor.processTouch(any(), anyInt(), any())).thenReturn(
                processorResultUp);
        event.setAction(ACTION_UP);
        mTouchListenerCaptor.getValue().onTouch(mUdfpsView, event);
        mBiometricExecutor.runAllReady();
        event.recycle();

        // THEN the UP is still received
        verify(mInputManager).pilferPointers(any());
        verify(mFingerprintManager).onPointerUp(anyLong(), anyInt(), anyInt(),
                anyFloat(), anyFloat(), anyFloat(), anyFloat(), anyFloat(), anyLong(), anyLong(),
                anyBoolean());
    }

    @Test
    @Test
    public void onTouch_withNewTouchDetection_pilferPointer() throws RemoteException {
    public void onTouch_withNewTouchDetection_pilferPointer() throws RemoteException {
        final NormalizedTouchData touchData = new NormalizedTouchData(0, 0f, 0f, 0f, 0f, 0f, 0L,
        final NormalizedTouchData touchData = new NormalizedTouchData(0, 0f, 0f, 0f, 0f, 0f, 0L,
@@ -1551,53 +1611,6 @@ public class UdfpsControllerTest extends SysuiTestCase {
        verify(mInputManager).pilferPointers(any());
        verify(mInputManager).pilferPointers(any());
    }
    }


    @Test
    public void onTouch_withNewTouchDetection_doNotProcessTouchWhenPullingUpBouncer()
            throws RemoteException {
        final NormalizedTouchData touchData = new NormalizedTouchData(0, 0f, 0f, 0f, 0f, 0f, 0L,
                0L);
        final TouchProcessorResult processorResultMove =
                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 */);

        // Configure UdfpsView to accept the ACTION_MOVE event
        when(mUdfpsView.isDisplayConfigured()).thenReturn(false);
        when(mUdfpsView.isWithinSensorArea(anyFloat(), anyFloat())).thenReturn(true);

        // GIVEN that the alternate bouncer is not showing and a11y touch exploration NOT enabled
        when(mAccessibilityManager.isTouchExplorationEnabled()).thenReturn(false);
        when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(false);
        mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, mOpticalProps.sensorId,
                BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback);
        mFgExecutor.runAllReady();

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

        // GIVEN a swipe up to bring up primary bouncer is in progress or swipe down for QS
        when(mPrimaryBouncerInteractor.isInTransit()).thenReturn(true);
        when(mLockscreenShadeTransitionController.getFractionToShade()).thenReturn(1f);

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

        // THEN the touch is NOT processed
        verify(mFingerprintManager, never()).onPointerDown(anyLong(), anyInt(), anyInt(),
                anyFloat(), anyFloat(), anyFloat(), anyFloat(), anyFloat(), anyLong(), anyLong(),
                anyBoolean());
    }


    @Test
    @Test
    public void onTouch_withNewTouchDetection_qsDrag_processesTouchWhenAlternateBouncerVisible()
    public void onTouch_withNewTouchDetection_qsDrag_processesTouchWhenAlternateBouncerVisible()
            throws RemoteException {
            throws RemoteException {