From 08a304912637c0fa55e087762bc40ca9df2fce56 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Wed, 30 Mar 2022 18:35:34 +0800 Subject: [PATCH] Make sure display config is updated when cutout is changed 1. LocalDisplayAdapter.LocalDisplayDevice#updateDeviceInfoLocked posts to display thread when receiving onOverlayChanged. So the operation depends on it should run sequentially. 2. After updating latest display info, the cutout may affect the height of status bar, then it still needs to compute display config again after that for screenHeightDp. Bug: 222572231 Test: Toggle different types of cutout in developer options, Either: rotate the display, there won't be a blank area or switch to another activity, there won't have another display config change CONFIG_SCREEN_SIZE. Change-Id: I8bb53d846656c76666074c0dee0e3c1c8627e24b --- .../com/android/server/wm/DisplayPolicy.java | 8 ++++++-- .../server/wm/WindowManagerService.java | 18 +++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java index 4573ede13f7f5..c6bfe8ba253cd 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -1814,10 +1814,14 @@ public class DisplayPolicy { /** * Called when the resource overlays change. */ - public void onOverlayChangedLw() { + void onOverlayChanged() { updateCurrentUserResources(); + // Update the latest display size, cutout. + mDisplayContent.updateDisplayInfo(); + // The height of status bar needs to update in case display cutout is changed. onConfigurationChanged(); - mSystemGestures.onConfigurationChanged(); + // The height of status bar can affect screen size configuration. + mDisplayContent.reconfigureDisplayLocked(); } /** diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 451e777387450..d7498b757124a 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -6967,13 +6967,17 @@ public class WindowManagerService extends IWindowManager.Stub } public void onOverlayChanged() { - synchronized (mGlobalLock) { - mRoot.forAllDisplays(displayContent -> { - displayContent.getDisplayPolicy().onOverlayChangedLw(); - displayContent.updateDisplayInfo(); - }); - requestTraversal(); - } + // Post to display thread so it can get the latest display info. + mH.post(() -> { + synchronized (mGlobalLock) { + mAtmService.deferWindowLayout(); + try { + mRoot.forAllDisplays(dc -> dc.getDisplayPolicy().onOverlayChanged()); + } finally { + mAtmService.continueWindowLayout(); + } + } + }); } @Override