diff options
7 files changed, 77 insertions, 4 deletions
diff --git a/core/java/android/hardware/hdmi/HdmiControlManager.java b/core/java/android/hardware/hdmi/HdmiControlManager.java index ec55e121bf74..9235ba15019c 100644 --- a/core/java/android/hardware/hdmi/HdmiControlManager.java +++ b/core/java/android/hardware/hdmi/HdmiControlManager.java @@ -564,6 +564,32 @@ public final class HdmiControlManager { @Retention(RetentionPolicy.SOURCE) public @interface TvSendStandbyOnSleep {} + // -- Whether a playback device should act on an incoming {@code <Set Menu Language>} message. + /** + * Confirmation dialog should be shown upon receiving the CEC message. + * + * @see HdmiControlManager#CEC_SETTING_NAME_SET_MENU_LANGUAGE + * @hide + */ + public static final int SET_MENU_LANGUAGE_ENABLED = 1; + /** + * The message should be ignored. + * + * @see HdmiControlManager#CEC_SETTING_NAME_SET_MENU_LANGUAGE + * @hide + */ + public static final int SET_MENU_LANGUAGE_DISABLED = 0; + /** + * @see HdmiControlManager#CEC_SETTING_NAME_SET_MENU_LANGUAGE + * @hide + */ + @IntDef(prefix = { "SET_MENU_LANGUAGE_" }, value = { + SET_MENU_LANGUAGE_ENABLED, + SET_MENU_LANGUAGE_DISABLED + }) + @Retention(RetentionPolicy.SOURCE) + public @interface SetMenuLanguage {} + // -- The RC profile of a TV panel. /** * RC profile none. @@ -818,6 +844,13 @@ public final class HdmiControlManager { public static final String CEC_SETTING_NAME_TV_SEND_STANDBY_ON_SLEEP = "tv_send_standby_on_sleep"; /** + * Name of a setting deciding whether {@code <Set Menu Language>} message should be + * handled by the framework or ignored. + * + * @hide + */ + public static final String CEC_SETTING_NAME_SET_MENU_LANGUAGE = "set_menu_language"; + /** * Name of a setting representing the RC profile of a TV panel. * * @hide @@ -983,6 +1016,7 @@ public final class HdmiControlManager { CEC_SETTING_NAME_VOLUME_CONTROL_MODE, CEC_SETTING_NAME_TV_WAKE_ON_ONE_TOUCH_PLAY, CEC_SETTING_NAME_TV_SEND_STANDBY_ON_SLEEP, + CEC_SETTING_NAME_SET_MENU_LANGUAGE, CEC_SETTING_NAME_RC_PROFILE_TV, CEC_SETTING_NAME_RC_PROFILE_SOURCE_HANDLES_ROOT_MENU, CEC_SETTING_NAME_RC_PROFILE_SOURCE_HANDLES_SETUP_MENU, diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 354e75cd6252..902d5e0b9f32 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -5276,6 +5276,12 @@ <bool name="config_cecTvSendStandbyOnSleepDisabled_allowed">true</bool> <bool name="config_cecTvSendStandbyOnSleepDisabled_default">false</bool> + <bool name="config_cecSetMenuLanguage_userConfigurable">true</bool> + <bool name="config_cecSetMenuLanguageEnabled_allowed">true</bool> + <bool name="config_cecSetMenuLanguageEnabled_default">true</bool> + <bool name="config_cecSetMenuLanguageDisabled_allowed">true</bool> + <bool name="config_cecSetMenuLanguageDisabled_default">false</bool> + <bool name="config_cecRcProfileTv_userConfigurable">true</bool> <bool name="config_cecRcProfileTvNone_allowed">true</bool> <bool name="config_cecRcProfileTvNone_default">true</bool> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index d5ef7c49e2a6..30a196395b35 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -4466,6 +4466,12 @@ <java-symbol type="bool" name="config_cecTvSendStandbyOnSleepDisabled_allowed" /> <java-symbol type="bool" name="config_cecTvSendStandbyOnSleepDisabled_default" /> + <java-symbol type="bool" name="config_cecSetMenuLanguage_userConfigurable" /> + <java-symbol type="bool" name="config_cecSetMenuLanguageEnabled_allowed" /> + <java-symbol type="bool" name="config_cecSetMenuLanguageEnabled_default" /> + <java-symbol type="bool" name="config_cecSetMenuLanguageDisabled_allowed" /> + <java-symbol type="bool" name="config_cecSetMenuLanguageDisabled_default" /> + <java-symbol type="bool" name="config_cecRcProfileTv_userConfigurable" /> <java-symbol type="bool" name="config_cecRcProfileTvNone_allowed" /> <java-symbol type="bool" name="config_cecRcProfileTvNone_default" /> diff --git a/services/core/java/com/android/server/hdmi/HdmiCecConfig.java b/services/core/java/com/android/server/hdmi/HdmiCecConfig.java index 65ec1c07c4a1..4792821f652b 100644 --- a/services/core/java/com/android/server/hdmi/HdmiCecConfig.java +++ b/services/core/java/com/android/server/hdmi/HdmiCecConfig.java @@ -385,6 +385,16 @@ public class HdmiCecConfig { R.bool.config_cecTvSendStandbyOnSleepDisabled_allowed, R.bool.config_cecTvSendStandbyOnSleepDisabled_default); + Setting setMenuLanguage = registerSetting( + HdmiControlManager.CEC_SETTING_NAME_SET_MENU_LANGUAGE, + R.bool.config_cecSetMenuLanguage_userConfigurable); + setMenuLanguage.registerValue(HdmiControlManager.SET_MENU_LANGUAGE_ENABLED, + R.bool.config_cecSetMenuLanguageEnabled_allowed, + R.bool.config_cecSetMenuLanguageEnabled_default); + setMenuLanguage.registerValue(HdmiControlManager.SET_MENU_LANGUAGE_DISABLED, + R.bool.config_cecSetMenuLanguageDisabled_allowed, + R.bool.config_cecSetMenuLanguageDisabled_default); + Setting rcProfileTv = registerSetting( HdmiControlManager.CEC_SETTING_NAME_RC_PROFILE_TV, R.bool.config_cecRcProfileTv_userConfigurable); @@ -697,6 +707,8 @@ public class HdmiCecConfig { return STORAGE_SHARED_PREFS; case HdmiControlManager.CEC_SETTING_NAME_TV_SEND_STANDBY_ON_SLEEP: return STORAGE_SHARED_PREFS; + case HdmiControlManager.CEC_SETTING_NAME_SET_MENU_LANGUAGE: + return STORAGE_SHARED_PREFS; case HdmiControlManager.CEC_SETTING_NAME_RC_PROFILE_TV: return STORAGE_SHARED_PREFS; case HdmiControlManager.CEC_SETTING_NAME_RC_PROFILE_SOURCE_HANDLES_ROOT_MENU: @@ -768,6 +780,8 @@ public class HdmiCecConfig { return setting.getName(); case HdmiControlManager.CEC_SETTING_NAME_TV_SEND_STANDBY_ON_SLEEP: return setting.getName(); + case HdmiControlManager.CEC_SETTING_NAME_SET_MENU_LANGUAGE: + return setting.getName(); case HdmiControlManager.CEC_SETTING_NAME_RC_PROFILE_TV: return setting.getName(); case HdmiControlManager.CEC_SETTING_NAME_RC_PROFILE_SOURCE_HANDLES_ROOT_MENU: diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java index f413fbd5c9b2..0edcea548055 100644 --- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java +++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java @@ -50,9 +50,6 @@ import java.util.Locale; public class HdmiCecLocalDevicePlayback extends HdmiCecLocalDeviceSource { private static final String TAG = "HdmiCecLocalDevicePlayback"; - private static final boolean SET_MENU_LANGUAGE = - HdmiProperties.set_menu_language_enabled().orElse(false); - // How long to wait after hotplug out before possibly going to Standby. @VisibleForTesting static final long STANDBY_AFTER_HOTPLUG_OUT_DELAY_MS = 30_000; @@ -388,7 +385,9 @@ public class HdmiCecLocalDevicePlayback extends HdmiCecLocalDeviceSource { @Constants.HandleMessageResult protected int handleSetMenuLanguage(HdmiCecMessage message) { assertRunOnServiceThread(); - if (!SET_MENU_LANGUAGE) { + if (mService.getHdmiCecConfig().getIntValue( + HdmiControlManager.CEC_SETTING_NAME_SET_MENU_LANGUAGE) + == HdmiControlManager.SET_MENU_LANGUAGE_DISABLED) { return Constants.ABORT_UNRECOGNIZED_OPCODE; } diff --git a/services/tests/servicestests/src/com/android/server/hdmi/FakeHdmiCecConfig.java b/services/tests/servicestests/src/com/android/server/hdmi/FakeHdmiCecConfig.java index d441143272d9..0028969d85a0 100644 --- a/services/tests/servicestests/src/com/android/server/hdmi/FakeHdmiCecConfig.java +++ b/services/tests/servicestests/src/com/android/server/hdmi/FakeHdmiCecConfig.java @@ -165,6 +165,17 @@ final class FakeHdmiCecConfig extends HdmiCecConfig { R.bool.config_cecTvSendStandbyOnSleepDisabled_default); doReturn(true).when(resources).getBoolean( + R.bool.config_cecSetMenuLanguage_userConfigurable); + doReturn(true).when(resources).getBoolean( + R.bool.config_cecSetMenuLanguageEnabled_allowed); + doReturn(true).when(resources).getBoolean( + R.bool.config_cecSetMenuLanguageEnabled_default); + doReturn(true).when(resources).getBoolean( + R.bool.config_cecSetMenuLanguageDisabled_allowed); + doReturn(false).when(resources).getBoolean( + R.bool.config_cecSetMenuLanguageDisabled_default); + + doReturn(true).when(resources).getBoolean( R.bool.config_cecRcProfileTv_userConfigurable); doReturn(true).when(resources).getBoolean( R.bool.config_cecRcProfileTvNone_allowed); diff --git a/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecConfigTest.java b/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecConfigTest.java index 85d30a6dbc36..ae7b494fffbb 100644 --- a/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecConfigTest.java +++ b/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecConfigTest.java @@ -83,6 +83,7 @@ public final class HdmiCecConfigTest { HdmiControlManager.CEC_SETTING_NAME_VOLUME_CONTROL_MODE, HdmiControlManager.CEC_SETTING_NAME_TV_WAKE_ON_ONE_TOUCH_PLAY, HdmiControlManager.CEC_SETTING_NAME_TV_SEND_STANDBY_ON_SLEEP, + HdmiControlManager.CEC_SETTING_NAME_SET_MENU_LANGUAGE, HdmiControlManager.CEC_SETTING_NAME_RC_PROFILE_TV, HdmiControlManager.CEC_SETTING_NAME_RC_PROFILE_SOURCE_HANDLES_ROOT_MENU, HdmiControlManager.CEC_SETTING_NAME_RC_PROFILE_SOURCE_HANDLES_SETUP_MENU, @@ -121,6 +122,7 @@ public final class HdmiCecConfigTest { HdmiControlManager.CEC_SETTING_NAME_VOLUME_CONTROL_MODE, HdmiControlManager.CEC_SETTING_NAME_TV_WAKE_ON_ONE_TOUCH_PLAY, HdmiControlManager.CEC_SETTING_NAME_TV_SEND_STANDBY_ON_SLEEP, + HdmiControlManager.CEC_SETTING_NAME_SET_MENU_LANGUAGE, HdmiControlManager.CEC_SETTING_NAME_RC_PROFILE_TV, HdmiControlManager.CEC_SETTING_NAME_RC_PROFILE_SOURCE_HANDLES_ROOT_MENU, HdmiControlManager.CEC_SETTING_NAME_RC_PROFILE_SOURCE_HANDLES_SETUP_MENU, @@ -159,6 +161,7 @@ public final class HdmiCecConfigTest { HdmiControlManager.CEC_SETTING_NAME_VOLUME_CONTROL_MODE, HdmiControlManager.CEC_SETTING_NAME_TV_WAKE_ON_ONE_TOUCH_PLAY, HdmiControlManager.CEC_SETTING_NAME_TV_SEND_STANDBY_ON_SLEEP, + HdmiControlManager.CEC_SETTING_NAME_SET_MENU_LANGUAGE, HdmiControlManager.CEC_SETTING_NAME_RC_PROFILE_TV, HdmiControlManager.CEC_SETTING_NAME_RC_PROFILE_SOURCE_HANDLES_ROOT_MENU, HdmiControlManager.CEC_SETTING_NAME_RC_PROFILE_SOURCE_HANDLES_SETUP_MENU, |