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

Commit 507fc910 authored by Mariia Sandrikova's avatar Mariia Sandrikova Committed by Automerger Merge Worker
Browse files

Merge "Allow using split aspect ratio for unresizable apps" into tm-qpr-dev am: 49be81a9

parents 319ff58f 49be81a9
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -5182,6 +5182,9 @@
         An exception will be thrown if the given aspect ratio < 4:3.  -->
         An exception will be thrown if the given aspect ratio < 4:3.  -->
    <item name="config_letterboxDefaultMinAspectRatioForUnresizableApps" format="float" type="dimen">1.5</item>
    <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
    <!-- Whether a camera compat controller is enabled to allow the user to apply or revert
         treatment for stretched issues in camera viewfinder. -->
         treatment for stretched issues in camera viewfinder. -->
    <bool name="config_isCameraCompatControlForStretchedIssuesEnabled">false</bool>
    <bool name="config_isCameraCompatControlForStretchedIssuesEnabled">false</bool>
+1 −0
Original line number Original line Diff line number Diff line
@@ -4396,6 +4396,7 @@
  <java-symbol type="integer" name="config_letterboxDefaultPositionForVerticalReachability" />
  <java-symbol type="integer" name="config_letterboxDefaultPositionForVerticalReachability" />
  <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_isCameraCompatControlForStretchedIssuesEnabled" />
  <java-symbol type="bool" name="config_isCameraCompatControlForStretchedIssuesEnabled" />


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


        final float letterboxAspectRatioOverride =
        final float letterboxAspectRatioOverride =
                mLetterboxUiController.getFixedOrientationLetterboxAspectRatio(newParentConfig);
                mWmService.mLetterboxConfiguration.getFixedOrientationLetterboxAspectRatio();
        final float desiredAspectRatio =
        final float desiredAspectRatio =
                letterboxAspectRatioOverride > MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO
                letterboxAspectRatioOverride > MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO
                        ? letterboxAspectRatioOverride : computeAspectRatio(parentBounds);
                        ? 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
                    // if an app sets orientation to portrait dynamically because of aspect ratio
                    // restriction applied here.
                    // restriction applied here.
                    && getRequestedConfigurationOrientation() != ORIENTATION_UNDEFINED
                    && getRequestedConfigurationOrientation() != ORIENTATION_UNDEFINED
                ? mWmService.mLetterboxConfiguration.getDefaultMinAspectRatioForUnresizableApps()
                ? mLetterboxUiController.getDefaultMinAspectRatioForUnresizableApps()
                : infoAspectRatio;
                : infoAspectRatio;
    }
    }


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


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

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


    /**
    /**
@@ -797,4 +802,28 @@ final class LetterboxConfiguration {
                R.bool.config_letterboxIsEducationEnabled);
                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 Original line Diff line number Diff line
@@ -211,12 +211,10 @@ final class LetterboxUiController {
                : mLetterboxConfiguration.getLetterboxVerticalPositionMultiplier();
                : mLetterboxConfiguration.getLetterboxVerticalPositionMultiplier();
    }
    }


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


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


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

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


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


    /**
    /**
Loading