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

Commit 73197f91 authored by Mariia Sandrikova's avatar Mariia Sandrikova
Browse files

Allow using split aspect ratio for unresizable apps

Bug: 233650077
Test: atest WmTests:SizeCompatTests
Change-Id: I650bcbaa763aec848676fc87956826d3e8b50be5
parent 4c996a74
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -5182,6 +5182,9 @@
         An exception will be thrown if the given aspect ratio < 4:3.  -->
    <item name="config_letterboxDefaultMinAspectRatioForUnresizableApps" format="float" type="dimen">1.5</item>

    <!-- Whether using split screen aspect ratio as a default aspect ratio for unresizable apps. -->
    <bool name="config_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled">false</bool>

    <!-- 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
@@ -4396,6 +4396,7 @@
  <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_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled" />
  <java-symbol type="bool" name="config_isCameraCompatControlForStretchedIssuesEnabled" />

  <java-symbol type="bool" name="config_hideDisplayCutoutWithDisplayArea" />
+2 −2
Original line number Diff line number Diff line
@@ -8082,7 +8082,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        resolvedBounds.set(containingBounds);

        final float letterboxAspectRatioOverride =
                mLetterboxUiController.getFixedOrientationLetterboxAspectRatio(newParentConfig);
                mWmService.mLetterboxConfiguration.getFixedOrientationLetterboxAspectRatio();
        final float desiredAspectRatio =
                letterboxAspectRatioOverride > MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO
                        ? letterboxAspectRatioOverride : computeAspectRatio(parentBounds);
@@ -8645,7 +8645,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                    // if an app sets orientation to portrait dynamically because of aspect ratio
                    // restriction applied here.
                    && getRequestedConfigurationOrientation() != ORIENTATION_UNDEFINED
                ? mWmService.mLetterboxConfiguration.getDefaultMinAspectRatioForUnresizableApps()
                ? mLetterboxUiController.getDefaultMinAspectRatioForUnresizableApps()
                : infoAspectRatio;
    }

+29 −0
Original line number Diff line number Diff line
@@ -187,6 +187,9 @@ final class LetterboxConfiguration {
    // Whether education is allowed for letterboxed fullscreen apps.
    private boolean mIsEducationEnabled;

    // Whether using split screen aspect ratio as a default aspect ratio for unresizable apps.
    private boolean mIsSplitScreenAspectRatioForUnresizableAppsEnabled;

    LetterboxConfiguration(Context systemUiContext) {
        mContext = systemUiContext;
        mFixedOrientationLetterboxAspectRatio = mContext.getResources().getFloat(
@@ -216,6 +219,8 @@ final class LetterboxConfiguration {
                R.bool.config_letterboxIsEducationEnabled);
        setDefaultMinAspectRatioForUnresizableApps(mContext.getResources().getFloat(
                R.dimen.config_letterboxDefaultMinAspectRatioForUnresizableApps));
        mIsSplitScreenAspectRatioForUnresizableAppsEnabled = mContext.getResources().getBoolean(
                R.bool.config_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled);
    }

    /**
@@ -797,4 +802,28 @@ final class LetterboxConfiguration {
                R.bool.config_letterboxIsEducationEnabled);
    }

    /**
     * Whether using split screen aspect ratio as a default aspect ratio for unresizable apps.
     */
    boolean getIsSplitScreenAspectRatioForUnresizableAppsEnabled() {
        return mIsSplitScreenAspectRatioForUnresizableAppsEnabled;
    }

    /**
     * Overrides whether using split screen aspect ratio as a default aspect ratio for unresizable
     * apps.
     */
    void setIsSplitScreenAspectRatioForUnresizableAppsEnabled(boolean enabled) {
        mIsSplitScreenAspectRatioForUnresizableAppsEnabled = enabled;
    }

    /**
     * Resets whether using split screen aspect ratio as a default aspect ratio for unresizable
     * apps {@link R.bool.config_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled}.
     */
    void resetIsSplitScreenAspectRatioForUnresizableAppsEnabled() {
        mIsSplitScreenAspectRatioForUnresizableAppsEnabled = mContext.getResources().getBoolean(
                R.bool.config_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled);
    }

}
+15 −12
Original line number Diff line number Diff line
@@ -211,12 +211,10 @@ final class LetterboxUiController {
                : mLetterboxConfiguration.getLetterboxVerticalPositionMultiplier();
    }

    float getFixedOrientationLetterboxAspectRatio(Configuration parentConfiguration) {
        // Don't check resolved windowing mode because it may not be updated yet during
        // configuration change.
        if (!isHorizontalReachabilityEnabled(parentConfiguration)
                && !isVerticalReachabilityEnabled(parentConfiguration)) {
            return mLetterboxConfiguration.getFixedOrientationLetterboxAspectRatio();
    float getDefaultMinAspectRatioForUnresizableApps() {
        if (!mLetterboxConfiguration.getIsSplitScreenAspectRatioForUnresizableAppsEnabled()
                || mActivityRecord.getDisplayContent() == null) {
            return mLetterboxConfiguration.getDefaultMinAspectRatioForUnresizableApps();
        }

        int dividerWindowWidth =
@@ -226,10 +224,14 @@ final class LetterboxUiController {
        int dividerSize = dividerWindowWidth - dividerInsets * 2;

        // Getting the same aspect ratio that apps get in split screen.
        Rect bounds = new Rect(parentConfiguration.windowConfiguration.getAppBounds());
        bounds.inset(dividerSize, /* dy */ 0);
        Rect bounds = new Rect(mActivityRecord.getDisplayContent().getBounds());
        if (bounds.width() >= bounds.height()) {
            bounds.inset(/* dx */ dividerSize, /* dy */ 0);
            bounds.right = bounds.centerX();

        } else {
            bounds.inset(/* dx */ 0, /* dy */ dividerSize);
            bounds.bottom = bounds.centerY();
        }
        return computeAspectRatio(bounds);
    }

@@ -538,10 +540,11 @@ final class LetterboxUiController {
        pw.println(prefix + "  letterboxVerticalPositionMultiplier="
                + getVerticalPositionMultiplier(mActivityRecord.getParent().getConfiguration()));
        pw.println(prefix + "  fixedOrientationLetterboxAspectRatio="
                + getFixedOrientationLetterboxAspectRatio(
                        mActivityRecord.getParent().getConfiguration()));
                + mLetterboxConfiguration.getFixedOrientationLetterboxAspectRatio());
        pw.println(prefix + "  defaultMinAspectRatioForUnresizableApps="
                + mLetterboxConfiguration.getDefaultMinAspectRatioForUnresizableApps());
        pw.println(prefix + "  isSplitScreenAspectRatioForUnresizableAppsEnabled="
                + mLetterboxConfiguration.getIsSplitScreenAspectRatioForUnresizableAppsEnabled());
    }

    /**
Loading