diff options
5 files changed, 22 insertions, 30 deletions
diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java index 721de613166e..b1ef60185d8d 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 12def36019b0..0844323e08fa 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<DisplayContent.DisplayChildWindowContainer> - 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<DisplayContent.DisplayChildWindowCo * values from being replaced by the initializing {@link #ActivityDisplay}. */ void initializeDisplayOverrideConfiguration() { - if (mActivityDisplay != null) { - mActivityDisplay.getRequestedOverrideConfiguration() - .updateFrom(getRequestedOverrideConfiguration()); + if (mActivityDisplay == null) { + return; } + mActivityDisplay.onRequestedOverrideConfigurationChanged( + getResolvedOverrideConfiguration()); + mActivityDisplay.registerConfigurationChangeListener(this); } void reconfigureDisplayLocked() { @@ -2373,6 +2375,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo void removeImmediately() { mRemovingDisplay = true; try { + if (mActivityDisplay != null) { + mActivityDisplay.unregisterConfigurationChangeListener(this); + } if (mParentWindow != null) { mParentWindow.removeEmbeddedDisplayContent(this); } diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 2ad91029212f..104fe5fb50cf 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -20,12 +20,8 @@ import static android.app.ActivityTaskManager.RESIZE_MODE_SYSTEM_SCREEN_ROTATION import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZABLE_LANDSCAPE_ONLY; import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZABLE_PORTRAIT_ONLY; import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZABLE_PRESERVE_ORIENTATION; -import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; -import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET; import static android.content.res.Configuration.EMPTY; -import static android.content.res.Configuration.ORIENTATION_LANDSCAPE; -import static android.content.res.Configuration.ORIENTATION_PORTRAIT; import static android.view.SurfaceControl.METADATA_TASK_ID; import static com.android.server.EventLogTags.WM_TASK_REMOVED; @@ -135,26 +131,17 @@ class Task extends WindowContainer<AppWindowToken> 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 1270658dbedd..82b9d460029d 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<WindowState> 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<WindowState> 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 fcda49472e8d..26617355cfbf 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 |