Merge "Check taskbar stash state for hover only on hover events." into udc-qpr-dev

This commit is contained in:
Pat Manning
2023-08-21 18:18:10 +00:00
committed by Android (Google) Code Review
3 changed files with 29 additions and 15 deletions
@@ -15,7 +15,6 @@
*/ */
package com.android.quickstep.inputconsumers; package com.android.quickstep.inputconsumers;
import static android.view.MotionEvent.ACTION_BUTTON_RELEASE;
import static android.view.MotionEvent.INVALID_POINTER_ID; import static android.view.MotionEvent.INVALID_POINTER_ID;
import static com.android.launcher3.MotionEventsUtils.isTrackpadMotionEvent; import static com.android.launcher3.MotionEventsUtils.isTrackpadMotionEvent;
@@ -29,6 +28,7 @@ import android.graphics.PointF;
import android.graphics.Rect; import android.graphics.Rect;
import android.view.GestureDetector; import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener; import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.InputDevice;
import android.view.MotionEvent; import android.view.MotionEvent;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@@ -130,8 +130,8 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer {
public void onMotionEvent(MotionEvent ev) { public void onMotionEvent(MotionEvent ev) {
mLongPressDetector.onTouchEvent(ev); mLongPressDetector.onTouchEvent(ev);
if (mState != STATE_ACTIVE) { if (mState != STATE_ACTIVE) {
boolean isStashedTaskbarHovered = boolean isStashedTaskbarHovered = isMouseEvent(ev)
isStashedTaskbarHovered((int) ev.getX(), (int) ev.getY()); && isStashedTaskbarHovered((int) ev.getX(), (int) ev.getY());
if (!isStashedTaskbarHovered) { if (!isStashedTaskbarHovered) {
mDelegate.onMotionEvent(ev); mDelegate.onMotionEvent(ev);
} }
@@ -229,7 +229,7 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer {
mHasPassedTaskbarNavThreshold = false; mHasPassedTaskbarNavThreshold = false;
mIsInBubbleBarArea = false; mIsInBubbleBarArea = false;
break; break;
case ACTION_BUTTON_RELEASE: case MotionEvent.ACTION_BUTTON_RELEASE:
if (isStashedTaskbarHovered) { if (isStashedTaskbarHovered) {
mOverviewCommandHelper.addCommand(OverviewCommandHelper.TYPE_HOME); mOverviewCommandHelper.addCommand(OverviewCommandHelper.TYPE_HOME);
} }
@@ -342,4 +342,8 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer {
dp.heightPx); dp.heightPx);
return mStashedTaskbarHandleBounds.contains(x, y); return mStashedTaskbarHandleBounds.contains(x, y);
} }
private boolean isMouseEvent(MotionEvent event) {
return event.getSource() == InputDevice.SOURCE_MOUSE;
}
} }
@@ -30,6 +30,7 @@ import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_STASHED_
import android.graphics.Point; import android.graphics.Point;
import android.graphics.Rect; import android.graphics.Rect;
import android.os.SystemClock; import android.os.SystemClock;
import android.view.InputDevice;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.ViewConfiguration; import android.view.ViewConfiguration;
@@ -308,7 +309,8 @@ public final class LaunchedAppState extends Background {
Point stashedTaskbarHintArea = new Point(mLauncher.getRealDisplaySize().x / 2, Point stashedTaskbarHintArea = new Point(mLauncher.getRealDisplaySize().x / 2,
mLauncher.getRealDisplaySize().y - stashedTaskbarBottomEdge - 1); mLauncher.getRealDisplaySize().y - stashedTaskbarBottomEdge - 1);
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_HOVER_ENTER, mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_HOVER_ENTER,
new Point(stashedTaskbarHintArea.x, stashedTaskbarHintArea.y), null); new Point(stashedTaskbarHintArea.x, stashedTaskbarHintArea.y), null,
InputDevice.SOURCE_MOUSE);
mLauncher.getDevice().wait(mStashedTaskbarHintScaleCondition, mLauncher.getDevice().wait(mStashedTaskbarHintScaleCondition,
LauncherInstrumentation.WAIT_TIME_MS); LauncherInstrumentation.WAIT_TIME_MS);
@@ -317,19 +319,21 @@ public final class LaunchedAppState extends Background {
"cursor clicking stashed taskbar to go home")) { "cursor clicking stashed taskbar to go home")) {
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_HOVER_EXIT, mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_HOVER_EXIT,
new Point(stashedTaskbarHintArea.x, stashedTaskbarHintArea.y), new Point(stashedTaskbarHintArea.x, stashedTaskbarHintArea.y),
null); null, InputDevice.SOURCE_MOUSE);
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN,
new Point(stashedTaskbarHintArea.x, stashedTaskbarHintArea.y), new Point(stashedTaskbarHintArea.x, stashedTaskbarHintArea.y),
LauncherInstrumentation.GestureScope.OUTSIDE_WITHOUT_PILFER); LauncherInstrumentation.GestureScope.OUTSIDE_WITHOUT_PILFER,
InputDevice.SOURCE_MOUSE);
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_BUTTON_PRESS, mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_BUTTON_PRESS,
new Point(stashedTaskbarHintArea.x, stashedTaskbarHintArea.y), new Point(stashedTaskbarHintArea.x, stashedTaskbarHintArea.y),
null); null, InputDevice.SOURCE_MOUSE);
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_BUTTON_RELEASE, mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_BUTTON_RELEASE,
new Point(stashedTaskbarHintArea.x, stashedTaskbarHintArea.y), new Point(stashedTaskbarHintArea.x, stashedTaskbarHintArea.y),
null); null, InputDevice.SOURCE_MOUSE);
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_UP, mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_UP,
new Point(stashedTaskbarHintArea.x, stashedTaskbarHintArea.y), new Point(stashedTaskbarHintArea.x, stashedTaskbarHintArea.y),
LauncherInstrumentation.GestureScope.OUTSIDE_WITHOUT_PILFER); LauncherInstrumentation.GestureScope.OUTSIDE_WITHOUT_PILFER,
InputDevice.SOURCE_MOUSE);
return mLauncher.getWorkspace(); return mLauncher.getWorkspace();
} }
@@ -1728,11 +1728,11 @@ public final class LauncherInstrumentation {
} }
private static MotionEvent getMotionEvent(long downTime, long eventTime, int action, private static MotionEvent getMotionEvent(long downTime, long eventTime, int action,
float x, float y) { float x, float y, int source) {
return MotionEvent.obtain(downTime, eventTime, action, 1, return MotionEvent.obtain(downTime, eventTime, action, 1,
new MotionEvent.PointerProperties[] {getPointerProperties(0)}, new MotionEvent.PointerProperties[]{getPointerProperties(0)},
new MotionEvent.PointerCoords[] {getPointerCoords(x, y)}, new MotionEvent.PointerCoords[]{getPointerCoords(x, y)},
0, 0, 1.0f, 1.0f, 0, 0, InputDevice.SOURCE_TOUCHSCREEN, 0); 0, 0, 1.0f, 1.0f, 0, 0, source, 0);
} }
private static MotionEvent.PointerProperties getPointerProperties(int pointerId) { private static MotionEvent.PointerProperties getPointerProperties(int pointerId) {
@@ -1768,6 +1768,12 @@ public final class LauncherInstrumentation {
public void sendPointer(long downTime, long currentTime, int action, Point point, public void sendPointer(long downTime, long currentTime, int action, Point point,
GestureScope gestureScope) { GestureScope gestureScope) {
sendPointer(downTime, currentTime, action, point, gestureScope,
InputDevice.SOURCE_TOUCHSCREEN);
}
public void sendPointer(long downTime, long currentTime, int action, Point point,
GestureScope gestureScope, int source) {
final boolean hasTIS = hasTIS(); final boolean hasTIS = hasTIS();
int pointerCount = mPointerCount; int pointerCount = mPointerCount;
@@ -1867,7 +1873,7 @@ public final class LauncherInstrumentation {
? getTrackpadMotionEvent( ? getTrackpadMotionEvent(
downTime, currentTime, action, point.x, point.y, pointerCount, downTime, currentTime, action, point.x, point.y, pointerCount,
mTrackpadGestureType) mTrackpadGestureType)
: getMotionEvent(downTime, currentTime, action, point.x, point.y); : getMotionEvent(downTime, currentTime, action, point.x, point.y, source);
if (action == MotionEvent.ACTION_BUTTON_PRESS if (action == MotionEvent.ACTION_BUTTON_PRESS
|| action == MotionEvent.ACTION_BUTTON_RELEASE) { || action == MotionEvent.ACTION_BUTTON_RELEASE) {
event.setActionButton(MotionEvent.BUTTON_PRIMARY); event.setActionButton(MotionEvent.BUTTON_PRIMARY);