Revert "Remove gBn/sConstructorMap."
This reverts commit c67f65df9a9832094df79c4f02dffa25ca2bb2b1.
Reason for revert: Break internal targets
Bug: 69122224
Bug: 70720496
Change-Id: I6373330871b504999653b4c0bad6bdd7111c25be
diff --git a/transport/HidlPassthroughSupport.cpp b/transport/HidlPassthroughSupport.cpp
index 18ef1c0..b79d21c 100644
--- a/transport/HidlPassthroughSupport.cpp
+++ b/transport/HidlPassthroughSupport.cpp
@@ -37,7 +37,10 @@
}
auto func = getBsConstructorMap().get(myDescriptor, nullptr);
if (!func) {
- return nullptr;
+ func = gBsConstructorMap.get(myDescriptor, nullptr);
+ if (!func) {
+ return nullptr;
+ }
}
sp<IBase> base = func(static_cast<void*>(iface.get()));
diff --git a/transport/Static.cpp b/transport/Static.cpp
index aa1ac42..cbe6add 100644
--- a/transport/Static.cpp
+++ b/transport/Static.cpp
@@ -29,11 +29,17 @@
Mutex gDefaultServiceManagerLock;
sp<android::hidl::manager::V1_0::IServiceManager> gDefaultServiceManager;
+// Deprecated; kept for ABI compatibility. Use getBnConstructorMap.
+BnConstructorMap gBnConstructorMap{};
+
ConcurrentMap<const ::android::hidl::base::V1_0::IBase*, wp<::android::hardware::BHwBinder>>
gBnMap{};
ConcurrentMap<wp<::android::hidl::base::V1_0::IBase>, SchedPrio> gServicePrioMap{};
+// Deprecated; kept for ABI compatibility. Use getBsConstructorMap.
+BsConstructorMap gBsConstructorMap{};
+
// For static executables, it is not guaranteed that gBnConstructorMap are initialized before
// used in HAL definition libraries.
BnConstructorMap& getBnConstructorMap() {
diff --git a/transport/include/hidl/HidlBinderSupport.h b/transport/include/hidl/HidlBinderSupport.h
index 55003cc..9759af1 100644
--- a/transport/include/hidl/HidlBinderSupport.h
+++ b/transport/include/hidl/HidlBinderSupport.h
@@ -332,7 +332,10 @@
if (sBnObj == nullptr) {
auto func = details::getBnConstructorMap().get(myDescriptor, nullptr);
if (!func) {
- return nullptr;
+ func = details::gBnConstructorMap.get(myDescriptor, nullptr);
+ if (!func) {
+ return nullptr;
+ }
}
sBnObj = sp<IBinder>(func(static_cast<void*>(ifacePtr)));
diff --git a/transport/include/hidl/Static.h b/transport/include/hidl/Static.h
index 9d9a14a..0522e44 100644
--- a/transport/include/hidl/Static.h
+++ b/transport/include/hidl/Static.h
@@ -44,6 +44,8 @@
// For HidlBinderSupport and autogenerated code
// value function receives reinterpret_cast<void *>(static_cast<IFoo *>(foo)),
// returns sp<IBinder>
+// deprecated; use getBnConstructorMap instead.
+extern BnConstructorMap gBnConstructorMap;
BnConstructorMap& getBnConstructorMap();
using BsConstructorMap = ConcurrentMap<std::string,
@@ -51,6 +53,8 @@
// For HidlPassthroughSupport and autogenerated code
// value function receives reinterpret_cast<void *>(static_cast<IFoo *>(foo)),
// returns sp<IBase>
+// deprecated; use getBsConstructorMap instead.
+extern BsConstructorMap gBsConstructorMap;
BsConstructorMap& getBsConstructorMap();
} // namespace details
} // namespace hardware