Ril分析四——來自網路端事件流程

來源:互聯網
上載者:User

從modem傳遞來的網路端事件,通過readLoop線程處理:

readLoop讀取資料過程:

static void *readerLoop(void *arg){    for (;;) {        //從與modem通訊裝置連接埠讀取資料        line = readline();        if (line == NULL) {            break;        }        //處理資料        processLine(line);    }    onReaderClosed();    return NULL;}static void processLine(const char *line){    if (sp_response == NULL) {       //來自網路端事件        handleUnsolicited(line);    } else if (isFinalResponseSuccess(line)) {        //用戶端請求處理返回        sp_response->success = 1;        handleFinalResponse(line);    } }

網路端事件處理過程:

static void handleUnsolicited(const char *line){    //onUnsolicited    if (s_unsolHandler != NULL) {        s_unsolHandler(line, NULL);    }}static void onUnsolicited (const char *s, const char *sms_pdu){    //初始化傳入的ril.cpp中RIL_onUnsolicitedResponse函數    RIL_onUnsolicitedResponse (            RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED,            NULL, 0);}Void RIL_onUnsolicitedSendResponse(int unsolResponse, void *data,                                size_t datalen, int client_id){    unsolResponseIndex = unsolResponse - RIL_UNSOL_RESPONSE_BASE;    appendPrintBuf("[UNSL]< %s", requestToString(unsolResponse));    Parcel p;    p.writeInt32 (RESPONSE_UNSOLICITED);    p.writeInt32 (unsolResponse);    //調用ril中網路端請求的響應函數     ret = s_unsolResponses[unsolResponseIndex]                .responseFunction(p, data, datalen);    //將資料傳遞給響應的裝置    ret = sendResponse(p, client_id);    return;}

同樣以數組映射表形式儲存網路端事件響應請求介面:

typedef struct {        int requestNumber;        int (*responseFunction) (Parcel &p, void *response,                     size_t responselen);        WakeType wakeType;    } UnsolResponseInfo;static UnsolResponseInfo s_unsolResponses[] = {  #include "ril_unsol_commands.h"};ril_unsol_commands.h:{RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, responseVoid, WAKE_PARTIAL},    {RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED, responseVoid, WAKE_PARTIAL},    {RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED, responseVoid, WAKE_PARTIAL},    {RIL_UNSOL_RESPONSE_NEW_SMS, responseString, WAKE_PARTIAL},……

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.