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

Commit 73a8d0df authored by Dian Zhang's avatar Dian Zhang Committed by Chris Li
Browse files

[BugFix]Fixed a fatal exception which cause IndexOutOfBoundsException.

Bug: 350617606
Merged-In: Ib57885c30d76bed06f5678f3f0b7078f61d0a1bc
Change-Id: Ib57885c30d76bed06f5678f3f0b7078f61d0a1bc
parent 219a0d17
Loading
Loading
Loading
Loading
+31 −28
Original line number Original line Diff line number Diff line
@@ -8010,26 +8010,33 @@ public class WindowManagerService extends IWindowManager.Stub
        @Override
        @Override
        public void waitForAllWindowsDrawn(Message message, long timeout, int displayId) {
        public void waitForAllWindowsDrawn(Message message, long timeout, int displayId) {
            Objects.requireNonNull(message.getTarget());
            Objects.requireNonNull(message.getTarget());
            boolean allWindowsDrawn = false;
            synchronized (mGlobalLock) {
                allWindowsDrawn = waitForAllWindowsDrawnLocked(message, timeout, displayId);
            }
            if (allWindowsDrawn) {
                message.sendToTarget();
            }
        }

        /** Return {@code true} if all windows have been drawn. */
        private boolean waitForAllWindowsDrawnLocked(Message message, long timeout, int displayId) {
            final WindowContainer<?> container = displayId == INVALID_DISPLAY
            final WindowContainer<?> container = displayId == INVALID_DISPLAY
                    ? mRoot : mRoot.getDisplayContent(displayId);
                    ? mRoot : mRoot.getDisplayContent(displayId);
            if (container == null) {
            if (container == null) {
                // The waiting container doesn't exist, no need to wait to run the callback. Run and
                // The waiting container doesn't exist, no need to wait. Treat as drawn.
                // return;
                return true;
                message.sendToTarget();
                return;
            }
            }
            boolean allWindowsDrawn = false;
            synchronized (mGlobalLock) {
            if (mRoot.getDefaultDisplay().mDisplayUpdater.waitForTransition(message)) {
            if (mRoot.getDefaultDisplay().mDisplayUpdater.waitForTransition(message)) {
                // Use the ready-to-play of transition as the signal.
                // Use the ready-to-play of transition as the signal.
                    return;
                return false;
            }
            }
            container.waitForAllWindowsDrawn();
            container.waitForAllWindowsDrawn();
            mWindowPlacerLocked.requestTraversal();
            mWindowPlacerLocked.requestTraversal();
            mH.removeMessages(H.WAITING_FOR_DRAWN_TIMEOUT, container);
            mH.removeMessages(H.WAITING_FOR_DRAWN_TIMEOUT, container);
            if (container.mWaitingForDrawn.isEmpty()) {
            if (container.mWaitingForDrawn.isEmpty()) {
                    allWindowsDrawn = true;
                return true;
                } else {
            }
            if (Trace.isTagEnabled(TRACE_TAG_WINDOW_MANAGER)) {
            if (Trace.isTagEnabled(TRACE_TAG_WINDOW_MANAGER)) {
                for (int i = 0; i < container.mWaitingForDrawn.size(); i++) {
                for (int i = 0; i < container.mWaitingForDrawn.size(); i++) {
                    traceStartWaitingForWindowDrawn(container.mWaitingForDrawn.get(i));
                    traceStartWaitingForWindowDrawn(container.mWaitingForDrawn.get(i));
@@ -8039,11 +8046,7 @@ public class WindowManagerService extends IWindowManager.Stub
            mWaitingForDrawnCallbacks.put(container, message);
            mWaitingForDrawnCallbacks.put(container, message);
            mH.sendNewMessageDelayed(H.WAITING_FOR_DRAWN_TIMEOUT, container, timeout);
            mH.sendNewMessageDelayed(H.WAITING_FOR_DRAWN_TIMEOUT, container, timeout);
            checkDrawnWindowsLocked();
            checkDrawnWindowsLocked();
                }
            return false;
            }
            if (allWindowsDrawn) {
                message.sendToTarget();
            }
        }
        }


        @Override
        @Override