Add (un)linkToDeath to IBase.
With corresponding callback interfaces. hidl_death_recipient
is a transport-independent interface, used directly by clients
and servers. hidl_binder_death_recipient wraps a hidl_death_recipient
object and implements the Binder-specific death recipient. It
holds a weak reference to the callback interface, as well as the
interface it was called on (so we can include that in the callback).
Bug: 31632518
Test: mma, hidl_test
Change-Id: I0430efff24c2bfd3993438c6ed3fe007d9f9e3ef
diff --git a/base/include/hidl/HidlSupport.h b/base/include/hidl/HidlSupport.h
index 844ef40..1a4fd3c 100644
--- a/base/include/hidl/HidlSupport.h
+++ b/base/include/hidl/HidlSupport.h
@@ -38,7 +38,8 @@
namespace android {
-// this file is included by all hidl interface, so we must forward declare the IMemory type.
+// this file is included by all hidl interface, so we must forward declare the
+// IMemory and IBase types.
namespace hidl {
namespace memory {
namespace V1_0 {
@@ -47,8 +48,23 @@
}; // namespace manager
}; // namespace hidl
+namespace hidl {
+namespace base {
+namespace V1_0 {
+ struct IBase;
+}; // namespace V1_0
+}; // namespace base
+}; // namespace hidl
+
namespace hardware {
+// hidl_death_recipient is a callback interfaced that can be used with
+// linkToDeath() / unlinkToDeath()
+struct hidl_death_recipient : public virtual RefBase {
+ virtual void serviceDied(uint64_t cookie,
+ const ::android::wp<::android::hidl::base::V1_0::IBase>& who) = 0;
+};
+
// hidl_handle wraps a pointer to a native_handle_t in a hidl_pointer,
// so that it can safely be transferred between 32-bit and 64-bit processes.
struct hidl_handle {