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

Commit 5f75cbd8 authored by Jungshik Jang's avatar Jungshik Jang
Browse files

Use message validator for sending message.

Change-Id: I2ff82c5596e8c78c24189199ede66ee9905b95f5
parent 9b5bd967
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -28,8 +28,6 @@ import java.util.Arrays;
public final class HdmiCecMessage {
    public static final byte[] EMPTY_PARAM = EmptyArray.BYTE;

    private static final int MAX_MESSAGE_PARAM_LENGTH = 14;

    private final int mSource;
    private final int mDestination;

@@ -43,12 +41,6 @@ public final class HdmiCecMessage {
        mSource = source;
        mDestination = destination;
        mOpcode = opcode & 0xFF;

        if (params.length > MAX_MESSAGE_PARAM_LENGTH) {
            throw new IllegalArgumentException(
                    "Param length should be at most 13 but current param length is "
                    + params.length);
        }
        mParams = Arrays.copyOf(params, params.length);
    }

+9 −2
Original line number Diff line number Diff line
@@ -517,13 +517,20 @@ public final class HdmiControlService extends SystemService {
    @ServiceThreadOnly
    void sendCecCommand(HdmiCecMessage command, @Nullable SendMessageCallback callback) {
        assertRunOnServiceThread();
        if (mMessageValidator.isValid(command)) {
            mCecController.sendCommand(command, callback);
        } else {
            Slog.e(TAG, "Invalid message type:" + command);
            if (callback != null) {
                callback.onSendCompleted(Constants.SEND_RESULT_FAILURE);
            }
        }
    }

    @ServiceThreadOnly
    void sendCecCommand(HdmiCecMessage command) {
        assertRunOnServiceThread();
        mCecController.sendCommand(command, null);
        sendCecCommand(command, null);
    }

    /**