private int mType;
private int mAudioType;
private String mAudioAddress;
- // TODO: Add HDMI handle for HDMI service.
+ private int mHdmiPortId;
private TvInputHardwareInfo() {
}
return mAudioAddress;
}
+ public int getHdmiPortId() {
+ if (mType != TV_INPUT_TYPE_HDMI) {
+ throw new IllegalStateException();
+ }
+ return mHdmiPortId;
+ }
+
// Parcelable
@Override
public int describeContents() {
dest.writeInt(mType);
dest.writeInt(mAudioType);
dest.writeString(mAudioAddress);
+ if (mType == TV_INPUT_TYPE_HDMI) {
+ dest.writeInt(mHdmiPortId);
+ }
}
public void readFromParcel(Parcel source) {
mType = source.readInt();
mAudioType = source.readInt();
mAudioAddress = source.readString();
+ if (mType == TV_INPUT_TYPE_HDMI) {
+ mHdmiPortId = source.readInt();
+ }
}
public static final class Builder {
private Integer mType = null;
private int mAudioType = AudioManager.DEVICE_NONE;
private String mAudioAddress = "";
+ private Integer mHdmiPortId = null;
public Builder() {
}
return this;
}
+ public Builder hdmiPortId(int hdmiPortId) {
+ mHdmiPortId = hdmiPortId;
+ return this;
+ }
+
public TvInputHardwareInfo build() {
if (mDeviceId == null || mType == null) {
throw new UnsupportedOperationException();
}
+ if ((mType == TV_INPUT_TYPE_HDMI && mHdmiPortId == null) ||
+ (mType != TV_INPUT_TYPE_HDMI && mHdmiPortId != null)) {
+ throw new UnsupportedOperationException();
+ }
TvInputHardwareInfo info = new TvInputHardwareInfo();
info.mDeviceId = mDeviceId;
if (info.mAudioType != AudioManager.DEVICE_NONE) {
info.mAudioAddress = mAudioAddress;
}
+ if (mHdmiPortId != null) {
+ info.mHdmiPortId = mHdmiPortId;
+ }
return info;
}
}
jmethodID constructor;
jmethodID deviceId;
jmethodID type;
+ jmethodID hdmiPortId;
jmethodID audioType;
jmethodID audioAddress;
jmethodID build;
builder, gTvInputHardwareInfoBuilderClassInfo.deviceId, info.device_id);
env->CallObjectMethod(
builder, gTvInputHardwareInfoBuilderClassInfo.type, info.type);
+ if (info.type == TV_INPUT_TYPE_HDMI) {
+ env->CallObjectMethod(
+ builder, gTvInputHardwareInfoBuilderClassInfo.hdmiPortId, info.hdmi.port_id);
+ }
env->CallObjectMethod(
builder, gTvInputHardwareInfoBuilderClassInfo.audioType, info.audio_type);
if (info.audio_type != AUDIO_DEVICE_NONE) {
gTvInputHardwareInfoBuilderClassInfo.clazz,
"type", "(I)Landroid/media/tv/TvInputHardwareInfo$Builder;");
GET_METHOD_ID(
+ gTvInputHardwareInfoBuilderClassInfo.hdmiPortId,
+ gTvInputHardwareInfoBuilderClassInfo.clazz,
+ "hdmiPortId", "(I)Landroid/media/tv/TvInputHardwareInfo$Builder;");
+ GET_METHOD_ID(
gTvInputHardwareInfoBuilderClassInfo.audioType,
gTvInputHardwareInfoBuilderClassInfo.clazz,
"audioType", "(I)Landroid/media/tv/TvInputHardwareInfo$Builder;");