Revert "delete gBn/sConstructorMap"
* We stil need it for legacy blobs
This reverts commit e29b2ad2157639fd466644154cde7673b052fa8d.
Change-Id: If689959309410d7062f8dc58234c802c2674b420
diff --git a/transport/HidlBinderSupport.cpp b/transport/HidlBinderSupport.cpp
index 8b36f1f..b48b460 100644
--- a/transport/HidlBinderSupport.cpp
+++ b/transport/HidlBinderSupport.cpp
@@ -254,8 +254,12 @@
if (sBnObj == nullptr) {
auto func = details::getBnConstructorMap().get(descriptor, nullptr);
- LOG_ALWAYS_FATAL_IF(func == nullptr, "%s getBnConstructorMap returned null for %s",
- __func__, descriptor.c_str());
+ if (!func) {
+ // TODO(b/69122224): remove this static variable when prebuilts updated
+ func = details::gBnConstructorMap->get(descriptor, nullptr);
+ }
+ LOG_ALWAYS_FATAL_IF(func == nullptr, "%s gBnConstructorMap returned null for %s", __func__,
+ descriptor.c_str());
sBnObj = sp<IBinder>(func(static_cast<void*>(ifacePtr)));
LOG_ALWAYS_FATAL_IF(sBnObj == nullptr, "%s Bn constructor function returned null for %s",
diff --git a/transport/HidlPassthroughSupport.cpp b/transport/HidlPassthroughSupport.cpp
index e059b4d..6f30b7b 100644
--- a/transport/HidlPassthroughSupport.cpp
+++ b/transport/HidlPassthroughSupport.cpp
@@ -29,6 +29,10 @@
static sp<IBase> tryWrap(const std::string& descriptor, sp<IBase> iface) {
auto func = getBsConstructorMap().get(descriptor, nullptr);
+ if (!func) {
+ // TODO(b/69122224): remove this when prebuilts don't reference it
+ func = gBsConstructorMap->get(descriptor, nullptr);
+ }
if (func) {
return func(static_cast<void*>(iface.get()));
}
diff --git a/transport/InternalStatic.h b/transport/InternalStatic.h
index a0d1c2d..666b2b6 100644
--- a/transport/InternalStatic.h
+++ b/transport/InternalStatic.h
@@ -28,6 +28,13 @@
namespace details {
// TODO(b/69122224): remove this once no prebuilts reference it
+// deprecated; use getBnConstructorMap instead.
+extern DoNotDestruct<BnConstructorMap> gBnConstructorMap;
+// TODO(b/69122224): remove this once no prebuilts reference it
+// deprecated; use getBsConstructorMap instead.
+extern DoNotDestruct<BsConstructorMap> gBsConstructorMap;
+
+// TODO(b/69122224): remove this once no prebuilts reference it
extern DoNotDestruct<ConcurrentMap<wp<::android::hidl::base::V1_0::IBase>, SchedPrio>>
gServicePrioMap;
// TODO(b/69122224): remove this once no prebuilts reference it
diff --git a/transport/Static.cpp b/transport/Static.cpp
index fe7c0f0..240d196 100644
--- a/transport/Static.cpp
+++ b/transport/Static.cpp
@@ -27,6 +27,9 @@
namespace hardware {
namespace details {
+// Deprecated; kept for ABI compatibility. Use getBnConstructorMap.
+DoNotDestruct<BnConstructorMap> gBnConstructorMap{};
+
DoNotDestruct<ConcurrentMap<const ::android::hidl::base::V1_0::IBase*,
wp<::android::hardware::BHwBinder>>>
gBnMap{};
@@ -35,6 +38,11 @@
DoNotDestruct<ConcurrentMap<wp<::android::hidl::base::V1_0::IBase>, SchedPrio>> gServicePrioMap{};
DoNotDestruct<ConcurrentMap<wp<::android::hidl::base::V1_0::IBase>, bool>> gServiceSidMap{};
+// Deprecated; kept for ABI compatibility. Use getBsConstructorMap.
+DoNotDestruct<BsConstructorMap> gBsConstructorMap{};
+
+// For static executables, it is not guaranteed that gBnConstructorMap are initialized before
+// used in HAL definition libraries.
BnConstructorMap& getBnConstructorMap() {
static BnConstructorMap& map = *new BnConstructorMap();
return map;