diff options
| author | 2023-10-27 00:31:42 -0500 | |
|---|---|---|
| committer | 2024-02-21 21:35:45 +0000 | |
| commit | ebf4bdac942e9bea0b89f00f7b0c281fc8c048ce (patch) | |
| tree | 7086a881755016eeaab36a248754a56e694f85f5 | |
| parent | 9f4ec92e13547630d85f46c9a6beaa8219cbb5ae (diff) | |
CEC: correct frameworks physicalAddress parsing
The HIDL interface defines physical address as a uint16_t, but Java
does not utilize unsigned types, so it represents this value as a
standard 32-bit signed integer type. However, it extends the MSB to
the full 32-bits instead of padding with zeroes, causing large
values to be read as negative, crashing the service when
HdmiPortInfo builder asserts >=0.
This also clarifies a related comment likely sourced from the same
incorrect assumption about how the parsing behaves.
Co-authored-by: Thomas Makin <halorocker89@gmail.com>
Co-authored-by: Aaron Kling <webgeek1234@gmail.com>
Change-Id: If101cf5a725315d75ea5315d4cf42c8d55fb7bec
| -rw-r--r-- | services/core/java/com/android/server/hdmi/HdmiCecController.java | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecController.java b/services/core/java/com/android/server/hdmi/HdmiCecController.java index 9087354dee40..3f89f236dfc3 100644 --- a/services/core/java/com/android/server/hdmi/HdmiCecController.java +++ b/services/core/java/com/android/server/hdmi/HdmiCecController.java @@ -347,7 +347,7 @@ final class HdmiCecController { * {@link HdmiCecNetwork} only. * * @return CEC physical address of the device. The range of success address - * is between 0x0000 and 0xFFFF. If failed it returns -1 + * is between 0x0000 and 0xFFFE. If failed it returns INVALID_PHYSICAL_ADDRESS. */ @ServiceThreadOnly int getPhysicalAddress() { @@ -1299,7 +1299,7 @@ final class HdmiCecController { hdmiPortInfo[i] = new HdmiPortInfo.Builder( portInfo.portId, portInfo.type, - portInfo.physicalAddress) + Short.toUnsignedInt(portInfo.physicalAddress)) .setCecSupported(portInfo.cecSupported) .setMhlSupported(false) .setArcSupported(portInfo.arcSupported) @@ -1496,7 +1496,7 @@ final class HdmiCecController { hdmiPortInfo[i] = new HdmiPortInfo.Builder( portInfo.portId, portInfo.type, - portInfo.physicalAddress) + Short.toUnsignedInt(portInfo.physicalAddress)) .setCecSupported(portInfo.cecSupported) .setMhlSupported(false) .setArcSupported(portInfo.arcSupported) |