Cleanup FQName usage.

Bug: 32559427
Test: hidl_test
Change-Id: Ie5e234c102f8ad76ab24db9bce1630e2227562f6
diff --git a/FQName.cpp b/FQName.cpp
index 99e9f9a..254a5a4 100644
--- a/FQName.cpp
+++ b/FQName.cpp
@@ -72,6 +72,11 @@
       mName(name),
       mValueName(valueName) {
     setVersion(version);
+
+    // Check if this is actually a valid fqName
+    FQName other;
+    other.setTo(this->string());
+    CHECK(other.mValid && (*this) == other);
 }
 
 FQName::FQName(const FQName& other)
@@ -339,7 +344,11 @@
     return FQName(package(), version(), "types");
 }
 
-const FQName FQName::getTopLevelType() const {
+FQName FQName::getPackageAndVersion() const {
+    return FQName(package(), version(), "");
+}
+
+FQName FQName::getTopLevelType() const {
     auto idx = mName.find('.');
 
     if (idx == std::string::npos) {