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

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

Override to full-screen for fixed orientation

Only override activities that request fixed orientation landscape or
portrait as they will be most likely letterboxed.
SCREEN_ORIENTATION_LOCKED or SCREEN_ORIENTATION_NOSENSOR will still be
full-screen even though they are fixed orientation.

Fix some broken javadoc links.

Flag: EXEMPT bug fix
Fix: 315936527
Test: atest SizeCompatTests
      atest AppCompatOrientationPolicyTest
Change-Id: I316fa3561b6a3fa2468b0a075a611009fd493832
parent 68fe97e6
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCA
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_USER;
import static android.content.pm.ActivityInfo.isFixedOrientation;
import static android.content.pm.ActivityInfo.isFixedOrientationLandscape;
import static android.content.pm.ActivityInfo.isFixedOrientationPortrait;
import static android.content.pm.ActivityInfo.screenOrientationToString;

import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM;
@@ -66,6 +67,7 @@ class AppCompatOrientationPolicy {
        final boolean shouldCameraCompatControlOrientation =
                AppCompatCameraPolicy.shouldCameraCompatControlOrientation(mActivityRecord);
        if (hasFullscreenOverride && isIgnoreOrientationRequestEnabled
                && (isFixedOrientationLandscape(candidate) || isFixedOrientationPortrait(candidate))
                // Do not override orientation to fullscreen for camera activities.
                // Fixed-orientation activities are rarely tested in other orientations, and it
                // often results in sideways or stretched previews. As the camera compat treatment
+2 −2
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ class AppCompatSizeCompatModePolicy {

    /**
     * The precomputed display insets for resolving configuration. It will be non-null if
     * {@link #shouldCreateAppCompatDisplayInsets} returns {@code true}.
     * {@link ActivityRecord#shouldCreateAppCompatDisplayInsets} returns {@code true}.
     */
    @Nullable
    private AppCompatDisplayInsets mAppCompatDisplayInsets;
@@ -84,7 +84,7 @@ class AppCompatSizeCompatModePolicy {
    }

    /**
     * @return The {@code true} if the current instance has {@link mAppCompatDisplayInsets} without
     * @return The {@code true} if the current instance has {@link #mAppCompatDisplayInsets} without
     * considering the inheritance implemented in {@link #getAppCompatDisplayInsets()}
     */
    boolean hasAppCompatDisplayInsetsWithoutInheritance() {
+3 −3
Original line number Diff line number Diff line
@@ -302,15 +302,15 @@ public class AppCompatOrientationPolicyTest extends WindowTestsBase {
    }

    @Test
    public void testOverrideOrientationIfNeeded_userFullscreenOverride_returnsUser() {
    public void testOverrideOrientationIfNeeded_userFullscreenOverride_notLetterboxed_unchanged() {
        runTestScenarioWithActivity((robot) -> {
            robot.applyOnActivity((a) -> {
                a.setShouldApplyUserFullscreenOverride(true);
                a.setIgnoreOrientationRequest(true);
            });

            robot.checkOverrideOrientation(/* candidate */ SCREEN_ORIENTATION_UNSPECIFIED,
                    /* expected */ SCREEN_ORIENTATION_USER);
            robot.checkOverrideOrientation(/* candidate */ SCREEN_ORIENTATION_LOCKED,
                    /* expected */ SCREEN_ORIENTATION_LOCKED);
        });
    }