| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 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 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
@SystemApi |
| 31 |
public final class HdmiPortInfo implements Parcelable { |
| 32 |
|
| 33 |
public static final int PORT_INPUT = 0; |
| 34 |
|
| 35 |
|
| 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 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 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 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
public int getId() { |
| 70 |
return mId; |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
public int getType() { |
| 79 |
return mType; |
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
public int getAddress() { |
| 88 |
return mAddress; |
| 89 |
} |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
public boolean isCecSupported() { |
| 97 |
return mCecSupported; |
| 98 |
} |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
public boolean isMhlSupported() { |
| 106 |
return mMhlSupported; |
| 107 |
} |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
public boolean isArcSupported() { |
| 115 |
return mArcSupported; |
| 116 |
} |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
@Override |
| 123 |
public int describeContents() { |
| 124 |
return 0; |
| 125 |
} |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 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 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 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 |
} |