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

Commit 13194c3c authored by Naomi Musgrave's avatar Naomi Musgrave
Browse files

Capture the contents of a single task

Introduces layer mirorring of a single task, given the task is both
identified (future work - dependency on setup flow in SysUI) and the
flag is enabled (currently disabled).

Error handling (tearing down the VirtualDisplay if task recording setup failed)
will come in a future change

Bug: 216625226
Test: atest WmTests:DisplayContentTests
Test: atest WmTests:ContentRecorderTests
Change-Id: I16abd55ce75537ff8fbbb379e4970668ea02a230
parent fdf73b0a
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -216,6 +216,12 @@ class ContextImpl extends Context {
    @UnsupportedAppUsage
    private @Nullable ClassLoader mClassLoader;

    /**
     * The {@link com.android.server.wm.WindowToken} representing this instance if it is
     * {@link #CONTEXT_TYPE_WINDOW_CONTEXT} or {@link #CONTEXT_TYPE_SYSTEM_OR_SYSTEM_UI}.
     * If the type is {@link #CONTEXT_TYPE_ACTIVITY}, then represents the
     * {@link android.window.WindowContainerToken} of the activity.
     */
    private final @Nullable IBinder mToken;

    private final @NonNull UserHandle mUser;
+3 −2
Original line number Diff line number Diff line
@@ -7145,8 +7145,9 @@ public abstract class Context {
    }

    /**
     * Returns token if the {@link Context} is a {@link android.app.WindowContext}. Returns
     * {@code null} otherwise.
     * Returns the {@link IBinder} representing the associated
     * {@link com.android.server.wm.WindowToken} if the {@link Context} is a
     * {@link android.app.WindowContext}. Returns {@code null} otherwise.
     *
     * @hide
     */
+21 −17
Original line number Diff line number Diff line
@@ -66,10 +66,11 @@ public final class ContentRecordingSession implements Parcelable {
    private int mContentToRecord = RECORD_CONTENT_DISPLAY;

    /**
     * The window token of the layer of the hierarchy to record.
     * The display content if {@link #getContentToRecord()} is
     * {@link RecordContent#RECORD_CONTENT_DISPLAY}, or task if {@link #getContentToRecord()} is
     * {@link RecordContent#RECORD_CONTENT_TASK}.
     * The token of the layer of the hierarchy to record.
     * If {@link #getContentToRecord()} is @link RecordContent#RECORD_CONTENT_DISPLAY}, then
     * represents the WindowToken corresponding to the DisplayContent to record.
     * If {@link #getContentToRecord()} is {@link RecordContent#RECORD_CONTENT_TASK}, then
     * represents the {@link android.window.WindowContainerToken} of the Task to record.
     */
    @VisibleForTesting
    @Nullable
@@ -192,10 +193,11 @@ public final class ContentRecordingSession implements Parcelable {
    }

    /**
     * The window token of the layer of the hierarchy to record.
     * The display content if {@link #getContentToRecord()} is
     * {@link RecordContent#RECORD_CONTENT_DISPLAY}, or task if {@link #getContentToRecord()} is
     * {@link RecordContent#RECORD_CONTENT_TASK}.
     * {The token of the layer of the hierarchy to record.
     * If {@link #getContentToRecord()} is @link RecordContent#RECORD_CONTENT_DISPLAY}, then
     * represents the WindowToken corresponding to the DisplayContent to record.
     * If {@link #getContentToRecord()} is {@link RecordContent#RECORD_CONTENT_TASK}, then
     * represents the {@link android.window.WindowContainerToken} of the Task to record.
     */
    @DataClass.Generated.Member
    public @VisibleForTesting @Nullable IBinder getTokenToRecord() {
@@ -231,10 +233,11 @@ public final class ContentRecordingSession implements Parcelable {
    }

    /**
     * The window token of the layer of the hierarchy to record.
     * The display content if {@link #getContentToRecord()} is
     * {@link RecordContent#RECORD_CONTENT_DISPLAY}, or task if {@link #getContentToRecord()} is
     * {@link RecordContent#RECORD_CONTENT_TASK}.
     * {The token of the layer of the hierarchy to record.
     * If {@link #getContentToRecord()} is @link RecordContent#RECORD_CONTENT_DISPLAY}, then
     * represents the WindowToken corresponding to the DisplayContent to record.
     * If {@link #getContentToRecord()} is {@link RecordContent#RECORD_CONTENT_TASK}, then
     * represents the {@link android.window.WindowContainerToken} of the Task to record.
     */
    @DataClass.Generated.Member
    public @NonNull ContentRecordingSession setTokenToRecord(@VisibleForTesting @NonNull IBinder value) {
@@ -390,10 +393,11 @@ public final class ContentRecordingSession implements Parcelable {
        }

        /**
         * The window token of the layer of the hierarchy to record.
         * The display content if {@link #getContentToRecord()} is
         * {@link RecordContent#RECORD_CONTENT_DISPLAY}, or task if {@link #getContentToRecord()} is
         * {@link RecordContent#RECORD_CONTENT_TASK}.
         * {The token of the layer of the hierarchy to record.
         * If {@link #getContentToRecord()} is @link RecordContent#RECORD_CONTENT_DISPLAY}, then
         * represents the WindowToken corresponding to the DisplayContent to record.
         * If {@link #getContentToRecord()} is {@link RecordContent#RECORD_CONTENT_TASK}, then
         * represents the {@link android.window.WindowContainerToken} of the Task to record.
         */
        @DataClass.Generated.Member
        public @NonNull Builder setTokenToRecord(@VisibleForTesting @NonNull IBinder value) {
@@ -433,7 +437,7 @@ public final class ContentRecordingSession implements Parcelable {
    }

    @DataClass.Generated(
            time = 1644843382972L,
            time = 1645803878639L,
            codegenVersion = "1.0.23",
            sourceFile = "frameworks/base/core/java/android/view/ContentRecordingSession.java",
            inputSignatures = "public static final  int RECORD_CONTENT_DISPLAY\npublic static final  int RECORD_CONTENT_TASK\nprivate  int mDisplayId\nprivate @android.view.ContentRecordingSession.RecordContent int mContentToRecord\nprivate @com.android.internal.annotations.VisibleForTesting @android.annotation.Nullable android.os.IBinder mTokenToRecord\npublic static  android.view.ContentRecordingSession createDisplaySession(android.os.IBinder)\npublic static  android.view.ContentRecordingSession createTaskSession(android.os.IBinder)\npublic static  boolean isValid(android.view.ContentRecordingSession)\npublic static  boolean isSameDisplay(android.view.ContentRecordingSession,android.view.ContentRecordingSession)\nclass ContentRecordingSession extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genConstructor=false, genToString=true, genSetters=true, genEqualsHashCode=true)")
+18 −6
Original line number Diff line number Diff line
@@ -2251,6 +2251,12 @@
      "group": "WM_DEBUG_WINDOW_TRANSITIONS",
      "at": "com\/android\/server\/wm\/TransitionController.java"
    },
    "264036181": {
      "message": "Unable to retrieve task to start recording for display %d",
      "level": "VERBOSE",
      "group": "WM_DEBUG_CONTENT_RECORDING",
      "at": "com\/android\/server\/wm\/ContentRecorder.java"
    },
    "269576220": {
      "message": "Resuming rotation after drag",
      "level": "DEBUG",
@@ -2671,12 +2677,6 @@
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "664667685": {
      "message": "Activity %s: enableOnBackInvokedCallback=false. Returning null BackNavigationInfo.",
      "level": "DEBUG",
      "group": "WM_DEBUG_BACK_PREVIEW",
      "at": "com\/android\/server\/wm\/BackNavigationController.java"
    },
    "665256544": {
      "message": "All windows drawn!",
      "level": "DEBUG",
@@ -2755,6 +2755,12 @@
      "group": "WM_DEBUG_WALLPAPER",
      "at": "com\/android\/server\/wm\/WallpaperWindowToken.java"
    },
    "736003885": {
      "message": "Unable to retrieve the task token to start recording for display %d",
      "level": "VERBOSE",
      "group": "WM_DEBUG_CONTENT_RECORDING",
      "at": "com\/android\/server\/wm\/ContentRecorder.java"
    },
    "736692676": {
      "message": "Config is relaunching %s",
      "level": "VERBOSE",
@@ -2785,6 +2791,12 @@
      "group": "WM_DEBUG_RECENTS_ANIMATIONS",
      "at": "com\/android\/server\/wm\/RecentsAnimation.java"
    },
    "778774915": {
      "message": "Unable to record task since feature is disabled %d",
      "level": "VERBOSE",
      "group": "WM_DEBUG_CONTENT_RECORDING",
      "at": "com\/android\/server\/wm\/ContentRecorder.java"
    },
    "781471998": {
      "message": "moveWindowTokenToDisplay: Cannot move to the original display for token: %s",
      "level": "WARN",
+13 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.media.projection;

import android.media.projection.IMediaProjectionCallback;
import android.window.WindowContainerToken;

/** {@hide} */
interface IMediaProjection {
@@ -28,4 +29,16 @@ interface IMediaProjection {
    int applyVirtualDisplayFlags(int flags);
    void registerCallback(IMediaProjectionCallback callback);
    void unregisterCallback(IMediaProjectionCallback callback);

    /**
     * Returns the {@link android.window.WindowContainerToken} identifying the task to record, or
     * {@code null} if there is none.
     */
    WindowContainerToken getTaskRecordingWindowContainerToken();

    /**
     * Updates the {@link android.window.WindowContainerToken} identifying the task to record, or
     * {@code null} if there is none.
     */
    void setTaskRecordingWindowContainerToken(in WindowContainerToken token);
}
Loading