Revert "Allow proxies to be compared."
This reverts commit 8264ad53b64162950b9d7d2cde93b5a961ab806b.
Change-Id: Ibbb66617c751dab7e93834892fb97936e5083e97
diff --git a/transport/Static.cpp b/transport/Static.cpp
index 784b835..18cb475 100644
--- a/transport/Static.cpp
+++ b/transport/Static.cpp
@@ -32,9 +32,6 @@
ConcurrentMap<std::string, std::function<sp<IBinder>(void *)>>
gBnConstructorMap{};
-ConcurrentMap<const ::android::hidl::base::V1_0::IBase*, wp<::android::hardware::BHwBinder>>
- gBnMap{};
-
ConcurrentMap<wp<::android::hidl::base::V1_0::IBase>, SchedPrio> gServicePrioMap{};
ConcurrentMap<std::string, std::function<sp<::android::hidl::base::V1_0::IBase>(void *)>>
diff --git a/transport/include/hidl/ConcurrentMap.h b/transport/include/hidl/ConcurrentMap.h
index cd55ad4..18881f1 100644
--- a/transport/include/hidl/ConcurrentMap.h
+++ b/transport/include/hidl/ConcurrentMap.h
@@ -50,19 +50,7 @@
return mMap.erase(k);
}
- std::unique_lock<std::mutex> lock() { return std::unique_lock<std::mutex>(mMutex); }
-
- void setLocked(K&& k, V&& v) { mMap[std::forward<K>(k)] = std::forward<V>(v); }
-
- const V& getLocked(const K& k, const V& def) const {
- const_iterator iter = mMap.find(k);
- if (iter == mMap.end()) {
- return def;
- }
- return iter->second;
- }
-
- private:
+private:
mutable std::mutex mMutex;
std::map<K, V> mMap;
};
diff --git a/transport/include/hidl/HidlBinderSupport.h b/transport/include/hidl/HidlBinderSupport.h
index 47ff581..6f82dbc 100644
--- a/transport/include/hidl/HidlBinderSupport.h
+++ b/transport/include/hidl/HidlBinderSupport.h
@@ -306,42 +306,25 @@
// Otherwise, the smallest possible BnChild is found where IChild is a subclass of IType
// and iface is of class IChild. BnChild will be used to wrapped the given iface.
// Return nullptr if iface is null or any failure.
-template <typename IType>
+template <typename IType, typename ProxyType>
sp<IBinder> toBinder(sp<IType> iface) {
IType *ifacePtr = iface.get();
if (ifacePtr == nullptr) {
return nullptr;
}
if (ifacePtr->isRemote()) {
- return ::android::hardware::IInterface::asBinder(
- static_cast<BpInterface<IType>*>(ifacePtr));
+ return ::android::hardware::IInterface::asBinder(static_cast<ProxyType *>(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::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()));
- }
+ auto func = details::gBnConstructorMap.get(myDescriptor, nullptr);
+ if (!func) {
+ return nullptr;
}
-
- return sBnObj;
+ return sp<IBinder>(func(static_cast<void *>(ifacePtr)));
}
}
diff --git a/transport/include/hidl/HidlTransportSupport.h b/transport/include/hidl/HidlTransportSupport.h
index d116598..0c174f7 100644
--- a/transport/include/hidl/HidlTransportSupport.h
+++ b/transport/include/hidl/HidlTransportSupport.h
@@ -62,15 +62,6 @@
bool setMinSchedulerPolicy(const sp<::android::hidl::base::V1_0::IBase>& service,
int policy, int priority);
-template <typename ILeft, typename IRight>
-bool interfacesEqual(sp<ILeft> left, sp<IRight> right) {
- if (left == nullptr || right == nullptr || !left->isRemote() || !right->isRemote()) {
- return left == right;
- }
-
- return toBinder<ILeft>(left) == toBinder<IRight>(right);
-}
-
namespace details {
// cast the interface IParent to IChild.
@@ -81,8 +72,8 @@
// 3. !emitError, calling into parent fails.
// Return an error Return object if:
// 1. emitError, calling into parent fails.
-template <typename IChild, typename IParent, typename BpChild>
-Return<sp<IChild>> castInterface(sp<IParent> parent, const char* childIndicator, bool emitError) {
+template<typename IChild, typename IParent, typename BpChild, typename BpParent>
+Return<sp<IChild>> castInterface(sp<IParent> parent, const char *childIndicator, bool emitError) {
if (parent.get() == nullptr) {
// casts always succeed with nullptrs.
return nullptr;
@@ -101,7 +92,7 @@
// TODO b/32001926 Needs to be fixed for socket mode.
if (parent->isRemote()) {
// binderized mode. Got BpChild. grab the remote and wrap it.
- return sp<IChild>(new BpChild(toBinder<IParent>(parent)));
+ return sp<IChild>(new BpChild(toBinder<IParent, BpParent>(parent)));
}
// Passthrough mode. Got BnChild and BsChild.
return sp<IChild>(static_cast<IChild *>(parent.get()));
diff --git a/transport/include/hidl/Static.h b/transport/include/hidl/Static.h
index 63b06fe..0133ff7 100644
--- a/transport/include/hidl/Static.h
+++ b/transport/include/hidl/Static.h
@@ -22,7 +22,6 @@
#include <android/hidl/base/1.0/IBase.h>
#include <hidl/ConcurrentMap.h>
#include <hwbinder/IBinder.h>
-#include <hwbinder/IInterface.h>
#include <utils/StrongPointer.h>
namespace android {
@@ -34,18 +33,14 @@
int prio;
};
-extern ConcurrentMap<wp<::android::hidl::base::V1_0::IBase>, SchedPrio> gServicePrioMap;
-
-// For HidlBinderSupport and autogenerated code
-extern ConcurrentMap<const ::android::hidl::base::V1_0::IBase*, wp<::android::hardware::BHwBinder>>
- gBnMap;
-
// 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;
+extern ConcurrentMap<wp<::android::hidl::base::V1_0::IBase>, SchedPrio> gServicePrioMap;
+
// For HidlPassthroughSupport and autogenerated code
// value function receives reinterpret_cast<void *>(static_cast<IFoo *>(foo)),
// returns sp<IBase>