Allow fixing race condition in lazy HAL.

This implements the updated interface for IServiceManager.

Interfaces are directly retrieved from their corresponding locations
and now servers are allowed to unregister themselves before shutting
down.

Bug: 123318663
Test: hidl_test, manual

Change-Id: Ia700d356d67a7c779262243225af5570d4c2817f
Merged-In: Ia700d356d67a7c779262243225af5570d4c2817f
diff --git a/ServiceManager.h b/ServiceManager.h
index 8cfaeb7..17d7143 100644
--- a/ServiceManager.h
+++ b/ServiceManager.h
@@ -53,7 +53,9 @@
                                             const sp<IServiceNotification>& callback) override;
 
     // Methods from ::android::hidl::manager::V1_2::IServiceManager follow.
-    Return<bool> registerClientCallback(const sp<IBase>& server,
+    Return<bool> registerClientCallback(const hidl_string& fqName,
+                                        const hidl_string& name,
+                                        const sp<IBase>& server,
                                         const sp<IClientCallback>& cb) override;
     Return<bool> unregisterClientCallback(const sp<IBase>& server,
                                           const sp<IClientCallback>& cb) override;
@@ -62,6 +64,9 @@
                               const hidl_vec<hidl_string>& chain) override;
     Return<void> listManifestByInterface(const hidl_string& fqInstanceName,
                                          listManifestByInterface_cb _hidl_cb) override;
+    Return<bool> tryUnregister(const hidl_string& fqName,
+                               const hidl_string& name,
+                               const sp<IBase>& service) override;
 
     void handleClientCallbacks();
 
@@ -86,6 +91,8 @@
     void forEachServiceEntry(std::function<bool(const HidlService *)> f) const;
     void forEachServiceEntry(std::function<bool(HidlService *)> f);
 
+    HidlService* lookup(const std::string& fqName, const std::string& name);
+
     using InstanceMap = std::map<
             std::string, // instance name e.x. "manager"
             std::unique_ptr<HidlService>