summaryrefslogtreecommitdiff
path: root/libnativeloader/library_namespaces.cpp
diff options
context:
space:
mode:
authorJooyung Han <jooyung@google.com>2020-09-01 14:53:23 +0900
committerJooyung Han <jooyung@google.com>2020-09-08 23:07:32 +0000
commitcd616d0fa2f11ced7f979d60cc686c86c7e74d9a (patch)
treea5a930782fbaf542d66bc9eccf9d59a241cf0ca2 /libnativeloader/library_namespaces.cpp
parentd78be00e7bc1daf0a1db07ba3944a2924bba8e26 (diff)
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
Diffstat (limited to 'libnativeloader/library_namespaces.cpp')
-rw-r--r--libnativeloader/library_namespaces.cpp40
1 files changed, 10 insertions, 30 deletions
diff --git a/libnativeloader/library_namespaces.cpp b/libnativeloader/library_namespaces.cpp
index 3ef50e3abf..47050cad80 100644
--- a/libnativeloader/library_namespaces.cpp
+++ b/libnativeloader/library_namespaces.cpp
@@ -50,9 +50,6 @@ constexpr const char* kApexPath = "/apex/";
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 @@ Result<NativeLoaderNamespace*> LibraryNamespaces::Create(JNIEnv* env, uint32_t t
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 @@ Result<NativeLoaderNamespace*> LibraryNamespaces::Create(JNIEnv* env, uint32_t t
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();
}
}