RILD

来源:互联网 发布:手机旋转屏幕软件 编辑:程序博客网 时间:2024/05/17 22:37

六、几个重要结构体

6.1 RILChannelCtx

封装了AT通道的上下文信息

typedef struct RILChannelCtx {    const char* myName;    RILChannelId id;    pthread_t tid_reader;    pthread_t tid_myProxy;    int fd;    ATUnsolHandler unsolHandler;    int readCount;    pthread_mutex_t commandmutex;    pthread_cond_t commandcond;//EventLoop中阻塞的线程    pthread_mutex_t* p_channelMutex;    ATCommandType type;    const char *responsePrefix;    const char *smsPDU;    ATResponse *p_response;//封装返回信息的结构体    int readerClosed;    char *ATBufferCur;    char ATBuffer[MAX_AT_RESPONSE+1];    int pendingRequest;} RILChannelCtx;

6.2 SocketListenParam

SocketListenParam是一个比较重要的结构体,从它的名字知道,其封装了RILJ与RILC的连接信息。

关于SocketListenParam的结构定义:

static SocketListenParam s_ril_param_socket[SIM_COUNT];typedef struct SocketListenParam {    RIL_SOCKET_ID socket_id;    int fdListen;//监听RILJ信息的Socket句柄    int fdCommand;// accept返回的进行流操作的套接字    char* processName;    struct ril_event* commands_event;//fdListen对应Event    struct ril_event* listen_event;//fdCommand对应Event    void (*processCommandsCallback)(int fd, short flags, void *param);//Event 回调函数    RecordStream *p_rs;//回调函数参数,这里是SocketListenParam变量    RIL_SOCKET_TYPE type;} SocketListenParam;

6.3 CommandInfo

CommandInfo结构体定义为:

struct CommandInfo {    int requestNumber;//int类型的请求码    void (*dispatchFunction) (Parcel &p, struct RequestInfo *pRI);//分发函数函数指针    int(*responseFunction) (Parcel &p, void *response, size_t responselen);//返回函数函数指针} ;

既然include了那么ril_commands.h文件,那么看看此文件:

//@ril_commands.h{RIL_REQUEST_GET_SIM_STATUS, dispatchVoid, responseSimStatus},{RIL_REQUEST_ENTER_SIM_PIN, dispatchStrings, responseInts},...{RIL_REQUEST_HANGUP, dispatchInts, responseVoid},

主要使用CommandInfo 的s_commands变量定义:

CommandInfo s_commands[] = {#include "telephony/ril_commands.h"};

其中定义了不同请求的请求码及其对应的dispatchFunction和responseFunction。
比如,获取Sim Status的请求吗为RIL_REQUEST_GET_SIM_STATUS,其宏定义为1,使用dispatchVoid分发,使用responseSimStatus返回结果。

6.4 RequestInfo

RequestInfo顾名思义,其包含了当前请求的所有信息,结构体如下:

typedef struct RequestInfo {    RIL_Client_Type *client; //MUST in the beginning    int32_t token;      //this is not RIL_Token //令牌    CommandInfo *pCI; //请求处理方式信息    struct RequestInfo *p_next;//链表的下一个节点    char cancelled;    char local;         // responses to local commands do not go back to command process    RIL_SOCKET_ID socket_id;    int wasAckSent;    // Indicates whether an ack was sent earlier    RILChannelId cid;    // For command dispatch after onRequest()} RequestInfo;

6.5 UnsolResponseInfo

UnsolResponseInfo定义了针对于UNSOL消息的处理方式
例如:
{RIL_LOCAL_GSM_UNSOL_CARD_TYPE_NOTIFY, responseString, WAKE_PARTIAL}

其结构体定义为:

typedef struct {    int requestNumber;//内容标识符    int (*responseFunction) (Parcel &p, void *response, size_t responselen);//处理函数    WakeType wakeType;//类型} UnsolResponseInfo;
原创粉丝点击