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
This commit is contained in:
Ats Jenk committed 2025-01-09 08:58:54 -08:00
1 parent c2012f23d3
commit 65e60920b8
1 file changed
+8 -3
@@ -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() {