USB: Advertise as sink when audio accessory is connected
This removes the "Charging connected device via USB" notification
when an analog USB-C headset is connected, such as Type-C to
3.5mm adapters without inbuilt DAC.
Change-Id: I596f19725eb2ba089ab9764c30fc7aa98bfb9b43
diff --git a/hal/Usb.cpp b/hal/Usb.cpp
index aa8ca84..353ce8f 100644
--- a/hal/Usb.cpp
+++ b/hal/Usb.cpp
@@ -400,14 +400,16 @@
if (!connected) return Status::SUCCESS;
- if (type == PortRoleType::MODE) {
+ if (type == PortRoleType::MODE || type == PortRoleType::POWER_ROLE) {
if (getAccessoryConnected(portName, &accessory) != Status::SUCCESS) {
return Status::ERROR;
}
if (accessory == "analog_audio") {
- *currentRole = static_cast<uint32_t>(PortMode_1_1::AUDIO_ACCESSORY);
+ *currentRole = type == PortRoleType::POWER_ROLE
+ ? static_cast<uint32_t>(PortPowerRole::SINK)
+ : static_cast<uint32_t>(PortMode_1_1::AUDIO_ACCESSORY);
return Status::SUCCESS;
- } else if (accessory == "debug") {
+ } else if (accessory == "debug" && type == PortRoleType::MODE) {
*currentRole = static_cast<uint32_t>(PortMode_1_1::DEBUG_ACCESSORY);
return Status::SUCCESS;
}