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

Commit 3147778d authored by Patrick Williams's avatar Patrick Williams Committed by Android (Google) Code Review
Browse files

Merge "Add a test api for setting MediaProjection launch cookie" into main

parents 781fb487 a61916bc
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -195,8 +195,11 @@ package android.app {
    method public void setTaskOverlay(boolean, boolean);
  }

  public static final class ActivityOptions.LaunchCookie {
  public static final class ActivityOptions.LaunchCookie implements android.os.Parcelable {
    ctor public ActivityOptions.LaunchCookie();
    method public int describeContents();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.app.ActivityOptions.LaunchCookie> CREATOR;
  }

  public static interface ActivityOptions.OnAnimationFinishedListener {
@@ -2108,6 +2111,14 @@ package android.media.metrics {

}

package android.media.projection {

  public final class MediaProjectionManager {
    method @NonNull public android.content.Intent createScreenCaptureIntent(@Nullable android.app.ActivityOptions.LaunchCookie);
  }

}

package android.media.soundtrigger {

  public final class SoundTriggerInstrumentation {
+4 −1
Original line number Diff line number Diff line
@@ -18,3 +18,6 @@ package android.app;

/** @hide */
parcelable ActivityOptions.SceneTransitionInfo;

/** @hide */
parcelable ActivityOptions.LaunchCookie;
 No newline at end of file
+76 −3
Original line number Diff line number Diff line
@@ -1958,14 +1958,87 @@ public class ActivityOptions extends ComponentOptions {
     */
    @SuppressLint("UnflaggedApi")
    @TestApi
    public static final class LaunchCookie {
    public static final class LaunchCookie implements Parcelable {
        /** @hide */
        public final IBinder binder = new Binder();
        public final IBinder binder;

        /** @hide */
        @SuppressLint("UnflaggedApi")
        @TestApi
        public LaunchCookie() {}
        public LaunchCookie() {
            binder = new Binder();
        }

        /** @hide */
        public LaunchCookie(@Nullable String descriptor) {
            binder = new Binder(descriptor);
        }

        private LaunchCookie(Parcel in) {
            this.binder = in.readStrongBinder();
        }

        /** @hide */
        @SuppressLint("UnflaggedApi")
        @TestApi
        @Override
        public int describeContents() {
            return 0;
        }

        /** @hide */
        @SuppressLint("UnflaggedApi")
        @TestApi
        @Override
        public void writeToParcel(@NonNull Parcel dest, int flags) {
            dest.writeStrongBinder(binder);
        }

        /** @hide */
        public static LaunchCookie readFromParcel(@NonNull Parcel in) {
            return new LaunchCookie(in);
        }

        /** @hide */
        public static void writeToParcel(@Nullable LaunchCookie launchCookie, Parcel out) {
            if (launchCookie != null) {
                launchCookie.writeToParcel(out, 0);
            } else {
                out.writeStrongBinder(null);
            }
        }

        /** @hide */
        @SuppressLint("UnflaggedApi")
        @TestApi
        @NonNull
        public static final Parcelable.Creator<LaunchCookie> CREATOR =
                new Parcelable.Creator<LaunchCookie>() {

                    @Override
                    public LaunchCookie createFromParcel(Parcel source) {
                        return new LaunchCookie(source);
                    }

                    @Override
                    public LaunchCookie[] newArray(int size) {
                        return new LaunchCookie[size];
                    }
                };

        @Override
        public boolean equals(@Nullable Object obj) {
            if (obj instanceof LaunchCookie) {
                LaunchCookie other = (LaunchCookie) obj;
                return binder == other.binder;
            }
            return false;
        }

        @Override
        public int hashCode() {
            return binder.hashCode();
        }
    }

    /**
+5 −4
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.media.projection;

import android.media.projection.IMediaProjectionCallback;
import android.os.IBinder;
import android.app.ActivityOptions.LaunchCookie;

/** {@hide} */
interface IMediaProjection {
@@ -38,22 +39,22 @@ interface IMediaProjection {
    void unregisterCallback(IMediaProjectionCallback callback);

    /**
     * Returns the {@link android.os.IBinder} identifying the task to record, or {@code null} if
     * Returns the {@link LaunchCookie} identifying the task to record, or {@code null} if
     * there is none.
     */
    @EnforcePermission("MANAGE_MEDIA_PROJECTION")
    @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest"
            + ".permission.MANAGE_MEDIA_PROJECTION)")
    IBinder getLaunchCookie();
    LaunchCookie getLaunchCookie();

    /**
     * Updates the {@link android.os.IBinder} identifying the task to record, or {@code null} if
     * Updates the {@link LaunchCookie} identifying the task to record, or {@code null} if
     * there is none.
     */
    @EnforcePermission("MANAGE_MEDIA_PROJECTION")
    @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest"
            + ".permission.MANAGE_MEDIA_PROJECTION)")
    void setLaunchCookie(in IBinder launchCookie);
    void setLaunchCookie(in LaunchCookie launchCookie);

    /**
     * Returns {@code true} if this token is still valid. A token is valid as long as the token
+7 −7
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

package android.media.projection;

import android.os.IBinder;
import android.app.ActivityOptions.LaunchCookie;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.UserHandle;
@@ -27,9 +27,9 @@ import java.util.Objects;
public final class MediaProjectionInfo implements Parcelable {
    private final String mPackageName;
    private final UserHandle mUserHandle;
    private final IBinder mLaunchCookie;
    private final LaunchCookie mLaunchCookie;

    public MediaProjectionInfo(String packageName, UserHandle handle, IBinder launchCookie) {
    public MediaProjectionInfo(String packageName, UserHandle handle, LaunchCookie launchCookie) {
        mPackageName = packageName;
        mUserHandle = handle;
        mLaunchCookie = launchCookie;
@@ -38,7 +38,7 @@ public final class MediaProjectionInfo implements Parcelable {
    public MediaProjectionInfo(Parcel in) {
        mPackageName = in.readString();
        mUserHandle = UserHandle.readFromParcel(in);
        mLaunchCookie = in.readStrongBinder();
        mLaunchCookie = LaunchCookie.readFromParcel(in);
    }

    public String getPackageName() {
@@ -49,7 +49,7 @@ public final class MediaProjectionInfo implements Parcelable {
        return mUserHandle;
    }

    public IBinder getLaunchCookie() {
    public LaunchCookie getLaunchCookie() {
        return mLaunchCookie;
    }

@@ -72,7 +72,7 @@ public final class MediaProjectionInfo implements Parcelable {
    public String toString() {
        return "MediaProjectionInfo{mPackageName="
            + mPackageName + ", mUserHandle="
            + mUserHandle + ", mLaunchCookie"
            + mUserHandle + ", mLaunchCookie="
            + mLaunchCookie + "}";
    }

@@ -85,7 +85,7 @@ public final class MediaProjectionInfo implements Parcelable {
    public void writeToParcel(Parcel out, int flags) {
        out.writeString(mPackageName);
        UserHandle.writeToParcel(mUserHandle, out);
        out.writeStrongBinder(mLaunchCookie);
        LaunchCookie.writeToParcel(mLaunchCookie, out);
    }

    public static final @android.annotation.NonNull Parcelable.Creator<MediaProjectionInfo> CREATOR =
Loading