summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Arthur Hung <arthurhung@google.com> 2022-06-06 08:03:52 +0000
committer Arthur Hung <arthurhung@google.com> 2022-06-06 08:03:52 +0000
commit2d6b7b0af1b2ba930e267a403af6e4c581ac9ad8 (patch)
tree193f3c00445a64b5a333a7952993875c41e39d7c
parent08a70e40fb254ed27ca7c31cf591ea368865e92f (diff)
Fix CrossAppDragAndDropTests failed
Currently, InputDispatcher could report the invalid drop target when receving an unexpected cancel or the drag window has gone. In other hand,`View.cancelDragAndDrop` could directly cancel the current drag state cause `reportDropWindow` access the invalid state. We should check the valid drag state when called `reportDropWindow`. Test: atest DragDropControllerTests CrossAppDragAndDropTests Bug: 234889646 Change-Id: Ibe9c94d2ff4471bfc5ff32d62e4701ef9a0d75d0
-rw-r--r--services/core/java/com/android/server/wm/DragDropController.java5
1 files changed, 5 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/wm/DragDropController.java b/services/core/java/com/android/server/wm/DragDropController.java
index 4ce058153003..aa8ebf763bec 100644
--- a/services/core/java/com/android/server/wm/DragDropController.java
+++ b/services/core/java/com/android/server/wm/DragDropController.java
@@ -342,6 +342,11 @@ class DragDropController {
}
void reportDropWindow(IBinder token, float x, float y) {
+ if (mDragState == null) {
+ Slog.w(TAG_WM, "Drag state is closed.");
+ return;
+ }
+
synchronized (mService.mGlobalLock) {
mDragState.reportDropWindowLock(token, x, y);
}