Include the local state obj in ACTION_DRAG_STARTED events

Fixes bug 3362502

The underlying cause was that the DragEvent.obtain() variant which
clones an existing event was failing to copy the local state field.

This change also moves the logic for inserting the local state object
into DragEvents about to be dispatched from the Binder incall thread
into the main-thread code sequence.  This is to eliminate any potential
SMP memory coherency issues around drag start vs incoming events
needing to refer to the local state object.

Change-Id: I368e8936dbf8a00b7d5cc19c2ef0101bd75b6b2d
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index 97983ba..2c6ec71 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -228,7 +228,7 @@
     /* Drag/drop */
     ClipDescription mDragDescription;
     View mCurrentDragView;
-    Object mLocalDragState;
+    volatile Object mLocalDragState;
     final PointF mDragPoint = new PointF();
     final PointF mLastTouchPoint = new PointF();
 
@@ -2051,7 +2051,9 @@
         } break;
         case DISPATCH_DRAG_EVENT:
         case DISPATCH_DRAG_LOCATION_EVENT: {
-            handleDragEvent((DragEvent)msg.obj);
+            DragEvent event = (DragEvent)msg.obj;
+            event.mLocalState = mLocalDragState;    // only present when this app called startDrag()
+            handleDragEvent(event);
         } break;
         }
     }
@@ -3133,7 +3135,6 @@
         } else {
             what = DISPATCH_DRAG_EVENT;
         }
-        event.mLocalState = mLocalDragState;    // only present when this app called startDrag()
         Message msg = obtainMessage(what, event);
         sendMessage(msg);
     }