Prefer to launch activities on the source display
If the Activity was sent by another Activity, the source display is
whatever display the original activity was running on. Otherwise,
the source display is the primary display.
- When looking for a task to launch the activity into, ignore affinity
matches on other displays so we ignore tasks on other displays (when
possible). This is effectively the inverse of LAUNCH_ADJACENT, which
ignores all affinity matches to try to launch into the adjacent stack.
- Bypass LAUNCH_ADJACENT's logic for determining the launch stack if
we're not on the primary display.
- If the focused stack is dynamic, only consider it if the source was on
the same display as that dynamic stack.
- If no particular stack matches, use the source display instead of
defaulting to the primary display.
This behavior also means we don't need to check display access
permissions unless the caller requests a specific display, since the
source is already running on the display and thus has permissions.
Bug: 34230873
Test: android.server.cts.ActivityManagerDisplayTests
Test: #testTaskMatchAcrossDisplays
Test: #testNewTaskSameDisplay
Change-Id: Ic3b4754ffb290f84c3964352105594961604891a
2 files changed