Hide global variables
am: 953e6b0f57

Change-Id: I19f86ced7fa3afb8c636b0aa074c26eaaeaea578
diff --git a/transport/HidlPassthroughSupport.cpp b/transport/HidlPassthroughSupport.cpp
index 981a139..3a7f6dc 100644
--- a/transport/HidlPassthroughSupport.cpp
+++ b/transport/HidlPassthroughSupport.cpp
@@ -16,8 +16,8 @@
 #include <hidl/HidlPassthroughSupport.h>
 
 #include <hidl/HidlSupport.h>
-#include <hidl/Static.h>
 #include <hidl/HidlTransportUtils.h>
+#include <hidl/Static.h>
 
 namespace android {
 namespace hardware {
diff --git a/transport/ServiceManagement.cpp b/transport/ServiceManagement.cpp
index feef01f..d425591 100644
--- a/transport/ServiceManagement.cpp
+++ b/transport/ServiceManagement.cpp
@@ -26,7 +26,6 @@
 
 #include <hidl/HidlBinderSupport.h>
 #include <hidl/ServiceManagement.h>
-#include <hidl/Static.h>
 #include <hidl/Status.h>
 
 #include <android-base/logging.h>
@@ -51,29 +50,34 @@
 namespace android {
 namespace hardware {
 
+namespace details {
+extern Mutex gDefaultServiceManagerLock;
+extern sp<android::hidl::manager::V1_0::IServiceManager> gDefaultServiceManager;
+}  // namespace details
+
 sp<IServiceManager> defaultServiceManager() {
 
     {
-        AutoMutex _l(gDefaultServiceManagerLock);
-        if (gDefaultServiceManager != NULL) {
-            return gDefaultServiceManager;
+        AutoMutex _l(details::gDefaultServiceManagerLock);
+        if (details::gDefaultServiceManager != NULL) {
+            return details::gDefaultServiceManager;
         }
         if (access("/dev/hwbinder", F_OK|R_OK|W_OK) != 0) {
             // HwBinder not available on this device or not accessible to
             // this process.
             return nullptr;
         }
-        while (gDefaultServiceManager == NULL) {
-            gDefaultServiceManager =
+        while (details::gDefaultServiceManager == NULL) {
+            details::gDefaultServiceManager =
                     fromBinder<IServiceManager, BpHwServiceManager, BnHwServiceManager>(
                         ProcessState::self()->getContextObject(NULL));
-            if (gDefaultServiceManager == NULL) {
+            if (details::gDefaultServiceManager == NULL) {
                 sleep(1);
             }
         }
     }
 
-    return gDefaultServiceManager;
+    return details::gDefaultServiceManager;
 }
 
 std::vector<std::string> search(const std::string &path,
diff --git a/transport/Static.cpp b/transport/Static.cpp
index d5b335e..496c8f0 100644
--- a/transport/Static.cpp
+++ b/transport/Static.cpp
@@ -19,8 +19,12 @@
 
 #include <hidl/Static.h>
 
+#include <android/hidl/manager/1.0/IServiceManager.h>
+#include <utils/Mutex.h>
+
 namespace android {
 namespace hardware {
+namespace details {
 
 Mutex gDefaultServiceManagerLock;
 sp<android::hidl::manager::V1_0::IServiceManager> gDefaultServiceManager;
@@ -31,5 +35,6 @@
 ConcurrentMap<std::string, std::function<sp<::android::hidl::base::V1_0::IBase>(void *)>>
         gBsConstructorMap;
 
-}   // namespace hardware
-}   // namespace android
+}  // namespace details
+}  // namespace hardware
+}  // namespace android
diff --git a/transport/include/hidl/HidlBinderSupport.h b/transport/include/hidl/HidlBinderSupport.h
index 8b98021..86ac74c 100644
--- a/transport/include/hidl/HidlBinderSupport.h
+++ b/transport/include/hidl/HidlBinderSupport.h
@@ -328,7 +328,7 @@
             // interfaceDescriptor fails
             return nullptr;
         }
-        auto func = gBnConstructorMap.get(myDescriptor, nullptr);
+        auto func = details::gBnConstructorMap.get(myDescriptor, nullptr);
         if (!func) {
             return nullptr;
         }
diff --git a/transport/include/hidl/Static.h b/transport/include/hidl/Static.h
index 04b1729..e6c9139 100644
--- a/transport/include/hidl/Static.h
+++ b/transport/include/hidl/Static.h
@@ -17,31 +17,29 @@
 // All static variables go here, to control initialization and
 // destruction order in the library.
 
+#include <functional>
+
 #include <android/hidl/base/1.0/IBase.h>
-#include <android/hidl/manager/1.0/IServiceManager.h>
 #include <hidl/ConcurrentMap.h>
 #include <hwbinder/IBinder.h>
 #include <utils/StrongPointer.h>
-#include <utils/Mutex.h>
 
 namespace android {
 namespace hardware {
+namespace details {
 
-// For ServiceManagement.cpp
-extern Mutex gDefaultServiceManagerLock;
-extern sp<android::hidl::manager::V1_0::IServiceManager> gDefaultServiceManager;
-
-// For HidlBinderSupport
+// For HidlBinderSupport and autogenerated code
 // value function receives reinterpret_cast<void *>(static_cast<IFoo *>(foo)),
 // returns sp<IBinder>
 extern ConcurrentMap<std::string,
         std::function<sp<IBinder>(void *)>> gBnConstructorMap;
 
-// For HidlPassthroughSupport
+// For HidlPassthroughSupport and autogenerated code
 // value function receives reinterpret_cast<void *>(static_cast<IFoo *>(foo)),
 // returns sp<IBase>
 extern ConcurrentMap<std::string,
         std::function<sp<::android::hidl::base::V1_0::IBase>(void *)>> gBsConstructorMap;
 
-}   // namespace hardware
-}   // namespace android
+}  // namespace details
+}  // namespace hardware
+}  // namespace android