diff options
| author | 2024-07-09 23:51:52 +0000 | |
|---|---|---|
| committer | 2024-07-10 03:15:58 +0000 | |
| commit | 6eee3cabf214e3ccfadf43cbd30936d6dce5aca4 (patch) | |
| tree | 3fba63ecb7ca1d22d95d8ce0b1b7c6743f502de3 /libs/WindowManager/Shell | |
| parent | 6ed1adb0efa3ac6c42d1c72a4fb58c58a8bff980 (diff) | |
Fix issue where highlight was drawing without bottom inset on one side only
- If a drag is started over home, we ignore the bottom insets to
draw the highlight the full height, however we were still handling
taskVanished even if there is no drag in session, which meant that
setForceIgnoreBottomMargin(true) could be called before the next
drag session which does not reset it (it only reset it on hide()).
This change properly skips handling taskVanished while not dragging
and also resets setForceIgnoreBottomMargin() when the highlights
should be showing for both tasks
- Also add some descriptive logging for the drag flags
Flag: EXEMPT bugfix
Bug: 350016003
Test: Drag floating assistant over home, then over another app
Change-Id: I175610a643b4a69850bc3b289032f1b3b8524a21
Diffstat (limited to 'libs/WindowManager/Shell')
4 files changed, 62 insertions, 6 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragAndDropController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragAndDropController.java index e0b08668b1d4..e00353d6ac82 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragAndDropController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragAndDropController.java @@ -302,7 +302,7 @@ public class DragAndDropController implements RemoteCallable<DragAndDropControll break; } } - if (pd == null || !pd.isHandlingDrag) { + if (pd == null || pd.activeDragCount <= 0 || !pd.isHandlingDrag) { // Not currently dragging return; } @@ -333,9 +333,10 @@ public class DragAndDropController implements RemoteCallable<DragAndDropControll mActiveDragDisplay = displayId; pd.isHandlingDrag = DragUtils.canHandleDrag(event); ProtoLog.v(ShellProtoLogGroup.WM_SHELL_DRAG_AND_DROP, - "Clip description: handlingDrag=%b itemCount=%d mimeTypes=%s", + "Clip description: handlingDrag=%b itemCount=%d mimeTypes=%s flags=%s", pd.isHandlingDrag, event.getClipData().getItemCount(), - DragUtils.getMimeTypesConcatenated(description)); + DragUtils.getMimeTypesConcatenated(description), + DragUtils.dragFlagsToString(event.getDragFlags())); } if (!pd.isHandlingDrag) { diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragLayout.java b/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragLayout.java index f0514e3e49f5..e4aa115347eb 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragLayout.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragLayout.java @@ -293,6 +293,8 @@ public class DragLayout extends LinearLayout int bgColor1 = getResizingBackgroundColor(taskInfo1).toArgb(); mDropZoneView1.setAppInfo(bgColor1, icon1); mDropZoneView2.setAppInfo(bgColor1, icon1); + mDropZoneView1.setForceIgnoreBottomMargin(false); + mDropZoneView2.setForceIgnoreBottomMargin(false); updateDropZoneSizes(null, null); // passing null splits the views evenly } else { // We use the first drop zone to show the fullscreen highlight, and don't need diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragUtils.java b/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragUtils.java index e215870f1894..22cfa328bfda 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragUtils.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragUtils.java @@ -19,16 +19,28 @@ package com.android.wm.shell.draganddrop; import static android.content.ClipDescription.MIMETYPE_APPLICATION_ACTIVITY; import static android.content.ClipDescription.MIMETYPE_APPLICATION_SHORTCUT; import static android.content.ClipDescription.MIMETYPE_APPLICATION_TASK; +import static android.view.View.DRAG_FLAG_ACCESSIBILITY_ACTION; +import static android.view.View.DRAG_FLAG_GLOBAL; +import static android.view.View.DRAG_FLAG_GLOBAL_PERSISTABLE_URI_PERMISSION; +import static android.view.View.DRAG_FLAG_GLOBAL_PREFIX_URI_PERMISSION; +import static android.view.View.DRAG_FLAG_GLOBAL_SAME_APPLICATION; +import static android.view.View.DRAG_FLAG_GLOBAL_URI_READ; +import static android.view.View.DRAG_FLAG_GLOBAL_URI_WRITE; +import static android.view.View.DRAG_FLAG_HIDE_CALLING_TASK_ON_DRAG_START; +import static android.view.View.DRAG_FLAG_OPAQUE; +import static android.view.View.DRAG_FLAG_REQUEST_SURFACE_FOR_RETURN_ANIMATION; +import static android.view.View.DRAG_FLAG_START_INTENT_SENDER_ON_UNHANDLED_DRAG; 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; +import java.util.StringJoiner; + /** Collection of utility classes for handling drag and drop. */ public class DragUtils { private static final String TAG = "DragUtils"; @@ -76,7 +88,7 @@ public class DragUtils { */ @Nullable public static PendingIntent getLaunchIntent(@NonNull ClipData data, int dragFlags) { - if ((dragFlags & View.DRAG_FLAG_START_INTENT_SENDER_ON_UNHANDLED_DRAG) == 0) { + if ((dragFlags & 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; } @@ -105,4 +117,35 @@ public class DragUtils { } return mimeTypes; } + + /** + * Returns the string description of the given {@param dragFlags}. + */ + public static String dragFlagsToString(int dragFlags) { + StringJoiner str = new StringJoiner("|"); + if ((dragFlags & DRAG_FLAG_GLOBAL) != 0) { + str.add("GLOBAL"); + } else if ((dragFlags & DRAG_FLAG_GLOBAL_URI_READ) != 0) { + str.add("GLOBAL_URI_READ"); + } else if ((dragFlags & DRAG_FLAG_GLOBAL_URI_WRITE) != 0) { + str.add("GLOBAL_URI_WRITE"); + } else if ((dragFlags & DRAG_FLAG_GLOBAL_PERSISTABLE_URI_PERMISSION) != 0) { + str.add("GLOBAL_PERSISTABLE_URI_PERMISSION"); + } else if ((dragFlags & DRAG_FLAG_GLOBAL_PREFIX_URI_PERMISSION) != 0) { + str.add("GLOBAL_PREFIX_URI_PERMISSION"); + } else if ((dragFlags & DRAG_FLAG_OPAQUE) != 0) { + str.add("OPAQUE"); + } else if ((dragFlags & DRAG_FLAG_ACCESSIBILITY_ACTION) != 0) { + str.add("ACCESSIBILITY_ACTION"); + } else if ((dragFlags & DRAG_FLAG_REQUEST_SURFACE_FOR_RETURN_ANIMATION) != 0) { + str.add("REQUEST_SURFACE_FOR_RETURN_ANIMATION"); + } else if ((dragFlags & DRAG_FLAG_GLOBAL_SAME_APPLICATION) != 0) { + str.add("GLOBAL_SAME_APPLICATION"); + } else if ((dragFlags & DRAG_FLAG_START_INTENT_SENDER_ON_UNHANDLED_DRAG) != 0) { + str.add("START_INTENT_SENDER_ON_UNHANDLED_DRAG"); + } else if ((dragFlags & DRAG_FLAG_HIDE_CALLING_TASK_ON_DRAG_START) != 0) { + str.add("HIDE_CALLING_TASK_ON_DRAG_START"); + } + return str.toString(); + } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DropZoneView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DropZoneView.java index b6b49a87484e..18cd2d84d32d 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DropZoneView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DropZoneView.java @@ -151,6 +151,10 @@ public class DropZoneView extends FrameLayout { /** Ignores the bottom margin provided by the insets. */ public void setForceIgnoreBottomMargin(boolean ignoreBottomMargin) { + if (DEBUG_LAYOUT) { + ProtoLog.v(ShellProtoLogGroup.WM_SHELL_DRAG_AND_DROP, + "setForceIgnoreBottomMargin: ignore=%b", ignoreBottomMargin); + } mIgnoreBottomMargin = ignoreBottomMargin; if (mMarginPercent > 0) { mMarginView.invalidate(); @@ -159,8 +163,14 @@ public class DropZoneView extends FrameLayout { /** Sets the bottom inset so the drop zones are above bottom navigation. */ public void setBottomInset(float bottom) { + if (DEBUG_LAYOUT) { + ProtoLog.v(ShellProtoLogGroup.WM_SHELL_DRAG_AND_DROP, "setBottomInset: inset=%f", + bottom); + } mBottomInset = bottom; - ((LayoutParams) mSplashScreenView.getLayoutParams()).bottomMargin = (int) bottom; + final LayoutParams lp = (LayoutParams) mSplashScreenView.getLayoutParams(); + lp.bottomMargin = (int) bottom; + mSplashScreenView.setLayoutParams(lp); if (mMarginPercent > 0) { mMarginView.invalidate(); } |