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
This commit is contained in:
Ats Jenk
2023-02-06 17:59:31 +00:00
committed by Android (Google) Code Review
3 changed files with 43 additions and 25 deletions

View File

@@ -308,7 +308,6 @@ public class RecentTasksController implements TaskStackListenerCallback,
rawMapping.put(taskInfo.taskId, taskInfo);
}
boolean desktopModeActive = DesktopModeStatus.isActive(mContext);
ArrayList<ActivityManager.RecentTaskInfo> freeformTasks = new ArrayList<>();
// Pull out the pairs as we iterate back in the list
@@ -320,7 +319,7 @@ public class RecentTasksController implements TaskStackListenerCallback,
continue;
}
if (desktopModeActive && mDesktopModeTaskRepository.isPresent()
if (DesktopModeStatus.isProto2Enabled() && mDesktopModeTaskRepository.isPresent()
&& mDesktopModeTaskRepository.get().isActiveTask(taskInfo.taskId)) {
// Freeform tasks will be added as a separate entry
freeformTasks.add(taskInfo);
@@ -328,7 +327,7 @@ public class RecentTasksController implements TaskStackListenerCallback,
}
final int pairedTaskId = mSplitTasks.get(taskInfo.taskId);
if (!desktopModeActive && pairedTaskId != INVALID_TASK_ID && rawMapping.contains(
if (pairedTaskId != INVALID_TASK_ID && rawMapping.contains(
pairedTaskId)) {
final ActivityManager.RecentTaskInfo pairedTaskInfo = rawMapping.get(pairedTaskId);
rawMapping.remove(pairedTaskId);

View File

@@ -301,18 +301,11 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
mDragPositioningCallback.onDragPositioningEnd(
e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx));
if (e.getRawY(dragPointerIdx) <= statusBarHeight) {
if (DesktopModeStatus.isProto2Enabled()) {
if (taskInfo.getWindowingMode() == WINDOWING_MODE_FREEFORM) {
// Switch a single task to fullscreen
mDesktopTasksController.ifPresent(
c -> c.moveToFullscreen(taskInfo));
}
} else if (DesktopModeStatus.isProto1Enabled()) {
if (DesktopModeStatus.isActive(mContext)) {
// Turn off desktop mode
mDesktopModeController.ifPresent(
c -> c.setDesktopModeActive(false));
}
if (DesktopModeStatus.isProto2Enabled()
&& taskInfo.getWindowingMode() == WINDOWING_MODE_FREEFORM) {
// Switch a single task to fullscreen
mDesktopTasksController.ifPresent(
c -> c.moveToFullscreen(taskInfo));
}
}
break;
@@ -402,10 +395,6 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
|| focusedDecor.mTaskInfo.getWindowingMode() != WINDOWING_MODE_FREEFORM) {
handleCaptionThroughStatusBar(ev);
}
} else if (DesktopModeStatus.isProto1Enabled()) {
if (!DesktopModeStatus.isActive(mContext)) {
handleCaptionThroughStatusBar(ev);
}
}
handleEventOutsideFocusedCaption(ev);
// 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
dragFromStatusBarAllowed = focusedDecor.mTaskInfo.getWindowingMode()
== 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)) {
@@ -524,7 +510,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
private boolean shouldShowWindowDecor(RunningTaskInfo taskInfo) {
if (taskInfo.getWindowingMode() == WINDOWING_MODE_FREEFORM) return true;
return DesktopModeStatus.isAnyEnabled()
return DesktopModeStatus.isProto2Enabled()
&& taskInfo.getActivityType() == ACTIVITY_TYPE_STANDARD
&& mDisplayController.getDisplayContext(taskInfo.displayId)
.getResources().getConfiguration().smallestScreenWidthDp >= 600;

View File

@@ -253,10 +253,10 @@ public class RecentTasksControllerTest extends ShellTestCase {
}
@Test
public void testGetRecentTasks_groupActiveFreeformTasks() {
public void testGetRecentTasks_hasActiveDesktopTasks_proto2Enabled_groupFreeformTasks() {
StaticMockitoSession mockitoSession = mockitoSession().mockStatic(
DesktopModeStatus.class).startMocking();
when(DesktopModeStatus.isActive(any())).thenReturn(true);
when(DesktopModeStatus.isProto2Enabled()).thenReturn(true);
ActivityManager.RecentTaskInfo t1 = makeTaskInfo(1);
ActivityManager.RecentTaskInfo t2 = makeTaskInfo(2);
@@ -292,6 +292,39 @@ public class RecentTasksControllerTest extends ShellTestCase {
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
public void testRemovedTaskRemovesSplit() {
ActivityManager.RecentTaskInfo t1 = makeTaskInfo(1);