Debian Codegraph @

core/java/android/hardware/hdmi/HdmiPortInfo.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2014 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 package android.hardware.hdmi;
17
18 import android.annotation.NonNull;
19 import android.annotation.Nullable;
20 import android.annotation.SystemApi;
21 import android.os.Parcel;
22 import android.os.Parcelable;
23
24 /**
25 * A class to encapsulate HDMI port information. Contains the capability of the ports such as
26 * HDMI-CEC, MHL, ARC(Audio Return Channel), and physical address assigned to each port.
27 *
28 * @hide
29 */
30 @SystemApi
31 public final class HdmiPortInfo implements Parcelable {
32 /** HDMI port type: Input */
33 public static final int PORT_INPUT = 0;
34
35 /** HDMI port type: Output */
36 public static final int PORT_OUTPUT = 1;
37
38 private final int mId;
39 private final int mType;
40 private final int mAddress;
41 private final boolean mCecSupported;
42 private final boolean mArcSupported;
43 private final boolean mMhlSupported;
44
45 /**
46 * Constructor.
47 *
48 * @param id identifier assigned to each port. 1 for HDMI port 1
49 * @param type HDMI port input/output type
50 * @param address physical address of the port
51 * @param cec {@code true} if HDMI-CEC is supported on the port
52 * @param mhl {@code true} if MHL is supported on the port
53 * @param arc {@code true} if audio return channel is supported on the port
54 */
55 public HdmiPortInfo(int id, int type, int address, boolean cec, boolean mhl, boolean arc) {
56 mId = id;
57 mType = type;
58 mAddress = address;
59 mCecSupported = cec;
60 mArcSupported = arc;
61 mMhlSupported = mhl;
62 }
63
64 /**
65 * Returns the port id.
66 *
67 * @return port id
68 */
69 public int getId() {
70 return mId;
71 }
72
73 /**
74 * Returns the port type.
75 *
76 * @return port type
77 */
78 public int getType() {
79 return mType;
80 }
81
82 /**
83 * Returns the port address.
84 *
85 * @return port address
86 */
87 public int getAddress() {
88 return mAddress;
89 }
90
91 /**
92 * Returns {@code true} if the port supports HDMI-CEC signaling.
93 *
94 * @return {@code true} if the port supports HDMI-CEC signaling.
95 */
96 public boolean isCecSupported() {
97 return mCecSupported;
98 }
99
100 /**
101 * Returns {@code true} if the port supports MHL signaling.
102 *
103 * @return {@code true} if the port supports MHL signaling.
104 */
105 public boolean isMhlSupported() {
106 return mMhlSupported;
107 }
108
109 /**
110 * Returns {@code true} if the port supports audio return channel.
111 *
112 * @return {@code true} if the port supports audio return channel
113 */
114 public boolean isArcSupported() {
115 return mArcSupported;
116 }
117
118 /**
119 * Describes the kinds of special objects contained in this Parcelable's
120 * marshalled representation.
121 */
122 @Override
123 public int describeContents() {
124 return 0;
125 }
126
127
128 /**
129 * A helper class to deserialize {@link HdmiPortInfo} for a parcel.
130 */
131 public static final @android.annotation.NonNull Parcelable.Creator<HdmiPortInfo> CREATOR =
132 new Parcelable.Creator<HdmiPortInfo>() {
133 @Override
134 public HdmiPortInfo createFromParcel(Parcel source) {
135 int id = source.readInt();
136 int type = source.readInt();
137 int address = source.readInt();
138 boolean cec = (source.readInt() == 1);
139 boolean arc = (source.readInt() == 1);
140 boolean mhl = (source.readInt() == 1);
141 return new HdmiPortInfo(id, type, address, cec, mhl, arc);
142 }
143
144 @Override
145 public HdmiPortInfo[] newArray(int size) {
146 return new HdmiPortInfo[size];
147 }
148 };
149
150 /**
151 * Serializes this object into a {@link Parcel}.
152 *
153 * @param dest The Parcel in which the object should be written.
154 * @param flags Additional flags about how the object should be written.
155 * May be 0 or {@link Parcelable#PARCELABLE_WRITE_RETURN_VALUE}.
156 * @hide
157 */
158 @SystemApi
159 @Override
160 public void writeToParcel(Parcel dest, int flags) {
161 dest.writeInt(mId);
162 dest.writeInt(mType);
163 dest.writeInt(mAddress);
164 dest.writeInt(mCecSupported ? 1 : 0);
165 dest.writeInt(mArcSupported ? 1 : 0);
166 dest.writeInt(mMhlSupported ? 1 : 0);
167 }
168
169 @NonNull
170 @Override
171 public String toString() {
172 StringBuilder s = new StringBuilder();
173 s.append("port_id: ").append(mId).append(", ");
174 s.append("type: ").append((mType == PORT_INPUT) ? "HDMI_IN" : "HDMI_OUT").append(", ");
175 s.append("address: ").append(String.format("0x%04x", mAddress)).append(", ");
176 s.append("cec: ").append(mCecSupported).append(", ");
177 s.append("arc: ").append(mArcSupported).append(", ");
178 s.append("mhl: ").append(mMhlSupported);
179 return s.toString();
180 }
181
182 @Override
183 public boolean equals(@Nullable Object o) {
184 if (!(o instanceof HdmiPortInfo)) {
185 return false;
186 }
187 final HdmiPortInfo other = (HdmiPortInfo) o;
188 return mId == other.mId && mType == other.mType && mAddress == other.mAddress
189 && mCecSupported == other.mCecSupported && mArcSupported == other.mArcSupported
190 && mMhlSupported == other.mMhlSupported;
191 }
192
193 @Override
194 public int hashCode() {
195 return java.util.Objects.hash(
196 mId, mType, mAddress, mCecSupported, mArcSupported, mMhlSupported);
197 }
198 }