Merge "CEC: Replace determistic mute commands"
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecKeycode.java b/services/core/java/com/android/server/hdmi/HdmiCecKeycode.java
index 2eca42b..adc1cd7 100644
--- a/services/core/java/com/android/server/hdmi/HdmiCecKeycode.java
+++ b/services/core/java/com/android/server/hdmi/HdmiCecKeycode.java
@@ -448,4 +448,20 @@
static boolean isSupportedKeycode(int androidKeycode) {
return HdmiCecKeycode.androidKeyToCecKey(androidKeycode) != null;
}
+
+ /**
+ * Returns CEC keycode to control audio mute status.
+ *
+ * @param muting {@code true} if audio is being muted
+ */
+ public static int getMuteKey(boolean muting) {
+ // CEC_KEYCODE_MUTE_FUNCTION, CEC_KEYCODE_RESTORE_VOLUME_FUNCTION are deterministic
+ // commands that ensures the status changes to what we want, while CEC_KEYCODE_MUTE
+ // simply toggles the status.
+ // The former is a better choice in this regard, but there are compatibility issues
+ // observed - many audio receivers don't recognize the commands. We fall back on
+ // CEC_KEYCODE_MUTE for now.
+ // return muting ? CEC_KEYCODE_MUTE_FUNCTION : CEC_KEYCODE_RESTORE_VOLUME_FUNCTION;
+ return CEC_KEYCODE_MUTE;
+ }
}
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java
index cd8484f..e63a143 100644
--- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java
+++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java
@@ -1099,8 +1099,7 @@
// Remove existing volume action.
removeAction(VolumeControlAction.class);
sendUserControlPressedAndReleased(getAvrDeviceInfo().getLogicalAddress(),
- mute ? HdmiCecKeycode.CEC_KEYCODE_MUTE_FUNCTION :
- HdmiCecKeycode.CEC_KEYCODE_RESTORE_VOLUME_FUNCTION);
+ HdmiCecKeycode.getMuteKey(mute));
}
@Override
diff --git a/services/core/java/com/android/server/hdmi/SystemAudioStatusAction.java b/services/core/java/com/android/server/hdmi/SystemAudioStatusAction.java
index dba3591..2ae5c97 100644
--- a/services/core/java/com/android/server/hdmi/SystemAudioStatusAction.java
+++ b/services/core/java/com/android/server/hdmi/SystemAudioStatusAction.java
@@ -68,10 +68,8 @@
// the audio amplifier is unknown.
tv().setAudioStatus(false, Constants.UNKNOWN_VOLUME);
- int uiCommand = tv().isSystemAudioActivated()
- ? HdmiCecKeycode.CEC_KEYCODE_RESTORE_VOLUME_FUNCTION // SystemAudioMode: ON
- : HdmiCecKeycode.CEC_KEYCODE_MUTE_FUNCTION; // SystemAudioMode: OFF
- sendUserControlPressedAndReleased(mAvrAddress, uiCommand);
+ sendUserControlPressedAndReleased(mAvrAddress,
+ HdmiCecKeycode.getMuteKey(!tv().isSystemAudioActivated()));
// Still return SUCCESS to callback.
finishWithCallback(HdmiControlManager.RESULT_SUCCESS);