Loading services/core/java/com/android/server/wm/ActivityRecord.java +8 −6 Original line number Diff line number Diff line Loading @@ -7738,6 +7738,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. Loading Loading @@ -7834,7 +7837,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. Loading Loading @@ -8005,8 +8008,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() { Loading Loading @@ -8222,7 +8224,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); } Loading Loading @@ -8250,7 +8252,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()); } } Loading Loading @@ -8314,7 +8316,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, Loading services/core/java/com/android/server/wm/TaskFragment.java +9 −20 Original line number Diff line number Diff line Loading @@ -1957,37 +1957,29 @@ class TaskFragment extends WindowContainer<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); } /** Loading @@ -2014,8 +2006,7 @@ class TaskFragment extends WindowContainer<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(); Loading Loading @@ -2122,7 +2113,6 @@ class TaskFragment extends WindowContainer<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 Loading @@ -2138,10 +2128,9 @@ class TaskFragment extends WindowContainer<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); } Loading services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +0 −73 Original line number Diff line number Diff line Loading @@ -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. Loading services/tests/wmtests/src/com/android/server/wm/TaskTests.java +1 −2 Original line number Diff line number Diff line Loading @@ -705,8 +705,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; Loading Loading
services/core/java/com/android/server/wm/ActivityRecord.java +8 −6 Original line number Diff line number Diff line Loading @@ -7738,6 +7738,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. Loading Loading @@ -7834,7 +7837,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. Loading Loading @@ -8005,8 +8008,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() { Loading Loading @@ -8222,7 +8224,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); } Loading Loading @@ -8250,7 +8252,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()); } } Loading Loading @@ -8314,7 +8316,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, Loading
services/core/java/com/android/server/wm/TaskFragment.java +9 −20 Original line number Diff line number Diff line Loading @@ -1957,37 +1957,29 @@ class TaskFragment extends WindowContainer<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); } /** Loading @@ -2014,8 +2006,7 @@ class TaskFragment extends WindowContainer<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(); Loading Loading @@ -2122,7 +2113,6 @@ class TaskFragment extends WindowContainer<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 Loading @@ -2138,10 +2128,9 @@ class TaskFragment extends WindowContainer<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); } Loading
services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +0 −73 Original line number Diff line number Diff line Loading @@ -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. Loading
services/tests/wmtests/src/com/android/server/wm/TaskTests.java +1 −2 Original line number Diff line number Diff line Loading @@ -705,8 +705,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; Loading