Merge "Update HIDL makefiles." am: 5dd8752f09 am: b8d4a6ce31
am: a68bfd01f6

Change-Id: Ie133ccc61dbfceee0183dfa4d656b01e3abec39d
diff --git a/manifest.xml b/manifest.xml
index fb1ee39..fdc9027 100644
--- a/manifest.xml
+++ b/manifest.xml
@@ -62,6 +62,15 @@
             <instance>default</instance>
         </interface>
     </hal>
+        <hal format="hidl">
+        <name>android.system.net.netd</name>
+        <transport>hwbinder</transport>
+        <version>1.0</version>
+        <interface>
+            <name>INetd</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
     <hal>
         <name>android.system.wifi.keystore</name>
         <transport>hwbinder</transport>
diff --git a/transport/Android.bp b/transport/Android.bp
index 7fc3717..2deb7cf 100644
--- a/transport/Android.bp
+++ b/transport/Android.bp
@@ -36,6 +36,7 @@
         "libhidlbase",
         "libhwbinder",
         "libcutils",
+        "libvndksupport",
     ],
     export_shared_lib_headers: [
         "libbase",
diff --git a/transport/ServiceManagement.cpp b/transport/ServiceManagement.cpp
index a404d10..44a6f31 100644
--- a/transport/ServiceManagement.cpp
+++ b/transport/ServiceManagement.cpp
@@ -36,6 +36,7 @@
 #include <android-base/properties.h>
 #include <hwbinder/IPCThreadState.h>
 #include <hwbinder/Parcel.h>
+#include <vndksupport/linker.h>
 
 #include <android/hidl/manager/1.1/IServiceManager.h>
 #include <android/hidl/manager/1.1/BpHwServiceManager.h>
@@ -45,10 +46,6 @@
 #define RE_PATH         RE_COMPONENT "(?:[.]" RE_COMPONENT ")*"
 static const std::regex gLibraryFileNamePattern("(" RE_PATH "@[0-9]+[.][0-9]+)-impl(.*?).so");
 
-extern "C" {
-    android_namespace_t* android_get_exported_namespace(const char*);
-}
-
 using android::base::WaitForProperty;
 
 using IServiceManager1_0 = android::hidl::manager::V1_0::IServiceManager;
@@ -275,7 +272,6 @@
         const std::string prefix = packageAndVersion + "-impl";
         const std::string sym = "HIDL_FETCH_" + ifaceName;
 
-        const android_namespace_t* sphal_namespace = android_get_exported_namespace("sphal");
         const int dlMode = RTLD_LAZY;
         void *handle = nullptr;
 
@@ -301,26 +297,9 @@
             for (const std::string &lib : libs) {
                 const std::string fullPath = path + lib;
 
-                // If sphal namespace is available, try to load from the
-                // namespace first. If it fails, fall back to the original
-                // dlopen, which loads from the current namespace.
-                if (sphal_namespace != nullptr && path != HAL_LIBRARY_PATH_SYSTEM) {
-                    const android_dlextinfo dlextinfo = {
-                        .flags = ANDROID_DLEXT_USE_NAMESPACE,
-                        // const_cast is dirty but required because
-                        // library_namespace field is non-const.
-                        .library_namespace = const_cast<android_namespace_t*>(sphal_namespace),
-                    };
-                    handle = android_dlopen_ext(fullPath.c_str(), dlMode, &dlextinfo);
-                    if (handle == nullptr) {
-                        const char* error = dlerror();
-                        LOG(WARNING) << "Failed to dlopen " << lib << " from sphal namespace:"
-                                     << (error == nullptr ? "unknown error" : error);
-                    } else {
-                        LOG(DEBUG) << lib << " loaded from sphal namespace.";
-                    }
-                }
-                if (handle == nullptr) {
+                if (path != HAL_LIBRARY_PATH_SYSTEM) {
+                    handle = android_load_sphal_library(fullPath.c_str(), dlMode);
+                } else {
                     handle = dlopen(fullPath.c_str(), dlMode);
                 }
 
diff --git a/transport/token/1.0/utils/Android.bp b/transport/token/1.0/utils/Android.bp
index 0360d99..ab77a2a 100644
--- a/transport/token/1.0/utils/Android.bp
+++ b/transport/token/1.0/utils/Android.bp
@@ -14,6 +14,7 @@
 
 cc_library {
     name: "android.hidl.token@1.0-utils",
+    vendor_available: true,
 
     srcs: [
         "HybridInterface.cpp",