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

Commit e32cf9e7 authored by Vali Calinescu's avatar Vali Calinescu Committed by Android (Google) Code Review
Browse files

Merge "Introduce config to use display aspect ratio for letterbox" into tm-qpr-dev

parents 4f726c8c 23b2b2fe
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -5356,6 +5356,9 @@
    <!-- Whether using split screen aspect ratio as a default aspect ratio for unresizable apps. -->
    <bool name="config_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled">false</bool>

    <!-- Whether using display aspect ratio as a default aspect ratio for all letterboxed apps. -->
    <bool name="config_letterboxIsDisplayAspectRatioForFixedOrientationLetterboxEnabled">false</bool>

    <!-- Whether the specific behaviour for translucent activities letterboxing is enabled.
         TODO(b/255532890) Enable when ignoreOrientationRequest is set -->
    <bool name="config_letterboxIsEnabledForTranslucentActivities">false</bool>
+1 −0
Original line number Diff line number Diff line
@@ -4463,6 +4463,7 @@
  <java-symbol type="bool" name="config_letterboxIsEducationEnabled" />
  <java-symbol type="dimen" name="config_letterboxDefaultMinAspectRatioForUnresizableApps" />
  <java-symbol type="bool" name="config_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled" />
  <java-symbol type="bool" name="config_letterboxIsDisplayAspectRatioForFixedOrientationLetterboxEnabled" />
  <java-symbol type="bool" name="config_isCompatFakeFocusEnabled" />
  <java-symbol type="bool" name="config_isWindowManagerCameraCompatTreatmentEnabled" />
  <java-symbol type="bool" name="config_isCameraCompatControlForStretchedIssuesEnabled" />
+34 −0
Original line number Diff line number Diff line
@@ -197,6 +197,12 @@ final class LetterboxConfiguration {
    // Whether using split screen aspect ratio as a default aspect ratio for unresizable apps.
    private boolean mIsSplitScreenAspectRatioForUnresizableAppsEnabled;

    // Whether using display aspect ratio as a default aspect ratio for all letterboxed apps.
    // mIsSplitScreenAspectRatioForUnresizableAppsEnabled and
    // config_letterboxDefaultMinAspectRatioForUnresizableApps take priority over this for
    // unresizable apps
    private boolean mIsDisplayAspectRatioEnabledForFixedOrientationLetterbox;

    // Whether letterboxing strategy is enabled for translucent activities. If {@value false}
    // all the feature is disabled
    private boolean mTranslucentLetterboxingEnabled;
@@ -288,6 +294,9 @@ final class LetterboxConfiguration {
                R.dimen.config_letterboxDefaultMinAspectRatioForUnresizableApps));
        mIsSplitScreenAspectRatioForUnresizableAppsEnabled = mContext.getResources().getBoolean(
                R.bool.config_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled);
        mIsDisplayAspectRatioEnabledForFixedOrientationLetterbox = mContext.getResources()
                .getBoolean(R.bool
                        .config_letterboxIsDisplayAspectRatioForFixedOrientationLetterboxEnabled);
        mTranslucentLetterboxingEnabled = mContext.getResources().getBoolean(
                R.bool.config_letterboxIsEnabledForTranslucentActivities);
        mIsCameraCompatTreatmentEnabled = mContext.getResources().getBoolean(
@@ -942,6 +951,13 @@ final class LetterboxConfiguration {
        return mIsSplitScreenAspectRatioForUnresizableAppsEnabled;
    }

    /**
     * Whether using display aspect ratio as a default aspect ratio for all letterboxed apps.
     */
    boolean getIsDisplayAspectRatioEnabledForFixedOrientationLetterbox() {
        return mIsDisplayAspectRatioEnabledForFixedOrientationLetterbox;
    }

    /**
     * Overrides whether using split screen aspect ratio as a default aspect ratio for unresizable
     * apps.
@@ -950,6 +966,14 @@ final class LetterboxConfiguration {
        mIsSplitScreenAspectRatioForUnresizableAppsEnabled = enabled;
    }

    /**
     * Overrides whether using display aspect ratio as a default aspect ratio for all letterboxed
     * apps.
     */
    void setIsDisplayAspectRatioEnabledForFixedOrientationLetterbox(boolean enabled) {
        mIsDisplayAspectRatioEnabledForFixedOrientationLetterbox = enabled;
    }

    /**
     * Resets whether using split screen aspect ratio as a default aspect ratio for unresizable
     * apps {@link R.bool.config_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled}.
@@ -959,6 +983,16 @@ final class LetterboxConfiguration {
                R.bool.config_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled);
    }

    /**
     * Resets whether using display aspect ratio as a default aspect ratio for all letterboxed
     * apps {@link R.bool.config_letterboxIsDisplayAspectRatioForFixedOrientationLetterboxEnabled}.
     */
    void resetIsDisplayAspectRatioEnabledForFixedOrientationLetterbox() {
        mIsDisplayAspectRatioEnabledForFixedOrientationLetterbox = mContext.getResources()
                .getBoolean(R.bool
                        .config_letterboxIsDisplayAspectRatioForFixedOrientationLetterboxEnabled);
    }

    boolean isTranslucentLetterboxingEnabled() {
        return mTranslucentLetterboxingOverrideEnabled || (mTranslucentLetterboxingEnabled
                && isTranslucentLetterboxingAllowed());
+15 −2
Original line number Diff line number Diff line
@@ -584,7 +584,7 @@ final class LetterboxUiController {
                ? getSplitScreenAspectRatio()
                : mActivityRecord.shouldCreateCompatDisplayInsets()
                    ? getDefaultMinAspectRatioForUnresizableApps()
                    : mLetterboxConfiguration.getFixedOrientationLetterboxAspectRatio();
                    : getDefaultMinAspectRatio();
    }

    private float getDefaultMinAspectRatioForUnresizableApps() {
@@ -593,7 +593,7 @@ final class LetterboxUiController {
            return mLetterboxConfiguration.getDefaultMinAspectRatioForUnresizableApps()
                    > MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO
                            ? mLetterboxConfiguration.getDefaultMinAspectRatioForUnresizableApps()
                            : mLetterboxConfiguration.getFixedOrientationLetterboxAspectRatio();
                            : getDefaultMinAspectRatio();
        }

        return getSplitScreenAspectRatio();
@@ -621,6 +621,16 @@ final class LetterboxUiController {
        return computeAspectRatio(bounds);
    }

    private float getDefaultMinAspectRatio() {
        final DisplayContent displayContent = mActivityRecord.getDisplayContent();
        if (displayContent == null
                || !mLetterboxConfiguration
                    .getIsDisplayAspectRatioEnabledForFixedOrientationLetterbox()) {
            return mLetterboxConfiguration.getFixedOrientationLetterboxAspectRatio();
        }
        return computeAspectRatio(new Rect(displayContent.getBounds()));
    }

    Resources getResources() {
        return mActivityRecord.mWmService.mContext.getResources();
    }
@@ -1014,6 +1024,9 @@ final class LetterboxUiController {
                + mLetterboxConfiguration.getDefaultMinAspectRatioForUnresizableApps());
        pw.println(prefix + "  isSplitScreenAspectRatioForUnresizableAppsEnabled="
                + mLetterboxConfiguration.getIsSplitScreenAspectRatioForUnresizableAppsEnabled());
        pw.println(prefix + "  isDisplayAspectRatioEnabledForFixedOrientationLetterbox="
                + mLetterboxConfiguration
                .getIsDisplayAspectRatioEnabledForFixedOrientationLetterbox());
    }

    /**
+12 −1
Original line number Diff line number Diff line
@@ -955,6 +955,10 @@ public class WindowManagerShellCommand extends ShellCommand {
                    runSetBooleanFlag(pw, mLetterboxConfiguration
                            ::setIsSplitScreenAspectRatioForUnresizableAppsEnabled);
                    break;
                case "--isDisplayAspectRatioEnabledForFixedOrientationLetterbox":
                    runSetBooleanFlag(pw, mLetterboxConfiguration
                            ::setIsDisplayAspectRatioEnabledForFixedOrientationLetterbox);
                    break;
                case "--isTranslucentLetterboxingEnabled":
                    runSetBooleanFlag(pw, mLetterboxConfiguration
                            ::setTranslucentLetterboxingOverrideEnabled);
@@ -1030,6 +1034,10 @@ public class WindowManagerShellCommand extends ShellCommand {
                        mLetterboxConfiguration
                                .resetIsSplitScreenAspectRatioForUnresizableAppsEnabled();
                        break;
                    case "IsDisplayAspectRatioEnabledForFixedOrientationLetterbox":
                        mLetterboxConfiguration
                                .resetIsDisplayAspectRatioEnabledForFixedOrientationLetterbox();
                        break;
                    case "isTranslucentLetterboxingEnabled":
                        mLetterboxConfiguration.resetTranslucentLetterboxingEnabled();
                        break;
@@ -1140,6 +1148,7 @@ public class WindowManagerShellCommand extends ShellCommand {
            mLetterboxConfiguration.resetDefaultPositionForVerticalReachability();
            mLetterboxConfiguration.resetIsEducationEnabled();
            mLetterboxConfiguration.resetIsSplitScreenAspectRatioForUnresizableAppsEnabled();
            mLetterboxConfiguration.resetIsDisplayAspectRatioEnabledForFixedOrientationLetterbox();
            mLetterboxConfiguration.resetTranslucentLetterboxingEnabled();
            mLetterboxConfiguration.resetCameraCompatRefreshEnabled();
            mLetterboxConfiguration.resetCameraCompatRefreshCycleThroughStopEnabled();
@@ -1187,7 +1196,9 @@ public class WindowManagerShellCommand extends ShellCommand {
            pw.println("Is using split screen aspect ratio as aspect ratio for unresizable apps: "
                    + mLetterboxConfiguration
                            .getIsSplitScreenAspectRatioForUnresizableAppsEnabled());

            pw.println("Is using display aspect ratio as aspect ratio for all letterboxed apps: "
                    + mLetterboxConfiguration
                            .getIsDisplayAspectRatioEnabledForFixedOrientationLetterbox());
            pw.println("    Is activity \"refresh\" in camera compatibility treatment enabled: "
                    + mLetterboxConfiguration.isCameraCompatRefreshEnabled());
            pw.println("    Refresh using \"stopped -> resumed\" cycle: "
Loading