Merge "CEC: Make TV try to dispatch the message first"

This commit is contained in:
Treehugger Robot
2018-10-18 15:25:30 +00:00
committed by Gerrit Code Review

View File

@@ -303,19 +303,19 @@ public final class HdmiControlService extends SystemService {
private final class CecMessageBuffer { private final class CecMessageBuffer {
private List<HdmiCecMessage> mBuffer = new ArrayList<>(); private List<HdmiCecMessage> mBuffer = new ArrayList<>();
public void bufferMessage(HdmiCecMessage message) { public boolean bufferMessage(HdmiCecMessage message) {
switch (message.getOpcode()) { switch (message.getOpcode()) {
case Constants.MESSAGE_ACTIVE_SOURCE: case Constants.MESSAGE_ACTIVE_SOURCE:
bufferActiveSource(message); bufferActiveSource(message);
break; return true;
case Constants.MESSAGE_IMAGE_VIEW_ON: case Constants.MESSAGE_IMAGE_VIEW_ON:
case Constants.MESSAGE_TEXT_VIEW_ON: case Constants.MESSAGE_TEXT_VIEW_ON:
bufferImageOrTextViewOn(message); bufferImageOrTextViewOn(message);
break; return true;
// Add here if new message that needs to buffer // Add here if new message that needs to buffer
default: default:
// Do not need to buffer messages other than above // Do not need to buffer messages other than above
break; return false;
} }
} }
@@ -869,10 +869,6 @@ public final class HdmiControlService extends SystemService {
@ServiceThreadOnly @ServiceThreadOnly
boolean handleCecCommand(HdmiCecMessage message) { boolean handleCecCommand(HdmiCecMessage message) {
assertRunOnServiceThread(); assertRunOnServiceThread();
if (!mAddressAllocated) {
mCecMessageBuffer.bufferMessage(message);
return true;
}
int errorCode = mMessageValidator.isValid(message); int errorCode = mMessageValidator.isValid(message);
if (errorCode != HdmiCecMessageValidator.OK) { if (errorCode != HdmiCecMessageValidator.OK) {
// We'll not response on the messages with the invalid source or destination // 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 true;
} }
return dispatchMessageToLocalDevice(message);
if (dispatchMessageToLocalDevice(message)) {
return true;
}
return (!mAddressAllocated) ? mCecMessageBuffer.bufferMessage(message) : false;
} }
void enableAudioReturnChannel(int portId, boolean enabled) { void enableAudioReturnChannel(int portId, boolean enabled) {