Loading services/core/java/com/android/server/wm/AppCompatSizeCompatModePolicy.java +5 −4 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import static android.internal.perfetto.protos.Windowmanagerservice.ActivityReco import static android.window.DesktopExperienceFlags.ENABLE_SIZE_COMPAT_MODE_IMPROVEMENTS_FOR_CONNECTED_DISPLAYS; import static android.window.DesktopExperienceFlags.ENABLE_UPSCALING_SIZE_COMPAT_ON_EXITING_DESKTOP_BUGFIX; import static com.android.server.wm.AppCompatUtils.isDesktopFirst; import static com.android.server.wm.AppCompatUtils.isInDesktopMode; import android.annotation.NonNull; Loading Loading @@ -593,8 +594,8 @@ class AppCompatSizeCompatModePolicy { * such as when: * - Moving from an external display to a smaller phone screen. * - Transitioning from desktop mode to fullscreen. * This treatment is not applied to internal displays that ignore orientation requests to * maintain consistent scaling behavior with orientation changes on those displays. * This treatment is not applied to fullscreen-first, internal displays that ignore orientation * requests to maintain consistent scaling behavior with orientation changes on those displays. */ private boolean shouldAllowUpscalingForDisplayOrWindowingModeChange(boolean isInDesktopMode) { final boolean launchedInAndExitedFromDesktop = getAppCompatDisplayInsets() != null Loading @@ -604,10 +605,10 @@ class AppCompatSizeCompatModePolicy { final boolean isOnIgnoreOrientationRequestInternalDisplay = isOnInternalDisplay() && mActivityRecord.getDisplayContent().getIgnoreOrientationRequest(); // TODO(b/432329483): Polish the policy for desktop-first devices. return ENABLE_UPSCALING_SIZE_COMPAT_ON_EXITING_DESKTOP_BUGFIX.isTrue() && (launchedInAndExitedFromDesktop || hasMovedBetweenDisplays) && !isOnIgnoreOrientationRequestInternalDisplay; && (!isOnIgnoreOrientationRequestInternalDisplay || isDesktopFirst(mActivityRecord.getDisplayArea())); } /** Returns whether the activity is on an internal display. */ Loading services/core/java/com/android/server/wm/AppCompatUtils.java +8 −0 Original line number Diff line number Diff line Loading @@ -320,6 +320,14 @@ final class AppCompatUtils { return parentWindowingMode == WINDOWING_MODE_FREEFORM && canEnterDesktopMode(context); } /** * Return {@code true} if the given display area is desktop-first. */ static boolean isDesktopFirst(@Nullable TaskDisplayArea taskDisplayArea) { return taskDisplayArea != null && taskDisplayArea.getWindowingMode() == WINDOWING_MODE_FREEFORM; } /** * Creates a {@link AppCompatTransitionInfo} which encapsulate the letterbox * information if needed. Loading services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +14 −4 Original line number Diff line number Diff line Loading @@ -162,6 +162,8 @@ public class SizeCompatTests extends WindowTestsBase { private static final float DELTA_ASPECT_RATIO_TOLERANCE = 0.005f; private static final double DELTA_COMPAT_SCALE_TOLERANCE = 1e7; @Rule public TestRule compatChangeRule = new PlatformCompatChangeRule(); Loading Loading @@ -4611,8 +4613,6 @@ public class SizeCompatTests extends WindowTestsBase { displayInfo.logicalWidth = dw; displayInfo.logicalHeight = dh; final DisplayContent display = new TestDisplayContent.Builder(mAtm, displayInfo).build(); display.getDefaultTaskDisplayArea() .setWindowingMode(WindowConfiguration.WINDOWING_MODE_FREEFORM); final TaskBuilder taskBuilder = new TaskBuilder(mSupervisor).setWindowingMode(WINDOWING_MODE_FREEFORM); setUpApp(display, null /* appBuilder */, taskBuilder); Loading Loading @@ -4642,14 +4642,24 @@ public class SizeCompatTests extends WindowTestsBase { internalDisplay.setIgnoreOrientationRequest(true); mActivity.onConfigurationChanged(mTask.getConfiguration()); assertTrue(mActivity.inSizeCompatMode()); assertEquals(1f, mActivity.getCompatScale(), 1e7); assertEquals(1f, mActivity.getCompatScale(), DELTA_COMPAT_SCALE_TOLERANCE); // Make the display not ignore-orientation-request. internalDisplay.setIgnoreOrientationRequest(false); mActivity.onConfigurationChanged(mTask.getConfiguration()); assertUpScaled(); } // Make the display ignore-orientation-request again. internalDisplay.setIgnoreOrientationRequest(true); mActivity.onConfigurationChanged(mTask.getConfiguration()); assertEquals(1f, mActivity.getCompatScale(), DELTA_COMPAT_SCALE_TOLERANCE); // Make the display desktop-first. mActivity.onConfigurationChanged(mTask.getConfiguration()); display.getDefaultTaskDisplayArea() .setWindowingMode(WindowConfiguration.WINDOWING_MODE_FREEFORM); assertUpScaled(); } @Test @EnableFlags(Flags.FLAG_IGNORE_ASPECT_RATIO_RESTRICTIONS_FOR_RESIZEABLE_FREEFORM_ACTIVITIES) Loading Loading
services/core/java/com/android/server/wm/AppCompatSizeCompatModePolicy.java +5 −4 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import static android.internal.perfetto.protos.Windowmanagerservice.ActivityReco import static android.window.DesktopExperienceFlags.ENABLE_SIZE_COMPAT_MODE_IMPROVEMENTS_FOR_CONNECTED_DISPLAYS; import static android.window.DesktopExperienceFlags.ENABLE_UPSCALING_SIZE_COMPAT_ON_EXITING_DESKTOP_BUGFIX; import static com.android.server.wm.AppCompatUtils.isDesktopFirst; import static com.android.server.wm.AppCompatUtils.isInDesktopMode; import android.annotation.NonNull; Loading Loading @@ -593,8 +594,8 @@ class AppCompatSizeCompatModePolicy { * such as when: * - Moving from an external display to a smaller phone screen. * - Transitioning from desktop mode to fullscreen. * This treatment is not applied to internal displays that ignore orientation requests to * maintain consistent scaling behavior with orientation changes on those displays. * This treatment is not applied to fullscreen-first, internal displays that ignore orientation * requests to maintain consistent scaling behavior with orientation changes on those displays. */ private boolean shouldAllowUpscalingForDisplayOrWindowingModeChange(boolean isInDesktopMode) { final boolean launchedInAndExitedFromDesktop = getAppCompatDisplayInsets() != null Loading @@ -604,10 +605,10 @@ class AppCompatSizeCompatModePolicy { final boolean isOnIgnoreOrientationRequestInternalDisplay = isOnInternalDisplay() && mActivityRecord.getDisplayContent().getIgnoreOrientationRequest(); // TODO(b/432329483): Polish the policy for desktop-first devices. return ENABLE_UPSCALING_SIZE_COMPAT_ON_EXITING_DESKTOP_BUGFIX.isTrue() && (launchedInAndExitedFromDesktop || hasMovedBetweenDisplays) && !isOnIgnoreOrientationRequestInternalDisplay; && (!isOnIgnoreOrientationRequestInternalDisplay || isDesktopFirst(mActivityRecord.getDisplayArea())); } /** Returns whether the activity is on an internal display. */ Loading
services/core/java/com/android/server/wm/AppCompatUtils.java +8 −0 Original line number Diff line number Diff line Loading @@ -320,6 +320,14 @@ final class AppCompatUtils { return parentWindowingMode == WINDOWING_MODE_FREEFORM && canEnterDesktopMode(context); } /** * Return {@code true} if the given display area is desktop-first. */ static boolean isDesktopFirst(@Nullable TaskDisplayArea taskDisplayArea) { return taskDisplayArea != null && taskDisplayArea.getWindowingMode() == WINDOWING_MODE_FREEFORM; } /** * Creates a {@link AppCompatTransitionInfo} which encapsulate the letterbox * information if needed. Loading
services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +14 −4 Original line number Diff line number Diff line Loading @@ -162,6 +162,8 @@ public class SizeCompatTests extends WindowTestsBase { private static final float DELTA_ASPECT_RATIO_TOLERANCE = 0.005f; private static final double DELTA_COMPAT_SCALE_TOLERANCE = 1e7; @Rule public TestRule compatChangeRule = new PlatformCompatChangeRule(); Loading Loading @@ -4611,8 +4613,6 @@ public class SizeCompatTests extends WindowTestsBase { displayInfo.logicalWidth = dw; displayInfo.logicalHeight = dh; final DisplayContent display = new TestDisplayContent.Builder(mAtm, displayInfo).build(); display.getDefaultTaskDisplayArea() .setWindowingMode(WindowConfiguration.WINDOWING_MODE_FREEFORM); final TaskBuilder taskBuilder = new TaskBuilder(mSupervisor).setWindowingMode(WINDOWING_MODE_FREEFORM); setUpApp(display, null /* appBuilder */, taskBuilder); Loading Loading @@ -4642,14 +4642,24 @@ public class SizeCompatTests extends WindowTestsBase { internalDisplay.setIgnoreOrientationRequest(true); mActivity.onConfigurationChanged(mTask.getConfiguration()); assertTrue(mActivity.inSizeCompatMode()); assertEquals(1f, mActivity.getCompatScale(), 1e7); assertEquals(1f, mActivity.getCompatScale(), DELTA_COMPAT_SCALE_TOLERANCE); // Make the display not ignore-orientation-request. internalDisplay.setIgnoreOrientationRequest(false); mActivity.onConfigurationChanged(mTask.getConfiguration()); assertUpScaled(); } // Make the display ignore-orientation-request again. internalDisplay.setIgnoreOrientationRequest(true); mActivity.onConfigurationChanged(mTask.getConfiguration()); assertEquals(1f, mActivity.getCompatScale(), DELTA_COMPAT_SCALE_TOLERANCE); // Make the display desktop-first. mActivity.onConfigurationChanged(mTask.getConfiguration()); display.getDefaultTaskDisplayArea() .setWindowingMode(WindowConfiguration.WINDOWING_MODE_FREEFORM); assertUpScaled(); } @Test @EnableFlags(Flags.FLAG_IGNORE_ASPECT_RATIO_RESTRICTIONS_FOR_RESIZEABLE_FREEFORM_ACTIVITIES) Loading