summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ameer Armaly <aarmaly@google.com> 2023-07-31 19:15:11 +0000
committer Ameer Armaly <aarmaly@google.com> 2023-08-01 22:44:04 +0000
commit7e7658858094720da111193a9ddf012e9fd596bb (patch)
treed160475fd96afc987b32ef54659f6470716157b7
parentf72337cdc55dd1827b59f1eb78e2a06c04f5ccba (diff)
[RESTRICT AUTOMERGE] Fix the consistency of the event stream during interrupted and continued touch exploration.
aosp/2677516 fixed the event stream when we initiate a new touch exploration which avoids a crash, but this change along with the accompanying test makes sure that the event stream is consistent in the moment rather than waiting for the next ACTION_DOWN to fix it. Bug:286037469 Bug: 290719741 Test: atest TouchExplorerTest Test: atest TouchInteractionControllerTest Test: atest TouchInteractionControllerTest#testInterruptedSwipe_generatesConsistentEventStream --rerun-until-failure 100 Change-Id: I909e150ae7652842ada5f329f25222e9093a3e6d
-rw-r--r--services/accessibility/java/com/android/server/accessibility/gestures/TouchExplorer.java19
1 files changed, 15 insertions, 4 deletions
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 2cf0e3e54326..24185c147ed3 100644
--- a/services/accessibility/java/com/android/server/accessibility/gestures/TouchExplorer.java
+++ b/services/accessibility/java/com/android/server/accessibility/gestures/TouchExplorer.java
@@ -634,7 +634,7 @@ public class TouchExplorer extends BaseEventStreamTransformation
MotionEvent event, MotionEvent rawEvent, int policyFlags) {
switch (event.getActionMasked()) {
case ACTION_DOWN:
- // We should have already received ACTION_DOWN. Ignore.
+ handleActionDownStateTouchExploring(event, rawEvent, policyFlags);
break;
case ACTION_POINTER_DOWN:
handleActionPointerDown(event, rawEvent, policyFlags);
@@ -840,6 +840,15 @@ public class TouchExplorer extends BaseEventStreamTransformation
}
}
+ private void handleActionDownStateTouchExploring(
+ MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+ // This is an interrupted and continued touch exploration. Maintain the consistency of the
+ // event stream.
+ mSendTouchExplorationEndDelayed.cancel();
+ mSendTouchInteractionEndDelayed.cancel();
+ sendTouchExplorationGestureStartAndHoverEnterIfNeeded(policyFlags);
+ }
+
/**
* Handles move events while touch exploring. this is also where we drag or delegate based on
* the number of fingers moving on the screen.
@@ -1097,12 +1106,15 @@ public class TouchExplorer extends BaseEventStreamTransformation
}
/**
- * Sends the enter events if needed. Such events are hover enter and touch explore
- * gesture start.
+ * Sends the enter events if needed. Such events are hover enter and touch explore gesture
+ * start.
*
* @param policyFlags The policy flags associated with the event.
*/
private void sendTouchExplorationGestureStartAndHoverEnterIfNeeded(int policyFlags) {
+ if (!mState.isTouchExploring()) {
+ mDispatcher.sendAccessibilityEvent(TYPE_TOUCH_EXPLORATION_GESTURE_START);
+ }
MotionEvent event = mState.getLastInjectedHoverEvent();
if (event != null && event.getActionMasked() == ACTION_HOVER_EXIT) {
final int pointerIdBits = event.getPointerIdBits();
@@ -1115,7 +1127,6 @@ public class TouchExplorer extends BaseEventStreamTransformation
}
}
-
/**
* Determines whether a two pointer gesture is a dragging one.
*