WM: Make maxAspectRatio work with display cutouts

Fixes an issue where the max aspect ratio was not correctly calculated
if there was a display cutout.

The issue was that the max aspect ratio logic assumed that nothing ever
applies a top inset (n.b. the status bar is ignored for this inset).
This is no longer true with display cutouts, which
cut into the app bounds from the top.

To make things work, we now need to grow the bounds for the app window
by that inset. Later on, the top part will be trimmed again for the
bounds reported to the app. Note that we cannot outright discard the
top part, or colored bars would cease to work.

Change-Id: I53925196a6a41736fc4748b12bbc3b8a9b0d174b
Fixes: 80248462
Test: atest AspectRatioTests
This commit is contained in:
Adrian Roos
2018-05-28 18:55:38 +02:00
parent 6de8729657
commit 24be34dcc9

View File

@@ -2413,11 +2413,16 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
}
// Compute configuration based on max supported width and height.
outBounds.set(0, 0, maxActivityWidth, maxActivityHeight);
// Position the activity frame on the opposite side of the nav bar.
final int navBarPosition = service.mWindowManager.getNavBarPosition();
final int left = navBarPosition == NAV_BAR_LEFT ? appBounds.right - outBounds.width() : 0;
outBounds.offsetTo(left, 0 /* top */);
// Also account for the left / top insets (e.g. from display cutouts), which will be clipped
// away later in StackWindowController.adjustConfigurationForBounds(). Otherwise, the app
// bounds would end up too small.
outBounds.set(0, 0, maxActivityWidth + appBounds.left, maxActivityHeight + appBounds.top);
if (service.mWindowManager.getNavBarPosition() == NAV_BAR_LEFT) {
// Position the activity frame on the opposite side of the nav bar.
outBounds.left = appBounds.right - maxActivityWidth;
outBounds.right = appBounds.right;
}
}
boolean ensureActivityConfiguration(int globalChanges, boolean preserveWindow) {