Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 179e858b authored by Jinsuk Kim's avatar Jinsuk Kim Committed by Android (Google) Code Review
Browse files

Merge "CEC: Replace determistic mute commands"

parents b85c7d5b 0ab37791
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -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;
    }
}
+1 −2
Original line number Diff line number Diff line
@@ -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
+2 −4
Original line number Diff line number Diff line
@@ -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);