Merge "Add sleep in unsafe path." am: c10ecd6086 am: 17187997d5 am: 01b755992f
am: 982895dccb
Change-Id: I6affd9ac8ea58afd1d43cc42b81318991d8b4077
diff --git a/transport/include/hidl/HidlBinderSupport.h b/transport/include/hidl/HidlBinderSupport.h
index 5dec5cd..05f7fab 100644
--- a/transport/include/hidl/HidlBinderSupport.h
+++ b/transport/include/hidl/HidlBinderSupport.h
@@ -204,10 +204,17 @@
if (binderIface.get() == nullptr) {
return nullptr;
}
+
if (binderIface->localBinder() == nullptr) {
return new ProxyType(binderIface);
}
+
+ // Ensure that IBinder is BnHwBase (not JHwBinder, for instance)
+ if (!binderIface->checkSubclass(IBase::descriptor)) {
+ return new ProxyType(binderIface);
+ }
sp<IBase> base = static_cast<BnHwBase*>(binderIface.get())->getImpl();
+
if (details::canCastInterface(base.get(), IType::descriptor)) {
StubType* stub = static_cast<StubType*>(binderIface.get());
return stub->getImpl();
diff --git a/transport/include/hidl/HidlLazyUtils.h b/transport/include/hidl/HidlLazyUtils.h
index 257de98..6a62c97 100644
--- a/transport/include/hidl/HidlLazyUtils.h
+++ b/transport/include/hidl/HidlLazyUtils.h
@@ -29,13 +29,13 @@
/** Exits when all HALs registered through this object have 0 clients */
class LazyServiceRegistrar {
public:
- LazyServiceRegistrar();
static LazyServiceRegistrar& getInstance();
status_t registerService(const sp<::android::hidl::base::V1_0::IBase>& service,
const std::string& name = "default");
private:
std::shared_ptr<details::LazyServiceRegistrarImpl> mImpl;
+ LazyServiceRegistrar();
};
} // namespace hardware