这里将 mDeathRecipient的初始化简单分析下,
::ndk::ScopedAIBinder_DeathRecipient mDeathRecipient;
ScopedAIBinder_DeathRecipient 定义在 frameworks/native/libs/binder/ndk/include_cpp/android/binder_auto_utils.h
/**
* Convenience wrapper. See AIBinder_DeathRecipient.
*/
class ScopedAIBinder_DeathRecipient
: public impl::ScopedAResource<AIBinder_DeathRecipient*, AIBinder_DeathRecipient_delete,
nullptr> {
public:
/**
* Takes ownership of a.
*/
explicit ScopedAIBinder_DeathRecipient(AIBinder_DeathRecipient* a = nullptr)
: ScopedAResource(a) {
}
~ScopedAIBinder_DeathRecipient() {
}
ScopedAIBinder_DeathRecipient(ScopedAIBinder_DeathRecipient&&) = default;
ScopedAIBinder_DeathRecipient& operator=(ScopedAIBinder_DeathRecipient&&) = default;
};
继承于 ScopedAResource类,定义在 frameworks/native/libs/binder/ndk/include_cpp/android/binder_auto_utils.h,
是一个模板类,泛型第一个参数指明了具体实施的类,,ScopedAResource 类中一个mT保存这个,AIBinder_DeathRecipient 实例,真正干活的是这个mT。
/**
* This baseclass owns a single object, used to make various classes RAII.
*/
template <typename T, void (*Destroy)(T), T DEFAULT>
class ScopedAResource {
publi