mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:50:18 +00:00
audio: Use allow list for device connection types in TryConnectMissingDevice am: 7b9b9e03e5
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/3038652 Change-Id: I304b1d7bb2d42151aa24d9c16387e4f2bfc14711 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -1740,6 +1740,11 @@ TEST_P(AudioCoreModule, SetAudioPortConfigInvalidPortConfigId) {
|
||||
}
|
||||
|
||||
TEST_P(AudioCoreModule, TryConnectMissingDevice) {
|
||||
// Limit checks to connection types that are known to be detectable by HAL implementations.
|
||||
static const std::set<std::string> kCheckedConnectionTypes{
|
||||
AudioDeviceDescription::CONNECTION_HDMI, AudioDeviceDescription::CONNECTION_HDMI_ARC,
|
||||
AudioDeviceDescription::CONNECTION_HDMI_EARC, AudioDeviceDescription::CONNECTION_IP_V4,
|
||||
AudioDeviceDescription::CONNECTION_USB};
|
||||
ASSERT_NO_FATAL_FAILURE(SetUpModuleConfig());
|
||||
std::vector<AudioPort> ports = moduleConfig->getExternalDevicePorts();
|
||||
if (ports.empty()) {
|
||||
@@ -1748,14 +1753,10 @@ TEST_P(AudioCoreModule, TryConnectMissingDevice) {
|
||||
WithDebugFlags doNotSimulateConnections = WithDebugFlags::createNested(*debug);
|
||||
doNotSimulateConnections.flags().simulateDeviceConnections = false;
|
||||
ASSERT_NO_FATAL_FAILURE(doNotSimulateConnections.SetUp(module.get()));
|
||||
bool hasAtLeastOneCheckedConnection = false;
|
||||
for (const auto& port : ports) {
|
||||
// Virtual devices may not require external hardware and thus can always be connected.
|
||||
if (port.ext.get<AudioPortExt::device>().device.type.connection ==
|
||||
AudioDeviceDescription::CONNECTION_VIRTUAL ||
|
||||
// SCO devices are handled at low level by DSP, may not be able to check actual
|
||||
// connection.
|
||||
port.ext.get<AudioPortExt::device>().device.type.connection ==
|
||||
AudioDeviceDescription::CONNECTION_BT_SCO) {
|
||||
if (kCheckedConnectionTypes.count(
|
||||
port.ext.get<AudioPortExt::device>().device.type.connection) == 0) {
|
||||
continue;
|
||||
}
|
||||
AudioPort portWithData = GenerateUniqueDeviceAddress(port), connectedPort;
|
||||
@@ -1768,6 +1769,10 @@ TEST_P(AudioCoreModule, TryConnectMissingDevice) {
|
||||
EXPECT_IS_OK(module->disconnectExternalDevice(connectedPort.id))
|
||||
<< "when disconnecting device port ID " << connectedPort.id;
|
||||
}
|
||||
hasAtLeastOneCheckedConnection = true;
|
||||
}
|
||||
if (!hasAtLeastOneCheckedConnection) {
|
||||
GTEST_SKIP() << "No external devices with connection types that can be checked.";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user