2 * Copyright (C) 2013 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package android.media;
19 import android.os.Parcel;
20 import android.os.Parcelable;
21 import android.text.TextUtils;
23 import java.util.ArrayList;
26 * Information available from IRemoteDisplayProvider about available remote displays.
28 * Clients must not modify the contents of this object.
31 public final class RemoteDisplayState implements Parcelable {
32 // Note: These constants are used by the remote display provider API.
33 // Do not change them!
34 public static final String SERVICE_INTERFACE =
35 "com.android.media.remotedisplay.RemoteDisplayProvider";
36 public static final int DISCOVERY_MODE_NONE = 0;
37 public static final int DISCOVERY_MODE_PASSIVE = 1;
38 public static final int DISCOVERY_MODE_ACTIVE = 2;
41 * A list of all remote displays.
43 public final ArrayList<RemoteDisplayInfo> displays;
45 public RemoteDisplayState() {
46 displays = new ArrayList<RemoteDisplayInfo>();
49 RemoteDisplayState(Parcel src) {
50 displays = src.createTypedArrayList(RemoteDisplayInfo.CREATOR);
53 public boolean isValid() {
54 if (displays == null) {
57 final int count = displays.size();
58 for (int i = 0; i < count; i++) {
59 if (!displays.get(i).isValid()) {
67 public int describeContents() {
72 public void writeToParcel(Parcel dest, int flags) {
73 dest.writeTypedList(displays);
76 public static final Parcelable.Creator<RemoteDisplayState> CREATOR =
77 new Parcelable.Creator<RemoteDisplayState>() {
79 public RemoteDisplayState createFromParcel(Parcel in) {
80 return new RemoteDisplayState(in);
84 public RemoteDisplayState[] newArray(int size) {
85 return new RemoteDisplayState[size];
89 public static final class RemoteDisplayInfo implements Parcelable {
90 // Note: These constants are used by the remote display provider API.
91 // Do not change them!
92 public static final int STATUS_NOT_AVAILABLE = 0;
93 public static final int STATUS_IN_USE = 1;
94 public static final int STATUS_AVAILABLE = 2;
95 public static final int STATUS_CONNECTING = 3;
96 public static final int STATUS_CONNECTED = 4;
98 public static final int PLAYBACK_VOLUME_VARIABLE =
99 MediaRouter.RouteInfo.PLAYBACK_VOLUME_VARIABLE;
100 public static final int PLAYBACK_VOLUME_FIXED =
101 MediaRouter.RouteInfo.PLAYBACK_VOLUME_FIXED;
105 public String description;
108 public int volumeMax;
109 public int volumeHandling;
110 public int presentationDisplayId;
112 public RemoteDisplayInfo(String id) {
114 status = STATUS_NOT_AVAILABLE;
115 volumeHandling = MediaRouter.RouteInfo.PLAYBACK_VOLUME_FIXED;
116 presentationDisplayId = -1;
119 public RemoteDisplayInfo(RemoteDisplayInfo other) {
122 description = other.description;
123 status = other.status;
124 volume = other.volume;
125 volumeMax = other.volumeMax;
126 volumeHandling = other.volumeHandling;
127 presentationDisplayId = other.presentationDisplayId;
130 RemoteDisplayInfo(Parcel in) {
131 id = in.readString();
132 name = in.readString();
133 description = in.readString();
134 status = in.readInt();
135 volume = in.readInt();
136 volumeMax = in.readInt();
137 volumeHandling = in.readInt();
138 presentationDisplayId = in.readInt();
141 public boolean isValid() {
142 return !TextUtils.isEmpty(id) && !TextUtils.isEmpty(name);
146 public int describeContents() {
151 public void writeToParcel(Parcel dest, int flags) {
152 dest.writeString(id);
153 dest.writeString(name);
154 dest.writeString(description);
155 dest.writeInt(status);
156 dest.writeInt(volume);
157 dest.writeInt(volumeMax);
158 dest.writeInt(volumeHandling);
159 dest.writeInt(presentationDisplayId);
163 public String toString() {
164 return "RemoteDisplayInfo{ id=" + id
166 + ", description=" + description
167 + ", status=" + status
168 + ", volume=" + volume
169 + ", volumeMax=" + volumeMax
170 + ", volumeHandling=" + volumeHandling
171 + ", presentationDisplayId=" + presentationDisplayId
175 @SuppressWarnings("hiding")
176 public static final Parcelable.Creator<RemoteDisplayInfo> CREATOR =
177 new Parcelable.Creator<RemoteDisplayInfo>() {
179 public RemoteDisplayInfo createFromParcel(Parcel in) {
180 return new RemoteDisplayInfo(in);
184 public RemoteDisplayInfo[] newArray(int size) {
185 return new RemoteDisplayInfo[size];