public libs from APEXes are pre-loadable

This change fixes a bug that public libs from APEXes are never
pre-loaded. This was happening because those libs are removed by
InitDefaultPublicLibraries which was originaly designed for listing up
the libs that needs to be provided to the app namespace from the default
namespace. Since the libs from APEXes are not available from the default
namespace, but from their own namespaces (e.g."runtime", etc.), the
removal was fine. But the problem happend when the same function is
parameterized (with bool for_preload) and used to get the libs for
preloading.

This change fixes the problem by not removing the libs from APEXes when
the function is called with for_preload == true.

Bug: 141847343
Test: m
Change-Id: I9edf2f94bac473ac7d0651514a2dabe976f81058
diff --git a/libnativeloader/public_libraries.cpp b/libnativeloader/public_libraries.cpp
index 93df1d0..010e8cc 100644
--- a/libnativeloader/public_libraries.cpp
+++ b/libnativeloader/public_libraries.cpp
@@ -176,6 +176,11 @@
     std::copy(vec.begin(), vec.end(), std::back_inserter(*sonames));
   }
 
+  // If this is for preloading libs, don't remove the libs from APEXes.
+  if (for_preload) {
+    return android::base::Join(*sonames, ':');
+  }
+
   // Remove the public libs in the runtime namespace.
   // These libs are listed in public.android.txt, but we don't want the rest of android
   // in default namespace to dlopen the libs.