Merge "TvInputHardware: Add HDMI port ID"
This commit is contained in:
@@ -59,7 +59,7 @@ public final class TvInputHardwareInfo implements Parcelable {
|
||||
private int mType;
|
||||
private int mAudioType;
|
||||
private String mAudioAddress;
|
||||
// TODO: Add HDMI handle for HDMI service.
|
||||
private int mHdmiPortId;
|
||||
|
||||
private TvInputHardwareInfo() {
|
||||
}
|
||||
@@ -80,6 +80,13 @@ public final class TvInputHardwareInfo implements Parcelable {
|
||||
return mAudioAddress;
|
||||
}
|
||||
|
||||
public int getHdmiPortId() {
|
||||
if (mType != TV_INPUT_TYPE_HDMI) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
return mHdmiPortId;
|
||||
}
|
||||
|
||||
// Parcelable
|
||||
@Override
|
||||
public int describeContents() {
|
||||
@@ -92,6 +99,9 @@ public final class TvInputHardwareInfo implements Parcelable {
|
||||
dest.writeInt(mType);
|
||||
dest.writeInt(mAudioType);
|
||||
dest.writeString(mAudioAddress);
|
||||
if (mType == TV_INPUT_TYPE_HDMI) {
|
||||
dest.writeInt(mHdmiPortId);
|
||||
}
|
||||
}
|
||||
|
||||
public void readFromParcel(Parcel source) {
|
||||
@@ -99,6 +109,9 @@ public final class TvInputHardwareInfo implements Parcelable {
|
||||
mType = source.readInt();
|
||||
mAudioType = source.readInt();
|
||||
mAudioAddress = source.readString();
|
||||
if (mType == TV_INPUT_TYPE_HDMI) {
|
||||
mHdmiPortId = source.readInt();
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Builder {
|
||||
@@ -106,6 +119,7 @@ public final class TvInputHardwareInfo implements Parcelable {
|
||||
private Integer mType = null;
|
||||
private int mAudioType = AudioManager.DEVICE_NONE;
|
||||
private String mAudioAddress = "";
|
||||
private Integer mHdmiPortId = null;
|
||||
|
||||
public Builder() {
|
||||
}
|
||||
@@ -130,10 +144,19 @@ public final class TvInputHardwareInfo implements Parcelable {
|
||||
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;
|
||||
@@ -142,6 +165,9 @@ public final class TvInputHardwareInfo implements Parcelable {
|
||||
if (info.mAudioType != AudioManager.DEVICE_NONE) {
|
||||
info.mAudioAddress = mAudioAddress;
|
||||
}
|
||||
if (mHdmiPortId != null) {
|
||||
info.mHdmiPortId = mHdmiPortId;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ static struct {
|
||||
jmethodID constructor;
|
||||
jmethodID deviceId;
|
||||
jmethodID type;
|
||||
jmethodID hdmiPortId;
|
||||
jmethodID audioType;
|
||||
jmethodID audioAddress;
|
||||
jmethodID build;
|
||||
@@ -250,6 +251,10 @@ void JTvInputHal::onDeviceAvailable(const tv_input_device_info_t& info) {
|
||||
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) {
|
||||
@@ -431,6 +436,10 @@ int register_android_server_tv_TvInputHal(JNIEnv* env) {
|
||||
gTvInputHardwareInfoBuilderClassInfo.type,
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user