1 /*
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.media.tv;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.os.Parcel;
22 import android.os.Parcelable;
23 
24 /**
25  * A response for TS (transport stream) from broadcast signal.
26  */
27 public final class TsResponse extends BroadcastInfoResponse implements Parcelable {
28     private static final @TvInputManager.BroadcastInfoType int RESPONSE_TYPE =
29             TvInputManager.BROADCAST_INFO_TYPE_TS;
30 
31     public static final @NonNull Parcelable.Creator<TsResponse> CREATOR =
32             new Parcelable.Creator<TsResponse>() {
33                 @Override
34                 public TsResponse createFromParcel(Parcel source) {
35                     source.readInt();
36                     return createFromParcelBody(source);
37                 }
38 
39                 @Override
40                 public TsResponse[] newArray(int size) {
41                     return new TsResponse[size];
42                 }
43             };
44 
45     private final String mSharedFilterToken;
46 
createFromParcelBody(@onNull Parcel in)47     static TsResponse createFromParcelBody(@NonNull Parcel in) {
48         return new TsResponse(in);
49     }
50 
TsResponse(int requestId, int sequence, @ResponseResult int responseResult, @Nullable String sharedFilterToken)51     public TsResponse(int requestId, int sequence, @ResponseResult int responseResult,
52             @Nullable String sharedFilterToken) {
53         super(RESPONSE_TYPE, requestId, sequence, responseResult);
54         this.mSharedFilterToken = sharedFilterToken;
55     }
56 
TsResponse(Parcel source)57     TsResponse(Parcel source) {
58         super(RESPONSE_TYPE, source);
59         mSharedFilterToken = source.readString();
60     }
61 
62     /**
63      * Gets a token of SharedFilter.
64      *
65      * <p>The token can be used to retrieve the transport stream from the filter.
66      */
67     @Nullable
getSharedFilterToken()68     public String getSharedFilterToken() {
69         return mSharedFilterToken;
70     }
71 
72     @Override
describeContents()73     public int describeContents() {
74         return 0;
75     }
76 
77     @Override
writeToParcel(@onNull Parcel dest, int flags)78     public void writeToParcel(@NonNull Parcel dest, int flags) {
79         super.writeToParcel(dest, flags);
80         dest.writeString(mSharedFilterToken);
81     }
82 }
83