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

Commit be1761a0 authored by Graciela Putri's avatar Graciela Putri Committed by Android (Google) Code Review
Browse files

Merge "Don't show button if fullscreen override is from system" into main

parents 58a5dbf3 f66f7ece
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -96,6 +96,11 @@ public class AppCompatTaskInfo implements Parcelable {
     */
    public boolean isUserFullscreenOverrideEnabled;

    /**
     * Whether the system has forced the activity to be fullscreen
     */
    public boolean isSystemFullscreenOverrideEnabled;

    /**
     * Hint about the letterbox state of the top activity.
     */
@@ -202,7 +207,8 @@ public class AppCompatTaskInfo implements Parcelable {
                && topActivityLetterboxHeight == that.topActivityLetterboxHeight
                && topActivityLetterboxHorizontalPosition
                    == that.topActivityLetterboxHorizontalPosition
                && isUserFullscreenOverrideEnabled == that.isUserFullscreenOverrideEnabled;
                && isUserFullscreenOverrideEnabled == that.isUserFullscreenOverrideEnabled
                && isSystemFullscreenOverrideEnabled == that.isSystemFullscreenOverrideEnabled;
    }

    /**
@@ -224,7 +230,8 @@ public class AppCompatTaskInfo implements Parcelable {
                && topActivityLetterboxWidth == that.topActivityLetterboxWidth
                && topActivityLetterboxHeight == that.topActivityLetterboxHeight
                && cameraCompatControlState == that.cameraCompatControlState
                && isUserFullscreenOverrideEnabled == that.isUserFullscreenOverrideEnabled;
                && isUserFullscreenOverrideEnabled == that.isUserFullscreenOverrideEnabled
                && isSystemFullscreenOverrideEnabled == that.isSystemFullscreenOverrideEnabled;
    }

    /**
@@ -243,6 +250,7 @@ public class AppCompatTaskInfo implements Parcelable {
        topActivityLetterboxWidth = source.readInt();
        topActivityLetterboxHeight = source.readInt();
        isUserFullscreenOverrideEnabled = source.readBoolean();
        isSystemFullscreenOverrideEnabled = source.readBoolean();
    }

    /**
@@ -262,6 +270,7 @@ public class AppCompatTaskInfo implements Parcelable {
        dest.writeInt(topActivityLetterboxWidth);
        dest.writeInt(topActivityLetterboxHeight);
        dest.writeBoolean(isUserFullscreenOverrideEnabled);
        dest.writeBoolean(isSystemFullscreenOverrideEnabled);
    }

    @Override
@@ -280,6 +289,7 @@ public class AppCompatTaskInfo implements Parcelable {
                + " topActivityLetterboxWidth=" + topActivityLetterboxWidth
                + " topActivityLetterboxHeight=" + topActivityLetterboxHeight
                + " isUserFullscreenOverrideEnabled=" + isUserFullscreenOverrideEnabled
                + " isSystemFullscreenOverrideEnabled=" + isSystemFullscreenOverrideEnabled
                + " cameraCompatControlState="
                + cameraCompatControlStateToString(cameraCompatControlState)
                + "}";
+1 −0
Original line number Diff line number Diff line
@@ -232,6 +232,7 @@ class UserAspectRatioSettingsWindowManager extends CompatUIWindowManagerAbstract
        return taskInfo.appCompatTaskInfo.topActivityEligibleForUserAspectRatioButton
                && (taskInfo.appCompatTaskInfo.topActivityBoundsLetterboxed
                    || taskInfo.appCompatTaskInfo.isUserFullscreenOverrideEnabled)
                && !taskInfo.appCompatTaskInfo.isSystemFullscreenOverrideEnabled
                && Intent.ACTION_MAIN.equals(intent.getAction())
                && intent.hasCategory(Intent.CATEGORY_LAUNCHER)
                && (!mUserAspectRatioButtonShownChecker.get() || isShowingButton());
+11 −6
Original line number Diff line number Diff line
@@ -173,7 +173,7 @@ final class LetterboxUiController {
    // Corresponds to OVERRIDE_ANY_ORIENTATION
    private final boolean mIsOverrideAnyOrientationEnabled;
    // Corresponds to OVERRIDE_ANY_ORIENTATION_TO_USER
    private final boolean mIsOverrideToUserOrientationEnabled;
    private final boolean mIsSystemOverrideToFullscreenEnabled;
    // Corresponds to OVERRIDE_UNDEFINED_ORIENTATION_TO_PORTRAIT
    private final boolean mIsOverrideToPortraitOrientationEnabled;
    // Corresponds to OVERRIDE_UNDEFINED_ORIENTATION_TO_NOSENSOR
@@ -358,7 +358,7 @@ final class LetterboxUiController {
                        PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_FULLSCREEN_OVERRIDE);

        mIsOverrideAnyOrientationEnabled = isCompatChangeEnabled(OVERRIDE_ANY_ORIENTATION);
        mIsOverrideToUserOrientationEnabled =
        mIsSystemOverrideToFullscreenEnabled =
                isCompatChangeEnabled(OVERRIDE_ANY_ORIENTATION_TO_USER);
        mIsOverrideToPortraitOrientationEnabled =
                isCompatChangeEnabled(OVERRIDE_UNDEFINED_ORIENTATION_TO_PORTRAIT);
@@ -671,8 +671,7 @@ final class LetterboxUiController {
        final DisplayContent displayContent = mActivityRecord.mDisplayContent;
        final boolean isIgnoreOrientationRequestEnabled = displayContent != null
                && displayContent.getIgnoreOrientationRequest();
        if (shouldApplyUserFullscreenOverride()
                && isIgnoreOrientationRequestEnabled) {
        if (shouldApplyUserFullscreenOverride() && isIgnoreOrientationRequestEnabled) {
            Slog.v(TAG, "Requested orientation " + screenOrientationToString(candidate) + " for "
                    + mActivityRecord + " is overridden to "
                    + screenOrientationToString(SCREEN_ORIENTATION_USER)
@@ -707,8 +706,7 @@ final class LetterboxUiController {
        // mUserAspectRatio is always initialized first in shouldApplyUserFullscreenOverride(),
        // which will always come first before this check as user override > device
        // manufacturer override.
        if (mUserAspectRatio == PackageManager.USER_MIN_ASPECT_RATIO_UNSET
                && mIsOverrideToUserOrientationEnabled && isIgnoreOrientationRequestEnabled) {
        if (isSystemOverrideToFullscreenEnabled() && isIgnoreOrientationRequestEnabled) {
            Slog.v(TAG, "Requested orientation  " + screenOrientationToString(candidate) + " for "
                    + mActivityRecord + " is overridden to "
                    + screenOrientationToString(SCREEN_ORIENTATION_USER));
@@ -1202,6 +1200,13 @@ final class LetterboxUiController {
        return mUserAspectRatio == USER_MIN_ASPECT_RATIO_FULLSCREEN;
    }

    boolean isSystemOverrideToFullscreenEnabled() {
        return mIsSystemOverrideToFullscreenEnabled
                && !FALSE.equals(mBooleanPropertyAllowOrientationOverride)
                && (mUserAspectRatio == USER_MIN_ASPECT_RATIO_UNSET
                    || mUserAspectRatio == USER_MIN_ASPECT_RATIO_FULLSCREEN);
    }

    float getUserMinAspectRatio() {
        switch (mUserAspectRatio) {
            case USER_MIN_ASPECT_RATIO_DISPLAY_SIZE:
+2 −0
Original line number Diff line number Diff line
@@ -3506,6 +3506,8 @@ class Task extends TaskFragment {
        appCompatTaskInfo.topActivityLetterboxHeight = TaskInfo.PROPERTY_VALUE_UNSET;
        appCompatTaskInfo.isUserFullscreenOverrideEnabled = top != null
                && top.mLetterboxUiController.shouldApplyUserFullscreenOverride();
        appCompatTaskInfo.isSystemFullscreenOverrideEnabled = top != null
                && top.mLetterboxUiController.isSystemOverrideToFullscreenEnabled();
        appCompatTaskInfo.isFromLetterboxDoubleTap = top != null
                && top.mLetterboxUiController.isFromDoubleTap();
        if (appCompatTaskInfo.isLetterboxDoubleTapEnabled) {
+25 −0
Original line number Diff line number Diff line
@@ -695,6 +695,31 @@ public class LetterboxUiControllerTest extends WindowTestsBase {
                /* candidate */ SCREEN_ORIENTATION_PORTRAIT));
    }

    @Test
    @EnableCompatChanges({OVERRIDE_ANY_ORIENTATION_TO_USER})
    public void testOverrideOrientationIfNeeded_fullscreenOverrides_optOutSystem_returnsUser()
            throws Exception {
        mockThatProperty(PROPERTY_COMPAT_ALLOW_ORIENTATION_OVERRIDE, /* value */ false);
        prepareActivityThatShouldApplyUserFullscreenOverride();

        // fullscreen override still applied
        assertEquals(SCREEN_ORIENTATION_USER, mController.overrideOrientationIfNeeded(
                /* candidate */ SCREEN_ORIENTATION_PORTRAIT));
    }

    @Test
    @EnableCompatChanges({OVERRIDE_ANY_ORIENTATION_TO_USER})
    public void testOverrideOrientationIfNeeded_fullscreenOverrides_optOutUser_returnsUser()
            throws Exception {
        mockThatProperty(PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_FULLSCREEN_OVERRIDE,
                /* value */ false);
        prepareActivityThatShouldApplyUserFullscreenOverride();

        // fullscreen override still applied
        assertEquals(SCREEN_ORIENTATION_USER, mController.overrideOrientationIfNeeded(
                /* candidate */ SCREEN_ORIENTATION_PORTRAIT));
    }

    @Test
    @EnableCompatChanges({OVERRIDE_ANY_ORIENTATION_TO_USER})
    public void testOverrideOrientationIfNeeded_fullscreenOverrideEnabled_returnsUnchanged()