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

Commit 09e7bdc6 authored by Hannah.Hsu's avatar Hannah.Hsu Committed by Hannah Hsu
Browse files

Optimize the flow for checking [Duration Available]

Since [Duration Available] is optional parameter for <Timer Status>, only check if this parameter is valid when parameter length matched.
Bug: b/320579948

Change-Id: I4003d652bf47acca22ba447b9921bd96b445675f
parent 583bc717
Loading
Loading
Loading
Loading
+8 −4
Original line number Original line Diff line number Diff line
@@ -717,7 +717,10 @@ public class HdmiCecMessageValidator {
            // Programmed
            // Programmed
            int programedInfo = params[offset] & 0x0F;
            int programedInfo = params[offset] & 0x0F;
            if (isValidProgrammedInfo(programedInfo)) {
            if (isValidProgrammedInfo(programedInfo)) {
                if (programedInfo == 0x09 || programedInfo == 0x0B) {
                offset = offset + 1;
                // Duration Available (2 bytes)
                if ((programedInfo == 0x09 || programedInfo == 0x0B)
                        && params.length - offset >= 2) {
                    durationAvailable = true;
                    durationAvailable = true;
                } else {
                } else {
                    return true;
                    return true;
@@ -727,16 +730,17 @@ public class HdmiCecMessageValidator {
            // Non programmed
            // Non programmed
            int nonProgramedErrorInfo = params[offset] & 0x0F;
            int nonProgramedErrorInfo = params[offset] & 0x0F;
            if (isValidNotProgrammedErrorInfo(nonProgramedErrorInfo)) {
            if (isValidNotProgrammedErrorInfo(nonProgramedErrorInfo)) {
                if (nonProgramedErrorInfo == 0x0E) {
                offset = offset + 1;
                // Duration Available (2 bytes)
                if (nonProgramedErrorInfo == 0x0E && params.length - offset >= 2) {
                    durationAvailable = true;
                    durationAvailable = true;
                } else {
                } else {
                    return true;
                    return true;
                }
                }
            }
            }
        }
        }
        offset = offset + 1;
        // Duration Available (2 bytes)
        // Duration Available (2 bytes)
        if (durationAvailable && params.length - offset >= 2) {
        if (durationAvailable) {
            return (isValidDurationHours(params[offset]) && isValidMinute(params[offset + 1]));
            return (isValidDurationHours(params[offset]) && isValidMinute(params[offset + 1]));
        }
        }
        return false;
        return false;