libbinder_ndk: add warning to linkToDeath
For common issue around cookie lifetimes.
Change-Id: Ia1cb8c4278d783acf2af874651bd0d459261a9cf
Fixes: 254939515
Test: N/A
diff --git a/libs/binder/ndk/include_ndk/android/binder_ibinder.h b/libs/binder/ndk/include_ndk/android/binder_ibinder.h
index 05677a8..db2d2c1 100644
--- a/libs/binder/ndk/include_ndk/android/binder_ibinder.h
+++ b/libs/binder/ndk/include_ndk/android/binder_ibinder.h
@@ -594,6 +594,9 @@
*
* See also AIBinder_linkToDeath/AIBinder_unlinkToDeath.
*
+ * WARNING: Make sure the lifetime of this cookie is long enough. If it is dynamically
+ * allocated, it should be deleted with AIBinder_DeathRecipient_setOnUnlinked.
+ *
* Available since API level 33.
*
* \param cookie the cookie passed to AIBinder_linkToDeath.
@@ -605,6 +608,9 @@
*
* Available since API level 29.
*
+ * WARNING: Make sure the lifetime of this cookie is long enough. If it is dynamically
+ * allocated, it should be deleted with AIBinder_DeathRecipient_setOnUnlinked.
+ *
* \param onBinderDied the callback to call when this death recipient is invoked.
*
* \return the newly constructed object (or null if onBinderDied is null).