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

Commit b4515c9c authored by Ats Jenk's avatar Ats Jenk Committed by Android (Google) Code Review
Browse files

Merge changes from topic "dm-update-proto1" into tm-qpr-dev

* changes:
  Remove dragging from/to status bar from proto 1
  Remove desktop tile from recents for proto 1
parents 2c26442b 00947ee4
Loading
Loading
Loading
Loading
+2 −3
Original line number Original line Diff line number Diff line
@@ -308,7 +308,6 @@ public class RecentTasksController implements TaskStackListenerCallback,
            rawMapping.put(taskInfo.taskId, taskInfo);
            rawMapping.put(taskInfo.taskId, taskInfo);
        }
        }


        boolean desktopModeActive = DesktopModeStatus.isActive(mContext);
        ArrayList<ActivityManager.RecentTaskInfo> freeformTasks = new ArrayList<>();
        ArrayList<ActivityManager.RecentTaskInfo> freeformTasks = new ArrayList<>();


        // Pull out the pairs as we iterate back in the list
        // Pull out the pairs as we iterate back in the list
@@ -320,7 +319,7 @@ public class RecentTasksController implements TaskStackListenerCallback,
                continue;
                continue;
            }
            }


            if (desktopModeActive && mDesktopModeTaskRepository.isPresent()
            if (DesktopModeStatus.isProto2Enabled() && mDesktopModeTaskRepository.isPresent()
                    && mDesktopModeTaskRepository.get().isActiveTask(taskInfo.taskId)) {
                    && mDesktopModeTaskRepository.get().isActiveTask(taskInfo.taskId)) {
                // Freeform tasks will be added as a separate entry
                // Freeform tasks will be added as a separate entry
                freeformTasks.add(taskInfo);
                freeformTasks.add(taskInfo);
@@ -328,7 +327,7 @@ public class RecentTasksController implements TaskStackListenerCallback,
            }
            }


            final int pairedTaskId = mSplitTasks.get(taskInfo.taskId);
            final int pairedTaskId = mSplitTasks.get(taskInfo.taskId);
            if (!desktopModeActive && pairedTaskId != INVALID_TASK_ID && rawMapping.contains(
            if (pairedTaskId != INVALID_TASK_ID && rawMapping.contains(
                    pairedTaskId)) {
                    pairedTaskId)) {
                final ActivityManager.RecentTaskInfo pairedTaskInfo = rawMapping.get(pairedTaskId);
                final ActivityManager.RecentTaskInfo pairedTaskInfo = rawMapping.get(pairedTaskId);
                rawMapping.remove(pairedTaskId);
                rawMapping.remove(pairedTaskId);
+6 −20
Original line number Original line Diff line number Diff line
@@ -301,19 +301,12 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
                    mDragPositioningCallback.onDragPositioningEnd(
                    mDragPositioningCallback.onDragPositioningEnd(
                            e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx));
                            e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx));
                    if (e.getRawY(dragPointerIdx) <= statusBarHeight) {
                    if (e.getRawY(dragPointerIdx) <= statusBarHeight) {
                        if (DesktopModeStatus.isProto2Enabled()) {
                        if (DesktopModeStatus.isProto2Enabled()
                            if (taskInfo.getWindowingMode() == WINDOWING_MODE_FREEFORM) {
                                && taskInfo.getWindowingMode() == WINDOWING_MODE_FREEFORM) {
                            // Switch a single task to fullscreen
                            // Switch a single task to fullscreen
                            mDesktopTasksController.ifPresent(
                            mDesktopTasksController.ifPresent(
                                    c -> c.moveToFullscreen(taskInfo));
                                    c -> c.moveToFullscreen(taskInfo));
                        }
                        }
                        } else if (DesktopModeStatus.isProto1Enabled()) {
                            if (DesktopModeStatus.isActive(mContext)) {
                                // Turn off desktop mode
                                mDesktopModeController.ifPresent(
                                        c -> c.setDesktopModeActive(false));
                            }
                        }
                    }
                    }
                    break;
                    break;
                }
                }
@@ -402,10 +395,6 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
                    || focusedDecor.mTaskInfo.getWindowingMode() != WINDOWING_MODE_FREEFORM) {
                    || focusedDecor.mTaskInfo.getWindowingMode() != WINDOWING_MODE_FREEFORM) {
                handleCaptionThroughStatusBar(ev);
                handleCaptionThroughStatusBar(ev);
            }
            }
        } else if (DesktopModeStatus.isProto1Enabled()) {
            if (!DesktopModeStatus.isActive(mContext)) {
                handleCaptionThroughStatusBar(ev);
            }
        }
        }
        handleEventOutsideFocusedCaption(ev);
        handleEventOutsideFocusedCaption(ev);
        // Prevent status bar from reacting to a caption drag.
        // Prevent status bar from reacting to a caption drag.
@@ -451,9 +440,6 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
                        // In proto2 any full screen task can be dragged to freeform
                        // In proto2 any full screen task can be dragged to freeform
                        dragFromStatusBarAllowed = focusedDecor.mTaskInfo.getWindowingMode()
                        dragFromStatusBarAllowed = focusedDecor.mTaskInfo.getWindowingMode()
                                == WINDOWING_MODE_FULLSCREEN;
                                == WINDOWING_MODE_FULLSCREEN;
                    } else if (DesktopModeStatus.isProto1Enabled()) {
                        // In proto1 task can be dragged to freeform when not in desktop mode
                        dragFromStatusBarAllowed = !DesktopModeStatus.isActive(mContext);
                    }
                    }


                    if (dragFromStatusBarAllowed && focusedDecor.checkTouchEventInHandle(ev)) {
                    if (dragFromStatusBarAllowed && focusedDecor.checkTouchEventInHandle(ev)) {
@@ -524,7 +510,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {


    private boolean shouldShowWindowDecor(RunningTaskInfo taskInfo) {
    private boolean shouldShowWindowDecor(RunningTaskInfo taskInfo) {
        if (taskInfo.getWindowingMode() == WINDOWING_MODE_FREEFORM) return true;
        if (taskInfo.getWindowingMode() == WINDOWING_MODE_FREEFORM) return true;
        return DesktopModeStatus.isAnyEnabled()
        return DesktopModeStatus.isProto2Enabled()
                && taskInfo.getActivityType() == ACTIVITY_TYPE_STANDARD
                && taskInfo.getActivityType() == ACTIVITY_TYPE_STANDARD
                && mDisplayController.getDisplayContext(taskInfo.displayId)
                && mDisplayController.getDisplayContext(taskInfo.displayId)
                .getResources().getConfiguration().smallestScreenWidthDp >= 600;
                .getResources().getConfiguration().smallestScreenWidthDp >= 600;
+35 −2
Original line number Original line Diff line number Diff line
@@ -253,10 +253,10 @@ public class RecentTasksControllerTest extends ShellTestCase {
    }
    }


    @Test
    @Test
    public void testGetRecentTasks_groupActiveFreeformTasks() {
    public void testGetRecentTasks_hasActiveDesktopTasks_proto2Enabled_groupFreeformTasks() {
        StaticMockitoSession mockitoSession = mockitoSession().mockStatic(
        StaticMockitoSession mockitoSession = mockitoSession().mockStatic(
                DesktopModeStatus.class).startMocking();
                DesktopModeStatus.class).startMocking();
        when(DesktopModeStatus.isActive(any())).thenReturn(true);
        when(DesktopModeStatus.isProto2Enabled()).thenReturn(true);


        ActivityManager.RecentTaskInfo t1 = makeTaskInfo(1);
        ActivityManager.RecentTaskInfo t1 = makeTaskInfo(1);
        ActivityManager.RecentTaskInfo t2 = makeTaskInfo(2);
        ActivityManager.RecentTaskInfo t2 = makeTaskInfo(2);
@@ -292,6 +292,39 @@ public class RecentTasksControllerTest extends ShellTestCase {
        mockitoSession.finishMocking();
        mockitoSession.finishMocking();
    }
    }


    @Test
    public void testGetRecentTasks_hasActiveDesktopTasks_proto2Disabled_doNotGroupFreeformTasks() {
        StaticMockitoSession mockitoSession = mockitoSession().mockStatic(
                DesktopModeStatus.class).startMocking();
        when(DesktopModeStatus.isProto2Enabled()).thenReturn(false);

        ActivityManager.RecentTaskInfo t1 = makeTaskInfo(1);
        ActivityManager.RecentTaskInfo t2 = makeTaskInfo(2);
        ActivityManager.RecentTaskInfo t3 = makeTaskInfo(3);
        ActivityManager.RecentTaskInfo t4 = makeTaskInfo(4);
        setRawList(t1, t2, t3, t4);

        when(mDesktopModeTaskRepository.isActiveTask(1)).thenReturn(true);
        when(mDesktopModeTaskRepository.isActiveTask(3)).thenReturn(true);

        ArrayList<GroupedRecentTaskInfo> recentTasks = mRecentTasksController.getRecentTasks(
                MAX_VALUE, RECENT_IGNORE_UNAVAILABLE, 0);

        // Expect no grouping of tasks
        assertEquals(4, recentTasks.size());
        assertEquals(GroupedRecentTaskInfo.TYPE_SINGLE, recentTasks.get(0).getType());
        assertEquals(GroupedRecentTaskInfo.TYPE_SINGLE, recentTasks.get(1).getType());
        assertEquals(GroupedRecentTaskInfo.TYPE_SINGLE, recentTasks.get(2).getType());
        assertEquals(GroupedRecentTaskInfo.TYPE_SINGLE, recentTasks.get(3).getType());

        assertEquals(t1, recentTasks.get(0).getTaskInfo1());
        assertEquals(t2, recentTasks.get(1).getTaskInfo1());
        assertEquals(t3, recentTasks.get(2).getTaskInfo1());
        assertEquals(t4, recentTasks.get(3).getTaskInfo1());

        mockitoSession.finishMocking();
    }

    @Test
    @Test
    public void testRemovedTaskRemovesSplit() {
    public void testRemovedTaskRemovesSplit() {
        ActivityManager.RecentTaskInfo t1 = makeTaskInfo(1);
        ActivityManager.RecentTaskInfo t1 = makeTaskInfo(1);