From 1383da0cd4763091d33a74b200dde88eb878474a Mon Sep 17 00:00:00 2001 From: Eghosa Ewansiha-Vlachavas Date: Thu, 16 Nov 2023 16:00:14 +0000 Subject: 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 --- .../wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java | 5 +++++ 1 file changed, 5 insertions(+) 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); -- cgit v1.2.3-59-g8ed1b