Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 94701206 authored by Graciela Wissen Putri's avatar Graciela Wissen Putri
Browse files

Don't create compatDisplayInsets if has fullscreen override

Don't allow SCM if system has overridden app to full screen to prevent
letterboxing or SCM when resuming activity.

Always show aspect ratio icon if user has set app to full screen.

Fix: 330887629
Test: atest SizeCompatTests
      atest UserAspectRatioSettingsWindowManagerTest
      manual
Change-Id: I1d7fdad2f48b6a68f52a8aeb4d6b864143a93b1b
parent 2d967b48
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -237,7 +237,8 @@ class UserAspectRatioSettingsWindowManager extends CompatUIWindowManagerAbstract
        final int letterboxWidth = taskInfo.topActivityLetterboxWidth;
        // App is not visibly letterboxed if it covers status bar/bottom insets or matches the
        // stable bounds, so don't show the button
        if (stableBounds.height() <= letterboxHeight && stableBounds.width() <= letterboxWidth) {
        if (stableBounds.height() <= letterboxHeight && stableBounds.width() <= letterboxWidth
                && !taskInfo.isUserFullscreenOverrideEnabled) {
            return false;
        }

+18 −0
Original line number Diff line number Diff line
@@ -291,6 +291,24 @@ public class UserAspectRatioSettingsWindowManagerTest extends ShellTestCase {
        verify(mWindowManager).inflateLayout();
    }

    @Test
    public void testUserFullscreenOverrideEnabled_buttonAlwaysShown() {
        TaskInfo taskInfo = createTaskInfo(/* eligibleForUserAspectRatioButton= */
                true, /* topActivityBoundsLetterboxed */ true, ACTION_MAIN, CATEGORY_LAUNCHER);

        final Rect stableBounds = mWindowManager.getTaskStableBounds();

        // Letterboxed activity that has user fullscreen override should always show button,
        // layout should be inflated
        taskInfo.appCompatTaskInfo.topActivityLetterboxHeight = stableBounds.height();
        taskInfo.appCompatTaskInfo.topActivityLetterboxWidth = stableBounds.width();
        taskInfo.appCompatTaskInfo.isUserFullscreenOverrideEnabled = true;

        mWindowManager.updateCompatInfo(taskInfo, mTaskListener, /* canShow= */ true);

        verify(mWindowManager).inflateLayout();
    }

    @Test
    public void testUpdateDisplayLayout() {
        final DisplayInfo displayInfo = new DisplayInfo();
+1 −1
Original line number Diff line number Diff line
@@ -8320,7 +8320,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
     *         aspect ratio.
     */
    boolean shouldCreateCompatDisplayInsets() {
        if (mLetterboxUiController.shouldApplyUserFullscreenOverride()) {
        if (mLetterboxUiController.hasFullscreenOverride()) {
            // If the user has forced the applications aspect ratio to be fullscreen, don't use size
            // compatibility mode in any situation. The user has been warned and therefore accepts
            // the risk of the application misbehaving.
+19 −0
Original line number Diff line number Diff line
@@ -1358,6 +1358,25 @@ public class SizeCompatTests extends WindowTestsBase {
        assertFalse(activity.shouldCreateCompatDisplayInsets());
    }

    @Test
    @EnableCompatChanges({ActivityInfo.OVERRIDE_ANY_ORIENTATION_TO_USER})
    public void testShouldNotCreateCompatDisplays_systemFullscreenOverride() {
        setUpDisplaySizeWithApp(1000, 2500);

        // Make the task root resizable.
        mActivity.info.resizeMode = RESIZE_MODE_RESIZEABLE;

        // Create an activity on the same task.
        final ActivityRecord activity = buildActivityRecord(/* supportsSizeChanges= */false,
                RESIZE_MODE_UNRESIZEABLE, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

        // Simulate the user selecting the fullscreen user aspect ratio override
        spyOn(activity.mLetterboxUiController);
        doReturn(true).when(activity.mLetterboxUiController)
                .isSystemOverrideToFullscreenEnabled();
        assertFalse(activity.shouldCreateCompatDisplayInsets());
    }

    @Test
    @EnableCompatChanges({ActivityInfo.NEVER_SANDBOX_DISPLAY_APIS})
    public void testNeverSandboxDisplayApis_configEnabled_sandboxingNotApplied() {