OSDN Git Service

Check for detached view in drag-related APIs
authorYorke Lee <yorkelee@google.com>
Mon, 13 Jun 2016 18:31:03 +0000 (11:31 -0700)
committerYorke Lee <yorkelee@google.com>
Mon, 13 Jun 2016 18:32:23 +0000 (11:32 -0700)
Bug: 29253539
Change-Id: I26285404ee15bb17e87ac23c67f7c3c6aaa2d968

core/java/android/view/View.java

index 88605db..5f6ee09 100644 (file)
@@ -20538,6 +20538,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
         if (ViewDebug.DEBUG_DRAG) {
             Log.d(VIEW_LOG_TAG, "startDragAndDrop: data=" + data + " flags=" + flags);
         }
+        if (mAttachInfo == null) {
+            Log.w(VIEW_LOG_TAG, "startDragAndDrop called on a detached view.");
+            return false;
+        }
         boolean okay = false;
 
         Point shadowSize = new Point();
@@ -20614,6 +20618,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
         if (ViewDebug.DEBUG_DRAG) {
             Log.d(VIEW_LOG_TAG, "cancelDragAndDrop");
         }
+        if (mAttachInfo == null) {
+            Log.w(VIEW_LOG_TAG, "cancelDragAndDrop called on a detached view.");
+            return;
+        }
         if (mAttachInfo.mDragToken != null) {
             try {
                 mAttachInfo.mSession.cancelDragAndDrop(mAttachInfo.mDragToken);
@@ -20636,6 +20644,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
         if (ViewDebug.DEBUG_DRAG) {
             Log.d(VIEW_LOG_TAG, "updateDragShadow");
         }
+        if (mAttachInfo == null) {
+            Log.w(VIEW_LOG_TAG, "updateDragShadow called on a detached view.");
+            return;
+        }
         if (mAttachInfo.mDragToken != null) {
             try {
                 Canvas canvas = mAttachInfo.mDragSurface.lockCanvas(null);