Loading core/java/android/view/DragEvent.java +22 −7 Original line number Diff line number Diff line Loading @@ -156,6 +156,13 @@ public class DragEvent implements Parcelable { private float mOffsetX; private float mOffsetY; /** * The View#DRAG_FLAG_* flags used to start the current drag, only provided if the target window * has the {@link WindowManager.LayoutParams#PRIVATE_FLAG_INTERCEPT_GLOBAL_DRAG_AND_DROP} flag * and is only sent with {@link #ACTION_DRAG_STARTED} and {@link #ACTION_DROP}. */ private int mFlags; private DragEvent mNext; private RuntimeException mRecycledLocation; private boolean mRecycled; Loading Loading @@ -290,7 +297,7 @@ public class DragEvent implements Parcelable { private DragEvent() { } private void init(int action, float x, float y, float offsetX, float offsetY, private void init(int action, float x, float y, float offsetX, float offsetY, int flags, ClipDescription description, ClipData data, SurfaceControl dragSurface, IDragAndDropPermissions dragAndDropPermissions, Object localState, boolean result) { mAction = action; Loading @@ -298,6 +305,7 @@ public class DragEvent implements Parcelable { mY = y; mOffsetX = offsetX; mOffsetY = offsetY; mFlags = flags; mClipDescription = description; mClipData = data; mDragSurface = dragSurface; Loading @@ -307,19 +315,19 @@ public class DragEvent implements Parcelable { } static DragEvent obtain() { return DragEvent.obtain(0, 0f, 0f, 0f, 0f, null, null, null, null, null, false); return DragEvent.obtain(0, 0f, 0f, 0f, 0f, 0, null, null, null, null, null, false); } /** @hide */ public static DragEvent obtain(int action, float x, float y, float offsetX, float offsetY, Object localState, ClipDescription description, ClipData data, int flags, Object localState, ClipDescription description, ClipData data, SurfaceControl dragSurface, IDragAndDropPermissions dragAndDropPermissions, boolean result) { final DragEvent ev; synchronized (gRecyclerLock) { if (gRecyclerTop == null) { ev = new DragEvent(); ev.init(action, x, y, offsetX, offsetY, description, data, dragSurface, ev.init(action, x, y, offsetX, offsetY, flags, description, data, dragSurface, dragAndDropPermissions, localState, result); return ev; } Loading @@ -331,7 +339,7 @@ public class DragEvent implements Parcelable { ev.mRecycled = false; ev.mNext = null; ev.init(action, x, y, offsetX, offsetY, description, data, dragSurface, ev.init(action, x, y, offsetX, offsetY, flags, description, data, dragSurface, dragAndDropPermissions, localState, result); return ev; Loading @@ -341,8 +349,8 @@ public class DragEvent implements Parcelable { @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) public static DragEvent obtain(DragEvent source) { return obtain(source.mAction, source.mX, source.mY, source.mOffsetX, source.mOffsetY, source.mLocalState, source.mClipDescription, source.mClipData, source.mDragSurface, source.mDragAndDropPermissions, source.mDragResult); source.mFlags, source.mLocalState, source.mClipDescription, source.mClipData, source.mDragSurface, source.mDragAndDropPermissions, source.mDragResult); } /** Loading Loading @@ -423,6 +431,11 @@ public class DragEvent implements Parcelable { return mDragSurface; } /** @hide */ public int getDragFlags() { return mFlags; } /** @hide */ public IDragAndDropPermissions getDragAndDropPermissions() { return mDragAndDropPermissions; Loading Loading @@ -571,6 +584,7 @@ public class DragEvent implements Parcelable { dest.writeFloat(mY); dest.writeFloat(mOffsetX); dest.writeFloat(mOffsetY); dest.writeInt(mFlags); dest.writeInt(mDragResult ? 1 : 0); if (mClipData == null) { dest.writeInt(0); Loading Loading @@ -610,6 +624,7 @@ public class DragEvent implements Parcelable { event.mY = in.readFloat(); event.mOffsetX = in.readFloat(); event.mOffsetY = in.readFloat(); event.mFlags = in.readInt(); event.mDragResult = (in.readInt() != 0); if (in.readInt() != 0) { event.mClipData = ClipData.CREATOR.createFromParcel(in); Loading core/java/android/view/ViewRootImpl.java +1 −1 Original line number Diff line number Diff line Loading @@ -10234,7 +10234,7 @@ public final class ViewRootImpl implements ViewParent, // force DRAG_EXITED_EVENT if appropriate DragEvent event = DragEvent.obtain( isExiting ? DragEvent.ACTION_DRAG_EXITED : DragEvent.ACTION_DRAG_LOCATION, x, y, 0 /* offsetX */, 0 /* offsetY */, null/* localState */, x, y, 0 /* offsetX */, 0 /* offsetY */, 0 /* flags */, null/* localState */, null/* description */, null /* data */, null /* dragSurface */, null /* dragAndDropPermissions */, false /* result */); dispatchDragEvent(event); Loading libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragAndDropController.java +2 −1 Original line number Diff line number Diff line Loading @@ -316,7 +316,8 @@ public class DragAndDropController implements RemoteCallable<DragAndDropControll } // TODO(b/290391688): Also update the session data with task stack changes pd.dragSession = new DragSession(ActivityTaskManager.getInstance(), mDisplayController.getDisplayLayout(displayId), event.getClipData()); mDisplayController.getDisplayLayout(displayId), event.getClipData(), event.getDragFlags()); pd.dragSession.update(); pd.activeDragCount++; pd.dragLayout.prepare(pd.dragSession, mLogger.logStart(pd.dragSession)); Loading libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragSession.java +4 −2 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import java.util.List; public class DragSession { private final ActivityTaskManager mActivityTaskManager; private final ClipData mInitialDragData; private final int mInitialDragFlags; final DisplayLayout displayLayout; // The activity info associated with the activity in the appData or the launchableIntent Loading @@ -62,9 +63,10 @@ public class DragSession { boolean dragItemSupportsSplitscreen; DragSession(ActivityTaskManager activityTaskManager, DisplayLayout dispLayout, ClipData data) { DisplayLayout dispLayout, ClipData data, int dragFlags) { mActivityTaskManager = activityTaskManager; mInitialDragData = data; mInitialDragFlags = dragFlags; displayLayout = dispLayout; } Loading Loading @@ -94,6 +96,6 @@ public class DragSession { dragItemSupportsSplitscreen = activityInfo == null || ActivityInfo.isResizeableMode(activityInfo.resizeMode); appData = mInitialDragData.getItemAt(0).getIntent(); launchableIntent = DragUtils.getLaunchIntent(mInitialDragData); launchableIntent = DragUtils.getLaunchIntent(mInitialDragData, mInitialDragFlags); } } libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragUtils.java +7 −2 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.app.PendingIntent; import android.content.ClipData; import android.content.ClipDescription; import android.view.DragEvent; import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; Loading Loading @@ -67,14 +68,18 @@ public class DragUtils { */ @Nullable public static PendingIntent getLaunchIntent(@NonNull DragEvent dragEvent) { return getLaunchIntent(dragEvent.getClipData()); return getLaunchIntent(dragEvent.getClipData(), dragEvent.getDragFlags()); } /** * Returns a launchable intent in the given `ClipData` or `null` if there is none. */ @Nullable public static PendingIntent getLaunchIntent(@NonNull ClipData data) { public static PendingIntent getLaunchIntent(@NonNull ClipData data, int dragFlags) { if ((dragFlags & View.DRAG_FLAG_START_INTENT_SENDER_ON_UNHANDLED_DRAG) == 0) { // Disallow launching the intent if the app does not want to delegate it to the system return null; } for (int i = 0; i < data.getItemCount(); i++) { final ClipData.Item item = data.getItemAt(i); if (item.getIntentSender() != null) { Loading Loading
core/java/android/view/DragEvent.java +22 −7 Original line number Diff line number Diff line Loading @@ -156,6 +156,13 @@ public class DragEvent implements Parcelable { private float mOffsetX; private float mOffsetY; /** * The View#DRAG_FLAG_* flags used to start the current drag, only provided if the target window * has the {@link WindowManager.LayoutParams#PRIVATE_FLAG_INTERCEPT_GLOBAL_DRAG_AND_DROP} flag * and is only sent with {@link #ACTION_DRAG_STARTED} and {@link #ACTION_DROP}. */ private int mFlags; private DragEvent mNext; private RuntimeException mRecycledLocation; private boolean mRecycled; Loading Loading @@ -290,7 +297,7 @@ public class DragEvent implements Parcelable { private DragEvent() { } private void init(int action, float x, float y, float offsetX, float offsetY, private void init(int action, float x, float y, float offsetX, float offsetY, int flags, ClipDescription description, ClipData data, SurfaceControl dragSurface, IDragAndDropPermissions dragAndDropPermissions, Object localState, boolean result) { mAction = action; Loading @@ -298,6 +305,7 @@ public class DragEvent implements Parcelable { mY = y; mOffsetX = offsetX; mOffsetY = offsetY; mFlags = flags; mClipDescription = description; mClipData = data; mDragSurface = dragSurface; Loading @@ -307,19 +315,19 @@ public class DragEvent implements Parcelable { } static DragEvent obtain() { return DragEvent.obtain(0, 0f, 0f, 0f, 0f, null, null, null, null, null, false); return DragEvent.obtain(0, 0f, 0f, 0f, 0f, 0, null, null, null, null, null, false); } /** @hide */ public static DragEvent obtain(int action, float x, float y, float offsetX, float offsetY, Object localState, ClipDescription description, ClipData data, int flags, Object localState, ClipDescription description, ClipData data, SurfaceControl dragSurface, IDragAndDropPermissions dragAndDropPermissions, boolean result) { final DragEvent ev; synchronized (gRecyclerLock) { if (gRecyclerTop == null) { ev = new DragEvent(); ev.init(action, x, y, offsetX, offsetY, description, data, dragSurface, ev.init(action, x, y, offsetX, offsetY, flags, description, data, dragSurface, dragAndDropPermissions, localState, result); return ev; } Loading @@ -331,7 +339,7 @@ public class DragEvent implements Parcelable { ev.mRecycled = false; ev.mNext = null; ev.init(action, x, y, offsetX, offsetY, description, data, dragSurface, ev.init(action, x, y, offsetX, offsetY, flags, description, data, dragSurface, dragAndDropPermissions, localState, result); return ev; Loading @@ -341,8 +349,8 @@ public class DragEvent implements Parcelable { @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) public static DragEvent obtain(DragEvent source) { return obtain(source.mAction, source.mX, source.mY, source.mOffsetX, source.mOffsetY, source.mLocalState, source.mClipDescription, source.mClipData, source.mDragSurface, source.mDragAndDropPermissions, source.mDragResult); source.mFlags, source.mLocalState, source.mClipDescription, source.mClipData, source.mDragSurface, source.mDragAndDropPermissions, source.mDragResult); } /** Loading Loading @@ -423,6 +431,11 @@ public class DragEvent implements Parcelable { return mDragSurface; } /** @hide */ public int getDragFlags() { return mFlags; } /** @hide */ public IDragAndDropPermissions getDragAndDropPermissions() { return mDragAndDropPermissions; Loading Loading @@ -571,6 +584,7 @@ public class DragEvent implements Parcelable { dest.writeFloat(mY); dest.writeFloat(mOffsetX); dest.writeFloat(mOffsetY); dest.writeInt(mFlags); dest.writeInt(mDragResult ? 1 : 0); if (mClipData == null) { dest.writeInt(0); Loading Loading @@ -610,6 +624,7 @@ public class DragEvent implements Parcelable { event.mY = in.readFloat(); event.mOffsetX = in.readFloat(); event.mOffsetY = in.readFloat(); event.mFlags = in.readInt(); event.mDragResult = (in.readInt() != 0); if (in.readInt() != 0) { event.mClipData = ClipData.CREATOR.createFromParcel(in); Loading
core/java/android/view/ViewRootImpl.java +1 −1 Original line number Diff line number Diff line Loading @@ -10234,7 +10234,7 @@ public final class ViewRootImpl implements ViewParent, // force DRAG_EXITED_EVENT if appropriate DragEvent event = DragEvent.obtain( isExiting ? DragEvent.ACTION_DRAG_EXITED : DragEvent.ACTION_DRAG_LOCATION, x, y, 0 /* offsetX */, 0 /* offsetY */, null/* localState */, x, y, 0 /* offsetX */, 0 /* offsetY */, 0 /* flags */, null/* localState */, null/* description */, null /* data */, null /* dragSurface */, null /* dragAndDropPermissions */, false /* result */); dispatchDragEvent(event); Loading
libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragAndDropController.java +2 −1 Original line number Diff line number Diff line Loading @@ -316,7 +316,8 @@ public class DragAndDropController implements RemoteCallable<DragAndDropControll } // TODO(b/290391688): Also update the session data with task stack changes pd.dragSession = new DragSession(ActivityTaskManager.getInstance(), mDisplayController.getDisplayLayout(displayId), event.getClipData()); mDisplayController.getDisplayLayout(displayId), event.getClipData(), event.getDragFlags()); pd.dragSession.update(); pd.activeDragCount++; pd.dragLayout.prepare(pd.dragSession, mLogger.logStart(pd.dragSession)); Loading
libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragSession.java +4 −2 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import java.util.List; public class DragSession { private final ActivityTaskManager mActivityTaskManager; private final ClipData mInitialDragData; private final int mInitialDragFlags; final DisplayLayout displayLayout; // The activity info associated with the activity in the appData or the launchableIntent Loading @@ -62,9 +63,10 @@ public class DragSession { boolean dragItemSupportsSplitscreen; DragSession(ActivityTaskManager activityTaskManager, DisplayLayout dispLayout, ClipData data) { DisplayLayout dispLayout, ClipData data, int dragFlags) { mActivityTaskManager = activityTaskManager; mInitialDragData = data; mInitialDragFlags = dragFlags; displayLayout = dispLayout; } Loading Loading @@ -94,6 +96,6 @@ public class DragSession { dragItemSupportsSplitscreen = activityInfo == null || ActivityInfo.isResizeableMode(activityInfo.resizeMode); appData = mInitialDragData.getItemAt(0).getIntent(); launchableIntent = DragUtils.getLaunchIntent(mInitialDragData); launchableIntent = DragUtils.getLaunchIntent(mInitialDragData, mInitialDragFlags); } }
libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragUtils.java +7 −2 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.app.PendingIntent; import android.content.ClipData; import android.content.ClipDescription; import android.view.DragEvent; import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; Loading Loading @@ -67,14 +68,18 @@ public class DragUtils { */ @Nullable public static PendingIntent getLaunchIntent(@NonNull DragEvent dragEvent) { return getLaunchIntent(dragEvent.getClipData()); return getLaunchIntent(dragEvent.getClipData(), dragEvent.getDragFlags()); } /** * Returns a launchable intent in the given `ClipData` or `null` if there is none. */ @Nullable public static PendingIntent getLaunchIntent(@NonNull ClipData data) { public static PendingIntent getLaunchIntent(@NonNull ClipData data, int dragFlags) { if ((dragFlags & View.DRAG_FLAG_START_INTENT_SENDER_ON_UNHANDLED_DRAG) == 0) { // Disallow launching the intent if the app does not want to delegate it to the system return null; } for (int i = 0; i < data.getItemCount(); i++) { final ClipData.Item item = data.getItemAt(i); if (item.getIntentSender() != null) { Loading