Move g(Bn|Bs)ConstructorMap's into cpp.

These were originally used to store IFoo::descriptor ->
constructor maps for HIDL code in order to create the
appropriate objects when receiving a binder in HIDL,
but due to static linking of these libraries in recovery
mode, they were moved into functions which create the
static variables and return them (getBnConstructorMap
and getBsConstructorMap). However, old prebuilts still
reference these old variables. In order to remove them,
prebuilt rebuilds need to not reference them, so here,
I have removed all references to them in headers.

Bug: 69122224
Bug: 69408124 # in preparation for this bug
Test: boot Pixel 2, hidl_test
Change-Id: I681d4895f7784bc080e01f4fae2be318ba8d6c0f
diff --git a/transport/include/hidl/HidlBinderSupport.h b/transport/include/hidl/HidlBinderSupport.h
index 1545946..6d45f39 100644
--- a/transport/include/hidl/HidlBinderSupport.h
+++ b/transport/include/hidl/HidlBinderSupport.h
@@ -301,6 +301,10 @@
 
 // ---------------------- support for casting interfaces
 
+// Constructs a binder for this interface and caches it. If it has already been created
+// then it returns it. ifacePtr must be a local object.
+sp<IBinder> getOrCreateCachedBinder(::android::hidl::base::V1_0::IBase* ifacePtr);
+
 // 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
@@ -317,35 +321,7 @@
         return ::android::hardware::IInterface::asBinder(
             static_cast<BpInterface<IType>*>(ifacePtr));
     } else {
-        std::string myDescriptor = details::getDescriptor(ifacePtr);
-        if (myDescriptor.empty()) {
-            // interfaceDescriptor fails
-            return nullptr;
-        }
-
-        // for get + set
-        std::unique_lock<std::mutex> _lock = details::gBnMap.lock();
-
-        wp<BHwBinder> wBnObj = details::gBnMap.getLocked(ifacePtr, nullptr);
-        sp<IBinder> sBnObj = wBnObj.promote();
-
-        if (sBnObj == nullptr) {
-            auto func = details::getBnConstructorMap().get(myDescriptor, nullptr);
-            if (!func) {
-                func = details::gBnConstructorMap.get(myDescriptor, nullptr);
-                if (!func) {
-                    return nullptr;
-                }
-            }
-
-            sBnObj = sp<IBinder>(func(static_cast<void*>(ifacePtr)));
-
-            if (sBnObj != nullptr) {
-                details::gBnMap.setLocked(ifacePtr, static_cast<BHwBinder*>(sBnObj.get()));
-            }
-        }
-
-        return sBnObj;
+        return getOrCreateCachedBinder(ifacePtr);
     }
 }
 
diff --git a/transport/include/hidl/Static.h b/transport/include/hidl/Static.h
index 6ff6a9f..b50c173 100644
--- a/transport/include/hidl/Static.h
+++ b/transport/include/hidl/Static.h
@@ -47,8 +47,6 @@
 // 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,
@@ -56,8 +54,6 @@
 // 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