From ecf20a8565fa0b4136da43a68fef86acd71a8e35 Mon Sep 17 00:00:00 2001 From: Michal Olech Date: Mon, 14 Dec 2020 16:35:07 +0100 Subject: [PATCH] [CEC Configuration] Add @SystemApi for CEC Configuration Bug: 172637440 Bug: 174731501 Test: atest com.google.android.gts.hdmicec.HdmiControlManagerHostTest Change-Id: I0877bacd6170c908400ed2742a5dd6bbf1f149fb --- core/api/system-current.txt | 29 ++++++ .../hardware/hdmi/HdmiControlManager.java | 98 +++++++++++-------- 2 files changed, 86 insertions(+), 41 deletions(-) diff --git a/core/api/system-current.txt b/core/api/system-current.txt index d040f41aa9ce6..a6dfdac44ff10 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -2743,19 +2743,37 @@ package android.hardware.hdmi { public final class HdmiControlManager { method @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void addHotplugEventListener(android.hardware.hdmi.HdmiControlManager.HotplugEventListener); method @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void addHotplugEventListener(@NonNull java.util.concurrent.Executor, @NonNull android.hardware.hdmi.HdmiControlManager.HotplugEventListener); + method @NonNull @RequiresPermission(android.Manifest.permission.HDMI_CEC) public java.util.List getAllowedCecSettingIntValues(@NonNull String); + method @NonNull @RequiresPermission(android.Manifest.permission.HDMI_CEC) public java.util.List getAllowedCecSettingStringValues(@NonNull String); method @Nullable public android.hardware.hdmi.HdmiClient getClient(int); method @NonNull public java.util.List getConnectedDevices(); + method @NonNull @RequiresPermission(android.Manifest.permission.HDMI_CEC) public int getHdmiCecEnabled(); + method @NonNull @RequiresPermission(android.Manifest.permission.HDMI_CEC) public int getHdmiCecVersion(); method public int getPhysicalAddress(); 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 @Nullable public android.hardware.hdmi.HdmiSwitchClient getSwitchClient(); + 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 java.util.List getUserCecSettings(); method public boolean isDeviceConnected(@NonNull android.hardware.hdmi.HdmiDeviceInfo); method public void powerOffDevice(@NonNull android.hardware.hdmi.HdmiDeviceInfo); method @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void removeHotplugEventListener(android.hardware.hdmi.HdmiControlManager.HotplugEventListener); method public void setActiveSource(@NonNull android.hardware.hdmi.HdmiDeviceInfo); + method @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void setHdmiCecEnabled(@NonNull int); + method @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void setHdmiCecVersion(@NonNull 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 setStandbyMode(boolean); + method @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void setSystemAudioModeMuting(@NonNull int); field public static final String ACTION_OSD_MESSAGE = "android.hardware.hdmi.action.OSD_MESSAGE"; field public static final int AVR_VOLUME_MUTED = 101; // 0x65 + field public static final String CEC_SETTING_NAME_HDMI_CEC_ENABLED = "hdmi_cec_enabled"; + 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 = "send_standby_on_sleep"; + 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_MODE_MUTING = "system_audio_mode_muting"; field public static final int CLEAR_TIMER_STATUS_CEC_DISABLE = 162; // 0xa2 field public static final int CLEAR_TIMER_STATUS_CHECK_RECORDER_CONNECTION = 160; // 0xa0 field public static final int CLEAR_TIMER_STATUS_FAIL_TO_CLEAR_SELECTED_SOURCE = 161; // 0xa1 @@ -2772,6 +2790,10 @@ package android.hardware.hdmi { field public static final int DEVICE_EVENT_UPDATE_DEVICE = 3; // 0x3 field public static final String EXTRA_MESSAGE_EXTRA_PARAM1 = "android.hardware.hdmi.extra.MESSAGE_EXTRA_PARAM1"; field public static final String EXTRA_MESSAGE_ID = "android.hardware.hdmi.extra.MESSAGE_ID"; + field public static final int HDMI_CEC_CONTROL_DISABLED = 0; // 0x0 + field public static final int HDMI_CEC_CONTROL_ENABLED = 1; // 0x1 + field public static final int HDMI_CEC_VERSION_1_4_B = 5; // 0x5 + field public static final int HDMI_CEC_VERSION_2_0 = 6; // 0x6 field public static final int ONE_TOUCH_RECORD_ALREADY_RECORDING = 18; // 0x12 field public static final int ONE_TOUCH_RECORD_CEC_DISABLED = 51; // 0x33 field public static final int ONE_TOUCH_RECORD_CHECK_RECORDER_CONNECTION = 49; // 0x31 @@ -2802,6 +2824,11 @@ package android.hardware.hdmi { field public static final int ONE_TOUCH_RECORD_UNSUPPORTED_CA = 11; // 0xb field public static final int OSD_MESSAGE_ARC_CONNECTED_INVALID_PORT = 1; // 0x1 field public static final int OSD_MESSAGE_AVR_VOLUME_CHANGED = 2; // 0x2 + field public static final String POWER_CONTROL_MODE_BROADCAST = "broadcast"; + field public static final String POWER_CONTROL_MODE_NONE = "none"; + field public static final String POWER_CONTROL_MODE_TV = "to_tv"; + field public static final String POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST_NONE = "none"; + field public static final String POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST_STANDBY_NOW = "standby_now"; field public static final int POWER_STATUS_ON = 0; // 0x0 field public static final int POWER_STATUS_STANDBY = 1; // 0x1 field public static final int POWER_STATUS_TRANSIENT_TO_ON = 2; // 0x2 @@ -2815,6 +2842,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_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 field public static final int TIMER_RECORDING_RESULT_EXTRA_CHECK_RECORDER_CONNECTION = 1; // 0x1 field public static final int TIMER_RECORDING_RESULT_EXTRA_FAIL_TO_RECORD_SELECTED_SOURCE = 2; // 0x2 diff --git a/core/java/android/hardware/hdmi/HdmiControlManager.java b/core/java/android/hardware/hdmi/HdmiControlManager.java index 43f04cd2fd40b..38ffc80e3f217 100644 --- a/core/java/android/hardware/hdmi/HdmiControlManager.java +++ b/core/java/android/hardware/hdmi/HdmiControlManager.java @@ -327,17 +327,19 @@ public final class HdmiControlManager { * * @hide */ + @SystemApi public static final int HDMI_CEC_CONTROL_ENABLED = 1; /** * HDMI CEC disabled. * * @hide */ + @SystemApi public static final int HDMI_CEC_CONTROL_DISABLED = 0; /** * @hide */ - @IntDef({ + @IntDef(prefix = { "HDMI_CEC_CONTROL_" }, value = { HDMI_CEC_CONTROL_ENABLED, HDMI_CEC_CONTROL_DISABLED }) @@ -350,17 +352,19 @@ public final class HdmiControlManager { * * @hide */ + @SystemApi public static final int HDMI_CEC_VERSION_1_4_B = 0x05; /** * Version constant for HDMI-CEC v2.0. * * @hide */ + @SystemApi public static final int HDMI_CEC_VERSION_2_0 = 0x06; /** * @hide */ - @IntDef({ + @IntDef(prefix = { "HDMI_CEC_VERSION_" }, value = { HDMI_CEC_VERSION_1_4_B, HDMI_CEC_VERSION_2_0 }) @@ -373,23 +377,26 @@ public final class HdmiControlManager { * * @hide */ + @SystemApi public static final String POWER_CONTROL_MODE_TV = "to_tv"; /** * Broadcast CEC power control messages to all devices in the network. * * @hide */ + @SystemApi public static final String POWER_CONTROL_MODE_BROADCAST = "broadcast"; /** * Don't send any CEC power control messages. * * @hide */ + @SystemApi public static final String POWER_CONTROL_MODE_NONE = "none"; /** * @hide */ - @StringDef({ + @StringDef(prefix = { "POWER_CONTROL_MODE_" }, value = { POWER_CONTROL_MODE_TV, POWER_CONTROL_MODE_BROADCAST, POWER_CONTROL_MODE_NONE @@ -403,17 +410,19 @@ public final class HdmiControlManager { * * @hide */ + @SystemApi public static final String POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST_NONE = "none"; /** * Go to standby immediately. * * @hide */ + @SystemApi public static final String POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST_STANDBY_NOW = "standby_now"; /** * @hide */ - @StringDef({ + @StringDef(prefix = { "POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST_" }, value = { POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST_NONE, POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST_STANDBY_NOW }) @@ -426,17 +435,19 @@ public final class HdmiControlManager { * * @hide */ + @SystemApi public static final int SYSTEM_AUDIO_MODE_MUTING_ENABLED = 1; /** * System Audio Mode muting disabled. * * @hide */ + @SystemApi public static final int SYSTEM_AUDIO_MODE_MUTING_DISABLED = 0; /** * @hide */ - @IntDef({ + @IntDef(prefix = { "SYSTEM_AUDIO_MODE_MUTING_" }, value = { SYSTEM_AUDIO_MODE_MUTING_ENABLED, SYSTEM_AUDIO_MODE_MUTING_DISABLED }) @@ -449,24 +460,28 @@ public final class HdmiControlManager { * * @hide */ + @SystemApi public static final String CEC_SETTING_NAME_HDMI_CEC_ENABLED = "hdmi_cec_enabled"; /** * Name of a setting controlling the version of HDMI-CEC used. * * @hide */ + @SystemApi public static final String CEC_SETTING_NAME_HDMI_CEC_VERSION = "hdmi_cec_version"; /** * Name of a setting deciding on the power control mode. * * @hide */ + @SystemApi public static final String CEC_SETTING_NAME_POWER_CONTROL_MODE = "send_standby_on_sleep"; /** * Name of a setting deciding on power state action when losing Active Source. * * @hide */ + @SystemApi public static final String CEC_SETTING_NAME_POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST = "power_state_change_on_active_source_lost"; /** @@ -474,12 +489,13 @@ public final class HdmiControlManager { * * @hide */ + @SystemApi public static final String CEC_SETTING_NAME_SYSTEM_AUDIO_MODE_MUTING = "system_audio_mode_muting"; /** * @hide */ - @StringDef({ + @StringDef(prefix = { "CEC_SETTING_NAME_" }, value = { CEC_SETTING_NAME_HDMI_CEC_ENABLED, CEC_SETTING_NAME_HDMI_CEC_VERSION, CEC_SETTING_NAME_POWER_CONTROL_MODE, @@ -1363,6 +1379,7 @@ public final class HdmiControlManager { * * @hide */ + @SystemApi @NonNull @CecSettingName @RequiresPermission(android.Manifest.permission.HDMI_CEC) @@ -1389,6 +1406,7 @@ public final class HdmiControlManager { * * @hide */ + @SystemApi @NonNull @RequiresPermission(android.Manifest.permission.HDMI_CEC) public List getAllowedCecSettingStringValues(@NonNull @CecSettingName String name) { @@ -1414,6 +1432,7 @@ public final class HdmiControlManager { * * @hide */ + @SystemApi @NonNull @RequiresPermission(android.Manifest.permission.HDMI_CEC) public List getAllowedCecSettingIntValues(@NonNull @CecSettingName String name) { @@ -1430,14 +1449,13 @@ public final class HdmiControlManager { } /** - * Set the 'hdmi_cec_enabled' option. + * Set the global status of HDMI CEC. * - * @param value the desired value - * @throws IllegalArgumentException when the new value is not allowed. - * @throws RuntimeException when the HdmiControlService is not available. + *

This allows to enable/disable HDMI CEC on the device. * * @hide */ + @SystemApi @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void setHdmiCecEnabled(@NonNull @HdmiCecControl int value) { if (mService == null) { @@ -1452,13 +1470,13 @@ public final class HdmiControlManager { } /** - * Get the value of 'hdmi_cec_enabled' option. + * Get the current global status of HDMI CEC. * - * @return the current value. - * @throws RuntimeException when the HdmiControlService is not available. + *

Reflects whether HDMI CEC is currently enabled on the device. * * @hide */ + @SystemApi @NonNull @HdmiCecControl @RequiresPermission(android.Manifest.permission.HDMI_CEC) @@ -1475,14 +1493,13 @@ public final class HdmiControlManager { } /** - * Set the 'hdmi_cec_version' option. + * Set the version of the HDMI CEC specification currently used. * - * @param value the desired value - * @throws IllegalArgumentException when the new value is not allowed. - * @throws RuntimeException when the HdmiControlService is not available. + *

Allows to select either CEC 1.4b or 2.0 to be used by the device. * * @hide */ + @SystemApi @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void setHdmiCecVersion(@NonNull @HdmiCecVersion int value) { if (mService == null) { @@ -1497,13 +1514,13 @@ public final class HdmiControlManager { } /** - * Get the value of 'hdmi_cec_enabled' option. + * Get the version of the HDMI CEC specification currently used. * - * @return the current value. - * @throws RuntimeException when the HdmiControlService is not available. + *

Reflects which CEC version 1.4b or 2.0 is currently used by the device. * * @hide */ + @SystemApi @NonNull @HdmiCecVersion @RequiresPermission(android.Manifest.permission.HDMI_CEC) @@ -1520,14 +1537,14 @@ public final class HdmiControlManager { } /** - * Set the 'power_control_mode' option. + * Set the status of Power Control. * - * @param value the desired value - * @throws IllegalArgumentException when the new value is not allowed. - * @throws RuntimeException when the HdmiControlService is not available. + *

Specifies to which devices Power Control messages should be sent: + * only to the TV, broadcast to all devices, no power control messages. * * @hide */ + @SystemApi @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void setPowerControlMode(@NonNull @PowerControlMode String value) { if (mService == null) { @@ -1542,13 +1559,14 @@ public final class HdmiControlManager { } /** - * Get the value of 'power_control_mode' option. + * Get the status of Power Control. * - * @return the current value. - * @throws RuntimeException when the HdmiControlService is not available. + *

Reflects to which devices Power Control messages should be sent: + * only to the TV, broadcast to all devices, no power control messages. * * @hide */ + @SystemApi @NonNull @PowerControlMode @RequiresPermission(android.Manifest.permission.HDMI_CEC) @@ -1565,14 +1583,13 @@ public final class HdmiControlManager { } /** - * Set the 'power_state_change_on_active_source_lost' option. + * Set the current power state behaviour when Active Source is lost. * - * @param value the desired value - * @throws IllegalArgumentException when the new value is not allowed - * @throws RuntimeException when the HdmiControlService is not available. + *

Sets the action taken: do nothing or go to sleep immediately. * * @hide */ + @SystemApi @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void setPowerStateChangeOnActiveSourceLost( @NonNull @ActiveSourceLostBehavior String value) { @@ -1589,13 +1606,13 @@ public final class HdmiControlManager { } /** - * Get the value of 'power_state_change_on_active_source_lost' option. + * Get the current power state behaviour when Active Source is lost. * - * @return the current value. - * @throws RuntimeException when the HdmiControlService is not available. + *

Reflects the action taken: do nothing or go to sleep immediately. * * @hide */ + @SystemApi @NonNull @ActiveSourceLostBehavior @RequiresPermission(android.Manifest.permission.HDMI_CEC) @@ -1613,14 +1630,13 @@ public final class HdmiControlManager { } /** - * Set the 'system_audio_mode_muting' option. + * Set the current status of System Audio Mode muting. * - * @param value the desired value - * @throws IllegalArgumentException when the new value is not allowed. - * @throws RuntimeException when the HdmiControlService is not available. + *

Sets whether the device should be muted when System Audio Mode is turned off. * * @hide */ + @SystemApi @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void setSystemAudioModeMuting(@NonNull @SystemAudioModeMuting int value) { if (mService == null) { @@ -1635,13 +1651,13 @@ public final class HdmiControlManager { } /** - * Get the value of 'system_audio_mode_muting' option. + * Get the current status of System Audio Mode muting. * - * @return the current value. - * @throws RuntimeException when the HdmiControlService is not available. + *

Reflects whether the device should be muted when System Audio Mode is turned off. * * @hide */ + @SystemApi @NonNull @SystemAudioModeMuting @RequiresPermission(android.Manifest.permission.HDMI_CEC)