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

Commit 93884a5b authored by Craig Mautner's avatar Craig Mautner
Browse files

Fix invalid stackId bug.

Eliminate race condition by executing window manager createStack
directly from activity manager.

Change-Id: I2dda276d07d0ae09c7c958980bc5ebffe72ebd92
parent 4504de5d
Loading
Loading
Loading
Loading
+8 −22
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 {
@@ -7047,8 +7040,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) {
@@ -7492,11 +7483,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");