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

Commit e946ed8f authored by Yuncheol Heo's avatar Yuncheol Heo
Browse files

Check the validity of the port id of HdmiCecMessage only in TV.

In playback device, we don't track the port info, so we can't verify
the validity of the port id part of the physical address parameter of
HdmiCecMessages.

Bug: 16274232
Change-Id: I41f95dba0505d45688e2c9031b78863dc93248ce
parent db573fc0
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -243,12 +243,17 @@ public final class HdmiCecMessageValidator {
    }

    private boolean isValidPhysicalAddress(byte[] params, int offset) {
        // TODO: Add more logic like validating 1.0.1.0.

        if (!mService.isTvDevice()) {
            // If the device is not TV, we can't convert path to port-id, so stop here.
            return true;
        }
        int path = HdmiUtils.twoBytesToInt(params, offset);
        int portId = mService.pathToPortId(path);
        if (portId == Constants.INVALID_PORT_ID) {
            return false;
        }
        // TODO: Add more logic like validating 1.0.1.0.
        return true;
    }

+4 −4
Original line number Diff line number Diff line
@@ -980,10 +980,6 @@ public final class HdmiControlService extends SystemService {
            }
        }

        private boolean isTvDevice() {
            return tv() != null;
        }

        @Override
        public void setProhibitMode(final boolean enabled) {
            enforceAccessPermission();
@@ -1304,6 +1300,10 @@ public final class HdmiControlService extends SystemService {
        return (HdmiCecLocalDeviceTv) mCecController.getLocalDevice(HdmiCecDeviceInfo.DEVICE_TV);
    }

    boolean isTvDevice() {
        return tv() != null;
    }

    private HdmiCecLocalDevicePlayback playback() {
        return (HdmiCecLocalDevicePlayback)
                mCecController.getLocalDevice(HdmiCecDeviceInfo.DEVICE_PLAYBACK);