Add (un)linkToDeath to generated interfaces.

(un)linkToDeath is now a part of IBase, and can be
called on any generated HIDL interface. The implementation
is a no-op, except in proxy objects, which are by
definition a different process than the interface they point
to.

Since clients are not aware of the transport implementation, we must
wrap the transport-independent callback in a transport-specific
callback object. In case of binder, that object is a
hidl_binder_death_recipient.

The binder proxy object contains a list of registered death
recipients, as well as a mutex to protect access to the list.
The list is required to allow us to map back transport-independent
callbacks to transport-dependent callbacks in unlinkToDeath().

Bug: 31632518
Test: mma, hidl_test
Change-Id: I5083a8789dd706a886a8a09f8c733031a351a36a
diff --git a/Method.cpp b/Method.cpp
index bfd28c9..a085497 100644
--- a/Method.cpp
+++ b/Method.cpp
@@ -71,20 +71,32 @@
     return *mAnnotations;
 }
 
-void Method::cppImpl(Formatter &out) const {
+void Method::cppImpl(MethodImplType type, Formatter &out) const {
     CHECK(mIsHidlReserved);
-    if (mCppImpl) {
-        mCppImpl(out);
+    auto it = mCppImpl.find(type);
+    if (it != mCppImpl.end()) {
+        it->second(out);
     }
 }
 
-void Method::javaImpl(Formatter &out) const {
+void Method::javaImpl(MethodImplType type, Formatter &out) const {
     CHECK(mIsHidlReserved);
-    if (mJavaImpl) {
-        mJavaImpl(out);
+    auto it = mJavaImpl.find(type);
+    if (it != mJavaImpl.end()) {
+        it->second(out);
     }
 }
 
+bool Method::overridesCppImpl(MethodImplType type) const {
+    CHECK(mIsHidlReserved);
+    return mCppImpl.find(type) != mCppImpl.end();
+}
+
+bool Method::overridesJavaImpl(MethodImplType type) const {
+    CHECK(mIsHidlReserved);
+    return mJavaImpl.find(type) != mJavaImpl.end();
+}
+
 void Method::setSerialId(size_t serial) {
     CHECK(!mIsHidlReserved);
     mSerial = serial;