API CHANGE: startDrag() now takes "int flags" instead of "boolean localOnly"
There will be, in the future, a flag (View.DRAG_FLAG_GLOBAL) that means
for the drag to be cross-application. For now that flag constant is @hide
and furthermore the server-side implementation strips it, enforcing
local-only drags.
Change-Id: I8db840480ab90e18a5b8ecf29d62b4e6eafd405e
diff --git a/api/current.xml b/api/current.xml
index 7e17a33..6371a32 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -216462,10 +216462,10 @@
</parameter>
<parameter name="shadowBuilder" type="android.view.View.DragShadowBuilder">
</parameter>
-<parameter name="myWindowOnly" type="boolean">
-</parameter>
<parameter name="myLocalState" type="java.lang.Object">
</parameter>
+<parameter name="flags" type="int">
+</parameter>
</method>
<method name="unscheduleDrawable"
return="void"
@@ -257994,7 +257994,7 @@
deprecated="not deprecated"
visibility="public"
>
-<parameter name="t" type="T">
+<parameter name="arg0" type="T">
</parameter>
</method>
</interface>
diff --git a/core/java/android/view/IWindowSession.aidl b/core/java/android/view/IWindowSession.aidl
index 23fae42..a5f405a 100644
--- a/core/java/android/view/IWindowSession.aidl
+++ b/core/java/android/view/IWindowSession.aidl
@@ -121,7 +121,7 @@
* the drag to the OS and passes that as the return value. A return value of
* null indicates failure.
*/
- IBinder prepareDrag(IWindow window, boolean localOnly,
+ IBinder prepareDrag(IWindow window, int flags,
int thumbnailWidth, int thumbnailHeight, out Surface outSurface);
/**
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 703084f..39ec26d 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -2138,6 +2138,12 @@
boolean mCanAcceptDrop;
/**
+ * Flag indicating that a drag can cross window boundaries
+ * @hide
+ */
+ public static final int DRAG_FLAG_GLOBAL = 1;
+
+ /**
* Position of the vertical scroll bar.
*/
private int mVerticalScrollbarPosition;
@@ -10633,22 +10639,21 @@
*
* @param data !!! TODO
* @param shadowBuilder !!! TODO
- * @param myWindowOnly When {@code true}, indicates that the drag operation should be
- * restricted to the calling application. In this case only the calling application
- * will see any DragEvents related to this drag operation.
* @param myLocalState An arbitrary object that will be passed as part of every DragEvent
* delivered to the calling application during the course of the current drag operation.
* This object is private to the application that called startDrag(), and is not
* visible to other applications. It provides a lightweight way for the application to
* propagate information from the initiator to the recipient of a drag within its own
* application; for example, to help disambiguate between 'copy' and 'move' semantics.
+ * @param flags Flags affecting the drag operation. At present no flags are defined;
+ * pass 0 for this parameter.
* @return {@code true} if the drag operation was initiated successfully; {@code false} if
* an error prevented the drag from taking place.
*/
public final boolean startDrag(ClipData data, DragShadowBuilder shadowBuilder,
- boolean myWindowOnly, Object myLocalState) {
+ Object myLocalState, int flags) {
if (ViewDebug.DEBUG_DRAG) {
- Log.d(VIEW_LOG_TAG, "startDrag: data=" + data + " local=" + myWindowOnly);
+ Log.d(VIEW_LOG_TAG, "startDrag: data=" + data + " flags=" + flags);
}
boolean okay = false;
@@ -10668,7 +10673,7 @@
Surface surface = new Surface();
try {
IBinder token = mAttachInfo.mSession.prepareDrag(mAttachInfo.mWindow,
- myWindowOnly, shadowSize.x, shadowSize.y, surface);
+ flags, shadowSize.x, shadowSize.y, surface);
if (ViewDebug.DEBUG_DRAG) Log.d(VIEW_LOG_TAG, "prepareDrag returned token=" + token
+ " surface=" + surface);
if (token != null) {
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index a1c286f..b892fe2 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -8104,7 +8104,7 @@
CharSequence selectedText = mTransformed.subSequence(start, end);
ClipData data = ClipData.newPlainText(null, null, selectedText);
DragLocalState localState = new DragLocalState(this, start, end);
- startDrag(data, getTextThumbnailBuilder(selectedText), false, localState);
+ startDrag(data, getTextThumbnailBuilder(selectedText), localState, 0);
stopSelectionActionMode();
} else {
updateSelectedRegion();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/ShirtPocket.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/ShirtPocket.java
index b9206ea..2ebd067 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/ShirtPocket.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/ShirtPocket.java
@@ -163,7 +163,7 @@
shadow = new DragShadowBuilder(mWindow.findViewById(R.id.preview));
}
- v.startDrag(clip, shadow, false, null);
+ v.startDrag(clip, shadow, null, 0);
// TODO: only discard the clipping if it was accepted
stash(null);
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index 5c823ba..7011f9a 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -493,7 +493,7 @@
class DragState {
IBinder mToken;
Surface mSurface;
- boolean mLocalOnly;
+ int mFlags;
IBinder mLocalWin;
ClipData mData;
ClipDescription mDataDescription;
@@ -507,10 +507,10 @@
private final Rect tmpRect = new Rect();
- DragState(IBinder token, Surface surface, boolean localOnly, IBinder localWin) {
+ DragState(IBinder token, Surface surface, int flags, IBinder localWin) {
mToken = token;
mSurface = surface;
- mLocalOnly = localOnly;
+ mFlags = flags;
mLocalWin = localWin;
mNotifiedWindows = new ArrayList<WindowState>();
}
@@ -520,7 +520,7 @@
mSurface.destroy();
}
mSurface = null;
- mLocalOnly = false;
+ mFlags = 0;
mLocalWin = null;
mToken = null;
mData = null;
@@ -593,7 +593,7 @@
ClipDescription desc) {
// Don't actually send the event if the drag is supposed to be pinned
// to the originating window but 'newWin' is not that window.
- if (mLocalOnly) {
+ if ((mFlags & View.DRAG_FLAG_GLOBAL) == 0) {
final IBinder winBinder = newWin.mClient.asBinder();
if (winBinder != mLocalWin) {
if (DEBUG_DRAG) {
@@ -681,7 +681,7 @@
// Tell the affected window
WindowState touchedWin = getTouchedWinAtPointLw(x, y);
- if (mLocalOnly) {
+ if ((mFlags & View.DRAG_FLAG_GLOBAL) == 0) {
final IBinder touchedBinder = touchedWin.mClient.asBinder();
if (touchedBinder != mLocalWin) {
// This drag is pinned only to the originating window, but the drag
@@ -5633,10 +5633,10 @@
// -------------------------------------------------------------
IBinder prepareDragSurface(IWindow window, SurfaceSession session,
- boolean localOnly, int width, int height, Surface outSurface) {
+ int flags, int width, int height, Surface outSurface) {
if (DEBUG_DRAG) {
Slog.d(TAG, "prepare drag surface: w=" + width + " h=" + height
- + " local=" + localOnly + " win=" + window
+ + " flags=" + Integer.toHexString(flags) + " win=" + window
+ " asbinder=" + window.asBinder());
}
@@ -5647,17 +5647,15 @@
try {
synchronized (mWindowMap) {
try {
- // !!! TODO: fail if the given window does not currently have touch focus?
-
if (mDragState == null) {
Surface surface = new Surface(session, callerPid, "drag surface", 0,
width, height, PixelFormat.TRANSLUCENT, Surface.HIDDEN);
outSurface.copyFrom(surface);
final IBinder winBinder = window.asBinder();
token = new Binder();
- mDragState = new DragState(token, surface, localOnly, winBinder);
+ // TODO: preserve flags param in DragState
+ mDragState = new DragState(token, surface, 0, winBinder);
mDragState.mSurface = surface;
- mDragState.mLocalOnly = localOnly;
token = mDragState.mToken = new Binder();
// 5 second timeout for this window to actually begin the drag
@@ -6412,9 +6410,9 @@
}
/* Drag/drop */
- public IBinder prepareDrag(IWindow window, boolean localOnly,
+ public IBinder prepareDrag(IWindow window, int flags,
int width, int height, Surface outSurface) {
- return prepareDragSurface(window, mSurfaceSession, localOnly,
+ return prepareDragSurface(window, mSurfaceSession, flags,
width, height, outSurface);
}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java
index 74e5a65..ff46e7c 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java
@@ -106,7 +106,7 @@
// pass for now.
}
- public IBinder prepareDrag(IWindow window, boolean localOnly,
+ public IBinder prepareDrag(IWindow window, int flags,
int thumbnailWidth, int thumbnailHeight, Surface outSurface)
throws RemoteException {
// pass for now