Merge "[RESTRICT AUTOMERGE] Fix the consistency of the event stream during interrupted and continued touch exploration." into main

This commit is contained in:
Ameer Armaly
2023-08-02 20:30:54 +00:00
committed by Gerrit Code Review

View File

@@ -634,7 +634,7 @@ public class TouchExplorer extends BaseEventStreamTransformation
MotionEvent event, MotionEvent rawEvent, int policyFlags) { MotionEvent event, MotionEvent rawEvent, int policyFlags) {
switch (event.getActionMasked()) { switch (event.getActionMasked()) {
case ACTION_DOWN: case ACTION_DOWN:
// We should have already received ACTION_DOWN. Ignore. handleActionDownStateTouchExploring(event, rawEvent, policyFlags);
break; break;
case ACTION_POINTER_DOWN: case ACTION_POINTER_DOWN:
handleActionPointerDown(event, rawEvent, policyFlags); 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 * Handles move events while touch exploring. this is also where we drag or delegate based on
* the number of fingers moving on the screen. * 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 * Sends the enter events if needed. Such events are hover enter and touch explore gesture
* gesture start. * start.
* *
* @param policyFlags The policy flags associated with the event. * @param policyFlags The policy flags associated with the event.
*/ */
private void sendTouchExplorationGestureStartAndHoverEnterIfNeeded(int policyFlags) { private void sendTouchExplorationGestureStartAndHoverEnterIfNeeded(int policyFlags) {
if (!mState.isTouchExploring()) {
mDispatcher.sendAccessibilityEvent(TYPE_TOUCH_EXPLORATION_GESTURE_START);
}
MotionEvent event = mState.getLastInjectedHoverEvent(); MotionEvent event = mState.getLastInjectedHoverEvent();
if (event != null && event.getActionMasked() == ACTION_HOVER_EXIT) { if (event != null && event.getActionMasked() == ACTION_HOVER_EXIT) {
final int pointerIdBits = event.getPointerIdBits(); final int pointerIdBits = event.getPointerIdBits();
@@ -1115,7 +1127,6 @@ public class TouchExplorer extends BaseEventStreamTransformation
} }
} }
/** /**
* Determines whether a two pointer gesture is a dragging one. * Determines whether a two pointer gesture is a dragging one.
* *