Merge "CEC: Update system audio mode based on the current status of AVR" into nyc-dev

This commit is contained in:
Donghyun Cho
2016-05-12 02:05:09 +00:00
committed by Android (Google) Code Review
2 changed files with 12 additions and 11 deletions

View File

@@ -826,9 +826,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
@ServiceThreadOnly @ServiceThreadOnly
void onNewAvrAdded(HdmiDeviceInfo avr) { void onNewAvrAdded(HdmiDeviceInfo avr) {
assertRunOnServiceThread(); assertRunOnServiceThread();
if (getSystemAudioModeSetting() && !isSystemAudioActivated()) { addAndStartAction(new SystemAudioAutoInitiationAction(this, avr.getLogicalAddress()));
addAndStartAction(new SystemAudioAutoInitiationAction(this, avr.getLogicalAddress()));
}
if (isArcFeatureEnabled(avr.getPortId()) if (isArcFeatureEnabled(avr.getPortId())
&& !hasAction(SetArcTransmissionStateAction.class)) { && !hasAction(SetArcTransmissionStateAction.class)) {
startArcAction(true); startArcAction(true);
@@ -1172,12 +1170,13 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
if (getAvrDeviceInfo() == null) { if (getAvrDeviceInfo() == null) {
// AVR may not have been discovered yet. Delay the message processing. // AVR may not have been discovered yet. Delay the message processing.
mDelayedMessageBuffer.add(message); mDelayedMessageBuffer.add(message);
return true; } else {
HdmiLogger.warning("Invalid <Set System Audio Mode> message:" + message);
mService.maySendFeatureAbortCommand(message, Constants.ABORT_REFUSED);
} }
HdmiLogger.warning("Invalid <Set System Audio Mode> message:" + message);
mService.maySendFeatureAbortCommand(message, Constants.ABORT_REFUSED);
return true; return true;
} }
removeAction(SystemAudioAutoInitiationAction.class);
SystemAudioActionFromAvr action = new SystemAudioActionFromAvr(this, SystemAudioActionFromAvr action = new SystemAudioActionFromAvr(this,
message.getSource(), HdmiUtils.parseCommandParamSystemAudioStatus(message), null); message.getSource(), HdmiUtils.parseCommandParamSystemAudioStatus(message), null);
addAndStartAction(action); addAndStartAction(action);

View File

@@ -64,13 +64,13 @@ final class SystemAudioAutoInitiationAction extends HdmiCecFeatureAction {
} }
if (cmd.getOpcode() == Constants.MESSAGE_SYSTEM_AUDIO_MODE_STATUS) { if (cmd.getOpcode() == Constants.MESSAGE_SYSTEM_AUDIO_MODE_STATUS) {
handleSystemAudioModeStatusMessage(); handleSystemAudioModeStatusMessage(HdmiUtils.parseCommandParamSystemAudioStatus(cmd));
return true; return true;
} }
return false; return false;
} }
private void handleSystemAudioModeStatusMessage() { private void handleSystemAudioModeStatusMessage(boolean isSystemAudioModeOn) {
if (!canChangeSystemAudio()) { if (!canChangeSystemAudio()) {
HdmiLogger.debug("Cannot change system audio mode in auto initiation action."); HdmiLogger.debug("Cannot change system audio mode in auto initiation action.");
finish(); finish();
@@ -78,9 +78,11 @@ final class SystemAudioAutoInitiationAction extends HdmiCecFeatureAction {
} }
boolean systemAudioModeSetting = tv().getSystemAudioModeSetting(); boolean systemAudioModeSetting = tv().getSystemAudioModeSetting();
// Update AVR's system audio mode regardless of AVR's status. if (systemAudioModeSetting && !isSystemAudioModeOn) {
addAndStartAction(new SystemAudioActionFromTv(tv(), mAvrAddress, systemAudioModeSetting, addAndStartAction(new SystemAudioActionFromTv(tv(), mAvrAddress, systemAudioModeSetting, null));
null)); } else {
tv().setSystemAudioMode(isSystemAudioModeOn, true);
}
finish(); finish();
} }