Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9f45a12c authored by huyuxin's avatar huyuxin Committed by Alan Viverette
Browse files

Intercept abnormal MotionEvent in GestureDetector#onTouchEvent



This could happen if an app started to send events to
GestureDetector.onTouchEvent without sending an ACTION_DOWN event first.
GestureDetector must see a complete event stream for a gesture to behave
correctly. A complete event stream is defined as:
-One ACTION_DOWN event
-Zero or more ACTION_MOVE events and matched pairs of
ACTION_POINTER_DOWN/ACTION_POINTER_UP
-One ACTION_UP or ACTION_CANCEL

Bug: 242021191
Test: run cts -m CtsViewTestCases -t android.view.cts.GestureDetectorTest

Change-Id: I22a5d1c162885d08ee7dfe9deef2aed0ed801d16
Signed-off-by: default avatarhuyuxin <huyuxin@xiaomi.corp-partner.google.com>
parent b37c41d3
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -653,7 +653,7 @@ public class GestureDetector {
                break;

            case MotionEvent.ACTION_MOVE:
                if (mInLongPress || mInContextClick) {
                if ((mCurrentDownEvent == null) || mInLongPress || mInContextClick) {
                    break;
                }

@@ -736,6 +736,9 @@ public class GestureDetector {
                break;

            case MotionEvent.ACTION_UP:
                if (mCurrentDownEvent == null) {
                    break;
                }
                mStillDown = false;
                MotionEvent currentUpEvent = MotionEvent.obtain(ev);
                if (mIsDoubleTapping) {