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

Commit f59a5c77 authored by David Zhao's avatar David Zhao
Browse files

Unhide Ad Insertion APIs

Also updates some javadoc

Bug: 262620108
Test: atest TvInputServiceTest && atest TvInteractiveAppServiceTest
Change-Id: I0803c207481656cd5c8b7b3bcee954d5c5c987d1
parent 86ebdba0
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -26318,8 +26318,23 @@ package android.media.session {
package android.media.tv {
  public final class AdBuffer implements android.os.Parcelable {
    ctor public AdBuffer(int, @NonNull String, @NonNull android.os.SharedMemory, int, int, long, int);
    method public int describeContents();
    method public int getFlags();
    method public int getId();
    method public int getLength();
    method @NonNull public String getMimeType();
    method public int getOffset();
    method public long getPresentationTimeUs();
    method @NonNull public android.os.SharedMemory getSharedMemory();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.media.tv.AdBuffer> CREATOR;
  }
  public final class AdRequest implements android.os.Parcelable {
    ctor public AdRequest(int, int, @Nullable android.os.ParcelFileDescriptor, long, long, long, @Nullable String, @NonNull android.os.Bundle);
    ctor public AdRequest(int, int, @Nullable android.net.Uri, long, long, long, @NonNull android.os.Bundle);
    method public int describeContents();
    method public long getEchoIntervalMillis();
    method @Nullable public android.os.ParcelFileDescriptor getFileDescriptor();
@@ -26329,6 +26344,7 @@ package android.media.tv {
    method public int getRequestType();
    method public long getStartTimeMillis();
    method public long getStopTimeMillis();
    method @Nullable public android.net.Uri getUri();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.media.tv.AdRequest> CREATOR;
    field public static final int REQUEST_TYPE_START = 1; // 0x1
@@ -26343,6 +26359,7 @@ package android.media.tv {
    method public int getResponseType();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.media.tv.AdResponse> CREATOR;
    field public static final int RESPONSE_TYPE_BUFFERING = 5; // 0x5
    field public static final int RESPONSE_TYPE_ERROR = 4; // 0x4
    field public static final int RESPONSE_TYPE_FINISHED = 2; // 0x2
    field public static final int RESPONSE_TYPE_PLAYING = 1; // 0x1
@@ -27096,6 +27113,7 @@ package android.media.tv {
  public abstract static class TvInputService.Session implements android.view.KeyEvent.Callback {
    ctor public TvInputService.Session(android.content.Context);
    method public void layoutSurface(int, int, int, int);
    method public void notifyAdBufferConsumed(@NonNull android.media.tv.AdBuffer);
    method public void notifyAdResponse(@NonNull android.media.tv.AdResponse);
    method public void notifyAitInfoUpdated(@NonNull android.media.tv.AitInfo);
    method public void notifyAudioPresentationChanged(@NonNull java.util.List<android.media.AudioPresentation>);
@@ -27111,6 +27129,7 @@ package android.media.tv {
    method public void notifyTuned(@NonNull android.net.Uri);
    method public void notifyVideoAvailable();
    method public void notifyVideoUnavailable(int);
    method public void onAdBuffer(@NonNull android.media.tv.AdBuffer);
    method public void onAppPrivateCommand(@NonNull String, android.os.Bundle);
    method public android.view.View onCreateOverlayView();
    method public boolean onGenericMotionEvent(android.view.MotionEvent);
@@ -27397,9 +27416,11 @@ package android.media.tv.interactive {
    ctor public TvInteractiveAppService.Session(@NonNull android.content.Context);
    method public boolean isMediaViewEnabled();
    method @CallSuper public void layoutSurface(int, int, int, int);
    method @CallSuper public void notifyAdBuffer(@NonNull android.media.tv.AdBuffer);
    method @CallSuper public final void notifyBiInteractiveAppCreated(@NonNull android.net.Uri, @Nullable String);
    method @CallSuper public void notifySessionStateChanged(int, int);
    method @CallSuper public final void notifyTeletextAppStateChanged(int);
    method public void onAdBufferConsumed(@NonNull android.media.tv.AdBuffer);
    method public void onAdResponse(@NonNull android.media.tv.AdResponse);
    method public void onBroadcastInfoResponse(@NonNull android.media.tv.BroadcastInfoResponse);
    method public void onContentAllowed();
+30 −7
Original line number Diff line number Diff line
@@ -24,9 +24,8 @@ import android.os.SharedMemory;

/**
 * Buffer for advertisement data.
 * @hide
 */
public class AdBuffer implements Parcelable {
public final class AdBuffer implements Parcelable {
    private final int mId;
    @NonNull
    private final String mMimeType;
@@ -60,6 +59,8 @@ public class AdBuffer implements Parcelable {

    /**
     * Gets corresponding AD request ID.
     *
     * @return The ID of the ad request
     */
    public int getId() {
        return mId;
@@ -67,6 +68,8 @@ public class AdBuffer implements Parcelable {

    /**
     * Gets the mime type of the data.
     *
     * @return The mime type of the data.
     */
    @NonNull
    public String getMimeType() {
@@ -74,7 +77,17 @@ public class AdBuffer implements Parcelable {
    }

    /**
     * Gets the shared memory which stores the data.
     * Gets the {@link SharedMemory} which stores the data.
     *
     * <p> Information on how the data in this buffer is formatted can be found using
     * {@link AdRequest#getMetadata()}
     * <p> This data lives in a {@link SharedMemory} instance because of the
     * potentially large amount of data needed to store the ad. This optimizes the
     * data communication between the ad data source and the service responsible for
     * its display.
     *
     * @see SharedMemory#create(String, int)
     * @return The {@link SharedMemory} that stores the data for this ad buffer.
     */
    @NonNull
    public SharedMemory getSharedMemory() {
@@ -82,28 +95,38 @@ public class AdBuffer implements Parcelable {
    }

    /**
     * Gets the offset of the buffer.
     * Gets the offset into the shared memory to begin mapping.
     *
     * @see SharedMemory#map(int, int, int)
     * @return The offset of this ad buffer in the shared memory in bytes.
     */
    public int getOffset() {
        return mOffset;
    }

    /**
     * Gets the data length.
     * Gets the data length of this ad buffer.
     *
     * @return The data length of this ad buffer in bytes.
     */
    public int getLength() {
        return mLength;
    }

    /**
     * Gets the presentation time in microseconds.
     * Gets the presentation time.
     *
     * @return The presentation time in microseconds.
     */
    public long getPresentationTimeUs() {
        return mPresentationTimeUs;
    }

    /**
     * Gets the flags.
     * Gets the buffer flags for this ad buffer.
     *
     * @see android.media.MediaCodec
     * @return The buffer flags for this ad buffer.
     */
    @BufferFlag
    public int getFlags() {
+0 −2
Original line number Diff line number Diff line
@@ -79,7 +79,6 @@ public final class AdRequest implements Parcelable {
                mediaFileType, metadata);
    }

    /** @hide */
    public AdRequest(int id, @RequestType int requestType, @Nullable Uri uri, long startTime,
            long stopTime, long echoInterval, @NonNull Bundle metadata) {
        this(id, requestType, null, uri, startTime, stopTime, echoInterval, null, metadata);
@@ -153,7 +152,6 @@ public final class AdRequest implements Parcelable {
     *
     * @return The URI of the AD media. Can be {@code null} for {@link #REQUEST_TYPE_STOP} or a file
     *         descriptor is used.
     * @hide
     */
    @Nullable
    public Uri getUri() {
+0 −1
Original line number Diff line number Diff line
@@ -43,7 +43,6 @@ public final class AdResponse implements Parcelable {
    public static final int RESPONSE_TYPE_FINISHED = 2;
    public static final int RESPONSE_TYPE_STOPPED = 3;
    public static final int RESPONSE_TYPE_ERROR = 4;
    /** @hide */
    public static final int RESPONSE_TYPE_BUFFERING = 5;

    public static final @NonNull Parcelable.Creator<AdResponse> CREATOR =
+7 −5
Original line number Diff line number Diff line
@@ -1005,9 +1005,10 @@ public abstract class TvInputService extends Service {

        /**
         * Notifies the advertisement buffer is consumed.
         * @hide
         *
         * @param buffer the {@link AdBuffer} that was consumed.
         */
        public void notifyAdBufferConsumed(AdBuffer buffer) {
        public void notifyAdBufferConsumed(@NonNull AdBuffer buffer) {
            executeOrPostRunnableOnMainThread(new Runnable() {
                @MainThread
                @Override
@@ -1320,10 +1321,11 @@ public abstract class TvInputService extends Service {
        }

        /**
         * Called when advertisement buffer is ready.
         * @hide
         * Called when an advertisement buffer is ready for playback.
         *
         * @param buffer The {@link AdBuffer} that became ready for playback.
         */
        public void onAdBuffer(AdBuffer buffer) {
        public void onAdBuffer(@NonNull AdBuffer buffer) {
        }

        /**
Loading