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
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/BubbleBarInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/BubbleBarInputConsumer.java
index 390d097..b2e7015 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/BubbleBarInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/BubbleBarInputConsumer.java
@@ -57,6 +57,7 @@
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 @@
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 @@
}
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 @@
}
mPassedTouchSlop = false;
mPilfered = false;
+ mDownTime = 0;
}
private boolean isCollapsed() {