From 6f69264f7583729bd898d1357fb3de061661b458 Mon Sep 17 00:00:00 2001 From: Marvin Ramin Date: Mon, 7 Dec 2020 15:47:57 +0100 Subject: [PATCH 1/2] Add HdmiDeviceInfo#mHdmiCecVersion Store CEC version for each device. Defaults to HDMI CEC 1.4b. Bug: 174732339 Test: make; atest HdmiDeviceInfoTest Change-Id: I97c962d58b16ddfab9010a1738670a107e12481f --- .../android/hardware/hdmi/HdmiDeviceInfo.java | 47 +++++++++++++++++-- .../hardware/hdmi/HdmiDeviceInfoTest.java | 11 +++++ .../android/server/hdmi/HdmiCecNetwork.java | 8 ++-- .../server/hdmi/HdmiControlService.java | 9 ++-- .../com/android/server/hdmi/HdmiUtils.java | 2 +- 5 files changed, 66 insertions(+), 11 deletions(-) diff --git a/core/java/android/hardware/hdmi/HdmiDeviceInfo.java b/core/java/android/hardware/hdmi/HdmiDeviceInfo.java index c6007f1184f5c..a8cafef844f1e 100644 --- a/core/java/android/hardware/hdmi/HdmiDeviceInfo.java +++ b/core/java/android/hardware/hdmi/HdmiDeviceInfo.java @@ -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. *