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

Commit f6690d1c authored by Robert Carr's avatar Robert Carr
Browse files

Pass PictureInPictureParams in TaskInfo.

This way TaskOrganizerImplementations can use the parameters from
taskAppeared. We also wire up taskInfoChanged.

Bug: 146594635
Bug: 139371701
Test: TaskOrganizerTests
Change-Id: I5371af16177ebdf6e2187beb7184efd499c8f36d
parent c0fce304
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -247,6 +247,14 @@ public final class PictureInPictureParams implements Parcelable {
        return mSourceRectHint != null && !mSourceRectHint.isEmpty();
    }

    /**
     * @return True if no parameters are set
     * @hide
     */
    public boolean empty() {
        return !hasSourceBoundsHint() && !hasSetActions() && !hasSetAspectRatio();
    }

    @Override
    public int describeContents() {
        return 0;
+18 −1
Original line number Diff line number Diff line
@@ -148,6 +148,13 @@ public class TaskInfo {
    @NonNull
    public IWindowContainer token;

    /**
     * The PictureInPictureParams for the Task, if set.
     * @hide
     */
    @Nullable
    public PictureInPictureParams pictureInPictureParams;

    /**
     * The activity type of the top activity in this task.
     * @hide
@@ -209,6 +216,9 @@ public class TaskInfo {
        configuration.readFromParcel(source);
        token = IWindowContainer.Stub.asInterface(source.readStrongBinder());
        topActivityType = source.readInt();
        pictureInPictureParams = source.readInt() != 0
            ? PictureInPictureParams.CREATOR.createFromParcel(source)
            : null;
    }

    /**
@@ -246,6 +256,12 @@ public class TaskInfo {
        configuration.writeToParcel(dest, flags);
        dest.writeStrongInterface(token);
        dest.writeInt(topActivityType);
        if (pictureInPictureParams == null) {
            dest.writeInt(0);
        } else {
            dest.writeInt(1);
            pictureInPictureParams.writeToParcel(dest, flags);
        }
    }

    @Override
@@ -261,6 +277,7 @@ public class TaskInfo {
                + " supportsSplitScreenMultiWindow=" + supportsSplitScreenMultiWindow
                + " resizeMode=" + resizeMode
                + " token=" + token
                + " topActivityType=" + topActivityType;
                + " topActivityType=" + topActivityType
                + " pictureInPictureParams=" + pictureInPictureParams;
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -7692,4 +7692,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        }
        win.getAnimationFrames(outFrame, outInsets, outStableInsets, outSurfaceInsets);
    }

    void setPictureInPictureParams(PictureInPictureParams p) {
        pictureInPictureArgs.copyOnlySet(p);
        getTask().getRootTask().setPictureInPictureParams(p);
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -4153,7 +4153,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                            return;
                        }
                        // Only update the saved args from the args that are set
                        r.pictureInPictureArgs.copyOnlySet(params);
                        r.setPictureInPictureParams(params);
                        final float aspectRatio = r.pictureInPictureArgs.getAspectRatio();
                        final List<RemoteAction> actions = r.pictureInPictureArgs.getActions();
                        // Adjust the source bounds by the insets for the transition down
@@ -4201,7 +4201,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                        "setPictureInPictureParams", token, params);

                // Only update the saved args from the args that are set
                r.pictureInPictureArgs.copyOnlySet(params);
                r.setPictureInPictureParams(params);
                if (r.inPinnedWindowingMode()) {
                    // If the activity is already in picture-in-picture, update the pinned stack now
                    // if it is not already expanding to fullscreen. Otherwise, the arguments will
+18 −0
Original line number Diff line number Diff line
@@ -99,6 +99,7 @@ import android.app.ActivityManager.TaskSnapshot;
import android.app.ActivityOptions;
import android.app.ActivityTaskManager;
import android.app.AppGlobals;
import android.app.PictureInPictureParams;
import android.app.TaskInfo;
import android.app.WindowConfiguration;
import android.content.ComponentName;
@@ -461,6 +462,11 @@ class Task extends WindowContainer<WindowContainer> {
     */
    ITaskOrganizer mTaskOrganizer;

    /**
     * Last Picture-in-Picture params applicable to the task. Updated when the app
     * enters Picture-in-Picture or when setPictureInPictureParams is called.
     */
    PictureInPictureParams mPictureInPictureParams = new PictureInPictureParams.Builder().build();

    /**
     * Don't use constructor directly. Use {@link #create(ActivityTaskManagerService, int,
@@ -3199,6 +3205,12 @@ class Task extends WindowContainer<WindowContainer> {
        //                    order changes.
        final Task top = getTopMostTask();
        info.resizeMode = top != null ? top.mResizeMode : mResizeMode;

        if (mPictureInPictureParams.empty()) {
            info.pictureInPictureParams = null;
        } else {
            info.pictureInPictureParams = mPictureInPictureParams;
        }
    }

    /**
@@ -3929,4 +3941,10 @@ class Task extends WindowContainer<WindowContainer> {
    void onWindowFocusChanged(boolean hasFocus) {
        updateShadowsRadius(hasFocus, getPendingTransaction());
    }

    void setPictureInPictureParams(PictureInPictureParams p) {
        mPictureInPictureParams.copyOnlySet(p);
        mAtmService.mTaskOrganizerController.dispatchTaskInfoChanged(
                this, true /* force */);
    }
}
Loading