Merge changes from topic "ttt-refactor" into main
* changes:
Migrate to TopTaskTracker.getPlaceholderGroupedTaskInfo
Introduce TopTaskTracker.getPlaceholderGroupedTaskInfo
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index 47aa1de..48630b1 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -161,7 +161,6 @@
import com.android.quickstep.views.TaskViewType;
import com.android.systemui.animation.TransitionAnimator;
import com.android.systemui.contextualeducation.GestureType;
-import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.recents.model.ThumbnailData;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.InputConsumerController;
@@ -170,6 +169,7 @@
import com.android.systemui.shared.system.TaskStackChangeListener;
import com.android.systemui.shared.system.TaskStackChangeListeners;
import com.android.wm.shell.Flags;
+import com.android.wm.shell.shared.GroupedTaskInfo;
import com.android.wm.shell.shared.TransactionPool;
import com.android.wm.shell.shared.desktopmode.DesktopModeStatus;
import com.android.wm.shell.shared.startingsurface.SplashScreenExitAnimationUtils;
@@ -182,7 +182,6 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
-import java.util.Objects;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.function.Consumer;
@@ -693,26 +692,23 @@
}
protected void notifyGestureAnimationStartToRecents() {
- Task[] runningTasks;
- TopTaskTracker.CachedTaskInfo cachedTaskInfo = mGestureState.getRunningTask();
- if (mIsSwipeForSplit) {
- int[] splitTaskIds = TopTaskTracker.INSTANCE.get(mContext).getRunningSplitTaskIds();
- runningTasks = cachedTaskInfo.getSplitPlaceholderTasks(splitTaskIds);
- } else {
- runningTasks = cachedTaskInfo.getPlaceholderTasks();
- }
+ int[] splitTaskIds = mIsSwipeForSplit
+ ? TopTaskTracker.INSTANCE.get(mContext).getRunningSplitTaskIds()
+ : null;
+ GroupedTaskInfo groupedTaskInfo =
+ mGestureState.getRunningTask().getPlaceholderGroupedTaskInfo(splitTaskIds);
// Safeguard against any null tasks being sent to recents view, happens when quickswitching
// very quickly w/ split tasks because TopTaskTracker provides stale information compared to
// actual running tasks in the recents animation.
// TODO(b/236226779), Proper fix (ag/22237143)
- if (Arrays.stream(runningTasks).anyMatch(Objects::isNull)) {
+ if (groupedTaskInfo == null) {
return;
}
if (mRecentsView == null) {
return;
}
- mRecentsView.onGestureAnimationStart(runningTasks);
+ mRecentsView.onGestureAnimationStart(groupedTaskInfo);
TaskView currentPageTaskView = mRecentsView.getCurrentPageTaskView();
if (currentPageTaskView != null) {
mPreviousTaskViewType = currentPageTaskView.getType();
diff --git a/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java b/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java
index 7d8a53d..9365383 100644
--- a/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java
+++ b/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java
@@ -218,7 +218,8 @@
if (mRunningOverHome) {
if (DisplayController.getNavigationMode(mContext).hasGestures) {
mRecentsView.onGestureAnimationStartOnHome(
- mGestureState.getRunningTask().getPlaceholderTasks());
+ mGestureState.getRunningTask().getPlaceholderGroupedTaskInfo(
+ /* splitTaskIds = */ null));
}
} else {
super.notifyGestureAnimationStartToRecents();
diff --git a/quickstep/src/com/android/quickstep/TopTaskTracker.java b/quickstep/src/com/android/quickstep/TopTaskTracker.java
index 7e773e3..43e8ff9 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.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.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;
@@ -50,8 +55,6 @@
import com.android.quickstep.dagger.QuickstepBaseAppComponent;
import com.android.quickstep.util.DesksUtils;
import com.android.quickstep.util.ExternalDisplaysKt;
-import com.android.systemui.shared.recents.model.Task;
-import com.android.systemui.shared.recents.model.Task.TaskKey;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.TaskStackChangeListener;
import com.android.systemui.shared.system.TaskStackChangeListeners;
@@ -92,8 +95,11 @@
// 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 +116,8 @@
TaskStackChangeListeners.getInstance().unregisterTaskStackListener(this);
systemUiProxy.unregisterSplitScreenListener(this);
});
+
+ mCanEnterDesktopMode = canEnterDesktopMode(context);
}
@Override
@@ -324,7 +332,7 @@
// 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 +343,9 @@
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 +362,10 @@
|| 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 +385,8 @@
* 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 +397,22 @@
@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,58 +522,73 @@
&& t.getActivityType() != ACTIVITY_TYPE_RECENTS)
.toList();
return visibleNonExcludedTasks.isEmpty() ? null
- : new CachedTaskInfo(visibleNonExcludedTasks);
+ : new CachedTaskInfo(visibleNonExcludedTasks, mCanEnterDesktopMode);
}
/**
- * Returns {@link Task} array 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. Only used when
+ * enableShellTopTaskTracking() is disabled.
*/
- public Task[] getPlaceholderTasks() {
- final TaskInfo baseTask = getLegacyBaseTask();
- // TODO(346588978): Update this to return more than a single task once the callers
- // are refactored
- return baseTask == null
- ? new Task[0]
- : new Task[]{Task.from(new TaskKey(baseTask), baseTask, false)};
- }
-
- /**
- * 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
- */
- public Task[] getSplitPlaceholderTasks(int[] taskIds) {
- 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];
+ private TaskInfo[] getSplitPlaceholderTasksInfo(int[] splitTaskIds) {
+ if (mTopTask == null) {
+ return new TaskInfo[0];
+ }
+ TaskInfo[] result = new TaskInfo[splitTaskIds.length];
+ for (int i = 0; i < splitTaskIds.length; i++) {
+ final int index = i;
+ int taskId = splitTaskIds[i];
+ mAllCachedTasks.forEach(rti -> {
+ if (rti.taskId == taskId) {
+ result[index] = rti;
}
- result[i] = Task.from(new TaskKey(info), info, false);
+ });
+ }
+ return result;
+ }
+
+ 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 result;
+ return mVisibleTasks.getBaseGroupedTask();
} else {
- if (mTopTask == null) {
- return new Task[0];
+ final TaskInfo baseTaskInfo = getLegacyBaseTask();
+ if (baseTaskInfo == null) {
+ return null;
}
- Task[] result = new Task[taskIds.length];
- for (int i = 0; i < taskIds.length; i++) {
- final int index = i;
- int taskId = taskIds[i];
- mAllCachedTasks.forEach(rti -> {
- if (rti.taskId == taskId) {
- result[index] = Task.from(new TaskKey(rti), rti, false);
- }
- });
+ if (splitTaskIds != null && splitTaskIds.length >= 2) {
+ TaskInfo[] splitTasksInfo = getSplitPlaceholderTasksInfo(splitTaskIds);
+ if (splitTasksInfo[0] == null || splitTasksInfo[1] == null) {
+ return null;
+ }
+ 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);
}
- return result;
}
}
diff --git a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
index 695c77c..dc1cdde 100644
--- a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
+++ b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
@@ -56,6 +56,7 @@
import com.android.quickstep.views.TaskContainer;
import com.android.quickstep.views.TaskView;
import com.android.systemui.shared.recents.model.Task;
+import com.android.wm.shell.shared.GroupedTaskInfo;
import java.util.ArrayList;
import java.util.Arrays;
@@ -116,11 +117,13 @@
* to the home task. This allows us to handle quick-switch similarly to a quick-switching
* from a foreground task.
*/
- public void onGestureAnimationStartOnHome(Task[] homeTask) {
+ public void onGestureAnimationStartOnHome(GroupedTaskInfo homeTaskInfo) {
// TODO(b/195607777) General fallback love, but this might be correct
// Home task should be defined as the front-most task info I think?
- mHomeTask = homeTask.length > 0 ? homeTask[0] : null;
- onGestureAnimationStart(homeTask);
+ if (homeTaskInfo != null) {
+ mHomeTask = Task.from(homeTaskInfo.getTaskInfo1());
+ }
+ onGestureAnimationStart(homeTaskInfo);
}
/**
@@ -175,13 +178,13 @@
}
@Override
- protected boolean shouldAddStubTaskView(Task[] runningTasks) {
- if (runningTasks.length > 1) {
+ protected boolean shouldAddStubTaskView(GroupedTaskInfo groupedTaskInfo) {
+ if (!groupedTaskInfo.isBaseType(GroupedTaskInfo.TYPE_FULLSCREEN)) {
// can't be in split screen w/ home task
- return super.shouldAddStubTaskView(runningTasks);
+ return super.shouldAddStubTaskView(groupedTaskInfo);
}
- Task runningTask = runningTasks[0];
+ Task runningTask = Task.from(groupedTaskInfo.getTaskInfo1());
if (mHomeTask != null && runningTask != null
&& mHomeTask.key.id == runningTask.key.id
&& !hasTaskViews() && mLoadPlanEverApplied) {
@@ -190,7 +193,7 @@
// Ignore empty task signal if applyLoadPlan has never run.
return false;
}
- return super.shouldAddStubTaskView(runningTasks);
+ return super.shouldAddStubTaskView(groupedTaskInfo);
}
@Override
diff --git a/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowSwipeHandler.java b/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowSwipeHandler.java
index b365ddf..0d139b4 100644
--- a/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowSwipeHandler.java
+++ b/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowSwipeHandler.java
@@ -257,7 +257,8 @@
if (mRunningOverHome) {
if (DisplayController.getNavigationMode(mContext).hasGestures) {
mRecentsView.onGestureAnimationStartOnHome(
- mGestureState.getRunningTask().getPlaceholderTasks());
+ mGestureState.getRunningTask().getPlaceholderGroupedTaskInfo(
+ /* splitTaskIds = */ null));
}
} else {
super.notifyGestureAnimationStartToRecents();
@@ -283,7 +284,7 @@
private final AnimatedFloat mHomeAlpha = new AnimatedFloat(this::updateAppTransforms);
private final AnimatedFloat mVerticalShiftForScale =
new AnimatedFloat(this::updateAppTransforms);
- private final AnimatedFloat mRecentsAlpha = new AnimatedFloat(this:: updateAppTransforms);
+ private final AnimatedFloat mRecentsAlpha = new AnimatedFloat(this::updateAppTransforms);
private final RectF mTargetRect = new RectF();
private SurfaceControl mSurfaceControl;
diff --git a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
index c1282b9..b86d0c8 100644
--- a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
@@ -54,7 +54,7 @@
import com.android.quickstep.SystemUiProxy;
import com.android.quickstep.util.AnimUtils;
import com.android.quickstep.util.SplitSelectStateController;
-import com.android.systemui.shared.recents.model.Task;
+import com.android.wm.shell.shared.GroupedTaskInfo;
import kotlin.Unit;
@@ -275,8 +275,8 @@
}
@Override
- public void onGestureAnimationStart(Task[] runningTasks) {
- super.onGestureAnimationStart(runningTasks);
+ public void onGestureAnimationStart(GroupedTaskInfo groupedTaskInfo) {
+ super.onGestureAnimationStart(groupedTaskInfo);
if (!ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY.isTrue()) {
// TODO: b/333533253 - Remove after flag rollout
DesktopVisibilityController.INSTANCE.get(mContainer).setRecentsGestureStart();
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 8f7dc80..ea95206 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -87,7 +87,6 @@
import android.animation.PropertyValuesHolder;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
-import android.app.WindowConfiguration;
import android.content.Context;
import android.content.Intent;
import android.content.LocusId;
@@ -234,6 +233,7 @@
import com.android.quickstep.util.VibrationConstants;
import com.android.systemui.plugins.ResourceProvider;
import com.android.systemui.shared.recents.model.Task;
+import com.android.systemui.shared.recents.model.Task.TaskKey;
import com.android.systemui.shared.recents.model.ThumbnailData;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.InteractionJankMonitorWrapper;
@@ -241,6 +241,7 @@
import com.android.systemui.shared.system.TaskStackChangeListener;
import com.android.systemui.shared.system.TaskStackChangeListeners;
import com.android.wm.shell.common.pip.IPipAnimationListener;
+import com.android.wm.shell.shared.GroupedTaskInfo;
import com.android.wm.shell.shared.desktopmode.DesktopModeStatus;
import com.android.wm.shell.shared.desktopmode.DesktopModeTransitionSource;
@@ -567,10 +568,10 @@
private DesktopVisibilityController mDesktopVisibilityController = null;
/**
- * Reflects if Recents is currently in the middle of a gesture, and if so, which tasks are
- * running. If a gesture is not in progress, this will be null.
+ * Reflects if Recents is currently in the middle of a gesture, and if so, which related
+ * [GroupedTaskInfo] is running. If a gesture is not in progress, this will be null.
*/
- private @Nullable Task[] mActiveGestureRunningTasks;
+ private @Nullable GroupedTaskInfo mActiveGestureGroupedTaskInfo;
// Keeps track of the previously known visible tasks for purposes of loading/unloading task data
private final SparseBooleanArray mHasVisibleTaskData = new SparseBooleanArray();
@@ -582,7 +583,7 @@
private final ViewPool<GroupedTaskView> mGroupedTaskViewPool;
private final ViewPool<DesktopTaskView> mDesktopTaskViewPool;
- private final TaskOverlayFactory mTaskOverlayFactory;
+ protected final TaskOverlayFactory mTaskOverlayFactory;
protected boolean mDisallowScrollToClearAll;
// True if it is not allowed to scroll to [AddDesktopButton].
@@ -671,7 +672,7 @@
return;
}
Log.d(TAG, "onTaskRemoved: " + taskId);
- Task.TaskKey taskKey = taskContainer.getTask().key;
+ TaskKey taskKey = taskContainer.getTask().key;
UI_HELPER_EXECUTOR.execute(new CancellableTask<>(
() -> PackageManagerWrapper.getInstance()
.getActivityInfo(taskKey.getComponent(), taskKey.userId) == null,
@@ -2100,12 +2101,12 @@
if (newRunningTaskView != null) {
setRunningTaskViewId(newRunningTaskView.getTaskViewId());
} else {
- if (mActiveGestureRunningTasks != null) {
+ if (mActiveGestureGroupedTaskInfo != null) {
// This will update mRunningTaskViewId and create a stub view if necessary.
// We try to avoid this because it can cause a scroll jump, but it is needed
// for cases where the running task isn't included in this load plan (e.g. if
// the current running task is excludedFromRecents.)
- showCurrentTask(mActiveGestureRunningTasks, "applyLoadPlan");
+ showCurrentTask(mActiveGestureGroupedTaskInfo, "applyLoadPlan");
newRunningTaskView = getRunningTaskView();
} else {
setRunningTaskViewId(INVALID_TASK_ID);
@@ -2826,7 +2827,7 @@
* Handle the edge case where Recents could increment task count very high over long
* period of device usage. Probably will never happen, but meh.
*/
- private TaskView getTaskViewFromPool(TaskViewType type) {
+ protected TaskView getTaskViewFromPool(TaskViewType type) {
TaskView taskView;
switch (type) {
case GROUPED:
@@ -2880,10 +2881,9 @@
*/
// TODO: b/401582344 - Implement a way to exclude the `DesktopWallpaperActivity` from being
// considered in Overview.
- public void onGestureAnimationStart(Task[] runningTasks) {
- Log.d(TAG, "onGestureAnimationStart - runningTasks: " + Arrays.toString(runningTasks));
- mActiveGestureRunningTasks = runningTasks;
-
+ public void onGestureAnimationStart(GroupedTaskInfo groupedTaskInfo) {
+ Log.d(TAG, "onGestureAnimationStart - groupedTaskInfo: " + groupedTaskInfo);
+ mActiveGestureGroupedTaskInfo = groupedTaskInfo;
// This needs to be called before the other states are set since it can create the task view
if (mOrientationState.setGestureActive(true)) {
@@ -2893,7 +2893,7 @@
updateSizeAndPadding();
}
- showCurrentTask(mActiveGestureRunningTasks, "onGestureAnimationStart");
+ showCurrentTask(groupedTaskInfo, "onGestureAnimationStart");
setEnableFreeScroll(false);
setEnableDrawingLiveTile(false);
setRunningTaskHidden(true);
@@ -2908,7 +2908,7 @@
}
private boolean isGestureActive() {
- return mActiveGestureRunningTasks != null;
+ return mActiveGestureGroupedTaskInfo != null;
}
/**
@@ -3046,7 +3046,7 @@
* Called when a gesture from an app has finished, and the animation to the target has ended.
*/
public void onGestureAnimationEnd() {
- mActiveGestureRunningTasks = null;
+ mActiveGestureGroupedTaskInfo = null;
if (mOrientationState.setGestureActive(false)) {
updateOrientationHandler(/* forceRecreateDragLayerControllers = */ false);
}
@@ -3085,10 +3085,17 @@
/**
* Returns true if we should add a stub taskView for the running task id
*/
- protected boolean shouldAddStubTaskView(Task[] runningTasks) {
- int[] runningTaskIds = Arrays.stream(runningTasks).mapToInt(task -> task.key.id).toArray();
+ protected boolean shouldAddStubTaskView(GroupedTaskInfo groupedTaskInfo) {
+ int[] runningTaskIds;
+ if (groupedTaskInfo != null) {
+ runningTaskIds = groupedTaskInfo.getTaskInfoList().stream().mapToInt(
+ taskInfo -> taskInfo.taskId).toArray();
+ } else {
+ runningTaskIds = new int[0];
+ }
TaskView matchingTaskView = null;
- if (hasDesktopTask(runningTasks) && runningTaskIds.length == 1) {
+ if (groupedTaskInfo != null && groupedTaskInfo.isBaseType(GroupedTaskInfo.TYPE_DESK)
+ && runningTaskIds.length == 1) {
// TODO(b/342635213): Unsure if it's expected, desktop runningTasks only have a single
// taskId, therefore we match any DesktopTaskView that contains the runningTaskId.
TaskView taskview = getTaskViewByTaskId(runningTaskIds[0]);
@@ -3102,53 +3109,36 @@
}
/**
- * Creates a `DesktopTaskView` for the currently active desk on this display, which contains the
- * gievn `runningTasks`.
- */
- private DesktopTaskView createDesktopTaskViewForActiveDesk(Task[] runningTasks) {
- final int activeDeskId = mUtils.getActiveDeskIdOnThisDisplay();
- final var desktopTaskView = (DesktopTaskView) getTaskViewFromPool(TaskViewType.DESKTOP);
-
- // TODO: b/401582344 - Implement a way to exclude the `DesktopWallpaperActivity`.
- desktopTaskView.bind(
- new DesktopTask(activeDeskId, mContainer.getDisplayId(),
- Arrays.asList(runningTasks)),
- mOrientationState, mTaskOverlayFactory);
- return desktopTaskView;
- }
-
- /**
- * Creates a task view (if necessary) to represent the task with the {@param runningTaskId}.
+ * Creates a task view (if necessary) to represent the tasks with the {@param groupedTaskInfo}.
*
* All subsequent calls to reload will keep the task as the first item until {@link #reset()}
* is called. Also scrolls the view to this task.
*/
- private void showCurrentTask(Task[] runningTasks, String caller) {
- Log.d(TAG, "showCurrentTask(" + caller + ") - runningTasks: "
- + Arrays.toString(runningTasks));
- if (runningTasks.length == 0) {
+ private void showCurrentTask(GroupedTaskInfo groupedTaskInfo, String caller) {
+ Log.d(TAG, "showCurrentTask(" + caller + ") - groupedTaskInfo: " + groupedTaskInfo);
+ if (groupedTaskInfo == null) {
return;
}
int runningTaskViewId = -1;
- if (shouldAddStubTaskView(runningTasks)) {
+ if (shouldAddStubTaskView(groupedTaskInfo)) {
boolean wasEmpty = getChildCount() == 0;
// Add an empty view for now until the task plan is loaded and applied
final TaskView taskView;
- final boolean needGroupTaskView = runningTasks.length > 1;
- final boolean needDesktopTask = hasDesktopTask(runningTasks);
- if (needDesktopTask) {
- taskView = createDesktopTaskViewForActiveDesk(runningTasks);
- } else if (needGroupTaskView) {
+ if (groupedTaskInfo.isBaseType(GroupedTaskInfo.TYPE_DESK)) {
+ taskView = mUtils.createDesktopTaskViewForActiveDesk(groupedTaskInfo);
+ } else if (groupedTaskInfo.isBaseType(GroupedTaskInfo.TYPE_SPLIT)) {
taskView = getTaskViewFromPool(TaskViewType.GROUPED);
// When we create a placeholder task view mSplitBoundsConfig will be null, but with
// the actual app running we won't need to show the thumbnail until all the tasks
// load later anyways
- ((GroupedTaskView) taskView).bind(runningTasks[0], runningTasks[1],
- mOrientationState, mTaskOverlayFactory, mSplitBoundsConfig);
+ ((GroupedTaskView) taskView).bind(Task.from(groupedTaskInfo.getTaskInfo1()),
+ Task.from(groupedTaskInfo.getTaskInfo2()), mOrientationState,
+ mTaskOverlayFactory, mSplitBoundsConfig);
} else {
taskView = getTaskViewFromPool(TaskViewType.SINGLE);
- taskView.bind(runningTasks[0], mOrientationState, mTaskOverlayFactory);
+ taskView.bind(Task.from(groupedTaskInfo.getTaskInfo1()), mOrientationState,
+ mTaskOverlayFactory);
}
if (mAddDesktopButton != null && wasEmpty) {
addView(mAddDesktopButton);
@@ -3165,7 +3155,7 @@
makeMeasureSpec(getMeasuredHeight(), EXACTLY));
layout(getLeft(), getTop(), getRight(), getBottom());
} else {
- var runningTaskView = getTaskViewByTaskId(runningTasks[0].key.id);
+ var runningTaskView = getTaskViewByTaskId(groupedTaskInfo.getTaskInfo1().taskId);
if (runningTaskView != null) {
runningTaskViewId = runningTaskView.getTaskViewId();
}
@@ -3198,22 +3188,6 @@
reloadIfNeeded();
}
- private boolean hasDesktopTask(Task[] runningTasks) {
- if (!DesktopModeStatus.canEnterDesktopMode(mContext)) {
- return false;
- }
- for (Task task : runningTasks) {
- if (task.key.windowingMode == WindowConfiguration.WINDOWING_MODE_FREEFORM) {
- return true;
- }
- }
-
- // A running empty desk will have a single running app for the `DesktopWallpaperActivity`.
- // TODO: b/401582344 - Implement a way to exclude the `DesktopWallpaperActivity`.
-
- return false;
- }
-
/**
* Sets the running task id, cleaning up the old running task if necessary.
*/
diff --git a/quickstep/src/com/android/quickstep/views/RecentsViewUtils.kt b/quickstep/src/com/android/quickstep/views/RecentsViewUtils.kt
index 50941fe..b265b13 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsViewUtils.kt
+++ b/quickstep/src/com/android/quickstep/views/RecentsViewUtils.kt
@@ -39,7 +39,9 @@
import com.android.quickstep.util.GroupTask
import com.android.quickstep.util.isExternalDisplay
import com.android.quickstep.views.RecentsView.RUNNING_TASK_ATTACH_ALPHA
+import com.android.systemui.shared.recents.model.Task
import com.android.systemui.shared.recents.model.ThumbnailData
+import com.android.wm.shell.shared.GroupedTaskInfo
import java.util.function.BiConsumer
import kotlin.math.min
import kotlin.reflect.KMutableProperty1
@@ -459,6 +461,22 @@
}
}
+ /**
+ * Creates a [DesktopTaskView] for the currently active desk on this display, which contains the
+ * tasks with the given [groupedTaskInfo].
+ */
+ fun createDesktopTaskViewForActiveDesk(groupedTaskInfo: GroupedTaskInfo): DesktopTaskView {
+ val desktopTaskView =
+ recentsView.getTaskViewFromPool(TaskViewType.DESKTOP) as DesktopTaskView
+ val tasks: List<Task> = groupedTaskInfo.taskInfoList.map { taskInfo -> Task.from(taskInfo) }
+ desktopTaskView.bind(
+ DesktopTask(groupedTaskInfo.deskId, groupedTaskInfo.deskDisplayId, tasks),
+ recentsView.mOrientationState,
+ recentsView.mTaskOverlayFactory,
+ )
+ return desktopTaskView
+ }
+
companion object {
class RecentsViewFloatProperty(
private val utilsProperty: KMutableProperty1<RecentsViewUtils, Float>
diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/AbsSwipeUpHandlerTestCase.java b/quickstep/tests/multivalentTests/src/com/android/quickstep/AbsSwipeUpHandlerTestCase.java
index 2f5f160..568da2d 100644
--- a/quickstep/tests/multivalentTests/src/com/android/quickstep/AbsSwipeUpHandlerTestCase.java
+++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/AbsSwipeUpHandlerTestCase.java
@@ -101,7 +101,8 @@
protected final ActivityManager.RunningTaskInfo mRunningTaskInfo =
new ActivityManager.RunningTaskInfo();
protected final TopTaskTracker.CachedTaskInfo mCachedTaskInfo =
- new TopTaskTracker.CachedTaskInfo(Collections.singletonList(mRunningTaskInfo));
+ new TopTaskTracker.CachedTaskInfo(
+ Collections.singletonList(mRunningTaskInfo), /* canEnterDesktopMode = */ false);
protected final RemoteAnimationTarget mRemoteAnimationTarget = new RemoteAnimationTarget(
/* taskId= */ 0,
/* mode= */ RemoteAnimationTarget.MODE_CLOSING,