Report drag success/fail in the DRAG_ENDED message

DragEvent.getResult() returns 'true' if the drop was ultimately accepted;
false otherwise.  The validity of this datum is only guaranteed when the
DragEvent's action verb is ACTION_DRAG_ENDED.

Also fixes the drag-start timeout handling (though the offending app is
not yet officially declared ANR).

Implements bug 3097807

Change-Id: I6908ac628c72ff7d6193d87060d769a559a78d0e
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index ae671b8..ea688ad 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -2506,7 +2506,7 @@
                 final View prevDragView = mCurrentDragView;
 
                 // Now dispatch the drag/drop event
-                mView.dispatchDragEvent(event);
+                boolean result = mView.dispatchDragEvent(event);
 
                 // If we changed apparent drag target, tell the OS about it
                 if (prevDragView != mCurrentDragView) {
@@ -2521,6 +2521,16 @@
                         Slog.e(TAG, "Unable to note drag target change");
                     }
                 }
+
+                // Report the drop result if necessary
+                if (what == DragEvent.ACTION_DROP) {
+                    try {
+                        Log.i(TAG, "Reporting drop result: " + result);
+                        sWindowSession.reportDropResult(mWindow, result);
+                    } catch (RemoteException e) {
+                        Log.e(TAG, "Unable to report drop result");
+                    }
+                }
             }
         }
         event.recycle();