diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java index 721de613166ef..b1ef60185d8d7 100644 --- a/services/core/java/com/android/server/wm/AppWindowToken.java +++ b/services/core/java/com/android/server/wm/AppWindowToken.java @@ -1735,13 +1735,13 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree } /** @return {@code true} if the compatibility bounds is taking effect. */ - boolean inSizeCompatMode() { + boolean hasSizeCompatBounds() { return mSizeCompatBounds != null; } @Override float getSizeCompatScale() { - return inSizeCompatMode() ? mSizeCompatScale : super.getSizeCompatScale(); + return hasSizeCompatBounds() ? mSizeCompatScale : super.getSizeCompatScale(); } @Override diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 12def36019b0c..0844323e08fa2 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -221,7 +221,7 @@ import java.util.function.Predicate; * particular Display. */ class DisplayContent extends WindowContainer - implements WindowManagerPolicy.DisplayContentInfo { + implements WindowManagerPolicy.DisplayContentInfo, ConfigurationContainerListener { private static final String TAG = TAG_WITH_CLASS_NAME ? "DisplayContent" : TAG_WM; /** The default scaling mode that scales content automatically. */ @@ -1136,10 +1136,12 @@ class DisplayContent extends WindowContainer implements ConfigurationConta mResizeMode = resizeMode; mSupportsPictureInPicture = supportsPictureInPicture; mTaskRecord = taskRecord; + mTaskDescription = taskDescription; + + // Tasks have no set orientation value (including SCREEN_ORIENTATION_UNSPECIFIED). + setOrientation(SCREEN_ORIENTATION_UNSET); if (mTaskRecord != null) { // This can be null when we call createTaskInStack in WindowTestUtils. Remove this after // unification. mTaskRecord.registerConfigurationChangeListener(this); + } else { + setBounds(getResolvedOverrideBounds()); } - setBounds(getResolvedOverrideBounds()); - mTaskDescription = taskDescription; - - // Tasks have no set orientation value (including SCREEN_ORIENTATION_UNSPECIFIED) not unless - // set through the override configuration. - int orientation = SCREEN_ORIENTATION_UNSET; - switch (getResolvedOverrideConfiguration().orientation) { - case ORIENTATION_PORTRAIT: - orientation = SCREEN_ORIENTATION_PORTRAIT; - break; - case ORIENTATION_LANDSCAPE: - orientation = SCREEN_ORIENTATION_LANDSCAPE; - break; - } - setOrientation(orientation); } @Override diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 1270658dbedd7..82b9d460029d9 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -836,7 +836,7 @@ class WindowState extends WindowContainer implements WindowManagerP */ boolean inSizeCompatMode() { return (mAttrs.privateFlags & PRIVATE_FLAG_COMPATIBLE_WINDOW) != 0 - || (mAppToken != null && mAppToken.inSizeCompatMode() + || (mAppToken != null && mAppToken.hasSizeCompatBounds() // Exclude starting window because it is not displayed by the application. && mAttrs.type != TYPE_APPLICATION_STARTING); } @@ -2320,7 +2320,7 @@ class WindowState extends WindowContainer implements WindowManagerP } // The offset of compatibility bounds is applied to surface of {@link #AppWindowToken} // and frame, so it is unnecessary to translate twice in surface based coordinates. - final int surfaceOffsetX = mAppToken.inSizeCompatMode() + final int surfaceOffsetX = mAppToken.hasSizeCompatBounds() ? mAppToken.getBounds().left : 0; mTmpRect.offset(surfaceOffsetX - mWindowFrames.mFrame.left, -mWindowFrames.mFrame.top); region.set(mTmpRect); diff --git a/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java b/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java index fcda49472e8d8..26617355cfbfc 100644 --- a/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java @@ -221,7 +221,7 @@ public class AppWindowTokenTests extends WindowTestsBase { containerBounds.set(0, 0, 600, 800); mToken.onConfigurationChanged(newParentConfig); - assertTrue(mToken.inSizeCompatMode()); + assertTrue(mToken.hasSizeCompatBounds()); assertEquals(containerAppBounds, mToken.getBounds()); assertEquals((float) containerAppBounds.width() / fixedBounds.width(), mToken.getSizeCompatScale(), 0.0001f /* delta */); @@ -231,7 +231,7 @@ public class AppWindowTokenTests extends WindowTestsBase { containerBounds.set(containerAppBounds); mToken.onConfigurationChanged(newParentConfig); - assertTrue(mToken.inSizeCompatMode()); + assertTrue(mToken.hasSizeCompatBounds()); // Don't scale up, so the bounds keep the same as the fixed width. assertEquals(fixedBounds.width(), mToken.getBounds().width()); // Assert the position is horizontal center. @@ -243,7 +243,7 @@ public class AppWindowTokenTests extends WindowTestsBase { containerBounds.set(0, 0, 1200, 2000); mToken.onConfigurationChanged(newParentConfig); // Assert don't use fixed bounds because the region is enough. - assertFalse(mToken.inSizeCompatMode()); + assertFalse(mToken.hasSizeCompatBounds()); } @Test