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

Commit bc57a6aa authored by Michal Olech's avatar Michal Olech
Browse files

[CEC Configuration] Add 'routing_control' setting

This ports Settings.Global.HDMI_CEC_SWITCH_ENABLED to HdmiCecConfig.

Bug: 187284252
Test: run cts
Change-Id: I7994a1d69ffc0bf68323d4dcc212a89be1926db9
parent f7f4be99
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -3297,6 +3297,7 @@ package android.hardware.hdmi {
    method @Nullable public android.hardware.hdmi.HdmiPlaybackClient getPlaybackClient();
    method @NonNull @RequiresPermission(android.Manifest.permission.HDMI_CEC) public String getPowerControlMode();
    method @NonNull @RequiresPermission(android.Manifest.permission.HDMI_CEC) public String getPowerStateChangeOnActiveSourceLost();
    method @NonNull @RequiresPermission(android.Manifest.permission.HDMI_CEC) public int getRoutingControl();
    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();
@@ -3314,6 +3315,7 @@ package android.hardware.hdmi {
    method @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void setHdmiCecVolumeControlEnabled(int);
    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 setRoutingControl(@NonNull int);
    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);
@@ -3325,6 +3327,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_ROUTING_CONTROL = "routing_control";
    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";
@@ -3399,6 +3402,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 ROUTING_CONTROL_DISABLED = 0; // 0x0
    field public static final int ROUTING_CONTROL_ENABLED = 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
+83 −1
Original line number Diff line number Diff line
@@ -346,7 +346,7 @@ public final class HdmiControlManager {
    @Retention(RetentionPolicy.SOURCE)
    public @interface HdmiCecControl {}

    // -- Supported HDM-CEC versions.
    // -- Supported HDMI-CEC versions.
    /**
     * Version constant for HDMI-CEC v1.4b.
     *
@@ -371,6 +371,31 @@ public final class HdmiControlManager {
    @Retention(RetentionPolicy.SOURCE)
    public @interface HdmiCecVersion {}

    // -- Whether the Routing Control feature is enabled or disabled.
    /**
     * Routing Control feature enabled.
     *
     * @hide
     */
    @SystemApi
    public static final int ROUTING_CONTROL_ENABLED = 1;
    /**
     * Routing Control feature disabled.
     *
     * @hide
     */
    @SystemApi
    public static final int ROUTING_CONTROL_DISABLED = 0;
    /**
     * @hide
     */
    @IntDef(prefix = { "ROUTING_CONTROL_" }, value = {
            ROUTING_CONTROL_ENABLED,
            ROUTING_CONTROL_DISABLED
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface RoutingControl {}

    // -- Scope of CEC power control messages sent by a playback device.
    /**
     * Send CEC power control messages to TV only:
@@ -754,6 +779,13 @@ public final class HdmiControlManager {
     */
    @SystemApi
    public static final String CEC_SETTING_NAME_HDMI_CEC_VERSION = "hdmi_cec_version";
    /**
     * Name of a setting deciding whether the Routing Control feature is enabled.
     *
     * @hide
     */
    @SystemApi
    public static final String CEC_SETTING_NAME_ROUTING_CONTROL = "routing_control";
    /**
     * Name of a setting deciding on the power control mode.
     *
@@ -2074,6 +2106,56 @@ public final class HdmiControlManager {
        }
    }

    /**
     * Set the status of Routing Control feature.
     *
     * <p>This allows to enable/disable Routing Control on the device.
     * If enabled, the switch device will route to the correct input source on
     * receiving Routing Control related messages. If disabled, you can only
     * switch the input via controls on this device.
     *
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.HDMI_CEC)
    public void setRoutingControl(@NonNull @RoutingControl 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_ROUTING_CONTROL, value);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Get the current status of Routing Control feature.
     *
     * <p>Reflects whether Routing Control is currently enabled on the device.
     * If enabled, the switch device will route to the correct input source on
     * receiving Routing Control related messages. If disabled, you can only
     * switch the input via controls on this device.
     *
     * @hide
     */
    @SystemApi
    @NonNull
    @RoutingControl
    @RequiresPermission(android.Manifest.permission.HDMI_CEC)
    public int getRoutingControl() {
        if (mService == null) {
            Log.e(TAG, "HdmiControlService is not available");
            throw new RuntimeException("HdmiControlService is not available");
        }
        try {
            return mService.getCecSettingIntValue(CEC_SETTING_NAME_ROUTING_CONTROL);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Set the status of Power Control.
     *
+6 −0
Original line number Diff line number Diff line
@@ -4848,6 +4848,12 @@
    <bool name="config_cecHdmiCecVersion20_allowed">true</bool>
    <bool name="config_cecHdmiCecVersion20_default">false</bool>

    <bool name="config_cecRoutingControl_userConfigurable">true</bool>
    <bool name="config_cecRoutingControlEnabled_allowed">true</bool>
    <bool name="config_cecRoutingControlEnabled_default">false</bool>
    <bool name="config_cecRoutingControlDisabled_allowed">true</bool>
    <bool name="config_cecRoutingControlDisabled_default">true</bool>

    <bool name="config_cecPowerControlMode_userConfigurable">true</bool>
    <bool name="config_cecPowerControlModeTv_allowed">true</bool>
    <bool name="config_cecPowerControlModeTv_default">false</bool>
+6 −0
Original line number Diff line number Diff line
@@ -4290,6 +4290,12 @@
  <java-symbol type="bool" name="config_cecHdmiCecVersion20_allowed" />
  <java-symbol type="bool" name="config_cecHdmiCecVersion20_default" />

  <java-symbol type="bool" name="config_cecRoutingControl_userConfigurable" />
  <java-symbol type="bool" name="config_cecRoutingControlEnabled_allowed" />
  <java-symbol type="bool" name="config_cecRoutingControlEnabled_default" />
  <java-symbol type="bool" name="config_cecRoutingControlDisabled_allowed" />
  <java-symbol type="bool" name="config_cecRoutingControlDisabled_default" />

  <java-symbol type="bool" name="config_cecPowerControlMode_userConfigurable" />
  <java-symbol type="bool" name="config_cecPowerControlModeTv_allowed" />
  <java-symbol type="bool" name="config_cecPowerControlModeTv_default" />
+14 −0
Original line number Diff line number Diff line
@@ -317,6 +317,16 @@ public class HdmiCecConfig {
                R.bool.config_cecHdmiCecVersion20_allowed,
                R.bool.config_cecHdmiCecVersion20_default);

        Setting routingControlControl = registerSetting(
                HdmiControlManager.CEC_SETTING_NAME_ROUTING_CONTROL,
                R.bool.config_cecRoutingControl_userConfigurable);
        routingControlControl.registerValue(HdmiControlManager.ROUTING_CONTROL_ENABLED,
                R.bool.config_cecRoutingControlEnabled_allowed,
                R.bool.config_cecRoutingControlEnabled_default);
        routingControlControl.registerValue(HdmiControlManager.ROUTING_CONTROL_DISABLED,
                R.bool.config_cecRoutingControlDisabled_allowed,
                R.bool.config_cecRoutingControlDisabled_default);

        Setting powerControlMode = registerSetting(
                HdmiControlManager.CEC_SETTING_NAME_POWER_CONTROL_MODE,
                R.bool.config_cecPowerControlMode_userConfigurable);
@@ -511,6 +521,8 @@ public class HdmiCecConfig {
                return STORAGE_GLOBAL_SETTINGS;
            case HdmiControlManager.CEC_SETTING_NAME_HDMI_CEC_VERSION:
                return STORAGE_SHARED_PREFS;
            case HdmiControlManager.CEC_SETTING_NAME_ROUTING_CONTROL:
                return STORAGE_GLOBAL_SETTINGS;
            case HdmiControlManager.CEC_SETTING_NAME_POWER_CONTROL_MODE:
                return STORAGE_GLOBAL_SETTINGS;
            case HdmiControlManager.CEC_SETTING_NAME_VOLUME_CONTROL_MODE:
@@ -550,6 +562,8 @@ public class HdmiCecConfig {
                return Global.HDMI_CONTROL_ENABLED;
            case HdmiControlManager.CEC_SETTING_NAME_HDMI_CEC_VERSION:
                return setting.getName();
            case HdmiControlManager.CEC_SETTING_NAME_ROUTING_CONTROL:
                return Global.HDMI_CEC_SWITCH_ENABLED;
            case HdmiControlManager.CEC_SETTING_NAME_POWER_CONTROL_MODE:
                return Global.HDMI_CONTROL_SEND_STANDBY_ON_SLEEP;
            case HdmiControlManager.CEC_SETTING_NAME_VOLUME_CONTROL_MODE:
Loading