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

Commit 11819bc6 authored by Yixiao Luo's avatar Yixiao Luo Committed by Android (Google) Code Review
Browse files

Merge "Extend other BroadcastInfo related classes"

parents c42e127f eef344e1
Loading
Loading
Loading
Loading
+44 −12
Original line number Diff line number Diff line
@@ -23,19 +23,35 @@ import android.annotation.NonNull;

/** @hide */
public abstract class BroadcastInfoRequest implements Parcelable {
    protected static final int PARCEL_TOKEN_TS_REQUEST = 1;

    // todo: change const declaration to intdef
    public static final int REQUEST_OPTION_REPEAT = 11;
    public static final int REQUEST_OPTION_AUTO_UPDATE = 12;

    public static final @NonNull Parcelable.Creator<BroadcastInfoRequest> CREATOR =
            new Parcelable.Creator<BroadcastInfoRequest>() {
                @Override
                public BroadcastInfoRequest createFromParcel(Parcel source) {
                    int token = source.readInt();
                    switch (token) {
                        case PARCEL_TOKEN_TS_REQUEST:
                    int type = source.readInt();
                    switch (type) {
                        case BroadcastInfoType.TS:
                            return TsRequest.createFromParcelBody(source);
                        case BroadcastInfoType.TABLE:
                            return TableRequest.createFromParcelBody(source);
                        case BroadcastInfoType.SECTION:
                            return SectionRequest.createFromParcelBody(source);
                        case BroadcastInfoType.PES:
                            return PesRequest.createFromParcelBody(source);
                        case BroadcastInfoType.STREAM_EVENT:
                            return StreamEventRequest.createFromParcelBody(source);
                        case BroadcastInfoType.DSMCC:
                            return DsmccRequest.createFromParcelBody(source);
                        case BroadcastInfoType.TV_PROPRIETARY_FUNCTION:
                            return TvProprietaryFunctionRequest.createFromParcelBody(source);
                        default:
                            throw new IllegalStateException(
                                    "Unexpected broadcast info request type token in parcel.");
                                    "Unexpected broadcast info request type (value "
                                            + type + ") in parcel.");
                    }
                }

@@ -45,18 +61,32 @@ public abstract class BroadcastInfoRequest implements Parcelable {
                }
            };

    int requestId;
    protected final int mType;
    protected final int mRequestId;
    protected final int mOption;

    protected BroadcastInfoRequest(int type, int requestId, int option) {
        mType = type;
        mRequestId = requestId;
        mOption = option;
    }

    public BroadcastInfoRequest(int requestId) {
        this.requestId = requestId;
    protected BroadcastInfoRequest(int type, Parcel source) {
        mType = type;
        mRequestId = source.readInt();
        mOption = source.readInt();
    }

    protected BroadcastInfoRequest(Parcel source) {
        requestId = source.readInt();
    public int getType() {
        return mType;
    }

    public int getRequestId() {
        return requestId;
        return mRequestId;
    }

    public int getOption() {
        return mOption;
    }

    @Override
@@ -66,6 +96,8 @@ public abstract class BroadcastInfoRequest implements Parcelable {

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeInt(requestId);
        dest.writeInt(mType);
        dest.writeInt(mRequestId);
        dest.writeInt(mOption);
    }
}
+58 −9
Original line number Diff line number Diff line
@@ -22,12 +22,37 @@ import android.os.Parcelable;
import android.annotation.NonNull;

/** @hide */
public final class BroadcastInfoResponse implements Parcelable {
public abstract class BroadcastInfoResponse implements Parcelable {
    // todo: change const declaration to intdef
    public static final int ERROR = 1;
    public static final int OK = 2;
    public static final int CANCEL = 3;

    public static final @NonNull Parcelable.Creator<BroadcastInfoResponse> CREATOR =
            new Parcelable.Creator<BroadcastInfoResponse>() {
                @Override
                public BroadcastInfoResponse createFromParcel(Parcel source) {
                    return new BroadcastInfoResponse(source);
                    int type = source.readInt();
                    switch (type) {
                        case BroadcastInfoType.TS:
                            return TsResponse.createFromParcelBody(source);
                        case BroadcastInfoType.TABLE:
                            return TableResponse.createFromParcelBody(source);
                        case BroadcastInfoType.SECTION:
                            return SectionResponse.createFromParcelBody(source);
                        case BroadcastInfoType.PES:
                            return PesResponse.createFromParcelBody(source);
                        case BroadcastInfoType.STREAM_EVENT:
                            return StreamEventResponse.createFromParcelBody(source);
                        case BroadcastInfoType.DSMCC:
                            return DsmccResponse.createFromParcelBody(source);
                        case BroadcastInfoType.TV_PROPRIETARY_FUNCTION:
                            return TvProprietaryFunctionResponse.createFromParcelBody(source);
                        default:
                            throw new IllegalStateException(
                                    "Unexpected broadcast info response type (value "
                                            + type + ") in parcel.");
                    }
                }

                @Override
@@ -36,18 +61,39 @@ public final class BroadcastInfoResponse implements Parcelable {
                }
            };

    int requestId;
    protected final int mType;
    protected final int mRequestId;
    protected final int mSequence;
    protected final int mResponseResult;

    protected BroadcastInfoResponse(int type, int requestId, int sequence, int responseResult) {
        mType = type;
        mRequestId = requestId;
        mSequence = sequence;
        mResponseResult = responseResult;
    }

    public BroadcastInfoResponse(int requestId) {
        this.requestId = requestId;
    protected BroadcastInfoResponse(int type, Parcel source) {
        mType = type;
        mRequestId = source.readInt();
        mSequence = source.readInt();
        mResponseResult = source.readInt();
    }

    private BroadcastInfoResponse(Parcel source) {
        requestId = source.readInt();
    public int getType() {
        return mType;
    }

    public int getRequestId() {
        return requestId;
        return mRequestId;
    }

    public int getSequence() {
        return mSequence;
    }

    public int getResponseResult() {
        return mResponseResult;
    }

    @Override
@@ -57,6 +103,9 @@ public final class BroadcastInfoResponse implements Parcelable {

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeInt(requestId);
        dest.writeInt(mType);
        dest.writeInt(mRequestId);
        dest.writeInt(mSequence);
        dest.writeInt(mResponseResult);
    }
}
+14 −1
Original line number Diff line number Diff line
@@ -16,4 +16,17 @@

package android.media.tv;

parcelable TsRequest;
/** @hide */
public final class BroadcastInfoType {
    // todo: change const declaration to intdef in TvInputManager
    public static final int TS = 1;
    public static final int TABLE = 2;
    public static final int SECTION = 3;
    public static final int PES = 4;
    public static final int STREAM_EVENT = 5;
    public static final int DSMCC = 6;
    public static final int TV_PROPRIETARY_FUNCTION = 7;

    private BroadcastInfoType() {
    }
}
+69 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.media.tv;

import android.annotation.NonNull;
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;

/** @hide */
public class DsmccRequest extends BroadcastInfoRequest implements Parcelable {
    public static final int requestType = BroadcastInfoType.DSMCC;

    public static final @NonNull Parcelable.Creator<DsmccRequest> CREATOR =
            new Parcelable.Creator<DsmccRequest>() {
                @Override
                public DsmccRequest createFromParcel(Parcel source) {
                    source.readInt();
                    return createFromParcelBody(source);
                }

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

    private final Uri mUri;

    public static DsmccRequest createFromParcelBody(Parcel in) {
        return new DsmccRequest(in);
    }

    public DsmccRequest(int requestId, int option, Uri uri) {
        super(requestType, requestId, option);
        mUri = uri;
    }

    protected DsmccRequest(Parcel source) {
        super(requestType, source);
        String uriString = source.readString();
        mUri = uriString == null ? null : Uri.parse(uriString);
    }

    public Uri getUri() {
        return mUri;
    }

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        super.writeToParcel(dest, flags);
        String uriString = mUri == null ? null : mUri.toString();
        dest.writeString(uriString);
    }
}
+68 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.media.tv;

import android.annotation.NonNull;
import android.os.Parcel;
import android.os.ParcelFileDescriptor;
import android.os.Parcelable;

/** @hide */
public class DsmccResponse extends BroadcastInfoResponse implements Parcelable {
    public static final int responseType = BroadcastInfoType.DSMCC;

    public static final @NonNull Parcelable.Creator<DsmccResponse> CREATOR =
            new Parcelable.Creator<DsmccResponse>() {
                @Override
                public DsmccResponse createFromParcel(Parcel source) {
                    source.readInt();
                    return createFromParcelBody(source);
                }

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

    private final ParcelFileDescriptor mFile;

    public static DsmccResponse createFromParcelBody(Parcel in) {
        return new DsmccResponse(in);
    }

    public DsmccResponse(int requestId, int sequence, int responseResult,
            ParcelFileDescriptor file) {
        super(responseType, requestId, sequence, responseResult);
        mFile = file;
    }

    protected DsmccResponse(Parcel source) {
        super(responseType, source);
        mFile = source.readFileDescriptor();
    }

    public ParcelFileDescriptor getFile() {
        return mFile;
    }

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        super.writeToParcel(dest, flags);
        mFile.writeToParcel(dest, flags);
    }
}
Loading