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

Commit 744cb09b authored by Ats Jenk's avatar Ats Jenk
Browse files

Skip restoring task order when dragging to bubble

Bubbles transition manages the order of tasks itself.
There is no need for the order to be restored.

Bug: 394651724
Test: atest WMShellUnitTests
Flag: com.android.wm.shell.enable_bubble_to_fullscreen
Change-Id: Icd3bdc412aa16031d2501fbeea1aac7f9bcdc2aa
parent 760542f5
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import static android.service.notification.NotificationListenerService.REASON_CA
import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
import static android.view.WindowManager.TRANSIT_CHANGE;

import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_BUBBLES;
import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME;
@@ -1613,10 +1612,6 @@ public class BubbleController implements ConfigurationChangeListener,
        }
        if (b.isInflated()) {
            mBubbleData.setSelectedBubbleAndExpandStack(b, location);
            if (dragData != null && dragData.getPendingWct() != null) {
                mTransitions.startTransition(TRANSIT_CHANGE,
                        dragData.getPendingWct(), /* handler= */ null);
            }
        } else {
            if (location != null) {
                setBubbleBarLocation(location, UpdateSource.DRAG_TASK);
+1 −15
Original line number Diff line number Diff line
@@ -168,7 +168,6 @@ public class BubbleTransitions {
     * Information about the task when it is being dragged to a bubble
     */
    public static class DragData {
        private final WindowContainerTransaction mPendingWct;
        private final boolean mReleasedOnLeft;
        private final float mTaskScale;
        private final float mCornerRadius;
@@ -179,25 +178,15 @@ public class BubbleTransitions {
         * @param taskScale      the scale of the task when it was dragged to bubble
         * @param cornerRadius   the corner radius of the task when it was dragged to bubble
         * @param dragPosition   the position of the task when it was dragged to bubble
         * @param wct            pending operations to be applied when finishing the drag
         */
        public DragData(boolean releasedOnLeft, float taskScale, float cornerRadius,
                @Nullable PointF dragPosition, @Nullable WindowContainerTransaction wct) {
            mPendingWct = wct;
                @Nullable PointF dragPosition) {
            mReleasedOnLeft = releasedOnLeft;
            mTaskScale = taskScale;
            mCornerRadius = cornerRadius;
            mDragPosition = dragPosition != null ? dragPosition : new PointF(0, 0);
        }

        /**
         * @return pending operations to be applied when finishing the drag
         */
        @Nullable
        public WindowContainerTransaction getPendingWct() {
            return mPendingWct;
        }

        /**
         * @return true if the bubble was released in the left drop target
         */
@@ -298,9 +287,6 @@ public class BubbleTransitions {
            mHomeIntentProvider.addLaunchHomePendingIntent(wct, mTaskInfo.displayId,
                    mTaskInfo.userId);

            if (mDragData != null && mDragData.getPendingWct() != null) {
                wct.merge(mDragData.getPendingWct(), true);
            }
            if (mTaskInfo.getWindowingMode() == WINDOWING_MODE_MULTI_WINDOW) {
                if (mTaskInfo.getParentTaskId() != INVALID_TASK_ID) {
                    wct.reparent(mTaskInfo.token, null, true);
+5 −10
Original line number Diff line number Diff line
@@ -287,10 +287,8 @@ sealed class DragToDesktopTransitionHandler(
                state.activeCancelAnimation = startCancelAnimation()
            } else {
                // Animation is handled by BubbleController
                val wct = WindowContainerTransaction()
                restoreWindowOrder(wct, state)
                val onLeft = cancelState == CancelState.CANCEL_BUBBLE_LEFT
                requestBubbleFromScaledTask(wct, onLeft)
                requestBubbleFromScaledTask(onLeft)
            }
        } else {
            // There's no dragged task, this can happen when the "cancel" happened too quickly
@@ -350,7 +348,7 @@ sealed class DragToDesktopTransitionHandler(
        splitScreenController.requestEnterSplitSelect(taskInfo, wct, splitPosition, taskBounds)
    }

    private fun requestBubbleFromScaledTask(wct: WindowContainerTransaction, onLeft: Boolean) {
    private fun requestBubbleFromScaledTask(onLeft: Boolean) {
        // TODO(b/391928049): update density once we can drag from desktop to bubble
        val state = requireTransitionState()
        val taskInfo = state.draggedTaskChange?.taskInfo ?: error("Expected non-null taskInfo")
@@ -358,11 +356,10 @@ sealed class DragToDesktopTransitionHandler(
        val scale = state.dragAnimator.scale
        val cornerRadius = state.dragAnimator.cornerRadius
        state.dragAnimator.cancelAnimator()
        requestBubble(wct, taskInfo, onLeft, scale, cornerRadius, dragPosition)
        requestBubble(taskInfo, onLeft, scale, cornerRadius, dragPosition)
    }

    private fun requestBubble(
        wct: WindowContainerTransaction,
        taskInfo: RunningTaskInfo,
        onLeft: Boolean,
        taskScale: Float = 1f,
@@ -373,7 +370,7 @@ sealed class DragToDesktopTransitionHandler(
            bubbleController.orElseThrow { IllegalStateException("BubbleController not set") }
        controller.expandStackAndSelectBubble(
            taskInfo,
            BubbleTransitions.DragData(onLeft, taskScale, cornerRadius, dragPosition, wct),
            BubbleTransitions.DragData(onLeft, taskScale, cornerRadius, dragPosition),
        )
    }

@@ -558,10 +555,8 @@ sealed class DragToDesktopTransitionHandler(
            }
            val taskInfo =
                state.draggedTaskChange?.taskInfo ?: error("Expected non-null task info.")
            val wct = WindowContainerTransaction()
            restoreWindowOrder(wct)
            val onLeft = state.cancelState == CancelState.CANCEL_BUBBLE_LEFT
            requestBubble(wct, taskInfo, onLeft)
            requestBubble(taskInfo, onLeft)
        }
        return true
    }
+2 −17
Original line number Diff line number Diff line
@@ -20,8 +20,6 @@ import static android.view.WindowManager.TRANSIT_TO_FRONT;

import static com.android.wm.shell.transition.Transitions.TRANSIT_CONVERT_TO_BUBBLE;

import static com.google.common.truth.Truth.assertThat;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
@@ -47,7 +45,6 @@ import android.view.ViewRootImpl;
import android.window.IWindowContainerToken;
import android.window.TransitionInfo;
import android.window.WindowContainerToken;
import android.window.WindowContainerTransaction;

import androidx.core.animation.AnimatorTestRule;
import androidx.test.filters.SmallTest;
@@ -230,31 +227,19 @@ public class BubbleTransitionsTest extends ShellTestCase {
    public void testConvertToBubble_drag() {
        ActivityManager.RunningTaskInfo taskInfo = setupBubble();

        WindowContainerTransaction pendingWct = new WindowContainerTransaction();
        WindowContainerToken pendingDragOpToken = createMockToken();
        pendingWct.reorder(pendingDragOpToken, /* onTop= */ false);

        PointF dragPosition = new PointF(10f, 20f);
        BubbleTransitions.DragData dragData = new BubbleTransitions.DragData(
                /* releasedOnLeft= */ false, /* taskScale= */ 0.5f, /* cornerRadius= */ 10f,
                dragPosition, pendingWct);
                dragPosition);

        final BubbleTransitions.BubbleTransition bt = mBubbleTransitions.startConvertToBubble(
                mBubble, taskInfo, mExpandedViewManager, mTaskViewFactory, mBubblePositioner,
                mStackView, mLayerView, mIconFactory, mHomeIntentProvider, dragData, false);
        final BubbleTransitions.ConvertToBubble ctb = (BubbleTransitions.ConvertToBubble) bt;

        ArgumentCaptor<WindowContainerTransaction> wctCaptor = ArgumentCaptor.forClass(
                WindowContainerTransaction.class);
        ctb.onInflated(mBubble);
        verify(mHomeIntentProvider).addLaunchHomePendingIntent(any(), anyInt(), anyInt());
        verify(mTransitions).startTransition(anyInt(), wctCaptor.capture(), eq(ctb));

        // Verify that the WCT has the pending operation from drag data
        WindowContainerTransaction transitionWct = wctCaptor.getValue();
        assertThat(transitionWct.getHierarchyOps().stream().anyMatch(op -> op.getType()
                == WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_REORDER
                && op.getContainer() == pendingDragOpToken.asBinder())).isTrue();
        verify(mTransitions).startTransition(anyInt(), any(), eq(ctb));

        SurfaceControl taskLeash = new SurfaceControl.Builder().setName("taskLeash").build();
        SurfaceControl snapshot = new SurfaceControl.Builder().setName("snapshot").build();