1 /*
2  * Copyright (C) 2015 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 com.android.tv.testing.testinput;
18 
19 import android.media.tv.TvTrackInfo;
20 import android.os.Parcel;
21 import android.os.Parcelable;
22 
23 import java.util.ArrayList;
24 import java.util.List;
25 
26 /**
27  * Mutable unversioned channel state.
28  */
29 public final class ChannelStateData implements Parcelable {
30     public static final Creator<ChannelStateData> CREATOR = new Creator<ChannelStateData>() {
31         @Override
32         public ChannelStateData createFromParcel(Parcel in) {
33             return new ChannelStateData(in);
34         }
35 
36         @Override
37         public ChannelStateData[] newArray(int size) {
38             return new ChannelStateData[size];
39         }
40     };
41 
42     public final List<TvTrackInfo> mTvTrackInfos = new ArrayList<>();
43     public int mTuneStatus = ChannelState.TUNE_STATUS_VIDEO_AVAILABLE;
44     public String mSelectedAudioTrackId = ChannelState.DEFAULT_AUDIO_TRACK.getId();
45     public String mSelectedVideoTrackId = ChannelState.DEFAULT_VIDEO_TRACK.getId();
46 
ChannelStateData()47     public ChannelStateData() {
48         mTvTrackInfos.add(ChannelState.DEFAULT_VIDEO_TRACK);
49         mTvTrackInfos.add(ChannelState.DEFAULT_AUDIO_TRACK);
50     }
51 
ChannelStateData(Parcel in)52     private ChannelStateData(Parcel in) {
53         mTuneStatus = in.readInt();
54         in.readTypedList(mTvTrackInfos, TvTrackInfo.CREATOR);
55         mSelectedAudioTrackId = in.readString();
56         mSelectedVideoTrackId = in.readString();
57     }
58 
59     @Override
describeContents()60     public int describeContents() {
61         return 0;
62     }
63 
64     @Override
writeToParcel(Parcel dest, int flags)65     public void writeToParcel(Parcel dest, int flags) {
66         dest.writeInt(mTuneStatus);
67         dest.writeTypedList(mTvTrackInfos);
68         dest.writeString(mSelectedAudioTrackId);
69         dest.writeString(mSelectedVideoTrackId);
70     }
71 
72     @Override
toString()73     public String toString() {
74         return "{"
75                 + "tune=" + mTuneStatus
76                 + ", tracks=" + mTvTrackInfos
77                 + "}";
78     }
79 }
80