From e65360216890886b2fa507ddb656820c166bba22 Mon Sep 17 00:00:00 2001 From: Jinsuk Kim Date: Tue, 2 Dec 2014 13:40:02 +0900 Subject: [PATCH] CEC: Set the parameter of right The parameter should be the physical address of the source device not that of AVR. Bug: 18582101 Change-Id: I3f7fd71ab87f174babc0d2bb10b2661df19336eb --- .../java/com/android/server/hdmi/Constants.java | 1 + .../android/server/hdmi/SystemAudioAction.java | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/hdmi/Constants.java b/services/core/java/com/android/server/hdmi/Constants.java index bb12eae614a6d..f6d4efdfb933f 100644 --- a/services/core/java/com/android/server/hdmi/Constants.java +++ b/services/core/java/com/android/server/hdmi/Constants.java @@ -186,6 +186,7 @@ final class Constants { static final int INVALID_PORT_ID = HdmiDeviceInfo.PORT_INVALID; static final int INVALID_PHYSICAL_ADDRESS = HdmiDeviceInfo.PATH_INVALID; + static final int PATH_INTERNAL = HdmiDeviceInfo.PATH_INTERNAL; // Send result codes. It should be consistent with hdmi_cec.h's send_message error code. static final int SEND_RESULT_SUCCESS = 0; diff --git a/services/core/java/com/android/server/hdmi/SystemAudioAction.java b/services/core/java/com/android/server/hdmi/SystemAudioAction.java index 6023354bd6c72..a209cd0cca73f 100644 --- a/services/core/java/com/android/server/hdmi/SystemAudioAction.java +++ b/services/core/java/com/android/server/hdmi/SystemAudioAction.java @@ -90,10 +90,9 @@ abstract class SystemAudioAction extends HdmiCecFeatureAction { } private void sendSystemAudioModeRequestInternal() { - int avrPhysicalAddress = tv().getAvrDeviceInfo().getPhysicalAddress(); HdmiCecMessage command = HdmiCecMessageBuilder.buildSystemAudioModeRequest( getSourceAddress(), - mAvrLogicalAddress, avrPhysicalAddress, mTargetAudioStatus); + mAvrLogicalAddress, getSystemAudioModeRequestParam(), mTargetAudioStatus); sendCommand(command, new HdmiControlService.SendMessageCallback() { @Override public void onSendCompleted(int error) { @@ -108,6 +107,20 @@ abstract class SystemAudioAction extends HdmiCecFeatureAction { addTimer(mState, mTargetAudioStatus ? ON_TIMEOUT_MS : OFF_TIMEOUT_MS); } + private int getSystemAudioModeRequestParam() { + // takes the physical address of the source device + // as a parameter. Get it from following candidates, in the order listed below: + // 1) physical address of the active source + // 2) active routing path + // 3) physical address of TV + if (tv().getActiveSource().isValid()) { + return tv().getActiveSource().physicalAddress; + } + int param = tv().getActivePath(); + return param != Constants.INVALID_PHYSICAL_ADDRESS + ? param : Constants.PATH_INTERNAL; + } + private void handleSendSystemAudioModeRequestTimeout() { if (!mTargetAudioStatus // Don't retry for Off case. || mSendRetryCount++ >= MAX_SEND_RETRY_COUNT) {