Merge "Start activity with focus root task for staged split" into sc-dev

This commit is contained in:
Jeff Chang
2021-04-29 10:35:31 +00:00
committed by Android (Google) Code Review
2 changed files with 32 additions and 1 deletions

View File

@@ -1274,7 +1274,15 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
for (int i = mLaunchRootTasks.size() - 1; i >= 0; --i) {
if (mLaunchRootTasks.get(i).contains(windowingMode, activityType)) {
return mLaunchRootTasks.get(i).task;
final Task launchRootTask = mLaunchRootTasks.get(i).task;
// Return the focusable root task for improving the UX with staged split screen.
final Task adjacentRootTask = launchRootTask != null
? launchRootTask.mAdjacentTask : null;
if (adjacentRootTask != null && adjacentRootTask.isFocusedRootTaskOnDisplay()) {
return adjacentRootTask;
} else {
return launchRootTask;
}
}
}
return null;

View File

@@ -100,6 +100,29 @@ public class TaskDisplayAreaTests extends WindowTestsBase {
assertNull(actualRootTask);
}
@Test
public void getLaunchRootTask_checksFocusedRootTask() {
final TaskDisplayArea taskDisplayArea = mRootWindowContainer.getDefaultTaskDisplayArea();
final Task rootTask = createTaskWithActivity(
taskDisplayArea,
WINDOWING_MODE_MULTI_WINDOW, ACTIVITY_TYPE_STANDARD, ON_TOP, true);
rootTask.mCreatedByOrganizer = true;
final Task adjacentRootTask = createTask(
mDisplayContent, WINDOWING_MODE_MULTI_WINDOW, ACTIVITY_TYPE_STANDARD);
adjacentRootTask.mCreatedByOrganizer = true;
adjacentRootTask.mAdjacentTask = rootTask;
rootTask.mAdjacentTask = adjacentRootTask;
taskDisplayArea.setLaunchRootTask(rootTask,
new int[]{WINDOWING_MODE_MULTI_WINDOW}, new int[]{ACTIVITY_TYPE_STANDARD});
Task actualRootTask = taskDisplayArea.getLaunchRootTask(
WINDOWING_MODE_MULTI_WINDOW, ACTIVITY_TYPE_STANDARD, null /* options */,
null /* sourceTask */, 0 /*launchFlags*/);
assertTrue(actualRootTask.isFocusedRootTaskOnDisplay());
}
@Test
public void getLaunchRootTask_fromLaunchAdjacentFlagRoot_checksAdjacentRoot() {
final ActivityRecord activity = createNonAttachedActivityRecord(mDisplayContent);