Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java +3 −2 Original line number Diff line number Diff line Loading @@ -1034,14 +1034,15 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel, final DesktopRepository repository = mDesktopUserRepositories.getCurrent(); final Integer leftTaskId = repository.getLeftTiledTask(deskId); final Integer rightTaskId = repository.getRightTiledTask(deskId); if (leftTaskId != null) { // if the decor wrapper is null, tiling will be initialised when the decor is created. if (leftTaskId != null && mWindowDecorByTaskId.get(leftTaskId) != null) { final WindowDecorationWrapper decor = mWindowDecorByTaskId.get(leftTaskId); final RunningTaskInfo taskInfo = decor.getTaskInfo(); final Rect currentBounds = taskInfo.configuration.windowConfiguration.getBounds(); snapPersistedTaskToHalfScreen(taskInfo, currentBounds, SnapPosition.LEFT); } if (rightTaskId != null) { if (rightTaskId != null && mWindowDecorByTaskId.get(rightTaskId) != null) { final WindowDecorationWrapper decor = mWindowDecorByTaskId.get(rightTaskId); final RunningTaskInfo taskInfo = decor.getTaskInfo(); final Rect currentBounds = taskInfo.configuration.windowConfiguration.getBounds(); Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModelTests.kt +42 −0 Original line number Diff line number Diff line Loading @@ -1483,6 +1483,48 @@ class DesktopModeWindowDecorViewModelTests : DesktopModeWindowDecorViewModelTest } } @Test fun nullDecor_shouldNotInitializeTiling() { mockDesktopRepository.stub { on { getLeftTiledTask(1) } doReturn 1 } mockDesktopRepository.stub { on { getRightTiledTask(2) } doReturn 2 } windowDecorByTaskIdSpy.stub { on { get(1) } doReturn null } windowDecorByTaskIdSpy.stub { on { get(2) } doReturn null } mockTilingWindowDecoration.stub { on { tilingDeskActive(any()) } doReturn false } desktopModeWindowDecorViewModel.onDeskActivated(1, 2) verify(mockTilingWindowDecoration, never()).snapToHalfScreen( taskInfo = any(), windowDecoration = any(), position = any(), currentBounds = any(), destinationBounds = any() ) } @Test fun nonNullDecor_shouldInitializeTiling() { val task = createTask(windowingMode = WINDOWING_MODE_FREEFORM) val taskSurface = SurfaceControl() val decoration = setUpMockDecorationForTask(task) onTaskOpening(task, taskSurface) mockDesktopRepository.stub { on { getLeftTiledTask(1) } doReturn task.taskId } mockDesktopRepository.stub { on { getRightTiledTask(1) } doReturn task.taskId } mockTilingWindowDecoration.stub { on { tilingDeskActive(any()) } doReturn false } windowDecorByTaskIdSpy.stub { on { get(task.taskId) } doReturn decoration } decoration.stub { on { taskInfo } doReturn task } desktopModeWindowDecorViewModel.onDeskActivated(1, 2) verify(mockTilingWindowDecoration, times(2)).snapToHalfScreen( taskInfo = any(), windowDecoration = any(), position = any(), currentBounds = any(), destinationBounds = any() ) } @Test @EnableFlags(Flags.FLAG_ENABLE_BLOCK_NON_DESKTOP_DISPLAY_WINDOW_DRAG_BUGFIX) fun testOnFreeformWindowDragMove_toNonDesktopModeDisplay_setsNoDropIconAndKeepsBounds() { Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java +3 −2 Original line number Diff line number Diff line Loading @@ -1034,14 +1034,15 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel, final DesktopRepository repository = mDesktopUserRepositories.getCurrent(); final Integer leftTaskId = repository.getLeftTiledTask(deskId); final Integer rightTaskId = repository.getRightTiledTask(deskId); if (leftTaskId != null) { // if the decor wrapper is null, tiling will be initialised when the decor is created. if (leftTaskId != null && mWindowDecorByTaskId.get(leftTaskId) != null) { final WindowDecorationWrapper decor = mWindowDecorByTaskId.get(leftTaskId); final RunningTaskInfo taskInfo = decor.getTaskInfo(); final Rect currentBounds = taskInfo.configuration.windowConfiguration.getBounds(); snapPersistedTaskToHalfScreen(taskInfo, currentBounds, SnapPosition.LEFT); } if (rightTaskId != null) { if (rightTaskId != null && mWindowDecorByTaskId.get(rightTaskId) != null) { final WindowDecorationWrapper decor = mWindowDecorByTaskId.get(rightTaskId); final RunningTaskInfo taskInfo = decor.getTaskInfo(); final Rect currentBounds = taskInfo.configuration.windowConfiguration.getBounds(); Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModelTests.kt +42 −0 Original line number Diff line number Diff line Loading @@ -1483,6 +1483,48 @@ class DesktopModeWindowDecorViewModelTests : DesktopModeWindowDecorViewModelTest } } @Test fun nullDecor_shouldNotInitializeTiling() { mockDesktopRepository.stub { on { getLeftTiledTask(1) } doReturn 1 } mockDesktopRepository.stub { on { getRightTiledTask(2) } doReturn 2 } windowDecorByTaskIdSpy.stub { on { get(1) } doReturn null } windowDecorByTaskIdSpy.stub { on { get(2) } doReturn null } mockTilingWindowDecoration.stub { on { tilingDeskActive(any()) } doReturn false } desktopModeWindowDecorViewModel.onDeskActivated(1, 2) verify(mockTilingWindowDecoration, never()).snapToHalfScreen( taskInfo = any(), windowDecoration = any(), position = any(), currentBounds = any(), destinationBounds = any() ) } @Test fun nonNullDecor_shouldInitializeTiling() { val task = createTask(windowingMode = WINDOWING_MODE_FREEFORM) val taskSurface = SurfaceControl() val decoration = setUpMockDecorationForTask(task) onTaskOpening(task, taskSurface) mockDesktopRepository.stub { on { getLeftTiledTask(1) } doReturn task.taskId } mockDesktopRepository.stub { on { getRightTiledTask(1) } doReturn task.taskId } mockTilingWindowDecoration.stub { on { tilingDeskActive(any()) } doReturn false } windowDecorByTaskIdSpy.stub { on { get(task.taskId) } doReturn decoration } decoration.stub { on { taskInfo } doReturn task } desktopModeWindowDecorViewModel.onDeskActivated(1, 2) verify(mockTilingWindowDecoration, times(2)).snapToHalfScreen( taskInfo = any(), windowDecoration = any(), position = any(), currentBounds = any(), destinationBounds = any() ) } @Test @EnableFlags(Flags.FLAG_ENABLE_BLOCK_NON_DESKTOP_DISPLAY_WINDOW_DRAG_BUGFIX) fun testOnFreeformWindowDragMove_toNonDesktopModeDisplay_setsNoDropIconAndKeepsBounds() { Loading