Merge "[CEC Configuration] Add 'set_menu_language' setting"

This commit is contained in:
TreeHugger Robot
2022-02-02 14:39:16 +00:00
committed by Android (Google) Code Review
7 changed files with 77 additions and 4 deletions

View File

@@ -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.
@@ -817,6 +843,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.
*
@@ -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,

View File

@@ -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>

View File

@@ -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" />

View File

@@ -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:

View File

@@ -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;
}

View File

@@ -164,6 +164,17 @@ final class FakeHdmiCecConfig extends HdmiCecConfig {
doReturn(false).when(resources).getBoolean(
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(

View File

@@ -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,