Get the latest display info for overlay change

LocalDisplayAdapter.LocalDisplayDevice#updateDeviceInfoLocked
posts to display thread when receiving onOverlayChanged. So
the operation depends on it should run sequentially.

This partial relands commit 08a3049 to make sure that the display
info can include the latest cutout info after changing the cutout
overlay resources. The reconfigureDisplayLocked in previous commit
is not called in this change because that will require to fix
configuration calculation according to decor windows that provide
display config related insets.

Bug: 222572231
Bug: 240961743
Test: Toggle different types of cutout in developer options,
      the cutout change should be applied immediately on screen.
Change-Id: I393c7b2c2e95eabc21123b7c95c760323a5386ec
This commit is contained in:
Riddle Hsu
2022-08-02 17:38:00 +08:00
parent 867250736a
commit eb8882f09b
2 changed files with 11 additions and 8 deletions

View File

@@ -1882,8 +1882,10 @@ public class DisplayPolicy {
/**
* Called when the resource overlays change.
*/
public void onOverlayChangedLw() {
void onOverlayChanged() {
updateCurrentUserResources();
// Update the latest display size, cutout.
mDisplayContent.updateDisplayInfo();
onConfigurationChanged();
mSystemGestures.onConfigurationChanged();
}

View File

@@ -7046,13 +7046,14 @@ 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();
mRoot.forAllDisplays(dc -> dc.getDisplayPolicy().onOverlayChanged());
mAtmService.continueWindowLayout();
}
});
}
@Override