Merge "Bring home task to front when desktop tasks are moved to front" into tm-qpr-dev

This commit is contained in:
Ats Jenk
2023-02-09 21:09:43 +00:00
committed by Android (Google) Code Review

View File

@@ -253,7 +253,8 @@ public class DesktopModeController implements RemoteCallable<DesktopModeControll
*/ */
void showDesktopApps() { void showDesktopApps() {
// Bring apps to front, ignoring their visibility status to always ensure they are on top. // Bring apps to front, ignoring their visibility status to always ensure they are on top.
WindowContainerTransaction wct = bringDesktopAppsToFront(true /* ignoreVisibility */); WindowContainerTransaction wct = new WindowContainerTransaction();
bringDesktopAppsToFront(wct);
if (Transitions.ENABLE_SHELL_TRANSITIONS) { if (Transitions.ENABLE_SHELL_TRANSITIONS) {
mTransitions.startTransition(TRANSIT_TO_FRONT, wct, null /* handler */); mTransitions.startTransition(TRANSIT_TO_FRONT, wct, null /* handler */);
@@ -267,9 +268,7 @@ public class DesktopModeController implements RemoteCallable<DesktopModeControll
return mDesktopModeTaskRepository.getVisibleTaskCount(); return mDesktopModeTaskRepository.getVisibleTaskCount();
} }
@NonNull private void bringDesktopAppsToFront(WindowContainerTransaction wct) {
private WindowContainerTransaction bringDesktopAppsToFront(boolean force) {
final WindowContainerTransaction wct = new WindowContainerTransaction();
final ArraySet<Integer> activeTasks = mDesktopModeTaskRepository.getActiveTasks(); final ArraySet<Integer> activeTasks = mDesktopModeTaskRepository.getActiveTasks();
ProtoLog.d(WM_SHELL_DESKTOP_MODE, "bringDesktopAppsToFront: tasks=%s", activeTasks.size()); ProtoLog.d(WM_SHELL_DESKTOP_MODE, "bringDesktopAppsToFront: tasks=%s", activeTasks.size());
@@ -282,18 +281,11 @@ public class DesktopModeController implements RemoteCallable<DesktopModeControll
} }
if (taskInfos.isEmpty()) { if (taskInfos.isEmpty()) {
return wct; return;
} }
if (!force) { moveHomeTaskToFront(wct);
final boolean allActiveTasksAreVisible = taskInfos.stream()
.allMatch(info -> mDesktopModeTaskRepository.isVisibleTask(info.taskId));
if (allActiveTasksAreVisible) {
ProtoLog.d(WM_SHELL_DESKTOP_MODE,
"bringDesktopAppsToFront: active tasks are already in front, skipping.");
return wct;
}
}
ProtoLog.d(WM_SHELL_DESKTOP_MODE, ProtoLog.d(WM_SHELL_DESKTOP_MODE,
"bringDesktopAppsToFront: reordering all active tasks to the front"); "bringDesktopAppsToFront: reordering all active tasks to the front");
final List<Integer> allTasksInZOrder = final List<Integer> allTasksInZOrder =
@@ -304,7 +296,15 @@ public class DesktopModeController implements RemoteCallable<DesktopModeControll
for (RunningTaskInfo task : taskInfos) { for (RunningTaskInfo task : taskInfos) {
wct.reorder(task.token, true); wct.reorder(task.token, true);
} }
return wct; }
private void moveHomeTaskToFront(WindowContainerTransaction wct) {
for (RunningTaskInfo task : mShellTaskOrganizer.getRunningTasks(mContext.getDisplayId())) {
if (task.getActivityType() == ACTIVITY_TYPE_HOME) {
wct.reorder(task.token, true /* onTop */);
return;
}
}
} }
/** /**
@@ -363,7 +363,7 @@ public class DesktopModeController implements RemoteCallable<DesktopModeControll
if (wct == null) { if (wct == null) {
wct = new WindowContainerTransaction(); wct = new WindowContainerTransaction();
} }
wct.merge(bringDesktopAppsToFront(false /* ignoreVisibility */), true /* transfer */); bringDesktopAppsToFront(wct);
wct.reorder(request.getTriggerTask().token, true /* onTop */); wct.reorder(request.getTriggerTask().token, true /* onTop */);
return wct; return wct;