Reset `mShouldClick` on ACTION_CANCEL event so click is not performed
`mShouldClick` is set to true during ACTION_DOWN event. However if
this event is interrupted or cancelled `mShouldClick` remains true so the
click is performed when the ACTION_CANCEL case is caught. Instead we
should rest `mShouldClick` to false if a motion even occurs and is
interrupted. So the click is only performed due to an ACTION_UP event.
Fix: 296921322
Test: manual
Change-Id: I9cac00ad39f1ef589eee116480d293feff4d2a11
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java
index e206039..a659694 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java
@@ -530,6 +530,11 @@
if (mGestureDetector.onTouchEvent(e)) {
return true;
}
+ if (e.getActionMasked() == MotionEvent.ACTION_CANCEL) {
+ // If a motion event is cancelled, reset mShouldClick so a click is not accidentally
+ // performed.
+ mShouldClick = false;
+ }
switch (e.getActionMasked()) {
case MotionEvent.ACTION_DOWN: {
mDragPointerId = e.getPointerId(0);