create gBsConstructorMap; add wrapPassthrough

Similar to gBnConstructorMap, this map helps wrapping a local
interface with the smallest BsFoo possible. They are added
in Static.h/cpp.

Added HidlPassthroughSupport.h/cpp to hold wrapPassthrough.

Also fixes a few Return object isOk() checks.

Fix: 33307350

Test: hidl_test

Change-Id: I92a7283699bfe5b022df5ab5a9ead5690477ea97
diff --git a/transport/HidlPassthroughSupport.cpp b/transport/HidlPassthroughSupport.cpp
new file mode 100644
index 0000000..9d4e2b4
--- /dev/null
+++ b/transport/HidlPassthroughSupport.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <hidl/HidlPassthroughSupport.h>
+
+#include <hidl/HidlSupport.h>
+#include <hidl/Static.h>
+#include <hidl/HidlTransportUtils.h>
+
+namespace android {
+namespace hardware {
+
+sp<::android::hidl::base::V1_0::IBase> wrapPassthrough(
+        sp<::android::hidl::base::V1_0::IBase> iface) {
+    if (iface.get() == nullptr || iface->isRemote()) {
+        // doesn't know how to handle it.
+        return iface;
+    }
+    std::string myDescriptor = getDescriptor(iface.get());
+    if (myDescriptor.empty()) {
+        // interfaceChain fails
+        return nullptr;
+    }
+    auto iter = gBsConstructorMap.find(myDescriptor);
+    if (iter == gBsConstructorMap.end()) {
+        return nullptr;
+    }
+    return (iter->second)(reinterpret_cast<void *>(iface.get()));
+}
+
+
+}  // namespace hardware
+}  // namespace android