169b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown/* 269b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown * Copyright (C) 2013 The Android Open Source Project 369b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown * 469b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown * Licensed under the Apache License, Version 2.0 (the "License"); 569b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown * you may not use this file except in compliance with the License. 669b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown * You may obtain a copy of the License at 769b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown * 869b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown * http://www.apache.org/licenses/LICENSE-2.0 969b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown * 1069b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown * Unless required by applicable law or agreed to in writing, software 1169b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown * distributed under the License is distributed on an "AS IS" BASIS, 1269b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1369b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown * See the License for the specific language governing permissions and 1469b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown * limitations under the License. 1569b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown */ 1669b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown 1769b07161bebdb2c726e3a826c2268866f1a94517Jeff Brownpackage android.media; 1869b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown 1969b07161bebdb2c726e3a826c2268866f1a94517Jeff Brownimport android.os.Parcel; 2069b07161bebdb2c726e3a826c2268866f1a94517Jeff Brownimport android.os.Parcelable; 2169b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown 2269b07161bebdb2c726e3a826c2268866f1a94517Jeff Brownimport java.util.ArrayList; 2369b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown 2469b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown/** 2569b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown * Information available from MediaRouterService about the state perceived by 2669b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown * a particular client and the routes that are available to it. 2769b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown * 2869b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown * Clients must not modify the contents of this object. 2969b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown * @hide 3069b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown */ 3169b07161bebdb2c726e3a826c2268866f1a94517Jeff Brownpublic final class MediaRouterClientState implements Parcelable { 3269b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown /** 3369b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown * A list of all known routes. 3469b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown */ 3569b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public final ArrayList<RouteInfo> routes; 3669b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown 3769b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public MediaRouterClientState() { 3869b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown routes = new ArrayList<RouteInfo>(); 3969b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown } 4069b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown 4169b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown MediaRouterClientState(Parcel src) { 4269b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown routes = src.createTypedArrayList(RouteInfo.CREATOR); 4369b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown } 4469b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown 45af574183c274f51d04487a9c8355e9f34a1150f2Jeff Brown public RouteInfo getRoute(String id) { 46af574183c274f51d04487a9c8355e9f34a1150f2Jeff Brown final int count = routes.size(); 47af574183c274f51d04487a9c8355e9f34a1150f2Jeff Brown for (int i = 0; i < count; i++) { 48af574183c274f51d04487a9c8355e9f34a1150f2Jeff Brown final RouteInfo route = routes.get(i); 49af574183c274f51d04487a9c8355e9f34a1150f2Jeff Brown if (route.id.equals(id)) { 50af574183c274f51d04487a9c8355e9f34a1150f2Jeff Brown return route; 51af574183c274f51d04487a9c8355e9f34a1150f2Jeff Brown } 52af574183c274f51d04487a9c8355e9f34a1150f2Jeff Brown } 53af574183c274f51d04487a9c8355e9f34a1150f2Jeff Brown return null; 54af574183c274f51d04487a9c8355e9f34a1150f2Jeff Brown } 55af574183c274f51d04487a9c8355e9f34a1150f2Jeff Brown 5669b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown @Override 5769b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public int describeContents() { 5869b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown return 0; 5969b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown } 6069b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown 6169b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown @Override 6269b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public void writeToParcel(Parcel dest, int flags) { 6369b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown dest.writeTypedList(routes); 6469b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown } 6569b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown 66af574183c274f51d04487a9c8355e9f34a1150f2Jeff Brown @Override 67af574183c274f51d04487a9c8355e9f34a1150f2Jeff Brown public String toString() { 68d103e56e657d374a31016cb62df88b8d5c910d06Sungsoo return "MediaRouterClientState{ routes=" + routes.toString() + " }"; 69af574183c274f51d04487a9c8355e9f34a1150f2Jeff Brown } 70af574183c274f51d04487a9c8355e9f34a1150f2Jeff Brown 7169b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public static final Parcelable.Creator<MediaRouterClientState> CREATOR = 7269b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown new Parcelable.Creator<MediaRouterClientState>() { 7369b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown @Override 7469b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public MediaRouterClientState createFromParcel(Parcel in) { 7569b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown return new MediaRouterClientState(in); 7669b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown } 7769b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown 7869b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown @Override 7969b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public MediaRouterClientState[] newArray(int size) { 8069b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown return new MediaRouterClientState[size]; 8169b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown } 8269b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown }; 8369b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown 8469b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public static final class RouteInfo implements Parcelable { 8569b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public String id; 8669b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public String name; 8769b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public String description; 8869b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public int supportedTypes; 8969b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public boolean enabled; 9069b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public int statusCode; 9169b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public int playbackType; 9269b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public int playbackStream; 9369b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public int volume; 9469b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public int volumeMax; 9569b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public int volumeHandling; 9669b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public int presentationDisplayId; 979dd66417ea984e4ff809ecdba78e3f55a8a17467Insun Kang public @MediaRouter.RouteInfo.DeviceType int deviceType; 9869b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown 9969b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public RouteInfo(String id) { 10069b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown this.id = id; 10169b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown enabled = true; 10269b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown statusCode = MediaRouter.RouteInfo.STATUS_NONE; 10369b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown playbackType = MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE; 10469b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown playbackStream = -1; 10569b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown volumeHandling = MediaRouter.RouteInfo.PLAYBACK_VOLUME_FIXED; 10669b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown presentationDisplayId = -1; 1079dd66417ea984e4ff809ecdba78e3f55a8a17467Insun Kang deviceType = MediaRouter.RouteInfo.DEVICE_TYPE_UNKNOWN; 10869b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown } 10969b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown 11069b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public RouteInfo(RouteInfo other) { 11169b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown id = other.id; 11269b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown name = other.name; 11369b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown description = other.description; 11469b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown supportedTypes = other.supportedTypes; 11569b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown enabled = other.enabled; 11669b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown statusCode = other.statusCode; 11769b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown playbackType = other.playbackType; 11869b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown playbackStream = other.playbackStream; 11969b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown volume = other.volume; 12069b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown volumeMax = other.volumeMax; 12169b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown volumeHandling = other.volumeHandling; 12269b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown presentationDisplayId = other.presentationDisplayId; 1239dd66417ea984e4ff809ecdba78e3f55a8a17467Insun Kang deviceType = other.deviceType; 12469b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown } 12569b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown 12669b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown RouteInfo(Parcel in) { 12769b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown id = in.readString(); 12869b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown name = in.readString(); 12969b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown description = in.readString(); 13069b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown supportedTypes = in.readInt(); 13169b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown enabled = in.readInt() != 0; 13269b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown statusCode = in.readInt(); 13369b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown playbackType = in.readInt(); 13469b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown playbackStream = in.readInt(); 13569b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown volume = in.readInt(); 13669b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown volumeMax = in.readInt(); 13769b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown volumeHandling = in.readInt(); 13869b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown presentationDisplayId = in.readInt(); 1399dd66417ea984e4ff809ecdba78e3f55a8a17467Insun Kang deviceType = in.readInt(); 14069b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown } 14169b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown 14269b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown @Override 14369b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public int describeContents() { 14469b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown return 0; 14569b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown } 14669b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown 14769b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown @Override 14869b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public void writeToParcel(Parcel dest, int flags) { 14969b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown dest.writeString(id); 15069b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown dest.writeString(name); 15169b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown dest.writeString(description); 15269b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown dest.writeInt(supportedTypes); 15369b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown dest.writeInt(enabled ? 1 : 0); 15469b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown dest.writeInt(statusCode); 15569b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown dest.writeInt(playbackType); 15669b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown dest.writeInt(playbackStream); 15769b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown dest.writeInt(volume); 15869b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown dest.writeInt(volumeMax); 15969b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown dest.writeInt(volumeHandling); 16069b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown dest.writeInt(presentationDisplayId); 1619dd66417ea984e4ff809ecdba78e3f55a8a17467Insun Kang dest.writeInt(deviceType); 16269b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown } 16369b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown 16469b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown @Override 16569b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public String toString() { 16669b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown return "RouteInfo{ id=" + id 16769b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown + ", name=" + name 16869b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown + ", description=" + description 16969b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown + ", supportedTypes=0x" + Integer.toHexString(supportedTypes) 17069b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown + ", enabled=" + enabled 17169b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown + ", statusCode=" + statusCode 17269b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown + ", playbackType=" + playbackType 17369b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown + ", playbackStream=" + playbackStream 17469b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown + ", volume=" + volume 17569b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown + ", volumeMax=" + volumeMax 17669b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown + ", volumeHandling=" + volumeHandling 17769b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown + ", presentationDisplayId=" + presentationDisplayId 1789dd66417ea984e4ff809ecdba78e3f55a8a17467Insun Kang + ", deviceType=" + deviceType 17969b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown + " }"; 18069b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown } 18169b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown 18269b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown @SuppressWarnings("hiding") 18369b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public static final Parcelable.Creator<RouteInfo> CREATOR = 18469b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown new Parcelable.Creator<RouteInfo>() { 18569b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown @Override 18669b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public RouteInfo createFromParcel(Parcel in) { 18769b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown return new RouteInfo(in); 18869b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown } 18969b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown 19069b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown @Override 19169b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public RouteInfo[] newArray(int size) { 19269b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown return new RouteInfo[size]; 19369b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown } 19469b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown }; 19569b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown } 19669b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown} 197