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

Commit 144c5157 authored by Shubang Lu's avatar Shubang Lu Committed by Android (Google) Code Review
Browse files

Merge "API review: Builder for TableResponse" into udc-dev

parents 26ccbdf9 6d2f3b3c
Loading
Loading
Loading
Loading
+9 −3
Original line number Original line Diff line number Diff line
@@ -26782,9 +26782,7 @@ package android.media.tv {
  }
  }
  public final class TableResponse extends android.media.tv.BroadcastInfoResponse implements android.os.Parcelable {
  public final class TableResponse extends android.media.tv.BroadcastInfoResponse implements android.os.Parcelable {
    ctor public TableResponse(int, int, int, @Nullable android.net.Uri, int, int);
    ctor @Deprecated public TableResponse(int, int, int, @Nullable android.net.Uri, int, int);
    ctor public TableResponse(int, int, int, @NonNull byte[], int, int);
    ctor public TableResponse(int, int, int, @NonNull android.os.SharedMemory, int, int);
    method public int getSize();
    method public int getSize();
    method @Nullable public byte[] getTableByteArray();
    method @Nullable public byte[] getTableByteArray();
    method @Nullable public android.os.SharedMemory getTableSharedMemory();
    method @Nullable public android.os.SharedMemory getTableSharedMemory();
@@ -26793,6 +26791,14 @@ package android.media.tv {
    field @NonNull public static final android.os.Parcelable.Creator<android.media.tv.TableResponse> CREATOR;
    field @NonNull public static final android.os.Parcelable.Creator<android.media.tv.TableResponse> CREATOR;
  }
  }
  public static final class TableResponse.Builder {
    ctor public TableResponse.Builder(int, int, int, int, int);
    method @NonNull public android.media.tv.TableResponse build();
    method @NonNull public android.media.tv.TableResponse.Builder setTableByteArray(@NonNull byte[]);
    method @NonNull public android.media.tv.TableResponse.Builder setTableSharedMemory(@NonNull android.os.SharedMemory);
    method @NonNull public android.media.tv.TableResponse.Builder setTableUri(@NonNull android.net.Uri);
  }
  public final class TimelineRequest extends android.media.tv.BroadcastInfoRequest implements android.os.Parcelable {
  public final class TimelineRequest extends android.media.tv.BroadcastInfoRequest implements android.os.Parcelable {
    ctor public TimelineRequest(int, int, int);
    ctor public TimelineRequest(int, int, int);
    ctor public TimelineRequest(int, int, int, @NonNull String);
    ctor public TimelineRequest(int, int, int, @NonNull String);
+119 −28
Original line number Original line Diff line number Diff line
@@ -64,7 +64,10 @@ public final class TableResponse extends BroadcastInfoResponse implements Parcel
     * @param tableUri The URI of the table in the database.
     * @param tableUri The URI of the table in the database.
     * @param version The version number of requested table.
     * @param version The version number of requested table.
     * @param size The Size number of table in bytes.
     * @param size The Size number of table in bytes.
     *
     * @deprecated use {@link Builder} instead.
     */
     */
    @Deprecated
    public TableResponse(int requestId, int sequence, @ResponseResult int responseResult,
    public TableResponse(int requestId, int sequence, @ResponseResult int responseResult,
            @Nullable Uri tableUri, int version, int size) {
            @Nullable Uri tableUri, int version, int size) {
        super(RESPONSE_TYPE, requestId, sequence, responseResult);
        super(RESPONSE_TYPE, requestId, sequence, responseResult);
@@ -76,51 +79,139 @@ public final class TableResponse extends BroadcastInfoResponse implements Parcel
    }
    }


    /**
    /**
     * Constructs a TableResponse with a table URI.
     * Constructs a TableResponse.
     *
     *
     * @param requestId The ID is used to associate the response with the request.
     * @param requestId The ID is used to associate the response with the request.
     * @param sequence The sequence number which indicates the order of related responses.
     * @param sequence The sequence number which indicates the order of related responses.
     * @param responseResult The result for the response. It's one of {@link #RESPONSE_RESULT_OK},
     * @param responseResult The result for the response. It's one of {@link #RESPONSE_RESULT_OK},
     *                       {@link #RESPONSE_RESULT_CANCEL}, {@link #RESPONSE_RESULT_ERROR}.
     *                       {@link #RESPONSE_RESULT_CANCEL}, {@link #RESPONSE_RESULT_ERROR}.
     * @param tableByteArray The byte array which stores the table in bytes. The structure and
     * @param tableSharedMemory The shared memory which stores the table. The table size can be
     *                       syntax of the table depends on the table name in
     *                          large so using a shared memory optimizes the data
     *                          communication between the table data source and the receiver. The
     *                          structure syntax of the table depends on the table name in
     *                          {@link TableRequest#getTableName()} and the corresponding standard.
     *                          {@link TableRequest#getTableName()} and the corresponding standard.
     * @param version The version number of requested table.
     * @param version The version number of requested table.
     * @param size The Size number of table in bytes.
     * @param size The Size number of table in bytes.
     * @param tableUri The URI of the table in the database.
     * @param tableByteArray The byte array which stores the table in bytes. The structure and
     *                       syntax of the table depends on the table name in
     * @param tableSharedMemory The shared memory which stores the table. The table size can be
     *                          large so using a shared memory optimizes the data
     *                          communication between the table data source and the receiver. The
     *                          structure syntax of the table depends on the table name in
     *                          {@link TableRequest#getTableName()} and the corresponding standard.
     */
     */
    public TableResponse(int requestId, int sequence, @ResponseResult int responseResult,
    private TableResponse(int requestId, int sequence, @ResponseResult int responseResult,
            @NonNull byte[] tableByteArray, int version, int size) {
            int version, int size, Uri tableUri, byte[] tableByteArray,
            SharedMemory tableSharedMemory) {
        super(RESPONSE_TYPE, requestId, sequence, responseResult);
        super(RESPONSE_TYPE, requestId, sequence, responseResult);
        mVersion = version;
        mVersion = version;
        mSize = size;
        mSize = size;
        mTableUri = null;
        mTableUri = tableUri;
        mTableByteArray = tableByteArray;
        mTableByteArray = tableByteArray;
        mTableSharedMemory = null;
        mTableSharedMemory = tableSharedMemory;
    }
    }


    /**
    /**
     * Constructs a TableResponse with a table URI.
     * Builder for {@link TableResponse}.
     */
    public static final class Builder {
        private final int mRequestId;
        private final int mSequence;
        @ResponseResult
        private final int mResponseResult;
        private final int mVersion;
        private final int mSize;
        private Uri mTableUri;
        private byte[] mTableByteArray;
        private SharedMemory mTableSharedMemory;

        /**
         * Constructs a Builder object of {@link TableResponse}.
         *
         *
         * @param requestId The ID is used to associate the response with the request.
         * @param requestId The ID is used to associate the response with the request.
         * @param sequence The sequence number which indicates the order of related responses.
         * @param sequence The sequence number which indicates the order of related responses.
     * @param responseResult The result for the response. It's one of {@link #RESPONSE_RESULT_OK},
         * @param responseResult The result for the response. It's one of
     *                       {@link #RESPONSE_RESULT_CANCEL}, {@link #RESPONSE_RESULT_ERROR}.
         *                       {@link #RESPONSE_RESULT_OK}, {@link #RESPONSE_RESULT_CANCEL},
     * @param tableSharedMemory The shared memory which stores the table. The table size can be
         *                       {@link #RESPONSE_RESULT_ERROR}.
     *                          large so using a shared memory optimizes the data
     *                          communication between the table data source and the receiver. The
     *                          structure syntax of the table depends on the table name in
     *                          {@link TableRequest#getTableName()} and the corresponding standard.
         * @param version The version number of requested table.
         * @param version The version number of requested table.
         * @param size The Size number of table in bytes.
         * @param size The Size number of table in bytes.
         */
         */
    public TableResponse(int requestId, int sequence, @ResponseResult int responseResult,
        public Builder(int requestId, int sequence, @ResponseResult int responseResult, int version,
            @NonNull SharedMemory tableSharedMemory, int version, int size) {
                int size) {
        super(RESPONSE_TYPE, requestId, sequence, responseResult);
            mRequestId = requestId;
            mSequence = sequence;
            mResponseResult = responseResult;
            mVersion = version;
            mVersion = version;
            mSize = size;
            mSize = size;
        }

        /**
         * Sets table URI.
         *
         * <p>For a single builder instance, at most one of table URI, table byte array, and table
         * shared memory can be set. If more than one are set, only the last call takes precedence
         * and others are reset to {@code null}.
         *
         * @param uri The URI of the table.
         */
        @NonNull
        public Builder setTableUri(@NonNull Uri uri) {
            mTableUri = uri;
            mTableByteArray = null;
            mTableSharedMemory = null;
            return this;
        }

        /**
         * Sets table byte array.
         *
         * <p>For a single builder instance, at most one of table URI, table byte array, and table
         * shared memory can be set. If more than one are set, only the last call takes precedence
         * and others are reset to {@code null}.
         *
         * @param bytes The byte array which stores the table in bytes. The structure and
         *              syntax of the table depends on the table name in
         *              {@link TableRequest#getTableName()} and the corresponding standard.
         */
        @NonNull
        public Builder setTableByteArray(@NonNull byte[] bytes) {
            mTableByteArray = bytes;
            mTableUri = null;
            mTableSharedMemory = null;
            return this;
        }


        /**
         * Sets table shared memory.
         *
         * <p>For a single builder instance, at most one of table URI, table byte array, and table
         * shared memory can be set. If more than one are set, only the last call takes precedence
         * and others are reset to {@code null}.
         *
         * @param sharedMemory The shared memory which stores the table. The table size can be
         *                     large so using a shared memory optimizes the data
         *                     communication between the table data source and the receiver. The
         *                     structure syntax of the table depends on the table name in
         *                     {@link TableRequest#getTableName()} and the corresponding standard.
         */
        @NonNull
        public Builder setTableSharedMemory(@NonNull SharedMemory sharedMemory) {
            mTableSharedMemory = sharedMemory;
            mTableUri = null;
            mTableUri = null;
            mTableByteArray = null;
            mTableByteArray = null;
        mTableSharedMemory = tableSharedMemory;
            return this;
        }

        /**
         * Builds a {@link TableResponse} object.
         */
        @NonNull
        public TableResponse build() {
            return new TableResponse(mRequestId, mSequence, mResponseResult, mVersion, mSize,
                    mTableUri, mTableByteArray, mTableSharedMemory);
        }
    }
    }


    TableResponse(Parcel source) {
    TableResponse(Parcel source) {