Use launchRootTask to determine parent of stack we getting
Also, have task org createRootTask create task directly vs. getting one
if it already exists.
Bug: 152619437
Test: They pass!
Change-Id: I2aa40ba79ae229eaeacef823ee9c89267d5028d8
diff --git a/services/core/java/com/android/server/wm/TaskDisplayArea.java b/services/core/java/com/android/server/wm/TaskDisplayArea.java
index 9356ec2..77ef011 100644
--- a/services/core/java/com/android/server/wm/TaskDisplayArea.java
+++ b/services/core/java/com/android/server/wm/TaskDisplayArea.java
@@ -732,11 +732,11 @@
/**
* Returns an existing stack compatible with the windowing mode and activity type or creates one
* if a compatible stack doesn't exist.
- * @see #getOrCreateStack(int, int, boolean, Intent, Task, boolean)
+ * @see #getOrCreateStack(int, int, boolean, Intent, Task)
*/
ActivityStack getOrCreateStack(int windowingMode, int activityType, boolean onTop) {
return getOrCreateStack(windowingMode, activityType, onTop, null /* intent */,
- null /* candidateTask */, false /* createdByOrganizer */);
+ null /* candidateTask */);
}
/**
@@ -748,7 +748,7 @@
* @see #createStack(int, int, boolean)
*/
ActivityStack getOrCreateStack(int windowingMode, int activityType, boolean onTop,
- Intent intent, Task candidateTask, boolean createdByOrganizer) {
+ Intent intent, Task candidateTask) {
if (!alwaysCreateStack(windowingMode, activityType)) {
ActivityStack stack = getStack(windowingMode, activityType);
if (stack != null) {
@@ -757,13 +757,13 @@
} else if (candidateTask != null) {
final ActivityStack stack = (ActivityStack) candidateTask;
final int position = onTop ? POSITION_TOP : POSITION_BOTTOM;
- if (isSplitScreenModeActivated()) {
- final Task splitRootSecondary = getTask(t -> t.mCreatedByOrganizer && t.isRootTask()
- && t.inSplitScreenSecondaryWindowingMode());
+ Task launchRootTask = updateLaunchRootTask(windowingMode);
+
+ if (launchRootTask != null) {
if (stack.getParent() == null) {
- splitRootSecondary.addChild(stack, position);
- } else if (stack.getParent() != splitRootSecondary) {
- stack.reparent(splitRootSecondary, position);
+ launchRootTask.addChild(stack, position);
+ } else if (stack.getParent() != launchRootTask) {
+ stack.reparent(launchRootTask, position);
}
} else if (stack.getDisplay() != mDisplayContent || !stack.isRootTask()) {
if (stack.getParent() == null) {
@@ -779,7 +779,7 @@
return stack;
}
return createStack(windowingMode, activityType, onTop, null /*info*/, intent,
- createdByOrganizer);
+ false /* createdByOrganizer */);
}
/**
@@ -798,7 +798,7 @@
// it's display's windowing mode.
windowingMode = validateWindowingMode(windowingMode, r, candidateTask, activityType);
return getOrCreateStack(windowingMode, activityType, onTop, null /* intent */,
- candidateTask, false /* createdByOrganizer */);
+ candidateTask);
}
@VisibleForTesting
diff --git a/services/core/java/com/android/server/wm/TaskOrganizerController.java b/services/core/java/com/android/server/wm/TaskOrganizerController.java
index 872f254..b641e4c 100644
--- a/services/core/java/com/android/server/wm/TaskOrganizerController.java
+++ b/services/core/java/com/android/server/wm/TaskOrganizerController.java
@@ -277,9 +277,9 @@
return null;
}
- final Task task = display.mTaskContainers.getOrCreateStack(windowingMode,
- ACTIVITY_TYPE_UNDEFINED, false /* onTop */, new Intent(),
- null /* candidateTask */, true /* createdByOrganizer */);
+ final Task task = display.mTaskContainers.createStack(windowingMode,
+ ACTIVITY_TYPE_UNDEFINED, false /* onTop */, null /* info */, new Intent(),
+ true /* createdByOrganizer */);
RunningTaskInfo out = task.getTaskInfo();
mLastSentTaskInfos.put(task, out);
return out;