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

Commit 74188e9b authored by Ikram Gabiyev's avatar Ikram Gabiyev
Browse files

Set sourceRectHint null if too small

Set sourceRectHint in pictureInPictureParams to null
if it is smaller than the entry bounds in PipTransition.
This makes sure we use content overlay to enter PiP.

Bug: 280508242
Test: reproduce the steps in the bug
Change-Id: Id622756e6005ae6535373f4975638eb3971d917c
parent 2b836cd5
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -180,6 +180,35 @@ public class PipBoundsAlgorithm {
        return null;
    }


    /**
     * Returns the source hint rect if it is valid (if provided and is contained by the current
     * task bounds, while not smaller than the destination bounds).
     */
    @Nullable
    public static Rect getValidSourceHintRect(PictureInPictureParams params, Rect sourceBounds,
            Rect destinationBounds) {
        Rect sourceRectHint = getValidSourceHintRect(params, sourceBounds);
        if (!isSourceRectHintValidForEnterPip(sourceRectHint, destinationBounds)) {
            sourceRectHint = null;
        }
        return sourceRectHint;
    }

    /**
     * This is a situation in which the source rect hint on at least one axis is smaller
     * than the destination bounds, which represents a problem because we would have to scale
     * up that axis to fit the bounds. So instead, just fallback to the non-source hint
     * animation in this case.
     *
     * @return {@code false} if the given source is too small to use for the entering animation.
     */
    static boolean isSourceRectHintValidForEnterPip(Rect sourceRectHint, Rect destinationBounds) {
        return sourceRectHint != null
                && sourceRectHint.width() > destinationBounds.width()
                && sourceRectHint.height() > destinationBounds.height();
    }

    public float getDefaultAspectRatio() {
        return mDefaultAspectRatio;
    }
+2 −16
Original line number Diff line number Diff line
@@ -1657,8 +1657,8 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
                    "%s: Abort animation, invalid leash", TAG);
            return null;
        }
        if (isInPipDirection(direction)
                && !isSourceRectHintValidForEnterPip(sourceHintRect, destinationBounds)) {
        if (isInPipDirection(direction) && !PipBoundsAlgorithm
                .isSourceRectHintValidForEnterPip(sourceHintRect, destinationBounds)) {
            // The given source rect hint is too small for enter PiP animation, reset it to null.
            sourceHintRect = null;
        }
@@ -1756,20 +1756,6 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
        return sourceHintRect;
    }

    /**
     * This is a situation in which the source rect hint on at least one axis is smaller
     * than the destination bounds, which represents a problem because we would have to scale
     * up that axis to fit the bounds. So instead, just fallback to the non-source hint
     * animation in this case.
     *
     * @return {@code false} if the given source is too small to use for the entering animation.
     */
    private boolean isSourceRectHintValidForEnterPip(Rect sourceRectHint, Rect destinationBounds) {
        return sourceRectHint != null
                && sourceRectHint.width() > destinationBounds.width()
                && sourceRectHint.height() > destinationBounds.height();
    }

    /**
     * Sync with {@link SplitScreenController} on destination bounds if PiP is going to
     * split screen.
+1 −1
Original line number Diff line number Diff line
@@ -764,7 +764,7 @@ public class PipTransition extends PipTransitionController {
        final Rect currentBounds = taskInfo.configuration.windowConfiguration.getBounds();
        int rotationDelta = deltaRotation(startRotation, endRotation);
        Rect sourceHintRect = PipBoundsAlgorithm.getValidSourceHintRect(
                taskInfo.pictureInPictureParams, currentBounds);
                taskInfo.pictureInPictureParams, currentBounds, destinationBounds);
        if (rotationDelta != Surface.ROTATION_0 && mInFixedRotation) {
            // Need to get the bounds of new rotation in old rotation for fixed rotation,
            computeEnterPipRotatedBounds(rotationDelta, startRotation, endRotation, taskInfo,