From 65e60920b8cdcbf750b32e99038fa3e9ee56d414 Mon Sep 17 00:00:00 2001 From: Ats Jenk Date: Wed, 8 Jan 2025 15:54:19 -0800 Subject: [PATCH] Use down and up event diff for bubble bar click When determining if a touch event on bubble bar area is a click, check the time diff between receiving ACTION_DOWN and ACTION_UP motion events. This matches with how the click handling is implemented in View.java. Bug: 385928447 Test: tap on bubble bar to expand it, long-press on bubble bar to move Test: atest PlatformScenarioTests:android.platform.test.scenario.sysui.bubble.ShowMultipleBubblesAndSwitchTest Flag: com.android.wm.shell.enable_bubble_bar Change-Id: I5a4a6605adf08f21b28b017cb6edfcb7b898a762 --- .../inputconsumers/BubbleBarInputConsumer.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/quickstep/src/com/android/quickstep/inputconsumers/BubbleBarInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/BubbleBarInputConsumer.java index 390d097d0e..b2e7015fb4 100644 --- a/quickstep/src/com/android/quickstep/inputconsumers/BubbleBarInputConsumer.java +++ b/quickstep/src/com/android/quickstep/inputconsumers/BubbleBarInputConsumer.java @@ -57,6 +57,7 @@ public class BubbleBarInputConsumer implements InputConsumer { private final int mTouchSlop; private final PointF mDownPos = new PointF(); private final PointF mLastPos = new PointF(); + private long mDownTime; private final long mTimeForLongPress; private int mActivePointerId = INVALID_POINTER_ID; @@ -81,6 +82,7 @@ public class BubbleBarInputConsumer implements InputConsumer { final int action = ev.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: + mDownTime = System.currentTimeMillis(); mActivePointerId = ev.getPointerId(0); mDownPos.set(ev.getX(), ev.getY()); mLastPos.set(mDownPos); @@ -120,13 +122,15 @@ public class BubbleBarInputConsumer implements InputConsumer { } break; case MotionEvent.ACTION_UP: + long tapTime = System.currentTimeMillis() - mDownTime; boolean swipeUpOnBubbleHandle = mBubbleBarSwipeController != null && mBubbleBarSwipeController.isSwipeGesture(); // Anything less than a long-press is a tap - boolean isWithinTapTime = ev.getEventTime() - ev.getDownTime() <= mTimeForLongPress; + boolean isWithinTapTime = tapTime <= mTimeForLongPress; Log.d(TAG, "ACTION_UP swipeUp=" + swipeUpOnBubbleHandle + " isInTapTime=" - + isWithinTapTime + " passedTouchSlop=" + mPassedTouchSlop - + " stashedOrCollapsedOnDown=" + mStashedOrCollapsedOnDown); + + isWithinTapTime + " tapTime=" + tapTime + " passedTouchSlop=" + + mPassedTouchSlop + " stashedOrCollapsedOnDown=" + + mStashedOrCollapsedOnDown); if (isWithinTapTime && !swipeUpOnBubbleHandle && !mPassedTouchSlop && mStashedOrCollapsedOnDown) { Log.d(TAG, "ACTION_UP showing bubble bar"); @@ -153,6 +157,7 @@ public class BubbleBarInputConsumer implements InputConsumer { } mPassedTouchSlop = false; mPilfered = false; + mDownTime = 0; } private boolean isCollapsed() {