diff --git a/quickstep/src/com/android/quickstep/inputconsumers/TaskbarUnstashInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/TaskbarUnstashInputConsumer.java index 4b13cd13aa..0e90e504d0 100644 --- a/quickstep/src/com/android/quickstep/inputconsumers/TaskbarUnstashInputConsumer.java +++ b/quickstep/src/com/android/quickstep/inputconsumers/TaskbarUnstashInputConsumer.java @@ -15,7 +15,6 @@ */ package com.android.quickstep.inputconsumers; -import static android.view.MotionEvent.ACTION_BUTTON_RELEASE; import static android.view.MotionEvent.INVALID_POINTER_ID; import static com.android.launcher3.MotionEventsUtils.isTrackpadMotionEvent; @@ -29,6 +28,7 @@ import android.graphics.PointF; import android.graphics.Rect; import android.view.GestureDetector; import android.view.GestureDetector.SimpleOnGestureListener; +import android.view.InputDevice; import android.view.MotionEvent; import androidx.annotation.Nullable; @@ -130,8 +130,8 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer { public void onMotionEvent(MotionEvent ev) { mLongPressDetector.onTouchEvent(ev); if (mState != STATE_ACTIVE) { - boolean isStashedTaskbarHovered = - isStashedTaskbarHovered((int) ev.getX(), (int) ev.getY()); + boolean isStashedTaskbarHovered = isMouseEvent(ev) + && isStashedTaskbarHovered((int) ev.getX(), (int) ev.getY()); if (!isStashedTaskbarHovered) { mDelegate.onMotionEvent(ev); } @@ -229,7 +229,7 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer { mHasPassedTaskbarNavThreshold = false; mIsInBubbleBarArea = false; break; - case ACTION_BUTTON_RELEASE: + case MotionEvent.ACTION_BUTTON_RELEASE: if (isStashedTaskbarHovered) { mOverviewCommandHelper.addCommand(OverviewCommandHelper.TYPE_HOME); } @@ -342,4 +342,8 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer { dp.heightPx); return mStashedTaskbarHandleBounds.contains(x, y); } + + private boolean isMouseEvent(MotionEvent event) { + return event.getSource() == InputDevice.SOURCE_MOUSE; + } } diff --git a/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java b/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java index 9b4d273647..a05b4997a9 100644 --- a/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java +++ b/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java @@ -30,6 +30,7 @@ import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_STASHED_ import android.graphics.Point; import android.graphics.Rect; import android.os.SystemClock; +import android.view.InputDevice; import android.view.MotionEvent; import android.view.ViewConfiguration; @@ -308,7 +309,8 @@ public final class LaunchedAppState extends Background { Point stashedTaskbarHintArea = new Point(mLauncher.getRealDisplaySize().x / 2, mLauncher.getRealDisplaySize().y - stashedTaskbarBottomEdge - 1); 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, LauncherInstrumentation.WAIT_TIME_MS); @@ -317,19 +319,21 @@ public final class LaunchedAppState extends Background { "cursor clicking stashed taskbar to go home")) { mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_HOVER_EXIT, new Point(stashedTaskbarHintArea.x, stashedTaskbarHintArea.y), - null); + null, InputDevice.SOURCE_MOUSE); mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, 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, new Point(stashedTaskbarHintArea.x, stashedTaskbarHintArea.y), - null); + null, InputDevice.SOURCE_MOUSE); mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_BUTTON_RELEASE, new Point(stashedTaskbarHintArea.x, stashedTaskbarHintArea.y), - null); + null, InputDevice.SOURCE_MOUSE); mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_UP, new Point(stashedTaskbarHintArea.x, stashedTaskbarHintArea.y), - LauncherInstrumentation.GestureScope.OUTSIDE_WITHOUT_PILFER); + LauncherInstrumentation.GestureScope.OUTSIDE_WITHOUT_PILFER, + InputDevice.SOURCE_MOUSE); return mLauncher.getWorkspace(); } diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 940ea3b6c9..262d5ff2b8 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -1728,11 +1728,11 @@ public final class LauncherInstrumentation { } 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, - new MotionEvent.PointerProperties[] {getPointerProperties(0)}, - new MotionEvent.PointerCoords[] {getPointerCoords(x, y)}, - 0, 0, 1.0f, 1.0f, 0, 0, InputDevice.SOURCE_TOUCHSCREEN, 0); + new MotionEvent.PointerProperties[]{getPointerProperties(0)}, + new MotionEvent.PointerCoords[]{getPointerCoords(x, y)}, + 0, 0, 1.0f, 1.0f, 0, 0, source, 0); } 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, 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(); int pointerCount = mPointerCount; @@ -1867,7 +1873,7 @@ public final class LauncherInstrumentation { ? getTrackpadMotionEvent( downTime, currentTime, action, point.x, point.y, pointerCount, mTrackpadGestureType) - : getMotionEvent(downTime, currentTime, action, point.x, point.y); + : getMotionEvent(downTime, currentTime, action, point.x, point.y, source); if (action == MotionEvent.ACTION_BUTTON_PRESS || action == MotionEvent.ACTION_BUTTON_RELEASE) { event.setActionButton(MotionEvent.BUTTON_PRIMARY);