Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3e9d5105 authored by Daichi Hirono's avatar Daichi Hirono
Browse files

Add a flag to cancelDragAndDrop to skip animation

When running cancel animation for drag shadow image, the system cannot
start another drag operation, which is problematic when the system would
start the other drag operation quickly.

Bug: 130313958
Test: Cancel drag operation by calling cancelDragAndDrop
Change-Id: I5d6650a0ce9a4cd80bbdb1beabc9e514349ccadc
parent 7deafd41
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -187,8 +187,10 @@ interface IWindowSession {

    /**
     * Cancel the current drag operation.
     * skipAnimation is 'true' when it should skip the drag cancel animation which brings the drag
     * shadow image back to the drag start position.
     */
    void cancelDragAndDrop(IBinder dragToken);
    void cancelDragAndDrop(IBinder dragToken, boolean skipAnimation);

    /**
     * Tell the OS that we've just dragged into a View that is willing to accept the drop
+1 −1
Original line number Diff line number Diff line
@@ -25456,7 +25456,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        }
        if (mAttachInfo.mDragToken != null) {
            try {
                mAttachInfo.mSession.cancelDragAndDrop(mAttachInfo.mDragToken);
                mAttachInfo.mSession.cancelDragAndDrop(mAttachInfo.mDragToken, false);
            } catch (Exception e) {
                Log.e(VIEW_LOG_TAG, "Unable to cancel drag", e);
            }
+2 −2
Original line number Diff line number Diff line
@@ -236,7 +236,7 @@ class DragDropController {
        }
    }

    void cancelDragAndDrop(IBinder dragToken) {
    void cancelDragAndDrop(IBinder dragToken, boolean skipAnimation) {
        if (DEBUG_DRAG) {
            Slog.d(TAG_WM, "cancelDragAndDrop");
        }
@@ -257,7 +257,7 @@ class DragDropController {
                }

                mDragState.mDragResult = false;
                mDragState.cancelDragLocked();
                mDragState.cancelDragLocked(skipAnimation);
            }
        } finally {
            mCallback.get().postCancelDragAndDrop();
+4 −3
Original line number Diff line number Diff line
@@ -475,15 +475,16 @@ class DragState {
        closeLocked();
    }

    void cancelDragLocked() {
    void cancelDragLocked(boolean skipAnimation) {
        if (mAnimator != null) {
            return;
        }
        if (!mDragInProgress) {
            // This can happen if an app invokes Session#cancelDragAndDrop before
        if (!mDragInProgress || skipAnimation) {
            // mDragInProgress is false if an app invokes Session#cancelDragAndDrop before
            // Session#performDrag. Reset the drag state without playing the cancel animation
            // because H.DRAG_START_TIMEOUT may be sent to WindowManagerService, which will cause
            // DragState#reset() while playing the cancel animation.
            // skipAnimation is true when a caller requests to skip the drag cancel animation.
            closeLocked();
            return;
        }
+2 −2
Original line number Diff line number Diff line
@@ -283,10 +283,10 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
    }

    @Override
    public void cancelDragAndDrop(IBinder dragToken) {
    public void cancelDragAndDrop(IBinder dragToken, boolean skipAnimation) {
        final long ident = Binder.clearCallingIdentity();
        try {
            mDragDropController.cancelDragAndDrop(dragToken);
            mDragDropController.cancelDragAndDrop(dragToken, skipAnimation);
        } finally {
            Binder.restoreCallingIdentity(ident);
        }
Loading