Loading core/java/android/provider/Settings.java +6 −4 Original line number Diff line number Diff line Loading @@ -7668,12 +7668,14 @@ public final class Settings { public static final String HDMI_CONTROL_ENABLED = "hdmi_control_enabled"; /** * Whether HDMI system audio is enabled. If enabled, TV internal speaker is muted, * and the output is redirected to AV Receiver connected via * {@Global#HDMI_SYSTEM_AUDIO_OUTPUT}. * Whether HDMI System Audio Control feature is enabled. If enabled, TV will try to turn on * system audio mode if there's a connected CEC-enabled AV Receiver. Then audio stream will * be played on AVR instead of TV spaeker. If disabled, the system audio mode will never be * activated. * @hide */ public static final String HDMI_SYSTEM_AUDIO_ENABLED = "hdmi_system_audio_enabled"; public static final String HDMI_SYSTEM_AUDIO_CONTROL_ENABLED = "hdmi_system_audio_control_enabled"; /** * Whether TV will automatically turn on upon reception of the CEC command Loading core/proto/android/providers/settings.proto +1 −1 Original line number Diff line number Diff line Loading @@ -97,7 +97,7 @@ message GlobalSettingsProto { SettingProto download_max_bytes_over_mobile = 52; SettingProto download_recommended_max_bytes_over_mobile = 53; SettingProto hdmi_control_enabled = 54; SettingProto hdmi_system_audio_enabled = 55; SettingProto hdmi_system_audio_control_enabled = 55; SettingProto hdmi_control_auto_wakeup_enabled = 56; SettingProto hdmi_control_auto_device_off_enabled = 57; SettingProto mhl_input_switching_enabled = 58; Loading core/tests/coretests/src/android/provider/SettingsBackupTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -198,7 +198,7 @@ public class SettingsBackupTest { Settings.Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED, Settings.Global.HDMI_CONTROL_AUTO_WAKEUP_ENABLED, Settings.Global.HDMI_CONTROL_ENABLED, Settings.Global.HDMI_SYSTEM_AUDIO_ENABLED, Settings.Global.HDMI_SYSTEM_AUDIO_CONTROL_ENABLED, Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED, Settings.Global.HTTP_PROXY, Settings.Global.INET_CONDITION_DEBOUNCE_DOWN_DELAY, Loading packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java +2 −2 Original line number Diff line number Diff line Loading @@ -240,8 +240,8 @@ class SettingsProtoDumpUtil { Settings.Global.HDMI_CONTROL_ENABLED, GlobalSettingsProto.HDMI_CONTROL_ENABLED); dumpSetting(s, p, Settings.Global.HDMI_SYSTEM_AUDIO_ENABLED, GlobalSettingsProto.HDMI_SYSTEM_AUDIO_ENABLED); Settings.Global.HDMI_SYSTEM_AUDIO_CONTROL_ENABLED, GlobalSettingsProto.HDMI_SYSTEM_AUDIO_CONTROL_ENABLED); dumpSetting(s, p, Settings.Global.HDMI_CONTROL_AUTO_WAKEUP_ENABLED, GlobalSettingsProto.HDMI_CONTROL_AUTO_WAKEUP_ENABLED); Loading services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java +41 −16 Original line number Diff line number Diff line Loading @@ -72,7 +72,8 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { @ServiceThreadOnly private boolean mArcEstablished = false; // Stores whether ARC feature is enabled per port. True by default for all the ARC-enabled ports. // Stores whether ARC feature is enabled per port. // True by default for all the ARC-enabled ports. private final SparseBooleanArray mArcFeatureEnabled = new SparseBooleanArray(); // Whether System audio mode is activated or not. Loading @@ -80,6 +81,10 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { @GuardedBy("mLock") private boolean mSystemAudioActivated = false; // Whether the System Audio Control feature is enabled or not. True by default. @GuardedBy("mLock") private boolean mSystemAudioControlFeatureEnabled; // The previous port id (input) before switching to the new one. This is remembered in order to // be able to switch to it upon receiving <Inactive Source> from currently active source. // This remains valid only when the active source was switched via one touch play operation Loading Loading @@ -186,6 +191,8 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { mAutoDeviceOff = mService.readBooleanSetting(Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED, true); mAutoWakeup = mService.readBooleanSetting(Global.HDMI_CONTROL_AUTO_WAKEUP_ENABLED, true); mSystemAudioControlFeatureEnabled = mService.readBooleanSetting(Global.HDMI_SYSTEM_AUDIO_CONTROL_ENABLED, true); mStandbyHandler = new HdmiCecStandbyModeHandler(service, this); } Loading Loading @@ -778,14 +785,11 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { addAndStartAction(new HotplugDetectionAction(HdmiCecLocalDeviceTv.this)); addAndStartAction(new PowerStatusMonitorAction(HdmiCecLocalDeviceTv.this)); // If there is AVR, initiate System Audio Auto initiation action, // which turns on and off system audio according to last system // audio setting. HdmiDeviceInfo avr = getAvrDeviceInfo(); if (avr != null) { onNewAvrAdded(avr); } else { setSystemAudioMode(false, true); setSystemAudioMode(false); } } }); Loading Loading @@ -818,13 +822,13 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { void changeSystemAudioMode(boolean enabled, IHdmiControlCallback callback) { assertRunOnServiceThread(); if (!mService.isControlEnabled() || hasAction(DeviceDiscoveryAction.class)) { setSystemAudioMode(false, true); setSystemAudioMode(false); invokeCallback(callback, HdmiControlManager.RESULT_INCORRECT_MODE); return; } HdmiDeviceInfo avr = getAvrDeviceInfo(); if (avr == null) { setSystemAudioMode(false, true); setSystemAudioMode(false); invokeCallback(callback, HdmiControlManager.RESULT_TARGET_NOT_AVAILABLE); return; } Loading @@ -834,12 +838,13 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { } // # Seq 25 void setSystemAudioMode(boolean on, boolean updateSetting) { HdmiLogger.debug("System Audio Mode change[old:%b new:%b]", mSystemAudioActivated, on); if (updateSetting) { mService.writeBooleanSetting(Global.HDMI_SYSTEM_AUDIO_ENABLED, on); void setSystemAudioMode(boolean on) { if (!isSystemAudioControlFeatureEnabled() && on) { HdmiLogger.debug("Cannot turn on system audio mode " + "because the System Audio Control feature is disabled."); return; } HdmiLogger.debug("System Audio Mode change[old:%b new:%b]", mSystemAudioActivated, on); updateAudioManagerForSystemAudio(on); synchronized (mLock) { if (mSystemAudioActivated != on) { Loading @@ -863,8 +868,21 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { } } boolean getSystemAudioModeSetting() { return mService.readBooleanSetting(Global.HDMI_SYSTEM_AUDIO_ENABLED, false); @ServiceThreadOnly void setSystemAudioControlFeatureEnabled(boolean enabled) { assertRunOnServiceThread(); synchronized (mLock) { mSystemAudioControlFeatureEnabled = enabled; } if (hasSystemAudioDevice()) { changeSystemAudioMode(enabled, null); } } boolean isSystemAudioControlFeatureEnabled() { synchronized (mLock) { return mSystemAudioControlFeatureEnabled; } } /** Loading Loading @@ -1112,6 +1130,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { @ServiceThreadOnly protected boolean handleSetSystemAudioMode(HdmiCecMessage message) { assertRunOnServiceThread(); boolean systemAudioStatus = HdmiUtils.parseCommandParamSystemAudioStatus(message); if (!isMessageForSystemAudio(message)) { if (getAvrDeviceInfo() == null) { // AVR may not have been discovered yet. Delay the message processing. Loading @@ -1121,10 +1140,15 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { mService.maySendFeatureAbortCommand(message, Constants.ABORT_REFUSED); } return true; } else if (systemAudioStatus && !isSystemAudioControlFeatureEnabled()) { HdmiLogger.debug("Ignoring <Set System Audio Mode> message " + "because the System Audio Control feature is disabled: %s", message); mService.maySendFeatureAbortCommand(message, Constants.ABORT_REFUSED); return true; } removeAction(SystemAudioAutoInitiationAction.class); SystemAudioActionFromAvr action = new SystemAudioActionFromAvr(this, message.getSource(), HdmiUtils.parseCommandParamSystemAudioStatus(message), null); message.getSource(), systemAudioStatus, null); addAndStartAction(action); return true; } Loading @@ -1138,7 +1162,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { // Ignore this message. return true; } setSystemAudioMode(HdmiUtils.parseCommandParamSystemAudioStatus(message), true); setSystemAudioMode(HdmiUtils.parseCommandParamSystemAudioStatus(message)); return true; } Loading Loading @@ -1882,6 +1906,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { pw.println("mArcFeatureEnabled: " + mArcFeatureEnabled); pw.println("mSystemAudioActivated: " + mSystemAudioActivated); pw.println("mSystemAudioMute: " + mSystemAudioMute); pw.println("mSystemAudioControlFeatureEnabled: " + mSystemAudioControlFeatureEnabled); pw.println("mAutoDeviceOff: " + mAutoDeviceOff); pw.println("mAutoWakeup: " + mAutoWakeup); pw.println("mSkipRoutingControl: " + mSkipRoutingControl); Loading Loading
core/java/android/provider/Settings.java +6 −4 Original line number Diff line number Diff line Loading @@ -7668,12 +7668,14 @@ public final class Settings { public static final String HDMI_CONTROL_ENABLED = "hdmi_control_enabled"; /** * Whether HDMI system audio is enabled. If enabled, TV internal speaker is muted, * and the output is redirected to AV Receiver connected via * {@Global#HDMI_SYSTEM_AUDIO_OUTPUT}. * Whether HDMI System Audio Control feature is enabled. If enabled, TV will try to turn on * system audio mode if there's a connected CEC-enabled AV Receiver. Then audio stream will * be played on AVR instead of TV spaeker. If disabled, the system audio mode will never be * activated. * @hide */ public static final String HDMI_SYSTEM_AUDIO_ENABLED = "hdmi_system_audio_enabled"; public static final String HDMI_SYSTEM_AUDIO_CONTROL_ENABLED = "hdmi_system_audio_control_enabled"; /** * Whether TV will automatically turn on upon reception of the CEC command Loading
core/proto/android/providers/settings.proto +1 −1 Original line number Diff line number Diff line Loading @@ -97,7 +97,7 @@ message GlobalSettingsProto { SettingProto download_max_bytes_over_mobile = 52; SettingProto download_recommended_max_bytes_over_mobile = 53; SettingProto hdmi_control_enabled = 54; SettingProto hdmi_system_audio_enabled = 55; SettingProto hdmi_system_audio_control_enabled = 55; SettingProto hdmi_control_auto_wakeup_enabled = 56; SettingProto hdmi_control_auto_device_off_enabled = 57; SettingProto mhl_input_switching_enabled = 58; Loading
core/tests/coretests/src/android/provider/SettingsBackupTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -198,7 +198,7 @@ public class SettingsBackupTest { Settings.Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED, Settings.Global.HDMI_CONTROL_AUTO_WAKEUP_ENABLED, Settings.Global.HDMI_CONTROL_ENABLED, Settings.Global.HDMI_SYSTEM_AUDIO_ENABLED, Settings.Global.HDMI_SYSTEM_AUDIO_CONTROL_ENABLED, Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED, Settings.Global.HTTP_PROXY, Settings.Global.INET_CONDITION_DEBOUNCE_DOWN_DELAY, Loading
packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java +2 −2 Original line number Diff line number Diff line Loading @@ -240,8 +240,8 @@ class SettingsProtoDumpUtil { Settings.Global.HDMI_CONTROL_ENABLED, GlobalSettingsProto.HDMI_CONTROL_ENABLED); dumpSetting(s, p, Settings.Global.HDMI_SYSTEM_AUDIO_ENABLED, GlobalSettingsProto.HDMI_SYSTEM_AUDIO_ENABLED); Settings.Global.HDMI_SYSTEM_AUDIO_CONTROL_ENABLED, GlobalSettingsProto.HDMI_SYSTEM_AUDIO_CONTROL_ENABLED); dumpSetting(s, p, Settings.Global.HDMI_CONTROL_AUTO_WAKEUP_ENABLED, GlobalSettingsProto.HDMI_CONTROL_AUTO_WAKEUP_ENABLED); Loading
services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java +41 −16 Original line number Diff line number Diff line Loading @@ -72,7 +72,8 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { @ServiceThreadOnly private boolean mArcEstablished = false; // Stores whether ARC feature is enabled per port. True by default for all the ARC-enabled ports. // Stores whether ARC feature is enabled per port. // True by default for all the ARC-enabled ports. private final SparseBooleanArray mArcFeatureEnabled = new SparseBooleanArray(); // Whether System audio mode is activated or not. Loading @@ -80,6 +81,10 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { @GuardedBy("mLock") private boolean mSystemAudioActivated = false; // Whether the System Audio Control feature is enabled or not. True by default. @GuardedBy("mLock") private boolean mSystemAudioControlFeatureEnabled; // The previous port id (input) before switching to the new one. This is remembered in order to // be able to switch to it upon receiving <Inactive Source> from currently active source. // This remains valid only when the active source was switched via one touch play operation Loading Loading @@ -186,6 +191,8 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { mAutoDeviceOff = mService.readBooleanSetting(Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED, true); mAutoWakeup = mService.readBooleanSetting(Global.HDMI_CONTROL_AUTO_WAKEUP_ENABLED, true); mSystemAudioControlFeatureEnabled = mService.readBooleanSetting(Global.HDMI_SYSTEM_AUDIO_CONTROL_ENABLED, true); mStandbyHandler = new HdmiCecStandbyModeHandler(service, this); } Loading Loading @@ -778,14 +785,11 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { addAndStartAction(new HotplugDetectionAction(HdmiCecLocalDeviceTv.this)); addAndStartAction(new PowerStatusMonitorAction(HdmiCecLocalDeviceTv.this)); // If there is AVR, initiate System Audio Auto initiation action, // which turns on and off system audio according to last system // audio setting. HdmiDeviceInfo avr = getAvrDeviceInfo(); if (avr != null) { onNewAvrAdded(avr); } else { setSystemAudioMode(false, true); setSystemAudioMode(false); } } }); Loading Loading @@ -818,13 +822,13 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { void changeSystemAudioMode(boolean enabled, IHdmiControlCallback callback) { assertRunOnServiceThread(); if (!mService.isControlEnabled() || hasAction(DeviceDiscoveryAction.class)) { setSystemAudioMode(false, true); setSystemAudioMode(false); invokeCallback(callback, HdmiControlManager.RESULT_INCORRECT_MODE); return; } HdmiDeviceInfo avr = getAvrDeviceInfo(); if (avr == null) { setSystemAudioMode(false, true); setSystemAudioMode(false); invokeCallback(callback, HdmiControlManager.RESULT_TARGET_NOT_AVAILABLE); return; } Loading @@ -834,12 +838,13 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { } // # Seq 25 void setSystemAudioMode(boolean on, boolean updateSetting) { HdmiLogger.debug("System Audio Mode change[old:%b new:%b]", mSystemAudioActivated, on); if (updateSetting) { mService.writeBooleanSetting(Global.HDMI_SYSTEM_AUDIO_ENABLED, on); void setSystemAudioMode(boolean on) { if (!isSystemAudioControlFeatureEnabled() && on) { HdmiLogger.debug("Cannot turn on system audio mode " + "because the System Audio Control feature is disabled."); return; } HdmiLogger.debug("System Audio Mode change[old:%b new:%b]", mSystemAudioActivated, on); updateAudioManagerForSystemAudio(on); synchronized (mLock) { if (mSystemAudioActivated != on) { Loading @@ -863,8 +868,21 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { } } boolean getSystemAudioModeSetting() { return mService.readBooleanSetting(Global.HDMI_SYSTEM_AUDIO_ENABLED, false); @ServiceThreadOnly void setSystemAudioControlFeatureEnabled(boolean enabled) { assertRunOnServiceThread(); synchronized (mLock) { mSystemAudioControlFeatureEnabled = enabled; } if (hasSystemAudioDevice()) { changeSystemAudioMode(enabled, null); } } boolean isSystemAudioControlFeatureEnabled() { synchronized (mLock) { return mSystemAudioControlFeatureEnabled; } } /** Loading Loading @@ -1112,6 +1130,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { @ServiceThreadOnly protected boolean handleSetSystemAudioMode(HdmiCecMessage message) { assertRunOnServiceThread(); boolean systemAudioStatus = HdmiUtils.parseCommandParamSystemAudioStatus(message); if (!isMessageForSystemAudio(message)) { if (getAvrDeviceInfo() == null) { // AVR may not have been discovered yet. Delay the message processing. Loading @@ -1121,10 +1140,15 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { mService.maySendFeatureAbortCommand(message, Constants.ABORT_REFUSED); } return true; } else if (systemAudioStatus && !isSystemAudioControlFeatureEnabled()) { HdmiLogger.debug("Ignoring <Set System Audio Mode> message " + "because the System Audio Control feature is disabled: %s", message); mService.maySendFeatureAbortCommand(message, Constants.ABORT_REFUSED); return true; } removeAction(SystemAudioAutoInitiationAction.class); SystemAudioActionFromAvr action = new SystemAudioActionFromAvr(this, message.getSource(), HdmiUtils.parseCommandParamSystemAudioStatus(message), null); message.getSource(), systemAudioStatus, null); addAndStartAction(action); return true; } Loading @@ -1138,7 +1162,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { // Ignore this message. return true; } setSystemAudioMode(HdmiUtils.parseCommandParamSystemAudioStatus(message), true); setSystemAudioMode(HdmiUtils.parseCommandParamSystemAudioStatus(message)); return true; } Loading Loading @@ -1882,6 +1906,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { pw.println("mArcFeatureEnabled: " + mArcFeatureEnabled); pw.println("mSystemAudioActivated: " + mSystemAudioActivated); pw.println("mSystemAudioMute: " + mSystemAudioMute); pw.println("mSystemAudioControlFeatureEnabled: " + mSystemAudioControlFeatureEnabled); pw.println("mAutoDeviceOff: " + mAutoDeviceOff); pw.println("mAutoWakeup: " + mAutoWakeup); pw.println("mSkipRoutingControl: " + mSkipRoutingControl); Loading