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

Commit 951dc026 authored by Hongwei Wang's avatar Hongwei Wang
Browse files

Work around for display info mismatch during the PiP transition

This is a work around for b/152720544, we noticed that when entering PiP
from a landscape activity to home screen in portrait mode
- OnDisplayChangingListener is not called
- PinnedStackListener#onDisplayInfoChanged gets called after the
transition is started

This work around updates the destination bounds once this mismatch is
detected and a more proper fix should be there for b/152809058

Bug: 152720544
Test: manually enter/exit PiP from Play Movies for X times
Change-Id: I833027d4a4638a7a99f7abd2f50e493bdf5bad03
parent f4d9f16f
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -110,6 +110,10 @@ public class PipAnimationController {
        return mCurrentAnimator;
        return mCurrentAnimator;
    }
    }


    PipTransitionAnimator getCurrentAnimator() {
        return mCurrentAnimator;
    }

    private PipTransitionAnimator setupPipTransitionAnimator(PipTransitionAnimator animator) {
    private PipTransitionAnimator setupPipTransitionAnimator(PipTransitionAnimator animator) {
        animator.setSurfaceTransactionHelper(mSurfaceTransactionHelper);
        animator.setSurfaceTransactionHelper(mSurfaceTransactionHelper);
        animator.setInterpolator(mFastOutSlowInInterpolator);
        animator.setInterpolator(mFastOutSlowInInterpolator);
@@ -239,6 +243,9 @@ public class PipAnimationController {


        void setDestinationBounds(Rect destinationBounds) {
        void setDestinationBounds(Rect destinationBounds) {
            mDestinationBounds.set(destinationBounds);
            mDestinationBounds.set(destinationBounds);
            if (mAnimationType == ANIM_TYPE_ALPHA) {
                onStartTransaction(mLeash, newSurfaceControlTransaction());
            }
        }
        }


        void setCurrentValue(T value) {
        void setCurrentValue(T value) {
+4 −0
Original line number Original line Diff line number Diff line
@@ -199,6 +199,10 @@ public class PipBoundsHandler {
        return mLastDestinationBounds;
        return mLastDestinationBounds;
    }
    }


    public Rect getDisplayBounds() {
        return new Rect(0, 0, mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight);
    }

    /**
    /**
     * Responds to IPinnedStackListener on {@link DisplayInfo} change.
     * Responds to IPinnedStackListener on {@link DisplayInfo} change.
     * It will normally follow up with a
     * It will normally follow up with a
+23 −0
Original line number Original line Diff line number Diff line
@@ -318,6 +318,29 @@ public class PipTaskOrganizer extends ITaskOrganizer.Stub {
                null /* updateBoundsCallback */);
                null /* updateBoundsCallback */);
    }
    }


    /**
     * TODO(b/152809058): consolidate the display info handling logic in SysUI
     */
    @SuppressWarnings("unchecked")
    public void mayUpdateCurrentAnimationOnRotationChange() {
        final PipAnimationController.PipTransitionAnimator animator =
                mPipAnimationController.getCurrentAnimator();
        if (animator != null && animator.isRunning()
                && animator.getTransitionDirection() == TRANSITION_DIRECTION_TO_PIP) {
            final Rect currentDestinationBounds = animator.getDestinationBounds();
            if (mPipBoundsHandler.getDisplayBounds().contains(currentDestinationBounds)) {
                return;
            }
            final Rect newDestinationBounds = mPipBoundsHandler.getDestinationBounds(
                    getAspectRatioOrDefault(mTaskInfo.pictureInPictureParams),
                    null /* bounds */, getMinimalSize(mTaskInfo.topActivityInfo));
            if (animator.getAnimationType() == ANIM_TYPE_BOUNDS) {
                animator.updateEndValue(newDestinationBounds);
            }
            animator.setDestinationBounds(newDestinationBounds);
        }
    }

    /**
    /**
     * @return {@code true} if the aspect ratio is changed since no other parameters within
     * @return {@code true} if the aspect ratio is changed since no other parameters within
     * {@link PictureInPictureParams} would affect the bounds.
     * {@link PictureInPictureParams} would affect the bounds.
+1 −0
Original line number Original line Diff line number Diff line
@@ -363,6 +363,7 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
        mTouchHandler.onMovementBoundsChanged(mTmpInsetBounds, mTmpNormalBounds,
        mTouchHandler.onMovementBoundsChanged(mTmpInsetBounds, mTmpNormalBounds,
                animatingBounds, fromImeAdjustment, fromShelfAdjustment,
                animatingBounds, fromImeAdjustment, fromShelfAdjustment,
                mTmpDisplayInfo.rotation);
                mTmpDisplayInfo.rotation);
        mPipTaskOrganizer.mayUpdateCurrentAnimationOnRotationChange();
    }
    }


    public void dump(PrintWriter pw) {
    public void dump(PrintWriter pw) {