Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 99cabe3e authored by Lingyu Feng's avatar Lingyu Feng Committed by Android (Google) Code Review
Browse files

Merge "Do not start secondary home on display that cannot host tasks" into main

parents d2797724 e2f59993
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -1577,6 +1577,14 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
            return false;
        }

        if (DesktopExperienceFlags.ENABLE_DISPLAY_CONTENT_MODE_MANAGEMENT.isTrue()
                && DesktopExperienceFlags.ENABLE_MIRROR_DISPLAY_NO_ACTIVITY.isTrue()) {
            if (!display.mDisplay.canHostTasks()) {
                // Can't launch home on display that cannot host tasks.
                return false;
            }
        }

        return true;
    }

+17 −0
Original line number Diff line number Diff line
@@ -1084,6 +1084,23 @@ public class RootWindowContainerTests extends WindowTestsBase {
        verify(mRootWindowContainer, never()).resolveSecondaryHomeActivity(anyInt(), any());
    }

    /**
     * Tests that secondary home activity should not be resolved if display cannot host tasks.
     */
    @Test
    public void testStartSecondaryHomeOnDisplayCannotHostTasks() {
        // Create secondary displays.
        final TestDisplayContent secondDisplay =
                new TestDisplayContent.Builder(mAtm, 1000, 1500).build();
        spyOn(secondDisplay.mDisplay);
        doReturn(false).when(secondDisplay.mDisplay).canHostTasks();

        mRootWindowContainer.startHomeOnDisplay(0 /* userId */, "testStartSecondaryHome",
                secondDisplay.mDisplayId, true /* allowInstrumenting */, true /* fromHomeKey */);

        verify(mRootWindowContainer, never()).resolveSecondaryHomeActivity(anyInt(), any());
    }

    /**
     * Tests that when starting {@link ResolverActivity} for home, it should use the standard
     * activity type (in a new root task) so the order of back stack won't be broken.