【ResourceManagerService 分析】第五篇:ScopedAIBinder_DeathRecipient 详解

本文主要分析Android多媒体框架中ScopedAIBinder_DeathRecipient的实现细节。该类在`frameworks/native/libs/binder/ndk/include_cpp/android/binder_auto_utils.h`中定义,继承自ScopedAResource,并且是一个模板类。核心工作由内部的AIBinder_DeathRecipient完成,该接口在`frameworks/native/libs/binder/ndk/ibinder_internal.h`中定义。文章还指出,内部类的依赖关系值得进一步研究。
摘要由CSDN通过智能技术生成

这里将 mDeathRecipient的初始化简单分析下,

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-mokPsmlt-1642949389686)(img/image-20220123202151941.png)]

::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
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

智者向内寻求力量

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值