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

Commit e056f435 authored by Sean Stout's avatar Sean Stout Committed by Android (Google) Code Review
Browse files

Merge "Call WindowManagerInternal#waitForAllWindowsDrawn for secondary displays" into sc-dev

parents 5743bb3b ff900bd1
Loading
Loading
Loading
Loading
+20 −19
Original line number Original line Diff line number Diff line
@@ -413,13 +413,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    volatile boolean mBootAnimationDismissable;
    volatile boolean mBootAnimationDismissable;
    private KeyguardServiceDelegate mKeyguardDelegate;
    private KeyguardServiceDelegate mKeyguardDelegate;
    private boolean mKeyguardBound;
    private boolean mKeyguardBound;
    final Runnable mWindowManagerDrawCallback = new Runnable() {
        @Override
        public void run() {
            if (DEBUG_WAKEUP) Slog.i(TAG, "All windows ready for display!");
            mHandler.sendEmptyMessage(MSG_WINDOW_MANAGER_DRAWN_COMPLETE);
        }
    };
    final DrawnListener mKeyguardDrawnCallback = new DrawnListener() {
    final DrawnListener mKeyguardDrawnCallback = new DrawnListener() {
        @Override
        @Override
        public void onDrawn() {
        public void onDrawn() {
@@ -646,7 +639,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    break;
                    break;
                case MSG_WINDOW_MANAGER_DRAWN_COMPLETE:
                case MSG_WINDOW_MANAGER_DRAWN_COMPLETE:
                    if (DEBUG_WAKEUP) Slog.w(TAG, "Setting mWindowManagerDrawComplete");
                    if (DEBUG_WAKEUP) Slog.w(TAG, "Setting mWindowManagerDrawComplete");
                    finishWindowsDrawn();
                    finishWindowsDrawn(msg.arg1);
                    break;
                    break;
                case MSG_HIDE_BOOT_MESSAGE:
                case MSG_HIDE_BOOT_MESSAGE:
                    handleHideBootMessage();
                    handleHideBootMessage();
@@ -4308,8 +4301,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {


        // ... eventually calls finishWindowsDrawn which will finalize our screen turn on
        // ... eventually calls finishWindowsDrawn which will finalize our screen turn on
        // as well as enabling the orientation change logic/sensor.
        // as well as enabling the orientation change logic/sensor.
        mWindowManagerInternal.waitForAllWindowsDrawn(mWindowManagerDrawCallback,
        mWindowManagerInternal.waitForAllWindowsDrawn(() -> {
                WAITING_FOR_DRAWN_TIMEOUT, INVALID_DISPLAY);
            if (DEBUG_WAKEUP) Slog.i(TAG, "All windows ready for every display");
            mHandler.sendMessage(mHandler.obtainMessage(MSG_WINDOW_MANAGER_DRAWN_COMPLETE,
                    INVALID_DISPLAY, 0));
            }, WAITING_FOR_DRAWN_TIMEOUT, INVALID_DISPLAY);
    }
    }


    // Called on the DisplayManager's DisplayPowerController thread.
    // Called on the DisplayManager's DisplayPowerController thread.
@@ -4369,6 +4365,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            }
            }
        } else {
        } else {
            mScreenOnListeners.put(displayId, screenOnListener);
            mScreenOnListeners.put(displayId, screenOnListener);
            mWindowManagerInternal.waitForAllWindowsDrawn(() -> {
                if (DEBUG_WAKEUP) Slog.i(TAG, "All windows ready for display: " + displayId);
                mHandler.sendMessage(mHandler.obtainMessage(MSG_WINDOW_MANAGER_DRAWN_COMPLETE,
                        displayId, 0));
            }, WAITING_FOR_DRAWN_TIMEOUT, displayId);
        }
        }
    }
    }


@@ -4409,7 +4410,15 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        mVrManagerInternal.onScreenStateChanged(isScreenOn);
        mVrManagerInternal.onScreenStateChanged(isScreenOn);
    }
    }


    private void finishWindowsDrawn() {
    private void finishWindowsDrawn(int displayId) {
        if (displayId != DEFAULT_DISPLAY && displayId != INVALID_DISPLAY) {
            final ScreenOnListener screenOnListener = mScreenOnListeners.removeReturnOld(displayId);
            if (screenOnListener != null) {
                screenOnListener.onScreenOn();
            }
            return;
        }

        if (!mDefaultDisplayPolicy.finishWindowsDrawn()) {
        if (!mDefaultDisplayPolicy.finishWindowsDrawn()) {
            return;
            return;
        }
        }
@@ -4453,14 +4462,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            if (listener != null) {
            if (listener != null) {
                listener.onScreenOn();
                listener.onScreenOn();
            }
            }

            for (int i = mScreenOnListeners.size() - 1; i >= 0; i--) {
                final ScreenOnListener screenOnListener = mScreenOnListeners.valueAt(i);
                if (screenOnListener != null) {
                    screenOnListener.onScreenOn();
                }
            }
            mScreenOnListeners.clear();
        }
        }


        if (enableScreen) {
        if (enableScreen) {