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

Commit b19e2ad2 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Schedule new transition on aspect ratio change only" into rvc-dev am:...

Merge "Schedule new transition on aspect ratio change only" into rvc-dev am: f71d1dc5 am: f4363577

Change-Id: I0f66d422261c1ffd3e423f276d1fd9007b8db489
parents bf64db60 f4363577
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -219,12 +219,28 @@ public class PipTaskOrganizer extends ITaskOrganizer.Stub {

    @Override
    public void onTaskInfoChanged(ActivityManager.RunningTaskInfo info) {
        final PictureInPictureParams newParams = info.pictureInPictureParams;
        if (!shouldUpdateDestinationBounds(newParams)) {
            Log.d(TAG, "Ignored onTaskInfoChanged with PiP param: " + newParams);
            return;
        }
        final Rect destinationBounds = mPipBoundsHandler.getDestinationBounds(
                getAspectRatioOrDefault(info.pictureInPictureParams), null /* bounds */);
                getAspectRatioOrDefault(newParams), null /* bounds */);
        Objects.requireNonNull(destinationBounds, "Missing destination bounds");
        animateResizePip(destinationBounds, DURATION_DEFAULT_MS);
    }

    /**
     * @return {@code true} if the aspect ratio is changed since no other parameters within
     * {@link PictureInPictureParams} would affect the bounds.
     */
    private boolean shouldUpdateDestinationBounds(PictureInPictureParams params) {
        if (params == null || mTaskInfo.pictureInPictureParams == null) {
            return params != mTaskInfo.pictureInPictureParams;
        }
        return !Objects.equals(mTaskInfo.pictureInPictureParams.getAspectRatioRational(),
                params.getAspectRatioRational());
    }

    /**
     * Directly perform manipulation/resize on the leash. This will not perform any