上一篇有提到rild,這裏作我我的的理解來分析rild:
參考達人B的文章,連接:http://blog.csdn.net/qitaosong/article/details/5069823 html
1.rild.c結構: java
2.各個函數分析: android
2.1>RIL_register
extern void RIL_register (const RIL_RadioFunctions *callbacks);
該函數在ril.cpp裏有實現,RIL_RadioFunctions 在ril.h裏定義爲: socket
typedef struct { int version; /* set to RIL_VERSION */ RIL_RequestFunc onRequest; RIL_RadioStateRequest onStateRequest; RIL_Supports supports; RIL_Cancel onCancel; RIL_GetVersion getVersion; } RIL_RadioFunctions;其中onRequest,指令請求會在reference-ril.c裏實現:
2.2>RIL_onRequestComplete
extern void RIL_onRequestComplete(RIL_Token t, RIL_Errno e,void *response, size_t responselen)、RIL_onUnsolicitedResponse、
RIL_requestTimedCallback和RIL_startEventLoop函數同上,都在ril.cpp裏有實現。 函數
2.3>main(守護進程) oop
編譯以後是個rild可執行文件,在/init.rc裏面打開rild服務,會隨系統一塊兒運行。
1>首先和phone.apk服務創建socket鏈接,句柄爲fd: spa
fd = socket_local_client( QEMUD_SOCKET_NAME, ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM );
2>加載/system/lib/libreference-ril.so動態庫
dlHandle = dlopen(rilLibPath, RTLD_NOW); .net
3>啓動eventLoop線程,開始執行RIL消息隊列 線程
http://blog.csdn.net/hare_lee/article/details/6903460 調試
http://blog.csdn.net/fengkehuan/article/details/6203076
(ril_commands.h)
http://blog.csdn.net/ace1985/article/details/7051522
http://blog.csdn.net/hare_lee/article/details/6903962
http://blog.csdn.net/qitaosong/article/details/5069823
http://www.eoeandroid.com/thread-109142-1-1.html