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
This commit is contained in:
Arthur Hung
2022-06-06 08:03:52 +00:00
parent 08a70e40fb
commit 2d6b7b0af1

View File

@@ -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);
}