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

Commit 3d007e9c authored by Michal Olech's avatar Michal Olech
Browse files

[CEC Configuration] Add 'system_audio_control' setting

This ports Settings.Global.HDMI_SYSTEM_AUDIO_CONTROL_ENABLED to
HdmiCecConfig.

Bug: 187284252
Test: run cts
Change-Id: Idb0e069f915a9a7c04c4f7fd24d8c200666c47a9
parent 6fea640d
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -3298,6 +3298,7 @@ package android.hardware.hdmi {
    method @NonNull @RequiresPermission(android.Manifest.permission.HDMI_CEC) public String getPowerControlMode();
    method @NonNull @RequiresPermission(android.Manifest.permission.HDMI_CEC) public String getPowerStateChangeOnActiveSourceLost();
    method @Nullable public android.hardware.hdmi.HdmiSwitchClient getSwitchClient();
    method @NonNull @RequiresPermission(android.Manifest.permission.HDMI_CEC) public int getSystemAudioControl();
    method @NonNull @RequiresPermission(android.Manifest.permission.HDMI_CEC) public int getSystemAudioModeMuting();
    method @Nullable public android.hardware.hdmi.HdmiTvClient getTvClient();
    method @NonNull @RequiresPermission(android.Manifest.permission.HDMI_CEC) public int getTvSendStandbyOnSleep();
@@ -3314,6 +3315,7 @@ package android.hardware.hdmi {
    method @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void setPowerControlMode(@NonNull String);
    method @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void setPowerStateChangeOnActiveSourceLost(@NonNull String);
    method @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void setStandbyMode(boolean);
    method @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void setSystemAudioControl(@NonNull int);
    method @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void setSystemAudioModeMuting(@NonNull int);
    method @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void setTvSendStandbyOnSleep(@NonNull int);
    method @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void setTvWakeOnOneTouchPlay(@NonNull int);
@@ -3323,6 +3325,7 @@ package android.hardware.hdmi {
    field public static final String CEC_SETTING_NAME_HDMI_CEC_VERSION = "hdmi_cec_version";
    field public static final String CEC_SETTING_NAME_POWER_CONTROL_MODE = "power_control_mode";
    field public static final String CEC_SETTING_NAME_POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST = "power_state_change_on_active_source_lost";
    field public static final String CEC_SETTING_NAME_SYSTEM_AUDIO_CONTROL = "system_audio_control";
    field public static final String CEC_SETTING_NAME_SYSTEM_AUDIO_MODE_MUTING = "system_audio_mode_muting";
    field public static final String CEC_SETTING_NAME_TV_SEND_STANDBY_ON_SLEEP = "tv_send_standby_on_sleep";
    field public static final String CEC_SETTING_NAME_TV_WAKE_ON_ONE_TOUCH_PLAY = "tv_wake_on_one_touch_play";
@@ -3396,6 +3399,8 @@ package android.hardware.hdmi {
    field public static final int RESULT_SUCCESS = 0; // 0x0
    field public static final int RESULT_TARGET_NOT_AVAILABLE = 3; // 0x3
    field public static final int RESULT_TIMEOUT = 1; // 0x1
    field public static final int SYSTEM_AUDIO_CONTROL_DISABLED = 0; // 0x0
    field public static final int SYSTEM_AUDIO_CONTROL_ENABLED = 1; // 0x1
    field public static final int SYSTEM_AUDIO_MODE_MUTING_DISABLED = 0; // 0x0
    field public static final int SYSTEM_AUDIO_MODE_MUTING_ENABLED = 1; // 0x1
    field public static final int TIMER_RECORDING_RESULT_EXTRA_CEC_DISABLED = 3; // 0x3
+86 −0
Original line number Diff line number Diff line
@@ -449,6 +449,31 @@ public final class HdmiControlManager {
    @Retention(RetentionPolicy.SOURCE)
    public @interface ActiveSourceLostBehavior {}

    // -- Whether System Audio Control is enabled or disabled.
    /**
     * System Audio Control enabled.
     *
     * @hide
     */
    @SystemApi
    public static final int SYSTEM_AUDIO_CONTROL_ENABLED = 1;
    /**
     * System Audio Control disabled.
     *
     * @hide
     */
    @SystemApi
    public static final int SYSTEM_AUDIO_CONTROL_DISABLED = 0;
    /**
     * @hide
     */
    @IntDef(prefix = { "SYSTEM_AUDIO_CONTROL_" }, value = {
            SYSTEM_AUDIO_CONTROL_ENABLED,
            SYSTEM_AUDIO_CONTROL_DISABLED
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface SystemAudioControl {}

    // -- Whether System Audio Mode muting is enabled or disabled.
    /**
     * System Audio Mode muting enabled.
@@ -744,6 +769,14 @@ public final class HdmiControlManager {
    @SystemApi
    public static final String CEC_SETTING_NAME_POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST =
            "power_state_change_on_active_source_lost";
    /**
     * Name of a setting deciding whether System Audio Control is enabled.
     *
     * @hide
     */
    @SystemApi
    public static final String CEC_SETTING_NAME_SYSTEM_AUDIO_CONTROL =
            "system_audio_control";
    /**
     * Name of a setting deciding whether System Audio Muting is allowed.
     *
@@ -862,6 +895,7 @@ public final class HdmiControlManager {
        CEC_SETTING_NAME_HDMI_CEC_VERSION,
        CEC_SETTING_NAME_POWER_CONTROL_MODE,
        CEC_SETTING_NAME_POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST,
        CEC_SETTING_NAME_SYSTEM_AUDIO_CONTROL,
        CEC_SETTING_NAME_SYSTEM_AUDIO_MODE_MUTING,
        CEC_SETTING_NAME_VOLUME_CONTROL_MODE,
        CEC_SETTING_NAME_TV_WAKE_ON_ONE_TOUCH_PLAY,
@@ -2133,6 +2167,58 @@ public final class HdmiControlManager {
        }
    }

    /**
     * Set the current status of System Audio Control.
     *
     * <p>Sets whether HDMI System Audio Control feature is enabled. If enabled,
     * TV or Audio System will try to turn on the System Audio Mode if there's a
     * connected CEC-enabled AV Receiver. Then an audio stream will be played on
     * the AVR instead of TV speaker or Audio System speakers. If disabled, the
     * System Audio Mode will never be activated.
     *
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.HDMI_CEC)
    public void setSystemAudioControl(@NonNull @SystemAudioControl int value) {
        if (mService == null) {
            Log.e(TAG, "HdmiControlService is not available");
            throw new RuntimeException("HdmiControlService is not available");
        }
        try {
            mService.setCecSettingIntValue(CEC_SETTING_NAME_SYSTEM_AUDIO_CONTROL, value);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Get the current status of System Audio Control.
     *
     * <p>Reflects whether HDMI System Audio Control feature is enabled. If enabled,
     * TV or Audio System will try to turn on the System Audio Mode if there's a
     * connected CEC-enabled AV Receiver. Then an audio stream will be played on
     * the AVR instead of TV speaker or Audio System speakers. If disabled, the
     * System Audio Mode will never be activated.
     *
     * @hide
     */
    @SystemApi
    @NonNull
    @SystemAudioControl
    @RequiresPermission(android.Manifest.permission.HDMI_CEC)
    public int getSystemAudioControl() {
        if (mService == null) {
            Log.e(TAG, "HdmiControlService is not available");
            throw new RuntimeException("HdmiControlService is not available");
        }
        try {
            return mService.getCecSettingIntValue(CEC_SETTING_NAME_SYSTEM_AUDIO_CONTROL);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Set the current status of System Audio Mode muting.
     *
+6 −0
Original line number Diff line number Diff line
@@ -4864,6 +4864,12 @@
    <bool name="config_cecPowerStateChangeOnActiveSourceLostStandbyNow_allowed">true</bool>
    <bool name="config_cecPowerStateChangeOnActiveSourceLostStandbyNow_default">false</bool>

    <bool name="config_cecSystemAudioControl_userConfigurable">true</bool>
    <bool name="config_cecSystemAudioControlEnabled_allowed">true</bool>
    <bool name="config_cecSystemAudioControlEnabled_default">true</bool>
    <bool name="config_cecSystemAudioControlDisabled_allowed">true</bool>
    <bool name="config_cecSystemAudioControlDisabled_default">false</bool>

    <bool name="config_cecSystemAudioModeMuting_userConfigurable">true</bool>
    <bool name="config_cecSystemAudioModeMutingEnabled_allowed">true</bool>
    <bool name="config_cecSystemAudioModeMutingEnabled_default">true</bool>
+6 −0
Original line number Diff line number Diff line
@@ -4306,6 +4306,12 @@
  <java-symbol type="bool" name="config_cecPowerStateChangeOnActiveSourceLostStandbyNow_allowed" />
  <java-symbol type="bool" name="config_cecPowerStateChangeOnActiveSourceLostStandbyNow_default" />

  <java-symbol type="bool" name="config_cecSystemAudioControl_userConfigurable" />
  <java-symbol type="bool" name="config_cecSystemAudioControlEnabled_allowed" />
  <java-symbol type="bool" name="config_cecSystemAudioControlEnabled_default" />
  <java-symbol type="bool" name="config_cecSystemAudioControlDisabled_allowed" />
  <java-symbol type="bool" name="config_cecSystemAudioControlDisabled_default" />

  <java-symbol type="bool" name="config_cecSystemAudioModeMuting_userConfigurable" />
  <java-symbol type="bool" name="config_cecSystemAudioModeMutingEnabled_allowed" />
  <java-symbol type="bool" name="config_cecSystemAudioModeMutingEnabled_default" />
+14 −0
Original line number Diff line number Diff line
@@ -345,6 +345,16 @@ public class HdmiCecConfig {
                R.bool.config_cecPowerStateChangeOnActiveSourceLostStandbyNow_allowed,
                R.bool.config_cecPowerStateChangeOnActiveSourceLostStandbyNow_default);

        Setting systemAudioControl = registerSetting(
                HdmiControlManager.CEC_SETTING_NAME_SYSTEM_AUDIO_CONTROL,
                R.bool.config_cecSystemAudioControl_userConfigurable);
        systemAudioControl.registerValue(HdmiControlManager.SYSTEM_AUDIO_CONTROL_ENABLED,
                R.bool.config_cecSystemAudioControlEnabled_allowed,
                R.bool.config_cecSystemAudioControlEnabled_default);
        systemAudioControl.registerValue(HdmiControlManager.SYSTEM_AUDIO_CONTROL_DISABLED,
                R.bool.config_cecSystemAudioControlDisabled_allowed,
                R.bool.config_cecSystemAudioControlDisabled_default);

        Setting systemAudioModeMuting = registerSetting(
                HdmiControlManager.CEC_SETTING_NAME_SYSTEM_AUDIO_MODE_MUTING,
                R.bool.config_cecSystemAudioModeMuting_userConfigurable);
@@ -507,6 +517,8 @@ public class HdmiCecConfig {
                return STORAGE_GLOBAL_SETTINGS;
            case HdmiControlManager.CEC_SETTING_NAME_POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST:
                return STORAGE_SHARED_PREFS;
            case HdmiControlManager.CEC_SETTING_NAME_SYSTEM_AUDIO_CONTROL:
                return STORAGE_GLOBAL_SETTINGS;
            case HdmiControlManager.CEC_SETTING_NAME_SYSTEM_AUDIO_MODE_MUTING:
                return STORAGE_SHARED_PREFS;
            case HdmiControlManager.CEC_SETTING_NAME_TV_WAKE_ON_ONE_TOUCH_PLAY:
@@ -544,6 +556,8 @@ public class HdmiCecConfig {
                return Global.HDMI_CONTROL_VOLUME_CONTROL_ENABLED;
            case HdmiControlManager.CEC_SETTING_NAME_POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST:
                return setting.getName();
            case HdmiControlManager.CEC_SETTING_NAME_SYSTEM_AUDIO_CONTROL:
                return Global.HDMI_SYSTEM_AUDIO_CONTROL_ENABLED;
            case HdmiControlManager.CEC_SETTING_NAME_SYSTEM_AUDIO_MODE_MUTING:
                return setting.getName();
            case HdmiControlManager.CEC_SETTING_NAME_TV_WAKE_ON_ONE_TOUCH_PLAY:
Loading