CompatibilityMatrix::addAllHalsAsOptional: avoid duplicate versions.

Make a copy of the <hal> tag that contains only that <version>.

For example, if level=1 requires foo@1.0, and level=2 requires
foo@{1.0 OR 2.0}, then in the output matrix:
- 1.0 required
- 2.0 optional

(Previous behavior is
- 1.0 required
- {1.0 OR 2.0} optional
where 1.0 is stated twice.)

Test: build without duplicate versions
Change-Id: I7b4f32e6c131dd77f4308e7cd8b8b78a30a2169f
diff --git a/test/LibVintfTest.cpp b/test/LibVintfTest.cpp
index 8c07075..af2bc67 100644
--- a/test/LibVintfTest.cpp
+++ b/test/LibVintfTest.cpp
@@ -2203,6 +2203,7 @@
         "<compatibility-matrix version=\"1.0\" type=\"framework\" level=\"2\">\n"
         "    <hal format=\"hidl\" optional=\"false\">\n"
         "        <name>android.hardware.foo</name>\n"
+        "        <version>1.2-3</version>\n"
         "        <version>2.0-4</version>\n"
         "        <interface>\n"
         "            <name>IFoo</name>\n"