Merge "Reserve 'libhidl' w/ convenient use."
diff --git a/transport/HidlBinderSupport.cpp b/transport/HidlBinderSupport.cpp
index caf7cf8..62b1755 100644
--- a/transport/HidlBinderSupport.cpp
+++ b/transport/HidlBinderSupport.cpp
@@ -256,16 +256,16 @@
}
// for get + set
- std::unique_lock<std::mutex> _lock = details::gBnMap.lock();
+ std::unique_lock<std::mutex> _lock = details::gBnMap->lock();
- wp<BHwBinder> wBnObj = details::gBnMap.getLocked(ifacePtr, nullptr);
+ wp<BHwBinder> wBnObj = details::gBnMap->getLocked(ifacePtr, nullptr);
sp<IBinder> sBnObj = wBnObj.promote();
if (sBnObj == nullptr) {
auto func = details::getBnConstructorMap().get(descriptor, nullptr);
if (!func) {
// TODO(b/69122224): remove this static variable when prebuilts updated
- func = details::gBnConstructorMap.get(descriptor, nullptr);
+ func = details::gBnConstructorMap->get(descriptor, nullptr);
}
LOG_ALWAYS_FATAL_IF(func == nullptr, "%s gBnConstructorMap returned null for %s", __func__,
descriptor.c_str());
@@ -274,7 +274,7 @@
LOG_ALWAYS_FATAL_IF(sBnObj == nullptr, "%s Bn constructor function returned null for %s",
__func__, descriptor.c_str());
- details::gBnMap.setLocked(ifacePtr, static_cast<BHwBinder*>(sBnObj.get()));
+ details::gBnMap->setLocked(ifacePtr, static_cast<BHwBinder*>(sBnObj.get()));
}
return sBnObj;
diff --git a/transport/HidlPassthroughSupport.cpp b/transport/HidlPassthroughSupport.cpp
index ff68a1e..bc67656 100644
--- a/transport/HidlPassthroughSupport.cpp
+++ b/transport/HidlPassthroughSupport.cpp
@@ -31,7 +31,7 @@
auto func = getBsConstructorMap().get(descriptor, nullptr);
if (!func) {
// TODO(b/69122224): remove this when prebuilts don't reference it
- func = gBsConstructorMap.get(descriptor, nullptr);
+ func = gBsConstructorMap->get(descriptor, nullptr);
}
if (func) {
return func(static_cast<void*>(iface.get()));
diff --git a/transport/HidlTransportSupport.cpp b/transport/HidlTransportSupport.cpp
index 311504d..846b166 100644
--- a/transport/HidlTransportSupport.cpp
+++ b/transport/HidlTransportSupport.cpp
@@ -88,20 +88,9 @@
// Due to ABI considerations, IBase cannot have a destructor to clean this up.
// So, because this API is so infrequently used, (expected to be usually only
// one time for a process, but it can be more), we are cleaning it up here.
- // TODO(b/37794345): if ever we update the HIDL ABI for launches in an Android
- // release in the meta-version sense, we should remove this.
- std::unique_lock<std::mutex> lock = details::gServicePrioMap.lock();
-
- std::vector<wp<IBase>> toDelete;
- for (const auto& kv : details::gServicePrioMap) {
- if (kv.first.promote() == nullptr) {
- toDelete.push_back(kv.first);
- }
- }
- for (const auto& k : toDelete) {
- details::gServicePrioMap.eraseLocked(k);
- }
- details::gServicePrioMap.setLocked(service, {policy, priority});
+ std::unique_lock<std::mutex> lock = details::gServicePrioMap->lock();
+ pruneMapLocked(details::gServicePrioMap.get());
+ details::gServicePrioMap->setLocked(service, {policy, priority});
return true;
}
@@ -115,9 +104,9 @@
// Due to ABI considerations, IBase cannot have a destructor to clean this up.
// So, because this API is so infrequently used, (expected to be usually only
// one time for a process, but it can be more), we are cleaning it up here.
- std::unique_lock<std::mutex> lock = details::gServiceSidMap.lock();
- pruneMapLocked(details::gServiceSidMap);
- details::gServiceSidMap.setLocked(service, requesting);
+ std::unique_lock<std::mutex> lock = details::gServiceSidMap->lock();
+ pruneMapLocked(details::gServiceSidMap.get());
+ details::gServiceSidMap->setLocked(service, requesting);
return true;
}
diff --git a/transport/InternalStatic.h b/transport/InternalStatic.h
index b0fefa9..1dfaae4 100644
--- a/transport/InternalStatic.h
+++ b/transport/InternalStatic.h
@@ -26,10 +26,12 @@
namespace hardware {
namespace details {
+// TODO(b/69122224): remove this
// deprecated; use getBnConstructorMap instead.
-extern BnConstructorMap gBnConstructorMap;
+extern DoNotDestruct<BnConstructorMap> gBnConstructorMap;
+// TODO(b/69122224): remove this
// deprecated; use getBsConstructorMap instead.
-extern BsConstructorMap gBsConstructorMap;
+extern DoNotDestruct<BsConstructorMap> gBsConstructorMap;
} // namespace details
} // namespace hardware
diff --git a/transport/Static.cpp b/transport/Static.cpp
index 0bbd48d..af16e8f 100644
--- a/transport/Static.cpp
+++ b/transport/Static.cpp
@@ -28,27 +28,28 @@
namespace details {
// Deprecated; kept for ABI compatibility. Use getBnConstructorMap.
-BnConstructorMap gBnConstructorMap{};
+DoNotDestruct<BnConstructorMap> gBnConstructorMap{};
-ConcurrentMap<const ::android::hidl::base::V1_0::IBase*, wp<::android::hardware::BHwBinder>>
- gBnMap{};
+DoNotDestruct<ConcurrentMap<const ::android::hidl::base::V1_0::IBase*,
+ wp<::android::hardware::BHwBinder>>>
+ gBnMap{};
// TODO(b/122472540): replace with single, hidden map
-ConcurrentMap<wp<::android::hidl::base::V1_0::IBase>, SchedPrio> gServicePrioMap{};
-ConcurrentMap<wp<::android::hidl::base::V1_0::IBase>, bool> gServiceSidMap{};
+DoNotDestruct<ConcurrentMap<wp<::android::hidl::base::V1_0::IBase>, SchedPrio>> gServicePrioMap{};
+DoNotDestruct<ConcurrentMap<wp<::android::hidl::base::V1_0::IBase>, bool>> gServiceSidMap{};
// Deprecated; kept for ABI compatibility. Use getBsConstructorMap.
-BsConstructorMap gBsConstructorMap{};
+DoNotDestruct<BsConstructorMap> gBsConstructorMap{};
// For static executables, it is not guaranteed that gBnConstructorMap are initialized before
// used in HAL definition libraries.
BnConstructorMap& getBnConstructorMap() {
- static BnConstructorMap map{};
+ static BnConstructorMap& map = *new BnConstructorMap();
return map;
}
BsConstructorMap& getBsConstructorMap() {
- static BsConstructorMap map{};
+ static BsConstructorMap& map = *new BsConstructorMap();
return map;
}
diff --git a/transport/include/hidl/ConcurrentMap.h b/transport/include/hidl/ConcurrentMap.h
index 1b06dfd..329752c 100644
--- a/transport/include/hidl/ConcurrentMap.h
+++ b/transport/include/hidl/ConcurrentMap.h
@@ -90,6 +90,23 @@
std::map<K, V> mMap;
};
+namespace details {
+
+// TODO(b/69122224): remove this type and usages of it
+// DO NOT ADD USAGES
+template <typename T>
+class DoNotDestruct {
+ public:
+ DoNotDestruct() { new (buffer) T(); }
+ T& get() { return *reinterpret_cast<T*>(buffer); }
+ T* operator->() { return reinterpret_cast<T*>(buffer); }
+
+ private:
+ alignas(T) char buffer[sizeof(T)];
+};
+
+} // namespace details
+
} // namespace hardware
} // namespace android
diff --git a/transport/include/hidl/Static.h b/transport/include/hidl/Static.h
index cc711b7..be74bae 100644
--- a/transport/include/hidl/Static.h
+++ b/transport/include/hidl/Static.h
@@ -37,12 +37,17 @@
int prio;
};
-extern ConcurrentMap<wp<::android::hidl::base::V1_0::IBase>, SchedPrio> gServicePrioMap;
-extern ConcurrentMap<wp<::android::hidl::base::V1_0::IBase>, bool> gServiceSidMap;
+// TODO(b/69122224): remove this
+extern DoNotDestruct<ConcurrentMap<wp<::android::hidl::base::V1_0::IBase>, SchedPrio>>
+ gServicePrioMap;
+// TODO(b/69122224): remove this
+extern DoNotDestruct<ConcurrentMap<wp<::android::hidl::base::V1_0::IBase>, bool>> gServiceSidMap;
+// TODO(b/69122224): remove this
// For HidlBinderSupport and autogenerated code
-extern ConcurrentMap<const ::android::hidl::base::V1_0::IBase*, wp<::android::hardware::BHwBinder>>
- gBnMap;
+extern DoNotDestruct<ConcurrentMap<const ::android::hidl::base::V1_0::IBase*,
+ wp<::android::hardware::BHwBinder>>>
+ gBnMap;
using BnConstructorMap = ConcurrentMap<std::string, std::function<sp<IBinder>(void*)>>;
// For HidlBinderSupport and autogenerated code
diff --git a/vintfdata/Android.mk b/vintfdata/Android.mk
index 232ef6f..ffe361f 100644
--- a/vintfdata/Android.mk
+++ b/vintfdata/Android.mk
@@ -16,6 +16,12 @@
LOCAL_PATH := $(call my-dir)
+# DEVICE_FRAMEWORK_MANIFEST_FILE is a device-specific framework manifest file
+# that installed to the system image. HALs entries should be written to
+# DEVICE_FRAMEWORK_MANIFEST_FILE or PRODUCT_MANIFEST_FILES depend on the path of
+# the module. It is recommended that such device-specific modules to be
+# installed on product partition.
+
FRAMEWORK_MANIFEST_INPUT_FILES := $(LOCAL_PATH)/manifest.xml
# TODO(b/110487738): replace with vintf_fragment
ifdef USE_VR_FLINGER
@@ -48,18 +54,21 @@
GEN := $(local-generated-sources-dir)/compatibility_matrix.xml
$(GEN): PRIVATE_VINTF_VNDK_VERSION := $(VINTF_VNDK_VERSION)
+$(GEN): PRIVATE_DEVICE_MATRIX_INPUT_FILE := $(DEVICE_MATRIX_INPUT_FILE)
$(GEN): $(DEVICE_MATRIX_INPUT_FILE) $(HOST_OUT_EXECUTABLES)/assemble_vintf
REQUIRED_VNDK_VERSION=$(PRIVATE_VINTF_VNDK_VERSION) \
BOARD_SYSTEMSDK_VERSIONS="$(BOARD_SYSTEMSDK_VERSIONS)" \
- $(HOST_OUT_EXECUTABLES)/assemble_vintf -i $< -o $@
+ $(HOST_OUT_EXECUTABLES)/assemble_vintf \
+ -i $(call normalize-path-list,$(PRIVATE_DEVICE_MATRIX_INPUT_FILE)) \
+ -o $@
LOCAL_PREBUILT_MODULE_FILE := $(GEN)
include $(BUILD_PREBUILT)
BUILT_VENDOR_MATRIX := $(LOCAL_BUILT_MODULE)
-# Framework Manifest
+# System Manifest
include $(CLEAR_VARS)
-LOCAL_MODULE := framework_manifest.xml
+LOCAL_MODULE := system_manifest.xml
LOCAL_MODULE_STEM := manifest.xml
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/vintf
@@ -79,6 +88,26 @@
include $(BUILD_PREBUILT)
BUILT_SYSTEM_MANIFEST := $(LOCAL_BUILT_MODULE)
+# Product Manifest
+ifneq ($(PRODUCT_MANIFEST_FILES),)
+include $(CLEAR_VARS)
+LOCAL_MODULE := product_manifest.xml
+LOCAL_MODULE_STEM := manifest.xml
+LOCAL_MODULE_CLASS := ETC
+LOCAL_MODULE_RELATIVE_PATH := vintf
+GEN := $(local-generated-sources-dir)/manifest.xml
+$(GEN): PRIVATE_PRODUCT_MANIFEST_FILES := $(PRODUCT_MANIFEST_FILES)
+$(GEN): $(PRODUCT_MANIFEST_FILES) $(HOST_OUT_EXECUTABLES)/assemble_vintf
+ $(HOST_OUT_EXECUTABLES)/assemble_vintf \
+ -i $(call normalize-path-list,$(PRIVATE_PRODUCT_MANIFEST_FILES)) \
+ -o $@
+
+LOCAL_PREBUILT_MODULE_FILE := $(GEN)
+include $(BUILD_PREBUILT)
+BUILT_PRODUCT_MANIFEST := $(LOCAL_BUILT_MODULE)
+endif
+
VINTF_VNDK_VERSION :=
FRAMEWORK_MANIFEST_INPUT_FILES :=
-DEVICE_MATRIX_INPUT_FILE :=
\ No newline at end of file
+DEVICE_MATRIX_INPUT_FILE :=
+PRODUCT_MANIFEST_INPUT_FILES :=