Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/VeiledResizeTaskPositioner.java +8 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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, Loading @@ -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); Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/VeiledResizeTaskPositionerTest.kt +17 −16 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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 Loading Loading @@ -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 Loading Loading @@ -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(), Loading @@ -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 && Loading @@ -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(), Loading Loading @@ -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(), Loading Loading @@ -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(), Loading Loading @@ -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(), Loading @@ -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 Loading @@ -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 Loading @@ -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 Loading @@ -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, Loading Loading @@ -416,7 +417,7 @@ class VeiledResizeTaskPositionerTest : ShellTestCase() { } @Test fun testIsResizingOrAnimatingResizeSet() { fun testIsResizingOrAnimatingResizeSet() = runOnUiThread { Assert.assertFalse(taskPositioner.isResizingOrAnimating) taskPositioner.onDragPositioningStart( Loading @@ -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, Loading @@ -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) Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/VeiledResizeTaskPositioner.java +8 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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, Loading @@ -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); Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/VeiledResizeTaskPositionerTest.kt +17 −16 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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 Loading Loading @@ -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 Loading Loading @@ -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(), Loading @@ -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 && Loading @@ -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(), Loading Loading @@ -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(), Loading Loading @@ -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(), Loading Loading @@ -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(), Loading @@ -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 Loading @@ -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 Loading @@ -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 Loading @@ -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, Loading Loading @@ -416,7 +417,7 @@ class VeiledResizeTaskPositionerTest : ShellTestCase() { } @Test fun testIsResizingOrAnimatingResizeSet() { fun testIsResizingOrAnimatingResizeSet() = runOnUiThread { Assert.assertFalse(taskPositioner.isResizingOrAnimating) taskPositioner.onDragPositioningStart( Loading @@ -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, Loading @@ -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) Loading