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

Commit 7fdad1e5 authored by Ikram Gabiyev's avatar Ikram Gabiyev
Browse files

Set KCA during swipe PiP to home

Set the KCA region due to the shelf height
upon swiping PiP to home.

We are also getting the pip change from
TransitionInfo coming into PipTransition#startExpandAnimation()
using the PiP task token instead of querying the windowing mode;
this is needed since the task is not PINNED at this point.
This was causing an issue where we wouldn't end up in EXITED_PIP
state.

Bug: 356508169
Flag: com.android.wm.shell.enable_pip2_implementation
Test: swipe up to enter PiP
Change-Id: Iae616572271e08371c8aa200fd34402bae1655d1
parent 1e561212
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -300,6 +300,10 @@ public class PipController implements ConfigurationChangeListener,
            int launcherRotation, Rect hotseatKeepClearArea) {
        ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
                "getSwipePipToHomeBounds: %s", componentName);
        // preemptively add the keep clear area for Hotseat, so that it is taken into account
        // when calculating the entry destination bounds of PiP window
        mPipBoundsState.setNamedUnrestrictedKeepClearArea(
                PipBoundsState.NAMED_KCA_LAUNCHER_SHELF, hotseatKeepClearArea);
        mPipBoundsState.setBoundsStateForEntry(componentName, activityInfo, pictureInPictureParams,
                mPipBoundsAlgorithm);
        return mPipBoundsAlgorithm.getEntryDestinationBounds();
@@ -349,10 +353,14 @@ public class PipController implements ConfigurationChangeListener,
                if (mPipTransitionState.isInSwipePipToHomeTransition()) {
                    mPipTransitionState.resetSwipePipToHomeState();
                }
                if (mOnIsInPipStateChangedListener != null) {
                    mOnIsInPipStateChangedListener.accept(true /* inPip */);
                }
                break;
            case PipTransitionState.EXITED_PIP:
                if (mOnIsInPipStateChangedListener != null) {
                    mOnIsInPipStateChangedListener.accept(false /* inPip */);
                }
                break;
        }
    }
+16 −8
Original line number Diff line number Diff line
@@ -107,10 +107,6 @@ public class PipTransition extends PipTransitionController implements
    // Internal state and relevant cached info
    //

    @Nullable
    private WindowContainerToken mPipTaskToken;
    @Nullable
    private SurfaceControl mPipLeash;
    @Nullable
    private Transitions.TransitionFinishCallback mFinishCallback;

@@ -402,7 +398,6 @@ public class PipTransition extends PipTransitionController implements
        finishWct.setBoundsChangeTransaction(pipTaskToken, tx);

        animator.setAnimationEndCallback(() -> {
            mPipTransitionState.setState(PipTransitionState.ENTERED_PIP);
            finishCallback.onTransitionFinished(finishWct.isEmpty() ? null : finishWct);
        });

@@ -444,15 +439,16 @@ public class PipTransition extends PipTransitionController implements
            @NonNull SurfaceControl.Transaction startTransaction,
            @NonNull SurfaceControl.Transaction finishTransaction,
            @NonNull Transitions.TransitionFinishCallback finishCallback) {
        TransitionInfo.Change pipChange = getPipChange(info);
        WindowContainerToken pipToken = mPipTransitionState.mPipTaskToken;

        TransitionInfo.Change pipChange = getChangeByToken(info, pipToken);
        if (pipChange == null) {
            return false;
        }

        Rect startBounds = pipChange.getStartAbsBounds();
        Rect endBounds = pipChange.getEndAbsBounds();
        SurfaceControl pipLeash = mPipTransitionState.mPinnedTaskLeash;
        Preconditions.checkNotNull(pipLeash, "Leash is null for bounds transition.");
        SurfaceControl pipLeash = pipChange.getLeash();

        PipEnterExitAnimator animator = new PipEnterExitAnimator(mContext, pipLeash,
                startTransaction, startBounds, startBounds, endBounds,
@@ -491,6 +487,18 @@ public class PipTransition extends PipTransitionController implements
        return null;
    }

    @Nullable
    private TransitionInfo.Change getChangeByToken(TransitionInfo info,
            WindowContainerToken token) {
        for (TransitionInfo.Change change : info.getChanges()) {
            if (change.getTaskInfo() != null
                    && change.getTaskInfo().getToken().equals(token)) {
                return change;
            }
        }
        return null;
    }

    private WindowContainerTransaction getEnterPipTransaction(@NonNull IBinder transition,
            @NonNull TransitionRequestInfo request) {
        // cache the original task token to check for multi-activity case later