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

Commit 8ed86c46 authored by Jungshik Jang's avatar Jungshik Jang
Browse files

Implement retransmission of cec request.

BUG: 16218422
Change-Id: I4a6692ba8815e9a0ae26c872656b31b678d54fd6

Conflicts:
	services/core/java/com/android/server/hdmi/HdmiCecController.java
parent ff0d298a
Loading
Loading
Loading
Loading
+13 −4
Original line number Original line Diff line number Diff line
@@ -533,16 +533,25 @@ final class HdmiCecController {
            @Override
            @Override
            public void run() {
            public void run() {
                byte[] body = buildBody(cecMessage.getOpcode(), cecMessage.getParams());
                byte[] body = buildBody(cecMessage.getOpcode(), cecMessage.getParams());
                final int error = nativeSendCecCommand(mNativePtr, cecMessage.getSource(),
                int i = 0;
                int errorCode = Constants.SEND_RESULT_SUCCESS;
                do {
                    errorCode = nativeSendCecCommand(mNativePtr, cecMessage.getSource(),
                            cecMessage.getDestination(), body);
                            cecMessage.getDestination(), body);
                if (error != Constants.SEND_RESULT_SUCCESS) {
                    if (errorCode == Constants.SEND_RESULT_SUCCESS) {
                        break;
                    }
                } while (i++ < HdmiConfig.RETRANSMISSION_COUNT);

                final int finalError = errorCode;
                if (finalError != Constants.SEND_RESULT_SUCCESS) {
                    Slog.w(TAG, "Failed to send " + cecMessage);
                    Slog.w(TAG, "Failed to send " + cecMessage);
                }
                }
                if (callback != null) {
                if (callback != null) {
                    runOnServiceThread(new Runnable() {
                    runOnServiceThread(new Runnable() {
                        @Override
                        @Override
                        public void run() {
                        public void run() {
                            callback.onSendCompleted(error);
                            callback.onSendCompleted(finalError);
                        }
                        }
                    });
                    });
                }
                }
+7 −0
Original line number Original line Diff line number Diff line
@@ -39,5 +39,12 @@ final class HdmiConfig {
    // Number of retries for polling each device in address allocation mechanism.
    // Number of retries for polling each device in address allocation mechanism.
    static final int ADDRESS_ALLOCATION_RETRY = 3;
    static final int ADDRESS_ALLOCATION_RETRY = 3;


    // CEC spec said that it should try retransmission at least once.
    // The actual number of send request for a single command will be at most
    // RETRANSMISSION_COUNT + 1. Note that it affects only to normal commands
    // and polling message for logical address allocation and device discovery
    // action. They will have their own retransmission count.
    static final int RETRANSMISSION_COUNT = 1;

    private HdmiConfig() { /* cannot be instantiated */ }
    private HdmiConfig() { /* cannot be instantiated */ }
}
}