libnativeloader: clean-up hard-coded public libs
art, nn, i18n apexes provide some of libs listed in
public.libraries.txt. The list of these apexes are now read from
/linkerconfig/apex.libraries.config.txt generated by
/system/bin/linkerconfig.
Bug: 150767721
Test: cuttlefish boots
Test: atest libnativeloader_test
Change-Id: Ic603b42669dff89d5d3da2f6822312e827eddd86
diff --git a/libnativeloader/library_namespaces.cpp b/libnativeloader/library_namespaces.cpp
index 3ef50e3..47050ca 100644
--- a/libnativeloader/library_namespaces.cpp
+++ b/libnativeloader/library_namespaces.cpp
@@ -50,9 +50,6 @@
constexpr const char* kVendorNamespaceName = "sphal";
constexpr const char* kVndkNamespaceName = "vndk";
constexpr const char* kVndkProductNamespaceName = "vndk_product";
-constexpr const char* kArtNamespaceName = "com_android_art";
-constexpr const char* kI18nNamespaceName = "com_android_i18n";
-constexpr const char* kNeuralNetworksNamespaceName = "com_android_neuralnetworks";
constexpr const char* kStatsdNamespaceName = "com_android_os_statsd";
// classloader-namespace is a linker namespace that is created for the loaded
@@ -314,31 +311,14 @@
return linked.error();
}
- auto art_ns = NativeLoaderNamespace::GetExportedNamespace(kArtNamespaceName, is_bridged);
- // ART APEX does not exist on host, and under certain build conditions.
- if (art_ns.ok()) {
- linked = app_ns->Link(*art_ns, art_public_libraries());
- if (!linked.ok()) {
- return linked.error();
- }
- }
-
- auto i18n_ns = NativeLoaderNamespace::GetExportedNamespace(kI18nNamespaceName, is_bridged);
- // i18n APEX does not exist on host, and under certain build conditions.
- if (i18n_ns.ok()) {
- linked = app_ns->Link(*i18n_ns, i18n_public_libraries());
- if (!linked.ok()) {
- return linked.error();
- }
- }
-
- // Give access to NNAPI libraries (apex-updated LLNDK library).
- auto nnapi_ns =
- NativeLoaderNamespace::GetExportedNamespace(kNeuralNetworksNamespaceName, is_bridged);
- if (nnapi_ns.ok()) {
- linked = app_ns->Link(*nnapi_ns, neuralnetworks_public_libraries());
- if (!linked.ok()) {
- return linked.error();
+ for (const auto&[apex_ns_name, public_libs] : apex_public_libraries()) {
+ auto ns = NativeLoaderNamespace::GetExportedNamespace(apex_ns_name, is_bridged);
+ // Even if APEX namespace is visible, it may not be available to bridged.
+ if (ns.ok()) {
+ linked = app_ns->Link(*ns, public_libs);
+ if (!linked.ok()) {
+ return linked.error();
+ }
}
}
@@ -370,8 +350,8 @@
if (jni_libs != "") {
auto apex_ns = NativeLoaderNamespace::GetExportedNamespace(*apex_ns_name, is_bridged);
if (apex_ns.ok()) {
- auto link = app_ns->Link(*apex_ns, jni_libs);
- if (!link.ok()) {
+ linked = app_ns->Link(*apex_ns, jni_libs);
+ if (!linked.ok()) {
return linked.error();
}
}