Merge "DisplayPolicy: Check that window provided insets" into tm-qpr-dev am: efeebb8c3b am: 1e27923bbf

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20063509

Change-Id: I66c1f760686cd2823cdfe336af9b9066effceb66
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
TreeHugger Robot
2022-09-28 21:23:22 +00:00
committed by Automerger Merge Worker
5 changed files with 27 additions and 13 deletions

View File

@@ -2167,10 +2167,7 @@ public class DisplayPolicy {
* If the decor insets changes, the display configuration may be affected. The caller should
* call {@link DisplayContent#sendNewConfiguration()} if this method returns {@code true}.
*/
boolean updateDecorInsetsInfoIfNeeded(WindowState win) {
if (!win.providesNonDecorInsets()) {
return false;
}
boolean updateDecorInsetsInfo() {
final DisplayFrames displayFrames = mDisplayContent.mDisplayFrames;
final int rotation = displayFrames.mRotation;
final int dw = displayFrames.mWidth;

View File

@@ -1834,8 +1834,12 @@ public class WindowManagerService extends IWindowManager.Stub
ProtoLog.v(WM_DEBUG_ADD_REMOVE, "addWindow: New client %s"
+ ": window=%s Callers=%s", client.asBinder(), win, Debug.getCallers(5));
if ((win.isVisibleRequestedOrAdding() && displayContent.updateOrientation())
|| displayPolicy.updateDecorInsetsInfoIfNeeded(win)) {
boolean needToSendNewConfiguration =
win.isVisibleRequestedOrAdding() && displayContent.updateOrientation();
if (win.providesNonDecorInsets()) {
needToSendNewConfiguration |= displayPolicy.updateDecorInsetsInfo();
}
if (needToSendNewConfiguration) {
displayContent.sendNewConfiguration();
}
@@ -2304,8 +2308,8 @@ public class WindowManagerService extends IWindowManager.Stub
& WindowManager.LayoutParams.SYSTEM_UI_VISIBILITY_CHANGED) != 0) {
win.mLayoutNeeded = true;
}
if (layoutChanged) {
configChanged = displayPolicy.updateDecorInsetsInfoIfNeeded(win);
if (layoutChanged && win.providesNonDecorInsets()) {
configChanged = displayPolicy.updateDecorInsetsInfo();
}
if (win.mActivityRecord != null && ((flagChanges & FLAG_SHOW_WHEN_LOCKED) != 0
|| (flagChanges & FLAG_DISMISS_KEYGUARD) != 0)) {

View File

@@ -2626,11 +2626,19 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
}
}
// Check if window provides non decor insets before clearing its provided insets.
final boolean windowProvidesNonDecorInsets = providesNonDecorInsets();
removeImmediately();
// Removing a visible window may affect the display orientation so just update it if
// needed. Also recompute configuration if it provides screen decor insets.
if ((wasVisible && displayContent.updateOrientation())
|| displayContent.getDisplayPolicy().updateDecorInsetsInfoIfNeeded(this)) {
boolean needToSendNewConfiguration = wasVisible && displayContent.updateOrientation();
if (windowProvidesNonDecorInsets) {
needToSendNewConfiguration |=
displayContent.getDisplayPolicy().updateDecorInsetsInfo();
}
if (needToSendNewConfiguration) {
displayContent.sendNewConfiguration();
}
mWmService.updateFocusedWindowLocked(isFocused()

View File

@@ -2990,7 +2990,8 @@ public class ActivityRecordTests extends WindowTestsBase {
.setSystemDecorations(true).build();
// Add a decor insets provider window.
final WindowState navbar = createNavBarWithProvidedInsets(squareDisplay);
squareDisplay.getDisplayPolicy().updateDecorInsetsInfoIfNeeded(navbar);
assertTrue(navbar.providesNonDecorInsets()
&& squareDisplay.getDisplayPolicy().updateDecorInsetsInfo());
squareDisplay.sendNewConfiguration();
final Task task = new TaskBuilder(mSupervisor).setDisplay(squareDisplay).build();

View File

@@ -292,12 +292,16 @@ public class DisplayPolicyTests extends WindowTestsBase {
final DisplayPolicy displayPolicy = mDisplayContent.getDisplayPolicy();
final DisplayInfo di = mDisplayContent.getDisplayInfo();
final int prevScreenHeightDp = mDisplayContent.getConfiguration().screenHeightDp;
assertTrue(displayPolicy.updateDecorInsetsInfoIfNeeded(navbar));
assertTrue(navbar.providesNonDecorInsets() && displayPolicy.updateDecorInsetsInfo());
assertEquals(NAV_BAR_HEIGHT, displayPolicy.getDecorInsetsInfo(di.rotation,
di.logicalWidth, di.logicalHeight).mConfigInsets.bottom);
mDisplayContent.sendNewConfiguration();
assertNotEquals(prevScreenHeightDp, mDisplayContent.getConfiguration().screenHeightDp);
assertFalse(displayPolicy.updateDecorInsetsInfoIfNeeded(navbar));
assertFalse(navbar.providesNonDecorInsets() && displayPolicy.updateDecorInsetsInfo());
navbar.removeIfPossible();
assertEquals(0, displayPolicy.getDecorInsetsInfo(di.rotation, di.logicalWidth,
di.logicalHeight).mNonDecorInsets.bottom);
}
@SetupWindows(addWindows = { W_NAVIGATION_BAR, W_INPUT_METHOD })