TouchExplorer: do not crash when the user lifts a finger while dragging.

Fix: 223396885
Test: Manual. Perform two-finger drag repeatedly.
Test: atest TouchExplorerTest
Change-Id: I5e5d8c69e4d1541048c91fbda20ff9d27912d21b
This commit is contained in:
Ameer Armaly
2022-03-08 10:03:18 -08:00
parent cde55d305f
commit 466c18a33b

View File

@@ -1006,12 +1006,10 @@ public class TouchExplorer extends BaseEventStreamTransformation
}
break;
case ACTION_POINTER_UP:
if (event.getPointerId(GestureUtils.getActionIndex(event)) == mDraggingPointerId) {
mDraggingPointerId = INVALID_POINTER_ID;
// Send an event to the end of the drag gesture.
mDispatcher.sendMotionEvent(
event, ACTION_UP, rawEvent, pointerIdBits, policyFlags);
}
break;
case ACTION_UP:
if (event.getPointerId(GestureUtils.getActionIndex(event)) == mDraggingPointerId) {
@@ -1146,6 +1144,10 @@ public class TouchExplorer extends BaseEventStreamTransformation
* closet to an edge of the screen.
*/
private void computeDraggingPointerIdIfNeeded(MotionEvent event) {
if (event.getPointerCount() != 2) {
mDraggingPointerId = INVALID_POINTER_ID;
return;
}
if (mDraggingPointerId != INVALID_POINTER_ID) {
// If we have a valid pointer ID, we should be good
final int pointerIndex = event.findPointerIndex(mDraggingPointerId);