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

Commit 1cddfdc1 authored by Bryce Lee's avatar Bryce Lee
Browse files

Create display if necessary when adding windows.

It is possible for a window to be added to a display before
ActivityManagerService has processed a display creation. In this
case, the relevant WindowManager and ActivityManager containers have
not been created. This will prevent the client from proceeding.

This changelist addresses this problem by allowing the WindowManager
DisplayContent to be created in this specific scenario. When the
ActivityManager side processes the new display, it will be associated
with the existing DisplayContent.

Change-Id: I1bc7d11f5cc538f35b5f7b0a8303d48fba370ea0
Fixes: 73292997
Test: cts-tradefed run singleCommand cts-dev --module CtsMediaTestCases --test android.media.cts.EncodeVirtualDisplayWithCompositionTest
parent cfcd8a05
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -204,9 +204,20 @@ class RootWindowContainer extends WindowContainer<DisplayContent> {
    }

    DisplayContent createDisplayContent(final Display display, DisplayWindowController controller) {
        final int displayId = display.getDisplayId();

        // In select scenarios, it is possible that a DisplayContent will be created on demand
        // rather than waiting for the controller. In this case, associate the controller and return
        // the existing display.
        final DisplayContent existing = getDisplayContent(displayId);

        if (existing != null) {
            existing.setController(controller);
            return existing;
        }

        final DisplayContent dc =
                new DisplayContent(display, mService, mWallpaperController, controller);
        final int displayId = display.getDisplayId();

        if (DEBUG_DISPLAY) Slog.v(TAG_WM, "Adding display=" + display);

+12 −1
Original line number Diff line number Diff line
@@ -1131,7 +1131,18 @@ public class WindowManagerService extends IWindowManager.Stub
                throw new IllegalStateException("Display has not been initialialized");
            }

            final DisplayContent displayContent = mRoot.getDisplayContent(displayId);
            DisplayContent displayContent = mRoot.getDisplayContent(displayId);

            // Adding a window is an exception where the WindowManagerService can create the
            // display instead of waiting for the ActivityManagerService to drive creation.
            if (displayContent == null) {
                final Display display = mDisplayManager.getDisplay(displayId);

                if (display != null) {
                    displayContent = mRoot.createDisplayContent(display, null /* controller */);
                }
            }

            if (displayContent == null) {
                Slog.w(TAG_WM, "Attempted to add window to a display that does not exist: "
                        + displayId + ".  Aborting.");