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: huyuxin <huyuxin@xiaomi.corp-partner.google.com>
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user