Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeVisualIndicator.java +10 −3 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.graphics.Region; import android.util.Pair; import android.view.Display; import android.view.SurfaceControl; import android.window.DesktopExperienceFlags; import android.window.DesktopModeFlags; import androidx.annotation.VisibleForTesting; Loading Loading @@ -258,8 +259,8 @@ public class DesktopModeVisualIndicator { * display, including no visible indicator, and update the indicator. */ @NonNull IndicatorType updateIndicatorType(PointF inputCoordinates) { final IndicatorType result = calculateIndicatorType(inputCoordinates); IndicatorType updateIndicatorType(int displayId, PointF inputCoordinates) { final IndicatorType result = calculateIndicatorType(displayId, inputCoordinates); updateIndicatorWithType(result); return result; } Loading @@ -269,7 +270,13 @@ public class DesktopModeVisualIndicator { * display, including no visible indicator. */ @NonNull IndicatorType calculateIndicatorType(PointF inputCoordinates) { IndicatorType calculateIndicatorType(int displayId, PointF inputCoordinates) { if (DesktopExperienceFlags.ENABLE_CONNECTED_DISPLAYS_WINDOW_DRAG.isTrue() && mTaskInfo.displayId != displayId) { // TODO(b/411292927): Allow indicator to show on the target display (`displayId`) // even if it differs from the task's original display. return NO_INDICATOR; } final IndicatorType result; if (mUseSmallTabletRegions) { result = getIndicatorSmallTablet(inputCoordinates); Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +15 −4 Original line number Diff line number Diff line Loading @@ -3809,12 +3809,15 @@ class DesktopTasksController( * * @param taskInfo the task being dragged. * @param taskSurface SurfaceControl of dragged task. * @param displayId displayId of the input event. * @param inputX x coordinate of input. Used for checks against left/right edge of screen. * @param inputY y coordinate of input. Used for checks about cross display drag. * @param taskBounds bounds of dragged task. Used for checks against status bar height. */ fun onDragPositioningMove( taskInfo: RunningTaskInfo, taskSurface: SurfaceControl, displayId: Int, inputX: Float, inputY: Float, taskBounds: Rect, Loading @@ -3825,6 +3828,7 @@ class DesktopTasksController( updateVisualIndicator( taskInfo, taskSurface, displayId, inputX, taskBounds.top.toFloat(), DragStartState.FROM_FREEFORM, Loading @@ -3835,7 +3839,7 @@ class DesktopTasksController( val indicator = getOrCreateVisualIndicator(taskInfo, taskSurface, DragStartState.FROM_FREEFORM) val indicatorType = indicator.calculateIndicatorType(PointF(inputX, taskBounds.top.toFloat())) indicator.calculateIndicatorType(displayId, PointF(inputX, taskBounds.top.toFloat())) visualIndicatorUpdateScheduler.schedule( taskInfo.displayId, indicatorType, Loading @@ -3849,12 +3853,13 @@ class DesktopTasksController( fun updateVisualIndicator( taskInfo: RunningTaskInfo, taskSurface: SurfaceControl?, displayId: Int, inputX: Float, taskTop: Float, dragStartState: DragStartState, ): IndicatorType { return getOrCreateVisualIndicator(taskInfo, taskSurface, dragStartState) .updateIndicatorType(PointF(inputX, taskTop)) .updateIndicatorType(displayId, PointF(inputX, taskTop)) } @VisibleForTesting Loading Loading @@ -3899,6 +3904,7 @@ class DesktopTasksController( * * @param taskInfo the task being dragged. * @param taskSurface the leash of the task being dragged. * @param displayId the displayId of the input event. * @param inputCoordinate the coordinates of the motion event * @param currentDragBounds the current bounds of where the visible task is (might be actual * task bounds or just task leash) Loading @@ -3908,6 +3914,7 @@ class DesktopTasksController( fun onDragPositioningEnd( taskInfo: RunningTaskInfo, taskSurface: SurfaceControl, displayId: Int, inputCoordinate: PointF, currentDragBounds: Rect, validDragArea: Rect, Loading @@ -3921,7 +3928,8 @@ class DesktopTasksController( val indicator = getVisualIndicator() ?: return val indicatorType = indicator.updateIndicatorType( PointF(inputCoordinate.x, currentDragBounds.top.toFloat()) displayId, PointF(inputCoordinate.x, currentDragBounds.top.toFloat()), ) when (indicatorType) { IndicatorType.TO_FULLSCREEN_INDICATOR -> { Loading Loading @@ -4051,11 +4059,13 @@ class DesktopTasksController( /** * Perform checks required when drag ends under status bar area. * * @param displayId the displayId of the input event. * @param taskInfo the task being dragged. * @param y height of drag, to be checked against status bar height. * @return the [IndicatorType] used for the resulting transition */ fun onDragPositioningEndThroughStatusBar( displayId: Int, inputCoordinates: PointF, taskInfo: RunningTaskInfo, taskSurface: SurfaceControl, Loading @@ -4063,7 +4073,7 @@ class DesktopTasksController( // End the drag_hold CUJ interaction. interactionJankMonitor.end(CUJ_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG_HOLD) val indicator = getVisualIndicator() ?: return IndicatorType.NO_INDICATOR val indicatorType = indicator.updateIndicatorType(inputCoordinates) val indicatorType = indicator.updateIndicatorType(displayId, inputCoordinates) when (indicatorType) { IndicatorType.TO_DESKTOP_INDICATOR -> { latencyTracker.onActionStart( Loading Loading @@ -4175,6 +4185,7 @@ class DesktopTasksController( updateVisualIndicator( taskInfo, dragEvent.dragSurface, dragEvent.displayId, dragEvent.x, dragEvent.y, DragStartState.DRAGGED_INTENT, Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java +7 −4 Original line number Diff line number Diff line Loading @@ -1362,6 +1362,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel, e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx)); mDesktopTasksController.onDragPositioningMove(taskInfo, decoration.mTaskSurface, e.getDisplayId(), e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx), newTaskBounds); Loading Loading @@ -1391,6 +1392,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel, // or transforming to fullscreen) before setting new task bounds. mDesktopTasksController.onDragPositioningEnd( taskInfo, decoration.mTaskSurface, e.getDisplayId(), new PointF(e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx)), newTaskBounds, decoration.calculateValidDragArea(), new Rect(mOnDragStartInitialBounds), e); Loading Loading @@ -1628,8 +1630,8 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel, .getDragStartState(relevantDecor.mTaskInfo); if (dragStartState == null) return; mDesktopTasksController.updateVisualIndicator(relevantDecor.mTaskInfo, relevantDecor.mTaskSurface, ev.getRawX(), ev.getRawY(), dragStartState); relevantDecor.mTaskSurface, ev.getDisplayId(), ev.getRawX(), ev.getRawY(), dragStartState); mTransitionDragActive = false; if (mMoveToDesktopAnimator != null) { // Though this isn't a hover event, we need to update handle's hover state Loading Loading @@ -1674,8 +1676,8 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel, if (dragStartState == null) return; final DesktopModeVisualIndicator.IndicatorType indicatorType = mDesktopTasksController.updateVisualIndicator( relevantDecor.mTaskInfo, relevantDecor.mTaskSurface, ev.getRawX(), ev.getRawY(), relevantDecor.mTaskInfo, relevantDecor.mTaskSurface, ev.getDisplayId(), ev.getRawX(), ev.getRawY(), dragStartState); if (indicatorType != TO_FULLSCREEN_INDICATOR || BubbleAnythingFlagHelper.enableBubbleToFullscreen()) { Loading Loading @@ -1708,6 +1710,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel, private void endDragToDesktop(MotionEvent ev, DesktopModeWindowDecoration relevantDecor) { DesktopModeVisualIndicator.IndicatorType resultType = mDesktopTasksController.onDragPositioningEndThroughStatusBar( ev.getDisplayId(), new PointF(ev.getRawX(), ev.getRawY()), relevantDecor.mTaskInfo, relevantDecor.mTaskSurface); Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopModeVisualIndicatorTest.kt +45 −30 Original line number Diff line number Diff line Loading @@ -24,9 +24,11 @@ import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import android.testing.AndroidTestingRunner import android.testing.TestableLooper.RunWithLooper import android.view.Display.DEFAULT_DISPLAY import android.view.SurfaceControl import androidx.test.filters.SmallTest import com.android.internal.policy.SystemBarUtils import com.android.window.flags.Flags.FLAG_ENABLE_CONNECTED_DISPLAYS_WINDOW_DRAG import com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE import com.android.window.flags.Flags.FLAG_ENABLE_VISUAL_INDICATOR_IN_TRANSITION_BUGFIX import com.android.wm.shell.R Loading Loading @@ -263,18 +265,18 @@ class DesktopModeVisualIndicatorTest : ShellTestCase() { @Test fun testDefaultIndicators() { createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_FULLSCREEN) var result = visualIndicator.updateIndicatorType(PointF(-10000f, 500f)) var result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, PointF(-10000f, 500f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_LEFT_INDICATOR) createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_SPLIT) result = visualIndicator.updateIndicatorType(PointF(10000f, 500f)) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, PointF(10000f, 500f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_RIGHT_INDICATOR) createVisualIndicator(DesktopModeVisualIndicator.DragStartState.DRAGGED_INTENT) result = visualIndicator.updateIndicatorType(PointF(500f, 10000f)) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, PointF(500f, 10000f)) assertThat(result).isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_DESKTOP_INDICATOR) createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_FREEFORM) result = visualIndicator.updateIndicatorType(PointF(500f, 10000f)) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, PointF(500f, 10000f)) assertThat(result).isEqualTo(DesktopModeVisualIndicator.IndicatorType.NO_INDICATOR) } Loading @@ -285,28 +287,28 @@ class DesktopModeVisualIndicatorTest : ShellTestCase() { ) fun testDefaultIndicators_enableBubbleToFullscreen() { createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_FULLSCREEN) var result = visualIndicator.updateIndicatorType(PointF(10f, 1500f)) var result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, PointF(10f, 1500f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_BUBBLE_LEFT_INDICATOR) result = visualIndicator.updateIndicatorType(PointF(2390f, 1500f)) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, PointF(2390f, 1500f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_BUBBLE_RIGHT_INDICATOR) // Check that bubble zones are not available from split createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_SPLIT) result = visualIndicator.updateIndicatorType(PointF(10f, 1500f)) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, PointF(10f, 1500f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_LEFT_INDICATOR) result = visualIndicator.updateIndicatorType(PointF(2390f, 1500f)) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, PointF(2390f, 1500f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_RIGHT_INDICATOR) // Check that bubble zones are not available from desktop createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_FREEFORM) result = visualIndicator.updateIndicatorType(PointF(10f, 1500f)) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, PointF(10f, 1500f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_LEFT_INDICATOR) result = visualIndicator.updateIndicatorType(PointF(2390f, 1500f)) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, PointF(2390f, 1500f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_RIGHT_INDICATOR) } Loading @@ -324,23 +326,23 @@ class DesktopModeVisualIndicatorTest : ShellTestCase() { isSmallTablet = true, isLeftRightSplit = true, ) var result = visualIndicator.updateIndicatorType(foldCenter()) var result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldCenter()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_FULLSCREEN_INDICATOR) result = visualIndicator.updateIndicatorType(foldLeftEdge()) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldLeftEdge()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_LEFT_INDICATOR) result = visualIndicator.updateIndicatorType(foldRightEdge()) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldRightEdge()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_RIGHT_INDICATOR) result = visualIndicator.updateIndicatorType(foldLeftBottom()) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldLeftBottom()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_BUBBLE_LEFT_INDICATOR) result = visualIndicator.updateIndicatorType(foldRightBottom()) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldRightBottom()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_BUBBLE_RIGHT_INDICATOR) } Loading @@ -359,16 +361,16 @@ class DesktopModeVisualIndicatorTest : ShellTestCase() { isSmallTablet = true, isLeftRightSplit = true, ) var result = visualIndicator.updateIndicatorType(foldCenter()) var result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldCenter()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_FULLSCREEN_INDICATOR) // Check that bubbles are not available from split result = visualIndicator.updateIndicatorType(foldLeftBottom()) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldLeftBottom()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_LEFT_INDICATOR) result = visualIndicator.updateIndicatorType(foldRightBottom()) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldRightBottom()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_RIGHT_INDICATOR) } Loading @@ -383,15 +385,15 @@ class DesktopModeVisualIndicatorTest : ShellTestCase() { isSmallTablet = true, isLeftRightSplit = true, ) var result = visualIndicator.updateIndicatorType(foldCenter()) var result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldCenter()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_FULLSCREEN_INDICATOR) result = visualIndicator.updateIndicatorType(foldLeftBottom()) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldLeftBottom()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_BUBBLE_LEFT_INDICATOR) result = visualIndicator.updateIndicatorType(foldRightBottom()) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldRightBottom()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_BUBBLE_RIGHT_INDICATOR) } Loading @@ -409,19 +411,19 @@ class DesktopModeVisualIndicatorTest : ShellTestCase() { isSmallTablet = true, isLeftRightSplit = false, ) var result = visualIndicator.updateIndicatorType(foldCenter()) var result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldCenter()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_FULLSCREEN_INDICATOR) result = visualIndicator.updateIndicatorType(foldLeftEdge()) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldLeftEdge()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_FULLSCREEN_INDICATOR) result = visualIndicator.updateIndicatorType(foldLeftBottom()) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldLeftBottom()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_BUBBLE_LEFT_INDICATOR) result = visualIndicator.updateIndicatorType(foldRightBottom()) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldRightBottom()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_BUBBLE_RIGHT_INDICATOR) Loading @@ -431,11 +433,24 @@ class DesktopModeVisualIndicatorTest : ShellTestCase() { isLeftRightSplit = false, ) // No indicator as top/bottom split apps should not be dragged result = visualIndicator.updateIndicatorType(foldCenter()) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldCenter()) assertThat(result).isEqualTo(DesktopModeVisualIndicator.IndicatorType.NO_INDICATOR) result = visualIndicator.updateIndicatorType(foldLeftBottom()) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldLeftBottom()) assertThat(result).isEqualTo(DesktopModeVisualIndicator.IndicatorType.NO_INDICATOR) result = visualIndicator.updateIndicatorType(foldRightBottom()) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldRightBottom()) assertThat(result).isEqualTo(DesktopModeVisualIndicator.IndicatorType.NO_INDICATOR) } @Test @EnableFlags(FLAG_ENABLE_CONNECTED_DISPLAYS_WINDOW_DRAG) fun testDefaultIndicators_crossDisplayDrag_noIndicator() { createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_FULLSCREEN) // Simulate dragging to a point on a different display. // Even though this point (-10000f, 500f) would trigger TO_SPLIT_LEFT_INDICATOR // on the original display, dragging across displays should show no indicator. val result = visualIndicator.updateIndicatorType(/* displayId= */ 10, PointF(-10000f, 500f)) assertThat(result).isEqualTo(DesktopModeVisualIndicator.IndicatorType.NO_INDICATOR) } Loading @@ -451,7 +466,7 @@ class DesktopModeVisualIndicatorTest : ShellTestCase() { createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_FULLSCREEN) desktopExecutor.flushAll() mainExecutor.flushAll() visualIndicator.updateIndicatorType(PointF(100f, 1500f)) visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, PointF(100f, 1500f)) desktopExecutor.flushAll() mainExecutor.flushAll() Loading @@ -472,7 +487,7 @@ class DesktopModeVisualIndicatorTest : ShellTestCase() { createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_FULLSCREEN) desktopExecutor.flushAll() mainExecutor.flushAll() visualIndicator.updateIndicatorType(PointF(2300f, 1500f)) visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, PointF(2300f, 1500f)) desktopExecutor.flushAll() mainExecutor.flushAll() Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +182 −45 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeVisualIndicator.java +10 −3 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.graphics.Region; import android.util.Pair; import android.view.Display; import android.view.SurfaceControl; import android.window.DesktopExperienceFlags; import android.window.DesktopModeFlags; import androidx.annotation.VisibleForTesting; Loading Loading @@ -258,8 +259,8 @@ public class DesktopModeVisualIndicator { * display, including no visible indicator, and update the indicator. */ @NonNull IndicatorType updateIndicatorType(PointF inputCoordinates) { final IndicatorType result = calculateIndicatorType(inputCoordinates); IndicatorType updateIndicatorType(int displayId, PointF inputCoordinates) { final IndicatorType result = calculateIndicatorType(displayId, inputCoordinates); updateIndicatorWithType(result); return result; } Loading @@ -269,7 +270,13 @@ public class DesktopModeVisualIndicator { * display, including no visible indicator. */ @NonNull IndicatorType calculateIndicatorType(PointF inputCoordinates) { IndicatorType calculateIndicatorType(int displayId, PointF inputCoordinates) { if (DesktopExperienceFlags.ENABLE_CONNECTED_DISPLAYS_WINDOW_DRAG.isTrue() && mTaskInfo.displayId != displayId) { // TODO(b/411292927): Allow indicator to show on the target display (`displayId`) // even if it differs from the task's original display. return NO_INDICATOR; } final IndicatorType result; if (mUseSmallTabletRegions) { result = getIndicatorSmallTablet(inputCoordinates); Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +15 −4 Original line number Diff line number Diff line Loading @@ -3809,12 +3809,15 @@ class DesktopTasksController( * * @param taskInfo the task being dragged. * @param taskSurface SurfaceControl of dragged task. * @param displayId displayId of the input event. * @param inputX x coordinate of input. Used for checks against left/right edge of screen. * @param inputY y coordinate of input. Used for checks about cross display drag. * @param taskBounds bounds of dragged task. Used for checks against status bar height. */ fun onDragPositioningMove( taskInfo: RunningTaskInfo, taskSurface: SurfaceControl, displayId: Int, inputX: Float, inputY: Float, taskBounds: Rect, Loading @@ -3825,6 +3828,7 @@ class DesktopTasksController( updateVisualIndicator( taskInfo, taskSurface, displayId, inputX, taskBounds.top.toFloat(), DragStartState.FROM_FREEFORM, Loading @@ -3835,7 +3839,7 @@ class DesktopTasksController( val indicator = getOrCreateVisualIndicator(taskInfo, taskSurface, DragStartState.FROM_FREEFORM) val indicatorType = indicator.calculateIndicatorType(PointF(inputX, taskBounds.top.toFloat())) indicator.calculateIndicatorType(displayId, PointF(inputX, taskBounds.top.toFloat())) visualIndicatorUpdateScheduler.schedule( taskInfo.displayId, indicatorType, Loading @@ -3849,12 +3853,13 @@ class DesktopTasksController( fun updateVisualIndicator( taskInfo: RunningTaskInfo, taskSurface: SurfaceControl?, displayId: Int, inputX: Float, taskTop: Float, dragStartState: DragStartState, ): IndicatorType { return getOrCreateVisualIndicator(taskInfo, taskSurface, dragStartState) .updateIndicatorType(PointF(inputX, taskTop)) .updateIndicatorType(displayId, PointF(inputX, taskTop)) } @VisibleForTesting Loading Loading @@ -3899,6 +3904,7 @@ class DesktopTasksController( * * @param taskInfo the task being dragged. * @param taskSurface the leash of the task being dragged. * @param displayId the displayId of the input event. * @param inputCoordinate the coordinates of the motion event * @param currentDragBounds the current bounds of where the visible task is (might be actual * task bounds or just task leash) Loading @@ -3908,6 +3914,7 @@ class DesktopTasksController( fun onDragPositioningEnd( taskInfo: RunningTaskInfo, taskSurface: SurfaceControl, displayId: Int, inputCoordinate: PointF, currentDragBounds: Rect, validDragArea: Rect, Loading @@ -3921,7 +3928,8 @@ class DesktopTasksController( val indicator = getVisualIndicator() ?: return val indicatorType = indicator.updateIndicatorType( PointF(inputCoordinate.x, currentDragBounds.top.toFloat()) displayId, PointF(inputCoordinate.x, currentDragBounds.top.toFloat()), ) when (indicatorType) { IndicatorType.TO_FULLSCREEN_INDICATOR -> { Loading Loading @@ -4051,11 +4059,13 @@ class DesktopTasksController( /** * Perform checks required when drag ends under status bar area. * * @param displayId the displayId of the input event. * @param taskInfo the task being dragged. * @param y height of drag, to be checked against status bar height. * @return the [IndicatorType] used for the resulting transition */ fun onDragPositioningEndThroughStatusBar( displayId: Int, inputCoordinates: PointF, taskInfo: RunningTaskInfo, taskSurface: SurfaceControl, Loading @@ -4063,7 +4073,7 @@ class DesktopTasksController( // End the drag_hold CUJ interaction. interactionJankMonitor.end(CUJ_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG_HOLD) val indicator = getVisualIndicator() ?: return IndicatorType.NO_INDICATOR val indicatorType = indicator.updateIndicatorType(inputCoordinates) val indicatorType = indicator.updateIndicatorType(displayId, inputCoordinates) when (indicatorType) { IndicatorType.TO_DESKTOP_INDICATOR -> { latencyTracker.onActionStart( Loading Loading @@ -4175,6 +4185,7 @@ class DesktopTasksController( updateVisualIndicator( taskInfo, dragEvent.dragSurface, dragEvent.displayId, dragEvent.x, dragEvent.y, DragStartState.DRAGGED_INTENT, Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java +7 −4 Original line number Diff line number Diff line Loading @@ -1362,6 +1362,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel, e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx)); mDesktopTasksController.onDragPositioningMove(taskInfo, decoration.mTaskSurface, e.getDisplayId(), e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx), newTaskBounds); Loading Loading @@ -1391,6 +1392,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel, // or transforming to fullscreen) before setting new task bounds. mDesktopTasksController.onDragPositioningEnd( taskInfo, decoration.mTaskSurface, e.getDisplayId(), new PointF(e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx)), newTaskBounds, decoration.calculateValidDragArea(), new Rect(mOnDragStartInitialBounds), e); Loading Loading @@ -1628,8 +1630,8 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel, .getDragStartState(relevantDecor.mTaskInfo); if (dragStartState == null) return; mDesktopTasksController.updateVisualIndicator(relevantDecor.mTaskInfo, relevantDecor.mTaskSurface, ev.getRawX(), ev.getRawY(), dragStartState); relevantDecor.mTaskSurface, ev.getDisplayId(), ev.getRawX(), ev.getRawY(), dragStartState); mTransitionDragActive = false; if (mMoveToDesktopAnimator != null) { // Though this isn't a hover event, we need to update handle's hover state Loading Loading @@ -1674,8 +1676,8 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel, if (dragStartState == null) return; final DesktopModeVisualIndicator.IndicatorType indicatorType = mDesktopTasksController.updateVisualIndicator( relevantDecor.mTaskInfo, relevantDecor.mTaskSurface, ev.getRawX(), ev.getRawY(), relevantDecor.mTaskInfo, relevantDecor.mTaskSurface, ev.getDisplayId(), ev.getRawX(), ev.getRawY(), dragStartState); if (indicatorType != TO_FULLSCREEN_INDICATOR || BubbleAnythingFlagHelper.enableBubbleToFullscreen()) { Loading Loading @@ -1708,6 +1710,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel, private void endDragToDesktop(MotionEvent ev, DesktopModeWindowDecoration relevantDecor) { DesktopModeVisualIndicator.IndicatorType resultType = mDesktopTasksController.onDragPositioningEndThroughStatusBar( ev.getDisplayId(), new PointF(ev.getRawX(), ev.getRawY()), relevantDecor.mTaskInfo, relevantDecor.mTaskSurface); Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopModeVisualIndicatorTest.kt +45 −30 Original line number Diff line number Diff line Loading @@ -24,9 +24,11 @@ import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import android.testing.AndroidTestingRunner import android.testing.TestableLooper.RunWithLooper import android.view.Display.DEFAULT_DISPLAY import android.view.SurfaceControl import androidx.test.filters.SmallTest import com.android.internal.policy.SystemBarUtils import com.android.window.flags.Flags.FLAG_ENABLE_CONNECTED_DISPLAYS_WINDOW_DRAG import com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE import com.android.window.flags.Flags.FLAG_ENABLE_VISUAL_INDICATOR_IN_TRANSITION_BUGFIX import com.android.wm.shell.R Loading Loading @@ -263,18 +265,18 @@ class DesktopModeVisualIndicatorTest : ShellTestCase() { @Test fun testDefaultIndicators() { createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_FULLSCREEN) var result = visualIndicator.updateIndicatorType(PointF(-10000f, 500f)) var result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, PointF(-10000f, 500f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_LEFT_INDICATOR) createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_SPLIT) result = visualIndicator.updateIndicatorType(PointF(10000f, 500f)) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, PointF(10000f, 500f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_RIGHT_INDICATOR) createVisualIndicator(DesktopModeVisualIndicator.DragStartState.DRAGGED_INTENT) result = visualIndicator.updateIndicatorType(PointF(500f, 10000f)) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, PointF(500f, 10000f)) assertThat(result).isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_DESKTOP_INDICATOR) createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_FREEFORM) result = visualIndicator.updateIndicatorType(PointF(500f, 10000f)) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, PointF(500f, 10000f)) assertThat(result).isEqualTo(DesktopModeVisualIndicator.IndicatorType.NO_INDICATOR) } Loading @@ -285,28 +287,28 @@ class DesktopModeVisualIndicatorTest : ShellTestCase() { ) fun testDefaultIndicators_enableBubbleToFullscreen() { createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_FULLSCREEN) var result = visualIndicator.updateIndicatorType(PointF(10f, 1500f)) var result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, PointF(10f, 1500f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_BUBBLE_LEFT_INDICATOR) result = visualIndicator.updateIndicatorType(PointF(2390f, 1500f)) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, PointF(2390f, 1500f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_BUBBLE_RIGHT_INDICATOR) // Check that bubble zones are not available from split createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_SPLIT) result = visualIndicator.updateIndicatorType(PointF(10f, 1500f)) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, PointF(10f, 1500f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_LEFT_INDICATOR) result = visualIndicator.updateIndicatorType(PointF(2390f, 1500f)) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, PointF(2390f, 1500f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_RIGHT_INDICATOR) // Check that bubble zones are not available from desktop createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_FREEFORM) result = visualIndicator.updateIndicatorType(PointF(10f, 1500f)) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, PointF(10f, 1500f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_LEFT_INDICATOR) result = visualIndicator.updateIndicatorType(PointF(2390f, 1500f)) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, PointF(2390f, 1500f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_RIGHT_INDICATOR) } Loading @@ -324,23 +326,23 @@ class DesktopModeVisualIndicatorTest : ShellTestCase() { isSmallTablet = true, isLeftRightSplit = true, ) var result = visualIndicator.updateIndicatorType(foldCenter()) var result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldCenter()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_FULLSCREEN_INDICATOR) result = visualIndicator.updateIndicatorType(foldLeftEdge()) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldLeftEdge()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_LEFT_INDICATOR) result = visualIndicator.updateIndicatorType(foldRightEdge()) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldRightEdge()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_RIGHT_INDICATOR) result = visualIndicator.updateIndicatorType(foldLeftBottom()) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldLeftBottom()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_BUBBLE_LEFT_INDICATOR) result = visualIndicator.updateIndicatorType(foldRightBottom()) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldRightBottom()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_BUBBLE_RIGHT_INDICATOR) } Loading @@ -359,16 +361,16 @@ class DesktopModeVisualIndicatorTest : ShellTestCase() { isSmallTablet = true, isLeftRightSplit = true, ) var result = visualIndicator.updateIndicatorType(foldCenter()) var result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldCenter()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_FULLSCREEN_INDICATOR) // Check that bubbles are not available from split result = visualIndicator.updateIndicatorType(foldLeftBottom()) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldLeftBottom()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_LEFT_INDICATOR) result = visualIndicator.updateIndicatorType(foldRightBottom()) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldRightBottom()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_RIGHT_INDICATOR) } Loading @@ -383,15 +385,15 @@ class DesktopModeVisualIndicatorTest : ShellTestCase() { isSmallTablet = true, isLeftRightSplit = true, ) var result = visualIndicator.updateIndicatorType(foldCenter()) var result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldCenter()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_FULLSCREEN_INDICATOR) result = visualIndicator.updateIndicatorType(foldLeftBottom()) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldLeftBottom()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_BUBBLE_LEFT_INDICATOR) result = visualIndicator.updateIndicatorType(foldRightBottom()) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldRightBottom()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_BUBBLE_RIGHT_INDICATOR) } Loading @@ -409,19 +411,19 @@ class DesktopModeVisualIndicatorTest : ShellTestCase() { isSmallTablet = true, isLeftRightSplit = false, ) var result = visualIndicator.updateIndicatorType(foldCenter()) var result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldCenter()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_FULLSCREEN_INDICATOR) result = visualIndicator.updateIndicatorType(foldLeftEdge()) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldLeftEdge()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_FULLSCREEN_INDICATOR) result = visualIndicator.updateIndicatorType(foldLeftBottom()) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldLeftBottom()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_BUBBLE_LEFT_INDICATOR) result = visualIndicator.updateIndicatorType(foldRightBottom()) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldRightBottom()) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_BUBBLE_RIGHT_INDICATOR) Loading @@ -431,11 +433,24 @@ class DesktopModeVisualIndicatorTest : ShellTestCase() { isLeftRightSplit = false, ) // No indicator as top/bottom split apps should not be dragged result = visualIndicator.updateIndicatorType(foldCenter()) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldCenter()) assertThat(result).isEqualTo(DesktopModeVisualIndicator.IndicatorType.NO_INDICATOR) result = visualIndicator.updateIndicatorType(foldLeftBottom()) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldLeftBottom()) assertThat(result).isEqualTo(DesktopModeVisualIndicator.IndicatorType.NO_INDICATOR) result = visualIndicator.updateIndicatorType(foldRightBottom()) result = visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, foldRightBottom()) assertThat(result).isEqualTo(DesktopModeVisualIndicator.IndicatorType.NO_INDICATOR) } @Test @EnableFlags(FLAG_ENABLE_CONNECTED_DISPLAYS_WINDOW_DRAG) fun testDefaultIndicators_crossDisplayDrag_noIndicator() { createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_FULLSCREEN) // Simulate dragging to a point on a different display. // Even though this point (-10000f, 500f) would trigger TO_SPLIT_LEFT_INDICATOR // on the original display, dragging across displays should show no indicator. val result = visualIndicator.updateIndicatorType(/* displayId= */ 10, PointF(-10000f, 500f)) assertThat(result).isEqualTo(DesktopModeVisualIndicator.IndicatorType.NO_INDICATOR) } Loading @@ -451,7 +466,7 @@ class DesktopModeVisualIndicatorTest : ShellTestCase() { createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_FULLSCREEN) desktopExecutor.flushAll() mainExecutor.flushAll() visualIndicator.updateIndicatorType(PointF(100f, 1500f)) visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, PointF(100f, 1500f)) desktopExecutor.flushAll() mainExecutor.flushAll() Loading @@ -472,7 +487,7 @@ class DesktopModeVisualIndicatorTest : ShellTestCase() { createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_FULLSCREEN) desktopExecutor.flushAll() mainExecutor.flushAll() visualIndicator.updateIndicatorType(PointF(2300f, 1500f)) visualIndicator.updateIndicatorType(DEFAULT_DISPLAY, PointF(2300f, 1500f)) desktopExecutor.flushAll() mainExecutor.flushAll() Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +182 −45 File changed.Preview size limit exceeded, changes collapsed. Show changes