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

Commit 6bfc30d2 authored by Louis Chang's avatar Louis Chang
Browse files

Select the focused display as fallback only if the display can host tasks

Otherwise, still select the default display.

It is possible for a display that cannot host tasks becomes focused
if there's a focused window on the display.

Bug: 406967985
Test: MultiDisplayActivityLaunchTests
Flag: com.android.window.flags.fallback_to_focused_display
Change-Id: I8b498ac4fe2a291ad8334f30b2f023c7c76724a8
parent 96b10744
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -453,9 +453,16 @@ class LaunchParamsUtil {
        }

        if (com.android.window.flags.Flags.fallbackToFocusedDisplay()) {
            // Select the TDA from the top focused display.
            final TaskDisplayArea defaultTaskDisplayArea = supervisor.mRootWindowContainer
                    .getTopFocusedDisplayContent().getDefaultTaskDisplayArea();
            // Select the TDA from the top focused display if possible.
            final DisplayContent focusedDisplay =
                    supervisor.mRootWindowContainer.getTopFocusedDisplayContent();
            final TaskDisplayArea defaultTaskDisplayArea;
            if (focusedDisplay.mDisplay.canHostTasks()) {
                defaultTaskDisplayArea = focusedDisplay.getDefaultTaskDisplayArea();
            } else {
                defaultTaskDisplayArea =
                        supervisor.mRootWindowContainer.getDefaultTaskDisplayArea();
            }
            logger.accept("display-area-from-default-fallback=" + defaultTaskDisplayArea);
            return defaultTaskDisplayArea;
        } else {