Initialize DisplayContent base info when object is constructed
It is possible for an external process (e.g. sys-ui) to call into WM to get the bounds of a stack in between the construction of the DisplayContent object and SystemServer telling WM that the display is ready. Incorrect bounds would be returned to the caller in this case since the baseDisplayWidth/Height is only set when the displayReady call is made. We now initialize the base display information when the DisplayContent object is created so any call to get the logical display rect of the display will always return the right bounds. This should be okay as the display manager is initialized way before window manager. Bug: 22961090 Change-Id: Iebd688ad8f4c08556846fcebb543e58bd2c01414
This commit is contained in:
committed by
Filip Gruszczynski
parent
ffffcf14c5
commit
4ff84631af
@@ -116,6 +116,7 @@ class DisplayContent {
|
||||
display.getDisplayInfo(mDisplayInfo);
|
||||
isDefaultDisplay = mDisplayId == Display.DEFAULT_DISPLAY;
|
||||
mService = service;
|
||||
initializeDisplayBaseInfo();
|
||||
}
|
||||
|
||||
int getDisplayId() {
|
||||
@@ -176,6 +177,21 @@ class DisplayContent {
|
||||
}
|
||||
}
|
||||
|
||||
void initializeDisplayBaseInfo() {
|
||||
synchronized(mDisplaySizeLock) {
|
||||
// Bootstrap the default logical display from the display manager.
|
||||
final DisplayInfo newDisplayInfo =
|
||||
mService.mDisplayManagerInternal.getDisplayInfo(mDisplayId);
|
||||
if (newDisplayInfo != null) {
|
||||
mDisplayInfo.copyFrom(newDisplayInfo);
|
||||
}
|
||||
mBaseDisplayWidth = mInitialDisplayWidth = mDisplayInfo.logicalWidth;
|
||||
mBaseDisplayHeight = mInitialDisplayHeight = mDisplayInfo.logicalHeight;
|
||||
mBaseDisplayDensity = mInitialDisplayDensity = mDisplayInfo.logicalDensityDpi;
|
||||
mBaseDisplayRect.set(0, 0, mBaseDisplayWidth, mBaseDisplayHeight);
|
||||
}
|
||||
}
|
||||
|
||||
void getLogicalDisplayRect(Rect out) {
|
||||
// Uses same calculation as in LogicalDisplay#configureDisplayInTransactionLocked.
|
||||
final int orientation = mDisplayInfo.rotation;
|
||||
|
||||
@@ -7670,22 +7670,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
final DisplayContent displayContent = getDisplayContentLocked(displayId);
|
||||
if (displayContent != null) {
|
||||
mAnimator.addDisplayLocked(displayId);
|
||||
synchronized(displayContent.mDisplaySizeLock) {
|
||||
// Bootstrap the default logical display from the display manager.
|
||||
final DisplayInfo displayInfo = displayContent.getDisplayInfo();
|
||||
DisplayInfo newDisplayInfo = mDisplayManagerInternal.getDisplayInfo(displayId);
|
||||
if (newDisplayInfo != null) {
|
||||
displayInfo.copyFrom(newDisplayInfo);
|
||||
}
|
||||
displayContent.mInitialDisplayWidth = displayInfo.logicalWidth;
|
||||
displayContent.mInitialDisplayHeight = displayInfo.logicalHeight;
|
||||
displayContent.mInitialDisplayDensity = displayInfo.logicalDensityDpi;
|
||||
displayContent.mBaseDisplayWidth = displayContent.mInitialDisplayWidth;
|
||||
displayContent.mBaseDisplayHeight = displayContent.mInitialDisplayHeight;
|
||||
displayContent.mBaseDisplayDensity = displayContent.mInitialDisplayDensity;
|
||||
displayContent.mBaseDisplayRect.set(0, 0,
|
||||
displayContent.mBaseDisplayWidth, displayContent.mBaseDisplayHeight);
|
||||
}
|
||||
displayContent.initializeDisplayBaseInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user