diff options
5 files changed, 53 insertions, 2 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index ef117eaaecc6..4448a4f43cc5 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -9361,6 +9361,15 @@ public final class Settings { "hdmi_system_audio_control_enabled"; /** + * Whether HDMI Routing Control feature is enabled. 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 + */ + public static final String HDMI_CEC_SWITCH_ENABLED = + "hdmi_cec_switch_enabled"; + + /** * Whether TV will automatically turn on upon reception of the CEC command * <Text View On> or <Image View On>. (0 = false, 1 = true) * diff --git a/core/tests/coretests/src/android/provider/SettingsBackupTest.java b/core/tests/coretests/src/android/provider/SettingsBackupTest.java index 1ed5ce4a3929..341f345ce11f 100644 --- a/core/tests/coretests/src/android/provider/SettingsBackupTest.java +++ b/core/tests/coretests/src/android/provider/SettingsBackupTest.java @@ -270,6 +270,7 @@ public class SettingsBackupTest { Settings.Global.GNSS_HAL_LOCATION_REQUEST_DURATION_MILLIS, Settings.Global.GNSS_SATELLITE_BLACKLIST, Settings.Global.GPRS_REGISTER_CHECK_PERIOD_MS, + Settings.Global.HDMI_CEC_SWITCH_ENABLED, Settings.Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED, Settings.Global.HDMI_CONTROL_AUTO_WAKEUP_ENABLED, Settings.Global.HDMI_CONTROL_ENABLED, diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystem.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystem.java index 630b28963743..cd0653f164e9 100644 --- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystem.java +++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystem.java @@ -31,6 +31,7 @@ import android.media.AudioManager; import android.media.AudioSystem; import android.media.tv.TvContract; import android.os.SystemProperties; +import android.provider.Settings.Global; import android.util.Slog; import android.util.SparseArray; @@ -92,6 +93,8 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDeviceSource { // TODO(amyjojo) make System Audio Control controllable by users /*mSystemAudioControlFeatureEnabled = mService.readBooleanSetting(Global.HDMI_SYSTEM_AUDIO_CONTROL_ENABLED, true);*/ + mRoutingControlFeatureEnabled = + mService.readBooleanSetting(Global.HDMI_CEC_SWITCH_ENABLED, true); // TODO(amyjojo): make the map ro property. mTvInputs.put(Constants.CEC_SWITCH_HDMI1, "com.droidlogic.tvinput/.services.Hdmi1InputService/HW5"); @@ -782,6 +785,14 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDeviceSource { } @ServiceThreadOnly + void setRoutingControlFeatureEnables(boolean enabled) { + assertRunOnServiceThread(); + synchronized (mLock) { + mRoutingControlFeatureEnabled = enabled; + } + } + + @ServiceThreadOnly void doManualPortSwitching(int portId, IHdmiControlCallback callback) { assertRunOnServiceThread(); // TODO: validate port ID @@ -916,6 +927,10 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDeviceSource { } protected void routeToInputFromPortId(int portId) { + if (!isRoutingControlFeatureEnabled()) { + HdmiLogger.debug("Routing Control Feature is not enabled."); + return; + } if (mArcIntentUsed) { routeToTvInputFromPortId(portId); } else { diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceSource.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceSource.java index a95f7f1f3f3d..cbddaf53348a 100644 --- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceSource.java +++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceSource.java @@ -66,6 +66,10 @@ abstract class HdmiCecLocalDeviceSource extends HdmiCecLocalDevice { @LocalActivePort protected int mLocalActivePort = Constants.CEC_SWITCH_HOME; + // Whether the Routing Coutrol feature is enabled or not. True by default. + @GuardedBy("mLock") + protected boolean mRoutingControlFeatureEnabled; + protected HdmiCecLocalDeviceSource(HdmiControlService service, int deviceType) { super(service, deviceType); } @@ -123,7 +127,9 @@ abstract class HdmiCecLocalDeviceSource extends HdmiCecLocalDevice { } setIsActiveSource(physicalAddress == mService.getPhysicalAddress()); updateDevicePowerStatus(logicalAddress, HdmiControlManager.POWER_STATUS_ON); - switchInputOnReceivingNewActivePath(physicalAddress); + if (isRoutingControlFeatureEnabled()) { + switchInputOnReceivingNewActivePath(physicalAddress); + } return true; } @@ -153,6 +159,10 @@ abstract class HdmiCecLocalDeviceSource extends HdmiCecLocalDevice { @ServiceThreadOnly protected boolean handleRoutingChange(HdmiCecMessage message) { assertRunOnServiceThread(); + if (!isRoutingControlFeatureEnabled()) { + mService.maySendFeatureAbortCommand(message, Constants.ABORT_REFUSED); + return true; + } int newPath = HdmiUtils.twoBytesToInt(message.getParams(), 2); // if the current device is a pure playback device if (!mIsSwitchDevice @@ -168,6 +178,10 @@ abstract class HdmiCecLocalDeviceSource extends HdmiCecLocalDevice { @ServiceThreadOnly protected boolean handleRoutingInformation(HdmiCecMessage message) { assertRunOnServiceThread(); + if (!isRoutingControlFeatureEnabled()) { + mService.maySendFeatureAbortCommand(message, Constants.ABORT_REFUSED); + return true; + } int physicalAddress = HdmiUtils.twoBytesToInt(message.getParams()); // if the current device is a pure playback device if (!mIsSwitchDevice @@ -279,6 +293,12 @@ abstract class HdmiCecLocalDeviceSource extends HdmiCecLocalDevice { } } + boolean isRoutingControlFeatureEnabled() { + synchronized (mLock) { + return mRoutingControlFeatureEnabled; + } + } + // Check if the device is trying to switch to the same input that is active right now. // This can help avoid redundant port switching. protected boolean isSwitchingToTheSameInput(@LocalActivePort int activePort) { diff --git a/services/core/java/com/android/server/hdmi/HdmiControlService.java b/services/core/java/com/android/server/hdmi/HdmiControlService.java index 9f1f213ce393..fcfb0664ea95 100644 --- a/services/core/java/com/android/server/hdmi/HdmiControlService.java +++ b/services/core/java/com/android/server/hdmi/HdmiControlService.java @@ -568,7 +568,8 @@ public class HdmiControlService extends SystemService { Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED, Global.HDMI_SYSTEM_AUDIO_CONTROL_ENABLED, Global.MHL_INPUT_SWITCHING_ENABLED, - Global.MHL_POWER_CHARGE_ENABLED + Global.MHL_POWER_CHARGE_ENABLED, + Global.HDMI_CEC_SWITCH_ENABLED }; for (String s : settings) { resolver.registerContentObserver(Global.getUriFor(s), false, mSettingsObserver, @@ -610,6 +611,11 @@ public class HdmiControlService extends SystemService { tv().setSystemAudioControlFeatureEnabled(enabled); } break; + case Global.HDMI_CEC_SWITCH_ENABLED: + if (isAudioSystemDevice()) { + audioSystem().setRoutingControlFeatureEnables(enabled); + } + break; case Global.MHL_INPUT_SWITCHING_ENABLED: setMhlInputChangeEnabled(enabled); break; |