Android RIL简介

来源:互联网 发布:java string类getchars 编辑:程序博客网 时间:2024/06/17 16:56

1、RIL 全称:

Radio Interface Layer,Android的无线接口层,负责提供电话服务.是上层应用和下层硬件modem之间的中间层。负责数据的可靠传输、AT命令的发送以及响应的解析。

2、RIL的三部分:

Android的RIL驱动模块在hardware/ril目录下,一共分rild,librild.so以及librefrence_ril.so三个部分。
(AT:调制解调器 命令语言,即Attention)

3、Rild:

Main函数作为整个ril层的入口点,用dlopen打开libreference-ril.so库,RIL_startEventLoop()创建客户端事件监听线程。RIL_register()注册事件处理接口,并创建socket监听事件。

4、Libril.so:

组成部分为:ril.cpp,ril_event.cpp。主要完成同Framework层通信的工作,接受ril请求并传递给libreference_ril.so,同时把来自modem的response通过libreference_ril.so的反馈回传给调用进程。

5、RIL_startEventLoop:

在ril.cpp中实现的,它的主要目的是通过
Pthread_create(&s_tid_dispatch,&attr,eventLoop,NULL)建立一个dispatch线程,入口点在eventLoop线程。在eventLoop中,会调用ril_event.cpp中的ril_event_loop()函数,建立消息队列机制

6、PIPE:

在创建队列之前,先创建一个PIPE无名管道,读端放入select队列中,写端放入rilEventAddWakeup()中。rilEventAddWakeup()包含ril_event_add(ev)和triggerEvLoop()两个函数,ril_event_add(ev)将事件加入队列中,triggerEvLoop()唤醒select()函数,pipe的作用就是刷新select监听的内容。

当select监听到readFds可读或者超时,就会解阻,执行:
processTimeouts();
processReadReadies(&rfds,n);
firePending();
最后执行:ev->func(ev->fd,0 ,ev->param);

7、三个队列:

Watch_list: 监测事件队列;
Time_list: 时间事件队列;
Pengding_list: 待处理事件队列。

8、RIL事件处理流程图:

这里写图片描述

9、RIL_register:

1)RIL_register注册一组函数指针:RIL_RadioFunctions;
2)打开接受上层命令的socket通道。
这里写图片描述

10、RIL_init 处理流程图:

这里写图片描述

11、总体流程图:

这里写图片描述

原创粉丝点击