Move drag event to InputDispatcher (5/n)

This CL add 'notifyDropWindow' to tell the policy about the dropping
window has been detected. That could help the drag controller to handle
the drop event and dispatch the clip data to the corresponding client.

Bug: 158242495
Test: atest inputflinger_tests
Change-Id: If7bce072dff5bdacb7eb765f94eb73ed63a58170
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index fe46d17..397a9d7 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -2345,6 +2345,10 @@
         }
     } else if (maskedAction == AMOTION_EVENT_ACTION_UP ||
                maskedAction == AMOTION_EVENT_ACTION_CANCEL) {
+        if (state.dragHoverWindowHandle && maskedAction == AMOTION_EVENT_ACTION_UP) {
+            vec2 local = state.dragHoverWindowHandle->getInfo()->transform.transform(x, y);
+            notifyDropWindowLocked(state.dragHoverWindowHandle->getToken(), local.x, local.y);
+        }
         state.dragWindow = nullptr;
         state.dragHoverWindowHandle = nullptr;
     }
@@ -5302,6 +5306,15 @@
     postCommandLocked(std::move(commandEntry));
 }
 
+void InputDispatcher::notifyDropWindowLocked(const sp<IBinder>& token, float x, float y) {
+    std::unique_ptr<CommandEntry> commandEntry =
+            std::make_unique<CommandEntry>(&InputDispatcher::doNotifyDropWindowLockedInterruptible);
+    commandEntry->newToken = token;
+    commandEntry->x = x;
+    commandEntry->y = y;
+    postCommandLocked(std::move(commandEntry));
+}
+
 void InputDispatcher::onAnrLocked(const sp<Connection>& connection) {
     if (connection == nullptr) {
         LOG_ALWAYS_FATAL("Caller must check for nullness");
@@ -5411,6 +5424,13 @@
     mLock.lock();
 }
 
+void InputDispatcher::doNotifyDropWindowLockedInterruptible(CommandEntry* commandEntry) {
+    sp<IBinder> newToken = commandEntry->newToken;
+    mLock.unlock();
+    mPolicy->notifyDropWindow(newToken, commandEntry->x, commandEntry->y);
+    mLock.lock();
+}
+
 void InputDispatcher::doNotifyNoFocusedWindowAnrLockedInterruptible(CommandEntry* commandEntry) {
     mLock.unlock();