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

Commit 7abb8cdb authored by Naomi Musgrave's avatar Naomi Musgrave Committed by Automerger Merge Worker
Browse files

Merge "(5/N)[MediaProjection] Send no frames until user reviews consent" into...

Merge "(5/N)[MediaProjection] Send no frames until user reviews consent" into udc-dev am: 9736133f am: 5e2b34e8

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22765499



Change-Id: I8177ba8713a1cdca217fdaa8d582e61fdea1422e
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents c91dabde 5e2b34e8
Loading
Loading
Loading
Loading
+20 −20
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ public final class ContentRecordingSession implements Parcelable {
     *
     * <p>Only set on the server side to sanitize any input from the client process.
     */
    private boolean mWaitingToRecord = false;
    private boolean mWaitingForConsent = false;

    /**
     * Default instance, with recording the display.
@@ -181,7 +181,7 @@ public final class ContentRecordingSession implements Parcelable {
            @RecordContent int contentToRecord,
            int displayToRecord,
            @Nullable IBinder tokenToRecord,
            boolean waitingToRecord) {
            boolean waitingForConsent) {
        this.mVirtualDisplayId = virtualDisplayId;
        this.mContentToRecord = contentToRecord;

@@ -195,7 +195,7 @@ public final class ContentRecordingSession implements Parcelable {

        this.mDisplayToRecord = displayToRecord;
        this.mTokenToRecord = tokenToRecord;
        this.mWaitingToRecord = waitingToRecord;
        this.mWaitingForConsent = waitingForConsent;

        // onConstructed(); // You can define this method to get a callback
    }
@@ -246,8 +246,8 @@ public final class ContentRecordingSession implements Parcelable {
     * <p>Only set on the server side to sanitize any input from the client process.
     */
    @DataClass.Generated.Member
    public boolean isWaitingToRecord() {
        return mWaitingToRecord;
    public boolean isWaitingForConsent() {
        return mWaitingForConsent;
    }

    /**
@@ -309,8 +309,8 @@ public final class ContentRecordingSession implements Parcelable {
     * <p>Only set on the server side to sanitize any input from the client process.
     */
    @DataClass.Generated.Member
    public @NonNull ContentRecordingSession setWaitingToRecord( boolean value) {
        mWaitingToRecord = value;
    public @NonNull ContentRecordingSession setWaitingForConsent( boolean value) {
        mWaitingForConsent = value;
        return this;
    }

@@ -325,7 +325,7 @@ public final class ContentRecordingSession implements Parcelable {
                "contentToRecord = " + recordContentToString(mContentToRecord) + ", " +
                "displayToRecord = " + mDisplayToRecord + ", " +
                "tokenToRecord = " + mTokenToRecord + ", " +
                "waitingToRecord = " + mWaitingToRecord +
                "waitingForConsent = " + mWaitingForConsent +
        " }";
    }

@@ -346,7 +346,7 @@ public final class ContentRecordingSession implements Parcelable {
                && mContentToRecord == that.mContentToRecord
                && mDisplayToRecord == that.mDisplayToRecord
                && java.util.Objects.equals(mTokenToRecord, that.mTokenToRecord)
                && mWaitingToRecord == that.mWaitingToRecord;
                && mWaitingForConsent == that.mWaitingForConsent;
    }

    @Override
@@ -360,7 +360,7 @@ public final class ContentRecordingSession implements Parcelable {
        _hash = 31 * _hash + mContentToRecord;
        _hash = 31 * _hash + mDisplayToRecord;
        _hash = 31 * _hash + java.util.Objects.hashCode(mTokenToRecord);
        _hash = 31 * _hash + Boolean.hashCode(mWaitingToRecord);
        _hash = 31 * _hash + Boolean.hashCode(mWaitingForConsent);
        return _hash;
    }

@@ -371,7 +371,7 @@ public final class ContentRecordingSession implements Parcelable {
        // void parcelFieldName(Parcel dest, int flags) { ... }

        byte flg = 0;
        if (mWaitingToRecord) flg |= 0x10;
        if (mWaitingForConsent) flg |= 0x10;
        if (mTokenToRecord != null) flg |= 0x8;
        dest.writeByte(flg);
        dest.writeInt(mVirtualDisplayId);
@@ -392,7 +392,7 @@ public final class ContentRecordingSession implements Parcelable {
        // static FieldType unparcelFieldName(Parcel in) { ... }

        byte flg = in.readByte();
        boolean waitingToRecord = (flg & 0x10) != 0;
        boolean waitingForConsent = (flg & 0x10) != 0;
        int virtualDisplayId = in.readInt();
        int contentToRecord = in.readInt();
        int displayToRecord = in.readInt();
@@ -411,7 +411,7 @@ public final class ContentRecordingSession implements Parcelable {

        this.mDisplayToRecord = displayToRecord;
        this.mTokenToRecord = tokenToRecord;
        this.mWaitingToRecord = waitingToRecord;
        this.mWaitingForConsent = waitingForConsent;

        // onConstructed(); // You can define this method to get a callback
    }
@@ -441,7 +441,7 @@ public final class ContentRecordingSession implements Parcelable {
        private @RecordContent int mContentToRecord;
        private int mDisplayToRecord;
        private @Nullable IBinder mTokenToRecord;
        private boolean mWaitingToRecord;
        private boolean mWaitingForConsent;

        private long mBuilderFieldsSet = 0L;

@@ -506,10 +506,10 @@ public final class ContentRecordingSession implements Parcelable {
         * <p>Only set on the server side to sanitize any input from the client process.
         */
        @DataClass.Generated.Member
        public @NonNull Builder setWaitingToRecord(boolean value) {
        public @NonNull Builder setWaitingForConsent(boolean value) {
            checkNotUsed();
            mBuilderFieldsSet |= 0x10;
            mWaitingToRecord = value;
            mWaitingForConsent = value;
            return this;
        }

@@ -531,14 +531,14 @@ public final class ContentRecordingSession implements Parcelable {
                mTokenToRecord = null;
            }
            if ((mBuilderFieldsSet & 0x10) == 0) {
                mWaitingToRecord = false;
                mWaitingForConsent = false;
            }
            ContentRecordingSession o = new ContentRecordingSession(
                    mVirtualDisplayId,
                    mContentToRecord,
                    mDisplayToRecord,
                    mTokenToRecord,
                    mWaitingToRecord);
                    mWaitingForConsent);
            return o;
        }

@@ -551,10 +551,10 @@ public final class ContentRecordingSession implements Parcelable {
    }

    @DataClass.Generated(
            time = 1679855157534L,
            time = 1683628463074L,
            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 mVirtualDisplayId\nprivate @android.view.ContentRecordingSession.RecordContent int mContentToRecord\nprivate  int mDisplayToRecord\nprivate @android.annotation.Nullable android.os.IBinder mTokenToRecord\nprivate  boolean mWaitingToRecord\npublic static  android.view.ContentRecordingSession createDisplaySession(int)\npublic static  android.view.ContentRecordingSession createTaskSession(android.os.IBinder)\npublic static  boolean isValid(android.view.ContentRecordingSession)\npublic static  boolean isProjectionOnSameDisplay(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)")
            inputSignatures = "public static final  int RECORD_CONTENT_DISPLAY\npublic static final  int RECORD_CONTENT_TASK\nprivate  int mVirtualDisplayId\nprivate @android.view.ContentRecordingSession.RecordContent int mContentToRecord\nprivate  int mDisplayToRecord\nprivate @android.annotation.Nullable android.os.IBinder mTokenToRecord\nprivate  boolean mWaitingForConsent\npublic static  android.view.ContentRecordingSession createDisplaySession(int)\npublic static  android.view.ContentRecordingSession createTaskSession(android.os.IBinder)\npublic static  boolean isValid(android.view.ContentRecordingSession)\npublic static  boolean isProjectionOnSameDisplay(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)")
    @Deprecated
    private void __metadata() {}

+12 −0
Original line number Diff line number Diff line
@@ -1675,6 +1675,12 @@
      "group": "WM_DEBUG_CONFIGURATION",
      "at": "com\/android\/server\/am\/ActivityManagerService.java"
    },
    "-584061725": {
      "message": "Content Recording: Accept session updating same display %d with granted consent, with an existing session %s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_CONTENT_RECORDING",
      "at": "com\/android\/server\/wm\/ContentRecordingController.java"
    },
    "-583031528": {
      "message": "%s",
      "level": "INFO",
@@ -2167,6 +2173,12 @@
      "group": "WM_DEBUG_BACK_PREVIEW",
      "at": "com\/android\/server\/wm\/TaskFragment.java"
    },
    "-125383273": {
      "message": "Content Recording: waiting to record, so do nothing",
      "level": "VERBOSE",
      "group": "WM_DEBUG_CONTENT_RECORDING",
      "at": "com\/android\/server\/wm\/ContentRecorder.java"
    },
    "-124316973": {
      "message": "Translucent=%s Floating=%s ShowWallpaper=%s Disable=%s",
      "level": "VERBOSE",
+1 −1
Original line number Diff line number Diff line
@@ -1560,7 +1560,7 @@ public final class DisplayManagerService extends SystemService {
                // VirtualDisplay has been successfully constructed.
                session.setVirtualDisplayId(displayId);
                // Don't start mirroring until user re-grants consent.
                session.setWaitingToRecord(waitForPermissionConsent);
                session.setWaitingForConsent(waitForPermissionConsent);

                // We set the content recording session here on the server side instead of using
                // a second AIDL call in MediaProjection. By ensuring that a virtual display has
+3 −3
Original line number Diff line number Diff line
@@ -406,7 +406,7 @@ public final class MediaProjectionManagerService extends SystemService
                return;
            }
            if (mProjectionGrant.mSession == null
                    || !mProjectionGrant.mSession.isWaitingToRecord()) {
                    || !mProjectionGrant.mSession.isWaitingForConsent()) {
                Slog.w(TAG, "Reusing token: Ignore consent result " + consentResult
                        + " if not waiting for the result.");
                return;
@@ -445,7 +445,7 @@ public final class MediaProjectionManagerService extends SystemService
     */
    private void setReviewedConsentSessionLocked(@Nullable ContentRecordingSession session) {
        if (session != null) {
            session.setWaitingToRecord(false);
            session.setWaitingForConsent(false);
            session.setVirtualDisplayId(mProjectionGrant.mVirtualDisplayId);
        }

@@ -490,7 +490,7 @@ public final class MediaProjectionManagerService extends SystemService
            // Supposedly the package has re-used the user's consent; confirm the provided details
            // against the current projection token before re-using the current projection.
            if (mProjectionGrant == null || mProjectionGrant.mSession == null
                    || !mProjectionGrant.mSession.isWaitingToRecord()) {
                    || !mProjectionGrant.mSession.isWaitingForConsent()) {
                Slog.e(TAG, "Reusing token: Not possible to reuse the current projection "
                        + "instance");
                return null;
+6 −0
Original line number Diff line number Diff line
@@ -276,6 +276,12 @@ final class ContentRecorder implements WindowContainerListener {
            return;
        }

        if (mContentRecordingSession.isWaitingForConsent()) {
            ProtoLog.v(WM_DEBUG_CONTENT_RECORDING, "Content Recording: waiting to record, so do "
                    + "nothing");
            return;
        }

        mRecordedWindowContainer = retrieveRecordedWindowContainer();
        if (mRecordedWindowContainer == null) {
            // Either the token is missing, or the window associated with the token is missing.
Loading