Merge "Avoid using secondary displays as launch params when not support" into qt-qpr1-dev
diff --git a/services/core/java/com/android/server/wm/TaskLaunchParamsModifier.java b/services/core/java/com/android/server/wm/TaskLaunchParamsModifier.java
index 14585c5..19fbfed 100644
--- a/services/core/java/com/android/server/wm/TaskLaunchParamsModifier.java
+++ b/services/core/java/com/android/server/wm/TaskLaunchParamsModifier.java
@@ -292,6 +292,10 @@
private int getPreferredLaunchDisplay(@Nullable TaskRecord task,
@Nullable ActivityOptions options, ActivityRecord source, LaunchParams currentParams) {
+ if (!mSupervisor.mService.mSupportsMultiDisplay) {
+ return DEFAULT_DISPLAY;
+ }
+
int displayId = INVALID_DISPLAY;
final int optionLaunchId = options != null ? options.getLaunchDisplayId() : INVALID_DISPLAY;
if (optionLaunchId != INVALID_DISPLAY) {
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 f918149..58614c6 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskLaunchParamsModifierTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskLaunchParamsModifierTests.java
@@ -1225,6 +1225,22 @@
assertEquals(startingBounds, adjustedBounds);
}
+ @Test
+ public void testNoMultiDisplaySupports() {
+ final boolean orgValue = mService.mSupportsMultiDisplay;
+ final TestActivityDisplay display = createNewActivityDisplay(WINDOWING_MODE_FULLSCREEN);
+ mCurrent.mPreferredDisplayId = display.mDisplayId;
+
+ try {
+ mService.mSupportsMultiDisplay = false;
+ assertEquals(RESULT_CONTINUE, mTarget.onCalculate(/* task */ null, /* layout */ null,
+ mActivity, /* source */ null, /* options */ null, mCurrent, mResult));
+ assertEquals(DEFAULT_DISPLAY, mResult.mPreferredDisplayId);
+ } finally {
+ mService.mSupportsMultiDisplay = orgValue;
+ }
+ }
+
private TestActivityDisplay createNewActivityDisplay(int windowingMode) {
final TestActivityDisplay display = addNewActivityDisplayAt(ActivityDisplay.POSITION_TOP);
display.setWindowingMode(windowingMode);