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

Commit eed79bf6 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Only restash TV PiP if necessary on immediate placement"

parents 5b2abf1c 63cd654a
Loading
Loading
Loading
Loading
+15 −16
Original line number Diff line number Diff line
@@ -122,9 +122,9 @@ public class TvPipBoundsController {
            cancelScheduledPlacement();
            applyPlacementBounds(placement.getUnstashedBounds(), animationDuration);
        } else if (immediate) {
            boolean shouldStash = mUnstashRunnable != null || placement.getTriggerStash();
            cancelScheduledPlacement();
            applyPlacementBounds(placement.getBounds(), animationDuration);
            scheduleUnstashIfNeeded(placement);
            applyPlacement(placement, shouldStash, animationDuration);
        } else {
            applyPlacementBounds(mCurrentPlacementBounds, animationDuration);
            schedulePinnedStackPlacement(placement, animationDuration);
@@ -176,22 +176,21 @@ public class TvPipBoundsController {
                    "%s: applyPendingPlacement()", TAG);
        }
        if (mPendingPlacement != null) {
            if (mPendingStash) {
            applyPlacement(mPendingPlacement, mPendingStash, mPendingPlacementAnimationDuration);
            mPendingStash = false;
                scheduleUnstashIfNeeded(mPendingPlacement);
            mPendingPlacement = null;
        }

            if (mUnstashRunnable != null) {
                // currently stashed, use stashed pos
                applyPlacementBounds(mPendingPlacement.getBounds(),
                        mPendingPlacementAnimationDuration);
            } else {
                applyPlacementBounds(mPendingPlacement.getUnstashedBounds(),
                        mPendingPlacementAnimationDuration);
    }

    private void applyPlacement(@NonNull final Placement placement, boolean shouldStash,
            int animationDuration) {
        if (placement.getStashType() != STASH_TYPE_NONE && shouldStash) {
            scheduleUnstashIfNeeded(placement);
        }

        mPendingPlacement = null;
        Rect bounds =
                mUnstashRunnable != null ? placement.getBounds() : placement.getUnstashedBounds();
        applyPlacementBounds(bounds, animationDuration);
    }

    void onPipDismissed() {
+10 −0
Original line number Diff line number Diff line
@@ -178,6 +178,16 @@ class TvPipBoundsControllerTest {
        assertMovementAt(time + STASH_DURATION, ANCHOR_BOUNDS)
    }

    @Test
    fun testImmediatePlacement_DoNotStashIfAlreadyUnstashed() {
        triggerImmediatePlacement(STASHED_PLACEMENT_RESTASH)
        assertMovement(STASHED_BOUNDS)
        assertMovementAt(time + STASH_DURATION, ANCHOR_BOUNDS)

        triggerImmediatePlacement(STASHED_PLACEMENT)
        assertNoMovementUpTo(time + FAR_FUTURE)
    }

    @Test
    fun testInMoveMode_KeepAtAnchor() {
        startMoveMode()