summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chris Li <lihongyu@google.com> 2022-11-22 08:00:03 +0000
committer Chris Li <lihongyu@google.com> 2022-11-22 08:22:54 +0000
commitcf84dd8a1be73725dc4635ad2d7fa94f21a0003c (patch)
treed88d0a7b15bd5be63fd9f059f6da3aa75b77f1a2
parentafac90a1ee1a1eca9756001cd3957b0328810440 (diff)
Reland Cleanup embedded Task related code from WindowTestsBase
This reverts commit b6dacb882f513a58489cf7cb9022b4ae533edc2e. 1. Update remaining usage of createTaskFragmentWithParentTask 2. Remove remaining test cases for embedded Task. Bug: 234351413 Change-Id: Ibd72c994bc491a17bcccc4a9c89175d45677782f Test: pass existing
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java3
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java8
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/AppTransitionControllerTest.java45
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/AppTransitionTests.java45
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java8
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/LaunchParamsPersisterTests.java6
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java36
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/RootTaskTests.java2
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java4
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/RunningTasksTest.java2
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TaskDisplayAreaTests.java2
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java14
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TaskLaunchParamsModifierTests.java2
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TaskTests.java20
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java16
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java64
16 files changed, 88 insertions, 189 deletions
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
index 042d21b3d6f5..1ab7d7e0c81b 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
@@ -2958,8 +2958,7 @@ public class ActivityRecordTests extends WindowTestsBase {
removeGlobalMinSizeRestriction();
final Task task = new TaskBuilder(mSupervisor).setCreateParentTask(true).build();
final Task rootTask = task.getRootTask();
- final TaskFragment taskFragment = createTaskFragmentWithParentTask(task,
- false /* createEmbeddedTask */);
+ final TaskFragment taskFragment = createTaskFragmentWithActivity(task);
final ActivityRecord activity = taskFragment.getTopNonFinishingActivity();
final Rect stackBounds = new Rect(0, 0, 1000, 600);
final Rect taskBounds = new Rect(100, 400, 600, 800);
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
index fc1989e84ac5..0743ef471d81 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
@@ -505,12 +505,12 @@ public class ActivityStarterTests extends WindowTestsBase {
// The fullscreen windowing mode activity will be moved to split-secondary by
// TestSplitOrganizer when a split-primary task appears.
final ActivityRecord splitPrimaryActivity = new TaskBuilder(mSupervisor)
- .setParentTaskFragment(splitOrg.mPrimary)
+ .setParentTask(splitOrg.mPrimary)
.setCreateActivity(true)
.build()
.getTopMostActivity();
final ActivityRecord splitSecondActivity = new TaskBuilder(mSupervisor)
- .setParentTaskFragment(splitOrg.mSecondary)
+ .setParentTask(splitOrg.mSecondary)
.setCreateActivity(true)
.build()
.getTopMostActivity();
@@ -1055,7 +1055,7 @@ public class ActivityStarterTests extends WindowTestsBase {
// Create another activity on top of the secondary display.
final Task topStack = secondaryTaskContainer.createRootTask(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_STANDARD, true /* onTop */);
- final Task topTask = new TaskBuilder(mSupervisor).setParentTaskFragment(topStack).build();
+ final Task topTask = new TaskBuilder(mSupervisor).setParentTask(topStack).build();
new ActivityBuilder(mAtm).setTask(topTask).build();
doReturn(mActivityMetricsLogger).when(mSupervisor).getActivityMetricsLogger();
@@ -1251,7 +1251,7 @@ public class ActivityStarterTests extends WindowTestsBase {
final ActivityStarter starter = prepareStarter(0 /* flags */);
starter.mStartActivity = new ActivityBuilder(mAtm).build();
final Task task = new TaskBuilder(mAtm.mTaskSupervisor)
- .setParentTaskFragment(createTask(mDisplayContent, WINDOWING_MODE_FULLSCREEN,
+ .setParentTask(createTask(mDisplayContent, WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_STANDARD))
.setUserId(10)
.build();
diff --git a/services/tests/wmtests/src/com/android/server/wm/AppTransitionControllerTest.java b/services/tests/wmtests/src/com/android/server/wm/AppTransitionControllerTest.java
index 43e79f9cbb15..fb94147c5e49 100644
--- a/services/tests/wmtests/src/com/android/server/wm/AppTransitionControllerTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/AppTransitionControllerTest.java
@@ -593,7 +593,7 @@ public class AppTransitionControllerTest extends WindowTestsBase {
final Task singleTopRoot = createTask(mDisplayContent);
final TaskBuilder builder = new TaskBuilder(mSupervisor)
.setWindowingMode(WINDOWING_MODE_MULTI_WINDOW)
- .setParentTaskFragment(singleTopRoot)
+ .setParentTask(singleTopRoot)
.setCreatedByOrganizer(true);
final Task splitRoot1 = builder.build();
final Task splitRoot2 = builder.build();
@@ -622,45 +622,12 @@ public class AppTransitionControllerTest extends WindowTestsBase {
// [DefaultTDA] - [Task] -+- [TaskFragment1] - [ActivityRecord1] (opening, invisible)
// +- [TaskFragment2] - [ActivityRecord2] (closing, visible)
final Task parentTask = createTask(mDisplayContent);
- final TaskFragment taskFragment1 = createTaskFragmentWithParentTask(parentTask,
- false /* createEmbeddedTask */);
+ final TaskFragment taskFragment1 = createTaskFragmentWithActivity(parentTask);
final ActivityRecord activity1 = taskFragment1.getTopMostActivity();
activity1.setVisible(false);
activity1.mVisibleRequested = true;
- final TaskFragment taskFragment2 = createTaskFragmentWithParentTask(parentTask,
- false /* createEmbeddedTask */);
- final ActivityRecord activity2 = taskFragment2.getTopMostActivity();
- activity2.setVisible(true);
- activity2.mVisibleRequested = false;
-
- final ArraySet<ActivityRecord> opening = new ArraySet<>();
- opening.add(activity1);
- final ArraySet<ActivityRecord> closing = new ArraySet<>();
- closing.add(activity2);
-
- // Promote animation targets up to TaskFragment level, not beyond.
- assertEquals(new ArraySet<>(new WindowContainer[]{taskFragment1}),
- AppTransitionController.getAnimationTargets(
- opening, closing, true /* visible */));
- assertEquals(new ArraySet<>(new WindowContainer[]{taskFragment2}),
- AppTransitionController.getAnimationTargets(
- opening, closing, false /* visible */));
- }
-
- @Test
- public void testGetAnimationTargets_openingClosingTaskFragmentWithEmbeddedTask() {
- // [DefaultTDA] - [Task] -+- [TaskFragment1] - [ActivityRecord1] (opening, invisible)
- // +- [TaskFragment2] - [ActivityRecord2] (closing, visible)
- final Task parentTask = createTask(mDisplayContent);
- final TaskFragment taskFragment1 = createTaskFragmentWithParentTask(parentTask,
- true /* createEmbeddedTask */);
- final ActivityRecord activity1 = taskFragment1.getTopMostActivity();
- activity1.setVisible(false);
- activity1.mVisibleRequested = true;
-
- final TaskFragment taskFragment2 = createTaskFragmentWithParentTask(parentTask,
- true /* createEmbeddedTask */);
+ final TaskFragment taskFragment2 = createTaskFragmentWithActivity(parentTask);
final ActivityRecord activity2 = taskFragment2.getTopMostActivity();
activity2.setVisible(true);
activity2.mVisibleRequested = false;
@@ -684,8 +651,7 @@ public class AppTransitionControllerTest extends WindowTestsBase {
// [DefaultTDA] -+- [Task1] - [TaskFragment1] - [ActivityRecord1] (opening, invisible)
// +- [Task2] - [ActivityRecord2] (closing, visible)
final Task task1 = createTask(mDisplayContent);
- final TaskFragment taskFragment1 = createTaskFragmentWithParentTask(task1,
- false /* createEmbeddedTask */);
+ final TaskFragment taskFragment1 = createTaskFragmentWithActivity(task1);
final ActivityRecord activity1 = taskFragment1.getTopMostActivity();
activity1.setVisible(false);
activity1.mVisibleRequested = true;
@@ -714,8 +680,7 @@ public class AppTransitionControllerTest extends WindowTestsBase {
// [DefaultTDA] -+- [Task1] - [TaskFragment1] - [ActivityRecord1] (closing, visible)
// +- [Task2] - [ActivityRecord2] (opening, invisible)
final Task task1 = createTask(mDisplayContent);
- final TaskFragment taskFragment1 = createTaskFragmentWithParentTask(task1,
- false /* createEmbeddedTask */);
+ final TaskFragment taskFragment1 = createTaskFragmentWithActivity(task1);
final ActivityRecord activity1 = taskFragment1.getTopMostActivity();
activity1.setVisible(true);
activity1.mVisibleRequested = false;
diff --git a/services/tests/wmtests/src/com/android/server/wm/AppTransitionTests.java b/services/tests/wmtests/src/com/android/server/wm/AppTransitionTests.java
index 8cfe503d61d7..437eeb1093ca 100644
--- a/services/tests/wmtests/src/com/android/server/wm/AppTransitionTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/AppTransitionTests.java
@@ -228,23 +228,7 @@ public class AppTransitionTests extends WindowTestsBase {
@Test
public void testTaskFragmentOpeningTransition() {
- final ActivityRecord activity = createHierarchyForTaskFragmentTest(
- false /* createEmbeddedTask */);
- activity.setVisible(false);
-
- mDisplayContent.prepareAppTransition(TRANSIT_OPEN);
- mDisplayContent.mOpeningApps.add(activity);
- assertEquals(TRANSIT_OLD_TASK_FRAGMENT_OPEN,
- AppTransitionController.getTransitCompatType(mDisplayContent.mAppTransition,
- mDisplayContent.mOpeningApps, mDisplayContent.mClosingApps,
- mDisplayContent.mChangingContainers, null /* wallpaperTarget */,
- null /* oldWallpaper */, false /* skipAppTransitionAnimation */));
- }
-
- @Test
- public void testEmbeddedTaskOpeningTransition() {
- final ActivityRecord activity = createHierarchyForTaskFragmentTest(
- true /* createEmbeddedTask */);
+ final ActivityRecord activity = createHierarchyForTaskFragmentTest();
activity.setVisible(false);
mDisplayContent.prepareAppTransition(TRANSIT_OPEN);
@@ -258,23 +242,7 @@ public class AppTransitionTests extends WindowTestsBase {
@Test
public void testTaskFragmentClosingTransition() {
- final ActivityRecord activity = createHierarchyForTaskFragmentTest(
- false /* createEmbeddedTask */);
- activity.setVisible(true);
-
- mDisplayContent.prepareAppTransition(TRANSIT_CLOSE);
- mDisplayContent.mClosingApps.add(activity);
- assertEquals(TRANSIT_OLD_TASK_FRAGMENT_CLOSE,
- AppTransitionController.getTransitCompatType(mDisplayContent.mAppTransition,
- mDisplayContent.mOpeningApps, mDisplayContent.mClosingApps,
- mDisplayContent.mChangingContainers, null /* wallpaperTarget */,
- null /* oldWallpaper */, false /* skipAppTransitionAnimation */));
- }
-
- @Test
- public void testEmbeddedTaskClosingTransition() {
- final ActivityRecord activity = createHierarchyForTaskFragmentTest(
- true /* createEmbeddedTask */);
+ final ActivityRecord activity = createHierarchyForTaskFragmentTest();
activity.setVisible(true);
mDisplayContent.prepareAppTransition(TRANSIT_CLOSE);
@@ -292,19 +260,16 @@ public class AppTransitionTests extends WindowTestsBase {
* {@link AppTransitionController#getAnimationTargets(ArraySet, ArraySet, boolean) the animation
* target} to promote to Task or above.
*
- * @param createEmbeddedTask {@code true} to create embedded Task for verified TaskFragment
* @return The Activity to be put in either opening or closing Activity
*/
- private ActivityRecord createHierarchyForTaskFragmentTest(boolean createEmbeddedTask) {
+ private ActivityRecord createHierarchyForTaskFragmentTest() {
final Task parentTask = createTask(mDisplayContent);
- final TaskFragment bottomTaskFragment = createTaskFragmentWithParentTask(parentTask,
- false /* createEmbeddedTask */);
+ final TaskFragment bottomTaskFragment = createTaskFragmentWithActivity(parentTask);
final ActivityRecord bottomActivity = bottomTaskFragment.getTopMostActivity();
bottomActivity.setOccludesParent(true);
bottomActivity.setVisible(true);
- final TaskFragment verifiedTaskFragment = createTaskFragmentWithParentTask(parentTask,
- createEmbeddedTask);
+ final TaskFragment verifiedTaskFragment = createTaskFragmentWithActivity(parentTask);
final ActivityRecord activity = verifiedTaskFragment.getTopMostActivity();
activity.setOccludesParent(true);
diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
index 37ab9a00737f..d1511880451e 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
@@ -2693,10 +2693,10 @@ public class DisplayContentTests extends WindowTestsBase {
ACTIVITY_TYPE_STANDARD, ON_TOP);
final Task rootTask4 = taskDisplayArea.createRootTask(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_STANDARD, ON_TOP);
- final Task task1 = new TaskBuilder(mSupervisor).setParentTaskFragment(rootTask1).build();
- final Task task2 = new TaskBuilder(mSupervisor).setParentTaskFragment(rootTask2).build();
- final Task task3 = new TaskBuilder(mSupervisor).setParentTaskFragment(rootTask3).build();
- final Task task4 = new TaskBuilder(mSupervisor).setParentTaskFragment(rootTask4).build();
+ final Task task1 = new TaskBuilder(mSupervisor).setParentTask(rootTask1).build();
+ final Task task2 = new TaskBuilder(mSupervisor).setParentTask(rootTask2).build();
+ final Task task3 = new TaskBuilder(mSupervisor).setParentTask(rootTask3).build();
+ final Task task4 = new TaskBuilder(mSupervisor).setParentTask(rootTask4).build();
// Reordering root tasks while removing root tasks.
doAnswer(invocation -> {
diff --git a/services/tests/wmtests/src/com/android/server/wm/LaunchParamsPersisterTests.java b/services/tests/wmtests/src/com/android/server/wm/LaunchParamsPersisterTests.java
index 8a6db2c62a10..7cb7c79d63a0 100644
--- a/services/tests/wmtests/src/com/android/server/wm/LaunchParamsPersisterTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/LaunchParamsPersisterTests.java
@@ -117,7 +117,7 @@ public class LaunchParamsPersisterTests extends WindowTestsBase {
Task rootTask = mTestDisplay.getDefaultTaskDisplayArea()
.createRootTask(TEST_WINDOWING_MODE, ACTIVITY_TYPE_STANDARD, /* onTop */ true);
mTestTask = new TaskBuilder(mSupervisor).setComponent(TEST_COMPONENT)
- .setParentTaskFragment(rootTask).build();
+ .setParentTask(rootTask).build();
mTestTask.mUserId = TEST_USER_ID;
mTestTask.mLastNonFullscreenBounds = TEST_BOUNDS;
mTestTask.setHasBeenVisible(true);
@@ -353,7 +353,7 @@ public class LaunchParamsPersisterTests extends WindowTestsBase {
final Task anotherTaskOfTheSameUser = new TaskBuilder(mSupervisor)
.setComponent(ALTERNATIVE_COMPONENT)
.setUserId(TEST_USER_ID)
- .setParentTaskFragment(stack)
+ .setParentTask(stack)
.build();
anotherTaskOfTheSameUser.setWindowingMode(WINDOWING_MODE_FREEFORM);
anotherTaskOfTheSameUser.setBounds(200, 300, 400, 500);
@@ -365,7 +365,7 @@ public class LaunchParamsPersisterTests extends WindowTestsBase {
final Task anotherTaskOfDifferentUser = new TaskBuilder(mSupervisor)
.setComponent(TEST_COMPONENT)
.setUserId(ALTERNATIVE_USER_ID)
- .setParentTaskFragment(stack)
+ .setParentTask(stack)
.build();
anotherTaskOfDifferentUser.setWindowingMode(WINDOWING_MODE_FREEFORM);
anotherTaskOfDifferentUser.setBounds(300, 400, 500, 600);
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 5def7039f987..ac2df62d6305 100644
--- a/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java
@@ -332,7 +332,7 @@ public class RecentTasksTest extends WindowTestsBase {
// other task
Task task1 = createTaskBuilder(".Task1")
.setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK)
- .setParentTaskFragment(mTaskContainer.getRootHomeTask()).build();
+ .setParentTask(mTaskContainer.getRootHomeTask()).build();
Task task2 = createTaskBuilder(".Task1")
.setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK)
.build();
@@ -472,8 +472,8 @@ public class RecentTasksTest extends WindowTestsBase {
final Task root = createTaskBuilder(".CreatedByOrganizerRoot").build();
root.mCreatedByOrganizer = true;
// Add organized and non-organized child.
- final Task child1 = createTaskBuilder(".Task1").setParentTaskFragment(root).build();
- final Task child2 = createTaskBuilder(".Task2").setParentTaskFragment(root).build();
+ final Task child1 = createTaskBuilder(".Task1").setParentTask(root).build();
+ final Task child2 = createTaskBuilder(".Task2").setParentTask(root).build();
doReturn(true).when(child1).isOrganized();
doReturn(false).when(child2).isOrganized();
mRecentTasks.add(root);
@@ -510,7 +510,7 @@ public class RecentTasksTest extends WindowTestsBase {
mRecentTasks.add(task1);
// Go home to trigger the removal of untracked tasks.
mRecentTasks.add(createTaskBuilder(".Home")
- .setParentTaskFragment(mTaskContainer.getRootHomeTask())
+ .setParentTask(mTaskContainer.getRootHomeTask())
.build());
triggerIdleToTrim();
@@ -677,7 +677,7 @@ public class RecentTasksTest extends WindowTestsBase {
public void testVisibleTasks_excludedFromRecents_firstTaskNotVisible() {
// Create some set of tasks, some of which are visible and some are not
Task homeTask = createTaskBuilder("com.android.pkg1", ".HomeTask")
- .setParentTaskFragment(mTaskContainer.getRootHomeTask())
+ .setParentTask(mTaskContainer.getRootHomeTask())
.build();
homeTask.mUserSetupComplete = true;
mRecentTasks.add(homeTask);
@@ -712,7 +712,7 @@ public class RecentTasksTest extends WindowTestsBase {
t1.mUserSetupComplete = true;
mRecentTasks.add(t1);
Task homeTask = createTaskBuilder("com.android.pkg1", ".HomeTask")
- .setParentTaskFragment(mTaskContainer.getRootHomeTask())
+ .setParentTask(mTaskContainer.getRootHomeTask())
.build();
homeTask.mUserSetupComplete = true;
mRecentTasks.add(homeTask);
@@ -976,10 +976,10 @@ public class RecentTasksTest extends WindowTestsBase {
// Add a number of tasks (beyond the max) but ensure that nothing is trimmed because all
// the tasks belong in stacks above the home stack
- mRecentTasks.add(createTaskBuilder(".HomeTask1").setParentTaskFragment(homeStack).build());
- mRecentTasks.add(createTaskBuilder(".Task1").setParentTaskFragment(aboveHomeStack).build());
- mRecentTasks.add(createTaskBuilder(".Task2").setParentTaskFragment(aboveHomeStack).build());
- mRecentTasks.add(createTaskBuilder(".Task3").setParentTaskFragment(aboveHomeStack).build());
+ mRecentTasks.add(createTaskBuilder(".HomeTask1").setParentTask(homeStack).build());
+ mRecentTasks.add(createTaskBuilder(".Task1").setParentTask(aboveHomeStack).build());
+ mRecentTasks.add(createTaskBuilder(".Task2").setParentTask(aboveHomeStack).build());
+ mRecentTasks.add(createTaskBuilder(".Task3").setParentTask(aboveHomeStack).build());
triggerTrimAndAssertNoTasksTrimmed();
}
@@ -997,11 +997,11 @@ public class RecentTasksTest extends WindowTestsBase {
// Add a number of tasks (beyond the max) but ensure that only the task in the stack behind
// the home stack is trimmed once a new task is added
final Task behindHomeTask = createTaskBuilder(".Task1")
- .setParentTaskFragment(behindHomeStack)
+ .setParentTask(behindHomeStack)
.build();
mRecentTasks.add(behindHomeTask);
- mRecentTasks.add(createTaskBuilder(".HomeTask1").setParentTaskFragment(homeStack).build());
- mRecentTasks.add(createTaskBuilder(".Task2").setParentTaskFragment(aboveHomeStack).build());
+ mRecentTasks.add(createTaskBuilder(".HomeTask1").setParentTask(homeStack).build());
+ mRecentTasks.add(createTaskBuilder(".Task2").setParentTask(aboveHomeStack).build());
triggerTrimAndAssertTrimmed(behindHomeTask);
}
@@ -1017,12 +1017,12 @@ public class RecentTasksTest extends WindowTestsBase {
// Add a number of tasks (beyond the max) on each display, ensure that the tasks are not
// removed
- mRecentTasks.add(createTaskBuilder(".HomeTask1").setParentTaskFragment(homeTask).build());
- mRecentTasks.add(createTaskBuilder(".Task1").setParentTaskFragment(otherDisplayRootTask)
+ mRecentTasks.add(createTaskBuilder(".HomeTask1").setParentTask(homeTask).build());
+ mRecentTasks.add(createTaskBuilder(".Task1").setParentTask(otherDisplayRootTask)
.build());
- mRecentTasks.add(createTaskBuilder(".Task2").setParentTaskFragment(otherDisplayRootTask)
+ mRecentTasks.add(createTaskBuilder(".Task2").setParentTask(otherDisplayRootTask)
.build());
- mRecentTasks.add(createTaskBuilder(".HomeTask2").setParentTaskFragment(homeTask).build());
+ mRecentTasks.add(createTaskBuilder(".HomeTask2").setParentTask(homeTask).build());
triggerTrimAndAssertNoTasksTrimmed();
}
@@ -1052,7 +1052,7 @@ public class RecentTasksTest extends WindowTestsBase {
Task t1 = createTaskBuilder("com.android.pkg1", ".Task1").build();
mRecentTasks.add(t1);
mRecentTasks.add(createTaskBuilder("com.android.pkg1", ".HomeTask")
- .setParentTaskFragment(mTaskContainer.getRootHomeTask()).build());
+ .setParentTask(mTaskContainer.getRootHomeTask()).build());
Task t2 = createTaskBuilder("com.android.pkg2", ".Task2").build();
mRecentTasks.add(t2);
mRecentTasks.add(createTaskBuilder("com.android.pkg1", ".PipTask")
diff --git a/services/tests/wmtests/src/com/android/server/wm/RootTaskTests.java b/services/tests/wmtests/src/com/android/server/wm/RootTaskTests.java
index b46e90da3944..881cc5f94f44 100644
--- a/services/tests/wmtests/src/com/android/server/wm/RootTaskTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/RootTaskTests.java
@@ -422,7 +422,7 @@ public class RootTaskTests extends WindowTestsBase {
final ComponentName alias = new ComponentName(DEFAULT_COMPONENT_PACKAGE_NAME,
aliasActivity);
final Task parentTask = new TaskBuilder(mSupervisor).build();
- final Task task = new TaskBuilder(mSupervisor).setParentTaskFragment(parentTask).build();
+ final Task task = new TaskBuilder(mSupervisor).setParentTask(parentTask).build();
task.origActivity = alias;
task.realActivity = target;
new ActivityBuilder(mAtm).setComponent(target).setTask(task).setTargetActivity(
diff --git a/services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java b/services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java
index e0e1d73657cb..f84865bce0fa 100644
--- a/services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java
@@ -172,7 +172,7 @@ public class RootWindowContainerTests extends WindowTestsBase {
@Test
public void testTaskLayerRank() {
final Task rootTask = new TaskBuilder(mSupervisor).build();
- final Task task1 = new TaskBuilder(mSupervisor).setParentTaskFragment(rootTask).build();
+ final Task task1 = new TaskBuilder(mSupervisor).setParentTask(rootTask).build();
final ActivityRecord activity1 = new ActivityBuilder(mAtm).setTask(task1).build();
activity1.mVisibleRequested = true;
mWm.mRoot.rankTaskLayers();
@@ -645,7 +645,7 @@ public class RootWindowContainerTests extends WindowTestsBase {
final TaskDisplayArea taskDisplayArea = mRootWindowContainer.getDefaultTaskDisplayArea();
final Task targetRootTask = taskDisplayArea.createRootTask(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_STANDARD, false /* onTop */);
- final Task targetTask = new TaskBuilder(mSupervisor).setParentTaskFragment(targetRootTask)
+ final Task targetTask = new TaskBuilder(mSupervisor).setParentTask(targetRootTask)
.build();
// Create Recents on secondary display.
diff --git a/services/tests/wmtests/src/com/android/server/wm/RunningTasksTest.java b/services/tests/wmtests/src/com/android/server/wm/RunningTasksTest.java
index eab2e156e9aa..9aa747a9297f 100644
--- a/services/tests/wmtests/src/com/android/server/wm/RunningTasksTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/RunningTasksTest.java
@@ -172,7 +172,7 @@ public class RunningTasksTest extends WindowTestsBase {
final Task task = new TaskBuilder(mAtm.mTaskSupervisor)
.setComponent(new ComponentName(mContext.getPackageName(), className))
.setTaskId(taskId)
- .setParentTaskFragment(stack)
+ .setParentTask(stack)
.build();
final ActivityRecord activity = new ActivityBuilder(mAtm)
.setTask(task)
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskDisplayAreaTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskDisplayAreaTests.java
index 7f09606d1c3a..d5fb1a856e31 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskDisplayAreaTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskDisplayAreaTests.java
@@ -614,7 +614,7 @@ public class TaskDisplayAreaTests extends WindowTestsBase {
final Task pinnedRootTask = mRootWindowContainer.getDefaultTaskDisplayArea()
.createRootTask(WINDOWING_MODE_PINNED, ACTIVITY_TYPE_STANDARD, ON_TOP);
final Task pinnedTask = new TaskBuilder(mAtm.mTaskSupervisor)
- .setParentTaskFragment(pinnedRootTask).build();
+ .setParentTask(pinnedRootTask).build();
new ActivityBuilder(mAtm).setActivityFlags(FLAG_ALWAYS_FOCUSABLE)
.setTask(pinnedTask).build();
pinnedRootTask.moveToFront("movePinnedRootTaskToFront");
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java b/services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java
index 97e5755fec02..4e796c55dda2 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java
@@ -219,10 +219,8 @@ public class TaskFragmentTest extends WindowTestsBase {
final ActivityRecord bottomActivity = createActivityRecord(bottomTask);
final Task topTask = createTask(mDisplayContent);
// First create primary TF, and then secondary TF, so that the secondary will be on the top.
- final TaskFragment primaryTf = createTaskFragmentWithParentTask(
- topTask, false /* createEmbeddedTask */);
- final TaskFragment secondaryTf = createTaskFragmentWithParentTask(
- topTask, false /* createEmbeddedTask */);
+ final TaskFragment primaryTf = createTaskFragmentWithActivity(topTask);
+ final TaskFragment secondaryTf = createTaskFragmentWithActivity(topTask);
final ActivityRecord primaryActivity = primaryTf.getTopMostActivity();
final ActivityRecord secondaryActivity = secondaryTf.getTopMostActivity();
doReturn(true).when(primaryActivity).supportsPictureInPicture();
@@ -386,7 +384,7 @@ public class TaskFragmentTest extends WindowTestsBase {
final Task rootTask = createTask(mDisplayContent, WINDOWING_MODE_MULTI_WINDOW,
ACTIVITY_TYPE_STANDARD);
final Task leafTask0 = new TaskBuilder(mSupervisor)
- .setParentTaskFragment(rootTask)
+ .setParentTask(rootTask)
.build();
final TaskFragment organizedTf = new TaskFragmentBuilder(mAtm)
.createActivityCount(2)
@@ -422,7 +420,7 @@ public class TaskFragmentTest extends WindowTestsBase {
// There is an activity in a different leaf task on top of activity0 and activity1.
// None of the two has overlay over untrusted mode embedded because it is not the same Task.
final Task leafTask1 = new TaskBuilder(mSupervisor)
- .setParentTaskFragment(rootTask)
+ .setParentTask(rootTask)
.setOnTop(true)
.setCreateActivity(true)
.build();
@@ -552,8 +550,8 @@ public class TaskFragmentTest extends WindowTestsBase {
@Test
public void testIsVisibleWithAdjacent_reportOrientationUnspecified() {
final Task task = createTask(mDisplayContent);
- final TaskFragment tf0 = createTaskFragmentWithParentTask(task);
- final TaskFragment tf1 = createTaskFragmentWithParentTask(task);
+ final TaskFragment tf0 = createTaskFragmentWithActivity(task);
+ final TaskFragment tf1 = createTaskFragmentWithActivity(task);
tf0.setAdjacentTaskFragment(tf1);
tf0.setWindowingMode(WINDOWING_MODE_MULTI_WINDOW);
tf1.setWindowingMode(WINDOWING_MODE_MULTI_WINDOW);
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskLaunchParamsModifierTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskLaunchParamsModifierTests.java
index 72f29d3b2e6a..a4cc09a205f6 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskLaunchParamsModifierTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskLaunchParamsModifierTests.java
@@ -1982,7 +1982,7 @@ public class TaskLaunchParamsModifierTests extends WindowTestsBase {
final Task rootTask = display.getDefaultTaskDisplayArea()
.createRootTask(display.getWindowingMode(), ACTIVITY_TYPE_STANDARD, true);
rootTask.setWindowingMode(WINDOWING_MODE_FREEFORM);
- final Task task = new TaskBuilder(mSupervisor).setParentTaskFragment(rootTask).build();
+ final Task task = new TaskBuilder(mSupervisor).setParentTask(rootTask).build();
// Just work around the unnecessary adjustments for bounds.
task.getWindowConfiguration().setBounds(bounds);
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
index d52c34bdc9e1..74d78842c7ac 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
@@ -149,8 +149,8 @@ public class TaskTests extends WindowTestsBase {
public void testRemoveContainer_multipleNestedTasks() {
final Task rootTask = createTask(mDisplayContent);
rootTask.mCreatedByOrganizer = true;
- final Task task1 = new TaskBuilder(mSupervisor).setParentTaskFragment(rootTask).build();
- final Task task2 = new TaskBuilder(mSupervisor).setParentTaskFragment(rootTask).build();
+ final Task task1 = new TaskBuilder(mSupervisor).setParentTask(rootTask).build();
+ final Task task2 = new TaskBuilder(mSupervisor).setParentTask(rootTask).build();
final ActivityRecord activity1 = createActivityRecord(task1);
final ActivityRecord activity2 = createActivityRecord(task2);
activity1.setVisible(false);
@@ -498,7 +498,7 @@ public class TaskTests extends WindowTestsBase {
TaskDisplayArea taskDisplayArea = mAtm.mRootWindowContainer.getDefaultTaskDisplayArea();
Task rootTask = taskDisplayArea.createRootTask(WINDOWING_MODE_FREEFORM,
ACTIVITY_TYPE_STANDARD, true /* onTop */);
- Task task = new TaskBuilder(mSupervisor).setParentTaskFragment(rootTask).build();
+ Task task = new TaskBuilder(mSupervisor).setParentTask(rootTask).build();
final Configuration parentConfig = rootTask.getConfiguration();
parentConfig.windowConfiguration.setBounds(parentBounds);
parentConfig.densityDpi = DisplayMetrics.DENSITY_DEFAULT;
@@ -800,7 +800,7 @@ public class TaskTests extends WindowTestsBase {
DisplayInfo displayInfo = new DisplayInfo();
mAtm.mContext.getDisplay().getDisplayInfo(displayInfo);
final int displayHeight = displayInfo.logicalHeight;
- final Task task = new TaskBuilder(mSupervisor).setParentTaskFragment(rootTask).build();
+ final Task task = new TaskBuilder(mSupervisor).setParentTask(rootTask).build();
final Configuration inOutConfig = new Configuration();
final Configuration parentConfig = new Configuration();
final int longSide = 1200;
@@ -1456,10 +1456,8 @@ public class TaskTests extends WindowTestsBase {
@Test
public void testResumeTask_doNotResumeTaskFragmentBehindTranslucent() {
final Task task = createTask(mDisplayContent);
- final TaskFragment tfBehind = createTaskFragmentWithParentTask(
- task, false /* createEmbeddedTask */);
- final TaskFragment tfFront = createTaskFragmentWithParentTask(
- task, false /* createEmbeddedTask */);
+ final TaskFragment tfBehind = createTaskFragmentWithActivity(task);
+ final TaskFragment tfFront = createTaskFragmentWithActivity(task);
spyOn(tfFront);
doReturn(true).when(tfFront).isTranslucent(any());
@@ -1479,8 +1477,8 @@ public class TaskTests extends WindowTestsBase {
@Test
public void testGetTaskFragment() {
final Task parentTask = createTask(mDisplayContent);
- final TaskFragment tf0 = createTaskFragmentWithParentTask(parentTask);
- final TaskFragment tf1 = createTaskFragmentWithParentTask(parentTask);
+ final TaskFragment tf0 = createTaskFragmentWithActivity(parentTask);
+ final TaskFragment tf1 = createTaskFragmentWithActivity(parentTask);
assertNull("Could not find it because there's no organized TaskFragment",
parentTask.getTaskFragment(TaskFragment::isOrganizedTaskFragment));
@@ -1522,7 +1520,7 @@ public class TaskTests extends WindowTestsBase {
TaskDisplayArea taskDisplayArea = mAtm.mRootWindowContainer.getDefaultTaskDisplayArea();
Task rootTask = taskDisplayArea.createRootTask(windowingMode, ACTIVITY_TYPE_STANDARD,
true /* onTop */);
- Task task = new TaskBuilder(mSupervisor).setParentTaskFragment(rootTask).build();
+ Task task = new TaskBuilder(mSupervisor).setParentTask(rootTask).build();
final Configuration parentConfig = rootTask.getConfiguration();
parentConfig.windowConfiguration.setAppBounds(parentBounds);
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java
index c8ea70c5d650..50fcafca5273 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java
@@ -1150,8 +1150,8 @@ public class WindowContainerTests extends WindowTestsBase {
@Test
public void testStartChangeTransitionWhenPreviousIsNotFinished() {
- final WindowContainer container = createTaskFragmentWithParentTask(
- createTask(mDisplayContent), false);
+ final WindowContainer container = createTaskFragmentWithActivity(
+ createTask(mDisplayContent));
container.mSurfaceControl = mock(SurfaceControl.class);
final SurfaceAnimator surfaceAnimator = container.mSurfaceAnimator;
final SurfaceFreezer surfaceFreezer = container.mSurfaceFreezer;
@@ -1214,8 +1214,8 @@ public class WindowContainerTests extends WindowTestsBase {
@Test
public void testUnfreezeWindow_removeWindowFromChanging() {
- final WindowContainer container = createTaskFragmentWithParentTask(
- createTask(mDisplayContent), false);
+ final WindowContainer container = createTaskFragmentWithActivity(
+ createTask(mDisplayContent));
mockSurfaceFreezerSnapshot(container.mSurfaceFreezer);
final SurfaceControl.Transaction t = mock(SurfaceControl.Transaction.class);
@@ -1230,8 +1230,8 @@ public class WindowContainerTests extends WindowTestsBase {
@Test
public void testFailToTaskSnapshot_unfreezeWindow() {
- final WindowContainer container = createTaskFragmentWithParentTask(
- createTask(mDisplayContent), false);
+ final WindowContainer container = createTaskFragmentWithActivity(
+ createTask(mDisplayContent));
final SurfaceControl.Transaction t = mock(SurfaceControl.Transaction.class);
spyOn(container.mSurfaceFreezer);
@@ -1244,8 +1244,8 @@ public class WindowContainerTests extends WindowTestsBase {
@Test
public void testRemoveUnstartedFreezeSurfaceWhenFreezeAgain() {
- final WindowContainer container = createTaskFragmentWithParentTask(
- createTask(mDisplayContent), false);
+ final WindowContainer container = createTaskFragmentWithActivity(
+ createTask(mDisplayContent));
container.mSurfaceControl = mock(SurfaceControl.class);
final SurfaceFreezer surfaceFreezer = container.mSurfaceFreezer;
mockSurfaceFreezerSnapshot(surfaceFreezer);
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java b/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java
index ab042d15963b..1348770bd807 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java
@@ -655,7 +655,7 @@ class WindowTestsBase extends SystemServiceTestsBase {
Task createTaskInRootTask(Task rootTask, int userId) {
final Task task = new TaskBuilder(rootTask.mTaskSupervisor)
.setUserId(userId)
- .setParentTaskFragment(rootTask)
+ .setParentTask(rootTask)
.build();
return task;
}
@@ -741,28 +741,18 @@ class WindowTestsBase extends SystemServiceTestsBase {
activity.mVisibleRequested = true;
}
- static TaskFragment createTaskFragmentWithParentTask(@NonNull Task parentTask) {
- return createTaskFragmentWithParentTask(parentTask, false /* createEmbeddedTask */);
- }
-
/**
- * Creates a {@link TaskFragment} and attach it to the {@code parentTask}.
+ * Creates a {@link TaskFragment} with {@link ActivityRecord} and attach it to the
+ * {@code parentTask}.
*
* @param parentTask the {@link Task} this TaskFragment is going to be attached
- * @param createEmbeddedTask Sets to {@code true} to create an embedded Task for this
- * TaskFragment. Otherwise, create a {@link ActivityRecord}.
* @return the created TaskFragment
*/
- static TaskFragment createTaskFragmentWithParentTask(@NonNull Task parentTask,
- boolean createEmbeddedTask) {
- final TaskFragmentBuilder builder = new TaskFragmentBuilder(parentTask.mAtmService)
- .setParentTask(parentTask);
- if (createEmbeddedTask) {
- builder.createEmbeddedTask();
- } else {
- builder.createActivityCount(1);
- }
- return builder.build();
+ static TaskFragment createTaskFragmentWithActivity(@NonNull Task parentTask) {
+ return new TaskFragmentBuilder(parentTask.mAtmService)
+ .setParentTask(parentTask)
+ .createActivityCount(1)
+ .build();
}
static TaskFragment createTaskFragmentWithEmbeddedActivity(@NonNull Task parentTask,
@@ -1218,7 +1208,7 @@ class WindowTestsBase extends SystemServiceTestsBase {
// Apply the root activity info and intent
.setActivityInfo(aInfo)
.setIntent(intent)
- .setParentTaskFragment(mParentTask).build();
+ .setParentTask(mParentTask).build();
} else if (mTask == null && mParentTask != null && DisplayContent.alwaysCreateRootTask(
mParentTask.getWindowingMode(), mParentTask.getActivityType())) {
// The parent task can be the task root.
@@ -1275,7 +1265,6 @@ class WindowTestsBase extends SystemServiceTestsBase {
private final ActivityTaskManagerService mAtm;
private Task mParentTask;
private boolean mCreateParentTask;
- private boolean mCreateEmbeddedTask;
private int mCreateActivityCount = 0;
@Nullable
private TaskFragmentOrganizer mOrganizer;
@@ -1296,12 +1285,6 @@ class WindowTestsBase extends SystemServiceTestsBase {
return this;
}
- /** Creates a child embedded Task and its Activity */
- TaskFragmentBuilder createEmbeddedTask() {
- mCreateEmbeddedTask = true;
- return this;
- }
-
TaskFragmentBuilder createActivityCount(int count) {
mCreateActivityCount = count;
return this;
@@ -1333,12 +1316,6 @@ class WindowTestsBase extends SystemServiceTestsBase {
if (mParentTask != null) {
mParentTask.addChild(taskFragment, POSITION_TOP);
}
- if (mCreateEmbeddedTask) {
- new TaskBuilder(mAtm.mTaskSupervisor)
- .setParentTaskFragment(taskFragment)
- .setCreateActivity(true)
- .build();
- }
while (mCreateActivityCount > 0) {
final ActivityRecord activity = new ActivityBuilder(mAtm).build();
taskFragment.addChild(activity);
@@ -1377,7 +1354,7 @@ class WindowTestsBase extends SystemServiceTestsBase {
private IVoiceInteractionSession mVoiceSession;
private boolean mCreateParentTask = false;
- private TaskFragment mParentTaskFragment;
+ private Task mParentTask;
private boolean mCreateActivity = false;
private boolean mCreatedByOrganizer = false;
@@ -1462,8 +1439,8 @@ class WindowTestsBase extends SystemServiceTestsBase {
return this;
}
- TaskBuilder setParentTaskFragment(TaskFragment parentTaskFragment) {
- mParentTaskFragment = parentTaskFragment;
+ TaskBuilder setParentTask(Task parentTask) {
+ mParentTask = parentTask;
return this;
}
@@ -1481,13 +1458,12 @@ class WindowTestsBase extends SystemServiceTestsBase {
SystemServicesTestRule.checkHoldsLock(mSupervisor.mService.mGlobalLock);
// Create parent task.
- if (mParentTaskFragment == null && mCreateParentTask) {
- mParentTaskFragment = mTaskDisplayArea.createRootTask(
+ if (mParentTask == null && mCreateParentTask) {
+ mParentTask = mTaskDisplayArea.createRootTask(
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */);
}
- if (mParentTaskFragment != null
- && !Mockito.mockingDetails(mParentTaskFragment).isSpy()) {
- spyOn(mParentTaskFragment);
+ if (mParentTask != null && !Mockito.mockingDetails(mParentTask).isSpy()) {
+ spyOn(mParentTask);
}
// Create task.
@@ -1515,15 +1491,13 @@ class WindowTestsBase extends SystemServiceTestsBase {
.setVoiceSession(mVoiceSession)
.setCreatedByOrganizer(mCreatedByOrganizer);
final Task task;
- if (mParentTaskFragment == null) {
+ if (mParentTask == null) {
task = builder.setActivityType(mActivityType)
.setParent(mTaskDisplayArea)
.build();
} else {
- task = builder.setParent(mParentTaskFragment).build();
- if (mParentTaskFragment.asTask() != null) {
- mParentTaskFragment.asTask().moveToFront("build-task");
- }
+ task = builder.setParent(mParentTask).build();
+ mParentTask.moveToFront("build-task");
}
spyOn(task);
task.mUserId = mUserId;