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

Commit 9d73e282 authored by Mariia Sandrikova's avatar Mariia Sandrikova Committed by Automerger Merge Worker
Browse files

Merge "Set min aspect ratio for unresizable apps to 3:2." into tm-qpr-dev am: 4d3dbf1c

parents 1aced357 4d3dbf1c
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -5176,6 +5176,12 @@
    <!-- Whether displaying letterbox education is enabled for letterboxed fullscreen apps. -->
    <bool name="config_letterboxIsEducationEnabled">false</bool>

    <!-- Default min aspect ratio for unresizable apps which is used when an app doesn't specify
         android:minAspectRatio in accordance with CDD 7.1.1.2 requirement:
         https://source.android.com/compatibility/12/android-12-cdd#7112_screen_aspect_ratio.
         An exception will be thrown if the given aspect ratio < 4:3.  -->
    <item name="config_letterboxDefaultMinAspectRatioForUnresizableApps" format="float" type="dimen">1.5</item>

    <!-- Whether a camera compat controller is enabled to allow the user to apply or revert
         treatment for stretched issues in camera viewfinder. -->
    <bool name="config_isCameraCompatControlForStretchedIssuesEnabled">false</bool>
+1 −0
Original line number Diff line number Diff line
@@ -4395,6 +4395,7 @@
  <java-symbol type="integer" name="config_letterboxDefaultPositionForHorizontalReachability" />
  <java-symbol type="integer" name="config_letterboxDefaultPositionForVerticalReachability" />
  <java-symbol type="bool" name="config_letterboxIsEducationEnabled" />
  <java-symbol type="dimen" name="config_letterboxDefaultMinAspectRatioForUnresizableApps" />
  <java-symbol type="bool" name="config_isCameraCompatControlForStretchedIssuesEnabled" />

  <java-symbol type="bool" name="config_hideDisplayCutoutWithDisplayArea" />
+16 −2
Original line number Diff line number Diff line
@@ -7860,7 +7860,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        // Vertical position
        int offsetY = 0;
        if (parentBounds.height() != screenResolvedBounds.height()) {

            if (screenResolvedBounds.height() >= parentAppBounds.height()) {
                // If resolved bounds overlap with insets, center within app bounds.
                offsetY = getCenterOffset(
@@ -7908,6 +7907,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        return mLetterboxBoundsForFixedOrientationAndAspectRatio != null;
    }

    boolean isAspectRatioApplied() {
        return mIsAspectRatioApplied;
    }

    /**
     * Whether this activity is eligible for letterbox eduction.
     *
@@ -8632,7 +8635,18 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
     * Returns the min aspect ratio of this activity.
     */
    private float getMinAspectRatio() {
        return info.getMinAspectRatio(getRequestedOrientation());
        float infoAspectRatio = info.getMinAspectRatio(getRequestedOrientation());
        // Complying with the CDD 7.1.1.2 requirement for unresizble apps:
        // https://source.android.com/compatibility/12/android-12-cdd#7112_screen_aspect_ratio
        return infoAspectRatio < 1f && info.resizeMode == RESIZE_MODE_UNRESIZEABLE
                    // TODO(233582832): Consider removing fixed-orientation condition.
                    // Some apps switching from tablet to phone layout at the certain size
                    // threshold. This may lead to flickering on tablets in landscape orientation
                    // if an app sets orientation to portrait dynamically because of aspect ratio
                    // restriction applied here.
                    && getRequestedConfigurationOrientation() != ORIENTATION_UNDEFINED
                ? mWmService.mLetterboxConfiguration.getDefaultMinAspectRatioForUnresizableApps()
                : infoAspectRatio;
    }

    /**
+49 −0
Original line number Diff line number Diff line
@@ -37,6 +37,11 @@ final class LetterboxConfiguration {
     */
    static final float MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO = 1.0f;

    // Min allowed aspect ratio for unresizable apps which is used when an app doesn't specify
    // android:minAspectRatio in accordance with the CDD 7.1.1.2 requirement:
    // https://source.android.com/compatibility/12/android-12-cdd#7112_screen_aspect_ratio
    static final float MIN_UNRESIZABLE_ASPECT_RATIO = 4 / 3f;

    /** Enum for Letterbox background type. */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef({LETTERBOX_BACKGROUND_SOLID_COLOR, LETTERBOX_BACKGROUND_APP_COLOR_BACKGROUND,
@@ -104,6 +109,11 @@ final class LetterboxConfiguration {
    // MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO will be ignored.
    private float mFixedOrientationLetterboxAspectRatio;

    // Default min aspect ratio for unresizable apps which is used when an app doesn't specify
    // android:minAspectRatio in accordance with the CDD 7.1.1.2 requirement:
    // https://source.android.com/compatibility/12/android-12-cdd#7112_screen_aspect_ratio
    private float mDefaultMinAspectRatioForUnresizableApps;

    // Corners radius for activities presented in the letterbox mode, values < 0 will be ignored.
    private int mLetterboxActivityCornersRadius;

@@ -204,6 +214,8 @@ final class LetterboxConfiguration {
        mLetterboxPositionForVerticalReachability = mDefaultPositionForVerticalReachability;
        mIsEducationEnabled = mContext.getResources().getBoolean(
                R.bool.config_letterboxIsEducationEnabled);
        setDefaultMinAspectRatioForUnresizableApps(mContext.getResources().getFloat(
                R.dimen.config_letterboxDefaultMinAspectRatioForUnresizableApps));
    }

    /**
@@ -232,6 +244,43 @@ final class LetterboxConfiguration {
        return mFixedOrientationLetterboxAspectRatio;
    }

    /**
     * Resets the min aspect ratio for unresizable apps which is used when an app doesn't specify
     * {@code android:minAspectRatio} to {@link
     * R.dimen.config_letterboxDefaultMinAspectRatioForUnresizableApps}.
     *
     * @throws AssertionError if {@link
     * R.dimen.config_letterboxDefaultMinAspectRatioForUnresizableApps} is < {@link
     * #MIN_UNRESIZABLE_ASPECT_RATIO}.
     */
    void resetDefaultMinAspectRatioForUnresizableApps() {
        setDefaultMinAspectRatioForUnresizableApps(mContext.getResources().getFloat(
                R.dimen.config_letterboxDefaultMinAspectRatioForUnresizableApps));
    }

    /**
     * Gets the min aspect ratio for unresizable apps which is used when an app doesn't specify
     * {@code android:minAspectRatio}.
     */
    float getDefaultMinAspectRatioForUnresizableApps() {
        return mDefaultMinAspectRatioForUnresizableApps;
    }

    /**
     * Overrides the min aspect ratio for unresizable apps which is used when an app doesn't
     * specify {@code android:minAspectRatio}.
     *
     * @throws AssertionError if given value is < {@link #MIN_UNRESIZABLE_ASPECT_RATIO}.
     */
    void setDefaultMinAspectRatioForUnresizableApps(float aspectRatio) {
        if (aspectRatio < MIN_UNRESIZABLE_ASPECT_RATIO) {
            throw new AssertionError(
                    "Unexpected min aspect ratio for unresizable apps, it should be <= "
                            + MIN_UNRESIZABLE_ASPECT_RATIO + " but was " + aspectRatio);
        }
        mDefaultMinAspectRatioForUnresizableApps = aspectRatio;
    }

    /**
     * Overrides corners raidus for activities presented in the letterbox mode. If given value < 0,
     * both it and a value of {@link
+5 −0
Original line number Diff line number Diff line
@@ -540,6 +540,8 @@ final class LetterboxUiController {
        pw.println(prefix + "  fixedOrientationLetterboxAspectRatio="
                + getFixedOrientationLetterboxAspectRatio(
                        mActivityRecord.getParent().getConfiguration()));
        pw.println(prefix + "  defaultMinAspectRatioForUnresizableApps="
                + mLetterboxConfiguration.getDefaultMinAspectRatioForUnresizableApps());
    }

    /**
@@ -556,6 +558,9 @@ final class LetterboxUiController {
        if (mainWin.isLetterboxedForDisplayCutout()) {
            return "DISPLAY_CUTOUT";
        }
        if (mActivityRecord.isAspectRatioApplied()) {
            return "ASPECT_RATIO";
        }
        return "UNKNOWN_REASON";
    }

Loading