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

Commit 4aec6911 authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Use display of parent window if available" into main

parents 353572f3 d62230ab
Loading
Loading
Loading
Loading
+17 −16
Original line number Diff line number Diff line
@@ -1547,7 +1547,23 @@ public class WindowManagerService extends IWindowManager.Stub
                return WindowManagerGlobal.ADD_APP_EXITING;
            }

            final DisplayContent displayContent = getDisplayContentOrCreate(displayId, attrs.token);
            if (type >= FIRST_SUB_WINDOW && type <= LAST_SUB_WINDOW) {
                parentWindow = windowForClientLocked(null, attrs.token, false);
                if (parentWindow == null) {
                    ProtoLog.w(WM_ERROR, "Attempted to add window with token that is not a window: "
                            + "%s.  Aborting.", attrs.token);
                    return WindowManagerGlobal.ADD_BAD_SUBWINDOW_TOKEN;
                }
                if (parentWindow.mAttrs.type >= FIRST_SUB_WINDOW
                        && parentWindow.mAttrs.type <= LAST_SUB_WINDOW) {
                    ProtoLog.w(WM_ERROR, "Attempted to add window with token that is a sub-window: "
                            + "%s.  Aborting.", attrs.token);
                    return WindowManagerGlobal.ADD_BAD_SUBWINDOW_TOKEN;
                }
            }
            final DisplayContent displayContent = parentWindow != null
                    ? parentWindow.mDisplayContent
                    : getDisplayContentOrCreate(displayId, attrs.token);

            if (displayContent == null) {
                ProtoLog.w(WM_ERROR, "Attempted to add window to a display that does "
@@ -1567,21 +1583,6 @@ public class WindowManagerService extends IWindowManager.Stub
                return WindowManagerGlobal.ADD_DUPLICATE_ADD;
            }

            if (type >= FIRST_SUB_WINDOW && type <= LAST_SUB_WINDOW) {
                parentWindow = windowForClientLocked(null, attrs.token, false);
                if (parentWindow == null) {
                    ProtoLog.w(WM_ERROR, "Attempted to add window with token that is not a window: "
                            + "%s.  Aborting.", attrs.token);
                    return WindowManagerGlobal.ADD_BAD_SUBWINDOW_TOKEN;
                }
                if (parentWindow.mAttrs.type >= FIRST_SUB_WINDOW
                        && parentWindow.mAttrs.type <= LAST_SUB_WINDOW) {
                    ProtoLog.w(WM_ERROR, "Attempted to add window with token that is a sub-window: "
                            + "%s.  Aborting.", attrs.token);
                    return WindowManagerGlobal.ADD_BAD_SUBWINDOW_TOKEN;
                }
            }

            if (type == TYPE_PRESENTATION || type == TYPE_PRIVATE_PRESENTATION) {
                mDisplayManagerInternal.onPresentation(displayContent.getDisplay().getDisplayId(),
                        /*isShown=*/ true);
+8 −0
Original line number Diff line number Diff line
@@ -554,6 +554,14 @@ public class WindowManagerServiceTests extends WindowTestsBase {
        verify(mWm.mWindowContextListenerController, never()).registerWindowContainerListener(any(),
                any(), any(), anyInt(), any(), anyBoolean());

        // Even if the given display id is INVALID_DISPLAY, the specified params.token should be
        // able to map the corresponding display.
        final int result = mWm.addWindow(
                session, new TestIWindow(), params, View.VISIBLE, INVALID_DISPLAY,
                UserHandle.USER_SYSTEM, WindowInsets.Type.defaultVisible(), null, new InsetsState(),
                new InsetsSourceControl.Array(), new Rect(), new float[1]);
        assertThat(result).isAtLeast(WindowManagerGlobal.ADD_OKAY);

        assertTrue(parentWin.hasChild());
        assertTrue(parentWin.isAttached());
        session.binderDied();