Checks for grave getOrCreateCachedBinder problems.

toBinder failing caused b/69180318, and logs when it
fails would have made fixing the bug way easier. I've
made them fatal here since any failure indicates an
inconsistent state in the loaded libraries.

For the first (failure if entry is missing from the map),
if you are creating an object and sending it over binder,
you should have loaded the HIDL library in your process.

For the second (failure if calling the map function
doesn't return), this should only occur when an alloc in
the function fails which can also not happen in Android.

Fixes: 69408124
Test: boot Pixel 2 and ensure that 'getOrCreateCachedBinder'
    doesn't exist in the logs as expected

Change-Id: I330f3f2dfd04651457115bcb445761ef168317c7
diff --git a/transport/HidlBinderSupport.cpp b/transport/HidlBinderSupport.cpp
index 015d607..a221b46 100644
--- a/transport/HidlBinderSupport.cpp
+++ b/transport/HidlBinderSupport.cpp
@@ -199,8 +199,8 @@
 }
 
 sp<IBinder> getOrCreateCachedBinder(::android::hidl::base::V1_0::IBase* ifacePtr) {
-    LOG_ALWAYS_FATAL_IF(ifacePtr->isRemote(),
-                        "getOrCreateCachedBinder does not have a way to construct remote binders");
+    LOG_ALWAYS_FATAL_IF(ifacePtr->isRemote(), "%s does not have a way to construct remote binders",
+                        __func__);
 
     std::string descriptor = details::getDescriptor(ifacePtr);
     if (descriptor.empty()) {
@@ -219,16 +219,15 @@
         if (!func) {
             // TODO(b/69122224): remove this static variable when prebuilts updated
             func = details::gBnConstructorMap.get(descriptor, nullptr);
-            if (!func) {
-                return 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",
+                            __func__, descriptor.c_str());
 
-        if (sBnObj != nullptr) {
-            details::gBnMap.setLocked(ifacePtr, static_cast<BHwBinder*>(sBnObj.get()));
-        }
+        details::gBnMap.setLocked(ifacePtr, static_cast<BHwBinder*>(sBnObj.get()));
     }
 
     return sBnObj;