Binder(3)--sayHello之ioctl.md

参考资料

  1. Android Binder详解 https://mr-cao.gitbooks.io/android/content/android-binder.html
  2. msm-4.14 Code https://github.com/android-linux-stable/msm-4.14/blob/9c4b6ed1b229cfc35e5c3e5815e297b7f519cf93/drivers/android/binder.c
  3. linux 内核 - ioctl 函数详解 https://blog.csdn.net/qq_19923217/article/details/82698787
  4. ioctl(2) — Linux manual page https://man7.org/linux/man-pages/man2/ioctl.2.html
  5. ioctl()分析——从用户空间到设备驱动 https://blog.csdn.net/zifehng/article/details/59576539

简介

接上文,首先回顾一下IBinder相关接口的类图:

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-G3NG2zsM-1608361238076)(res/2_4_IBinder全类图.png)]

我们知道在Client App中获取的IBinder实际上是BinderProxy类型的对象。那么在上一文中Client App调用sayHello方法过程的的#2.3.2中,我们卡住了,现在可以继续了:

virtual status_t        transact(   uint32_t code,
                                        const Parcel& data,
                                        Parcel* reply,
                                        uint32_t flags = 0) = 0;

一. IBinder.transact

  1. Service.onServiceConnected
  2. IDemoInterface.Stub.Proxy.sayHello
  3. BinderProxy.transact(Stub.TRANSACTION_sayHello, …)

1.1 BinderProxy.transact

public boolean transact(int code, Parcel data, Parcel reply, int flags) throws RemoteException {
   
    // ......
    try {
   
        // 不多废话,直接开始, 注意我们现在的进程环境是Client App哦
        return transactNative(code, data, reply, flags);
    }
    // ......
}

1.2 android_util_Binder#android_os_BinderProxy_transact

static jboolean android_os_BinderProxy_tra
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值