HalManifests can be merged.
assemble_vintf and VintfObject can now merge manifests
correctly (previously, only <hal>'s are merged).
Test: libvintf_test
Test: vintf_object_test
Fixes: 78943004
Change-Id: I5e2987e9c97e0b60e976fe4e0bb8833edf043a53
diff --git a/CompatibilityMatrix.cpp b/CompatibilityMatrix.cpp
index 290ebf9..5bb6d1e 100644
--- a/CompatibilityMatrix.cpp
+++ b/CompatibilityMatrix.cpp
@@ -28,6 +28,8 @@
namespace android {
namespace vintf {
+using details::mergeField;
+
bool CompatibilityMatrix::addKernel(MatrixKernel&& kernel, std::string* error) {
if (mType != SchemaType::FRAMEWORK) {
if (error) {
@@ -294,22 +296,6 @@
return true;
}
-template <typename T>
-static bool mergeField(T* dst, T* src) {
- static const T kEmpty{};
- if (*dst == *src) {
- return true; // no conflict
- }
- if (*src == kEmpty) {
- return true;
- }
- if (*dst == kEmpty) {
- *dst = std::move(*src);
- return true;
- }
- return false;
-}
-
bool CompatibilityMatrix::addSepolicy(CompatibilityMatrix* other, std::string* error) {
bool success = mergeField(&this->framework.mSepolicy, &other->framework.mSepolicy);
if (!success && error) *error = "<sepolicy> is already defined";