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

Commit 62648cba authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Revert "Reduce touch exploration sensitivity."" into main

parents 251d3ca5 40a66ffb
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -58,13 +58,6 @@ flag {
    bug: "286587811"
}

flag {
    name: "reduce_touch_exploration_sensitivity"
    namespace: "accessibility"
    description: "Reduces touch exploration sensitivity by only sending a hover event when the ifnger has moved the amount of pixels defined by the system's touch slop."
    bug: "303677860"
}

flag {
    name: "scan_packages_without_lock"
    namespace: "accessibility"
+3 −15
Original line number Diff line number Diff line
@@ -884,20 +884,8 @@ public class TouchExplorer extends BaseEventStreamTransformation
            case 1:
            // Touch exploration.
                sendTouchExplorationGestureStartAndHoverEnterIfNeeded(policyFlags);
                if (Flags.reduceTouchExplorationSensitivity()
                        && mState.getLastInjectedHoverEvent() != null) {
                    final MotionEvent lastEvent = mState.getLastInjectedHoverEvent();
                    final float deltaX = lastEvent.getX() - rawEvent.getX();
                    final float deltaY = lastEvent.getY() - rawEvent.getY();
                    final double moveDelta = Math.hypot(deltaX, deltaY);
                    if (moveDelta > mTouchSlop) {
                        mDispatcher.sendMotionEvent(
                                event, ACTION_HOVER_MOVE, rawEvent, pointerIdBits, policyFlags);
                    }
                } else {
                mDispatcher.sendMotionEvent(
                        event, ACTION_HOVER_MOVE, rawEvent, pointerIdBits, policyFlags);
                }
                break;
            case 2:
                if (mGestureDetector.isMultiFingerGesturesEnabled()
+9 −52
Original line number Diff line number Diff line
@@ -44,10 +44,6 @@ import android.content.Context;
import android.graphics.PointF;
import android.os.Looper;
import android.os.SystemClock;
import android.platform.test.annotations.RequiresFlagsDisabled;
import android.platform.test.annotations.RequiresFlagsEnabled;
import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import android.testing.DexmakerShareClassLoaderRule;
import android.view.InputDevice;
import android.view.MotionEvent;
@@ -60,7 +56,6 @@ import androidx.test.runner.AndroidJUnit4;
import com.android.server.accessibility.AccessibilityManagerService;
import com.android.server.accessibility.AccessibilityTraceManager;
import com.android.server.accessibility.EventStreamTransformation;
import com.android.server.accessibility.Flags;
import com.android.server.accessibility.utils.GestureLogParser;
import com.android.server.testutils.OffsettableClock;

@@ -81,7 +76,6 @@ import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;


@RunWith(AndroidJUnit4.class)
public class TouchExplorerTest {

@@ -125,9 +119,6 @@ public class TouchExplorerTest {
    public final DexmakerShareClassLoaderRule mDexmakerShareClassLoaderRule =
            new DexmakerShareClassLoaderRule();

    @Rule
    public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();

    /**
     * {@link TouchExplorer#sendDownForAllNotInjectedPointers} injecting events with the same object
     * is resulting {@link ArgumentCaptor} to capture events with last state. Before implementation
@@ -170,42 +161,11 @@ public class TouchExplorerTest {
        goFromStateClearTo(STATE_TOUCH_EXPLORING_1FINGER);
        // Wait for transiting to touch exploring state.
        mHandler.fastForward(2 * USER_INTENT_TIMEOUT);
        assertState(STATE_TOUCH_EXPLORING);
        // Manually construct the next move event. Using moveEachPointers() will batch the move
        // event which produces zero movement for some reason.
        float[] x = new float[1];
        float[] y = new float[1];
        x[0] = mLastEvent.getX(0) + mTouchSlop;
        y[0] = mLastEvent.getY(0) + mTouchSlop;
        send(manyPointerEvent(ACTION_MOVE, x, y));
        goToStateClearFrom(STATE_TOUCH_EXPLORING_1FINGER);
        assertCapturedEvents(ACTION_HOVER_ENTER, ACTION_HOVER_MOVE, ACTION_HOVER_EXIT);
    }

    /**
     * Test the case where ACTION_DOWN is followed by a number of ACTION_MOVE events that do not
     * change the coordinates.
     */
    @Test
    @RequiresFlagsEnabled(Flags.FLAG_REDUCE_TOUCH_EXPLORATION_SENSITIVITY)
    public void testOneFingerMoveWithExtraMoveEvents_generatesOneMoveEvent() {
        goFromStateClearTo(STATE_TOUCH_EXPLORING_1FINGER);
        // Inject a set of move events that have the same coordinates as the down event.
        moveEachPointers(mLastEvent, p(0, 0));
        send(mLastEvent);
        // Wait for transition to touch exploring state.
        mHandler.fastForward(2 * USER_INTENT_TIMEOUT);
        // Now move for real.
        moveAtLeastTouchSlop(mLastEvent);
        send(mLastEvent);
        // One more move event with no change.
        moveEachPointers(mLastEvent, p(0, 0));
        moveEachPointers(mLastEvent, p(10, 10));
        send(mLastEvent);
        goToStateClearFrom(STATE_TOUCH_EXPLORING_1FINGER);
        assertCapturedEvents(
                ACTION_HOVER_ENTER,
                ACTION_HOVER_MOVE,
                ACTION_HOVER_EXIT);
        assertCapturedEvents(ACTION_HOVER_ENTER, ACTION_HOVER_MOVE, ACTION_HOVER_EXIT);
        assertState(STATE_TOUCH_EXPLORING);
    }

    /**
@@ -213,8 +173,7 @@ public class TouchExplorerTest {
     * change the coordinates.
     */
    @Test
    @RequiresFlagsDisabled(Flags.FLAG_REDUCE_TOUCH_EXPLORATION_SENSITIVITY)
    public void testOneFingerMoveWithExtraMoveEvents_generatesThreeMoveEvent() {
    public void testOneFingerMoveWithExtraMoveEvents() {
        goFromStateClearTo(STATE_TOUCH_EXPLORING_1FINGER);
        // Inject a set of move events that have the same coordinates as the down event.
        moveEachPointers(mLastEvent, p(0, 0));
@@ -222,7 +181,7 @@ public class TouchExplorerTest {
        // Wait for transition to touch exploring state.
        mHandler.fastForward(2 * USER_INTENT_TIMEOUT);
        // Now move for real.
        moveAtLeastTouchSlop(mLastEvent);
        moveEachPointers(mLastEvent, p(10, 10));
        send(mLastEvent);
        // One more move event with no change.
        moveEachPointers(mLastEvent, p(0, 0));
@@ -283,7 +242,7 @@ public class TouchExplorerTest {
        moveEachPointers(mLastEvent, p(0, 0), p(0, 0));
        send(mLastEvent);
        // Now move for real.
        moveEachPointers(mLastEvent, p(mTouchSlop, mTouchSlop), p(mTouchSlop, mTouchSlop));
        moveEachPointers(mLastEvent, p(10, 10), p(10, 10));
        send(mLastEvent);
        goToStateClearFrom(STATE_DRAGGING_2FINGERS);
        assertCapturedEvents(ACTION_DOWN, ACTION_MOVE, ACTION_MOVE, ACTION_MOVE, ACTION_UP);
@@ -292,7 +251,7 @@ public class TouchExplorerTest {
    @Test
    public void testUpEvent_OneFingerMove_clearStateAndInjectHoverEvents() {
        goFromStateClearTo(STATE_TOUCH_EXPLORING_1FINGER);
        moveAtLeastTouchSlop(mLastEvent);
        moveEachPointers(mLastEvent, p(10, 10));
        send(mLastEvent);
        // Wait 10 ms to make sure that hover enter and exit are not scheduled for the same moment.
        mHandler.fastForward(10);
@@ -318,7 +277,7 @@ public class TouchExplorerTest {

        // Wait for the finger moving to the second view.
        mHandler.fastForward(oneThirdUserIntentTimeout);
        moveAtLeastTouchSlop(mLastEvent);
        moveEachPointers(mLastEvent, p(10, 10));
        send(mLastEvent);

        // Wait for the finger lifting from the second view.
@@ -443,6 +402,7 @@ public class TouchExplorerTest {
        // Manually construct the next move event. Using moveEachPointers() will batch the move
        // event onto the pointer up event which will mean that the move event still has a pointer
        // count of 3.
        // Todo: refactor to avoid using batching as there is no special reason to do it that way.
        float[] x = new float[2];
        float[] y = new float[2];
        x[0] = mLastEvent.getX(0) + 100;
@@ -774,9 +734,6 @@ public class TouchExplorerTest {
        }
    }

    private void moveAtLeastTouchSlop(MotionEvent event) {
        moveEachPointers(event, p(2 * mTouchSlop, 0));
    }
    /**
     * A {@link android.os.Handler} that doesn't process messages until {@link #fastForward(int)} is
     * invoked.