Merge "CEC : Add additional validator for message record status" am: 8f150a68d9 am: 79e282d64b am: 74e93ddf98 am: 01f17b925f
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1413608 Change-Id: I6fdb65c76516f12a1fedeaee2b865357c6427a67
This commit is contained in:
@@ -117,14 +117,15 @@ public class HdmiCecMessageValidator {
|
||||
// TODO: Validate more than length for the following messages.
|
||||
|
||||
// Messages for the One Touch Record.
|
||||
FixedLengthValidator oneByteValidator = new FixedLengthValidator(1);
|
||||
addValidationInfo(Constants.MESSAGE_RECORD_ON,
|
||||
new VariableLengthValidator(1, 8), DEST_DIRECT);
|
||||
addValidationInfo(Constants.MESSAGE_RECORD_STATUS, oneByteValidator, DEST_DIRECT);
|
||||
addValidationInfo(Constants.MESSAGE_RECORD_STATUS,
|
||||
new RecordStatusInfoValidator(), DEST_DIRECT);
|
||||
|
||||
// TODO: Handle messages for the Timer Programming.
|
||||
|
||||
// Messages for the System Information.
|
||||
FixedLengthValidator oneByteValidator = new FixedLengthValidator(1);
|
||||
addValidationInfo(Constants.MESSAGE_CEC_VERSION, oneByteValidator, DEST_DIRECT);
|
||||
addValidationInfo(Constants.MESSAGE_SET_MENU_LANGUAGE,
|
||||
new FixedLengthValidator(3), DEST_BROADCAST);
|
||||
@@ -339,4 +340,23 @@ public class HdmiCecMessageValidator {
|
||||
isValidPhysicalAddress(params, 0) && isValidPhysicalAddress(params, 2));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given record status message parameter is valid.
|
||||
* A valid parameter should lie within the range description of Record Status Info defined in
|
||||
* CEC 1.4 Specification : Operand Descriptions (Section 17)
|
||||
*/
|
||||
private class RecordStatusInfoValidator implements ParameterValidator {
|
||||
@Override
|
||||
public int isValid(byte[] params) {
|
||||
if (params.length < 1) {
|
||||
return ERROR_PARAMETER_SHORT;
|
||||
}
|
||||
return toErrorCode(isWithinRange(params[0], 0x01, 0x07)
|
||||
|| isWithinRange(params[0], 0x09, 0x0E)
|
||||
|| isWithinRange(params[0], 0x10, 0x17)
|
||||
|| isWithinRange(params[0], 0x1A, 0x1B)
|
||||
|| params[0] == 0x1F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user