audio: Skip stream I/O test for "echo reference" input device

This is aligned with the HIDL implementation VTS. The echo reference
device can't provide any input until certain preconditions are met,
and modeling these preconditions in the test is not trivial.

Also, add the information into the mix port into the trace scope
for easier identification on test failure.

Bug: 328010709
Test: atest VtsHalAudioCoreTargetTest
(cherry picked from https://android-review.googlesource.com/q/commit:a62c5df181b37bb7a066cbd154cb13a59a596345)
Merged-In: I737479d8ef1961791ac3bd82aeb779453d2e49f4
Change-Id: I737479d8ef1961791ac3bd82aeb779453d2e49f4
diff --git a/audio/aidl/vts/ModuleConfig.cpp b/audio/aidl/vts/ModuleConfig.cpp
index 2b86271..d24c4c8 100644
--- a/audio/aidl/vts/ModuleConfig.cpp
+++ b/audio/aidl/vts/ModuleConfig.cpp
@@ -551,6 +551,11 @@
     return result;
 }
 
+std::optional<AudioPort> ModuleConfig::getPort(int32_t portId) {
+    auto portsIt = findById(mPorts, portId);
+    return portsIt != mPorts.end() ? std::optional<AudioPort>(*portsIt) : std::nullopt;
+}
+
 ndk::ScopedAStatus ModuleConfig::onExternalDeviceConnected(IModule* module, const AudioPort& port) {
     RETURN_STATUS_IF_ERROR(module->getAudioPorts(&mPorts));
     RETURN_STATUS_IF_ERROR(module->getAudioRoutes(&mRoutes));
diff --git a/audio/aidl/vts/ModuleConfig.h b/audio/aidl/vts/ModuleConfig.h
index 4a87f8c..27286e5 100644
--- a/audio/aidl/vts/ModuleConfig.h
+++ b/audio/aidl/vts/ModuleConfig.h
@@ -166,6 +166,8 @@
         return *config.begin();
     }
 
+    std::optional<aidl::android::media::audio::common::AudioPort> getPort(int32_t portId);
+
     ndk::ScopedAStatus onExternalDeviceConnected(
             aidl::android::hardware::audio::core::IModule* module,
             const aidl::android::media::audio::common::AudioPort& port);
diff --git a/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp b/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp
index e26b81b..c677e1b 100644
--- a/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp
@@ -2980,6 +2980,11 @@
                      AudioOutputFlags::COMPRESS_OFFLOAD, AudioOutputFlags::INCALL_MUSIC}));
 }
 
+// Certain types of devices can not be used without special preconditions.
+static bool skipStreamIoTestForDevice(const AudioDevice& device) {
+    return device.type.type == AudioDeviceType::IN_ECHO_REFERENCE;
+}
+
 template <typename Stream>
 class StreamFixtureWithWorker {
   public:
@@ -3888,6 +3893,9 @@
             GTEST_SKIP() << "No mix ports have attached devices";
         }
         for (const auto& portConfig : allPortConfigs) {
+            auto port = moduleConfig->getPort(portConfig.portId);
+            ASSERT_TRUE(port.has_value());
+            SCOPED_TRACE(port->toString());
             SCOPED_TRACE(portConfig.toString());
             if (skipStreamIoTestForMixPortConfig(portConfig)) continue;
             const bool isNonBlocking =
@@ -3970,6 +3978,7 @@
         StreamFixture<Stream> stream;
         ASSERT_NO_FATAL_FAILURE(
                 stream.SetUpStreamForMixPortConfig(module.get(), moduleConfig.get(), portConfig));
+        if (skipStreamIoTestForDevice(stream.getDevice())) return;
         ASSERT_EQ("", stream.skipTestReason());
         StreamLogicDefaultDriver driver(commandsAndStates,
                                         stream.getStreamContext()->getFrameSizeBytes());
@@ -3998,6 +4007,7 @@
         StreamFixture<Stream> stream;
         ASSERT_NO_FATAL_FAILURE(
                 stream.SetUpPatchForMixPortConfig(module.get(), moduleConfig.get(), portConfig));
+        if (skipStreamIoTestForDevice(stream.getDevice())) return;
         ASSERT_EQ("", stream.skipTestReason());
         ASSERT_NO_FATAL_FAILURE(stream.TeardownPatchSetUpStream(module.get()));
         StreamLogicDefaultDriver driver(commandsAndStates,