CEC: Update system audio mode based on the current status of AVR
When AVR is newly discovered, make TV get the current status of AVR first. Based on the response, TV will update and initiate system audio mode if necessary. Bug: 27858658, Bug: 27168826 Change-Id: I3084471db970d271693f10dae802d8abaccddf39
This commit is contained in:
@@ -826,9 +826,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
|
||||
@ServiceThreadOnly
|
||||
void onNewAvrAdded(HdmiDeviceInfo avr) {
|
||||
assertRunOnServiceThread();
|
||||
if (getSystemAudioModeSetting() && !isSystemAudioActivated()) {
|
||||
addAndStartAction(new SystemAudioAutoInitiationAction(this, avr.getLogicalAddress()));
|
||||
}
|
||||
addAndStartAction(new SystemAudioAutoInitiationAction(this, avr.getLogicalAddress()));
|
||||
if (isArcFeatureEnabled(avr.getPortId())
|
||||
&& !hasAction(SetArcTransmissionStateAction.class)) {
|
||||
startArcAction(true);
|
||||
@@ -1172,12 +1170,13 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
|
||||
if (getAvrDeviceInfo() == null) {
|
||||
// AVR may not have been discovered yet. Delay the message processing.
|
||||
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;
|
||||
}
|
||||
removeAction(SystemAudioAutoInitiationAction.class);
|
||||
SystemAudioActionFromAvr action = new SystemAudioActionFromAvr(this,
|
||||
message.getSource(), HdmiUtils.parseCommandParamSystemAudioStatus(message), null);
|
||||
addAndStartAction(action);
|
||||
|
||||
@@ -64,13 +64,13 @@ final class SystemAudioAutoInitiationAction extends HdmiCecFeatureAction {
|
||||
}
|
||||
|
||||
if (cmd.getOpcode() == Constants.MESSAGE_SYSTEM_AUDIO_MODE_STATUS) {
|
||||
handleSystemAudioModeStatusMessage();
|
||||
handleSystemAudioModeStatusMessage(HdmiUtils.parseCommandParamSystemAudioStatus(cmd));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void handleSystemAudioModeStatusMessage() {
|
||||
private void handleSystemAudioModeStatusMessage(boolean isSystemAudioModeOn) {
|
||||
if (!canChangeSystemAudio()) {
|
||||
HdmiLogger.debug("Cannot change system audio mode in auto initiation action.");
|
||||
finish();
|
||||
@@ -78,9 +78,11 @@ final class SystemAudioAutoInitiationAction extends HdmiCecFeatureAction {
|
||||
}
|
||||
|
||||
boolean systemAudioModeSetting = tv().getSystemAudioModeSetting();
|
||||
// Update AVR's system audio mode regardless of AVR's status.
|
||||
addAndStartAction(new SystemAudioActionFromTv(tv(), mAvrAddress, systemAudioModeSetting,
|
||||
null));
|
||||
if (systemAudioModeSetting && !isSystemAudioModeOn) {
|
||||
addAndStartAction(new SystemAudioActionFromTv(tv(), mAvrAddress, systemAudioModeSetting, null));
|
||||
} else {
|
||||
tv().setSystemAudioMode(isSystemAudioModeOn, true);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user