Merge changes from topic 'hwservicemanager-1-1'

* changes:
  Support minor version upgrade of hwservicemanager.
  Add test for 1.1 IServiceManager.
diff --git a/Coordinator.cpp b/Coordinator.cpp
index 6155fcf..1f76410 100644
--- a/Coordinator.cpp
+++ b/Coordinator.cpp
@@ -187,7 +187,6 @@
 std::vector<std::string>::const_iterator
 Coordinator::findPackageRoot(const FQName &fqName) const {
     CHECK(!fqName.package().empty());
-    CHECK(!fqName.version().empty());
 
     // Find the right package prefix and path for this FQName.  For
     // example, if FQName is "android.hardware.nfc@1.0::INfc", and the
diff --git a/NamedType.h b/NamedType.h
index 1e5a614..cfc3df8 100644
--- a/NamedType.h
+++ b/NamedType.h
@@ -30,7 +30,7 @@
 struct Scope;
 
 struct NamedType : public Type {
-    NamedType(const char* localName, const Location& loc, Scope* mParent);
+    NamedType(const char* localName, const Location& loc, Scope* parent);
 
     bool isNamedType() const override;
 
diff --git a/generateCpp.cpp b/generateCpp.cpp
index b2a4a73..9039257 100644
--- a/generateCpp.cpp
+++ b/generateCpp.cpp
@@ -482,7 +482,9 @@
         }
         out << "{ return false; }\n\n";
 
-        for (const auto &method : iface->methods()) {
+        for (const auto& tuple : iface->allMethodsFromRoot()) {
+            const Method* method = tuple.method();
+
             out << "\n";
 
             const bool returnsValue = !method->results().empty();
diff --git a/hidl-gen_y.yy b/hidl-gen_y.yy
index a244579..d67638e 100644
--- a/hidl-gen_y.yy
+++ b/hidl-gen_y.yy
@@ -625,7 +625,7 @@
       {
           Type *parent = $3;
 
-          if (ast->package() != gIBasePackageFqName) {
+          if (ast->package().package() != gIBasePackageFqName.string()) {
               if (!ast->addImport(gIBaseFqName.string().c_str())) {
                   std::cerr << "ERROR: Unable to automatically import '"
                             << gIBaseFqName.string()
diff --git a/main.cpp b/main.cpp
index b610456..6645267 100644
--- a/main.cpp
+++ b/main.cpp
@@ -189,7 +189,7 @@
         options.insert(coordinator->getPackageRootOption(interface));
     }
     options.insert(coordinator->getPackageRootOption(packageFQName));
-    options.insert(coordinator->getPackageRootOption(gIBasePackageFqName));
+    options.insert(coordinator->getPackageRootOption(gIBaseFqName));
     for (const auto &option : options) {
         out << "-r"
             << option
@@ -649,9 +649,9 @@
     return true;
 }
 
-bool isHidlTransportPackage(const FQName &package) {
-    return package == gIBasePackageFqName ||
-           package == gIManagerPackageFqName;
+bool isHidlTransportPackage(const FQName& fqName) {
+    return fqName.package() == gIBasePackageFqName.string() ||
+           fqName.package() == gIManagerPackageFqName.string();
 }
 
 bool isSystemPackage(const FQName &package) {
diff --git a/test/hidl_test b/test/hidl_test
index c4e62a5..fa25b76 100644
--- a/test/hidl_test
+++ b/test/hidl_test
@@ -1,3 +1,5 @@
+set -e
+
 source /data/nativetest64/hidl_test_helper
 
 chmod a+x /data/nativetest/hidl_test_servers/hidl_test_servers
diff --git a/test/hidl_test_client.cpp b/test/hidl_test_client.cpp
index 07c3ba7..a8e7793 100644
--- a/test/hidl_test_client.cpp
+++ b/test/hidl_test_client.cpp
@@ -5,7 +5,7 @@
 
 #include <android-base/logging.h>
 
-#include <android/hidl/manager/1.0/IServiceManager.h>
+#include <android/hidl/manager/1.1/IServiceManager.h>
 #include <android/hidl/manager/1.0/IServiceNotification.h>
 
 #include <android/hidl/allocator/1.0/IAllocator.h>
@@ -111,7 +111,7 @@
 using ::android::hardware::hidl_vec;
 using ::android::hidl::allocator::V1_0::IAllocator;
 using ::android::hidl::base::V1_0::IBase;
-using ::android::hidl::manager::V1_0::IServiceManager;
+using ::android::hidl::manager::V1_1::IServiceManager;
 using ::android::hidl::manager::V1_0::IServiceNotification;
 using ::android::hidl::memory::V1_0::IMemory;
 using ::android::hidl::token::V1_0::ITokenManager;
@@ -586,10 +586,12 @@
         "android.hardware.tests.inheritance@1.0::IGrandparent/child",
         "android.hardware.tests.foo@1.0::IFoo/foo",
         "android.hidl.manager@1.0::IServiceManager/default",
+        "android.hidl.manager@1.1::IServiceManager/default",
     };
 
     static const std::set<std::string> passthroughSet = {
-        "android.hidl.manager@1.0::IServiceManager/default"
+        "android.hidl.manager@1.0::IServiceManager/default",
+        "android.hidl.manager@1.1::IServiceManager/default",
     };
 
     std::set<std::string> activeSet;
@@ -685,6 +687,40 @@
     }
 }
 
+TEST_F(HidlTest, ServiceUnregisterTest) {
+    if (mode == BINDERIZED) {
+        const std::string instance = "some-instance-name";
+
+        sp<ServiceNotification> sNotification = new ServiceNotification();
+
+        // unregister all
+        EXPECT_TRUE(IParent::registerForNotifications(instance, sNotification));
+        EXPECT_TRUE(manager->unregisterForNotifications("", "", sNotification));
+
+        // unregister all with instance name
+        EXPECT_TRUE(IParent::registerForNotifications(instance, sNotification));
+        EXPECT_TRUE(manager->unregisterForNotifications(IParent::descriptor,
+            "", sNotification));
+
+        // unregister package listener
+        EXPECT_TRUE(IParent::registerForNotifications("", sNotification));
+        EXPECT_TRUE(manager->unregisterForNotifications(IParent::descriptor,
+            "", sNotification));
+
+        // unregister listener for specific service and name
+        EXPECT_TRUE(IParent::registerForNotifications(instance, sNotification));
+        EXPECT_TRUE(manager->unregisterForNotifications(IParent::descriptor,
+            instance, sNotification));
+
+        EXPECT_FALSE(manager->unregisterForNotifications("", "", sNotification));
+
+        // TODO(b/32837397): remote destructor is lazy
+        // wp<ServiceNotification> wNotification = sNotification;
+        // sNotification = nullptr;
+        // EXPECT_EQ(nullptr, wNotification.promote().get());
+    }
+}
+
 // passthrough TODO(b/31959402)
 TEST_F(HidlTest, ServiceAllNotificationTest) {
     if (mode == BINDERIZED) {
diff --git a/test/vendor/1.0/IVendor.hal b/test/vendor/1.0/IVendor.hal
index 91269a8..3beebea 100644
--- a/test/vendor/1.0/IVendor.hal
+++ b/test/vendor/1.0/IVendor.hal
@@ -30,4 +30,8 @@
     fun4(string a) generates(string b);
     fun5(uint8_t[4][4] a) generates(uint8_t[4][4] b);
 
+    // Testing static functions in derived class
+    // overriding virtual functions in parent class
+    // due to namespace resolution.
+    registerForNotifications();
 };
\ No newline at end of file
diff --git a/utils/include/hidl-util/FQName.h b/utils/include/hidl-util/FQName.h
index 6c471d4..3cdc7a9 100644
--- a/utils/include/hidl-util/FQName.h
+++ b/utils/include/hidl-util/FQName.h
@@ -226,9 +226,9 @@
 };
 
 static const FQName gIBaseFqName = FQName{"android.hidl.base@1.0::IBase"};
-static const FQName gIBasePackageFqName = FQName{"android.hidl.base@1.0"};
+static const FQName gIBasePackageFqName = FQName{"android.hidl.base"};
 static const FQName gIManagerFqName = FQName{"android.hidl.manager@1.0::IServiceManager"};
-static const FQName gIManagerPackageFqName = FQName{"android.hidl.manager@1.0"};
+static const FQName gIManagerPackageFqName = FQName{"android.hidl.manager"};
 
 }  // namespace android