summaryrefslogtreecommitdiff
path: root/quickstep/src
diff options
context:
space:
mode:
author minch <minch@google.com> 2025-03-20 20:37:33 +0000
committer minch <minch@google.com> 2025-03-22 05:22:05 +0000
commitfba9726258c30e040b7131c826e6c4a6a9b9b0f4 (patch)
treeb788b58d435c47e8c637a0bb6a852707000e8f93 /quickstep/src
parent0eb036014646a2b2f2b532eae1b044d861fbadaa (diff)
Introduce TopTaskTracker.getPlaceholderGroupedTaskInfo
This CL just introduces an API inside TopTaskTracker to return a GroupedTaskInfo, no existing logic being migrated to it yet. It will be used to replace `getPlaceholderTasks` and `getSplitPlaceholderTasks` in the follow-up cls. Bug: 401582344 Flag: EXEMPT, introduce a new API without usage Test: m Change-Id: Ic12003833605582d191c4abfd4a0878c266dd30f
Diffstat (limited to 'quickstep/src')
-rw-r--r--quickstep/src/com/android/quickstep/TopTaskTracker.java131
1 files changed, 98 insertions, 33 deletions
diff --git a/quickstep/src/com/android/quickstep/TopTaskTracker.java b/quickstep/src/com/android/quickstep/TopTaskTracker.java
index 7e773e3a58..ef5c1db8f0 100644
--- a/quickstep/src/com/android/quickstep/TopTaskTracker.java
+++ b/quickstep/src/com/android/quickstep/TopTaskTracker.java
@@ -29,9 +29,13 @@ import static com.android.quickstep.fallback.window.RecentsWindowFlags.enableOve
import static com.android.wm.shell.Flags.enableShellTopTaskTracking;
import static com.android.wm.shell.Flags.enableFlexibleSplit;
import static com.android.wm.shell.shared.GroupedTaskInfo.TYPE_SPLIT;
+import static com.android.launcher3.statehandlers.DesktopVisibilityController.INACTIVE_DESK_ID;
+import static com.android.wm.shell.shared.desktopmode.DesktopModeStatus.canEnterDesktopMode;
import android.app.ActivityManager.RunningTaskInfo;
import android.app.TaskInfo;
+import android.app.WindowConfiguration;
+import android.content.Context;
import android.util.ArrayMap;
import android.util.Log;
@@ -39,6 +43,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
+import com.android.launcher3.dagger.ApplicationContext;
import com.android.launcher3.dagger.LauncherAppSingleton;
import com.android.launcher3.util.DaggerSingletonObject;
import com.android.launcher3.util.DaggerSingletonTracker;
@@ -92,8 +97,11 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta
// most.
private ArrayMap<Integer, GroupedTaskInfo> mVisibleTasks = new ArrayMap<>();
+ private final boolean mCanEnterDesktopMode;
+
@Inject
- public TopTaskTracker(DaggerSingletonTracker tracker, SystemUiProxy systemUiProxy) {
+ public TopTaskTracker(@ApplicationContext Context context, DaggerSingletonTracker tracker,
+ SystemUiProxy systemUiProxy) {
if (!enableShellTopTaskTracking()) {
mMainStagePosition.stageType = SplitConfigurationOptions.STAGE_TYPE_MAIN;
mSideStagePosition.stageType = SplitConfigurationOptions.STAGE_TYPE_SIDE;
@@ -110,6 +118,8 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta
TaskStackChangeListeners.getInstance().unregisterTaskStackListener(this);
systemUiProxy.unregisterSplitScreenListener(this);
});
+
+ mCanEnterDesktopMode = canEnterDesktopMode(context);
}
@Override
@@ -324,7 +334,7 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta
// TODO(346588978): Currently ignore filterOnlyVisibleRecents, but perhaps make this an
// explicit filter For things to ignore (ie. PIP/Bubbles/Assistant/etc/so that this is
// explicit)
- return new CachedTaskInfo(mVisibleTasks.get(displayId));
+ return new CachedTaskInfo(mVisibleTasks.get(displayId), mCanEnterDesktopMode);
} else {
if (filterOnlyVisibleRecents) {
// Since we only know about the top most task, any filtering may not be applied on
@@ -335,9 +345,9 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta
if (enableOverviewOnConnectedDisplays()) {
return new CachedTaskInfo(Arrays.stream(tasks).filter(
info -> ExternalDisplaysKt.getSafeDisplayId(info)
- == displayId).toList());
+ == displayId).toList(), mCanEnterDesktopMode);
} else {
- return new CachedTaskInfo(Arrays.asList(tasks));
+ return new CachedTaskInfo(Arrays.asList(tasks), mCanEnterDesktopMode);
}
}
@@ -354,9 +364,10 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta
|| DesksUtils.isDesktopWallpaperTask(t));
if (enableOverviewOnConnectedDisplays()) {
return new CachedTaskInfo(tasks.stream().filter(
- info -> ExternalDisplaysKt.getSafeDisplayId(info) == displayId).toList());
+ info -> ExternalDisplaysKt.getSafeDisplayId(info) == displayId).toList(),
+ mCanEnterDesktopMode);
} else {
- return new CachedTaskInfo(tasks);
+ return new CachedTaskInfo(tasks, mCanEnterDesktopMode);
}
}
}
@@ -376,6 +387,8 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta
* during the lifecycle of the task.
*/
public static class CachedTaskInfo {
+ // TODO: b/402362465 - Provide a valid value while tracking top task per display.
+ private final int mDisplayId = DEFAULT_DISPLAY;
// Only used when enableShellTopTaskTracking() is disabled
@Nullable
private final TaskInfo mTopTask;
@@ -386,20 +399,22 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta
@Nullable
private final GroupedTaskInfo mVisibleTasks;
+ private final boolean mCanEnterDesktopMode;
// Only used when enableShellTopTaskTracking() is enabled
- CachedTaskInfo(@Nullable GroupedTaskInfo visibleTasks) {
+ CachedTaskInfo(@Nullable GroupedTaskInfo visibleTasks, boolean canEnterDesktopMode) {
mAllCachedTasks = null;
mTopTask = null;
mVisibleTasks = visibleTasks;
-
+ mCanEnterDesktopMode = canEnterDesktopMode;
}
// Only used when enableShellTopTaskTracking() is disabled
- CachedTaskInfo(@NonNull List<TaskInfo> allCachedTasks) {
+ CachedTaskInfo(@NonNull List<TaskInfo> allCachedTasks, boolean canEnterDesktopMode) {
mVisibleTasks = null;
mAllCachedTasks = allCachedTasks;
mTopTask = allCachedTasks.isEmpty() ? null : allCachedTasks.get(0);
+ mCanEnterDesktopMode = canEnterDesktopMode;
}
/**
@@ -509,7 +524,7 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta
&& t.getActivityType() != ACTIVITY_TYPE_RECENTS)
.toList();
return visibleNonExcludedTasks.isEmpty() ? null
- : new CachedTaskInfo(visibleNonExcludedTasks);
+ : new CachedTaskInfo(visibleNonExcludedTasks, mCanEnterDesktopMode);
}
/**
@@ -526,37 +541,25 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta
}
/**
- * Returns {@link Task} array corresponding to the provided task ids which can be used as a
- * placeholder until the true object is loaded by the model
+ * Returns {@link TaskInfo} array corresponding to the provided task ids which can be
+ * used as a placeholder until the true object is loaded by the model. Returns null
+ * directly when [enableShellTopTaskTracking] is true, as it will be a no-op when the
+ * flag is enabled.
*/
- public Task[] getSplitPlaceholderTasks(int[] taskIds) {
+ private TaskInfo[] getSplitPlaceholderTasksInfo(int[] splitTaskIds) {
if (enableShellTopTaskTracking()) {
- if (mVisibleTasks == null || !mVisibleTasks.isBaseType(TYPE_SPLIT)) {
- return new Task[0];
- }
-
- GroupedTaskInfo splitTask = mVisibleTasks.getBaseGroupedTask();
- Task[] result = new Task[taskIds.length];
- for (int i = 0; i < taskIds.length; i++) {
- TaskInfo info = splitTask.getTaskById(taskIds[i]);
- if (info == null) {
- Log.w(TAG, "Requested task (" + taskIds[i] + ") not found");
- return new Task[0];
- }
- result[i] = Task.from(new TaskKey(info), info, false);
- }
- return result;
+ return null;
} else {
if (mTopTask == null) {
- return new Task[0];
+ return new TaskInfo[0];
}
- Task[] result = new Task[taskIds.length];
- for (int i = 0; i < taskIds.length; i++) {
+ TaskInfo[] result = new TaskInfo[splitTaskIds.length];
+ for (int i = 0; i < splitTaskIds.length; i++) {
final int index = i;
- int taskId = taskIds[i];
+ int taskId = splitTaskIds[i];
mAllCachedTasks.forEach(rti -> {
if (rti.taskId == taskId) {
- result[index] = Task.from(new TaskKey(rti), rti, false);
+ result[index] = rti;
}
});
}
@@ -564,6 +567,68 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta
}
}
+ /**
+ * Returns {@link Task} array corresponding to the provided task ids which can be
+ * used as a placeholder until the true object is loaded by the model. Returns null
+ * directly when [enableShellTopTaskTracking] is true, as it will be a no-op when the
+ * flag is enabled.
+ */
+ public Task[] getSplitPlaceholderTasks(int[] splitTaskIds) {
+ if (enableShellTopTaskTracking()) {
+ return null;
+ } else {
+ TaskInfo[] tasksInfo = getSplitPlaceholderTasksInfo(splitTaskIds);
+ Task[] tasks = new Task[tasksInfo.length];
+ for (int i = 0; i < tasksInfo.length; i++) {
+ tasks[i] = Task.from(new TaskKey(tasksInfo[i]), tasksInfo[i], /* isLocked = */
+ false);
+ }
+ return tasks;
+ }
+ }
+
+ private boolean isDesktopTask(TaskInfo taskInfo) {
+ return mCanEnterDesktopMode
+ && taskInfo.configuration.windowConfiguration.getWindowingMode()
+ == WindowConfiguration.WINDOWING_MODE_FREEFORM;
+ }
+
+ // TODO(346588978): Update this to return more than a single task once the callers
+ // are refactored.
+
+ /**
+ * Returns a {@link GroupedTaskInfo} which can be used as a placeholder until the true
+ * object is loaded by the model.
+ *
+ * @param splitTaskIds provide if it is for split, which represents the task ids of the
+ * paired tasks. Otherwise, provide null.
+ */
+ public GroupedTaskInfo getPlaceholderGroupedTaskInfo(@Nullable int[] splitTaskIds) {
+ if (enableShellTopTaskTracking()) {
+ if (mVisibleTasks == null) {
+ return null;
+ }
+ return mVisibleTasks.getBaseGroupedTask();
+ } else {
+ final TaskInfo baseTaskInfo = getLegacyBaseTask();
+ if (baseTaskInfo == null) {
+ return null;
+ }
+ if (splitTaskIds != null && splitTaskIds.length >= 2) {
+ TaskInfo[] splitTasksInfo = getSplitPlaceholderTasksInfo(splitTaskIds);
+ return GroupedTaskInfo.forSplitTasks(splitTasksInfo[0],
+ splitTasksInfo[1], /* splitBounds = */ null);
+ } else if (isDesktopTask(baseTaskInfo)) {
+ return GroupedTaskInfo.forDeskTasks(INACTIVE_DESK_ID, mDisplayId,
+ Collections.singletonList(
+ baseTaskInfo), /* minimizedFreeformTaskIds = */
+ Collections.emptySet());
+ } else {
+ return GroupedTaskInfo.forFullscreenTasks(baseTaskInfo);
+ }
+ }
+ }
+
@Nullable
public String getPackageName() {
final TaskInfo baseTask = getLegacyBaseTask();