Modify on hotPlug logic for Audio devices
ag/5259084
The onHotPlug logic applied to only TV and pure playback device before.
Modify it to apply to Audio/Playback device with TvInput.
Test: local tested
Bug: 117291910
Change-Id: I1f885ab44f77fc6c4a80c8d04f30477b76d81ea6
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystem.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystem.java
index 59387e4..88e85fc 100644
--- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystem.java
+++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystem.java
@@ -23,6 +23,7 @@
import android.content.Intent;
import android.hardware.hdmi.HdmiControlManager;
import android.hardware.hdmi.HdmiDeviceInfo;
+import android.hardware.hdmi.HdmiPortInfo;
import android.hardware.hdmi.IHdmiControlCallback;
import android.media.AudioDeviceInfo;
import android.media.AudioManager;
@@ -181,6 +182,24 @@
@Override
@ServiceThreadOnly
+ void onHotplug(int portId, boolean connected) {
+ assertRunOnServiceThread();
+ if (connected) {
+ mService.wakeUp();
+ }
+ if (mService.getPortInfo(portId).getType() == HdmiPortInfo.PORT_OUTPUT) {
+ mCecMessageCache.flushAll();
+ } else {
+ if (connected) {
+ // TODO(amyjojo): start the device discovery action
+ } else {
+ // TODO(amyjojo): remove device from mDeviceInfo
+ }
+ }
+ }
+
+ @Override
+ @ServiceThreadOnly
protected void onStandby(boolean initiatedByCec, int standbyAction) {
assertRunOnServiceThread();
mTvSystemAudioModeSupport = false;
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceSource.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceSource.java
index 8e4671c..75a9297 100644
--- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceSource.java
+++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceSource.java
@@ -19,6 +19,7 @@
import static com.android.internal.os.RoSystemProperties.PROPERTY_HDMI_IS_DEVICE_HDMI_CEC_SWITCH;
import android.hardware.hdmi.HdmiControlManager;
+import android.hardware.hdmi.HdmiPortInfo;
import android.hardware.hdmi.IHdmiControlCallback;
import android.os.SystemProperties;
import android.util.Slog;
@@ -73,7 +74,9 @@
@ServiceThreadOnly
void onHotplug(int portId, boolean connected) {
assertRunOnServiceThread();
- mCecMessageCache.flushAll();
+ if (mService.getPortInfo(portId).getType() == HdmiPortInfo.PORT_OUTPUT) {
+ mCecMessageCache.flushAll();
+ }
// We'll not clear mIsActiveSource on the hotplug event to pass CETC 11.2.2-2 ~ 3.
if (connected) {
mService.wakeUp();
diff --git a/services/core/java/com/android/server/hdmi/HdmiControlService.java b/services/core/java/com/android/server/hdmi/HdmiControlService.java
index 373c4d7..65f3466 100644
--- a/services/core/java/com/android/server/hdmi/HdmiControlService.java
+++ b/services/core/java/com/android/server/hdmi/HdmiControlService.java
@@ -1008,8 +1008,9 @@
void onHotplug(int portId, boolean connected) {
assertRunOnServiceThread();
- if (connected && !isTvDevice()) {
- if (getPortInfo(portId).getType() == HdmiPortInfo.PORT_OUTPUT && isSwitchDevice()) {
+ if (connected && !isTvDevice()
+ && getPortInfo(portId).getType() == HdmiPortInfo.PORT_OUTPUT) {
+ if (isSwitchDevice()) {
initPortInfo();
HdmiLogger.debug("initPortInfo for switch device when onHotplug from tx.");
}