ld.config for com.android.neuralnetworks APEX.

Makes updated libneuralnetworks.so in /apex/com.android.neuralnetworks/{LIB}
loadable from all relevant namespaces.

Test: Verified that right library is being loaded using lsof and
Test: verbose debug logs from bionic/ld.
Bug: 137320025
Change-Id: I38140bb9915a3f85f10456e15ed0f492dbdba802
diff --git a/libnativeloader/library_namespaces.cpp b/libnativeloader/library_namespaces.cpp
index f7f972f..c22ce8a 100644
--- a/libnativeloader/library_namespaces.cpp
+++ b/libnativeloader/library_namespaces.cpp
@@ -43,6 +43,7 @@
 constexpr const char* kVendorNamespaceName = "sphal";
 constexpr const char* kVndkNamespaceName = "vndk";
 constexpr const char* kRuntimeNamespaceName = "runtime";
+constexpr const char* kNeuralNetworksNamespaceName = "neuralnetworks";
 
 // classloader-namespace is a linker namespace that is created for the loaded
 // app. To be specific, it is created for the app classloader. When
@@ -238,6 +239,14 @@
     }
   }
 
+  // Give access to NNAPI libraries (apex-updated LLNDK library).
+  auto nnapi_ns =
+      NativeLoaderNamespace::GetExportedNamespace(kNeuralNetworksNamespaceName, is_bridged);
+  if (!app_ns.Link(nnapi_ns, neuralnetworks_public_libraries())) {
+    *error_msg = app_ns.GetError();
+    return nullptr;
+  }
+
   // Give access to VNDK-SP libraries from the 'vndk' namespace.
   if (unbundled_vendor_or_product_app && !vndksp_libraries().empty()) {
     auto vndk_ns = NativeLoaderNamespace::GetExportedNamespace(kVndkNamespaceName, is_bridged);