OSDN Git Service

Revert "Implement View.cancelDrag"
authorVladislav Kaznacheev <kaznacheev@google.com>
Thu, 19 Nov 2015 22:20:06 +0000 (22:20 +0000)
committerVladislav Kaznacheev <kaznacheev@google.com>
Thu, 19 Nov 2015 22:20:06 +0000 (22:20 +0000)
This reverts commit 93cf731b26e2ab4db49bd80f60675b03e40512f3.

This is required because adding View.cancelDrag conflicts with existing app code.

Change-Id: I323fc5d2144266781d3168fe033c53cb5b37050e

api/current.txt
api/system-current.txt
core/java/android/view/IWindowSession.aidl
core/java/android/view/View.java
core/java/android/view/ViewRootImpl.java
services/core/java/com/android/server/wm/Session.java

index 429b117..e7627f7 100644 (file)
@@ -36238,7 +36238,6 @@ package android.view {
     method public boolean canResolveTextDirection();
     method public boolean canScrollHorizontally(int);
     method public boolean canScrollVertically(int);
-    method public final void cancelDrag();
     method public void cancelLongPress();
     method public final void cancelPendingInputEvents();
     method public boolean checkInputConnectionProxy(android.view.View);
index 6d53b3f..203df90 100644 (file)
@@ -38559,7 +38559,6 @@ package android.view {
     method public boolean canResolveTextDirection();
     method public boolean canScrollHorizontally(int);
     method public boolean canScrollVertically(int);
-    method public final void cancelDrag();
     method public void cancelLongPress();
     method public final void cancelPendingInputEvents();
     method public boolean checkInputConnectionProxy(android.view.View);
index f81b5d0..3fc70cc 100644 (file)
@@ -186,11 +186,6 @@ interface IWindowSession {
        void reportDropResult(IWindow window, boolean consumed);
 
     /**
-     * Cancel a drag operation.
-     */
-    void cancelDrag(IBinder dragToken);
-
-    /**
      * Tell the OS that we've just dragged into a View that is willing to accept the drop
      */
     void dragRecipientEntered(IWindow window);
index 30408c6..de4d439 100644 (file)
@@ -19905,11 +19905,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
         }
         Surface surface = new Surface();
         try {
-            mAttachInfo.mDragToken = mAttachInfo.mSession.prepareDrag(mAttachInfo.mWindow,
+            IBinder token = mAttachInfo.mSession.prepareDrag(mAttachInfo.mWindow,
                     flags, shadowSize.x, shadowSize.y, surface);
-            if (ViewDebug.DEBUG_DRAG) Log.d(VIEW_LOG_TAG, "prepareDrag returned token="
-                    + mAttachInfo.mDragToken + " surface=" + surface);
-            if (mAttachInfo.mDragToken != null) {
+            if (ViewDebug.DEBUG_DRAG) Log.d(VIEW_LOG_TAG, "prepareDrag returned token=" + token
+                    + " surface=" + surface);
+            if (token != null) {
                 Canvas canvas = surface.lockCanvas(null);
                 try {
                     canvas.drawColor(0, PorterDuff.Mode.CLEAR);
@@ -19926,7 +19926,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                 // repurpose 'shadowSize' for the last touch point
                 root.getLastTouchPoint(shadowSize);
 
-                okay = mAttachInfo.mSession.performDrag(mAttachInfo.mWindow, mAttachInfo.mDragToken,
+                okay = mAttachInfo.mSession.performDrag(mAttachInfo.mWindow, token,
                         shadowSize.x, shadowSize.y,
                         shadowTouchPoint.x, shadowTouchPoint.y, data);
                 if (ViewDebug.DEBUG_DRAG) Log.d(VIEW_LOG_TAG, "performDrag returned " + okay);
@@ -19943,22 +19943,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
         return okay;
     }
 
-    public final void cancelDrag() {
-        if (ViewDebug.DEBUG_DRAG) {
-            Log.d(VIEW_LOG_TAG, "cancelDrag");
-        }
-        if (mAttachInfo.mDragToken != null) {
-            try {
-                mAttachInfo.mSession.cancelDrag(mAttachInfo.mDragToken);
-            } catch (Exception e) {
-                Log.e(VIEW_LOG_TAG, "Unable to cancel drag", e);
-            }
-            mAttachInfo.mDragToken = null;
-        } else {
-            Log.e(VIEW_LOG_TAG, "No active drag to cancel");
-        }
-    }
-
     /**
      * Starts a move from {startX, startY}, the amount of the movement will be the offset
      * between {startX, startY} and the new cursor positon.
@@ -22237,11 +22221,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
         View mViewRequestingLayout;
 
         /**
-         * Used to track the identity of the current drag operation.
-         */
-        IBinder mDragToken;
-
-        /**
          * Creates a new set of attachment information with the specified
          * events handler and thread.
          *
index f1d9f1a..cd9dd97 100644 (file)
@@ -5307,10 +5307,10 @@ public final class ViewRootImpl implements ViewParent,
                     }
                 }
 
-                // When the drag operation ends, reset drag-related state
+                // When the drag operation ends, release any local state object
+                // that may have been in use
                 if (what == DragEvent.ACTION_DRAG_ENDED) {
                     setLocalDragState(null);
-                    mAttachInfo.mDragToken = null;
                 }
             }
         }
index b85a692..1caeca0 100644 (file)
@@ -401,32 +401,6 @@ final class Session extends IWindowSession.Stub
         }
     }
 
-    public void cancelDrag(IBinder dragToken) {
-        if (WindowManagerService.DEBUG_DRAG) {
-            Slog.d(WindowManagerService.TAG, "cancel drag");
-        }
-
-        synchronized (mService.mWindowMap) {
-            long ident = Binder.clearCallingIdentity();
-            try {
-                if (mService.mDragState == null) {
-                    Slog.w(WindowManagerService.TAG, "cancelDrag() without prepareDrag()");
-                    throw new IllegalStateException("cancelDrag() without prepareDrag()");
-                }
-
-                if (mService.mDragState.mToken != dragToken) {
-                    Slog.w(WindowManagerService.TAG, "cancelDrag() does not match prepareDrag()");
-                    throw new IllegalStateException("cancelDrag() does not match prepareDrag()");
-                }
-
-                mService.mDragState.mDragResult = false;
-                mService.mDragState.endDragLw();
-            } finally {
-                Binder.restoreCallingIdentity(ident);
-            }
-        }
-    }
-
     public void dragRecipientEntered(IWindow window) {
         if (WindowManagerService.DEBUG_DRAG) {
             Slog.d(WindowManagerService.TAG, "Drag into new candidate view @ " + window.asBinder());