Loading services/core/java/com/android/server/hdmi/HdmiCecKeycode.java +16 −0 Original line number Diff line number Diff line Loading @@ -448,4 +448,20 @@ final class HdmiCecKeycode { 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; } } services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java +1 −2 Original line number Diff line number Diff line Loading @@ -1099,8 +1099,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { // 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 Loading services/core/java/com/android/server/hdmi/SystemAudioStatusAction.java +2 −4 Original line number Diff line number Diff line Loading @@ -68,10 +68,8 @@ final class SystemAudioStatusAction extends HdmiCecFeatureAction { // 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); Loading Loading
services/core/java/com/android/server/hdmi/HdmiCecKeycode.java +16 −0 Original line number Diff line number Diff line Loading @@ -448,4 +448,20 @@ final class HdmiCecKeycode { 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; } }
services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java +1 −2 Original line number Diff line number Diff line Loading @@ -1099,8 +1099,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { // 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 Loading
services/core/java/com/android/server/hdmi/SystemAudioStatusAction.java +2 −4 Original line number Diff line number Diff line Loading @@ -68,10 +68,8 @@ final class SystemAudioStatusAction extends HdmiCecFeatureAction { // 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); Loading