From ff900bd19c873ed32f4eacd7839a55dd49b074da Mon Sep 17 00:00:00 2001 From: Sean Stout Date: Wed, 7 Apr 2021 15:42:40 -0700 Subject: Call WindowManagerInternal#waitForAllWindowsDrawn for secondary displays When a secondary display is turning on, WindowManagerInternal#waitForAllWindowsDrawn does not get called properly. This CL updates PhoneWindowManager to call this method so that secondary displays may power on correctly. Fixes: 184780671 Test: power on primary display while using Android Auto Change-Id: I649c796933d81ff80afec26f66eecb4805f3d69c --- .../android/server/policy/PhoneWindowManager.java | 39 +++++++++++----------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index 5b333e15fe67..a8b0273eccf6 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -413,13 +413,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { volatile boolean mBootAnimationDismissable; private KeyguardServiceDelegate mKeyguardDelegate; 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() { @Override public void onDrawn() { @@ -646,7 +639,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { break; case MSG_WINDOW_MANAGER_DRAWN_COMPLETE: if (DEBUG_WAKEUP) Slog.w(TAG, "Setting mWindowManagerDrawComplete"); - finishWindowsDrawn(); + finishWindowsDrawn(msg.arg1); break; case MSG_HIDE_BOOT_MESSAGE: handleHideBootMessage(); @@ -4308,8 +4301,11 @@ public class PhoneWindowManager implements WindowManagerPolicy { // ... eventually calls finishWindowsDrawn which will finalize our screen turn on // as well as enabling the orientation change logic/sensor. - mWindowManagerInternal.waitForAllWindowsDrawn(mWindowManagerDrawCallback, - WAITING_FOR_DRAWN_TIMEOUT, INVALID_DISPLAY); + mWindowManagerInternal.waitForAllWindowsDrawn(() -> { + 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. @@ -4369,6 +4365,11 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } else { 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); } - 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()) { return; } @@ -4453,14 +4462,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (listener != null) { 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) { -- cgit v1.2.3-59-g8ed1b