summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/wm/DragDropController.java8
-rw-r--r--services/core/java/com/android/server/wm/DragInputEventReceiver.java6
-rw-r--r--services/core/java/com/android/server/wm/DragState.java22
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/DragDropControllerTests.java31
4 files changed, 43 insertions, 24 deletions
diff --git a/services/core/java/com/android/server/wm/DragDropController.java b/services/core/java/com/android/server/wm/DragDropController.java
index 258a87eae196..3c60d8296577 100644
--- a/services/core/java/com/android/server/wm/DragDropController.java
+++ b/services/core/java/com/android/server/wm/DragDropController.java
@@ -289,7 +289,8 @@ class DragDropController {
transaction.setAlpha(surfaceControl, mDragState.mOriginalAlpha);
transaction.show(surfaceControl);
displayContent.reparentToOverlay(transaction, surfaceControl);
- mDragState.updateDragSurfaceLocked(true, touchX, touchY);
+ mDragState.updateDragSurfaceLocked(true /* keepHandling */,
+ displayContent.getDisplayId(), touchX, touchY);
if (SHOW_LIGHT_TRANSACTIONS) {
Slog.i(TAG_WM, "<<< CLOSE TRANSACTION performDrag");
}
@@ -483,10 +484,11 @@ class DragDropController {
* Handles motion events.
* @param keepHandling Whether if the drag operation is continuing or this is the last motion
* event.
+ * @param displayId id of the display the X,Y coordinate is n.
* @param newX X coordinate value in dp in the screen coordinate
* @param newY Y coordinate value in dp in the screen coordinate
*/
- void handleMotionEvent(boolean keepHandling, float newX, float newY) {
+ void handleMotionEvent(boolean keepHandling, int displayId, float newX, float newY) {
synchronized (mService.mGlobalLock) {
if (!dragDropActiveLocked()) {
// The drag has ended but the clean-up message has not been processed by
@@ -495,7 +497,7 @@ class DragDropController {
return;
}
- mDragState.updateDragSurfaceLocked(keepHandling, newX, newY);
+ mDragState.updateDragSurfaceLocked(keepHandling, displayId, newX, newY);
}
}
diff --git a/services/core/java/com/android/server/wm/DragInputEventReceiver.java b/services/core/java/com/android/server/wm/DragInputEventReceiver.java
index 5372d8b6e796..8f4548fa4fcb 100644
--- a/services/core/java/com/android/server/wm/DragInputEventReceiver.java
+++ b/services/core/java/com/android/server/wm/DragInputEventReceiver.java
@@ -22,13 +22,13 @@ import static android.view.MotionEvent.ACTION_DOWN;
import static android.view.MotionEvent.ACTION_MOVE;
import static android.view.MotionEvent.ACTION_UP;
import static android.view.MotionEvent.BUTTON_STYLUS_PRIMARY;
+
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_DRAG;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import android.os.Looper;
import android.util.Slog;
import android.view.InputChannel;
-import android.view.InputDevice;
import android.view.InputEvent;
import android.view.InputEventReceiver;
import android.view.MotionEvent;
@@ -63,6 +63,7 @@ class DragInputEventReceiver extends InputEventReceiver {
return;
}
final MotionEvent motionEvent = (MotionEvent) event;
+ final int displayId = motionEvent.getDisplayId();
final float newX = motionEvent.getRawX();
final float newY = motionEvent.getRawY();
final boolean isStylusButtonDown =
@@ -102,7 +103,8 @@ class DragInputEventReceiver extends InputEventReceiver {
return;
}
- mDragDropController.handleMotionEvent(!mMuteInput /* keepHandling */, newX, newY);
+ mDragDropController.handleMotionEvent(!mMuteInput /* keepHandling */, displayId, newX,
+ newY);
handled = true;
} catch (Exception e) {
Slog.e(TAG_WM, "Exception caught by drag handleMotion", e);
diff --git a/services/core/java/com/android/server/wm/DragState.java b/services/core/java/com/android/server/wm/DragState.java
index 1c4e487d2e7e..add812722d20 100644
--- a/services/core/java/com/android/server/wm/DragState.java
+++ b/services/core/java/com/android/server/wm/DragState.java
@@ -685,12 +685,21 @@ class DragState {
mAnimator = createCancelAnimationLocked();
}
- void updateDragSurfaceLocked(boolean keepHandling, float x, float y) {
+ /**
+ * Updates the position of the drag surface.
+ *
+ * @param keepHandling whether to keep handling the drag.
+ * @param displayId the display ID of the drag surface.
+ * @param displayX the x-coordinate of the drag surface in the display's coordinate frame.
+ * @param displayY the y-coordinate of the drag surface in the display's coordinate frame.
+ */
+ void updateDragSurfaceLocked(boolean keepHandling, int displayId, float displayX,
+ float displayY) {
if (mAnimator != null) {
return;
}
- mCurrentX = x;
- mCurrentY = y;
+ mCurrentX = displayX;
+ mCurrentY = displayY;
if (!keepHandling) {
return;
@@ -700,9 +709,10 @@ class DragState {
if (SHOW_LIGHT_TRANSACTIONS) {
Slog.i(TAG_WM, ">>> OPEN TRANSACTION notifyMoveLocked");
}
- mTransaction.setPosition(mSurfaceControl, x - mThumbOffsetX, y - mThumbOffsetY).apply();
- ProtoLog.i(WM_SHOW_TRANSACTIONS, "DRAG %s: pos=(%d,%d)", mSurfaceControl,
- (int) (x - mThumbOffsetX), (int) (y - mThumbOffsetY));
+ mTransaction.setPosition(mSurfaceControl, displayX - mThumbOffsetX,
+ displayY - mThumbOffsetY).apply();
+ ProtoLog.i(WM_SHOW_TRANSACTIONS, "DRAG %s: displayId=%d, pos=(%d,%d)", mSurfaceControl,
+ displayId, (int) (displayX - mThumbOffsetX), (int) (displayY - mThumbOffsetY));
}
/**
diff --git a/services/tests/wmtests/src/com/android/server/wm/DragDropControllerTests.java b/services/tests/wmtests/src/com/android/server/wm/DragDropControllerTests.java
index 429a396ad997..de4b6fac7abf 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DragDropControllerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DragDropControllerTests.java
@@ -150,8 +150,8 @@ public class DragDropControllerTests extends WindowTestsBase {
mProcess).build();
// Use a new TestIWindow so we don't collect events for other windows
- final WindowState window = createWindow(null, TYPE_BASE_APPLICATION, activity, name,
- ownerId, false, new TestIWindow());
+ final WindowState window = newWindowBuilder(name, TYPE_BASE_APPLICATION).setWindowToken(
+ activity).setOwnerId(ownerId).setClientWindow(new TestIWindow()).build();
InputChannel channel = new InputChannel();
window.openInputChannel(channel);
window.mHasSurface = true;
@@ -249,7 +249,7 @@ public class DragDropControllerTests extends WindowTestsBase {
mTarget.mDeferDragStateClosed = true;
mTarget.reportDropWindow(mWindow.mInputChannelToken, 0, 0);
// Verify the drop event includes the drag surface
- mTarget.handleMotionEvent(false, 0, 0);
+ mTarget.handleMotionEvent(false, mWindow.getDisplayId(), 0, 0);
final DragEvent dropEvent = dragEvents.get(dragEvents.size() - 1);
assertTrue(dropEvent.getDragSurface() != null);
@@ -296,7 +296,7 @@ public class DragDropControllerTests extends WindowTestsBase {
0).getClipData().willParcelWithActivityInfo());
mTarget.reportDropWindow(globalInterceptWindow.mInputChannelToken, 0, 0);
- mTarget.handleMotionEvent(false, 0, 0);
+ mTarget.handleMotionEvent(false, globalInterceptWindow.getDisplayId(), 0, 0);
mToken = globalInterceptWindow.mClient.asBinder();
// Verify the drop event is only sent for the global intercept window
@@ -334,8 +334,8 @@ public class DragDropControllerTests extends WindowTestsBase {
try {
mTarget.mDeferDragStateClosed = true;
mTarget.reportDropWindow(mWindow.mInputChannelToken, 0, 0);
- // // Verify the drop event does not have the drag flags
- mTarget.handleMotionEvent(false, 0, 0);
+ // Verify the drop event does not have the drag flags
+ mTarget.handleMotionEvent(false, mWindow.getDisplayId(), 0, 0);
final DragEvent dropEvent = dragEvents.get(dragEvents.size() - 1);
assertTrue(dropEvent.getDragFlags() == (View.DRAG_FLAG_GLOBAL
| View.DRAG_FLAG_START_INTENT_SENDER_ON_UNHANDLED_DRAG));
@@ -520,7 +520,7 @@ public class DragDropControllerTests extends WindowTestsBase {
// Verify after consuming that the drag surface is relinquished
mTarget.reportDropWindow(otherWindow.mInputChannelToken, 0, 0);
- mTarget.handleMotionEvent(false, 0, 0);
+ mTarget.handleMotionEvent(false, otherWindow.getDisplayId(), 0, 0);
mToken = otherWindow.mClient.asBinder();
mTarget.reportDropResult(otherIWindow, true);
@@ -551,7 +551,7 @@ public class DragDropControllerTests extends WindowTestsBase {
// Verify after consuming that the drag surface is relinquished
mTarget.reportDropWindow(otherWindow.mInputChannelToken, 0, 0);
- mTarget.handleMotionEvent(false, 0, 0);
+ mTarget.handleMotionEvent(false, otherWindow.getDisplayId(), 0, 0);
mToken = otherWindow.mClient.asBinder();
mTarget.reportDropResult(otherIWindow, false);
@@ -586,7 +586,8 @@ public class DragDropControllerTests extends WindowTestsBase {
ClipData.newPlainText("label", "Test"), () -> {
// Trigger an unhandled drop and verify the global drag listener was called
mTarget.reportDropWindow(mWindow.mInputChannelToken, invalidXY, invalidXY);
- mTarget.handleMotionEvent(false /* keepHandling */, invalidXY, invalidXY);
+ mTarget.handleMotionEvent(false /* keepHandling */, mWindow.getDisplayId(),
+ invalidXY, invalidXY);
mTarget.reportDropResult(mWindow.mClient, false);
mTarget.onUnhandledDropCallback(true);
mToken = null;
@@ -610,7 +611,8 @@ public class DragDropControllerTests extends WindowTestsBase {
ClipData.newPlainText("label", "Test"), () -> {
// Trigger an unhandled drop and verify the global drag listener was called
mTarget.reportDropWindow(mock(IBinder.class), invalidXY, invalidXY);
- mTarget.handleMotionEvent(false /* keepHandling */, invalidXY, invalidXY);
+ mTarget.handleMotionEvent(false /* keepHandling */, mWindow.getDisplayId(),
+ invalidXY, invalidXY);
mTarget.onUnhandledDropCallback(true);
mToken = null;
try {
@@ -632,7 +634,8 @@ public class DragDropControllerTests extends WindowTestsBase {
startDrag(View.DRAG_FLAG_GLOBAL, ClipData.newPlainText("label", "Test"), () -> {
// Trigger an unhandled drop and verify the global drag listener was not called
mTarget.reportDropWindow(mock(IBinder.class), invalidXY, invalidXY);
- mTarget.handleMotionEvent(false /* keepHandling */, invalidXY, invalidXY);
+ mTarget.handleMotionEvent(false /* keepHandling */, mDisplayContent.getDisplayId(),
+ invalidXY, invalidXY);
mToken = null;
try {
verify(listener, never()).onUnhandledDrop(any(), any());
@@ -654,7 +657,8 @@ public class DragDropControllerTests extends WindowTestsBase {
ClipData.newPlainText("label", "Test"), () -> {
// Trigger an unhandled drop and verify the global drag listener was called
mTarget.reportDropWindow(mock(IBinder.class), invalidXY, invalidXY);
- mTarget.handleMotionEvent(false /* keepHandling */, invalidXY, invalidXY);
+ mTarget.handleMotionEvent(false /* keepHandling */,
+ mDisplayContent.getDisplayId(), invalidXY, invalidXY);
// Verify that the unhandled drop listener callback timeout has been scheduled
final Handler handler = mTarget.getHandler();
@@ -673,7 +677,8 @@ public class DragDropControllerTests extends WindowTestsBase {
private void doDragAndDrop(int flags, ClipData data, float dropX, float dropY) {
startDrag(flags, data, () -> {
mTarget.reportDropWindow(mWindow.mInputChannelToken, dropX, dropY);
- mTarget.handleMotionEvent(false /* keepHandling */, dropX, dropY);
+ mTarget.handleMotionEvent(false /* keepHandling */, mWindow.getDisplayId(), dropX,
+ dropY);
mToken = mWindow.mClient.asBinder();
});
}