Add HdmiDeviceInfo#mHdmiCecVersion

Store CEC version for each device. Defaults to HDMI CEC 1.4b.

Bug: 174732339
Test: make; atest HdmiDeviceInfoTest

Change-Id: I97c962d58b16ddfab9010a1738670a107e12481f
This commit is contained in:
Marvin Ramin
2020-12-07 15:47:57 +01:00
parent dd6308cafb
commit 6f69264f75
5 changed files with 66 additions and 11 deletions

View File

@@ -19,6 +19,7 @@ package android.hardware.hdmi;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.hardware.hdmi.HdmiControlManager.HdmiCecVersion;
import android.os.Parcel;
import android.os.Parcelable;
@@ -107,6 +108,8 @@ public class HdmiDeviceInfo implements Parcelable {
// CEC only parameters.
private final int mLogicalAddress;
private final int mDeviceType;
@HdmiCecVersion
private final int mHdmiCecVersion;
private final int mVendorId;
private final String mDisplayName;
private final int mDevicePowerStatus;
@@ -133,8 +136,9 @@ public class HdmiDeviceInfo implements Parcelable {
int vendorId = source.readInt();
int powerStatus = source.readInt();
String displayName = source.readString();
int cecVersion = source.readInt();
return new HdmiDeviceInfo(logicalAddress, physicalAddress, portId,
deviceType, vendorId, displayName, powerStatus);
deviceType, vendorId, displayName, powerStatus, cecVersion);
case HDMI_DEVICE_TYPE_MHL:
int deviceId = source.readInt();
int adopterId = source.readInt();
@@ -167,7 +171,7 @@ public class HdmiDeviceInfo implements Parcelable {
* @hide
*/
public HdmiDeviceInfo(int logicalAddress, int physicalAddress, int portId, int deviceType,
int vendorId, String displayName, int powerStatus) {
int vendorId, String displayName, int powerStatus, int hdmiCecVersion) {
mHdmiDeviceType = HDMI_DEVICE_TYPE_CEC;
mPhysicalAddress = physicalAddress;
mPortId = portId;
@@ -175,6 +179,7 @@ public class HdmiDeviceInfo implements Parcelable {
mId = idForCecDevice(logicalAddress);
mLogicalAddress = logicalAddress;
mDeviceType = deviceType;
mHdmiCecVersion = hdmiCecVersion;
mVendorId = vendorId;
mDevicePowerStatus = powerStatus;
mDisplayName = displayName;
@@ -192,12 +197,31 @@ public class HdmiDeviceInfo implements Parcelable {
* @param deviceType type of device
* @param vendorId vendor id of device. Used for vendor specific command.
* @param displayName name of device
* @param powerStatus device power status
* @hide
*/
public HdmiDeviceInfo(int logicalAddress, int physicalAddress, int portId, int deviceType,
int vendorId, String displayName, int powerStatus) {
this(logicalAddress, physicalAddress, portId, deviceType,
vendorId, displayName, powerStatus, HdmiControlManager.HDMI_CEC_VERSION_1_4_b);
}
/**
* Constructor. Used to initialize the instance for CEC device.
*
* @param logicalAddress logical address of HDMI-CEC device
* @param physicalAddress physical address of HDMI-CEC device
* @param portId HDMI port ID (1 for HDMI1)
* @param deviceType type of device
* @param vendorId vendor id of device. Used for vendor specific command.
* @param displayName name of device
* @hide
*/
public HdmiDeviceInfo(int logicalAddress, int physicalAddress, int portId, int deviceType,
int vendorId, String displayName) {
this(logicalAddress, physicalAddress, portId, deviceType,
vendorId, displayName, HdmiControlManager.POWER_STATUS_UNKNOWN);
vendorId, displayName, HdmiControlManager.POWER_STATUS_UNKNOWN,
HdmiControlManager.HDMI_CEC_VERSION_1_4_b);
}
/**
@@ -215,6 +239,7 @@ public class HdmiDeviceInfo implements Parcelable {
mId = idForHardware(portId);
mLogicalAddress = -1;
mDeviceType = DEVICE_RESERVED;
mHdmiCecVersion = HdmiControlManager.HDMI_CEC_VERSION_1_4_b;
mVendorId = 0;
mDevicePowerStatus = HdmiControlManager.POWER_STATUS_UNKNOWN;
mDisplayName = "HDMI" + portId;
@@ -240,6 +265,7 @@ public class HdmiDeviceInfo implements Parcelable {
mId = idForMhlDevice(portId);
mLogicalAddress = -1;
mDeviceType = DEVICE_RESERVED;
mHdmiCecVersion = HdmiControlManager.HDMI_CEC_VERSION_1_4_b;
mVendorId = 0;
mDevicePowerStatus = HdmiControlManager.POWER_STATUS_UNKNOWN;
mDisplayName = "Mobile";
@@ -261,6 +287,7 @@ public class HdmiDeviceInfo implements Parcelable {
mLogicalAddress = -1;
mDeviceType = DEVICE_INACTIVE;
mHdmiCecVersion = HdmiControlManager.HDMI_CEC_VERSION_1_4_b;
mPortId = PORT_INVALID;
mDevicePowerStatus = HdmiControlManager.POWER_STATUS_UNKNOWN;
mDisplayName = "Inactive";
@@ -338,6 +365,16 @@ public class HdmiDeviceInfo implements Parcelable {
return mDeviceType;
}
/**
* Returns the CEC version the device supports.
*
* @hide
*/
@HdmiCecVersion
public int getCecVersion() {
return mHdmiCecVersion;
}
/**
* Returns device's power status. It should be one of the following values.
* <ul>
@@ -448,6 +485,7 @@ public class HdmiDeviceInfo implements Parcelable {
dest.writeInt(mVendorId);
dest.writeInt(mDevicePowerStatus);
dest.writeString(mDisplayName);
dest.writeInt(mHdmiCecVersion);
break;
case HDMI_DEVICE_TYPE_MHL:
dest.writeInt(mDeviceId);
@@ -470,6 +508,7 @@ public class HdmiDeviceInfo implements Parcelable {
s.append("logical_address: ").append(String.format("0x%02X", mLogicalAddress));
s.append(" ");
s.append("device_type: ").append(mDeviceType).append(" ");
s.append("cec_version: ").append(mHdmiCecVersion).append(" ");
s.append("vendor_id: ").append(mVendorId).append(" ");
s.append("display_name: ").append(mDisplayName).append(" ");
s.append("power_status: ").append(mDevicePowerStatus).append(" ");
@@ -507,6 +546,7 @@ public class HdmiDeviceInfo implements Parcelable {
&& mPortId == other.mPortId
&& mLogicalAddress == other.mLogicalAddress
&& mDeviceType == other.mDeviceType
&& mHdmiCecVersion == other.mHdmiCecVersion
&& mVendorId == other.mVendorId
&& mDevicePowerStatus == other.mDevicePowerStatus
&& mDisplayName.equals(other.mDisplayName)
@@ -522,6 +562,7 @@ public class HdmiDeviceInfo implements Parcelable {
mPortId,
mLogicalAddress,
mDeviceType,
mHdmiCecVersion,
mVendorId,
mDevicePowerStatus,
mDisplayName,

View File

@@ -37,6 +37,7 @@ public class HdmiDeviceInfoTest {
int deviceType = 0;
int vendorId = 0x123456;
String displayName = "test device";
int cecVersion = HdmiControlManager.HDMI_CEC_VERSION_2_0;
int powerStatus = HdmiControlManager.POWER_STATUS_TRANSIENT_TO_STANDBY;
int deviceId = 3;
int adopterId = 2;
@@ -70,6 +71,16 @@ public class HdmiDeviceInfoTest {
vendorId,
displayName,
powerStatus))
.addEqualityGroup(
new HdmiDeviceInfo(
logicalAddr,
phyAddr,
portId,
deviceType,
vendorId,
displayName,
powerStatus,
cecVersion))
.testEquals();
}
}

View File

@@ -543,7 +543,8 @@ public class HdmiCecNetwork {
HdmiDeviceInfo updatedDeviceInfo = new HdmiDeviceInfo(deviceInfo.getLogicalAddress(),
physicalAddress,
physicalAddressToPortId(physicalAddress), type, deviceInfo.getVendorId(),
deviceInfo.getDisplayName(), deviceInfo.getDevicePowerStatus());
deviceInfo.getDisplayName(), deviceInfo.getDevicePowerStatus(),
deviceInfo.getCecVersion());
updateCecDevice(updatedDeviceInfo);
}
}
@@ -586,7 +587,7 @@ public class HdmiCecNetwork {
updateCecDevice(new HdmiDeviceInfo(deviceInfo.getLogicalAddress(),
deviceInfo.getPhysicalAddress(), deviceInfo.getPortId(),
deviceInfo.getDeviceType(), deviceInfo.getVendorId(), osdName,
deviceInfo.getDevicePowerStatus()));
deviceInfo.getDevicePowerStatus(), deviceInfo.getCecVersion()));
}
@ServiceThreadOnly
@@ -602,7 +603,8 @@ public class HdmiCecNetwork {
HdmiDeviceInfo updatedDeviceInfo = new HdmiDeviceInfo(deviceInfo.getLogicalAddress(),
deviceInfo.getPhysicalAddress(),
deviceInfo.getPortId(), deviceInfo.getDeviceType(), vendorId,
deviceInfo.getDisplayName(), deviceInfo.getDevicePowerStatus());
deviceInfo.getDisplayName(), deviceInfo.getDevicePowerStatus(),
deviceInfo.getCecVersion());
updateCecDevice(updatedDeviceInfo);
}
}

View File

@@ -813,7 +813,7 @@ public class HdmiControlService extends SystemService {
// with system.
HdmiDeviceInfo deviceInfo = createDeviceInfo(logicalAddress,
deviceType,
HdmiControlManager.POWER_STATUS_ON);
HdmiControlManager.POWER_STATUS_ON, getCecVersion());
localDevice.setDeviceInfo(deviceInfo);
mHdmiCecNetwork.addLocalDevice(deviceType, localDevice);
mCecController.addLogicalAddress(logicalAddress);
@@ -1222,11 +1222,12 @@ public class HdmiControlService extends SystemService {
}
}
private HdmiDeviceInfo createDeviceInfo(int logicalAddress, int deviceType, int powerStatus) {
private HdmiDeviceInfo createDeviceInfo(int logicalAddress, int deviceType, int powerStatus,
int cecVersion) {
String displayName = readStringSetting(Global.DEVICE_NAME, Build.MODEL);
return new HdmiDeviceInfo(logicalAddress,
getPhysicalAddress(), pathToPortId(getPhysicalAddress()), deviceType,
getVendorId(), displayName, powerStatus);
getVendorId(), displayName, powerStatus, cecVersion);
}
// Set the display name in HdmiDeviceInfo of the current devices to content provided by
@@ -1240,7 +1241,7 @@ public class HdmiControlService extends SystemService {
device.setDeviceInfo(new HdmiDeviceInfo(
deviceInfo.getLogicalAddress(), deviceInfo.getPhysicalAddress(),
deviceInfo.getPortId(), deviceInfo.getDeviceType(), deviceInfo.getVendorId(),
newDisplayName, deviceInfo.getDevicePowerStatus()));
newDisplayName, deviceInfo.getDevicePowerStatus(), deviceInfo.getCecVersion()));
sendCecCommand(HdmiCecMessageBuilder.buildSetOsdNameCommand(
device.mAddress, Constants.ADDR_TV, newDisplayName));
}

View File

@@ -396,7 +396,7 @@ final class HdmiUtils {
static HdmiDeviceInfo cloneHdmiDeviceInfo(HdmiDeviceInfo info, int newPowerStatus) {
return new HdmiDeviceInfo(info.getLogicalAddress(),
info.getPhysicalAddress(), info.getPortId(), info.getDeviceType(),
info.getVendorId(), info.getDisplayName(), newPowerStatus);
info.getVendorId(), info.getDisplayName(), newPowerStatus, info.getCecVersion());
}
/**