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