audio: capEngine: Allow built-in strategies to omit the 'id' attribute

For builtin strategy, the "id" must be set from the name.
These builtin strategies must be provisionned in the structure file.
The parameters associated to these strategies will use their legacy
name (whereas vendor strategies are referred with "vx_<id>".

Bug: 390449625
Test: m

Change-Id: I63763f1e05f1ca2cdd7e3163d2e0c4e6b3979446
Signed-off-by: François Gaffie <francois.gaffie@ampere.cars>
diff --git a/audio/aidl/default/CapEngineConfigXmlConverter.cpp b/audio/aidl/default/CapEngineConfigXmlConverter.cpp
index 20fbca4..14d27f2 100644
--- a/audio/aidl/default/CapEngineConfigXmlConverter.cpp
+++ b/audio/aidl/default/CapEngineConfigXmlConverter.cpp
@@ -52,6 +52,7 @@
 static constexpr const char* gOutputDevicesParameter = "selected_output_devices";
 static constexpr const char* gOutputDeviceAddressParameter = "device_address";
 static constexpr const char* gStrategyPrefix = "vx_";
+static constexpr const char* gLegacyStrategyPrefix = "STRATEGY_";
 static constexpr const char* gLegacyOutputDevicePrefix = "AUDIO_DEVICE_OUT_";
 static constexpr const char* gLegacyInputDevicePrefix = "AUDIO_DEVICE_IN_";
 static constexpr const char* gLegacyStreamPrefix = "AUDIO_STREAM_";
@@ -159,6 +160,17 @@
             }
             return strategyId;
         }
+        pos = stringToken.find(gLegacyStrategyPrefix);
+        if (pos != std::string::npos) {
+            std::string legacyStrategyIdLiteral = stringToken.substr(pos);
+            const auto legacyStrategies = getLegacyProductStrategyMap();
+            if (const auto& it = legacyStrategies.find(legacyStrategyIdLiteral);
+                    it != legacyStrategies.end()) {
+                return it->second;
+            }
+            LOG(ERROR) << "Invalid legacy strategy " << stringToken << " from path " << path;
+            return unexpected(BAD_VALUE);
+        }
     }
     return unexpected(BAD_VALUE);
 }