RESTRICT AUTOMERGE: libnativeloader_test: Skip reading VNDK libs for vendor if not available

(Using Merged-In with an ID of a recent ART CL to avoid merging into master.)

Bug: 235217081
Test: atest libnativeloader_test
Change-Id: I8e6965189e9df3ba20ff3ddc22f74f0e23e7a1ee
Merged-In: I1400a701a622f9f35b3ce0781575134faca679ae
diff --git a/libnativeloader/native_loader_test.cpp b/libnativeloader/native_loader_test.cpp
index b1a7e35..2fc2b4e 100644
--- a/libnativeloader/native_loader_test.cpp
+++ b/libnativeloader/native_loader_test.cpp
@@ -344,7 +344,7 @@
   expected_permitted_path = expected_permitted_path + ":/vendor/" LIB_DIR;
   expected_shared_libs_to_platform_ns =
       default_public_libraries() + ":" + llndk_libraries_vendor();
-  expected_link_with_vndk_ns = true;
+  expected_link_with_vndk_ns = !get_vndk_version(/*is_product_vndk=*/false).empty();
   SetExpectations();
   RunTest();
 }
diff --git a/libnativeloader/public_libraries.cpp b/libnativeloader/public_libraries.cpp
index ffebe0b..433a909 100644
--- a/libnativeloader/public_libraries.cpp
+++ b/libnativeloader/public_libraries.cpp
@@ -212,6 +212,9 @@
 }
 
 static std::string InitLlndkLibrariesVendor() {
+  if (get_vndk_version(/*is_product_vndk=*/false).empty()) {
+    return "";
+  }
   std::string config_file = kLlndkLibrariesFile;
   InsertVndkVersionStr(&config_file, false);
   auto sonames = ReadConfig(config_file, always_true);
@@ -237,6 +240,9 @@
 }
 
 static std::string InitVndkspLibrariesVendor() {
+  if (get_vndk_version(/*is_product_vndk=*/false).empty()) {
+    return "";
+  }
   std::string config_file = kVndkLibrariesFile;
   InsertVndkVersionStr(&config_file, false);
   auto sonames = ReadConfig(config_file, always_true);