Reduce touch exploration sensitivity.
This change alters touch exploration behavior by requiring that the finger move a number of pixels defined by the system's scaled touch slop value before it sends a hover event.
Fix: 303677860
Test: atest CtsAccessibilityServiceTestCases:TouchExplorerTest FrameworksServicesTests:TouchExplorerTest
Change-Id: Ib8dd4de60d5c71f38f8873b9c5c2af1d0c6e6010
diff --git a/services/accessibility/accessibility.aconfig b/services/accessibility/accessibility.aconfig
index 25b6244..f09cb19 100644
--- a/services/accessibility/accessibility.aconfig
+++ b/services/accessibility/accessibility.aconfig
@@ -55,3 +55,10 @@
description: "Scans packages for accessibility service/activity info without holding the A11yMS lock"
bug: "295969873"
}
+
+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"
+}
diff --git a/services/accessibility/java/com/android/server/accessibility/gestures/TouchExplorer.java b/services/accessibility/java/com/android/server/accessibility/gestures/TouchExplorer.java
index c418485..fc8d4f8 100644
--- a/services/accessibility/java/com/android/server/accessibility/gestures/TouchExplorer.java
+++ b/services/accessibility/java/com/android/server/accessibility/gestures/TouchExplorer.java
@@ -882,10 +882,22 @@
final int pointerIndex = event.findPointerIndex(pointerId);
switch (event.getPointerCount()) {
case 1:
- // Touch exploration.
+ // Touch exploration.
sendTouchExplorationGestureStartAndHoverEnterIfNeeded(policyFlags);
- mDispatcher.sendMotionEvent(
- event, ACTION_HOVER_MOVE, rawEvent, pointerIdBits, 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()