Don't allow conflicting interfaces.

For IBar extends IFoo if 1.0::IFoo/default is being registered, remove
IFoo/default. This makes sure the following two things are equivalent
1). IBar::castFrom(IFoo::getService(X))
2). IBar::getService(X)

Test: hidl_test, hidl_test_java, manually confirm that killing
  an interface can remove it from lshal.
Fixes: 62303973

Change-Id: Ic3e95e3d4ffb7eda5ac70b1c87dd83a2c5a187f5
diff --git a/ServiceManager.h b/ServiceManager.h
index 7d927a4..54ecb37 100644
--- a/ServiceManager.h
+++ b/ServiceManager.h
@@ -54,7 +54,9 @@
 
     virtual void serviceDied(uint64_t cookie, const wp<IBase>& who);
 private:
-    bool removeService(const wp<IBase>& who);
+    // if restrictToInstanceName is nullptr, remove all, otherwise only those services
+    // which match this instance name. Returns whether all instances were removed.
+    bool removeService(const wp<IBase>& who, const std::string* restrictToInstanceName);
     bool removePackageListener(const wp<IBase>& who);
     bool removeServiceListener(const wp<IBase>& who);
     size_t countExistingService() const;