diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index 6380801af6b0d..01f5e8f72a2bd 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -1410,10 +1410,10 @@ public class ActivityManager { public static final int RECENT_IGNORE_HOME_STACK_TASKS = 0x0008; /** - * Ignores all tasks that are on the docked stack. + * Ignores the top task in the docked stack. * @hide */ - public static final int RECENT_INGORE_DOCKED_STACK_TASKS = 0x0010; + public static final int RECENT_INGORE_DOCKED_STACK_TOP_TASK = 0x0010; /** * Ignores all tasks that are on the pinned stack. diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java index 7daef649adfce..c52d17f3a58c1 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java @@ -438,7 +438,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener } // Launch the task - ssp.startActivityFromRecents(mContext, toTask.key.id, toTask.title, launchOpts); + ssp.startActivityFromRecents(mContext, toTask.key, toTask.title, launchOpts); } /** @@ -510,7 +510,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener MetricsLogger.count(mContext, "overview_affiliated_task_launch", 1); // Launch the task - ssp.startActivityFromRecents(mContext, toTask.key.id, toTask.title, launchOpts); + ssp.startActivityFromRecents(mContext, toTask.key, toTask.title, launchOpts); } public void showNextAffiliatedTask() { diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java index 3b759c02c8ca3..1a4b40f507e8f 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java +++ b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java @@ -18,6 +18,7 @@ package com.android.systemui.recents.misc; import static android.app.ActivityManager.StackId.DOCKED_STACK_ID; import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID; +import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID; import static android.app.ActivityManager.StackId.HOME_STACK_ID; import static android.app.ActivityManager.StackId.PINNED_STACK_ID; import static android.provider.Settings.Global.DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT; @@ -77,6 +78,7 @@ import com.android.internal.os.BackgroundThread; import com.android.systemui.R; import com.android.systemui.recents.RecentsDebugFlags; import com.android.systemui.recents.RecentsImpl; +import com.android.systemui.recents.model.Task; import com.android.systemui.recents.tv.RecentsTvImpl; import com.android.systemui.recents.model.ThumbnailData; @@ -284,7 +286,7 @@ public class SystemServicesProxy { int numTasksToQuery = Math.max(minNumTasksToQuery, numLatestTasks); List tasks = mAm.getRecentTasksForUser(numTasksToQuery, ActivityManager.RECENT_IGNORE_HOME_STACK_TASKS | - ActivityManager.RECENT_INGORE_DOCKED_STACK_TASKS | + ActivityManager.RECENT_INGORE_DOCKED_STACK_TOP_TASK | ActivityManager.RECENT_INGORE_PINNED_STACK_TASKS | ActivityManager.RECENT_IGNORE_UNAVAILABLE | ActivityManager.RECENT_INCLUDE_PROFILES | @@ -962,11 +964,20 @@ public class SystemServicesProxy { } /** Starts an activity from recents. */ - public boolean startActivityFromRecents(Context context, int taskId, String taskName, + public boolean startActivityFromRecents(Context context, Task.TaskKey taskKey, String taskName, ActivityOptions options) { if (mIam != null) { try { - mIam.startActivityFromRecents(taskId, options == null ? null : options.toBundle()); + if (taskKey.stackId == DOCKED_STACK_ID) { + // We show non-visible docked tasks in Recents, but we always want to launch + // them in the fullscreen stack. + if (options == null) { + options = ActivityOptions.makeBasic(); + } + options.setLaunchStackId(FULLSCREEN_WORKSPACE_STACK_ID); + } + mIam.startActivityFromRecents( + taskKey.id, options == null ? null : options.toBundle()); return true; } catch (Exception e) { Log.e(TAG, context.getString(R.string.recents_launch_error_message, taskName), e); diff --git a/packages/SystemUI/src/com/android/systemui/recents/tv/views/RecentsTvTransitionHelper.java b/packages/SystemUI/src/com/android/systemui/recents/tv/views/RecentsTvTransitionHelper.java index bd3143f688cc2..a69f8a2cf3991 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/tv/views/RecentsTvTransitionHelper.java +++ b/packages/SystemUI/src/com/android/systemui/recents/tv/views/RecentsTvTransitionHelper.java @@ -89,7 +89,7 @@ public class RecentsTvTransitionHelper { private void startTaskActivity(TaskStack stack, Task task, @Nullable TaskCardView taskView, ActivityOptions opts,final ActivityOptions.OnAnimationStartedListener animStartedListener) { SystemServicesProxy ssp = Recents.getSystemServices(); - if (ssp.startActivityFromRecents(mContext, task.key.id, task.title, opts)) { + if (ssp.startActivityFromRecents(mContext, task.key, task.title, opts)) { // Keep track of the index of the task launch int taskIndexFromFront = 0; int taskIndex = stack.indexOfStackTask(task); diff --git a/packages/SystemUI/src/com/android/systemui/recents/tv/views/RecentsTvView.java b/packages/SystemUI/src/com/android/systemui/recents/tv/views/RecentsTvView.java index 3d5176f2554eb..d966614efb1bb 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/tv/views/RecentsTvView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/tv/views/RecentsTvView.java @@ -109,7 +109,7 @@ public class RecentsTvView extends FrameLayout { Task task = mTaskStackHorizontalView.getFocusedTask(); if (task != null) { SystemServicesProxy ssp = Recents.getSystemServices(); - ssp.startActivityFromRecents(getContext(), task.key.id, task.title, null); + ssp.startActivityFromRecents(getContext(), task.key, task.title, null); return true; } } @@ -123,7 +123,7 @@ public class RecentsTvView extends FrameLayout { Task task = stack.getLaunchTarget(); if (task != null) { SystemServicesProxy ssp = Recents.getSystemServices(); - ssp.startActivityFromRecents(getContext(), task.key.id, task.title, null); + ssp.startActivityFromRecents(getContext(), task.key, task.title, null); return true; } } @@ -140,7 +140,7 @@ public class RecentsTvView extends FrameLayout { TaskCardView tv = taskViews.get(j); if (tv.getTask() == task) { SystemServicesProxy ssp = Recents.getSystemServices(); - ssp.startActivityFromRecents(getContext(), task.key.id, task.title, null); + ssp.startActivityFromRecents(getContext(), task.key, task.title, null); return true; } } diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java index 98616f49ee883..9dc3fb14936a8 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java @@ -186,7 +186,7 @@ public class RecentsTransitionHelper { ActivityOptions opts, IAppTransitionAnimationSpecsFuture transitionFuture, final ActivityOptions.OnAnimationStartedListener animStartedListener) { SystemServicesProxy ssp = Recents.getSystemServices(); - if (ssp.startActivityFromRecents(mContext, task.key.id, task.title, opts)) { + if (ssp.startActivityFromRecents(mContext, task.key, task.title, opts)) { // Keep track of the index of the task launch int taskIndexFromFront = 0; int taskIndex = stack.indexOfStackTask(task); diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 9070849c80923..9e0934d46d3a9 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -8845,10 +8845,11 @@ public final class ActivityManagerService extends ActivityManagerNative continue; } } - if ((flags & ActivityManager.RECENT_INGORE_DOCKED_STACK_TASKS) != 0) { - if (tr.stack != null && tr.stack.isDockedStack()) { + if ((flags & ActivityManager.RECENT_INGORE_DOCKED_STACK_TOP_TASK) != 0) { + final ActivityStack stack = tr.stack; + if (stack != null && stack.isDockedStack() && stack.topTask() == tr) { if (DEBUG_RECENTS) Slog.d(TAG_RECENTS, - "Skipping, docked stack task: " + tr); + "Skipping, top task in docked stack: " + tr); continue; } }