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

Commit 7db0a115 authored by Winson Chung's avatar Winson Chung Committed by Android Build Coastguard Worker
Browse files

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
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:6eee3cabf214e3ccfadf43cbd30936d6dce5aca4)
Merged-In: I175610a643b4a69850bc3b289032f1b3b8524a21
Change-Id: I175610a643b4a69850bc3b289032f1b3b8524a21
parent f94e099e
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -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) {
+2 −0
Original line number Diff line number Diff line
@@ -294,6 +294,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
+45 −2
Original line number Diff line number Diff line
@@ -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();
    }
}
+11 −1
Original line number Diff line number Diff line
@@ -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();
        }