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

Commit 65845f09 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Close mDragState immediately when error"

parents 12f1b7f0 663e9a77
Loading
Loading
Loading
Loading
+65 −61
Original line number Diff line number Diff line
@@ -150,23 +150,24 @@ class DragDropController {
            Slog.d(TAG_WM, "perform drag: win=" + window + " data=" + data);
        }

        if (!mCallback.get().prePerformDrag(window, dragToken, touchSource, touchX, touchY, thumbCenterX,
                thumbCenterY, data)) {
            return false;
        }
        final boolean callbackResult = mCallback.get().prePerformDrag(window, dragToken,
                touchSource, touchX, touchY, thumbCenterX, thumbCenterY, data);
        try {
            synchronized (mService.mWindowMap) {
                if (mDragState == null) {
                    Slog.w(TAG_WM, "No drag prepared");
                    throw new IllegalStateException("performDrag() without prepareDrag()");
                mHandler.removeMessages(MSG_DRAG_START_TIMEOUT, window.asBinder());
                try {
                    if (!callbackResult) {
                        return false;
                    }

                if (dragToken != mDragState.mToken) {
                    Slog.w(TAG_WM, "Performing mismatched drag");
                    throw new IllegalStateException("performDrag() does not match prepareDrag()");
                }
                    Preconditions.checkState(
                            mDragState != null, "performDrag() without prepareDrag()");
                    Preconditions.checkState(
                            mDragState.mToken == dragToken,
                            "performDrag() does not match prepareDrag()");

                final WindowState callingWin = mService.windowForClientLocked(null, window, false);
                    final WindowState callingWin = mService.windowForClientLocked(
                            null, window, false);
                    if (callingWin == null) {
                        Slog.w(TAG_WM, "Bad requesting window " + window);
                        return false;  // !!! TODO: throw here?
@@ -176,8 +177,6 @@ class DragDropController {
                    // the drag initiation (e.g. an alarm window popped up just as the application
                    // called performDrag()

                mHandler.removeMessages(MSG_DRAG_START_TIMEOUT, window.asBinder());

                    // !!! TODO: extract the current touch (x, y) in screen coordinates.  That
                    // will let us eliminate the (touchX,touchY) parameters from the API.

@@ -186,14 +185,15 @@ class DragDropController {

                    final DisplayContent displayContent = callingWin.getDisplayContent();
                    if (displayContent == null) {
                        Slog.w(TAG_WM, "display content is null");
                        return false;
                    }
                Display display = displayContent.getDisplay();

                    final Display display = displayContent.getDisplay();
                    mDragState.register(display);
                    if (!mService.mInputManager.transferTouchFocus(callingWin.mInputChannel,
                            mDragState.getInputChannel())) {
                        Slog.e(TAG_WM, "Unable to transfer touch focus");
                    mDragState.closeLocked();
                        return false;
                    }

@@ -201,7 +201,6 @@ class DragDropController {
                    mDragState.mData = data;
                    mDragState.broadcastDragStartedLocked(touchX, touchY);
                    mDragState.overridePointerIconLocked(touchSource);

                    // remember the thumb offsets for later
                    mDragState.mThumbOffsetX = thumbCenterX;
                    mDragState.mThumbOffsetY = thumbCenterY;
@@ -224,6 +223,11 @@ class DragDropController {
                    }

                    mDragState.notifyLocationLocked(touchX, touchY);
                } finally {
                    if (mDragState != null && !mDragState.isInProgress()) {
                        mDragState.closeLocked();
                    }
                }
            }
            return true;    // success!
        } finally {
+8 −0
Original line number Diff line number Diff line
@@ -568,6 +568,14 @@ class DragState {
        mToken = token;
    }

    /**
     * Returns true if it has sent DRAG_STARTED broadcast out but has not been sent DRAG_END
     * broadcast.
     */
    boolean isInProgress() {
        return mDragInProgress;
    }

    private static DragEvent obtainDragEvent(WindowState win, int action,
            float x, float y, Object localState,
            ClipDescription description, ClipData data,