diff options
| author | 2019-12-18 14:41:13 -0800 | |
|---|---|---|
| committer | 2019-12-19 10:58:31 -0800 | |
| commit | c6222fabb3277ff8c5cbe872d25cd89e9cc1623d (patch) | |
| tree | 4950380c28c8435856631f85da8b3407009003a5 | |
| parent | 848cc3537531f925fb7c695810ece3f7d1fec960 (diff) | |
Fix issues with swiping on some devices.
Some devices will send ACTION_MOVE events with the same coordinates as ACTION_DOWN. If so, we ignore them in order to correctly interpret the rest of the gesture.
Fix: 146472448
Test: Run talkback and swipe in all directions.
Test: atest AccessibilityGestureDetectorTest TouchExplorerTest GestureManifoldTest
Change-Id: I7c6ee32aa64cd9558afef4caf690f822f2541c5b
| -rw-r--r-- | services/accessibility/java/com/android/server/accessibility/gestures/Swipe.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/services/accessibility/java/com/android/server/accessibility/gestures/Swipe.java b/services/accessibility/java/com/android/server/accessibility/gestures/Swipe.java index b246c67944c7..a285c10cc6ff 100644 --- a/services/accessibility/java/com/android/server/accessibility/gestures/Swipe.java +++ b/services/accessibility/java/com/android/server/accessibility/gestures/Swipe.java @@ -26,6 +26,7 @@ import android.util.DisplayMetrics; import android.util.Slog; import android.util.TypedValue; import android.view.MotionEvent; +import android.view.ViewConfiguration; import java.util.ArrayList; @@ -85,6 +86,10 @@ class Swipe extends GestureMatcher { private static final float MIN_CM_BETWEEN_SAMPLES = 0.25f; private final float mMinPixelsBetweenSamplesX; private final float mMinPixelsBetweenSamplesY; + // The minmimum distance the finger must travel before we evaluate the initial direction of the + // swipe. + // Anything less is still considered a touch. + private int mTouchSlop; // Constants for separating gesture segments private static final float ANGLE_THRESHOLD = 0.0f; @@ -122,6 +127,7 @@ class Swipe extends GestureMatcher { final float pixelsPerCmY = displayMetrics.ydpi / 2.54f; mMinPixelsBetweenSamplesX = MIN_CM_BETWEEN_SAMPLES * pixelsPerCmX; mMinPixelsBetweenSamplesY = MIN_CM_BETWEEN_SAMPLES * pixelsPerCmY; + mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); clear(); } @@ -165,7 +171,10 @@ class Swipe extends GestureMatcher { + Float.toString(mGestureDetectionThreshold)); } if (getState() == STATE_CLEAR) { - if (mStrokeBuffer.size() == 0) { + if (moveDelta < mTouchSlop) { + // This still counts as a touch not a swipe. + return; + } else if (mStrokeBuffer.size() == 0) { // First, make sure the pointer is going in the right direction. cancelAfterDelay(event, rawEvent, policyFlags); int direction = toDirection(x - mBaseX, y - mBaseY); |