From c6cb35d97e7f9d08fae824ab918d5300a7edc5ee Mon Sep 17 00:00:00 2001 From: Sebastian Franco Date: Fri, 12 Jan 2024 13:22:14 -0800 Subject: [PATCH] Send pointer up input even if there is an exception Fix: 315525621 Test: atest TaplTestsQuickstep Flag: NA Change-Id: Ie0310ee8d4cf25435d752ed2b838ae79e7ce4a45 --- .../tapl/LauncherInstrumentation.java | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index e359cc81d4..f68e12cc88 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -1749,32 +1749,38 @@ public final class LauncherInstrumentation { final long downTime = SystemClock.uptimeMillis(); final Point start = new Point(startX, startY); final Point end = new Point(endX, endY); + long endTime = downTime; sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, start, gestureScope); - if (mTrackpadGestureType != TrackpadGestureType.NONE) { - sendPointer(downTime, downTime, getPointerAction(MotionEvent.ACTION_POINTER_DOWN, 1), - start, gestureScope); - if (mTrackpadGestureType == TrackpadGestureType.THREE_FINGER - || mTrackpadGestureType == TrackpadGestureType.FOUR_FINGER) { + try { + + if (mTrackpadGestureType != TrackpadGestureType.NONE) { sendPointer(downTime, downTime, - getPointerAction(MotionEvent.ACTION_POINTER_DOWN, 2), + getPointerAction(MotionEvent.ACTION_POINTER_DOWN, 1), start, gestureScope); - if (mTrackpadGestureType == TrackpadGestureType.FOUR_FINGER) { + if (mTrackpadGestureType == TrackpadGestureType.THREE_FINGER + || mTrackpadGestureType == TrackpadGestureType.FOUR_FINGER) { sendPointer(downTime, downTime, - getPointerAction(MotionEvent.ACTION_POINTER_DOWN, 3), + getPointerAction(MotionEvent.ACTION_POINTER_DOWN, 2), + start, gestureScope); + if (mTrackpadGestureType == TrackpadGestureType.FOUR_FINGER) { + sendPointer(downTime, downTime, + getPointerAction(MotionEvent.ACTION_POINTER_DOWN, 3), + start, gestureScope); + } + } + } + endTime = movePointer( + start, end, steps, false, downTime, downTime, slowDown, gestureScope); + if (mTrackpadGestureType != TrackpadGestureType.NONE) { + for (int i = mPointerCount; i >= 2; i--) { + sendPointer(downTime, downTime, + getPointerAction(MotionEvent.ACTION_POINTER_UP, i - 1), start, gestureScope); } } + } finally { + sendPointer(downTime, endTime, MotionEvent.ACTION_UP, end, gestureScope); } - final long endTime = movePointer( - start, end, steps, false, downTime, downTime, slowDown, gestureScope); - if (mTrackpadGestureType != TrackpadGestureType.NONE) { - for (int i = mPointerCount; i >= 2; i--) { - sendPointer(downTime, downTime, - getPointerAction(MotionEvent.ACTION_POINTER_UP, i - 1), - start, gestureScope); - } - } - sendPointer(downTime, endTime, MotionEvent.ACTION_UP, end, gestureScope); } private static int getPointerAction(int action, int index) {