Loading services/core/java/com/android/server/hdmi/HdmiCecMessageValidator.java +17 −1 Original line number Diff line number Diff line Loading @@ -242,7 +242,7 @@ public class HdmiCecMessageValidator { mValidationInfo.append(opcode, new ValidationInfo(validator, addrType)); } int isValid(HdmiCecMessage message) { int isValid(HdmiCecMessage message, boolean isMessageReceived) { int opcode = message.getOpcode(); ValidationInfo info = mValidationInfo.get(opcode); if (info == null) { Loading @@ -256,6 +256,22 @@ public class HdmiCecMessageValidator { HdmiLogger.warning("Unexpected source: " + message); return ERROR_SOURCE; } if (isMessageReceived) { // Check if the source's logical address and local device's logical // address are the same. for (HdmiCecLocalDevice device : mService.getAllLocalDevices()) { synchronized (device.mLock) { if (message.getSource() == device.getDeviceInfo().getLogicalAddress() && message.getSource() != Constants.ADDR_UNREGISTERED) { HdmiLogger.warning( "Unexpected source: message sent from device itself, " + message); return ERROR_SOURCE; } } } } // Check the destination field. if (message.getDestination() == Constants.ADDR_BROADCAST) { if ((info.addressType & DEST_BROADCAST) == 0) { Loading services/core/java/com/android/server/hdmi/HdmiControlService.java +4 −4 Original line number Diff line number Diff line Loading @@ -1122,7 +1122,7 @@ public class HdmiControlService extends SystemService { @ServiceThreadOnly void sendCecCommand(HdmiCecMessage command, @Nullable SendMessageCallback callback) { assertRunOnServiceThread(); if (mMessageValidator.isValid(command) == HdmiCecMessageValidator.OK) { if (mMessageValidator.isValid(command, false) == HdmiCecMessageValidator.OK) { mCecController.sendCommand(command, callback); } else { HdmiLogger.error("Invalid message type:" + command); Loading Loading @@ -1153,7 +1153,7 @@ public class HdmiControlService extends SystemService { @ServiceThreadOnly boolean handleCecCommand(HdmiCecMessage message) { assertRunOnServiceThread(); int errorCode = mMessageValidator.isValid(message); int errorCode = mMessageValidator.isValid(message, true); if (errorCode != HdmiCecMessageValidator.OK) { // We'll not response on the messages with the invalid source or destination // or with parameter length shorter than specified in the standard. Loading services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -125,7 +125,7 @@ public class HdmiCecLocalDeviceTest { mMessageValidator = new HdmiCecMessageValidator(mHdmiControlService) { @Override int isValid(HdmiCecMessage message) { int isValid(HdmiCecMessage message, boolean isMessageReceived) { return HdmiCecMessageValidator.OK; } }; Loading services/tests/servicestests/src/com/android/server/hdmi/HdmiCecMessageValidatorTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -629,7 +629,7 @@ public class HdmiCecMessageValidatorTest { } private IntegerSubject assertMessageValidity(String message) { return assertThat(mHdmiCecMessageValidator.isValid(buildMessage(message))); return assertThat(mHdmiCecMessageValidator.isValid(buildMessage(message), false)); } /** Loading Loading
services/core/java/com/android/server/hdmi/HdmiCecMessageValidator.java +17 −1 Original line number Diff line number Diff line Loading @@ -242,7 +242,7 @@ public class HdmiCecMessageValidator { mValidationInfo.append(opcode, new ValidationInfo(validator, addrType)); } int isValid(HdmiCecMessage message) { int isValid(HdmiCecMessage message, boolean isMessageReceived) { int opcode = message.getOpcode(); ValidationInfo info = mValidationInfo.get(opcode); if (info == null) { Loading @@ -256,6 +256,22 @@ public class HdmiCecMessageValidator { HdmiLogger.warning("Unexpected source: " + message); return ERROR_SOURCE; } if (isMessageReceived) { // Check if the source's logical address and local device's logical // address are the same. for (HdmiCecLocalDevice device : mService.getAllLocalDevices()) { synchronized (device.mLock) { if (message.getSource() == device.getDeviceInfo().getLogicalAddress() && message.getSource() != Constants.ADDR_UNREGISTERED) { HdmiLogger.warning( "Unexpected source: message sent from device itself, " + message); return ERROR_SOURCE; } } } } // Check the destination field. if (message.getDestination() == Constants.ADDR_BROADCAST) { if ((info.addressType & DEST_BROADCAST) == 0) { Loading
services/core/java/com/android/server/hdmi/HdmiControlService.java +4 −4 Original line number Diff line number Diff line Loading @@ -1122,7 +1122,7 @@ public class HdmiControlService extends SystemService { @ServiceThreadOnly void sendCecCommand(HdmiCecMessage command, @Nullable SendMessageCallback callback) { assertRunOnServiceThread(); if (mMessageValidator.isValid(command) == HdmiCecMessageValidator.OK) { if (mMessageValidator.isValid(command, false) == HdmiCecMessageValidator.OK) { mCecController.sendCommand(command, callback); } else { HdmiLogger.error("Invalid message type:" + command); Loading Loading @@ -1153,7 +1153,7 @@ public class HdmiControlService extends SystemService { @ServiceThreadOnly boolean handleCecCommand(HdmiCecMessage message) { assertRunOnServiceThread(); int errorCode = mMessageValidator.isValid(message); int errorCode = mMessageValidator.isValid(message, true); if (errorCode != HdmiCecMessageValidator.OK) { // We'll not response on the messages with the invalid source or destination // or with parameter length shorter than specified in the standard. Loading
services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -125,7 +125,7 @@ public class HdmiCecLocalDeviceTest { mMessageValidator = new HdmiCecMessageValidator(mHdmiControlService) { @Override int isValid(HdmiCecMessage message) { int isValid(HdmiCecMessage message, boolean isMessageReceived) { return HdmiCecMessageValidator.OK; } }; Loading
services/tests/servicestests/src/com/android/server/hdmi/HdmiCecMessageValidatorTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -629,7 +629,7 @@ public class HdmiCecMessageValidatorTest { } private IntegerSubject assertMessageValidity(String message) { return assertThat(mHdmiCecMessageValidator.isValid(buildMessage(message))); return assertThat(mHdmiCecMessageValidator.isValid(buildMessage(message), false)); } /** Loading