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

Commit 77672d8c authored by Chavi Weingarten's avatar Chavi Weingarten Committed by Android (Google) Code Review
Browse files

Merge "Add uid to CaptureArgs."

parents 37bf178c 26fda2aa
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -654,6 +654,7 @@ public final class SurfaceControl implements Parcelable {
        private final float mFrameScale;
        private final boolean mCaptureSecureLayers;
        private final boolean mAllowProtected;
        private final long mUid;

        private CaptureArgs(Builder<? extends Builder<?>> builder) {
            mPixelFormat = builder.mPixelFormat;
@@ -661,6 +662,7 @@ public final class SurfaceControl implements Parcelable {
            mFrameScale = builder.mFrameScale;
            mCaptureSecureLayers = builder.mCaptureSecureLayers;
            mAllowProtected = builder.mAllowProtected;
            mUid = builder.mUid;
        }

        /**
@@ -674,6 +676,7 @@ public final class SurfaceControl implements Parcelable {
            private float mFrameScale = 1;
            private boolean mCaptureSecureLayers;
            private boolean mAllowProtected;
            private long mUid = -1;

            /**
             * The desired pixel format of the returned buffer.
@@ -722,6 +725,15 @@ public final class SurfaceControl implements Parcelable {
                return getThis();
            }

            /**
             * Set the uid of the content that should be screenshot. The code will skip any surfaces
             * that don't belong to the specified uid.
             */
            public T setUid(long uid) {
                mUid = uid;
                return getThis();
            }

            /**
             * Each sub class should return itself to allow the builder to chain properly
             */
+3 −0
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@ static struct {
    jfieldID frameScale;
    jfieldID captureSecureLayers;
    jfieldID allowProtected;
    jfieldID uid;
} gCaptureArgsClassInfo;

static struct {
@@ -371,6 +372,7 @@ static void getCaptureArgs(JNIEnv* env, jobject captureArgsObject, CaptureArgs&
            env->GetBooleanField(captureArgsObject, gCaptureArgsClassInfo.captureSecureLayers);
    captureArgs.allowProtected =
            env->GetBooleanField(captureArgsObject, gCaptureArgsClassInfo.allowProtected);
    captureArgs.uid = env->GetLongField(captureArgsObject, gCaptureArgsClassInfo.uid);
}

static DisplayCaptureArgs displayCaptureArgsFromObject(JNIEnv* env,
@@ -1895,6 +1897,7 @@ int register_android_view_SurfaceControl(JNIEnv* env)
            GetFieldIDOrDie(env, captureArgsClazz, "mCaptureSecureLayers", "Z");
    gCaptureArgsClassInfo.allowProtected =
            GetFieldIDOrDie(env, captureArgsClazz, "mAllowProtected", "Z");
    gCaptureArgsClassInfo.uid = GetFieldIDOrDie(env, captureArgsClazz, "mUid", "J");

    jclass displayCaptureArgsClazz =
            FindClassOrDie(env, "android/view/SurfaceControl$DisplayCaptureArgs");