diff options
| author | 2024-11-26 14:13:14 +0800 | |
|---|---|---|
| committer | 2024-11-26 14:21:28 +0800 | |
| commit | b458c493c52c7ac3ccc0bffe548b2f5ec500c512 (patch) | |
| tree | 66bd1f31f31f31e224be5a67ae9a26201c554ee0 | |
| parent | b8debc693469dc3bbcaf74762534b3863ff8da70 (diff) | |
Make large screen display ignore orientation request by default
- Make the behavior consistent on large screen.
Enable ignore-orientation-request by smallestScreenWidthDp >= 600dp
It can still be overridden by shell command or display_settings.xml.
- The regular large screen devices already configure their
display_settings.xml with ignoreOrientationRequest="true".
This can reduce duplication of display_settings.xml for new large
screen devices every time.
- Make most tests of SizeCompatTests use default display. Because
it is more efficient than creating a new display. That may reduce
the test time by tens of seconds.
- Remove some incorrect assertDownScaled in SizeCompatTests which
should not apply compat scale, e.g. a 700x1400 activity in
a 2800x1400 display rotates to 1400x700. But it was accidentally
passed by the fallback scale DisplayContent#mCompatibleScreenScale
which is 0 on a TestDisplayContent.
Bug: 357141415
Flag: com.android.window.flags.universal_resizable_by_default
Test: atest SizeCompatTests
Change-Id: Id67309257d3af875ea6b2b2fb42c5fb5e01b9d6e
18 files changed, 182 insertions, 140 deletions
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index ef33ffe509b3..20a5f7a04649 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -3212,8 +3212,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A * will be ignored. */ boolean isUniversalResizeable() { - final boolean isLargeScreen = mDisplayContent != null && mDisplayContent.getConfiguration() - .smallestScreenWidthDp >= WindowManager.LARGE_SCREEN_SMALLEST_SCREEN_WIDTH_DP + final boolean isLargeScreen = mDisplayContent != null && mDisplayContent.isLargeScreen() && mDisplayContent.getIgnoreOrientationRequest(); if (!canBeUniversalResizeable(info.applicationInfo, mWmService, isLargeScreen, true /* forActivity */)) { diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 9a33df13bb6a..9fd1fb6c6c6b 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -438,6 +438,10 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp */ private boolean mSandboxDisplayApis = true; + /** Whether {@link #setIgnoreOrientationRequest} is called to override the default policy. */ + @VisibleForTesting + boolean mHasSetIgnoreOrientationRequest; + /** * Overridden display density for current user. Initialized with {@link #mInitialDisplayDensity} * but can be set from Settings or via shell command "adb shell wm density". @@ -6675,8 +6679,25 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp return mDisplayPolicy.getSystemUiContext(); } + /** Returns {@code} true if the smallest screen width dp >= 600. */ + boolean isLargeScreen() { + return getConfiguration().smallestScreenWidthDp + >= WindowManager.LARGE_SCREEN_SMALLEST_SCREEN_WIDTH_DP; + } + + @Override + boolean getIgnoreOrientationRequest() { + if (mHasSetIgnoreOrientationRequest + || !com.android.window.flags.Flags.universalResizableByDefault()) { + return super.getIgnoreOrientationRequest(); + } + // Large screen (sw >= 600dp) ignores orientation request by default. + return isLargeScreen() && !mWmService.isIgnoreOrientationRequestDisabled(); + } + @Override boolean setIgnoreOrientationRequest(boolean ignoreOrientationRequest) { + mHasSetIgnoreOrientationRequest = true; if (mSetIgnoreOrientationRequest == ignoreOrientationRequest) return false; final boolean rotationChanged = super.setIgnoreOrientationRequest(ignoreOrientationRequest); mWmService.mDisplayWindowSettings.setIgnoreOrientationRequest( diff --git a/services/core/java/com/android/server/wm/DisplayWindowSettings.java b/services/core/java/com/android/server/wm/DisplayWindowSettings.java index c87b811b4231..2fd9d570d0e3 100644 --- a/services/core/java/com/android/server/wm/DisplayWindowSettings.java +++ b/services/core/java/com/android/server/wm/DisplayWindowSettings.java @@ -374,9 +374,9 @@ class DisplayWindowSettings { final DisplayInfo displayInfo = dc.getDisplayInfo(); final SettingsProvider.SettingsEntry settings = mSettingsProvider.getSettings(displayInfo); - final boolean ignoreOrientationRequest = settings.mIgnoreOrientationRequest != null - ? settings.mIgnoreOrientationRequest : false; - dc.setIgnoreOrientationRequest(ignoreOrientationRequest); + if (settings.mIgnoreOrientationRequest != null) { + dc.setIgnoreOrientationRequest(settings.mIgnoreOrientationRequest); + } dc.getDisplayRotation().resetAllowAllRotations(); } diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java index fee646d9cb9c..51a03e30c249 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java @@ -554,6 +554,7 @@ public class ActivityRecordTests extends WindowTestsBase { @Test public void testSetRequestedOrientationUpdatesConfiguration() throws Exception { + mDisplayContent.setIgnoreOrientationRequest(false); final ActivityRecord activity = new ActivityBuilder(mAtm) .setCreateTask(true) .setConfigChanges(ORIENTATION_CONFIG_CHANGES) @@ -641,6 +642,7 @@ public class ActivityRecordTests extends WindowTestsBase { @Test public void ignoreRequestedOrientationForResizableInSplitWindows() { + mDisplayContent.setIgnoreOrientationRequest(false); final ActivityRecord activity = createActivityWith2LevelTask(); final Task task = activity.getTask(); final Task rootTask = activity.getRootTask(); @@ -685,6 +687,7 @@ public class ActivityRecordTests extends WindowTestsBase { @Test public void respectRequestedOrientationForNonResizableInSplitWindows() { + mDisplayContent.setIgnoreOrientationRequest(false); final TaskDisplayArea tda = mDisplayContent.getDefaultTaskDisplayArea(); spyOn(tda); doReturn(true).when(tda).supportsNonResizableMultiWindow(); @@ -1906,6 +1909,7 @@ public class ActivityRecordTests extends WindowTestsBase { @Test public void testActivityOnCancelFixedRotationTransform() { + mDisplayContent.setIgnoreOrientationRequest(false); final ActivityRecord activity = createActivityWithTask(); final DisplayRotation displayRotation = activity.mDisplayContent.getDisplayRotation(); final RemoteDisplayChangeController remoteDisplayChangeController = activity @@ -2054,6 +2058,7 @@ public class ActivityRecordTests extends WindowTestsBase { @Test public void testFixedRotationSnapshotStartingWindow() { + mDisplayContent.setIgnoreOrientationRequest(false); final ActivityRecord activity = createActivityWithTask(); // TaskSnapshotSurface requires a fullscreen opaque window. final WindowManager.LayoutParams params = new WindowManager.LayoutParams( @@ -2278,6 +2283,7 @@ public class ActivityRecordTests extends WindowTestsBase { @Test public void testSupportsFreeform() { final ActivityRecord activity = new ActivityBuilder(mAtm) + .setComponent(getUniqueComponentName(mContext.getPackageName())) .setCreateTask(true) .setResizeMode(ActivityInfo.RESIZE_MODE_UNRESIZEABLE) .setScreenOrientation(SCREEN_ORIENTATION_LANDSCAPE) @@ -2410,6 +2416,7 @@ public class ActivityRecordTests extends WindowTestsBase { @Test public void testOrientationForScreenOrientationBehind() { + mDisplayContent.setIgnoreOrientationRequest(false); final Task task = createTask(mDisplayContent); // Activity below new ActivityBuilder(mAtm) @@ -2507,6 +2514,7 @@ public class ActivityRecordTests extends WindowTestsBase { @SetupWindows(addWindows = W_ACTIVITY) @Test public void testLandscapeSeascapeRotationByApp() { + mDisplayContent.setIgnoreOrientationRequest(false); final Task task = new TaskBuilder(mSupervisor) .setDisplay(mDisplayContent).setCreateActivity(true).build(); final ActivityRecord activity = task.getTopNonFinishingActivity(); @@ -2572,6 +2580,7 @@ public class ActivityRecordTests extends WindowTestsBase { @Test @Presubmit public void testGetOrientation() { + mDisplayContent.setIgnoreOrientationRequest(false); // ActivityBuilder will resume top activities and cause the activity been added into // opening apps list. Since this test is focus on the effect of visible on getting // orientation, we skip app transition to avoid interference. @@ -2663,8 +2672,8 @@ public class ActivityRecordTests extends WindowTestsBase { @Test public void testSetOrientation_restrictedByTargetSdk() { mSetFlagsRule.enableFlags(Flags.FLAG_UNIVERSAL_RESIZABLE_BY_DEFAULT); - mDisplayContent.setIgnoreOrientationRequest(true); makeDisplayLargeScreen(mDisplayContent); + assertTrue(mDisplayContent.getIgnoreOrientationRequest()); assertSetOrientation(Build.VERSION_CODES.CUR_DEVELOPMENT, CATEGORY_SOCIAL, false); assertSetOrientation(Build.VERSION_CODES.CUR_DEVELOPMENT, CATEGORY_GAME, true); @@ -2702,6 +2711,7 @@ public class ActivityRecordTests extends WindowTestsBase { @Test public void testRespectTopFullscreenOrientation() { + mDisplayContent.setIgnoreOrientationRequest(false); final ActivityRecord activity = new ActivityBuilder(mAtm).setCreateTask(true).build(); final Configuration displayConfig = activity.mDisplayContent.getConfiguration(); final Configuration activityConfig = activity.getConfiguration(); diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java index e0b29c937381..1cb1e3cae413 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java @@ -511,6 +511,7 @@ public class ActivityTaskManagerServiceTests extends WindowTestsBase { @Test public void testSupportsMultiWindow_nonResizable() { final ActivityRecord activity = new ActivityBuilder(mAtm) + .setComponent(getUniqueComponentName(mContext.getPackageName())) .setCreateTask(true) .setResizeMode(RESIZE_MODE_UNRESIZEABLE) .build(); diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayAreaGroupTest.java b/services/tests/wmtests/src/com/android/server/wm/DisplayAreaGroupTest.java index 87dbca51e24e..060b379c1281 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayAreaGroupTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayAreaGroupTest.java @@ -84,6 +84,7 @@ public class DisplayAreaGroupTest extends WindowTestsBase { @Test public void testGetRequestedOrientationForDisplay() { + mDisplayContent.setIgnoreOrientationRequest(false); final Task task = new TaskBuilder(mSupervisor) .setTaskDisplayArea(mTaskDisplayArea).setCreateActivity(true).build(); final ActivityRecord activity = task.getTopNonFinishingActivity(); diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayAreaTest.java b/services/tests/wmtests/src/com/android/server/wm/DisplayAreaTest.java index 7b2cd63b4afb..0a7df5a305bc 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayAreaTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayAreaTest.java @@ -491,6 +491,7 @@ public class DisplayAreaTest extends WindowTestsBase { @Test public void testSetIgnoreOrientationRequest_callSuperOnDescendantOrientationChangedNoSensor() { final TaskDisplayArea tda = mDisplayContent.getDefaultTaskDisplayArea(); + mDisplayContent.setIgnoreOrientationRequest(false); final Task stack = new TaskBuilder(mSupervisor).setOnTop(!ON_TOP).setCreateActivity(true).build(); final ActivityRecord activity = stack.getTopNonFinishingActivity(); diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java index 9408f907d058..317258eaf25a 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java @@ -898,6 +898,7 @@ public class DisplayContentTests extends WindowTestsBase { public void testOrientationDefinedByKeyguard() { final DisplayContent dc = mDisplayContent; dc.getDisplayPolicy().setAwake(true); + dc.setIgnoreOrientationRequest(false); // Create a window that requests landscape orientation. It will define device orientation // by default. @@ -925,6 +926,7 @@ public class DisplayContentTests extends WindowTestsBase { @Test public void testOrientationForAspectRatio() { final DisplayContent dc = createNewDisplay(); + dc.setIgnoreOrientationRequest(false); // When display content is created its configuration is not yet initialized, which could // cause unnecessary configuration propagation, so initialize it here. @@ -1034,6 +1036,7 @@ public class DisplayContentTests extends WindowTestsBase { @Test public void testAllowsTopmostFullscreenOrientation() { final DisplayContent dc = createNewDisplay(); + dc.setIgnoreOrientationRequest(false); assertEquals(SCREEN_ORIENTATION_UNSPECIFIED, dc.getOrientation()); dc.getDisplayRotation().setFixedToUserRotation( IWindowManager.FIXED_TO_USER_ROTATION_DISABLED); @@ -1112,6 +1115,7 @@ public class DisplayContentTests extends WindowTestsBase { @Test public void testOnDescendantOrientationRequestChanged() { final DisplayContent dc = createNewDisplay(); + dc.setIgnoreOrientationRequest(false); dc.getDisplayRotation().setFixedToUserRotation( IWindowManager.FIXED_TO_USER_ROTATION_DISABLED); dc.getDefaultTaskDisplayArea().setWindowingMode(WINDOWING_MODE_FULLSCREEN); @@ -1130,6 +1134,7 @@ public class DisplayContentTests extends WindowTestsBase { @Test public void testOnDescendantOrientationRequestChanged_FrozenToUserRotation() { final DisplayContent dc = createNewDisplay(); + dc.setIgnoreOrientationRequest(false); dc.getDisplayRotation().setFixedToUserRotation( IWindowManager.FIXED_TO_USER_ROTATION_ENABLED); dc.getDisplayRotation().setUserRotation( @@ -1152,6 +1157,7 @@ public class DisplayContentTests extends WindowTestsBase { @Test public void testOrientationBehind() { assertNull(mDisplayContent.getLastOrientationSource()); + mDisplayContent.setIgnoreOrientationRequest(false); final ActivityRecord prev = new ActivityBuilder(mAtm).setCreateTask(true) .setScreenOrientation(getRotatedOrientation(mDisplayContent)).build(); prev.setVisibleRequested(false); @@ -1172,6 +1178,7 @@ public class DisplayContentTests extends WindowTestsBase { @Test public void testFixedToUserRotationChanged() { final DisplayContent dc = createNewDisplay(); + dc.setIgnoreOrientationRequest(false); dc.getDisplayRotation().setFixedToUserRotation( IWindowManager.FIXED_TO_USER_ROTATION_ENABLED); dc.getDisplayRotation().setUserRotation( @@ -1589,6 +1596,7 @@ public class DisplayContentTests extends WindowTestsBase { W_INPUT_METHOD, W_NOTIFICATION_SHADE }) @Test public void testApplyTopFixedRotationTransform() { + mDisplayContent.setIgnoreOrientationRequest(false); final DisplayPolicy displayPolicy = mDisplayContent.getDisplayPolicy(); spyOn(displayPolicy); // Only non-movable (gesture) navigation bar will be animated by fixed rotation animation. @@ -1742,6 +1750,7 @@ public class DisplayContentTests extends WindowTestsBase { @Test public void testFixedRotationWithPip() { final DisplayContent displayContent = mDefaultDisplay; + displayContent.setIgnoreOrientationRequest(false); unblockDisplayRotation(displayContent); // Unblock the condition in PinnedTaskController#continueOrientationChangeIfNeeded. doNothing().when(displayContent).prepareAppTransition(anyInt()); diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayRotationImmersiveAppCompatPolicyTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayRotationImmersiveAppCompatPolicyTests.java index 63973345b5fb..6527af1ec704 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayRotationImmersiveAppCompatPolicyTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayRotationImmersiveAppCompatPolicyTests.java @@ -77,7 +77,7 @@ public class DisplayRotationImmersiveAppCompatPolicyTests extends WindowTestsBas when(mMockActivityRecord.findMainWindow()).thenReturn(mMockWindowState); doReturn(mMockActivityRecord).when(mDisplayContent).topRunningActivity(); - when(mDisplayContent.getIgnoreOrientationRequest()).thenReturn(true); + mDisplayContent.setIgnoreOrientationRequest(true); mMockAppCompatConfiguration = mock(AppCompatConfiguration.class); when(mMockAppCompatConfiguration.isDisplayRotationImmersiveAppCompatPolicyEnabled()) @@ -195,7 +195,7 @@ public class DisplayRotationImmersiveAppCompatPolicyTests extends WindowTestsBas @Test public void testIsRotationLockEnforced_ignoreOrientationRequestDisabled_lockNotEnforced() { - when(mDisplayContent.getIgnoreOrientationRequest()).thenReturn(false); + mDisplayContent.setIgnoreOrientationRequest(false); assertIsRotationLockEnforcedReturnsFalseForAllRotations(); } diff --git a/services/tests/wmtests/src/com/android/server/wm/DualDisplayAreaGroupPolicyTest.java b/services/tests/wmtests/src/com/android/server/wm/DualDisplayAreaGroupPolicyTest.java index 708d6860abc2..bd15bc42e811 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DualDisplayAreaGroupPolicyTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/DualDisplayAreaGroupPolicyTest.java @@ -106,6 +106,8 @@ public class DualDisplayAreaGroupPolicyTest extends WindowTestsBase { // Display: 1920x1200 (landscape). First and second display are both 860x1200 (portrait). mDisplay = new DualDisplayContent.Builder(mAtm, 1920, 1200).build(); + // The test verifies that the display area can affect display's getLastOrientation(). + mDisplay.setIgnoreOrientationRequest(false); mFirstRoot = mDisplay.mFirstRoot; mSecondRoot = mDisplay.mSecondRoot; mFirstTda = mDisplay.getTaskDisplayArea(FEATURE_FIRST_TASK_CONTAINER); diff --git a/services/tests/wmtests/src/com/android/server/wm/RootTaskTests.java b/services/tests/wmtests/src/com/android/server/wm/RootTaskTests.java index 7cb62c5a6769..d96512588c7c 100644 --- a/services/tests/wmtests/src/com/android/server/wm/RootTaskTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/RootTaskTests.java @@ -132,6 +132,7 @@ public class RootTaskTests extends WindowTestsBase { @Test public void testClosingAppDifferentTaskOrientation() { + mDisplayContent.setIgnoreOrientationRequest(false); final ActivityRecord activity1 = createActivityRecord(mDisplayContent); activity1.setOrientation(SCREEN_ORIENTATION_LANDSCAPE); @@ -146,6 +147,7 @@ public class RootTaskTests extends WindowTestsBase { @Test public void testMoveTaskToBackDifferentTaskOrientation() { + mDisplayContent.setIgnoreOrientationRequest(false); final ActivityRecord activity1 = createActivityRecord(mDisplayContent); activity1.setOrientation(SCREEN_ORIENTATION_LANDSCAPE); diff --git a/services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java b/services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java index 7e8bd38fb6a9..023cc552846b 100644 --- a/services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java @@ -693,6 +693,7 @@ public class RootWindowContainerTests extends WindowTestsBase { @Test public void testAwakeFromSleepingWithAppConfiguration() { final DisplayContent display = mRootWindowContainer.getDefaultDisplay(); + display.setIgnoreOrientationRequest(false); final ActivityRecord activity = new ActivityBuilder(mAtm).setCreateTask(true).build(); activity.moveFocusableActivityToTop("test"); assertTrue(activity.getRootTask().isFocusedRootTaskOnDisplay()); diff --git a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java index 87db6c0e8577..a1cd0f7d96ae 100644 --- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java @@ -107,6 +107,8 @@ import android.platform.test.annotations.EnableFlags; import android.platform.test.annotations.Presubmit; import android.provider.DeviceConfig; import android.provider.DeviceConfig.Properties; +import android.view.DisplayCutout; +import android.view.DisplayInfo; import android.view.InsetsFrameProvider; import android.view.InsetsSource; import android.view.InsetsState; @@ -210,6 +212,37 @@ public class SizeCompatTests extends WindowTestsBase { return setUpApp(builder.build(), appBuilder); } + private void setUpLargeScreenDisplayWithApp(int dw, int dh) { + final DisplayContent display = mDisplayContent; + final DisplayInfo displayInfo = display.getDisplayInfo(); + displayInfo.logicalWidth = dw; + displayInfo.logicalHeight = dh; + // Prevent legacy sdk from being affected by INSETS_DECOUPLED_CONFIGURATION_ENFORCED. + display.mInitialDisplayCutout = displayInfo.displayCutout = DisplayCutout.NO_CUTOUT; + // Smallest screen width=747dp according to 1400/(300/160). + display.mBaseDisplayDensity = displayInfo.logicalDensityDpi = + TestDisplayContent.DEFAULT_LOGICAL_DISPLAY_DENSITY; + doNothing().when(display).updateDisplayInfo(any()); + resizeDisplay(display, displayInfo.logicalWidth, displayInfo.logicalHeight); + assertTrue(display.isLargeScreen()); + if (com.android.window.flags.Flags.universalResizableByDefault()) { + assertTrue("Large screen must ignore orientation request", + display.getIgnoreOrientationRequest()); + } else { + display.setIgnoreOrientationRequest(true); + } + setUpApp(display, null /* appBuilder */); + spyOn(display.getDisplayRotation()); + } + + private void setUpLandscapeLargeScreenDisplayWithApp() { + setUpLargeScreenDisplayWithApp(/* dw */ 2800, /* dh */ 1400); + } + + private void setUpPortraitLargeScreenDisplayWithApp() { + setUpLargeScreenDisplayWithApp(/* dw */ 1400, /* dh */ 2800); + } + @Test public void testHorizontalReachabilityEnabledForTranslucentActivities() { testReachabilityEnabledForTranslucentActivity(/* dw */ 2500, /* dh */1000, @@ -658,9 +691,7 @@ public class SizeCompatTests extends WindowTestsBase { @Test public void testIsLetterboxed_activityFromBubble_returnsFalse() { - setUpDisplaySizeWithApp(1000, 2500); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); - spyOn(mActivity); + setUpPortraitLargeScreenDisplayWithApp(); doReturn(true).when(mActivity).getLaunchedFromBubble(); prepareUnresizable(mActivity, SCREEN_ORIENTATION_LANDSCAPE); @@ -1694,10 +1725,9 @@ public class SizeCompatTests extends WindowTestsBase { @Test public void testGetLetterboxInnerBounds_noScalingApplied() { // Set up a display in portrait and ignoring orientation request. - final int dw = 1400; - final int dh = 2800; - setUpDisplaySizeWithApp(dw, dh); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + setUpPortraitLargeScreenDisplayWithApp(); + final int dw = mDisplayContent.mBaseDisplayWidth; + final int dh = mDisplayContent.mBaseDisplayHeight; // Rotate display to landscape. rotateDisplay(mActivity.mDisplayContent, ROTATION_90); @@ -1823,8 +1853,7 @@ public class SizeCompatTests extends WindowTestsBase { @Test public void testDisplayIgnoreOrientationRequest_fixedOrientationAppLaunchedLetterbox() { // Set up a display in landscape and ignoring orientation request. - setUpDisplaySizeWithApp(2800, 1400); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + setUpLandscapeLargeScreenDisplayWithApp(); // Portrait fixed app without max aspect. prepareUnresizable(mActivity, /* maxAspect= */ 0, SCREEN_ORIENTATION_PORTRAIT); @@ -1852,8 +1881,7 @@ public class SizeCompatTests extends WindowTestsBase { @Test public void testDisplayIgnoreOrientationRequest_fixedOrientationAppRespectMinAspectRatio() { // Set up a display in landscape and ignoring orientation request. - setUpDisplaySizeWithApp(2800, 1400); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + setUpLandscapeLargeScreenDisplayWithApp(); // Portrait fixed app with min aspect ratio higher that aspect ratio override for fixed // orientation letterbox. @@ -1884,8 +1912,7 @@ public class SizeCompatTests extends WindowTestsBase { @Test public void testDisplayIgnoreOrientationRequest_fixedOrientationAppRespectMaxAspectRatio() { // Set up a display in landscape and ignoring orientation request. - setUpDisplaySizeWithApp(2800, 1400); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + setUpLandscapeLargeScreenDisplayWithApp(); // Portrait fixed app with max aspect ratio lower that aspect ratio override for fixed // orientation letterbox. @@ -1915,8 +1942,7 @@ public class SizeCompatTests extends WindowTestsBase { @Test public void testDisplayIgnoreOrientationRequest_fixedOrientationAppWithAspectRatioOverride() { // Set up a display in landscape and ignoring orientation request. - setUpDisplaySizeWithApp(2800, 1400); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + setUpLandscapeLargeScreenDisplayWithApp(); final float fixedOrientationLetterboxAspectRatio = 1.1f; mActivity.mWmService.mAppCompatConfiguration.setFixedOrientationLetterboxAspectRatio( @@ -2011,8 +2037,7 @@ public class SizeCompatTests extends WindowTestsBase { @Test public void testDisplayIgnoreOrientationRequest_unresizableWithCorrespondingMinAspectRatio() { // Set up a display in landscape and ignoring orientation request. - setUpDisplaySizeWithApp(2800, 1400); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + setUpLandscapeLargeScreenDisplayWithApp(); final float fixedOrientationLetterboxAspectRatio = 1.1f; mActivity.mWmService.mAppCompatConfiguration.setFixedOrientationLetterboxAspectRatio( @@ -2045,13 +2070,10 @@ public class SizeCompatTests extends WindowTestsBase { @Test public void testComputeConfigResourceOverrides_unresizableApp() { // Set up a display in landscape and ignoring orientation request. - setUpDisplaySizeWithApp(2800, 1400); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + setUpLandscapeLargeScreenDisplayWithApp(); prepareUnresizable(mActivity, SCREEN_ORIENTATION_PORTRAIT); - final Rect activityBounds = new Rect(mActivity.getBounds()); - int originalScreenWidthDp = mActivity.getConfiguration().screenWidthDp; int originalScreenHeighthDp = mActivity.getConfiguration().screenHeightDp; @@ -2068,7 +2090,7 @@ public class SizeCompatTests extends WindowTestsBase { // After we rotate, the activity should go in the size-compat mode and report the same // configuration values. - assertDownScaled(); + assertThat(mActivity.inSizeCompatMode()).isTrue(); assertEquals(originalScreenWidthDp, mActivity.getConfiguration().smallestScreenWidthDp); assertEquals(originalScreenWidthDp, mActivity.getConfiguration().screenWidthDp); assertEquals(originalScreenHeighthDp, mActivity.getConfiguration().screenHeightDp); @@ -2087,14 +2109,11 @@ public class SizeCompatTests extends WindowTestsBase { @Test public void testComputeConfigResourceOverrides_resizableFixedOrientationActivity() { // Set up a display in landscape and ignoring orientation request. - setUpDisplaySizeWithApp(2800, 1400); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + setUpLandscapeLargeScreenDisplayWithApp(); // Portrait fixed app without max aspect. prepareLimitedBounds(mActivity, SCREEN_ORIENTATION_PORTRAIT, false /* isUnresizable */); - final Rect activityBounds = new Rect(mActivity.getBounds()); - int originalScreenWidthDp = mActivity.getConfiguration().screenWidthDp; int originalScreenHeighthDp = mActivity.getConfiguration().screenHeightDp; @@ -2206,10 +2225,10 @@ public class SizeCompatTests extends WindowTestsBase { @Test public void testSystemFullscreenOverrideForLandscapeDisplay() { - final int displayWidth = 1600; - final int displayHeight = 1400; - setUpDisplaySizeWithApp(displayWidth, displayHeight); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + setUpLandscapeLargeScreenDisplayWithApp(); + final int displayWidth = mDisplayContent.mBaseDisplayWidth; + final int displayHeight = mDisplayContent.mBaseDisplayHeight; + spyOn(mActivity.mAppCompatController.getAppCompatAspectRatioOverrides()); doReturn(true).when( mActivity.mAppCompatController.getAppCompatAspectRatioOverrides()) @@ -2226,10 +2245,10 @@ public class SizeCompatTests extends WindowTestsBase { @Test public void testSystemFullscreenOverrideForPortraitDisplay() { - final int displayWidth = 1400; - final int displayHeight = 1600; - setUpDisplaySizeWithApp(displayWidth, displayHeight); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + setUpPortraitLargeScreenDisplayWithApp(); + final int displayWidth = mDisplayContent.mBaseDisplayWidth; + final int displayHeight = mDisplayContent.mBaseDisplayHeight; + spyOn(mActivity.mAppCompatController.getAppCompatAspectRatioOverrides()); doReturn(true).when( mActivity.mAppCompatController.getAppCompatAspectRatioOverrides()) @@ -2619,7 +2638,7 @@ public class SizeCompatTests extends WindowTestsBase { @EnableCompatChanges({ActivityInfo.OVERRIDE_RESPECT_REQUESTED_ORIENTATION}) public void testOverrideRespectRequestedOrientationIsEnabled_orientationIsRespected() { // Set up a display in landscape - setUpDisplaySizeWithApp(2800, 1400); + setUpDisplaySizeWithApp(1000, 500); final ActivityRecord activity = buildActivityRecord(/* supportsSizeChanges= */ false, RESIZE_MODE_UNRESIZEABLE, SCREEN_ORIENTATION_PORTRAIT); @@ -2636,7 +2655,7 @@ public class SizeCompatTests extends WindowTestsBase { @EnableCompatChanges({ActivityInfo.OVERRIDE_RESPECT_REQUESTED_ORIENTATION}) public void testOverrideRespectRequestedOrientationIsEnabled_multiWindow_orientationIgnored() { // Set up a display in landscape - setUpDisplaySizeWithApp(2800, 1400); + setUpDisplaySizeWithApp(1000, 500); final ActivityRecord activity = buildActivityRecord(/* supportsSizeChanges= */ false, RESIZE_MODE_UNRESIZEABLE, SCREEN_ORIENTATION_PORTRAIT); @@ -2655,10 +2674,9 @@ public class SizeCompatTests extends WindowTestsBase { @Test public void testSplitAspectRatioForUnresizableLandscapeApps() { // Set up a display in portrait and ignoring orientation request. - int screenWidth = 1400; - int screenHeight = 1600; - setUpDisplaySizeWithApp(screenWidth, screenHeight); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + setUpLargeScreenDisplayWithApp(1400, 2400); + final int screenWidth = mDisplayContent.mBaseDisplayWidth; + final int screenHeight = mDisplayContent.mBaseDisplayHeight; mActivity.mWmService.mAppCompatConfiguration .setIsSplitScreenAspectRatioForUnresizableAppsEnabled(true); @@ -2692,10 +2710,9 @@ public class SizeCompatTests extends WindowTestsBase { @Test public void testDisplayAspectRatioForResizablePortraitApps() { // Set up a display in portrait and ignoring orientation request. - int displayWidth = 1400; - int displayHeight = 1600; - setUpDisplaySizeWithApp(displayWidth, displayHeight); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + setUpLargeScreenDisplayWithApp(1400, 2400); + final int displayWidth = mDisplayContent.mBaseDisplayWidth; + final int displayHeight = mDisplayContent.mBaseDisplayHeight; mWm.mAppCompatConfiguration.setFixedOrientationLetterboxAspectRatio(2f); // Enable display aspect ratio to take precedence before @@ -2728,10 +2745,9 @@ public class SizeCompatTests extends WindowTestsBase { @Test public void testDisplayAspectRatioForResizableLandscapeApps() { // Set up a display in landscape and ignoring orientation request. - int displayWidth = 1600; - int displayHeight = 1400; - setUpDisplaySizeWithApp(displayWidth, displayHeight); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + setUpLandscapeLargeScreenDisplayWithApp(); + final int displayWidth = mDisplayContent.mBaseDisplayWidth; + final int displayHeight = mDisplayContent.mBaseDisplayHeight; mWm.mAppCompatConfiguration.setFixedOrientationLetterboxAspectRatio(2f); // Enable display aspect ratio to take precedence before @@ -2764,10 +2780,9 @@ public class SizeCompatTests extends WindowTestsBase { @Test public void testDisplayAspectRatioForUnresizableLandscapeApps() { // Set up a display in portrait and ignoring orientation request. - int displayWidth = 1400; - int displayHeight = 1600; - setUpDisplaySizeWithApp(displayWidth, displayHeight); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + setUpPortraitLargeScreenDisplayWithApp(); + final int displayWidth = mDisplayContent.mBaseDisplayWidth; + final int displayHeight = mDisplayContent.mBaseDisplayHeight; mActivity.mWmService.mAppCompatConfiguration.setFixedOrientationLetterboxAspectRatio(1.1f); // Enable display aspect ratio to take precedence before @@ -2791,10 +2806,9 @@ public class SizeCompatTests extends WindowTestsBase { @Test public void testDisplayAspectRatioForUnresizablePortraitApps() { // Set up a display in landscape and ignoring orientation request. - int displayWidth = 1600; - int displayHeight = 1400; - setUpDisplaySizeWithApp(displayWidth, displayHeight); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + setUpLandscapeLargeScreenDisplayWithApp(); + final int displayWidth = mDisplayContent.mBaseDisplayWidth; + final int displayHeight = mDisplayContent.mBaseDisplayHeight; mActivity.mWmService.mAppCompatConfiguration.setFixedOrientationLetterboxAspectRatio(1.1f); // Enable display aspect ratio to take precedence before @@ -2819,8 +2833,7 @@ public class SizeCompatTests extends WindowTestsBase { public void testDisplayIgnoreOrientationRequest_orientationLetterboxBecameSizeCompatAfterRotate() { // Set up a display in landscape and ignoring orientation request. - setUpDisplaySizeWithApp(2800, 1400); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + setUpLandscapeLargeScreenDisplayWithApp(); // Portrait fixed app without max aspect. prepareUnresizable(mActivity, 0, SCREEN_ORIENTATION_PORTRAIT); @@ -2837,7 +2850,7 @@ public class SizeCompatTests extends WindowTestsBase { // App should be in size compat. assertFalse(mActivity.mAppCompatController.getAppCompatAspectRatioPolicy() .isLetterboxedForFixedOrientationAndAspectRatio()); - assertDownScaled(); + assertThat(mActivity.inSizeCompatMode()).isTrue(); assertEquals(activityBounds.width(), newActivityBounds.width()); assertEquals(activityBounds.height(), newActivityBounds.height()); assertActivityMaxBoundsSandboxed(); @@ -2846,8 +2859,7 @@ public class SizeCompatTests extends WindowTestsBase { @Test public void testDisplayIgnoreOrientationRequest_sizeCompatAfterRotate() { // Set up a display in portrait and ignoring orientation request. - setUpDisplaySizeWithApp(1400, 2800); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + setUpPortraitLargeScreenDisplayWithApp(); // Portrait fixed app without max aspect. prepareUnresizable(mActivity, 0, SCREEN_ORIENTATION_PORTRAIT); @@ -2882,9 +2894,8 @@ public class SizeCompatTests extends WindowTestsBase { @Test public void testDisplayIgnoreOrientationRequest_newLaunchedOrientationAppInLetterbox() { // Set up a display in landscape and ignoring orientation request. - setUpDisplaySizeWithApp(2800, 1400); + setUpLandscapeLargeScreenDisplayWithApp(); final DisplayContent display = mActivity.mDisplayContent; - display.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); // Portrait fixed app without max aspect. prepareUnresizable(mActivity, 0, SCREEN_ORIENTATION_PORTRAIT); @@ -2928,9 +2939,7 @@ public class SizeCompatTests extends WindowTestsBase { @EnableCompatChanges({ActivityInfo.OVERRIDE_ENABLE_INSETS_DECOUPLED_CONFIGURATION}) 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 */); + setUpLandscapeLargeScreenDisplayWithApp(); // Portrait fixed app without max aspect. prepareUnresizable(mActivity, 0, SCREEN_ORIENTATION_PORTRAIT); @@ -2950,9 +2959,8 @@ public class SizeCompatTests extends WindowTestsBase { @Test public void testDisplayIgnoreOrientationRequest_newLaunchedMaxAspectApp() { // Set up a display in landscape and ignoring orientation request. - setUpDisplaySizeWithApp(2800, 1400); + setUpLandscapeLargeScreenDisplayWithApp(); final DisplayContent display = mActivity.mDisplayContent; - display.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); // Portrait fixed app without max aspect. prepareUnresizable(mActivity, 0, SCREEN_ORIENTATION_PORTRAIT); @@ -3001,9 +3009,7 @@ public class SizeCompatTests extends WindowTestsBase { @SuppressWarnings("GuardedBy") public void testDisplayIgnoreOrientationRequest_pausedAppNotLostSizeCompat() { // Set up a display in landscape and ignoring orientation request. - setUpDisplaySizeWithApp(2800, 1400); - final DisplayContent display = mActivity.mDisplayContent; - display.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + setUpLandscapeLargeScreenDisplayWithApp(); // Portrait fixed app. prepareUnresizable(mActivity, 0, SCREEN_ORIENTATION_PORTRAIT); @@ -3019,7 +3025,6 @@ public class SizeCompatTests extends WindowTestsBase { // App should be in size compat. assertFalse(mActivity.mAppCompatController.getAppCompatAspectRatioPolicy() .isLetterboxedForFixedOrientationAndAspectRatio()); - assertDownScaled(); assertThat(mActivity.inSizeCompatMode()).isTrue(); // Activity max bounds are sandboxed due to size compat mode. assertActivityMaxBoundsSandboxed(); @@ -3035,7 +3040,7 @@ public class SizeCompatTests extends WindowTestsBase { verify(scmPolicy, never()).clearSizeCompatMode(); assertFalse(mActivity.mAppCompatController.getAppCompatAspectRatioPolicy() .isLetterboxedForFixedOrientationAndAspectRatio()); - assertDownScaled(); + assertThat(mActivity.inSizeCompatMode()).isTrue(); assertEquals(activityBounds, mActivity.getBounds()); // Activity max bounds are sandboxed due to size compat. assertActivityMaxBoundsSandboxed(); @@ -3044,9 +3049,8 @@ public class SizeCompatTests extends WindowTestsBase { @Test public void testDisplayIgnoreOrientationRequest_rotated180_notInSizeCompat() { // Set up a display in landscape and ignoring orientation request. - setUpDisplaySizeWithApp(2800, 1400); + setUpLandscapeLargeScreenDisplayWithApp(); final DisplayContent display = mActivity.mDisplayContent; - display.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); // Portrait fixed app. prepareUnresizable(mActivity, 0, SCREEN_ORIENTATION_PORTRAIT); @@ -3063,7 +3067,7 @@ public class SizeCompatTests extends WindowTestsBase { // App should be in size compat. assertFalse(mActivity.mAppCompatController.getAppCompatAspectRatioPolicy() .isLetterboxedForFixedOrientationAndAspectRatio()); - assertDownScaled(); + assertThat(mActivity.inSizeCompatMode()).isTrue(); assertActivityMaxBoundsSandboxed(); // Rotate display to landscape. @@ -3246,8 +3250,9 @@ public class SizeCompatTests extends WindowTestsBase { @Test public void testTaskDisplayAreaNotFillDisplay() { - setUpDisplaySizeWithApp(1400, 2800); + setUpPortraitLargeScreenDisplayWithApp(); final DisplayContent display = mActivity.mDisplayContent; + display.setIgnoreOrientationRequest(false); final TaskDisplayArea taskDisplayArea = mActivity.getDisplayArea(); taskDisplayArea.setBounds(0, 0, 1000, 2400); @@ -3430,8 +3435,7 @@ public class SizeCompatTests extends WindowTestsBase { @Test public void testIsHorizontalReachabilityEnabled_splitScreen_false() { mAtm.mDevEnableNonResizableMultiWindow = true; - setUpDisplaySizeWithApp(2800, 1000); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + setUpLandscapeLargeScreenDisplayWithApp(); mWm.mAppCompatConfiguration.setIsHorizontalReachabilityEnabled(true); setUpAllowThinLetterboxed(/* thinLetterboxAllowed */ true); final TestSplitOrganizer organizer = @@ -3518,8 +3522,7 @@ public class SizeCompatTests extends WindowTestsBase { @Test public void testIsHorizontalReachabilityEnabled_emptyBounds_true() { - setUpDisplaySizeWithApp(/* dw */ 2800, /* dh */ 1000); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + setUpLandscapeLargeScreenDisplayWithApp(); mWm.mAppCompatConfiguration.setIsHorizontalReachabilityEnabled(true); setUpAllowThinLetterboxed(/* thinLetterboxAllowed */ true); @@ -3566,8 +3569,7 @@ public class SizeCompatTests extends WindowTestsBase { @Test public void testIsHorizontalReachabilityEnabled_doesNotMatchParentHeight_false() { - setUpDisplaySizeWithApp(2800, 1000); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + setUpLandscapeLargeScreenDisplayWithApp(); mWm.mAppCompatConfiguration.setIsHorizontalReachabilityEnabled(true); setUpAllowThinLetterboxed(/* thinLetterboxAllowed */ true); @@ -3787,12 +3789,10 @@ public class SizeCompatTests extends WindowTestsBase { } private void assertLandscapeActivityAlignedToBottomWithNavbar(boolean immersive) { - final int screenHeight = 2800; - final int screenWidth = 1400; + setUpPortraitLargeScreenDisplayWithApp(); + final int screenHeight = mDisplayContent.mBaseDisplayHeight; + final int screenWidth = mDisplayContent.mBaseDisplayWidth; final int taskbarHeight = 200; - setUpDisplaySizeWithApp(screenWidth, screenHeight); - - mActivity.mDisplayContent.setIgnoreOrientationRequest(true); mActivity.mWmService.mAppCompatConfiguration.setLetterboxVerticalPositionMultiplier(1.0f); final InsetsSource navSource = new InsetsSource( @@ -3972,8 +3972,7 @@ public class SizeCompatTests extends WindowTestsBase { float letterboxHorizontalPositionMultiplier, Rect fixedOrientationLetterbox, Rect sizeCompatUnscaled, Rect sizeCompatScaled) { // Set up a display in landscape and ignoring orientation request. - setUpDisplaySizeWithApp(2800, 1400); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + setUpLandscapeLargeScreenDisplayWithApp(); mActivity.mWmService.mAppCompatConfiguration.setLetterboxHorizontalPositionMultiplier( letterboxHorizontalPositionMultiplier); @@ -4177,13 +4176,28 @@ public class SizeCompatTests extends WindowTestsBase { @Test public void testUpdateResolvedBoundsHorizontalPosition_activityFillParentWidth() { + // Set up a display in landscape and ignoring orientation request. + setUpLandscapeLargeScreenDisplayWithApp(); + prepareUnresizable(mActivity, SCREEN_ORIENTATION_LANDSCAPE); + + final Consumer<Float> assertHorizontalPosition = letterboxHorizontalPositionMultiplier -> { + mActivity.mWmService.mAppCompatConfiguration.setLetterboxHorizontalPositionMultiplier( + letterboxHorizontalPositionMultiplier); + mActivity.recomputeConfiguration(); + assertFitted(); + // Rotate to put activity in size compat mode. + rotateDisplay(mActivity.mDisplayContent, ROTATION_90); + assertTrue(mActivity.inSizeCompatMode()); + // Activity is in size compat mode but not scaled. + assertEquals(new Rect(0, 0, 1400, 700), mActivity.getBounds()); + if (letterboxHorizontalPositionMultiplier < 1f) { + rotateDisplay(mActivity.mDisplayContent, ROTATION_0); + } + }; // When activity width equals parent width, multiplier shouldn't have any effect. - assertHorizontalPositionForDifferentDisplayConfigsForLandscapeActivity( - /* letterboxHorizontalPositionMultiplier */ 0.0f); - assertHorizontalPositionForDifferentDisplayConfigsForLandscapeActivity( - /* letterboxHorizontalPositionMultiplier */ 0.5f); - assertHorizontalPositionForDifferentDisplayConfigsForLandscapeActivity( - /* letterboxHorizontalPositionMultiplier */ 1.0f); + assertHorizontalPosition.accept(0.0f); + assertHorizontalPosition.accept(0.5f); + assertHorizontalPosition.accept(1.0f); } @Test @@ -4354,8 +4368,7 @@ public class SizeCompatTests extends WindowTestsBase { @Test public void testUpdateResolvedBoundsHorizontalPosition_bookModeEnabled() { // Set up a display in landscape with a fixed-orientation PORTRAIT app - setUpDisplaySizeWithApp(2800, 1400); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + setUpLandscapeLargeScreenDisplayWithApp(); mWm.mAppCompatConfiguration.setIsAutomaticReachabilityInBookModeEnabled(true); mWm.mAppCompatConfiguration.setLetterboxHorizontalPositionMultiplier( 1.0f /*letterboxHorizontalPositionMultiplier*/); @@ -4380,8 +4393,7 @@ public class SizeCompatTests extends WindowTestsBase { @Test public void testUpdateResolvedBoundsHorizontalPosition_bookModeDisabled_centered() { // Set up a display in landscape with a fixed-orientation PORTRAIT app - setUpDisplaySizeWithApp(2800, 1400); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + setUpLandscapeLargeScreenDisplayWithApp(); mWm.mAppCompatConfiguration.setIsAutomaticReachabilityInBookModeEnabled(false); mWm.mAppCompatConfiguration.setLetterboxHorizontalPositionMultiplier(0.5f); prepareUnresizable(mActivity, 1.75f, SCREEN_ORIENTATION_PORTRAIT); @@ -4462,8 +4474,7 @@ public class SizeCompatTests extends WindowTestsBase { float letterboxVerticalPositionMultiplier, Rect fixedOrientationLetterbox, Rect sizeCompatUnscaled, Rect sizeCompatScaled) { // Set up a display in portrait and ignoring orientation request. - setUpDisplaySizeWithApp(1400, 2800); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + setUpPortraitLargeScreenDisplayWithApp(); mActivity.mWmService.mAppCompatConfiguration.setLetterboxVerticalPositionMultiplier( letterboxVerticalPositionMultiplier); @@ -5035,23 +5046,6 @@ public class SizeCompatTests extends WindowTestsBase { return (dimensionToSplit - (dividerWindowWidth - dividerInsets * 2)) / 2; } - private void assertHorizontalPositionForDifferentDisplayConfigsForLandscapeActivity( - float letterboxHorizontalPositionMultiplier) { - // Set up a display in landscape and ignoring orientation request. - setUpDisplaySizeWithApp(2800, 1400); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); - - mActivity.mWmService.mAppCompatConfiguration.setLetterboxHorizontalPositionMultiplier( - letterboxHorizontalPositionMultiplier); - prepareUnresizable(mActivity, SCREEN_ORIENTATION_LANDSCAPE); - assertFitted(); - // Rotate to put activity in size compat mode. - rotateDisplay(mActivity.mDisplayContent, ROTATION_90); - assertTrue(mActivity.inSizeCompatMode()); - // Activity is in size compat mode but not scaled. - assertEquals(new Rect(0, 0, 1400, 700), mActivity.getBounds()); - } - private void assertVerticalPositionForDifferentDisplayConfigsForPortraitActivity( float letterboxVerticalPositionMultiplier) { // Set up a display in portrait and ignoring orientation request. diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java index e4512c31069a..1febc9fb4742 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java @@ -527,6 +527,7 @@ public class TaskTests extends WindowTestsBase { @Test public void testHandlesOrientationChangeFromDescendant() { + mDisplayContent.setIgnoreOrientationRequest(false); final Task rootTask = createTask(mDisplayContent, WINDOWING_MODE_MULTI_WINDOW, ACTIVITY_TYPE_STANDARD); final Task leafTask1 = createTaskInRootTask(rootTask, 0 /* userId */); @@ -1570,6 +1571,7 @@ public class TaskTests extends WindowTestsBase { @Test public void testNotSpecifyOrientationByFloatingTask() { + mDisplayContent.setIgnoreOrientationRequest(false); final Task task = new TaskBuilder(mSupervisor) .setCreateActivity(true).setCreateParentTask(true).build(); final ActivityRecord activity = task.getTopMostActivity(); @@ -1589,6 +1591,7 @@ public class TaskTests extends WindowTestsBase { @Test public void testNotSpecifyOrientation_taskDisplayAreaNotFocused() { + mDisplayContent.setIgnoreOrientationRequest(false); final TaskDisplayArea firstTaskDisplayArea = mDisplayContent.getDefaultTaskDisplayArea(); final TaskDisplayArea secondTaskDisplayArea = createTaskDisplayArea( mDisplayContent, mRootWindowContainer.mWmService, "TestTaskDisplayArea", @@ -1625,6 +1628,7 @@ public class TaskTests extends WindowTestsBase { @Test public void testTaskOrientationOnDisplayWindowingModeChange() { + mDisplayContent.setIgnoreOrientationRequest(false); // Skip unnecessary operations to speed up the test. mAtm.deferWindowLayout(); final Task task = getTestTask(); diff --git a/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java b/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java index 039a3ddd3e4f..78f32c1a4f88 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java @@ -1333,6 +1333,7 @@ public class TransitionTests extends WindowTestsBase { @Test public void testDeferRotationForTransientLaunch() { + mDisplayContent.setIgnoreOrientationRequest(false); final TestTransitionPlayer player = registerTestTransitionPlayer(); assumeFalse(mDisplayContent.mTransitionController.useShellTransitionsRotation()); final ActivityRecord app = new ActivityBuilder(mAtm).setCreateTask(true).build(); diff --git a/services/tests/wmtests/src/com/android/server/wm/TransparentPolicyTest.java b/services/tests/wmtests/src/com/android/server/wm/TransparentPolicyTest.java index 42752c326615..f1180ff93edb 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TransparentPolicyTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/TransparentPolicyTest.java @@ -314,6 +314,7 @@ public class TransparentPolicyTest extends WindowTestsBase { runTestScenario((robot) -> { robot.transparentActivity((ta) -> { ta.applyOnActivity((a) -> { + a.setIgnoreOrientationRequest(false); a.applyToTopActivity((topActivity) -> { topActivity.mWmService.mAppCompatConfiguration .setLetterboxHorizontalPositionMultiplier(1.0f); diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java index 410fa2879600..bb1e3ea078c3 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java @@ -777,6 +777,7 @@ public class WindowOrganizerTests extends WindowTestsBase { @Test public void testSetIgnoreOrientationRequest_taskDisplayArea() { removeGlobalMinSizeRestriction(); + mDisplayContent.setIgnoreOrientationRequest(false); final TaskDisplayArea taskDisplayArea = mDisplayContent.getDefaultTaskDisplayArea(); final Task rootTask = taskDisplayArea.createRootTask( WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, false /* onTop */); @@ -815,6 +816,7 @@ public class WindowOrganizerTests extends WindowTestsBase { @Test public void testSetIgnoreOrientationRequest_displayContent() { removeGlobalMinSizeRestriction(); + mDisplayContent.setIgnoreOrientationRequest(false); final TaskDisplayArea taskDisplayArea = mDisplayContent.getDefaultTaskDisplayArea(); final Task rootTask = taskDisplayArea.createRootTask( WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, false /* onTop */); diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java b/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java index 757c358f51d0..169fd80380f5 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java @@ -201,14 +201,10 @@ public class WindowTestsBase extends SystemServiceTestsBase { * {@link WindowTestsBase#setUpBase()}. */ private static boolean sGlobalOverridesChecked; + /** * Whether device-specific overrides have already been checked in - * {@link WindowTestsBase#setUpBase()} when the default display is used. - */ - private static boolean sOverridesCheckedDefaultDisplay; - /** - * Whether device-specific overrides have already been checked in - * {@link WindowTestsBase#setUpBase()} when a {@link TestDisplayContent} is used. + * {@link WindowTestsBase#setUpBase()}. */ private static boolean sOverridesCheckedTestDisplay; @@ -332,17 +328,14 @@ public class WindowTestsBase extends SystemServiceTestsBase { private void checkDeviceSpecificOverridesNotApplied() { // Check global overrides if (!sGlobalOverridesChecked) { + sGlobalOverridesChecked = true; assertEquals(0, mWm.mAppCompatConfiguration.getFixedOrientationLetterboxAspectRatio(), 0 /* delta */); - sGlobalOverridesChecked = true; } // Check display-specific overrides - if (!sOverridesCheckedDefaultDisplay && mDisplayContent == mDefaultDisplay) { - assertFalse(mDisplayContent.getIgnoreOrientationRequest()); - sOverridesCheckedDefaultDisplay = true; - } else if (!sOverridesCheckedTestDisplay && mDisplayContent instanceof TestDisplayContent) { - assertFalse(mDisplayContent.getIgnoreOrientationRequest()); + if (!sOverridesCheckedTestDisplay) { sOverridesCheckedTestDisplay = true; + assertFalse(mDisplayContent.mHasSetIgnoreOrientationRequest); } } @@ -1120,7 +1113,7 @@ public class WindowTestsBase extends SystemServiceTestsBase { displayContent.getDisplayRotation().configure(width, height); final Configuration c = new Configuration(); displayContent.computeScreenConfiguration(c); - displayContent.onRequestedOverrideConfigurationChanged(c); + displayContent.performDisplayOverrideConfigUpdate(c); } static void makeDisplayLargeScreen(DisplayContent displayContent) { |