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

Commit ad25fa36 authored by Craig Mautner's avatar Craig Mautner
Browse files

Add display synchronously.

Adding the virtual display to window manager through a handler message
causes timing issues. Add the display directly to fix it.

Change-Id: I3ad6b16ce6dff2a48abd120a8e873e11a028e2c3
parent 4504de5d
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -2995,8 +2995,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
            final Display display = virtualDisplay.getDisplay();
            final int displayId = display.getDisplayId();

            // Do WindowManager operation first so that it is ahead of CREATE_STACK in the H queue.
            mWindowManager.onDisplayAdded(displayId);
            mWindowManager.handleDisplayAdded(displayId);

            synchronized (mService) {
                ActivityDisplay activityDisplay = new ActivityDisplay(display);
+16 −31
Original line number Diff line number Diff line
@@ -4817,27 +4817,20 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    public void createStack(int stackId, int displayId) {
        mH.sendMessage(mH.obtainMessage(H.CREATE_STACK, stackId, displayId));
    }

    /**
     * Create a new TaskStack and place it next to an existing stack.
     * Create a new TaskStack and place it on a DisplayContent.
     * @param stackId The unique identifier of the new stack.
     * @param displayId The unique identifier of the DisplayContent.
     */
    private void createStackLocked(int stackId, int displayId) {
    public void createStack(int stackId, int displayId) {
        final long origId = Binder.clearCallingIdentity();
        try {
            synchronized (mWindowMap) {
                final int numDisplays = mDisplayContents.size();
                for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
                    final DisplayContent displayContent = mDisplayContents.valueAt(displayNdx);
                    if (displayContent.getDisplayId() == displayId) {
                final DisplayContent displayContent = mDisplayContents.get(displayId);
                if (displayContent != null) {
                    TaskStack stack = displayContent.createStack(stackId);
                    mStackIdToStack.put(stackId, stack);
                    performLayoutAndPlaceSurfacesLocked();
                        return;
                    }
                }
            }
        } finally {
@@ -4872,7 +4865,6 @@ public class WindowManagerService extends IWindowManager.Stub
            final TaskStack stack = task.mStack;
            EventLog.writeEvent(EventLogTags.WM_TASK_REMOVED, taskId, "removeTask");
            stack.removeTask(task);
            stack.getDisplayContent().layoutNeeded = true;
        }
    }

@@ -7047,8 +7039,6 @@ public class WindowManagerService extends IWindowManager.Stub

        public static final int REMOVE_STARTING_TIMEOUT = 33;

        public static final int CREATE_STACK = 34;

        @Override
        public void handleMessage(Message msg) {
            if (DEBUG_WINDOW_TRACE) {
@@ -7456,9 +7446,7 @@ public class WindowManagerService extends IWindowManager.Stub
                }

                case DO_DISPLAY_ADDED:
                    synchronized (mWindowMap) {
                        handleDisplayAddedLocked(msg.arg1);
                    }
                    handleDisplayAdded(msg.arg1);
                    break;

                case DO_DISPLAY_REMOVED:
@@ -7492,11 +7480,6 @@ public class WindowManagerService extends IWindowManager.Stub
                    } catch (RemoteException e) {
                    }
                    break;
                case CREATE_STACK:
                    synchronized (mWindowMap) {
                        createStackLocked(msg.arg1, msg.arg2);
                    }
                    break;
            }
            if (DEBUG_WINDOW_TRACE) {
                Slog.v(TAG, "handleMessage: exit");
@@ -10800,13 +10783,15 @@ public class WindowManagerService extends IWindowManager.Stub
        mH.sendMessage(mH.obtainMessage(H.DO_DISPLAY_ADDED, displayId, 0));
    }

    private void handleDisplayAddedLocked(int displayId) {
    public void handleDisplayAdded(int displayId) {
        synchronized (mWindowMap) {
            final Display display = mDisplayManager.getDisplay(displayId);
            if (display != null) {
                createDisplayContentLocked(display);
                displayReady(displayId);
            }
        }
    }

    @Override
    public void onDisplayRemoved(int displayId) {