Merge "Exclude recent tasks within an ActivityView"
diff --git a/services/core/java/com/android/server/wm/RecentTasks.java b/services/core/java/com/android/server/wm/RecentTasks.java
index c6c85fd..0480d43 100644
--- a/services/core/java/com/android/server/wm/RecentTasks.java
+++ b/services/core/java/com/android/server/wm/RecentTasks.java
@@ -1159,7 +1159,8 @@
/**
* @return whether the given active task should be presented to the user through SystemUI.
*/
- private boolean isVisibleRecentTask(TaskRecord task) {
+ @VisibleForTesting
+ boolean isVisibleRecentTask(TaskRecord task) {
if (DEBUG_RECENTS_TRIM_TASKS) Slog.d(TAG, "isVisibleRecentTask: task=" + task
+ " minVis=" + mMinNumVisibleTasks + " maxVis=" + mMaxNumVisibleTasks
+ " sessionDuration=" + mActiveTasksSessionDurationMs
@@ -1195,6 +1196,17 @@
}
}
+ // Tasks managed by/associated with an ActivityView should be excluded from recents.
+ // singleTaskInstance is set on the VirtualDisplay managed by ActivityView
+ // TODO(b/126185105): Find a different signal to use besides isSingleTaskInstance
+ final ActivityStack stack = task.getStack();
+ if (stack != null) {
+ ActivityDisplay display = stack.getDisplay();
+ if (display != null && display.isSingleTaskInstance()) {
+ return false;
+ }
+ }
+
// If we're in lock task mode, ignore the root task
if (task == mService.getLockTaskController().getRootTask()) {
return false;
diff --git a/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java b/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java
index 3e025f6..fc1eb1c 100644
--- a/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java
@@ -30,7 +30,6 @@
import static android.view.Display.DEFAULT_DISPLAY;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
-import static com.android.dx.mockito.inline.extended.ExtendedMockito.spy;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
@@ -96,6 +95,7 @@
private TestActivityTaskManagerService mTestService;
private ActivityDisplay mDisplay;
private ActivityDisplay mOtherDisplay;
+ private ActivityDisplay mSingleTaskDisplay;
private ActivityStack mStack;
private ActivityStack mHomeStack;
private TestTaskPersister mTaskPersister;
@@ -547,6 +547,41 @@
assertTrimmed(mTasks.get(0), mTasks.get(1));
}
+ /**
+ * Tests that tasks on singleTaskDisplay are not visible and not trimmed/removed.
+ */
+ @Test
+ public void testVisibleTasks_singleTaskDisplay() {
+ mRecentTasks.setOnlyTestVisibleRange();
+ mRecentTasks.setParameters(-1 /* min */, 3 /* max */, -1 /* ms */);
+
+ ActivityStack singleTaskStack = mSingleTaskDisplay.createStack(
+ WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */);
+
+ TaskRecord excludedTask1 = createTaskBuilder(".ExcludedTask1")
+ .setStack(singleTaskStack)
+ .build();
+
+ assertFalse("Tasks on singleTaskDisplay should not be visible recents",
+ mRecentTasks.isVisibleRecentTask(excludedTask1));
+
+ mRecentTasks.add(excludedTask1);
+
+ // Add N+1 visible tasks.
+ mRecentTasks.add(mTasks.get(0));
+ mRecentTasks.add(mTasks.get(1));
+ mRecentTasks.add(mTasks.get(2));
+ mRecentTasks.add(mTasks.get(3));
+
+ // excludedTask is not trimmed.
+ assertTrimmed(mTasks.get(0));
+
+ mRecentTasks.removeAllVisibleTasks();
+
+ // Only visible tasks removed.
+ assertTrimmed(mTasks.get(0), mTasks.get(1), mTasks.get(2), mTasks.get(3));
+ }
+
@Test
public void testBackStackTasks_expectNoTrim() {
mRecentTasks.setParameters(-1 /* min */, 1 /* max */, -1 /* ms */);
@@ -879,8 +914,12 @@
super.createDefaultDisplay();
mDisplay = mRootActivityContainer.getActivityDisplay(DEFAULT_DISPLAY);
mOtherDisplay = TestActivityDisplay.create(mTestStackSupervisor, DEFAULT_DISPLAY + 1);
+ mSingleTaskDisplay = TestActivityDisplay.create(mTestStackSupervisor,
+ DEFAULT_DISPLAY + 2);
+ mSingleTaskDisplay.setDisplayToSingleTaskInstance();
mRootActivityContainer.addChild(mOtherDisplay, ActivityDisplay.POSITION_TOP);
mRootActivityContainer.addChild(mDisplay, ActivityDisplay.POSITION_TOP);
+ mRootActivityContainer.addChild(mSingleTaskDisplay, ActivityDisplay.POSITION_TOP);
}
}