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

Commit 7bbf9e72 authored by Jungshik Jang's avatar Jungshik Jang Committed by Android (Google) Code Review
Browse files

Merge "Use message validator for sending message." into lmp-dev

parents 985e566c 5f75cbd8
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);
    }

    /**