Modify multi-display Activity launching behavior

When choosing the display on which to launch an Activity, prefer the
display of the launching app over the display the launched Application
is already on.

Bug: 176199388
Test: manual - launch app on external display, launch via Launcher on
primary display, relaunch on external display

Change-Id: I95d8bce2662a0d38ce8399450ccf246a72afb9fd
This commit is contained in:
Sean Stout
2021-03-02 14:59:07 -08:00
parent 2573939d60
commit 79ce09a0fc
2 changed files with 8 additions and 8 deletions

View File

@@ -380,6 +380,12 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
}
}
if (taskDisplayArea == null && source != null) {
final TaskDisplayArea sourceDisplayArea = source.getDisplayArea();
if (DEBUG) appendLog("display-area-from-source=" + sourceDisplayArea);
taskDisplayArea = sourceDisplayArea;
}
Task rootTask = (taskDisplayArea == null && task != null)
? task.getRootTask() : null;
if (rootTask != null) {
@@ -387,12 +393,6 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
taskDisplayArea = rootTask.getDisplayArea();
}
if (taskDisplayArea == null && source != null) {
final TaskDisplayArea sourceDisplayArea = source.getDisplayArea();
if (DEBUG) appendLog("display-area-from-source=" + sourceDisplayArea);
taskDisplayArea = sourceDisplayArea;
}
if (taskDisplayArea == null && options != null) {
final int callerDisplayId = options.getCallerDisplayId();
final DisplayContent dc =

View File

@@ -195,7 +195,7 @@ public class TaskLaunchParamsModifierTests extends WindowTestsBase {
}
@Test
public void testUsesTasksDisplayAreaIdPriorToSourceIfSet() {
public void testUsesSourcesDisplayAreaIdPriorToTaskIfSet() {
final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
final TestDisplayContent fullscreenDisplay = createNewDisplayContent(
@@ -211,7 +211,7 @@ public class TaskLaunchParamsModifierTests extends WindowTestsBase {
.setSource(source)
.calculate());
assertEquals(fullscreenDisplay.getDefaultTaskDisplayArea(),
assertEquals(freeformDisplay.getDefaultTaskDisplayArea(),
mResult.mPreferredTaskDisplayArea);
}