From 7b9b9e03e5c82e95b017222089b3915817095cef Mon Sep 17 00:00:00 2001 From: Mikhail Naganov Date: Wed, 10 Apr 2024 14:22:13 -0700 Subject: [PATCH] audio: Use allow list for device connection types in TryConnectMissingDevice Limit the connection types to test to the following: - HDMI* - IP_V4 - USB Only these connection types can be easily checked by the HAL for presence of an external device. Bug: 326888643 Test: atest VtsHalAudioCoreTargetTest Change-Id: I659e14a150b3043ead8d844cd89a2c4700d57efd --- .../vts/VtsHalAudioCoreModuleTargetTest.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp b/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp index 4a7bfbde2b..8b08945e89 100644 --- a/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp +++ b/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp @@ -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 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 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().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().device.type.connection == - AudioDeviceDescription::CONNECTION_BT_SCO) { + if (kCheckedConnectionTypes.count( + port.ext.get().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."; } }