Merge "Make libhidl(base|memory) apex-available for com.android.neuralnetworks." am: 750364bd76 am: abe3f34125 am: 4065edea29

Change-Id: I4ee097b004ec988339b0d24cc608fc3e80db234a
diff --git a/Android.bp b/Android.bp
index 8d907b7..da50c0a 100644
--- a/Android.bp
+++ b/Android.bp
@@ -108,6 +108,8 @@
 cc_library {
     name: "libhidltransport",
     vendor_available: true,
+
+    visibility: [":__subpackages__"],
 }
 
 cc_defaults {
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
diff --git a/vintfdata/Android.mk b/vintfdata/Android.mk
index b345308..f1b8b57 100644
--- a/vintfdata/Android.mk
+++ b/vintfdata/Android.mk
@@ -27,6 +27,10 @@
   FRAMEWORK_MANIFEST_INPUT_FILES += $(DEVICE_FRAMEWORK_MANIFEST_FILE)
 endif
 
+ifeq ($(BOARD_IS_AUTOMOTIVE), true)
+  FRAMEWORK_MANIFEST_INPUT_FILES += $(LOCAL_PATH)/automotive_manifest.xml
+endif
+
 # VNDK Version in device compatibility matrix and framework manifest
 ifeq ($(BOARD_VNDK_VERSION),current)
 VINTF_VNDK_VERSION := $(PLATFORM_VNDK_VERSION)
diff --git a/vintfdata/automotive_manifest.xml b/vintfdata/automotive_manifest.xml
new file mode 100644
index 0000000..464dcac
--- /dev/null
+++ b/vintfdata/automotive_manifest.xml
@@ -0,0 +1,11 @@
+<manifest version="1.0" type="framework">
+    <hal>
+        <name>android.frameworks.automotive.display</name>
+        <transport>hwbinder</transport>
+        <version>1.0</version>
+        <interface>
+            <name>IAutomotiveDisplayProxyService</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+</manifest>