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

Commit 36ebe4c6 authored by Vladislav Kaznacheev's avatar Vladislav Kaznacheev Committed by Android (Google) Code Review
Browse files

Merge "Expose the desktop location of an unconsumed drag and drop"

parents a2e84601 c7482415
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import android.content.ClipDescription;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.Binder;
import android.os.IBinder;
import android.os.Message;
import android.os.Process;
@@ -52,6 +51,7 @@ class DragState {
    SurfaceControl mSurfaceControl;
    int mFlags;
    IBinder mLocalWin;
    int mPid;
    int mUid;
    ClipData mData;
    ClipDescription mDataDescription;
@@ -270,8 +270,15 @@ class DragState {
            Slog.d(WindowManagerService.TAG, "broadcasting DRAG_ENDED");
        }
        for (WindowState ws : mNotifiedWindows) {
            float x = 0;
            float y = 0;
            if (!mDragResult && (ws.mSession.mPid == mPid)) {
                // Report unconsumed drop location back to the app that started the drag.
                x = mCurrentX;
                y = mCurrentY;
            }
            DragEvent evt = DragEvent.obtain(DragEvent.ACTION_DRAG_ENDED,
                    0, 0, null, null, null, null, mDragResult);
                    x, y, null, null, null, null, mDragResult);
            try {
                ws.mClient.dispatchDragEvent(evt);
            } catch (RemoteException e) {
+10 −4
Original line number Diff line number Diff line
@@ -701,7 +701,7 @@ public class WindowManagerService extends IWindowManager.Stub
                            if (DEBUG_DRAG) Slog.d(TAG, "Button no longer pressed; dropping at "
                                    + newX + "," + newY);
                            synchronized (mWindowMap) {
                                endDrag = completeDrop(newX, newY);
                                endDrag = completeDropLw(newX, newY);
                            }
                        } else {
                            synchronized (mWindowMap) {
@@ -715,7 +715,7 @@ public class WindowManagerService extends IWindowManager.Stub
                        if (DEBUG_DRAG) Slog.d(TAG, "Got UP on move channel; dropping at "
                                + newX + "," + newY);
                        synchronized (mWindowMap) {
                            endDrag = completeDrop(newX, newY);
                            endDrag = completeDropLw(newX, newY);
                        }
                    } break;

@@ -745,11 +745,15 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    private boolean completeDrop(float x, float y) {
    private boolean completeDropLw(float x, float y) {
        WindowState dropTargetWin = mDragState.getDropTargetWinLw(x, y);

        mDragState.mCurrentX = x;
        mDragState.mCurrentY = y;

        DropPermissionHolder dropPermissionHolder = null;
        if ((mDragState.mFlags & View.DRAG_FLAG_GLOBAL) != 0 &&
        if (dropTargetWin != null &&
                (mDragState.mFlags & View.DRAG_FLAG_GLOBAL) != 0 &&
                (mDragState.mFlags & DRAG_FLAGS_URI_ACCESS) != 0) {
            dropPermissionHolder = new DropPermissionHolder(
                    mDragState.mData,
@@ -7104,6 +7108,7 @@ public class WindowManagerService extends IWindowManager.Stub
                    + " asbinder=" + window.asBinder());
        }

        final int callerPid = Binder.getCallingPid();
        final int callerUid = Binder.getCallingUid();
        final long origId = Binder.clearCallingIdentity();
        IBinder token = null;
@@ -7129,6 +7134,7 @@ public class WindowManagerService extends IWindowManager.Stub
                        final IBinder winBinder = window.asBinder();
                        token = new Binder();
                        mDragState = new DragState(this, token, surface, flags, winBinder);
                        mDragState.mPid = callerPid;
                        mDragState.mUid = callerUid;
                        token = mDragState.mToken = new Binder();