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

Commit a15539ec authored by Kyeongkab.Nam's avatar Kyeongkab.Nam
Browse files

CEC: Make TV try to dispatch the message first

TV sometimes does not wake up after receiving <Image/Text View On> when
connected device starts "One Touch Play" from suspend state.
Since CEC message is not dispatched and just buffered.

This CL changes to dispatch message first and then buffer message if it
fails.

Test: run "One Touch Play" from suspend(standby) state.
Change-Id: I148a0d3373b5b85c8a4d7b858147e7a6e118b7b4
parent b65aca27
Loading
Loading
Loading
Loading
+10 −9
Original line number Diff line number Diff line
@@ -303,19 +303,19 @@ public final class HdmiControlService extends SystemService {
    private final class CecMessageBuffer {
        private List<HdmiCecMessage> mBuffer = new ArrayList<>();

        public void bufferMessage(HdmiCecMessage message) {
        public boolean bufferMessage(HdmiCecMessage message) {
            switch (message.getOpcode()) {
                case Constants.MESSAGE_ACTIVE_SOURCE:
                    bufferActiveSource(message);
                    break;
                    return true;
                case Constants.MESSAGE_IMAGE_VIEW_ON:
                case Constants.MESSAGE_TEXT_VIEW_ON:
                    bufferImageOrTextViewOn(message);
                    break;
                    return true;
                    // Add here if new message that needs to buffer
                default:
                    // Do not need to buffer messages other than above
                    break;
                    return false;
            }
        }

@@ -869,10 +869,6 @@ public final class HdmiControlService extends SystemService {
    @ServiceThreadOnly
    boolean handleCecCommand(HdmiCecMessage message) {
        assertRunOnServiceThread();
        if (!mAddressAllocated) {
            mCecMessageBuffer.bufferMessage(message);
            return true;
        }
        int errorCode = mMessageValidator.isValid(message);
        if (errorCode != HdmiCecMessageValidator.OK) {
            // We'll not response on the messages with the invalid source or destination
@@ -882,7 +878,12 @@ public final class HdmiControlService extends SystemService {
            }
            return true;
        }
        return dispatchMessageToLocalDevice(message);

        if (dispatchMessageToLocalDevice(message)) {
            return true;
        }

        return (!mAddressAllocated) ? mCecMessageBuffer.bufferMessage(message) : false;
    }

    void enableAudioReturnChannel(int portId, boolean enabled) {