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

Commit b18e7c37 authored by Vali Calinescu's avatar Vali Calinescu Committed by Automerger Merge Worker
Browse files

Merge "Introduce config to use display aspect ratio for letterbox" into...

Merge "Introduce config to use display aspect ratio for letterbox" into tm-qpr-dev am: e32cf9e7 am: 9353ce7a

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20943145



Change-Id: I5ce3db0d030bd1a5693407762f9c066ca58f7459
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 49afa597 9353ce7a
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -5414,6 +5414,9 @@
    <!-- Whether using split screen aspect ratio as a default aspect ratio for unresizable apps. -->
    <!-- Whether using split screen aspect ratio as a default aspect ratio for unresizable apps. -->
    <bool name="config_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled">false</bool>
    <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.
    <!-- Whether the specific behaviour for translucent activities letterboxing is enabled.
         TODO(b/255532890) Enable when ignoreOrientationRequest is set -->
         TODO(b/255532890) Enable when ignoreOrientationRequest is set -->
    <bool name="config_letterboxIsEnabledForTranslucentActivities">false</bool>
    <bool name="config_letterboxIsEnabledForTranslucentActivities">false</bool>
+1 −0
Original line number Original line Diff line number Diff line
@@ -4442,6 +4442,7 @@
  <java-symbol type="bool" name="config_letterboxIsEducationEnabled" />
  <java-symbol type="bool" name="config_letterboxIsEducationEnabled" />
  <java-symbol type="dimen" name="config_letterboxDefaultMinAspectRatioForUnresizableApps" />
  <java-symbol type="dimen" name="config_letterboxDefaultMinAspectRatioForUnresizableApps" />
  <java-symbol type="bool" name="config_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled" />
  <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_isCompatFakeFocusEnabled" />
  <java-symbol type="bool" name="config_isWindowManagerCameraCompatTreatmentEnabled" />
  <java-symbol type="bool" name="config_isWindowManagerCameraCompatTreatmentEnabled" />
  <java-symbol type="bool" name="config_isCameraCompatControlForStretchedIssuesEnabled" />
  <java-symbol type="bool" name="config_isCameraCompatControlForStretchedIssuesEnabled" />
+34 −0
Original line number Original line 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.
    // Whether using split screen aspect ratio as a default aspect ratio for unresizable apps.
    private boolean mIsSplitScreenAspectRatioForUnresizableAppsEnabled;
    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}
    // Whether letterboxing strategy is enabled for translucent activities. If {@value false}
    // all the feature is disabled
    // all the feature is disabled
    private boolean mTranslucentLetterboxingEnabled;
    private boolean mTranslucentLetterboxingEnabled;
@@ -288,6 +294,9 @@ final class LetterboxConfiguration {
                R.dimen.config_letterboxDefaultMinAspectRatioForUnresizableApps));
                R.dimen.config_letterboxDefaultMinAspectRatioForUnresizableApps));
        mIsSplitScreenAspectRatioForUnresizableAppsEnabled = mContext.getResources().getBoolean(
        mIsSplitScreenAspectRatioForUnresizableAppsEnabled = mContext.getResources().getBoolean(
                R.bool.config_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled);
                R.bool.config_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled);
        mIsDisplayAspectRatioEnabledForFixedOrientationLetterbox = mContext.getResources()
                .getBoolean(R.bool
                        .config_letterboxIsDisplayAspectRatioForFixedOrientationLetterboxEnabled);
        mTranslucentLetterboxingEnabled = mContext.getResources().getBoolean(
        mTranslucentLetterboxingEnabled = mContext.getResources().getBoolean(
                R.bool.config_letterboxIsEnabledForTranslucentActivities);
                R.bool.config_letterboxIsEnabledForTranslucentActivities);
        mIsCameraCompatTreatmentEnabled = mContext.getResources().getBoolean(
        mIsCameraCompatTreatmentEnabled = mContext.getResources().getBoolean(
@@ -942,6 +951,13 @@ final class LetterboxConfiguration {
        return mIsSplitScreenAspectRatioForUnresizableAppsEnabled;
        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
     * Overrides whether using split screen aspect ratio as a default aspect ratio for unresizable
     * apps.
     * apps.
@@ -950,6 +966,14 @@ final class LetterboxConfiguration {
        mIsSplitScreenAspectRatioForUnresizableAppsEnabled = enabled;
        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
     * Resets whether using split screen aspect ratio as a default aspect ratio for unresizable
     * apps {@link R.bool.config_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled}.
     * apps {@link R.bool.config_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled}.
@@ -959,6 +983,16 @@ final class LetterboxConfiguration {
                R.bool.config_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled);
                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() {
    boolean isTranslucentLetterboxingEnabled() {
        return mTranslucentLetterboxingOverrideEnabled || (mTranslucentLetterboxingEnabled
        return mTranslucentLetterboxingOverrideEnabled || (mTranslucentLetterboxingEnabled
                && isTranslucentLetterboxingAllowed());
                && isTranslucentLetterboxingAllowed());
+15 −2
Original line number Original line Diff line number Diff line
@@ -584,7 +584,7 @@ final class LetterboxUiController {
                ? getSplitScreenAspectRatio()
                ? getSplitScreenAspectRatio()
                : mActivityRecord.shouldCreateCompatDisplayInsets()
                : mActivityRecord.shouldCreateCompatDisplayInsets()
                    ? getDefaultMinAspectRatioForUnresizableApps()
                    ? getDefaultMinAspectRatioForUnresizableApps()
                    : mLetterboxConfiguration.getFixedOrientationLetterboxAspectRatio();
                    : getDefaultMinAspectRatio();
    }
    }


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


        return getSplitScreenAspectRatio();
        return getSplitScreenAspectRatio();
@@ -621,6 +621,16 @@ final class LetterboxUiController {
        return computeAspectRatio(bounds);
        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() {
    Resources getResources() {
        return mActivityRecord.mWmService.mContext.getResources();
        return mActivityRecord.mWmService.mContext.getResources();
    }
    }
@@ -1014,6 +1024,9 @@ final class LetterboxUiController {
                + mLetterboxConfiguration.getDefaultMinAspectRatioForUnresizableApps());
                + mLetterboxConfiguration.getDefaultMinAspectRatioForUnresizableApps());
        pw.println(prefix + "  isSplitScreenAspectRatioForUnresizableAppsEnabled="
        pw.println(prefix + "  isSplitScreenAspectRatioForUnresizableAppsEnabled="
                + mLetterboxConfiguration.getIsSplitScreenAspectRatioForUnresizableAppsEnabled());
                + mLetterboxConfiguration.getIsSplitScreenAspectRatioForUnresizableAppsEnabled());
        pw.println(prefix + "  isDisplayAspectRatioEnabledForFixedOrientationLetterbox="
                + mLetterboxConfiguration
                .getIsDisplayAspectRatioEnabledForFixedOrientationLetterbox());
    }
    }


    /**
    /**
+12 −1
Original line number Original line Diff line number Diff line
@@ -970,6 +970,10 @@ public class WindowManagerShellCommand extends ShellCommand {
                    runSetBooleanFlag(pw, mLetterboxConfiguration
                    runSetBooleanFlag(pw, mLetterboxConfiguration
                            ::setIsSplitScreenAspectRatioForUnresizableAppsEnabled);
                            ::setIsSplitScreenAspectRatioForUnresizableAppsEnabled);
                    break;
                    break;
                case "--isDisplayAspectRatioEnabledForFixedOrientationLetterbox":
                    runSetBooleanFlag(pw, mLetterboxConfiguration
                            ::setIsDisplayAspectRatioEnabledForFixedOrientationLetterbox);
                    break;
                case "--isTranslucentLetterboxingEnabled":
                case "--isTranslucentLetterboxingEnabled":
                    runSetBooleanFlag(pw, mLetterboxConfiguration
                    runSetBooleanFlag(pw, mLetterboxConfiguration
                            ::setTranslucentLetterboxingOverrideEnabled);
                            ::setTranslucentLetterboxingOverrideEnabled);
@@ -1045,6 +1049,10 @@ public class WindowManagerShellCommand extends ShellCommand {
                        mLetterboxConfiguration
                        mLetterboxConfiguration
                                .resetIsSplitScreenAspectRatioForUnresizableAppsEnabled();
                                .resetIsSplitScreenAspectRatioForUnresizableAppsEnabled();
                        break;
                        break;
                    case "IsDisplayAspectRatioEnabledForFixedOrientationLetterbox":
                        mLetterboxConfiguration
                                .resetIsDisplayAspectRatioEnabledForFixedOrientationLetterbox();
                        break;
                    case "isTranslucentLetterboxingEnabled":
                    case "isTranslucentLetterboxingEnabled":
                        mLetterboxConfiguration.resetTranslucentLetterboxingEnabled();
                        mLetterboxConfiguration.resetTranslucentLetterboxingEnabled();
                        break;
                        break;
@@ -1155,6 +1163,7 @@ public class WindowManagerShellCommand extends ShellCommand {
            mLetterboxConfiguration.resetDefaultPositionForVerticalReachability();
            mLetterboxConfiguration.resetDefaultPositionForVerticalReachability();
            mLetterboxConfiguration.resetIsEducationEnabled();
            mLetterboxConfiguration.resetIsEducationEnabled();
            mLetterboxConfiguration.resetIsSplitScreenAspectRatioForUnresizableAppsEnabled();
            mLetterboxConfiguration.resetIsSplitScreenAspectRatioForUnresizableAppsEnabled();
            mLetterboxConfiguration.resetIsDisplayAspectRatioEnabledForFixedOrientationLetterbox();
            mLetterboxConfiguration.resetTranslucentLetterboxingEnabled();
            mLetterboxConfiguration.resetTranslucentLetterboxingEnabled();
            mLetterboxConfiguration.resetCameraCompatRefreshEnabled();
            mLetterboxConfiguration.resetCameraCompatRefreshEnabled();
            mLetterboxConfiguration.resetCameraCompatRefreshCycleThroughStopEnabled();
            mLetterboxConfiguration.resetCameraCompatRefreshCycleThroughStopEnabled();
@@ -1202,7 +1211,9 @@ public class WindowManagerShellCommand extends ShellCommand {
            pw.println("Is using split screen aspect ratio as aspect ratio for unresizable apps: "
            pw.println("Is using split screen aspect ratio as aspect ratio for unresizable apps: "
                    + mLetterboxConfiguration
                    + mLetterboxConfiguration
                            .getIsSplitScreenAspectRatioForUnresizableAppsEnabled());
                            .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: "
            pw.println("    Is activity \"refresh\" in camera compatibility treatment enabled: "
                    + mLetterboxConfiguration.isCameraCompatRefreshEnabled());
                    + mLetterboxConfiguration.isCameraCompatRefreshEnabled());
            pw.println("    Refresh using \"stopped -> resumed\" cycle: "
            pw.println("    Refresh using \"stopped -> resumed\" cycle: "
Loading