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

Commit 99c6b978 authored by Pierre Barbier de Reuille's avatar Pierre Barbier de Reuille
Browse files

Stop using DesktopModeStatus in drag and drop

Bug: 395863348
Flag: EXEMPT (refactor)
Test: atest WMShellUnitTests
Change-Id: Ie40084f4d1495600a57742653229b0384de84f21
parent 4f54ce8e
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -1644,7 +1644,8 @@ public abstract class WMShellModule {
            GlobalDragListener globalDragListener,
            Transitions transitions,
            Lazy<BubbleController> bubbleControllerLazy,
            @ShellMainThread ShellExecutor mainExecutor) {
            @ShellMainThread ShellExecutor mainExecutor,
            DesktopState desktopState) {
        return new DragAndDropController(
                context,
                shellInit,
@@ -1662,7 +1663,8 @@ public abstract class WMShellModule {
                        return bubbleControllerLazy.get();
                    }
                },
                mainExecutor);
                mainExecutor,
                desktopState);
    }

    //
+8 −5
Original line number Diff line number Diff line
@@ -69,20 +69,20 @@ import com.android.wm.shell.common.RemoteCallable;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.protolog.ShellProtoLogGroup;
import com.android.wm.shell.shared.annotations.ExternalMainThread;
import com.android.wm.shell.shared.desktopmode.DesktopModeStatus;
import com.android.wm.shell.shared.desktopmode.DesktopState;
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 dagger.Lazy;

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.function.Consumer;
import java.util.function.Function;

import dagger.Lazy;

/**
 * Handles the global drag and drop handling for the Shell.
 */
@@ -103,6 +103,7 @@ public class DragAndDropController implements RemoteCallable<DragAndDropControll
    private final IconProvider mIconProvider;
    private final GlobalDragListener mGlobalDragListener;
    private final Transitions mTransitions;
    private final DesktopState mDesktopState;
    private SplitScreenController mSplitScreen;
    private Lazy<BubbleBarDragListener> mBubbleBarDragController;
    private ShellExecutor mMainExecutor;
@@ -148,7 +149,8 @@ public class DragAndDropController implements RemoteCallable<DragAndDropControll
            GlobalDragListener globalDragListener,
            Transitions transitions,
            Lazy<BubbleBarDragListener> bubbleBarDragController,
            ShellExecutor mainExecutor) {
            ShellExecutor mainExecutor,
            DesktopState desktopState) {
        mContext = context;
        mShellController = shellController;
        mShellCommandHandler = shellCommandHandler;
@@ -160,6 +162,7 @@ public class DragAndDropController implements RemoteCallable<DragAndDropControll
        mTransitions = transitions;
        mBubbleBarDragController = bubbleBarDragController;
        mMainExecutor = mainExecutor;
        mDesktopState = desktopState;
        shellInit.addInitCallback(this::onInit, this);
    }

@@ -347,7 +350,7 @@ public class DragAndDropController implements RemoteCallable<DragAndDropControll
            final ActivityManager.RunningTaskInfo taskInfo = dragSession.runningTaskInfo;
            // Desktop tasks will have their own drag handling.
            final boolean isDesktopDrag = taskInfo != null && taskInfo.isFreeform()
                    && DesktopModeStatus.canEnterDesktopMode(mContext);
                    && mDesktopState.canEnterDesktopMode();
            pd.isHandlingDrag = DragUtils.canHandleDrag(event) && !isDesktopDrag;
            ProtoLog.v(ShellProtoLogGroup.WM_SHELL_DRAG_AND_DROP,
                    "Clip description: handlingDrag=%b itemCount=%d mimeTypes=%s flags=%s",
+6 −3
Original line number Diff line number Diff line
@@ -50,19 +50,20 @@ import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.bubbles.bar.BubbleBarDragListener;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.shared.desktopmode.FakeDesktopState;
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 dagger.Lazy;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import dagger.Lazy;

/**
 * Tests for the drag and drop controller.
 */
@@ -96,16 +97,18 @@ public class DragAndDropControllerTest extends ShellTestCase {
    private GlobalDragListener mGlobalDragListener;
    @Mock
    private Lazy<BubbleBarDragListener> mBubbleBarDragControllerLazy;
    private FakeDesktopState mDesktopState;

    private DragAndDropController mController;

    @Before
    public void setUp() throws RemoteException {
        mDesktopState = new FakeDesktopState();
        MockitoAnnotations.initMocks(this);
        mController = new DragAndDropController(mContext, mShellInit, mShellController,
                mShellCommandHandler, mShellTaskOrganizer, mDisplayController, mUiEventLogger,
                mIconProvider, mGlobalDragListener, mTransitions, mBubbleBarDragControllerLazy,
                mMainExecutor);
                mMainExecutor, mDesktopState);
        mController.onInit();
    }