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

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

Merge "add an extended class of BroadcastInfoRequest: TsRequest"

parents 74afc4ff 63830aa3
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -22,12 +22,21 @@ import android.os.Parcelable;
import android.annotation.NonNull;

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

    public static final @NonNull Parcelable.Creator<BroadcastInfoRequest> CREATOR =
            new Parcelable.Creator<BroadcastInfoRequest>() {
                @Override
                public BroadcastInfoRequest createFromParcel(Parcel source) {
                    return new BroadcastInfoRequest(source);
                    int token = source.readInt();
                    switch (token) {
                        case PARCEL_TOKEN_TS_REQUEST:
                            return TsRequest.createFromParcelBody(source);
                        default:
                            throw new IllegalStateException(
                                    "Unexpected broadcast info request type token in parcel.");
                    }
                }

                @Override
@@ -42,10 +51,14 @@ public final class BroadcastInfoRequest implements Parcelable {
        this.requestId = requestId;
    }

    private BroadcastInfoRequest(Parcel source) {
    protected BroadcastInfoRequest(Parcel source) {
        requestId = source.readInt();
    }

    public int getRequestId() {
        return requestId;
    }

    @Override
    public int describeContents() {
        return 0;
+19 −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;

parcelable TsRequest;
+65 −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.Parcelable;

/** @hide */
public class TsRequest extends BroadcastInfoRequest implements Parcelable {
    public static final @NonNull Parcelable.Creator<TsRequest> CREATOR =
            new Parcelable.Creator<TsRequest>() {
                @Override
                public TsRequest createFromParcel(Parcel source) {
                    source.readInt();
                    return createFromParcelBody(source);
                }

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

    int tsPid;

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

    public TsRequest(int requestId, int tsPid) {
        super(requestId);
        this.tsPid = tsPid;
    }

    protected TsRequest(Parcel source) {
        super(source);
        tsPid = source.readInt();
    }

    public int getTsPid() {
        return tsPid;
    }

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeInt(PARCEL_TOKEN_TS_REQUEST);
        super.writeToParcel(dest, flags);
        dest.writeInt(tsPid);
    }
}