参考资料
- Android Binder详解 https://mr-cao.gitbooks.io/android/content/android-binder.html
- msm-4.14 Code https://github.com/android-linux-stable/msm-4.14/blob/9c4b6ed1b229cfc35e5c3e5815e297b7f519cf93/drivers/android/binder.c
- linux 内核 - ioctl 函数详解 https://blog.csdn.net/qq_19923217/article/details/82698787
- ioctl(2) — Linux manual page https://man7.org/linux/man-pages/man2/ioctl.2.html
- ioctl()分析——从用户空间到设备驱动 https://blog.csdn.net/zifehng/article/details/59576539
简介
接上文,首先回顾一下IBinder相关接口的类图:
我们知道在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
- Service.onServiceConnected
- IDemoInterface.Stub.Proxy.sayHello
- 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