diff options
| author | 2015-11-06 01:31:54 +0000 | |
|---|---|---|
| committer | 2015-11-06 01:31:54 +0000 | |
| commit | 36ebe4c61821a471120b8f5ae7d85f51e8c64d9c (patch) | |
| tree | b197aa8db1111391d607eea953a1c397d66ae8ee | |
| parent | a2e846013b251e9b2e490bc6491ddbb77b7bb306 (diff) | |
| parent | c748241523e12121015e793f5f368638b98a11fe (diff) | |
Merge "Expose the desktop location of an unconsumed drag and drop"
| -rw-r--r-- | services/core/java/com/android/server/wm/DragState.java | 11 | ||||
| -rw-r--r-- | services/core/java/com/android/server/wm/WindowManagerService.java | 14 |
2 files changed, 19 insertions, 6 deletions
diff --git a/services/core/java/com/android/server/wm/DragState.java b/services/core/java/com/android/server/wm/DragState.java index f35ea669a71d..400cc5e3d9b5 100644 --- a/services/core/java/com/android/server/wm/DragState.java +++ b/services/core/java/com/android/server/wm/DragState.java @@ -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) { diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index bc411a5187a7..59f420a464a8 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -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(); |