Cleanup Hidl*Support.* files.
* Move gBnConstructorMap to Static.cpp/h
* update obsolete comments
Test: compiles
Change-Id: If9720b8fc3b09e9b91b8fdc04bcde269208471ed
diff --git a/transport/HidlBinderSupport.cpp b/transport/HidlBinderSupport.cpp
index f3e99e1..38e0640 100644
--- a/transport/HidlBinderSupport.cpp
+++ b/transport/HidlBinderSupport.cpp
@@ -25,8 +25,6 @@
namespace android {
namespace hardware {
-std::map<std::string, std::function<sp<IBinder>(void*)>> gBnConstructorMap{};
-
const size_t hidl_memory::kOffsetOfHandle = offsetof(hidl_memory, mHandle);
const size_t hidl_memory::kOffsetOfName = offsetof(hidl_memory, mName);
diff --git a/transport/Static.cpp b/transport/Static.cpp
index 3bd0285..ddda712 100644
--- a/transport/Static.cpp
+++ b/transport/Static.cpp
@@ -25,5 +25,7 @@
Mutex gDefaultServiceManagerLock;
sp<android::hidl::manager::V1_0::IServiceManager> gDefaultServiceManager;
+std::map<std::string, std::function<sp<IBinder>(void*)>> gBnConstructorMap{};
+
} // namespace hardware
} // namespace android
diff --git a/transport/include/hidl/HidlBinderSupport.h b/transport/include/hidl/HidlBinderSupport.h
index 1851870..a596917 100644
--- a/transport/include/hidl/HidlBinderSupport.h
+++ b/transport/include/hidl/HidlBinderSupport.h
@@ -19,6 +19,7 @@
#include <hidl/HidlSupport.h>
#include <hidl/MQDescriptor.h>
+#include <hidl/Static.h>
#include <hwbinder/IBinder.h>
#include <hwbinder/Parcel.h>
@@ -280,8 +281,6 @@
// ---------------------- support for casting interfaces
-extern std::map<std::string, std::function<sp<IBinder>(void*)>> gBnConstructorMap;
-
// Construct a smallest possible binder from the given interface.
// If it is remote, then its remote() will be retrieved.
// Otherwise, the smallest possible BnChild is found where IChild is a subclass of IType
@@ -303,7 +302,7 @@
}
});
if (myDescriptor.empty()) {
- // interfaceChain fails || types.size() == 0
+ // interfaceChain fails
return nullptr;
}
auto iter = gBnConstructorMap.find(myDescriptor);
diff --git a/transport/include/hidl/HidlTransportSupport.h b/transport/include/hidl/HidlTransportSupport.h
index f8cae2e..1d22cb7 100644
--- a/transport/include/hidl/HidlTransportSupport.h
+++ b/transport/include/hidl/HidlTransportSupport.h
@@ -17,8 +17,8 @@
#ifndef ANDROID_HIDL_TRANSPORT_SUPPORT_H
#define ANDROID_HIDL_TRANSPORT_SUPPORT_H
-#include <hidl/HidlSupport.h>
#include <hidl/HidlBinderSupport.h>
+#include <hidl/HidlSupport.h>
namespace android {
namespace hardware {
diff --git a/transport/include/hidl/Static.h b/transport/include/hidl/Static.h
index 00db8a7..2a40125 100644
--- a/transport/include/hidl/Static.h
+++ b/transport/include/hidl/Static.h
@@ -17,8 +17,10 @@
// All static variables go here, to control initialization and
// destruction order in the library.
-#include <utils/threads.h>
+#include <android/hidl/base/1.0/IBase.h>
#include <android/hidl/manager/1.0/IServiceManager.h>
+#include <hwbinder/IBinder.h>
+#include <utils/threads.h>
namespace android {
namespace hardware {
@@ -27,5 +29,10 @@
extern Mutex gDefaultServiceManagerLock;
extern sp<android::hidl::manager::V1_0::IServiceManager> gDefaultServiceManager;
+// For HidlBinderSupport
+// value function receives reinterpret_cast<void *>(static_cast<IFoo *>(foo)),
+// returns sp<IBinder>
+extern std::map<std::string, std::function<sp<IBinder>(void*)>> gBnConstructorMap;
+
} // namespace hardware
} // namespace android