Effect AIDL: remove the shared_lib dependency for example binary
They will be dlopen so no need to add the shared_lib dependency.
But we need to add them as PRODUCT_PACKAGES in base_vendor.mk
Bug: 258124419
Test: build and boot cuttlefish, change effect lib path in Android.bp
and audio_effects_config.xml and bootup.
Change-Id: Ia3b9bef9b5ed86921d80adcc0ce2296f50939370
diff --git a/audio/aidl/default/EffectConfig.cpp b/audio/aidl/default/EffectConfig.cpp
index e1427ec..c030b7a 100644
--- a/audio/aidl/default/EffectConfig.cpp
+++ b/audio/aidl/default/EffectConfig.cpp
@@ -79,14 +79,30 @@
return children;
}
+bool EffectConfig::resolveLibrary(const std::string& path, std::string* resolvedPath) {
+ for (auto* libraryDirectory : kEffectLibPath) {
+ std::string candidatePath = std::string(libraryDirectory) + '/' + path;
+ if (access(candidatePath.c_str(), R_OK) == 0) {
+ *resolvedPath = std::move(candidatePath);
+ return true;
+ }
+ }
+ return false;
+}
+
bool EffectConfig::parseLibrary(const tinyxml2::XMLElement& xml) {
const char* name = xml.Attribute("name");
RETURN_VALUE_IF(!name, false, "noNameAttribute");
const char* path = xml.Attribute("path");
RETURN_VALUE_IF(!path, false, "noPathAttribute");
- mLibraryMap[name] = path;
- LOG(DEBUG) << __func__ << " " << name << " : " << path;
+ std::string resolvedPath;
+ if (!resolveLibrary(path, &resolvedPath)) {
+ LOG(ERROR) << __func__ << " can't find " << path;
+ return false;
+ }
+ mLibraryMap[name] = resolvedPath;
+ LOG(DEBUG) << __func__ << " " << name << " : " << resolvedPath;
return true;
}