Double gBn/sConstructorMap
The new getBn/sConstructorMap() functions ensure that the
map is initialized before usage. For ABI compatibility (to prebuilt
HAL definition libs), the old global map is kept and checked as well.
Test: boots
Bug: 69122224
Change-Id: I32b1a612f8e841d1e7dca5335230a3dc7d589da5
diff --git a/transport/include/hidl/Static.h b/transport/include/hidl/Static.h
index 63b06fe..0522e44 100644
--- a/transport/include/hidl/Static.h
+++ b/transport/include/hidl/Static.h
@@ -40,18 +40,22 @@
extern ConcurrentMap<const ::android::hidl::base::V1_0::IBase*, wp<::android::hardware::BHwBinder>>
gBnMap;
+using BnConstructorMap = ConcurrentMap<std::string, std::function<sp<IBinder>(void*)>>;
// 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;
+// deprecated; use getBnConstructorMap instead.
+extern BnConstructorMap gBnConstructorMap;
+BnConstructorMap& getBnConstructorMap();
+using BsConstructorMap = ConcurrentMap<std::string,
+ std::function<sp<::android::hidl::base::V1_0::IBase>(void*)>>;
// 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;
-
+// deprecated; use getBsConstructorMap instead.
+extern BsConstructorMap gBsConstructorMap;
+BsConstructorMap& getBsConstructorMap();
} // namespace details
} // namespace hardware
} // namespace android