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

Commit 9e3020b2 authored by Chris Li's avatar Chris Li Committed by Android (Google) Code Review
Browse files

Merge "Polish ActivityEmbedding enter/exit PiP (1/n)" into tm-qpr-dev

parents 6d1c1b57 84ec824a
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -407,6 +407,7 @@ public final class TransitionInfo implements Parcelable {
    public static final class Change implements Parcelable {
        private final WindowContainerToken mContainer;
        private WindowContainerToken mParent;
        private WindowContainerToken mLastParent;
        private final SurfaceControl mLeash;
        private @TransitionMode int mMode = TRANSIT_NONE;
        private @ChangeFlags int mFlags = FLAG_NONE;
@@ -435,6 +436,7 @@ public final class TransitionInfo implements Parcelable {
        private Change(Parcel in) {
            mContainer = in.readTypedObject(WindowContainerToken.CREATOR);
            mParent = in.readTypedObject(WindowContainerToken.CREATOR);
            mLastParent = in.readTypedObject(WindowContainerToken.CREATOR);
            mLeash = new SurfaceControl();
            mLeash.readFromParcel(in);
            mMode = in.readInt();
@@ -458,6 +460,14 @@ public final class TransitionInfo implements Parcelable {
            mParent = parent;
        }

        /**
         * Sets the parent of this change's container before the transition if this change's
         * container is reparented in the transition.
         */
        public void setLastParent(@Nullable WindowContainerToken lastParent) {
            mLastParent = lastParent;
        }

        /** Sets the transition mode for this change */
        public void setMode(@TransitionMode int mode) {
            mMode = mode;
@@ -541,6 +551,17 @@ public final class TransitionInfo implements Parcelable {
            return mParent;
        }

        /**
         * @return the parent of the changing container before the transition if it is reparented
         * in the transition. The parent window may not be collected in the transition as a
         * participant, and it may have been detached from the display. {@code null} if the changing
         * container has not been reparented in the transition, or if the parent is not organizable.
         */
        @Nullable
        public WindowContainerToken getLastParent() {
            return mLastParent;
        }

        /** @return which action this change represents. */
        public @TransitionMode int getMode() {
            return mMode;
@@ -640,6 +661,7 @@ public final class TransitionInfo implements Parcelable {
        public void writeToParcel(@NonNull Parcel dest, int flags) {
            dest.writeTypedObject(mContainer, flags);
            dest.writeTypedObject(mParent, flags);
            dest.writeTypedObject(mLastParent, flags);
            mLeash.writeToParcel(dest, flags);
            dest.writeInt(mMode);
            dest.writeInt(mFlags);
@@ -685,6 +707,7 @@ public final class TransitionInfo implements Parcelable {
                    + mStartRotation + "->" + mEndRotation + ":" + mRotationAnimation
                    + " endFixedRotation=" + mEndFixedRotation;
            if (mSnapshot != null) out += " snapshot=" + mSnapshot;
            if (mLastParent != null) out += " lastParent=" + mLastParent;
            return out + "}";
        }
    }
+7 −4
Original line number Diff line number Diff line
@@ -452,14 +452,17 @@ public class PipTransition extends PipTransitionController {
            @NonNull Transitions.TransitionFinishCallback finishCallback,
            @NonNull TaskInfo taskInfo, @Nullable TransitionInfo.Change pipTaskChange) {
        TransitionInfo.Change pipChange = pipTaskChange;
        if (pipChange == null) {
        if (mCurrentPipTaskToken == null) {
            ProtoLog.w(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
                    "%s: There is no existing PiP Task for TRANSIT_EXIT_PIP", TAG);
        } else if (pipChange == null) {
            // The pipTaskChange is null, this can happen if we are reparenting the PIP activity
            // back to its original Task. In that case, we should animate the activity leash
            // instead, which should be the only non-task, independent, TRANSIT_CHANGE window.
            // instead, which should be the change whose last parent is the recorded PiP Task.
            for (int i = info.getChanges().size() - 1; i >= 0; --i) {
                final TransitionInfo.Change change = info.getChanges().get(i);
                if (change.getTaskInfo() == null && change.getMode() == TRANSIT_CHANGE
                        && TransitionInfo.isIndependent(change, info)) {
                if (mCurrentPipTaskToken.equals(change.getLastParent())) {
                    // Find the activity that is exiting PiP.
                    pipChange = change;
                    break;
                }
+6 −1
Original line number Diff line number Diff line
@@ -2021,7 +2021,12 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
                // non-fullscreen bounds. Then when this new PIP task exits PIP, it can restore
                // to its previous freeform bounds.
                rootTask.setLastNonFullscreenBounds(task.mLastNonFullscreenBounds);
                rootTask.setBounds(task.getBounds());
                // When creating a new Task for PiP, set its initial bounds as the TaskFragment in
                // case the activity is embedded, so that it can be animated to PiP window from the
                // current bounds.
                // Use Task#setBoundsUnchecked to skip checking windowing mode as the windowing mode
                // will be updated later after this is collected in transition.
                rootTask.setBoundsUnchecked(r.getTaskFragment().getBounds());

                // Move the last recents animation transaction from original task to the new one.
                if (task.mLastRecentsAnimationTransaction != null) {
+8 −4
Original line number Diff line number Diff line
@@ -2618,6 +2618,13 @@ class Task extends TaskFragment {
        return boundsChange;
    }

    /** Sets the requested bounds regardless of the windowing mode. */
    int setBoundsUnchecked(@NonNull Rect bounds) {
        final int boundsChange = super.setBounds(bounds);
        updateSurfaceBounds();
        return boundsChange;
    }

    @Override
    public boolean isCompatible(int windowingMode, int activityType) {
        // TODO: Should we just move this to ConfigurationContainer?
@@ -5920,10 +5927,7 @@ class Task extends TaskFragment {
            return BOUNDS_CHANGE_NONE;
        }

        final int result = super.setBounds(!inMultiWindowMode() ? null : bounds);

        updateSurfaceBounds();
        return result;
        return setBoundsUnchecked(!inMultiWindowMode() ? null : bounds);
    }

    @Override
+4 −0
Original line number Diff line number Diff line
@@ -1595,6 +1595,10 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
            if (info.mEndParent != null) {
                change.setParent(info.mEndParent.mRemoteToken.toWindowContainerToken());
            }
            if (info.mStartParent != null && info.mStartParent.mRemoteToken != null
                    && target.getParent() != info.mStartParent) {
                change.setLastParent(info.mStartParent.mRemoteToken.toWindowContainerToken());
            }
            change.setMode(info.getTransitMode(target));
            change.setStartAbsBounds(info.mAbsoluteBounds);
            change.setFlags(info.getChangeFlags(target));
Loading