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

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

Merge "Add setFrameTimeline() call for task drag transaction." into main

parents 399f0d8e 3d3444ab
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ import android.graphics.PointF;
import android.graphics.Rect;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.view.Choreographer;
import android.view.Surface;
import android.view.SurfaceControl;
import android.window.TransitionInfo;
@@ -124,6 +126,11 @@ public class VeiledResizeTaskPositioner implements TaskPositioner, Transitions.T

    @Override
    public Rect onDragPositioningMove(float x, float y) {
        if (Looper.myLooper() != mHandler.getLooper()) {
            // This method must run on the shell main thread to use the correct Choreographer
            // instance below.
            throw new IllegalStateException("This method must run on the shell main thread.");
        }
        PointF delta = DragPositioningCallbackUtility.calculateDelta(x, y, mRepositionStartPoint);
        if (isResizing() && DragPositioningCallbackUtility.changeBounds(mCtrlType,
                mRepositionTaskBounds, mTaskBoundsAtDragStart, mStableBounds, delta,
@@ -141,6 +148,7 @@ public class VeiledResizeTaskPositioner implements TaskPositioner, Transitions.T
            final SurfaceControl.Transaction t = mTransactionSupplier.get();
            DragPositioningCallbackUtility.setPositionOnDrag(mDesktopWindowDecoration,
                    mRepositionTaskBounds, mTaskBoundsAtDragStart, mRepositionStartPoint, t, x, y);
            t.setFrameTimeline(Choreographer.getInstance().getVsyncId());
            t.apply();
        }
        return new Rect(mRepositionTaskBounds);
+17 −16
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.graphics.Point
import android.graphics.Rect
import android.os.Handler
import android.os.IBinder
import android.os.Looper
import android.testing.AndroidTestingRunner
import android.view.Display
import android.view.Surface.ROTATION_0
@@ -34,6 +35,7 @@ import android.view.WindowManager.TRANSIT_CHANGE
import android.window.TransitionInfo
import android.window.WindowContainerToken
import androidx.test.filters.SmallTest
import androidx.test.internal.runner.junit4.statement.UiThreadStatement.runOnUiThread
import com.android.internal.jank.InteractionJankMonitor
import com.android.wm.shell.ShellTaskOrganizer
import com.android.wm.shell.ShellTestCase
@@ -108,8 +110,7 @@ class VeiledResizeTaskPositionerTest : ShellTestCase() {
    private lateinit var mockResources: Resources
    @Mock
    private lateinit var mockInteractionJankMonitor: InteractionJankMonitor
    @Mock
    private lateinit var mockHandler: Handler
    private val mainHandler = Handler(Looper.getMainLooper())

    private lateinit var taskPositioner: VeiledResizeTaskPositioner

@@ -159,12 +160,12 @@ class VeiledResizeTaskPositionerTest : ShellTestCase() {
                        mockTransactionFactory,
                        mockTransitions,
                        mockInteractionJankMonitor,
                        mockHandler,
                        mainHandler,
                )
    }

    @Test
    fun testDragResize_noMove_doesNotShowResizeVeil() {
    fun testDragResize_noMove_doesNotShowResizeVeil() = runOnUiThread {
        taskPositioner.onDragPositioningStart(
            CTRL_TYPE_TOP or CTRL_TYPE_RIGHT,
            STARTING_BOUNDS.left.toFloat(),
@@ -176,6 +177,7 @@ class VeiledResizeTaskPositionerTest : ShellTestCase() {
            STARTING_BOUNDS.left.toFloat(),
            STARTING_BOUNDS.top.toFloat()
        )

        verify(mockTransitions, never()).startTransition(eq(TRANSIT_CHANGE), argThat { wct ->
            return@argThat wct.changes.any { (token, change) ->
                token == taskBinder &&
@@ -186,7 +188,7 @@ class VeiledResizeTaskPositionerTest : ShellTestCase() {
    }

    @Test
    fun testDragResize_movesTask_doesNotShowResizeVeil() {
    fun testDragResize_movesTask_doesNotShowResizeVeil() = runOnUiThread {
        taskPositioner.onDragPositioningStart(
            CTRL_TYPE_UNDEFINED,
            STARTING_BOUNDS.left.toFloat(),
@@ -221,7 +223,7 @@ class VeiledResizeTaskPositionerTest : ShellTestCase() {
    }

    @Test
    fun testDragResize_resize_boundsUpdateOnEnd() {
    fun testDragResize_resize_boundsUpdateOnEnd() = runOnUiThread {
        taskPositioner.onDragPositioningStart(
            CTRL_TYPE_RIGHT or CTRL_TYPE_TOP,
            STARTING_BOUNDS.right.toFloat(),
@@ -262,7 +264,7 @@ class VeiledResizeTaskPositionerTest : ShellTestCase() {
    }

    @Test
    fun testDragResize_noEffectiveMove_skipsTransactionOnEnd() {
    fun testDragResize_noEffectiveMove_skipsTransactionOnEnd() = runOnUiThread {
        taskPositioner.onDragPositioningStart(
            CTRL_TYPE_TOP or CTRL_TYPE_RIGHT,
            STARTING_BOUNDS.left.toFloat(),
@@ -294,9 +296,8 @@ class VeiledResizeTaskPositionerTest : ShellTestCase() {
        })
    }


    @Test
    fun testDragResize_drag_setBoundsNotRunIfDragEndsInDisallowedEndArea() {
    fun testDragResize_drag_setBoundsNotRunIfDragEndsInDisallowedEndArea() = runOnUiThread {
        taskPositioner.onDragPositioningStart(
                CTRL_TYPE_UNDEFINED, // drag
                STARTING_BOUNDS.left.toFloat(),
@@ -321,7 +322,7 @@ class VeiledResizeTaskPositionerTest : ShellTestCase() {
    }

    @Test
    fun testDragResize_resize_resizingTaskReorderedToTopWhenNotFocused() {
    fun testDragResize_resize_resizingTaskReorderedToTopWhenNotFocused() = runOnUiThread {
        mockDesktopWindowDecoration.mTaskInfo.isFocused = false
        taskPositioner.onDragPositioningStart(
                CTRL_TYPE_RIGHT, // Resize right
@@ -337,7 +338,7 @@ class VeiledResizeTaskPositionerTest : ShellTestCase() {
    }

    @Test
    fun testDragResize_resize_resizingTaskNotReorderedToTopWhenFocused() {
    fun testDragResize_resize_resizingTaskNotReorderedToTopWhenFocused() = runOnUiThread {
        mockDesktopWindowDecoration.mTaskInfo.isFocused = true
        taskPositioner.onDragPositioningStart(
                CTRL_TYPE_RIGHT, // Resize right
@@ -353,7 +354,7 @@ class VeiledResizeTaskPositionerTest : ShellTestCase() {
    }

    @Test
    fun testDragResize_drag_draggedTaskNotReorderedToTop() {
    fun testDragResize_drag_draggedTaskNotReorderedToTop() = runOnUiThread {
        mockDesktopWindowDecoration.mTaskInfo.isFocused = false
        taskPositioner.onDragPositioningStart(
                CTRL_TYPE_UNDEFINED, // drag
@@ -370,7 +371,7 @@ class VeiledResizeTaskPositionerTest : ShellTestCase() {
    }

    @Test
    fun testDragResize_drag_updatesStableBoundsOnRotate() {
    fun testDragResize_drag_updatesStableBoundsOnRotate() = runOnUiThread {
        // Test landscape stable bounds
        performDrag(STARTING_BOUNDS.right.toFloat(), STARTING_BOUNDS.bottom.toFloat(),
            STARTING_BOUNDS.right.toFloat() + 2000, STARTING_BOUNDS.bottom.toFloat() + 2000,
@@ -416,7 +417,7 @@ class VeiledResizeTaskPositionerTest : ShellTestCase() {
    }

    @Test
    fun testIsResizingOrAnimatingResizeSet() {
    fun testIsResizingOrAnimatingResizeSet() = runOnUiThread {
        Assert.assertFalse(taskPositioner.isResizingOrAnimating)

        taskPositioner.onDragPositioningStart(
@@ -443,7 +444,7 @@ class VeiledResizeTaskPositionerTest : ShellTestCase() {
    }

    @Test
    fun testIsResizingOrAnimatingResizeResetAfterStartAnimation() {
    fun testIsResizingOrAnimatingResizeResetAfterStartAnimation() = runOnUiThread {
        performDrag(
                STARTING_BOUNDS.left.toFloat(), STARTING_BOUNDS.top.toFloat(),
                STARTING_BOUNDS.left.toFloat() - 20, STARTING_BOUNDS.top.toFloat() - 20,
@@ -457,7 +458,7 @@ class VeiledResizeTaskPositionerTest : ShellTestCase() {
    }

    @Test
    fun testStartAnimation_useEndRelOffset() {
    fun testStartAnimation_useEndRelOffset() = runOnUiThread {
        val changeMock = mock(TransitionInfo.Change::class.java)
        val startTransaction = mock(Transaction::class.java)
        val finishTransaction = mock(Transaction::class.java)