From f20212adb868916170756b0300d3e21babba8a31 Mon Sep 17 00:00:00 2001 From: Neha Jain Date: Wed, 20 Jul 2022 02:24:36 +0000 Subject: [PATCH] Revert "Adjust smallestScreenWidthDp for letterbox" This reverts commit ea12f9a7a145cea034bf9ff7e6bbd20c1a2a8205. Reason for revert: b/238845492 Change-Id: I369804d817e943f58d42087c77db83017a34e459 --- .../com/android/server/wm/ActivityRecord.java | 14 ++-- .../com/android/server/wm/TaskFragment.java | 29 +++----- .../android/server/wm/SizeCompatTests.java | 73 ------------------- .../src/com/android/server/wm/TaskTests.java | 3 +- 4 files changed, 18 insertions(+), 101 deletions(-) diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index d6076f7012437..a9b154c869e83 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -7737,6 +7737,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // relatively fixed. overrideConfig.colorMode = fullConfig.colorMode; overrideConfig.densityDpi = fullConfig.densityDpi; + // The smallest screen width is the short side of screen bounds. Because the bounds + // and density won't be changed, smallestScreenWidthDp is also fixed. + overrideConfig.smallestScreenWidthDp = fullConfig.smallestScreenWidthDp; if (info.isFixedOrientation()) { // lock rotation too. When in size-compat, onConfigurationChanged will watch for and // apply runtime rotation changes. @@ -7833,7 +7836,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // computed accordingly. if (!matchParentBounds()) { getTaskFragment().computeConfigResourceOverrides(resolvedConfig, - newParentConfiguration, areBoundsLetterboxed()); + newParentConfiguration); } // If activity in fullscreen mode is letterboxed because of fixed orientation then bounds // are already calculated in resolveFixedOrientationConfiguration. @@ -8004,8 +8007,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } // Since bounds has changed, the configuration needs to be computed accordingly. - getTaskFragment().computeConfigResourceOverrides(resolvedConfig, newParentConfiguration, - areBoundsLetterboxed()); + getTaskFragment().computeConfigResourceOverrides(resolvedConfig, newParentConfiguration); } void recomputeConfiguration() { @@ -8221,7 +8223,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // Calculate app bounds using fixed orientation bounds because they will be needed later // for comparison with size compat app bounds in {@link resolveSizeCompatModeConfiguration}. getTaskFragment().computeConfigResourceOverrides(getResolvedOverrideConfiguration(), - newParentConfig, mCompatDisplayInsets, areBoundsLetterboxed()); + newParentConfig); mLetterboxBoundsForFixedOrientationAndAspectRatio = new Rect(resolvedBounds); } @@ -8249,7 +8251,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // Compute the configuration based on the resolved bounds. If aspect ratio doesn't // restrict, the bounds should be the requested override bounds. getTaskFragment().computeConfigResourceOverrides(resolvedConfig, newParentConfiguration, - getFixedRotationTransformDisplayInfo(), areBoundsLetterboxed()); + getFixedRotationTransformDisplayInfo()); } } @@ -8313,7 +8315,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // are calculated in compat container space. The actual position on screen will be applied // later, so the calculation is simpler that doesn't need to involve offset from parent. getTaskFragment().computeConfigResourceOverrides(resolvedConfig, newParentConfiguration, - mCompatDisplayInsets, areBoundsLetterboxed()); + mCompatDisplayInsets); // Use current screen layout as source because the size of app is independent to parent. resolvedConfig.screenLayout = TaskFragment.computeScreenLayoutOverride( getConfiguration().screenLayout, resolvedConfig.screenWidthDp, diff --git a/services/core/java/com/android/server/wm/TaskFragment.java b/services/core/java/com/android/server/wm/TaskFragment.java index 21c5886f085ba..f8a9d4665acca 100644 --- a/services/core/java/com/android/server/wm/TaskFragment.java +++ b/services/core/java/com/android/server/wm/TaskFragment.java @@ -1957,37 +1957,29 @@ class TaskFragment extends WindowContainer { void computeConfigResourceOverrides(@NonNull Configuration inOutConfig, @NonNull Configuration parentConfig) { computeConfigResourceOverrides(inOutConfig, parentConfig, null /* overrideDisplayInfo */, - null /* compatInsets */, false /* areBoundsLetterboxed */); + null /* compatInsets */); } void computeConfigResourceOverrides(@NonNull Configuration inOutConfig, - @NonNull Configuration parentConfig, boolean areBoundsLetterboxed) { - computeConfigResourceOverrides(inOutConfig, parentConfig, null /* overrideDisplayInfo */, - null /* compatInsets */, areBoundsLetterboxed); - } - - void computeConfigResourceOverrides(@NonNull Configuration inOutConfig, - @NonNull Configuration parentConfig, @Nullable DisplayInfo overrideDisplayInfo, - boolean areBoundsLetterboxed) { + @NonNull Configuration parentConfig, @Nullable DisplayInfo overrideDisplayInfo) { if (overrideDisplayInfo != null) { // Make sure the screen related configs can be computed by the provided display info. inOutConfig.screenLayout = Configuration.SCREENLAYOUT_UNDEFINED; invalidateAppBoundsConfig(inOutConfig); } computeConfigResourceOverrides(inOutConfig, parentConfig, overrideDisplayInfo, - null /* compatInsets */, areBoundsLetterboxed); + null /* compatInsets */); } void computeConfigResourceOverrides(@NonNull Configuration inOutConfig, @NonNull Configuration parentConfig, - @Nullable ActivityRecord.CompatDisplayInsets compatInsets, - boolean areBoundsLetterboxed) { + @Nullable ActivityRecord.CompatDisplayInsets compatInsets) { if (compatInsets != null) { // Make sure the app bounds can be computed by the compat insets. invalidateAppBoundsConfig(inOutConfig); } computeConfigResourceOverrides(inOutConfig, parentConfig, null /* overrideDisplayInfo */, - compatInsets, areBoundsLetterboxed); + compatInsets); } /** @@ -2014,8 +2006,7 @@ class TaskFragment extends WindowContainer { **/ void computeConfigResourceOverrides(@NonNull Configuration inOutConfig, @NonNull Configuration parentConfig, @Nullable DisplayInfo overrideDisplayInfo, - @Nullable ActivityRecord.CompatDisplayInsets compatInsets, - boolean areBoundsLetterboxed) { + @Nullable ActivityRecord.CompatDisplayInsets compatInsets) { int windowingMode = inOutConfig.windowConfiguration.getWindowingMode(); if (windowingMode == WINDOWING_MODE_UNDEFINED) { windowingMode = parentConfig.windowConfiguration.getWindowingMode(); @@ -2122,7 +2113,6 @@ class TaskFragment extends WindowContainer { : overrideScreenHeightDp; } - // TODO(b/238331848): Consider simplifying logic that computes smallestScreenWidthDp. if (inOutConfig.smallestScreenWidthDp == Configuration.SMALLEST_SCREEN_WIDTH_DP_UNDEFINED) { // When entering to or exiting from Pip, the PipTaskOrganizer will set the @@ -2138,10 +2128,9 @@ class TaskFragment extends WindowContainer { // task, because they should not be affected by insets. inOutConfig.smallestScreenWidthDp = (int) (0.5f + Math.min(mTmpFullBounds.width(), mTmpFullBounds.height()) / density); - } else if (isEmbedded() || areBoundsLetterboxed || customContainerPolicy) { - // For embedded TFs and activities that are letteboxed or eligible for size - // compat mode, the smallest width should be updated. Otherwise, inherit from - // the parent task would result in applications loaded wrong resource. + } else if (isEmbedded()) { + // For embedded TFs, the smallest width should be updated. Otherwise, inherit + // from the parent task would result in applications loaded wrong resource. inOutConfig.smallestScreenWidthDp = Math.min(inOutConfig.screenWidthDp, inOutConfig.screenHeightDp); } 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 f2640d2dc4049..324e244c46f50 100644 --- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java @@ -1495,79 +1495,6 @@ public class SizeCompatTests extends WindowTestsBase { assertEquals(displayBounds.height() / defaultAspectRatio, activityBounds.width(), 0.5); } - @Test - public void testComputeConfigResourceOverrides_unresizableApp() { - // Set up a display in landscape and ignoring orientation request. - setUpDisplaySizeWithApp(2800, 1400); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); - - prepareUnresizable(mActivity, SCREEN_ORIENTATION_PORTRAIT); - - final Rect activityBounds = new Rect(mActivity.getBounds()); - - int originalScreenWidthDp = mActivity.getConfiguration().screenWidthDp; - int originalScreenHeighthDp = mActivity.getConfiguration().screenHeightDp; - - // App should launch in fixed orientation letterbox. - // Activity bounds should be 700x1400 with the ratio as the display. - assertTrue(mActivity.isLetterboxedForFixedOrientationAndAspectRatio()); - assertFitted(); - assertEquals(originalScreenWidthDp, mActivity.getConfiguration().smallestScreenWidthDp); - assertTrue(originalScreenWidthDp < originalScreenHeighthDp); - - // Rotate display to portrait. - rotateDisplay(mActivity.mDisplayContent, ROTATION_90); - - // After we rotate, the activity should go in the size-compat mode and report the same - // configuration values. - assertScaled(); - assertEquals(originalScreenWidthDp, mActivity.getConfiguration().smallestScreenWidthDp); - assertEquals(originalScreenWidthDp, mActivity.getConfiguration().screenWidthDp); - assertEquals(originalScreenHeighthDp, mActivity.getConfiguration().screenHeightDp); - - // Restart activity - mActivity.restartProcessIfVisible(); - - // Now configuration should be updated - assertFitted(); - assertNotEquals(originalScreenWidthDp, mActivity.getConfiguration().screenWidthDp); - assertNotEquals(originalScreenHeighthDp, mActivity.getConfiguration().screenHeightDp); - assertEquals(mActivity.getConfiguration().screenWidthDp, - mActivity.getConfiguration().smallestScreenWidthDp); - } - - @Test - public void testComputeConfigResourceOverrides_resizableFixedOrientationActivity() { - // Set up a display in landscape and ignoring orientation request. - setUpDisplaySizeWithApp(2800, 1400); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); - - // 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; - - // App should launch in fixed orientation letterbox. - // Activity bounds should be 700x1400 with the ratio as the display. - assertTrue(mActivity.isLetterboxedForFixedOrientationAndAspectRatio()); - assertFitted(); - assertEquals(originalScreenWidthDp, mActivity.getConfiguration().smallestScreenWidthDp); - assertTrue(originalScreenWidthDp < originalScreenHeighthDp); - - // Rotate display to portrait. - rotateDisplay(mActivity.mDisplayContent, ROTATION_90); - - // Now configuration should be updated - assertFitted(); - assertNotEquals(originalScreenWidthDp, mActivity.getConfiguration().screenWidthDp); - assertNotEquals(originalScreenHeighthDp, mActivity.getConfiguration().screenHeightDp); - assertEquals(mActivity.getConfiguration().screenWidthDp, - mActivity.getConfiguration().smallestScreenWidthDp); - } - @Test public void testSplitAspectRatioForUnresizablePortraitApps() { // Set up a display in landscape 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 e2fe1b175dc82..46e21f1ffdbcb 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java @@ -691,8 +691,7 @@ public class TaskTests extends WindowTestsBase { final ActivityRecord.CompatDisplayInsets compatInsets = new ActivityRecord.CompatDisplayInsets( display, activity, /* fixedOrientationBounds= */ null); - task.computeConfigResourceOverrides( - inOutConfig, parentConfig, compatInsets, /* areBoundsLetterboxed */ true); + task.computeConfigResourceOverrides(inOutConfig, parentConfig, compatInsets); assertEquals(largerLandscapeBounds, inOutConfig.windowConfiguration.getAppBounds()); final float density = parentConfig.densityDpi * DisplayMetrics.DENSITY_DEFAULT_SCALE;