diff options
| author | 2023-11-16 16:00:14 +0000 | |
|---|---|---|
| committer | 2023-11-16 16:44:44 +0000 | |
| commit | 1383da0cd4763091d33a74b200dde88eb878474a (patch) | |
| tree | e86e1d5f029c72f82217f873cc070a8e77b3d9ad | |
| parent | 22daeee1fae2d38179af79299c54c85e86f8dbae (diff) | |
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
| -rw-r--r-- | libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java | 5 |
1 files changed, 5 insertions, 0 deletions
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 e206039aa6bf..a659694c7dad 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 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { 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); |