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

Commit aaec57c2 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes Id2d2258a,I96d7f722 into main

* changes:
  Bring the task forward when it consumes a cross-window global drag
  Generalize the unhandled drag listener for other global drag callbacks
parents 0ca9cb73 47c91b21
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -69,11 +69,11 @@ import android.view.SurfaceControl;
import android.view.displayhash.DisplayHash;
import android.view.displayhash.VerifiedDisplayHash;
import android.window.AddToSurfaceSyncGroupResult;
import android.window.IGlobalDragListener;
import android.window.IScreenRecordingCallback;
import android.window.ISurfaceSyncGroupCompletedListener;
import android.window.ITaskFpsCallback;
import android.window.ITrustedPresentationListener;
import android.window.IUnhandledDragListener;
import android.window.InputTransferToken;
import android.window.ScreenCapture;
import android.window.TrustedPresentationThresholds;
@@ -1094,10 +1094,9 @@ interface IWindowManager
    void unregisterScreenRecordingCallback(IScreenRecordingCallback callback);

    /**
     * Sets the listener to be called back when a cross-window drag and drop operation is unhandled
     * (ie. not handled by any window which can handle the drag).
     * Sets the listener to be called back when a cross-window drag and drop operation happens.
     */
    void setUnhandledDragListener(IUnhandledDragListener listener);
    void setGlobalDragListener(IGlobalDragListener listener);

    boolean transferTouchGesture(in InputTransferToken transferFromToken,
            in InputTransferToken transferToToken);
+9 −2
Original line number Diff line number Diff line
@@ -16,14 +16,21 @@

package android.window;

import android.app.ActivityManager;
import android.view.DragEvent;
import android.window.IUnhandledDragCallback;

/**
 * An interface to a handler for global drags that are not consumed (ie. not handled by any window).
 * An interface to a handler for global drags.
 * {@hide}
 */
oneway interface IUnhandledDragListener {
oneway interface IGlobalDragListener {
    /**
     * Called when a cross-window drag is handled by another window.
     * @param taskInfo the task containing the window that consumed the drop
     */
    void onCrossWindowDrop(in ActivityManager.RunningTaskInfo taskInfo);

    /**
     * Called when the user finishes the drag gesture but no windows have reported handling the
     * drop.  The DragEvent is populated with the drag surface for the listener to animate.  The
+0 −13
Original line number Diff line number Diff line
@@ -643,19 +643,6 @@ public class ShellTaskOrganizer extends TaskOrganizer implements
        }
    }

    /** Helper to set int metadata on the Surface corresponding to the task id. */
    public void setSurfaceMetadata(int taskId, int key, int value) {
        synchronized (mLock) {
            final TaskAppearedInfo info = mTasks.get(taskId);
            if (info == null || info.getLeash() == null) {
                return;
            }
            SurfaceControl.Transaction t = new SurfaceControl.Transaction();
            t.setMetadata(info.getLeash(), key, value);
            t.apply();
        }
    }

    private boolean updateTaskListenerIfNeeded(RunningTaskInfo taskInfo, SurfaceControl leash,
            TaskListener oldListener, TaskListener newListener) {
        if (oldListener == newListener) return false;
+8 −5
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ import com.android.wm.shell.desktopmode.EnterDesktopTaskTransitionHandler;
import com.android.wm.shell.desktopmode.ExitDesktopTaskTransitionHandler;
import com.android.wm.shell.desktopmode.ToggleResizeDesktopTaskTransitionHandler;
import com.android.wm.shell.draganddrop.DragAndDropController;
import com.android.wm.shell.draganddrop.UnhandledDragController;
import com.android.wm.shell.draganddrop.GlobalDragListener;
import com.android.wm.shell.freeform.FreeformComponents;
import com.android.wm.shell.freeform.FreeformTaskListener;
import com.android.wm.shell.freeform.FreeformTaskTransitionHandler;
@@ -562,10 +562,10 @@ public abstract class WMShellModule {

    @WMSingleton
    @Provides
    static UnhandledDragController provideUnhandledDragController(
    static GlobalDragListener provideGlobalDragListener(
            IWindowManager wmService,
            @ShellMainThread ShellExecutor mainExecutor) {
        return new UnhandledDragController(wmService, mainExecutor);
        return new GlobalDragListener(wmService, mainExecutor);
    }

    @WMSingleton
@@ -577,9 +577,12 @@ public abstract class WMShellModule {
            DisplayController displayController,
            UiEventLogger uiEventLogger,
            IconProvider iconProvider,
            GlobalDragListener globalDragListener,
            Transitions transitions,
            @ShellMainThread ShellExecutor mainExecutor) {
        return new DragAndDropController(context, shellInit, shellController,
                shellCommandHandler, displayController, uiEventLogger, iconProvider, mainExecutor);
        return new DragAndDropController(context, shellInit, shellController, shellCommandHandler,
                displayController, uiEventLogger, iconProvider, globalDragListener, transitions,
                mainExecutor);
    }

    //
+19 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
import static com.android.wm.shell.common.ExecutorUtils.executeRemoteCallWithTaskPermission;
import static com.android.wm.shell.sysui.ShellSharedConstants.KEY_EXTRA_SHELL_DRAG_AND_DROP;

import android.app.ActivityManager;
import android.app.ActivityTaskManager;
import android.content.ClipDescription;
import android.content.ComponentCallbacks2;
@@ -51,6 +52,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.window.WindowContainerTransaction;

import androidx.annotation.BinderThread;
import androidx.annotation.NonNull;
@@ -71,6 +73,7 @@ import com.android.wm.shell.splitscreen.SplitScreenController;
import com.android.wm.shell.sysui.ShellCommandHandler;
import com.android.wm.shell.sysui.ShellController;
import com.android.wm.shell.sysui.ShellInit;
import com.android.wm.shell.transition.Transitions;

import java.io.PrintWriter;
import java.util.ArrayList;
@@ -79,6 +82,7 @@ import java.util.ArrayList;
 * Handles the global drag and drop handling for the Shell.
 */
public class DragAndDropController implements RemoteCallable<DragAndDropController>,
        GlobalDragListener.GlobalDragListenerCallback,
        DisplayController.OnDisplaysChangedListener,
        View.OnDragListener, ComponentCallbacks2 {

@@ -90,6 +94,8 @@ public class DragAndDropController implements RemoteCallable<DragAndDropControll
    private final DisplayController mDisplayController;
    private final DragAndDropEventLogger mLogger;
    private final IconProvider mIconProvider;
    private final GlobalDragListener mGlobalDragListener;
    private final Transitions mTransitions;
    private SplitScreenController mSplitScreen;
    private ShellExecutor mMainExecutor;
    private ArrayList<DragAndDropListener> mListeners = new ArrayList<>();
@@ -112,6 +118,8 @@ public class DragAndDropController implements RemoteCallable<DragAndDropControll
            DisplayController displayController,
            UiEventLogger uiEventLogger,
            IconProvider iconProvider,
            GlobalDragListener globalDragListener,
            Transitions transitions,
            ShellExecutor mainExecutor) {
        mContext = context;
        mShellController = shellController;
@@ -119,6 +127,8 @@ public class DragAndDropController implements RemoteCallable<DragAndDropControll
        mDisplayController = displayController;
        mLogger = new DragAndDropEventLogger(uiEventLogger);
        mIconProvider = iconProvider;
        mGlobalDragListener = globalDragListener;
        mTransitions = transitions;
        mMainExecutor = mainExecutor;
        shellInit.addInitCallback(this::onInit, this);
    }
@@ -136,6 +146,7 @@ public class DragAndDropController implements RemoteCallable<DragAndDropControll
        mShellController.addExternalInterface(KEY_EXTRA_SHELL_DRAG_AND_DROP,
                this::createExternalInterface, this);
        mShellCommandHandler.addDumpCallback(this::dump, this);
        mGlobalDragListener.setListener(this);
    }

    private ExternalInterfaceBinder createExternalInterface() {
@@ -322,6 +333,14 @@ public class DragAndDropController implements RemoteCallable<DragAndDropControll
        return true;
    }

    @Override
    public void onCrossWindowDrop(@NonNull ActivityManager.RunningTaskInfo taskInfo) {
        // Bring the task forward when an item is dropped on it
        final WindowContainerTransaction wct = new WindowContainerTransaction();
        wct.reorder(taskInfo.token, true /* onTop */);
        mTransitions.startTransition(WindowManager.TRANSIT_TO_FRONT, wct, null);
    }

    /**
     * Handles dropping on the drop target.
     */
Loading