Loading services/core/java/com/android/server/wm/ActivityRecord.java +9 −2 Original line number Diff line number Diff line Loading @@ -8087,6 +8087,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A final boolean orientationRequested = requestedOrientation != ORIENTATION_UNDEFINED; final int orientation = orientationRequested ? requestedOrientation // We should use the original orientation of the activity when possible to avoid // forcing the activity in the opposite orientation. : mCompatDisplayInsets.mOriginalRequestedOrientation != ORIENTATION_UNDEFINED ? mCompatDisplayInsets.mOriginalRequestedOrientation : newParentConfiguration.orientation; int rotation = newParentConfiguration.windowConfiguration.getRotation(); final boolean isFixedToUserRotation = mDisplayContent == null Loading Loading @@ -9356,8 +9360,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A * compatibility mode activity compute the configuration without relying on its current display. */ static class CompatDisplayInsets { /** The original rotation the compat insets were computed in */ /** The original rotation the compat insets were computed in. */ final @Rotation int mOriginalRotation; /** The original requested orientation for the activity. */ final @Configuration.Orientation int mOriginalRequestedOrientation; /** The container width on rotation 0. */ private final int mWidth; /** The container height on rotation 0. */ Loading Loading @@ -9386,6 +9392,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A @Nullable Rect fixedOrientationBounds) { mOriginalRotation = display.getRotation(); mIsFloating = container.getWindowConfiguration().tasksAreFloating(); mOriginalRequestedOrientation = container.getRequestedConfigurationOrientation(); if (mIsFloating) { final Rect containerBounds = container.getWindowConfiguration().getBounds(); mWidth = containerBounds.width(); Loading services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +21 −0 Original line number Diff line number Diff line Loading @@ -1528,6 +1528,27 @@ public class SizeCompatTests extends WindowTestsBase { newActivityBounds.width()); } @Test public void testDisplayIgnoreOrientationRequest_orientationChangedToUnspecified() { // Set up a display in landscape and ignoring orientation request. setUpDisplaySizeWithApp(2800, 1400); final DisplayContent display = mActivity.mDisplayContent; display.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); // Portrait fixed app without max aspect. prepareUnresizable(mActivity, 0, SCREEN_ORIENTATION_PORTRAIT); assertTrue(mActivity.isLetterboxedForFixedOrientationAndAspectRatio()); assertFalse(mActivity.inSizeCompatMode()); mActivity.setRequestedOrientation(SCREEN_ORIENTATION_UNSPECIFIED); assertTrue(mActivity.inSizeCompatMode()); // We should remember the original orientation. assertEquals(mActivity.getResolvedOverrideConfiguration().orientation, Configuration.ORIENTATION_PORTRAIT); } @Test public void testDisplayIgnoreOrientationRequest_newLaunchedMaxAspectApp() { // Set up a display in landscape and ignoring orientation request. Loading Loading
services/core/java/com/android/server/wm/ActivityRecord.java +9 −2 Original line number Diff line number Diff line Loading @@ -8087,6 +8087,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A final boolean orientationRequested = requestedOrientation != ORIENTATION_UNDEFINED; final int orientation = orientationRequested ? requestedOrientation // We should use the original orientation of the activity when possible to avoid // forcing the activity in the opposite orientation. : mCompatDisplayInsets.mOriginalRequestedOrientation != ORIENTATION_UNDEFINED ? mCompatDisplayInsets.mOriginalRequestedOrientation : newParentConfiguration.orientation; int rotation = newParentConfiguration.windowConfiguration.getRotation(); final boolean isFixedToUserRotation = mDisplayContent == null Loading Loading @@ -9356,8 +9360,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A * compatibility mode activity compute the configuration without relying on its current display. */ static class CompatDisplayInsets { /** The original rotation the compat insets were computed in */ /** The original rotation the compat insets were computed in. */ final @Rotation int mOriginalRotation; /** The original requested orientation for the activity. */ final @Configuration.Orientation int mOriginalRequestedOrientation; /** The container width on rotation 0. */ private final int mWidth; /** The container height on rotation 0. */ Loading Loading @@ -9386,6 +9392,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A @Nullable Rect fixedOrientationBounds) { mOriginalRotation = display.getRotation(); mIsFloating = container.getWindowConfiguration().tasksAreFloating(); mOriginalRequestedOrientation = container.getRequestedConfigurationOrientation(); if (mIsFloating) { final Rect containerBounds = container.getWindowConfiguration().getBounds(); mWidth = containerBounds.width(); Loading
services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +21 −0 Original line number Diff line number Diff line Loading @@ -1528,6 +1528,27 @@ public class SizeCompatTests extends WindowTestsBase { newActivityBounds.width()); } @Test public void testDisplayIgnoreOrientationRequest_orientationChangedToUnspecified() { // Set up a display in landscape and ignoring orientation request. setUpDisplaySizeWithApp(2800, 1400); final DisplayContent display = mActivity.mDisplayContent; display.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); // Portrait fixed app without max aspect. prepareUnresizable(mActivity, 0, SCREEN_ORIENTATION_PORTRAIT); assertTrue(mActivity.isLetterboxedForFixedOrientationAndAspectRatio()); assertFalse(mActivity.inSizeCompatMode()); mActivity.setRequestedOrientation(SCREEN_ORIENTATION_UNSPECIFIED); assertTrue(mActivity.inSizeCompatMode()); // We should remember the original orientation. assertEquals(mActivity.getResolvedOverrideConfiguration().orientation, Configuration.ORIENTATION_PORTRAIT); } @Test public void testDisplayIgnoreOrientationRequest_newLaunchedMaxAspectApp() { // Set up a display in landscape and ignoring orientation request. Loading