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

Commit 86edc8c5 authored by Mateusz Cicheński's avatar Mateusz Cicheński
Browse files

Validate aspect ratio on PiP params change.

If the params do not provide the aspect ratio we will return 0f, which
impacts further computations on e.g. pinch resize gesture.

Bug: 276455406
Test: manually modify ApiDemos to not provide aspect ratio, enter PiP
and verify that aspect ratio is set to default value instead of 0

Change-Id: Ie734a4e35ccbccdad5a2bee0f0e1bd507dcc1025
parent b3d00601
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -198,7 +198,7 @@ public class PipBoundsAlgorithm {
    /**
     * @return whether the given {@param aspectRatio} is valid.
     */
    private boolean isValidPictureInPictureAspectRatio(float aspectRatio) {
    public boolean isValidPictureInPictureAspectRatio(float aspectRatio) {
        return Float.compare(mMinAspectRatio, aspectRatio) <= 0
                && Float.compare(aspectRatio, mMaxAspectRatio) <= 0;
    }
+10 −1
Original line number Diff line number Diff line
@@ -1230,7 +1230,16 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
    protected void applyNewPictureInPictureParams(@NonNull PictureInPictureParams params) {
        if (mDeferredTaskInfo != null || PipUtils.aspectRatioChanged(params.getAspectRatioFloat(),
                mPictureInPictureParams.getAspectRatioFloat())) {
            if (mPipBoundsAlgorithm.isValidPictureInPictureAspectRatio(
                    params.getAspectRatioFloat())) {
                mPipParamsChangedForwarder.notifyAspectRatioChanged(params.getAspectRatioFloat());
            } else {
                ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
                        "%s: New aspect ratio is not valid."
                                + " hasAspectRatio=%b"
                                + " aspectRatio=%f",
                        TAG, params.hasSetAspectRatio(), params.getAspectRatioFloat());
            }
        }
        if (mDeferredTaskInfo != null
                || PipUtils.remoteActionsChanged(params.getActions(),