Loading libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentTasksController.java +36 −24 Original line number Diff line number Diff line Loading @@ -689,8 +689,22 @@ public class RecentTasksController implements TaskStackListenerCallback, // Desktop tasks if (mDesktopState.canEnterDesktopMode() && mDesktopUserRepositories.isPresent() && mDesktopUserRepositories.get().getCurrent().isActiveTask(taskId)) { && mDesktopUserRepositories.isPresent()) { Integer deskId; if (taskInfo.isTopActivityTransparent && mDesktopUserRepositories.get().getProfile( taskInfo.userId).getActiveDeskId(taskInfo.displayId) != null) { deskId = mDesktopUserRepositories.get().getCurrent().getActiveDeskId( taskInfo.displayId); } else if (mDesktopUserRepositories.get().getCurrent().isActiveTask(taskId)) { deskId = multipleDesktopsEnabled ? mDesktopUserRepositories.get().getCurrent().getDeskIdForTask(taskId) : INVALID_DESK_ID; } else { deskId = null; } if (deskId != null) { // If task has their app bounds set to null which happens after reboot, set the // app bounds to persisted lastFullscreenBounds. Also set the position in parent // to the top left of the bounds. Loading @@ -702,11 +716,9 @@ public class RecentTasksController implements TaskStackListenerCallback, taskInfo.positionInParent = new Point(taskInfo.lastNonFullscreenBounds.left, taskInfo.lastNonFullscreenBounds.top); } // Lump all freeform tasks together as if they were all in a single desk whose ID is // Lump all freeform tasks together as if they were all in a single desk // whose ID is // `INVALID_DESK_ID` when the multiple desktops feature is disabled. final int deskId = multipleDesktopsEnabled ? mDesktopUserRepositories.get().getCurrent().getDeskIdForTask(taskId) : INVALID_DESK_ID; final Desk desk = getOrCreateDesk(deskId); desk.addTask(taskInfo, mDesktopUserRepositories.get().getCurrent().isMinimizedTask(taskId), Loading @@ -714,7 +726,7 @@ public class RecentTasksController implements TaskStackListenerCallback, mTmpRemaining.remove(taskId); continue; } } if (enableShellTopTaskTracking()) { // Visible tasks if (mVisibleTasksMap.containsKey(taskId)) { Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/recents/RecentTasksControllerTest.java +84 −2 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ import static com.android.wm.shell.shared.GroupedTaskInfo.TYPE_FULLSCREEN; import static com.android.wm.shell.shared.GroupedTaskInfo.TYPE_SPLIT; import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_50_50; import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; Loading @@ -53,6 +55,7 @@ import android.app.ActivityManager.RecentTaskInfo; import android.app.ActivityManager.RunningTaskInfo; import android.app.ActivityTaskManager; import android.app.KeyguardManager; import android.app.TaskInfo; import android.content.ComponentName; import android.content.Context; import android.content.Intent; Loading Loading @@ -932,6 +935,85 @@ public class RecentTasksControllerTest extends ShellTestCase { + " empty desks", groupedTasks.isEmpty()); } @Test @EnableFlags({Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND, Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_FRONTEND}) public void getRecentTask_transparentAppInDesktopTask_addedToSameDesktopTask() { mDesktopState.setEnableMultipleDesktops(true); RecentTaskInfo task1 = makeTaskInfo(1); task1.isTopActivityTransparent = true; RecentTaskInfo task2 = makeTaskInfo(2); RecentTaskInfo task3 = makeTaskInfo(3); RecentTaskInfo task4 = makeTaskInfo(4); setRawList(task1, task2, task3, task4); int deskId = 1; when(mDesktopRepository.getActiveDeskId(anyInt())).thenReturn(deskId); when(mDesktopUserRepositories.getCurrent().isActiveTask(2)).thenReturn(true); when(mDesktopUserRepositories.getCurrent().getDeskIdForTask(1)).thenReturn(deskId); when(mDesktopUserRepositories.getCurrent().getDeskIdForTask(2)).thenReturn(deskId); ArrayList<GroupedTaskInfo> recentTasks = mRecentTasksController.getRecentTasks(MAX_VALUE, RECENT_IGNORE_UNAVAILABLE, 0); assertThat(recentTasks).hasSize(3); GroupedTaskInfo fullscreenGroup1 = recentTasks.get(0); assertThat(fullscreenGroup1.isBaseType(TYPE_FULLSCREEN)).isTrue(); assertThat(fullscreenGroup1.getTaskInfoList().get(0)).isEqualTo(task3); GroupedTaskInfo fullscreenGroup2 = recentTasks.get(1); assertThat(fullscreenGroup2.isBaseType(TYPE_FULLSCREEN)).isTrue(); assertThat(fullscreenGroup2.getTaskInfoList().get(0)).isEqualTo(task4); GroupedTaskInfo deskGroup = recentTasks.get(2); assertThat(deskGroup.getDeskId()).isEqualTo(deskId); assertThat(deskGroup.isBaseType(TYPE_DESK)).isTrue(); List<TaskInfo> deskTasks = deskGroup.getTaskInfoList(); assertThat(deskTasks).hasSize(2); assertThat(deskTasks).containsExactly(task1, task2); } @Test @EnableFlags({Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND, Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_FRONTEND}) public void getRecentTask_transparentAppNotInExistingDesktopTask_shownAsFullScreenTask() { mDesktopState.setEnableMultipleDesktops(true); RecentTaskInfo task1 = makeTaskInfo(1); task1.isTopActivityTransparent = true; RecentTaskInfo task2 = makeTaskInfo(2); RecentTaskInfo task3 = makeTaskInfo(3); RecentTaskInfo task4 = makeTaskInfo(4); setRawList(task1, task2, task3, task4); int deskId = 1; when(mDesktopRepository.getActiveDeskId(anyInt())).thenReturn(null); when(mDesktopUserRepositories.getCurrent().isActiveTask(2)).thenReturn(true); when(mDesktopUserRepositories.getCurrent().isActiveTask(3)).thenReturn(true); when(mDesktopUserRepositories.getCurrent().getDeskIdForTask(2)).thenReturn(deskId); when(mDesktopUserRepositories.getCurrent().getDeskIdForTask(3)).thenReturn(deskId); ArrayList<GroupedTaskInfo> recentTasks = mRecentTasksController.getRecentTasks(MAX_VALUE, RECENT_IGNORE_UNAVAILABLE, 0); assertThat(recentTasks).hasSize(3); GroupedTaskInfo fullscreenGroup1 = recentTasks.get(0); assertThat(fullscreenGroup1.isBaseType(TYPE_FULLSCREEN)).isTrue(); assertThat(fullscreenGroup1.getTaskInfoList().get(0)).isEqualTo(task1); GroupedTaskInfo fullscreenGroup2 = recentTasks.get(1); assertThat(fullscreenGroup2.isBaseType(TYPE_FULLSCREEN)).isTrue(); assertThat(fullscreenGroup2.getTaskInfoList().get(0)).isEqualTo(task4); GroupedTaskInfo deskGroup = recentTasks.get(2); assertThat(deskGroup.getDeskId()).isEqualTo(deskId); assertThat(deskGroup.isBaseType(TYPE_DESK)).isTrue(); List<TaskInfo> deskTasks = deskGroup.getTaskInfoList(); assertThat(deskTasks).hasSize(2); assertThat(deskTasks).containsExactly(task2, task3); } /** * Helper to create a task with a given task id. */ Loading packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/Task.java +12 −3 Original line number Diff line number Diff line Loading @@ -95,6 +95,11 @@ public class Task { * The type of the top most activity. */ public @WindowConfiguration.ActivityType int topActivityType; /** * Whether the top activity fillsParent() is false. This is used to determine if the * activity is translucent. */ public boolean isTopActivityTransparent; // The source component name which started this task public final ComponentName sourceComponent; Loading @@ -119,6 +124,7 @@ public class Task { this.isTopActivityNoDisplay = t.isTopActivityNoDisplay; this.isActivityStackTransparent = t.isActivityStackTransparent; this.topActivityType = t.topActivityType; this.isTopActivityTransparent = t.isTopActivityTransparent; updateHashCode(); } Loading @@ -138,7 +144,8 @@ public class Task { ComponentName sourceComponent, int userId, long lastActiveTime, int displayId, @Nullable ComponentName baseActivity, int numActivities, boolean isTopActivityNoDisplay, boolean isActivityStackTransparent, @WindowConfiguration.ActivityType int topActivityType) { @WindowConfiguration.ActivityType int topActivityType, boolean isTopActivityTransparent) { this.id = id; this.windowingMode = windowingMode; this.baseIntent = intent; Loading @@ -151,6 +158,7 @@ public class Task { this.isTopActivityNoDisplay = isTopActivityNoDisplay; this.isActivityStackTransparent = isActivityStackTransparent; this.topActivityType = topActivityType; this.isTopActivityTransparent = isTopActivityTransparent; updateHashCode(); } Loading Loading @@ -227,6 +235,7 @@ public class Task { parcel.writeBoolean(isTopActivityNoDisplay); parcel.writeBoolean(isActivityStackTransparent); parcel.writeInt(topActivityType); parcel.writeBoolean(isTopActivityTransparent); } private static TaskKey readFromParcel(Parcel parcel) { Loading @@ -242,10 +251,10 @@ public class Task { boolean isTopActivityNoDisplay = parcel.readBoolean(); boolean isActivityStackTransparent = parcel.readBoolean(); int topActivityType = parcel.readInt(); boolean isTopActivityTransparent = parcel.readBoolean(); return new TaskKey(id, windowingMode, baseIntent, sourceComponent, userId, lastActiveTime, displayId, baseActivity, numActivities, isTopActivityNoDisplay, isActivityStackTransparent, topActivityType); isActivityStackTransparent, topActivityType, isTopActivityTransparent); } @Override Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentTasksController.java +36 −24 Original line number Diff line number Diff line Loading @@ -689,8 +689,22 @@ public class RecentTasksController implements TaskStackListenerCallback, // Desktop tasks if (mDesktopState.canEnterDesktopMode() && mDesktopUserRepositories.isPresent() && mDesktopUserRepositories.get().getCurrent().isActiveTask(taskId)) { && mDesktopUserRepositories.isPresent()) { Integer deskId; if (taskInfo.isTopActivityTransparent && mDesktopUserRepositories.get().getProfile( taskInfo.userId).getActiveDeskId(taskInfo.displayId) != null) { deskId = mDesktopUserRepositories.get().getCurrent().getActiveDeskId( taskInfo.displayId); } else if (mDesktopUserRepositories.get().getCurrent().isActiveTask(taskId)) { deskId = multipleDesktopsEnabled ? mDesktopUserRepositories.get().getCurrent().getDeskIdForTask(taskId) : INVALID_DESK_ID; } else { deskId = null; } if (deskId != null) { // If task has their app bounds set to null which happens after reboot, set the // app bounds to persisted lastFullscreenBounds. Also set the position in parent // to the top left of the bounds. Loading @@ -702,11 +716,9 @@ public class RecentTasksController implements TaskStackListenerCallback, taskInfo.positionInParent = new Point(taskInfo.lastNonFullscreenBounds.left, taskInfo.lastNonFullscreenBounds.top); } // Lump all freeform tasks together as if they were all in a single desk whose ID is // Lump all freeform tasks together as if they were all in a single desk // whose ID is // `INVALID_DESK_ID` when the multiple desktops feature is disabled. final int deskId = multipleDesktopsEnabled ? mDesktopUserRepositories.get().getCurrent().getDeskIdForTask(taskId) : INVALID_DESK_ID; final Desk desk = getOrCreateDesk(deskId); desk.addTask(taskInfo, mDesktopUserRepositories.get().getCurrent().isMinimizedTask(taskId), Loading @@ -714,7 +726,7 @@ public class RecentTasksController implements TaskStackListenerCallback, mTmpRemaining.remove(taskId); continue; } } if (enableShellTopTaskTracking()) { // Visible tasks if (mVisibleTasksMap.containsKey(taskId)) { Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/recents/RecentTasksControllerTest.java +84 −2 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ import static com.android.wm.shell.shared.GroupedTaskInfo.TYPE_FULLSCREEN; import static com.android.wm.shell.shared.GroupedTaskInfo.TYPE_SPLIT; import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_50_50; import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; Loading @@ -53,6 +55,7 @@ import android.app.ActivityManager.RecentTaskInfo; import android.app.ActivityManager.RunningTaskInfo; import android.app.ActivityTaskManager; import android.app.KeyguardManager; import android.app.TaskInfo; import android.content.ComponentName; import android.content.Context; import android.content.Intent; Loading Loading @@ -932,6 +935,85 @@ public class RecentTasksControllerTest extends ShellTestCase { + " empty desks", groupedTasks.isEmpty()); } @Test @EnableFlags({Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND, Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_FRONTEND}) public void getRecentTask_transparentAppInDesktopTask_addedToSameDesktopTask() { mDesktopState.setEnableMultipleDesktops(true); RecentTaskInfo task1 = makeTaskInfo(1); task1.isTopActivityTransparent = true; RecentTaskInfo task2 = makeTaskInfo(2); RecentTaskInfo task3 = makeTaskInfo(3); RecentTaskInfo task4 = makeTaskInfo(4); setRawList(task1, task2, task3, task4); int deskId = 1; when(mDesktopRepository.getActiveDeskId(anyInt())).thenReturn(deskId); when(mDesktopUserRepositories.getCurrent().isActiveTask(2)).thenReturn(true); when(mDesktopUserRepositories.getCurrent().getDeskIdForTask(1)).thenReturn(deskId); when(mDesktopUserRepositories.getCurrent().getDeskIdForTask(2)).thenReturn(deskId); ArrayList<GroupedTaskInfo> recentTasks = mRecentTasksController.getRecentTasks(MAX_VALUE, RECENT_IGNORE_UNAVAILABLE, 0); assertThat(recentTasks).hasSize(3); GroupedTaskInfo fullscreenGroup1 = recentTasks.get(0); assertThat(fullscreenGroup1.isBaseType(TYPE_FULLSCREEN)).isTrue(); assertThat(fullscreenGroup1.getTaskInfoList().get(0)).isEqualTo(task3); GroupedTaskInfo fullscreenGroup2 = recentTasks.get(1); assertThat(fullscreenGroup2.isBaseType(TYPE_FULLSCREEN)).isTrue(); assertThat(fullscreenGroup2.getTaskInfoList().get(0)).isEqualTo(task4); GroupedTaskInfo deskGroup = recentTasks.get(2); assertThat(deskGroup.getDeskId()).isEqualTo(deskId); assertThat(deskGroup.isBaseType(TYPE_DESK)).isTrue(); List<TaskInfo> deskTasks = deskGroup.getTaskInfoList(); assertThat(deskTasks).hasSize(2); assertThat(deskTasks).containsExactly(task1, task2); } @Test @EnableFlags({Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND, Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_FRONTEND}) public void getRecentTask_transparentAppNotInExistingDesktopTask_shownAsFullScreenTask() { mDesktopState.setEnableMultipleDesktops(true); RecentTaskInfo task1 = makeTaskInfo(1); task1.isTopActivityTransparent = true; RecentTaskInfo task2 = makeTaskInfo(2); RecentTaskInfo task3 = makeTaskInfo(3); RecentTaskInfo task4 = makeTaskInfo(4); setRawList(task1, task2, task3, task4); int deskId = 1; when(mDesktopRepository.getActiveDeskId(anyInt())).thenReturn(null); when(mDesktopUserRepositories.getCurrent().isActiveTask(2)).thenReturn(true); when(mDesktopUserRepositories.getCurrent().isActiveTask(3)).thenReturn(true); when(mDesktopUserRepositories.getCurrent().getDeskIdForTask(2)).thenReturn(deskId); when(mDesktopUserRepositories.getCurrent().getDeskIdForTask(3)).thenReturn(deskId); ArrayList<GroupedTaskInfo> recentTasks = mRecentTasksController.getRecentTasks(MAX_VALUE, RECENT_IGNORE_UNAVAILABLE, 0); assertThat(recentTasks).hasSize(3); GroupedTaskInfo fullscreenGroup1 = recentTasks.get(0); assertThat(fullscreenGroup1.isBaseType(TYPE_FULLSCREEN)).isTrue(); assertThat(fullscreenGroup1.getTaskInfoList().get(0)).isEqualTo(task1); GroupedTaskInfo fullscreenGroup2 = recentTasks.get(1); assertThat(fullscreenGroup2.isBaseType(TYPE_FULLSCREEN)).isTrue(); assertThat(fullscreenGroup2.getTaskInfoList().get(0)).isEqualTo(task4); GroupedTaskInfo deskGroup = recentTasks.get(2); assertThat(deskGroup.getDeskId()).isEqualTo(deskId); assertThat(deskGroup.isBaseType(TYPE_DESK)).isTrue(); List<TaskInfo> deskTasks = deskGroup.getTaskInfoList(); assertThat(deskTasks).hasSize(2); assertThat(deskTasks).containsExactly(task2, task3); } /** * Helper to create a task with a given task id. */ Loading
packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/Task.java +12 −3 Original line number Diff line number Diff line Loading @@ -95,6 +95,11 @@ public class Task { * The type of the top most activity. */ public @WindowConfiguration.ActivityType int topActivityType; /** * Whether the top activity fillsParent() is false. This is used to determine if the * activity is translucent. */ public boolean isTopActivityTransparent; // The source component name which started this task public final ComponentName sourceComponent; Loading @@ -119,6 +124,7 @@ public class Task { this.isTopActivityNoDisplay = t.isTopActivityNoDisplay; this.isActivityStackTransparent = t.isActivityStackTransparent; this.topActivityType = t.topActivityType; this.isTopActivityTransparent = t.isTopActivityTransparent; updateHashCode(); } Loading @@ -138,7 +144,8 @@ public class Task { ComponentName sourceComponent, int userId, long lastActiveTime, int displayId, @Nullable ComponentName baseActivity, int numActivities, boolean isTopActivityNoDisplay, boolean isActivityStackTransparent, @WindowConfiguration.ActivityType int topActivityType) { @WindowConfiguration.ActivityType int topActivityType, boolean isTopActivityTransparent) { this.id = id; this.windowingMode = windowingMode; this.baseIntent = intent; Loading @@ -151,6 +158,7 @@ public class Task { this.isTopActivityNoDisplay = isTopActivityNoDisplay; this.isActivityStackTransparent = isActivityStackTransparent; this.topActivityType = topActivityType; this.isTopActivityTransparent = isTopActivityTransparent; updateHashCode(); } Loading Loading @@ -227,6 +235,7 @@ public class Task { parcel.writeBoolean(isTopActivityNoDisplay); parcel.writeBoolean(isActivityStackTransparent); parcel.writeInt(topActivityType); parcel.writeBoolean(isTopActivityTransparent); } private static TaskKey readFromParcel(Parcel parcel) { Loading @@ -242,10 +251,10 @@ public class Task { boolean isTopActivityNoDisplay = parcel.readBoolean(); boolean isActivityStackTransparent = parcel.readBoolean(); int topActivityType = parcel.readInt(); boolean isTopActivityTransparent = parcel.readBoolean(); return new TaskKey(id, windowingMode, baseIntent, sourceComponent, userId, lastActiveTime, displayId, baseActivity, numActivities, isTopActivityNoDisplay, isActivityStackTransparent, topActivityType); isActivityStackTransparent, topActivityType, isTopActivityTransparent); } @Override Loading