共享采用Android活页夹文件描述 [英] Sharing file descriptor using Android binder
问题描述
我如何可以共享文件描述符在整个C ++采用了Android粘合剂IPC过程?你可以张贴的例子也?
How can I share file descriptor across process using Android binder IPC in C++? Can you post example also?
推荐答案
在客户端的过程中,我们做了以下执行粘合剂交易
In client process we do the following to perform a binder transaction
远程() - >办理(MYTRANSACTION,数据,和放大器;回复,的IBinder :: FLAG_ONEWAY);
数据和答复是类型包裹。马歇尔和解组在使用地块对象原生Android做。它具有的功能,马歇尔文件描述符。
data and reply are of type Parcel. marshall and unmarshalling is done in native android using Parcel objects. It has the functionality to marshall a file descriptor.
data.writeFileDescriptor(FD);
在服务器进程(即服务机器人),我们调用下面的方法 读取文件描述符在服务器进程
In server process (i.e, Service in android), we call the following method to read the file descriptor in the server process.
INT FD = data.readFileDescriptor();
共享跨进程的文件描述符将在粘合剂驱动程序处理
sharing the file descriptor across process will be handled by the binder driver.
注意:复制所接收到的文件描述符之前包裹对象被销毁
Note : duplicate the received file descriptor before the parcel object is destroyed.
您可以找到执行和解释在本地粘合剂 Android系统的HelloWorldService
You can find the implementation and explanation for native binder at Android-HelloWorldService
这篇关于共享采用Android活页夹文件描述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!