Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ebf4bdac authored by Thomas Makin's avatar Thomas Makin
Browse files

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: default avatarThomas Makin <halorocker89@gmail.com>
Co-authored-by: default avatarAaron Kling <webgeek1234@gmail.com>

Change-Id: If101cf5a725315d75ea5315d4cf42c8d55fb7bec
parent 9f4ec92e
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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)