X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=libril%2Fril.cpp;h=65edba1ee2fb5ef8f28c71446ea58569ba9b5a60;hb=a592eebc;hp=3476232b6dd3a84b2cbd55a86129ffd048cf75cb;hpb=31f41943663ccc71bef87d42585b04afb23f6754;p=android-x86%2Fhardware-ril.git diff --git a/libril/ril.cpp b/libril/ril.cpp index 3476232..65edba1 100644 --- a/libril/ril.cpp +++ b/libril/ril.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -72,6 +73,8 @@ namespace android { #define NUM_ELEMS(a) (sizeof (a) / sizeof (a)[0]) +#define MIN(a,b) ((a)<(b) ? (a) : (b)) + /* Constants for response types */ #define RESPONSE_SOLICITED 0 #define RESPONSE_UNSOLICITED 1 @@ -132,7 +135,7 @@ typedef struct RequestInfo { char local; // responses to local commands do not go back to command process } RequestInfo; -typedef struct UserCallbackInfo{ +typedef struct UserCallbackInfo { RIL_TimedCallback p_callback; void *userParam; struct ril_event event; @@ -199,6 +202,11 @@ static void dispatchCallForward(Parcel& p, RequestInfo *pRI); static void dispatchRaw(Parcel& p, RequestInfo *pRI); static void dispatchSmsWrite (Parcel &p, RequestInfo *pRI); +static void dispatchCdmaSms(Parcel &p, RequestInfo *pRI); +static void dispatchCdmaSmsAck(Parcel &p, RequestInfo *pRI); +static void dispatchGsmBrSmsCnf(Parcel &p, RequestInfo *pRI); +static void dispatchCdmaBrSmsCnf(Parcel &p, RequestInfo *pRI); +static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI); static int responseInts(Parcel &p, void *response, size_t responselen); static int responseStrings(Parcel &p, void *response, size_t responselen); static int responseString(Parcel &p, void *response, size_t responselen); @@ -207,10 +215,19 @@ static int responseCallList(Parcel &p, void *response, size_t responselen); static int responseSMS(Parcel &p, void *response, size_t responselen); static int responseSIM_IO(Parcel &p, void *response, size_t responselen); static int responseCallForwards(Parcel &p, void *response, size_t responselen); -static int responseContexts(Parcel &p, void *response, size_t responselen); +static int responseDataCallList(Parcel &p, void *response, size_t responselen); static int responseRaw(Parcel &p, void *response, size_t responselen); static int responseSsn(Parcel &p, void *response, size_t responselen); +static int responseSimStatus(Parcel &p, void *response, size_t responselen); +static int responseGsmBrSmsCnf(Parcel &p, void *response, size_t responselen); +static int responseCdmaBrSmsCnf(Parcel &p, void *response, size_t responselen); +static int responseCdmaSms(Parcel &p, void *response, size_t responselen); static int responseCellList(Parcel &p, void *response, size_t responselen); +static int responseCdmaInformationRecords(Parcel &p,void *response, size_t responselen); +static int responseRilSignalStrength(Parcel &p,void *response, size_t responselen); +static int responseCallRing(Parcel &p, void *response, size_t responselen); +static int responseCdmaSignalInfoRecord(Parcel &p,void *response, size_t responselen); +static int responseCdmaCallWaiting(Parcel &p,void *response, size_t responselen); extern "C" const char * requestToString(int request); extern "C" const char * failCauseToString(RIL_Errno); @@ -237,8 +254,7 @@ static UnsolResponseInfo s_unsolResponses[] = { static char * -strdupReadString(Parcel &p) -{ +strdupReadString(Parcel &p) { size_t stringlen; const char16_t *s16; @@ -247,8 +263,7 @@ strdupReadString(Parcel &p) return strndup16to8(s16, stringlen); } -static void writeStringToParcel(Parcel &p, const char *s) -{ +static void writeStringToParcel(Parcel &p, const char *s) { char16_t *s16; size_t s16_len; s16 = strdup8to16(s, &s16_len); @@ -258,8 +273,7 @@ static void writeStringToParcel(Parcel &p, const char *s) static void -memsetString (char *s) -{ +memsetString (char *s) { if (s != NULL) { memset (s, 0, strlen(s)); } @@ -267,8 +281,7 @@ memsetString (char *s) void nullParcelReleaseFunction (const uint8_t* data, size_t dataSize, const size_t* objects, size_t objectsSize, - void* cookie) -{ + void* cookie) { // do nothing -- the data reference lives longer than the Parcel object } @@ -278,8 +291,7 @@ void nullParcelReleaseFunction (const uint8_t* data, size_t dataSize, * is not sent back up to the command process */ static void -issueLocalRequest(int request, void *data, int len) -{ +issueLocalRequest(int request, void *data, int len) { RequestInfo *pRI; int ret; @@ -306,8 +318,7 @@ issueLocalRequest(int request, void *data, int len) static int -processCommandBuffer(void *buffer, size_t buflen) -{ +processCommandBuffer(void *buffer, size_t buflen) { Parcel p; status_t status; int32_t request; @@ -355,16 +366,14 @@ processCommandBuffer(void *buffer, size_t buflen) } static void -invalidCommandBlock (RequestInfo *pRI) -{ +invalidCommandBlock (RequestInfo *pRI) { LOGE("invalid command block for token %d request %s", pRI->token, requestToString(pRI->pCI->requestNumber)); } /** Callee expects NULL */ static void -dispatchVoid (Parcel& p, RequestInfo *pRI) -{ +dispatchVoid (Parcel& p, RequestInfo *pRI) { clearPrintBuf; printRequest(pRI->token, pRI->pCI->requestNumber); s_callbacks.onRequest(pRI->pCI->requestNumber, NULL, 0, pRI); @@ -372,8 +381,7 @@ dispatchVoid (Parcel& p, RequestInfo *pRI) /** Callee expects const char * */ static void -dispatchString (Parcel& p, RequestInfo *pRI) -{ +dispatchString (Parcel& p, RequestInfo *pRI) { status_t status; size_t datalen; size_t stringlen; @@ -402,8 +410,7 @@ invalid: /** Callee expects const char ** */ static void -dispatchStrings (Parcel &p, RequestInfo *pRI) -{ +dispatchStrings (Parcel &p, RequestInfo *pRI) { int32_t countStrings; status_t status; size_t datalen; @@ -460,8 +467,7 @@ invalid: /** Callee expects const int * */ static void -dispatchInts (Parcel &p, RequestInfo *pRI) -{ +dispatchInts (Parcel &p, RequestInfo *pRI) { int32_t count; status_t status; size_t datalen; @@ -513,8 +519,7 @@ invalid: * String pdu */ static void -dispatchSmsWrite (Parcel &p, RequestInfo *pRI) -{ +dispatchSmsWrite (Parcel &p, RequestInfo *pRI) { RIL_SMS_WriteArgs args; int32_t t; status_t status; @@ -563,8 +568,7 @@ invalid: * int32_t clir */ static void -dispatchDial (Parcel &p, RequestInfo *pRI) -{ +dispatchDial (Parcel &p, RequestInfo *pRI) { RIL_Dial dial; int32_t t; status_t status; @@ -614,8 +618,7 @@ invalid: * String pin2 */ static void -dispatchSIM_IO (Parcel &p, RequestInfo *pRI) -{ +dispatchSIM_IO (Parcel &p, RequestInfo *pRI) { RIL_SIM_IO simIO; int32_t t; status_t status; @@ -689,8 +692,7 @@ invalid: * int32_t timeSeconds */ static void -dispatchCallForward(Parcel &p, RequestInfo *pRI) -{ +dispatchCallForward(Parcel &p, RequestInfo *pRI) { RIL_CallForwardInfo cff; int32_t t; status_t status; @@ -753,8 +755,7 @@ invalid: static void -dispatchRaw(Parcel &p, RequestInfo *pRI) -{ +dispatchRaw(Parcel &p, RequestInfo *pRI) { int32_t len; status_t status; const void *data; @@ -786,9 +787,349 @@ invalid: return; } +static void +dispatchCdmaSms(Parcel &p, RequestInfo *pRI) { + RIL_CDMA_SMS_Message rcsm; + int32_t t; + uint8_t ut; + status_t status; + int32_t digitCount; + int digitLimit; + + memset(&rcsm, 0, sizeof(rcsm)); + + status = p.readInt32(&t); + rcsm.uTeleserviceID = (int) t; + + status = p.read(&ut,sizeof(ut)); + rcsm.bIsServicePresent = (uint8_t) ut; + + status = p.readInt32(&t); + rcsm.uServicecategory = (int) t; + + status = p.readInt32(&t); + rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) t; + + status = p.readInt32(&t); + rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) t; + + status = p.readInt32(&t); + rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) t; + + status = p.readInt32(&t); + rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) t; + + status = p.read(&ut,sizeof(ut)); + rcsm.sAddress.number_of_digits= (uint8_t) ut; + + digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX); + for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { + status = p.read(&ut,sizeof(ut)); + rcsm.sAddress.digits[digitCount] = (uint8_t) ut; + } + + status = p.readInt32(&t); + rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) t; + + status = p.read(&ut,sizeof(ut)); + rcsm.sSubAddress.odd = (uint8_t) ut; + + status = p.read(&ut,sizeof(ut)); + rcsm.sSubAddress.number_of_digits = (uint8_t) ut; + + digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX); + for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { + status = p.read(&ut,sizeof(ut)); + rcsm.sSubAddress.digits[digitCount] = (uint8_t) ut; + } + + status = p.readInt32(&t); + rcsm.uBearerDataLen = (int) t; + + digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX); + for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { + status = p.read(&ut, sizeof(ut)); + rcsm.aBearerData[digitCount] = (uint8_t) ut; + } + + if (status != NO_ERROR) { + goto invalid; + } + + startRequest; + appendPrintBuf("%suTeleserviceID=%d, bIsServicePresent=%d, uServicecategory=%d, \ + sAddress.digit_mode=%d, sAddress.Number_mode=%d, sAddress.number_type=%d, ", + printBuf, rcsm.uTeleserviceID,rcsm.bIsServicePresent,rcsm.uServicecategory, + rcsm.sAddress.digit_mode, rcsm.sAddress.number_mode,rcsm.sAddress.number_type); + closeRequest; + + printRequest(pRI->token, pRI->pCI->requestNumber); + + s_callbacks.onRequest(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm),pRI); + +#ifdef MEMSET_FREED + memset(&rcsm, 0, sizeof(rcsm)); +#endif + + return; + +invalid: + invalidCommandBlock(pRI); + return; +} + +static void +dispatchCdmaSmsAck(Parcel &p, RequestInfo *pRI) { + RIL_CDMA_SMS_Ack rcsa; + int32_t t; + status_t status; + int32_t digitCount; + + memset(&rcsa, 0, sizeof(rcsa)); + + status = p.readInt32(&t); + rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) t; + + status = p.readInt32(&t); + rcsa.uSMSCauseCode = (int) t; + + if (status != NO_ERROR) { + goto invalid; + } + + startRequest; + appendPrintBuf("%suErrorClass=%d, uTLStatus=%d, ", + printBuf, rcsa.uErrorClass, rcsa.uSMSCauseCode); + closeRequest; + + printRequest(pRI->token, pRI->pCI->requestNumber); + + s_callbacks.onRequest(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa),pRI); + +#ifdef MEMSET_FREED + memset(&rcsa, 0, sizeof(rcsa)); +#endif + + return; + +invalid: + invalidCommandBlock(pRI); + return; +} + +static void +dispatchGsmBrSmsCnf(Parcel &p, RequestInfo *pRI) { + int32_t t; + status_t status; + int32_t num; + + status = p.readInt32(&num); + if (status != NO_ERROR) { + goto invalid; + } + + RIL_GSM_BroadcastSmsConfigInfo gsmBci[num]; + RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num]; + + startRequest; + for (int i = 0 ; i < num ; i++ ) { + gsmBciPtrs[i] = &gsmBci[i]; + + status = p.readInt32(&t); + gsmBci[i].fromServiceId = (int) t; + + status = p.readInt32(&t); + gsmBci[i].toServiceId = (int) t; + + status = p.readInt32(&t); + gsmBci[i].fromCodeScheme = (int) t; + + status = p.readInt32(&t); + gsmBci[i].toCodeScheme = (int) t; + + status = p.readInt32(&t); + gsmBci[i].selected = (uint8_t) t; + + appendPrintBuf("%s [%d: fromServiceId=%d, toServiceId =%d, \ + fromCodeScheme=%d, toCodeScheme=%d, selected =%d]", printBuf, i, + gsmBci[i].fromServiceId, gsmBci[i].toServiceId, + gsmBci[i].fromCodeScheme, gsmBci[i].toCodeScheme, + gsmBci[i].selected); + } + closeRequest; + + if (status != NO_ERROR) { + goto invalid; + } + + s_callbacks.onRequest(pRI->pCI->requestNumber, + gsmBciPtrs, + num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), + pRI); + +#ifdef MEMSET_FREED + memset(gsmBci, 0, num * sizeof(RIL_GSM_BroadcastSmsConfigInfo)); + memset(gsmBciPtrs, 0, num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *)); +#endif + + return; + +invalid: + invalidCommandBlock(pRI); + return; +} + +static void +dispatchCdmaBrSmsCnf(Parcel &p, RequestInfo *pRI) { + int32_t t; + status_t status; + int32_t num; + + status = p.readInt32(&num); + if (status != NO_ERROR) { + goto invalid; + } + + RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num]; + RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num]; + + startRequest; + for (int i = 0 ; i < num ; i++ ) { + cdmaBciPtrs[i] = &cdmaBci[i]; + + status = p.readInt32(&t); + cdmaBci[i].service_category = (int) t; + + status = p.readInt32(&t); + cdmaBci[i].language = (int) t; + + status = p.readInt32(&t); + cdmaBci[i].selected = (uint8_t) t; + + appendPrintBuf("%s [%d: service_category=%d, language =%d, \ + entries.bSelected =%d]", printBuf, i, cdmaBci[i].service_category, + cdmaBci[i].language, cdmaBci[i].selected); + } + closeRequest; + + if (status != NO_ERROR) { + goto invalid; + } + + s_callbacks.onRequest(pRI->pCI->requestNumber, + cdmaBciPtrs, + num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), + pRI); + +#ifdef MEMSET_FREED + memset(cdmaBci, 0, num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo)); + memset(cdmaBciPtrs, 0, num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *)); +#endif + + return; + +invalid: + invalidCommandBlock(pRI); + return; +} + +static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI) { + RIL_CDMA_SMS_WriteArgs rcsw; + int32_t t; + uint32_t ut; + uint8_t uct; + status_t status; + int32_t digitCount; + + memset(&rcsw, 0, sizeof(rcsw)); + + status = p.readInt32(&t); + rcsw.status = t; + + status = p.readInt32(&t); + rcsw.message.uTeleserviceID = (int) t; + + status = p.read(&uct,sizeof(uct)); + rcsw.message.bIsServicePresent = (uint8_t) uct; + + status = p.readInt32(&t); + rcsw.message.uServicecategory = (int) t; + + status = p.readInt32(&t); + rcsw.message.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) t; + + status = p.readInt32(&t); + rcsw.message.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) t; + + status = p.readInt32(&t); + rcsw.message.sAddress.number_type = (RIL_CDMA_SMS_NumberType) t; + + status = p.readInt32(&t); + rcsw.message.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) t; + + status = p.read(&uct,sizeof(uct)); + rcsw.message.sAddress.number_of_digits = (uint8_t) uct; + + for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_ADDRESS_MAX; digitCount ++) { + status = p.read(&uct,sizeof(uct)); + rcsw.message.sAddress.digits[digitCount] = (uint8_t) uct; + } + + status = p.readInt32(&t); + rcsw.message.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) t; + + status = p.read(&uct,sizeof(uct)); + rcsw.message.sSubAddress.odd = (uint8_t) uct; + + status = p.read(&uct,sizeof(uct)); + rcsw.message.sSubAddress.number_of_digits = (uint8_t) uct; + + for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_SUBADDRESS_MAX; digitCount ++) { + status = p.read(&uct,sizeof(uct)); + rcsw.message.sSubAddress.digits[digitCount] = (uint8_t) uct; + } + + status = p.readInt32(&t); + rcsw.message.uBearerDataLen = (int) t; + + for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_BEARER_DATA_MAX; digitCount ++) { + status = p.read(&uct, sizeof(uct)); + rcsw.message.aBearerData[digitCount] = (uint8_t) uct; + } + + if (status != NO_ERROR) { + goto invalid; + } + + startRequest; + appendPrintBuf("%sstatus=%d, message.uTeleserviceID=%d, message.bIsServicePresent=%d, \ + message.uServicecategory=%d, message.sAddress.digit_mode=%d, \ + message.sAddress.number_mode=%d, \ + message.sAddress.number_type=%d, ", + printBuf, rcsw.status, rcsw.message.uTeleserviceID, rcsw.message.bIsServicePresent, + rcsw.message.uServicecategory, rcsw.message.sAddress.digit_mode, + rcsw.message.sAddress.number_mode, + rcsw.message.sAddress.number_type); + closeRequest; + + printRequest(pRI->token, pRI->pCI->requestNumber); + + s_callbacks.onRequest(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw),pRI); + +#ifdef MEMSET_FREED + memset(&rcsw, 0, sizeof(rcsw)); +#endif + + return; + +invalid: + invalidCommandBlock(pRI); + return; + +} + static int -blockingWrite(int fd, const void *buffer, size_t len) -{ +blockingWrite(int fd, const void *buffer, size_t len) { size_t writeOffset = 0; const uint8_t *toWrite; @@ -814,8 +1155,7 @@ blockingWrite(int fd, const void *buffer, size_t len) } static int -sendResponseRaw (const void *data, size_t dataSize) -{ +sendResponseRaw (const void *data, size_t dataSize) { int fd = s_fdCommand; int ret; uint32_t header; @@ -856,8 +1196,7 @@ sendResponseRaw (const void *data, size_t dataSize) } static int -sendResponse (Parcel &p) -{ +sendResponse (Parcel &p) { printResponse; return sendResponseRaw(p.data(), p.dataSize()); } @@ -865,8 +1204,7 @@ sendResponse (Parcel &p) /** response is an int* pointing to an array of ints*/ static int -responseInts(Parcel &p, void *response, size_t responselen) -{ +responseInts(Parcel &p, void *response, size_t responselen) { int numInts; if (response == NULL && responselen != 0) { @@ -897,8 +1235,7 @@ responseInts(Parcel &p, void *response, size_t responselen) } /** response is a char **, pointing to an array of char *'s */ -static int responseStrings(Parcel &p, void *response, size_t responselen) -{ +static int responseStrings(Parcel &p, void *response, size_t responselen) { int numStrings; if (response == NULL && responselen != 0) { @@ -936,8 +1273,7 @@ static int responseStrings(Parcel &p, void *response, size_t responselen) * NULL strings are accepted * FIXME currently ignores responselen */ -static int responseString(Parcel &p, void *response, size_t responselen) -{ +static int responseString(Parcel &p, void *response, size_t responselen) { /* one string only */ startResponse; appendPrintBuf("%s%s", printBuf, (char*)response); @@ -948,15 +1284,13 @@ static int responseString(Parcel &p, void *response, size_t responselen) return 0; } -static int responseVoid(Parcel &p, void *response, size_t responselen) -{ +static int responseVoid(Parcel &p, void *response, size_t responselen) { startResponse; removeLastChar; return 0; } -static int responseCallList(Parcel &p, void *response, size_t responselen) -{ +static int responseCallList(Parcel &p, void *response, size_t responselen) { int num; if (response == NULL && responselen != 0) { @@ -965,7 +1299,7 @@ static int responseCallList(Parcel &p, void *response, size_t responselen) } if (responselen % sizeof (RIL_Call *) != 0) { - LOGE("invalid response length %d expected multiple of %d\n", + LOGE("invalid response length %d expected multiple of %d\n", (int)responselen, (int)sizeof (RIL_Call *)); return RIL_ERRNO_INVALID_RESPONSE; } @@ -985,15 +1319,29 @@ static int responseCallList(Parcel &p, void *response, size_t responselen) p.writeInt32(p_cur->isMT); p.writeInt32(p_cur->als); p.writeInt32(p_cur->isVoice); - writeStringToParcel (p, p_cur->number); - appendPrintBuf("%s[%s,id=%d,toa=%d,%s,%s,als=%d,%s,%s],", printBuf, + p.writeInt32(p_cur->isVoicePrivacy); + writeStringToParcel(p, p_cur->number); + p.writeInt32(p_cur->numberPresentation); + writeStringToParcel(p, p_cur->name); + p.writeInt32(p_cur->namePresentation); + appendPrintBuf("%s[id=%d,%s,toa=%d,", + printBuf, + p_cur->index, callStateToString(p_cur->state), - p_cur->index, p_cur->toa, - (p_cur->isMpty)?"mpty":"norm", + p_cur->toa); + appendPrintBuf("%s%s,%s,als=%d,%s,%s,", + printBuf, + (p_cur->isMpty)?"conf":"norm", (p_cur->isMT)?"mt":"mo", p_cur->als, (p_cur->isVoice)?"voc":"nonvoc", - (char*)p_cur->number); + (p_cur->isVoicePrivacy)?"evp":"noevp"); + appendPrintBuf("%s%s,cli=%d,name='%s',%d]", + printBuf, + p_cur->number, + p_cur->numberPresentation, + p_cur->name, + p_cur->namePresentation); } removeLastChar; closeResponse; @@ -1001,8 +1349,7 @@ static int responseCallList(Parcel &p, void *response, size_t responselen) return 0; } -static int responseSMS(Parcel &p, void *response, size_t responselen) -{ +static int responseSMS(Parcel &p, void *response, size_t responselen) { if (response == NULL) { LOGE("invalid response: NULL"); return RIL_ERRNO_INVALID_RESPONSE; @@ -1027,23 +1374,23 @@ static int responseSMS(Parcel &p, void *response, size_t responselen) return 0; } -static int responseContexts(Parcel &p, void *response, size_t responselen) +static int responseDataCallList(Parcel &p, void *response, size_t responselen) { if (response == NULL && responselen != 0) { LOGE("invalid response: NULL"); return RIL_ERRNO_INVALID_RESPONSE; } - if (responselen % sizeof(RIL_PDP_Context_Response) != 0) { + if (responselen % sizeof(RIL_Data_Call_Response) != 0) { LOGE("invalid response length %d expected multiple of %d", - (int)responselen, (int)sizeof(RIL_PDP_Context_Response)); + (int)responselen, (int)sizeof(RIL_Data_Call_Response)); return RIL_ERRNO_INVALID_RESPONSE; } - int num = responselen / sizeof(RIL_PDP_Context_Response); + int num = responselen / sizeof(RIL_Data_Call_Response); p.writeInt32(num); - RIL_PDP_Context_Response *p_cur = (RIL_PDP_Context_Response *) response; + RIL_Data_Call_Response *p_cur = (RIL_Data_Call_Response *) response; startResponse; int i; for (i = 0; i < num; i++) { @@ -1065,8 +1412,7 @@ static int responseContexts(Parcel &p, void *response, size_t responselen) return 0; } -static int responseRaw(Parcel &p, void *response, size_t responselen) -{ +static int responseRaw(Parcel &p, void *response, size_t responselen) { if (response == NULL && responselen != 0) { LOGE("invalid response: NULL with responselen != 0"); return RIL_ERRNO_INVALID_RESPONSE; @@ -1084,8 +1430,7 @@ static int responseRaw(Parcel &p, void *response, size_t responselen) } -static int responseSIM_IO(Parcel &p, void *response, size_t responselen) -{ +static int responseSIM_IO(Parcel &p, void *response, size_t responselen) { if (response == NULL) { LOGE("invalid response: NULL"); return RIL_ERRNO_INVALID_RESPONSE; @@ -1111,8 +1456,7 @@ static int responseSIM_IO(Parcel &p, void *response, size_t responselen) return 0; } -static int responseCallForwards(Parcel &p, void *response, size_t responselen) -{ +static int responseCallForwards(Parcel &p, void *response, size_t responselen) { int num; if (response == NULL && responselen != 0) { @@ -1152,8 +1496,7 @@ static int responseCallForwards(Parcel &p, void *response, size_t responselen) return 0; } -static int responseSsn(Parcel &p, void *response, size_t responselen) -{ +static int responseSsn(Parcel &p, void *response, size_t responselen) { if (response == NULL) { LOGE("invalid response: NULL"); return RIL_ERRNO_INVALID_RESPONSE; @@ -1182,8 +1525,7 @@ static int responseSsn(Parcel &p, void *response, size_t responselen) return 0; } -static int responseCellList(Parcel &p, void *response, size_t responselen) -{ +static int responseCellList(Parcel &p, void *response, size_t responselen) { int num; if (response == NULL && responselen != 0) { @@ -1198,14 +1540,13 @@ static int responseCellList(Parcel &p, void *response, size_t responselen) } startResponse; - /* number of cell info's */ + /* number of records */ num = responselen / sizeof(RIL_NeighboringCell *); p.writeInt32(num); for (int i = 0 ; i < num ; i++) { RIL_NeighboringCell *p_cur = ((RIL_NeighboringCell **) response)[i]; - /* each cell info */ p.writeInt32(p_cur->rssi); writeStringToParcel (p, p_cur->cid); @@ -1218,8 +1559,317 @@ static int responseCellList(Parcel &p, void *response, size_t responselen) return 0; } -static void triggerEvLoop() -{ +/** + * Marshall the signalInfoRecord into the parcel if it exists. + */ +static void marshallSignalInfoRecord(Parcel &p, + RIL_CDMA_SignalInfoRecord &p_signalInfoRecord) { + p.writeInt32(p_signalInfoRecord.isPresent); + p.writeInt32(p_signalInfoRecord.signalType); + p.writeInt32(p_signalInfoRecord.alertPitch); + p.writeInt32(p_signalInfoRecord.signal); +} + +static int responseCdmaInformationRecords(Parcel &p, + void *response, size_t responselen) { + int num; + char* string8 = NULL; + int buffer_lenght; + RIL_CDMA_InformationRecord *infoRec; + + if (response == NULL && responselen != 0) { + LOGE("invalid response: NULL"); + return RIL_ERRNO_INVALID_RESPONSE; + } + + if (responselen != sizeof (RIL_CDMA_InformationRecords)) { + LOGE("invalid response length %d expected multiple of %d\n", + (int)responselen, (int)sizeof (RIL_CDMA_InformationRecords *)); + return RIL_ERRNO_INVALID_RESPONSE; + } + + RIL_CDMA_InformationRecords *p_cur = + (RIL_CDMA_InformationRecords *) response; + num = MIN(p_cur->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS); + + startResponse; + p.writeInt32(num); + + for (int i = 0 ; i < num ; i++) { + infoRec = &p_cur->infoRec[i]; + p.writeInt32(infoRec->name); + switch (infoRec->name) { + case RIL_CDMA_DISPLAY_INFO_REC: + case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: + if (infoRec->rec.display.alpha_len > + CDMA_ALPHA_INFO_BUFFER_LENGTH) { + LOGE("invalid display info response length %d \ + expected not more than %d\n", + (int)infoRec->rec.display.alpha_len, + CDMA_ALPHA_INFO_BUFFER_LENGTH); + return RIL_ERRNO_INVALID_RESPONSE; + } + string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) + * sizeof(char) ); + for (int i = 0 ; i < infoRec->rec.display.alpha_len ; i++) { + string8[i] = infoRec->rec.display.alpha_buf[i]; + } + string8[infoRec->rec.display.alpha_len] = '\0'; + writeStringToParcel(p, (const char*)string8); + free(string8); + string8 = NULL; + break; + case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC: + case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC: + case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: + if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) { + LOGE("invalid display info response length %d \ + expected not more than %d\n", + (int)infoRec->rec.number.len, + CDMA_NUMBER_INFO_BUFFER_LENGTH); + return RIL_ERRNO_INVALID_RESPONSE; + } + string8 = (char*) malloc((infoRec->rec.number.len + 1) + * sizeof(char) ); + for (int i = 0 ; i < infoRec->rec.number.len; i++) { + string8[i] = infoRec->rec.number.buf[i]; + } + string8[infoRec->rec.number.len] = '\0'; + writeStringToParcel(p, (const char*)string8); + free(string8); + string8 = NULL; + p.writeInt32(infoRec->rec.number.number_type); + p.writeInt32(infoRec->rec.number.number_plan); + p.writeInt32(infoRec->rec.number.pi); + p.writeInt32(infoRec->rec.number.si); + break; + case RIL_CDMA_SIGNAL_INFO_REC: + p.writeInt32(infoRec->rec.signal.isPresent); + p.writeInt32(infoRec->rec.signal.signalType); + p.writeInt32(infoRec->rec.signal.alertPitch); + p.writeInt32(infoRec->rec.signal.signal); + + appendPrintBuf("%sisPresent=%X, signalType=%X, \ + alertPitch=%X, signal=%X, ", + printBuf, (int)infoRec->rec.signal.isPresent, + (int)infoRec->rec.signal.signalType, + (int)infoRec->rec.signal.alertPitch, + (int)infoRec->rec.signal.signal); + removeLastChar; + break; + case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: + if (infoRec->rec.redir.redirectingNumber.len > + CDMA_NUMBER_INFO_BUFFER_LENGTH) { + LOGE("invalid display info response length %d \ + expected not more than %d\n", + (int)infoRec->rec.redir.redirectingNumber.len, + CDMA_NUMBER_INFO_BUFFER_LENGTH); + return RIL_ERRNO_INVALID_RESPONSE; + } + string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber + .len + 1) * sizeof(char) ); + for (int i = 0; + i < infoRec->rec.redir.redirectingNumber.len; + i++) { + string8[i] = infoRec->rec.redir.redirectingNumber.buf[i]; + } + string8[infoRec->rec.redir.redirectingNumber.len] = '\0'; + writeStringToParcel(p, (const char*)string8); + free(string8); + string8 = NULL; + p.writeInt32(infoRec->rec.redir.redirectingNumber.number_type); + p.writeInt32(infoRec->rec.redir.redirectingNumber.number_plan); + p.writeInt32(infoRec->rec.redir.redirectingNumber.pi); + p.writeInt32(infoRec->rec.redir.redirectingNumber.si); + p.writeInt32(infoRec->rec.redir.redirectingReason); + break; + case RIL_CDMA_LINE_CONTROL_INFO_REC: + p.writeInt32(infoRec->rec.lineCtrl.lineCtrlPolarityIncluded); + p.writeInt32(infoRec->rec.lineCtrl.lineCtrlToggle); + p.writeInt32(infoRec->rec.lineCtrl.lineCtrlReverse); + p.writeInt32(infoRec->rec.lineCtrl.lineCtrlPowerDenial); + + appendPrintBuf("%slineCtrlPolarityIncluded=%d, \ + lineCtrlToggle=%d, lineCtrlReverse=%d, \ + lineCtrlPowerDenial=%d, ", printBuf, + (int)infoRec->rec.lineCtrl.lineCtrlPolarityIncluded, + (int)infoRec->rec.lineCtrl.lineCtrlToggle, + (int)infoRec->rec.lineCtrl.lineCtrlReverse, + (int)infoRec->rec.lineCtrl.lineCtrlPowerDenial); + removeLastChar; + break; + case RIL_CDMA_T53_CLIR_INFO_REC: + p.writeInt32((int)(infoRec->rec.clir.cause)); + + appendPrintBuf("%scause%d", printBuf, infoRec->rec.clir.cause); + removeLastChar; + break; + case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: + p.writeInt32(infoRec->rec.audioCtrl.upLink); + p.writeInt32(infoRec->rec.audioCtrl.downLink); + + appendPrintBuf("%supLink=%d, downLink=%d, ", printBuf, + infoRec->rec.audioCtrl.upLink, + infoRec->rec.audioCtrl.downLink); + removeLastChar; + break; + case RIL_CDMA_T53_RELEASE_INFO_REC: + // TODO(Moto): See David Krause, he has the answer:) + LOGE("RIL_CDMA_T53_RELEASE_INFO_REC: return INVALID_RESPONSE"); + return RIL_ERRNO_INVALID_RESPONSE; + default: + LOGE("Incorrect name value"); + return RIL_ERRNO_INVALID_RESPONSE; + } + } + closeResponse; + + return 0; +} + +static int responseRilSignalStrength(Parcel &p, + void *response, size_t responselen) { + if (response == NULL && responselen != 0) { + LOGE("invalid response: NULL"); + return RIL_ERRNO_INVALID_RESPONSE; + } + + if (responselen == sizeof (RIL_SignalStrength)) { + // New RIL + RIL_SignalStrength *p_cur = ((RIL_SignalStrength *) response); + + p.writeInt32(p_cur->GW_SignalStrength.signalStrength); + p.writeInt32(p_cur->GW_SignalStrength.bitErrorRate); + p.writeInt32(p_cur->CDMA_SignalStrength.dbm); + p.writeInt32(p_cur->CDMA_SignalStrength.ecio); + p.writeInt32(p_cur->EVDO_SignalStrength.dbm); + p.writeInt32(p_cur->EVDO_SignalStrength.ecio); + p.writeInt32(p_cur->EVDO_SignalStrength.signalNoiseRatio); + + startResponse; + appendPrintBuf("%s[signalStrength=%d,bitErrorRate=%d,\ + CDMA_SignalStrength.dbm=%d,CDMA_SignalStrength.ecio=%d,\ + EVDO_SignalStrength.dbm =%d,EVDO_SignalStrength.ecio=%d,\ + EVDO_SignalStrength.signalNoiseRatio=%d]", + printBuf, + p_cur->GW_SignalStrength.signalStrength, + p_cur->GW_SignalStrength.bitErrorRate, + p_cur->CDMA_SignalStrength.dbm, + p_cur->CDMA_SignalStrength.ecio, + p_cur->EVDO_SignalStrength.dbm, + p_cur->EVDO_SignalStrength.ecio, + p_cur->EVDO_SignalStrength.signalNoiseRatio); + + closeResponse; + + } else if (responselen % sizeof (int) == 0) { + // Old RIL deprecated + int *p_cur = (int *) response; + + startResponse; + + // With the Old RIL we see one or 2 integers. + size_t num = responselen / sizeof (int); // Number of integers from ril + size_t totalIntegers = 7; // Number of integers in RIL_SignalStrength + size_t i; + + appendPrintBuf("%s[", printBuf); + for (i = 0; i < num; i++) { + appendPrintBuf("%s %d", printBuf, *p_cur); + p.writeInt32(*p_cur++); + } + appendPrintBuf("%s]", printBuf); + + // Fill the remainder with zero's. + for (; i < totalIntegers; i++) { + p.writeInt32(0); + } + + closeResponse; + } else { + LOGE("invalid response length"); + return RIL_ERRNO_INVALID_RESPONSE; + } + + return 0; +} + +static int responseCallRing(Parcel &p, void *response, size_t responselen) { + if ((response == NULL) || (responselen == 0)) { + return responseVoid(p, response, responselen); + } else { + return responseCdmaSignalInfoRecord(p, response, responselen); + } +} + +static int responseCdmaSignalInfoRecord(Parcel &p, void *response, size_t responselen) { + if (response == NULL || responselen == 0) { + LOGE("invalid response: NULL"); + return RIL_ERRNO_INVALID_RESPONSE; + } + + if (responselen != sizeof (RIL_CDMA_SignalInfoRecord)) { + LOGE("invalid response length %d expected sizeof (RIL_CDMA_SignalInfoRecord) of %d\n", + (int)responselen, (int)sizeof (RIL_CDMA_SignalInfoRecord)); + return RIL_ERRNO_INVALID_RESPONSE; + } + + startResponse; + + RIL_CDMA_SignalInfoRecord *p_cur = ((RIL_CDMA_SignalInfoRecord *) response); + marshallSignalInfoRecord(p, *p_cur); + + appendPrintBuf("%s[isPresent=%d,signalType=%d,alertPitch=%d\ + signal=%d]", + printBuf, + p_cur->isPresent, + p_cur->signalType, + p_cur->alertPitch, + p_cur->signal); + + closeResponse; + return 0; +} + +static int responseCdmaCallWaiting(Parcel &p, void *response, + size_t responselen) { + if (response == NULL && responselen != 0) { + LOGE("invalid response: NULL"); + return RIL_ERRNO_INVALID_RESPONSE; + } + + if (responselen != sizeof(RIL_CDMA_CallWaiting)) { + LOGE("invalid response length %d expected %d\n", + (int)responselen, (int)sizeof(RIL_CDMA_CallWaiting)); + return RIL_ERRNO_INVALID_RESPONSE; + } + + startResponse; + RIL_CDMA_CallWaiting *p_cur = ((RIL_CDMA_CallWaiting *) response); + + writeStringToParcel (p, p_cur->number); + p.writeInt32(p_cur->numberPresentation); + writeStringToParcel (p, p_cur->name); + marshallSignalInfoRecord(p, p_cur->signalInfoRecord); + + appendPrintBuf("%snumber=%s,numberPresentation=%d, name=%s,\ + signalInfoRecord[isPresent=%d,signalType=%d,alertPitch=%d\ + signal=%d]", + printBuf, + p_cur->number, + p_cur->numberPresentation, + p_cur->name, + p_cur->signalInfoRecord.isPresent, + p_cur->signalInfoRecord.signalType, + p_cur->signalInfoRecord.alertPitch, + p_cur->signalInfoRecord.signal); + + closeResponse; + + return 0; +} + +static void triggerEvLoop() { int ret; if (!pthread_equal(pthread_self(), s_tid_dispatch)) { /* trigger event loop to wakeup. No reason to do this, @@ -1230,19 +1880,173 @@ static void triggerEvLoop() } } -static void rilEventAddWakeup(struct ril_event *ev) -{ +static void rilEventAddWakeup(struct ril_event *ev) { ril_event_add(ev); triggerEvLoop(); } +static int responseSimStatus(Parcel &p, void *response, size_t responselen) { + int i; + + if (response == NULL && responselen != 0) { + LOGE("invalid response: NULL"); + return RIL_ERRNO_INVALID_RESPONSE; + } + + if (responselen % sizeof (RIL_CardStatus *) != 0) { + LOGE("invalid response length %d expected multiple of %d\n", + (int)responselen, (int)sizeof (RIL_CardStatus *)); + return RIL_ERRNO_INVALID_RESPONSE; + } + + RIL_CardStatus *p_cur = ((RIL_CardStatus *) response); + + p.writeInt32(p_cur->card_state); + p.writeInt32(p_cur->universal_pin_state); + p.writeInt32(p_cur->gsm_umts_subscription_app_index); + p.writeInt32(p_cur->cdma_subscription_app_index); + p.writeInt32(p_cur->num_applications); + + startResponse; + for (i = 0; i < p_cur->num_applications; i++) { + p.writeInt32(p_cur->applications[i].app_type); + p.writeInt32(p_cur->applications[i].app_state); + p.writeInt32(p_cur->applications[i].perso_substate); + writeStringToParcel(p, (const char*)(p_cur->applications[i].aid_ptr)); + writeStringToParcel(p, (const char*) + (p_cur->applications[i].app_label_ptr)); + p.writeInt32(p_cur->applications[i].pin1_replaced); + p.writeInt32(p_cur->applications[i].pin1); + p.writeInt32(p_cur->applications[i].pin2); + appendPrintBuf("%s[app_type=%d,app_state=%d,perso_substate=%d,\ + aid_ptr=%s,app_label_ptr=%s,pin1_replaced=%d,pin1=%d,pin2=%d],", + printBuf, + p_cur->applications[i].app_type, + p_cur->applications[i].app_state, + p_cur->applications[i].perso_substate, + p_cur->applications[i].aid_ptr, + p_cur->applications[i].app_label_ptr, + p_cur->applications[i].pin1_replaced, + p_cur->applications[i].pin1, + p_cur->applications[i].pin2); + } + closeResponse; + + return 0; +} + +static int responseGsmBrSmsCnf(Parcel &p, void *response, size_t responselen) { + int num = responselen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *); + p.writeInt32(num); + + startResponse; + RIL_GSM_BroadcastSmsConfigInfo **p_cur = + (RIL_GSM_BroadcastSmsConfigInfo **) response; + for (int i = 0; i < num; i++) { + p.writeInt32(p_cur[i]->fromServiceId); + p.writeInt32(p_cur[i]->toServiceId); + p.writeInt32(p_cur[i]->fromCodeScheme); + p.writeInt32(p_cur[i]->toCodeScheme); + p.writeInt32(p_cur[i]->selected); + + appendPrintBuf("%s [%d: fromServiceId=%d, toServiceId=%d, \ + fromCodeScheme=%d, toCodeScheme=%d, selected =%d]", + printBuf, i, p_cur[i]->fromServiceId, p_cur[i]->toServiceId, + p_cur[i]->fromCodeScheme, p_cur[i]->toCodeScheme, + p_cur[i]->selected); + } + closeResponse; + + return 0; +} + +static int responseCdmaBrSmsCnf(Parcel &p, void *response, size_t responselen) { + RIL_CDMA_BroadcastSmsConfigInfo **p_cur = + (RIL_CDMA_BroadcastSmsConfigInfo **) response; + + int num = responselen / sizeof (RIL_CDMA_BroadcastSmsConfigInfo *); + p.writeInt32(num); + + startResponse; + for (int i = 0 ; i < num ; i++ ) { + p.writeInt32(p_cur[i]->service_category); + p.writeInt32(p_cur[i]->language); + p.writeInt32(p_cur[i]->selected); + + appendPrintBuf("%s [%d: srvice_category=%d, language =%d, \ + selected =%d], ", + printBuf, i, p_cur[i]->service_category, p_cur[i]->language, + p_cur[i]->selected); + } + closeResponse; + + return 0; +} + +static int responseCdmaSms(Parcel &p, void *response, size_t responselen) { + int num; + int digitCount; + int digitLimit; + uint8_t uct; + void* dest; + + LOGD("Inside responseCdmaSms"); + + if (response == NULL && responselen != 0) { + LOGE("invalid response: NULL"); + return RIL_ERRNO_INVALID_RESPONSE; + } + + if (responselen != sizeof(RIL_CDMA_SMS_Message)) { + LOGE("invalid response length was %d expected %d", + (int)responselen, (int)sizeof(RIL_CDMA_SMS_Message)); + return RIL_ERRNO_INVALID_RESPONSE; + } + + RIL_CDMA_SMS_Message *p_cur = (RIL_CDMA_SMS_Message *) response; + p.writeInt32(p_cur->uTeleserviceID); + p.write(&(p_cur->bIsServicePresent),sizeof(uct)); + p.writeInt32(p_cur->uServicecategory); + p.writeInt32(p_cur->sAddress.digit_mode); + p.writeInt32(p_cur->sAddress.number_mode); + p.writeInt32(p_cur->sAddress.number_type); + p.writeInt32(p_cur->sAddress.number_plan); + p.write(&(p_cur->sAddress.number_of_digits), sizeof(uct)); + digitLimit= MIN((p_cur->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX); + for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { + p.write(&(p_cur->sAddress.digits[digitCount]),sizeof(uct)); + } + + p.writeInt32(p_cur->sSubAddress.subaddressType); + p.write(&(p_cur->sSubAddress.odd),sizeof(uct)); + p.write(&(p_cur->sSubAddress.number_of_digits),sizeof(uct)); + digitLimit= MIN((p_cur->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX); + for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { + p.write(&(p_cur->sSubAddress.digits[digitCount]),sizeof(uct)); + } + + digitLimit= MIN((p_cur->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX); + p.writeInt32(p_cur->uBearerDataLen); + for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { + p.write(&(p_cur->aBearerData[digitCount]), sizeof(uct)); + } + + startResponse; + appendPrintBuf("%suTeleserviceID=%d, bIsServicePresent=%d, uServicecategory=%d, \ + sAddress.digit_mode=%d, sAddress.number_mode=%d, sAddress.number_type=%d, ", + printBuf, p_cur->uTeleserviceID,p_cur->bIsServicePresent,p_cur->uServicecategory, + p_cur->sAddress.digit_mode, p_cur->sAddress.number_mode,p_cur->sAddress.number_type); + closeResponse; + + return 0; +} + /** * A write on the wakeup fd is done just to pop us out of select() * We empty the buffer here and then ril_event will reset the timers on the * way back down */ -static void processWakeupCallback(int fd, short flags, void *param) -{ +static void processWakeupCallback(int fd, short flags, void *param) { char buff[16]; int ret; @@ -1254,8 +2058,7 @@ static void processWakeupCallback(int fd, short flags, void *param) } while (ret > 0 || (ret < 0 && errno == EINTR)); } -static void onCommandsSocketClosed() -{ +static void onCommandsSocketClosed() { int ret; RequestInfo *p_cur; @@ -1277,8 +2080,7 @@ static void onCommandsSocketClosed() assert (ret == 0); } -static void processCommandsCallback(int fd, short flags, void *param) -{ +static void processCommandsCallback(int fd, short flags, void *param) { RecordStream *p_rs; void *p_record; size_t recordlen; @@ -1325,8 +2127,7 @@ static void processCommandsCallback(int fd, short flags, void *param) } -static void onNewCommandConnect() -{ +static void onNewCommandConnect() { // implicit radio state changed RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, NULL, 0); @@ -1353,8 +2154,7 @@ static void onNewCommandConnect() } -static void listenCallback (int fd, short flags, void *param) -{ +static void listenCallback (int fd, short flags, void *param) { int ret; int err; int is_phone_socket; @@ -1377,7 +2177,7 @@ static void listenCallback (int fd, short flags, void *param) LOGE("Error on accept() errno:%d", errno); /* start listening for new connections again */ rilEventAddWakeup(&s_listen_event); - return; + return; } /* check the credential of the other side and only accept socket from @@ -1385,23 +2185,23 @@ static void listenCallback (int fd, short flags, void *param) */ errno = 0; is_phone_socket = 0; - + err = getsockopt(s_fdCommand, SOL_SOCKET, SO_PEERCRED, &creds, &szCreds); - + if (err == 0 && szCreds > 0) { - errno = 0; - pwd = getpwuid(creds.uid); - if (pwd != NULL) { - if (strcmp(pwd->pw_name, PHONE_PROCESS) == 0) { - is_phone_socket = 1; - } else { - LOGE("RILD can't accept socket from process %s", pwd->pw_name); - } - } else { - LOGE("Error on getpwuid() errno: %d", errno); - } + errno = 0; + pwd = getpwuid(creds.uid); + if (pwd != NULL) { + if (strcmp(pwd->pw_name, PHONE_PROCESS) == 0) { + is_phone_socket = 1; + } else { + LOGE("RILD can't accept socket from process %s", pwd->pw_name); + } + } else { + LOGE("Error on getpwuid() errno: %d", errno); + } } else { - LOGD("Error on getsockopt() errno: %d", errno); + LOGD("Error on getsockopt() errno: %d", errno); } if ( !is_phone_socket ) { @@ -1445,8 +2245,7 @@ static void freeDebugCallbackArgs(int number, char **args) { free(args); } -static void debugCallback (int fd, short flags, void *param) -{ +static void debugCallback (int fd, short flags, void *param) { int acceptFD, option; struct sockaddr_un peeraddr; socklen_t socklen = sizeof (peeraddr); @@ -1482,7 +2281,7 @@ static void debugCallback (int fd, short flags, void *param) // +1 for null-term args[i] = (char *) malloc((sizeof(char) * len) + 1); if (recv(acceptFD, args[i], sizeof(char) * len, 0) - != sizeof(char) * len) { + != (int)sizeof(char) * len) { LOGE ("error reading on socket: Args[%d] \n", i); freeDebugCallbackArgs(i, args); return; @@ -1540,14 +2339,14 @@ static void debugCallback (int fd, short flags, void *param) issueLocalRequest(RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC, NULL, 0); break; case 6: - LOGI("Debug port: Setup PDP, Apn :%s\n", args[1]); + LOGI("Debug port: Setup Data Call, Apn :%s\n", args[1]); actData[0] = args[1]; - issueLocalRequest(RIL_REQUEST_SETUP_DEFAULT_PDP, &actData, + issueLocalRequest(RIL_REQUEST_SETUP_DATA_CALL, &actData, sizeof(actData)); break; case 7: - LOGI("Debug port: Deactivate PDP"); - issueLocalRequest(RIL_REQUEST_DEACTIVATE_DEFAULT_PDP, &deactData, + LOGI("Debug port: Deactivate Data Call"); + issueLocalRequest(RIL_REQUEST_DEACTIVATE_DATA_CALL, &deactData, sizeof(deactData)); break; case 8: @@ -1574,8 +2373,7 @@ static void debugCallback (int fd, short flags, void *param) } -static void userTimerCallback (int fd, short flags, void *param) -{ +static void userTimerCallback (int fd, short flags, void *param) { UserCallbackInfo *p_info; p_info = (UserCallbackInfo *)param; @@ -1593,8 +2391,7 @@ static void userTimerCallback (int fd, short flags, void *param) static void * -eventLoop(void *param) -{ +eventLoop(void *param) { int ret; int filedes[2]; @@ -1632,8 +2429,7 @@ eventLoop(void *param) } extern "C" void -RIL_startEventLoop(void) -{ +RIL_startEventLoop(void) { int ret; pthread_attr_t attr; @@ -1663,8 +2459,7 @@ extern "C" void RIL_setcallbacks (const RIL_RadioFunctions *callbacks) { } extern "C" void -RIL_register (const RIL_RadioFunctions *callbacks) -{ +RIL_register (const RIL_RadioFunctions *callbacks) { int ret; int flags; @@ -1689,11 +2484,11 @@ RIL_register (const RIL_RadioFunctions *callbacks) // Little self-check - for (int i = 0; i < (int)NUM_ELEMS(s_commands) ; i++) { + for (int i = 0; i < (int)NUM_ELEMS(s_commands); i++) { assert(i == s_commands[i].requestNumber); } - for (int i = 0; i < (int)NUM_ELEMS(s_unsolResponses) ; i++) { + for (int i = 0; i < (int)NUM_ELEMS(s_unsolResponses); i++) { assert(i + RIL_UNSOL_RESPONSE_BASE == s_unsolResponses[i].requestNumber); } @@ -1766,8 +2561,7 @@ RIL_register (const RIL_RadioFunctions *callbacks) } static int -checkAndDequeueRequestInfo(struct RequestInfo *pRI) -{ +checkAndDequeueRequestInfo(struct RequestInfo *pRI) { int ret = 0; if (pRI == NULL) { @@ -1795,8 +2589,7 @@ checkAndDequeueRequestInfo(struct RequestInfo *pRI) extern "C" void -RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responselen) -{ +RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responselen) { RequestInfo *pRI; int ret; size_t errorOffset; @@ -1853,14 +2646,12 @@ done: static void -grabPartialWakeLock() -{ +grabPartialWakeLock() { acquire_wake_lock(PARTIAL_WAKE_LOCK, ANDROID_WAKE_LOCK_NAME); } static void -releaseWakeLock() -{ +releaseWakeLock() { release_wake_lock(ANDROID_WAKE_LOCK_NAME); } @@ -1868,8 +2659,7 @@ releaseWakeLock() * Timer callback to put us back to sleep before the default timeout */ static void -wakeTimeoutCallback (void *param) -{ +wakeTimeoutCallback (void *param) { // We're using "param != NULL" as a cancellation mechanism if (param == NULL) { //LOGD("wakeTimeout: releasing wake lock"); @@ -1894,7 +2684,7 @@ void RIL_onUnsolicitedResponse(int unsolResponse, void *data, LOGW("RIL_onUnsolicitedResponse called before RIL_register"); return; } - + unsolResponseIndex = unsolResponse - RIL_UNSOL_RESPONSE_BASE; if ((unsolResponseIndex < 0) @@ -1996,7 +2786,6 @@ void RIL_onUnsolicitedResponse(int unsolResponse, void *data, return; error_exit: - // There was an error and we've got the wake lock so release it. if (shouldScheduleTimeout) { releaseWakeLock(); } @@ -2008,7 +2797,6 @@ error_exit: static UserCallbackInfo * internalRequestTimedCallback (RIL_TimedCallback callback, void *param, const struct timeval *relativeTime) - { struct timeval myRelativeTime; UserCallbackInfo *p_info; @@ -2037,14 +2825,12 @@ internalRequestTimedCallback (RIL_TimedCallback callback, void *param, extern "C" void RIL_requestTimedCallback (RIL_TimedCallback callback, void *param, - const struct timeval *relativeTime) -{ + const struct timeval *relativeTime) { internalRequestTimedCallback (callback, param, relativeTime); } const char * -failCauseToString(RIL_Errno e) -{ +failCauseToString(RIL_Errno e) { switch(e) { case RIL_E_SUCCESS: return "E_SUCCESS"; case RIL_E_RADIO_NOT_AVAILABLE: return "E_RAIDO_NOT_AVAILABLE"; @@ -2057,26 +2843,34 @@ failCauseToString(RIL_Errno e) case RIL_E_OP_NOT_ALLOWED_DURING_VOICE_CALL: return "E_OP_NOT_ALLOWED_DURING_VOICE_CALL"; case RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW: return "E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW"; case RIL_E_SMS_SEND_FAIL_RETRY: return "E_SMS_SEND_FAIL_RETRY"; + case RIL_E_SIM_ABSENT:return "E_SIM_ABSENT"; +#ifdef FEATURE_MULTIMODE_ANDROID + case RIL_E_SUBSCRIPTION_NOT_AVAILABLE:return "E_SUBSCRIPTION_NOT_AVAILABLE"; + case RIL_E_MODE_NOT_SUPPORTED:return "E_MODE_NOT_SUPPORTED"; +#endif default: return ""; } } const char * -radioStateToString(RIL_RadioState s) -{ +radioStateToString(RIL_RadioState s) { switch(s) { case RADIO_STATE_OFF: return "RADIO_OFF"; case RADIO_STATE_UNAVAILABLE: return "RADIO_UNAVAILABLE"; case RADIO_STATE_SIM_NOT_READY: return "RADIO_SIM_NOT_READY"; case RADIO_STATE_SIM_LOCKED_OR_ABSENT: return "RADIO_SIM_LOCKED_OR_ABSENT"; case RADIO_STATE_SIM_READY: return "RADIO_SIM_READY"; + case RADIO_STATE_RUIM_NOT_READY:return"RADIO_RUIM_NOT_READY"; + case RADIO_STATE_RUIM_READY:return"RADIO_RUIM_READY"; + case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:return"RADIO_RUIM_LOCKED_OR_ABSENT"; + case RADIO_STATE_NV_NOT_READY:return"RADIO_NV_NOT_READY"; + case RADIO_STATE_NV_READY:return"RADIO_NV_READY"; default: return ""; } } const char * -callStateToString(RIL_CallState s) -{ +callStateToString(RIL_CallState s) { switch(s) { case RIL_CALL_ACTIVE : return "ACTIVE"; case RIL_CALL_HOLDING: return "HOLDING"; @@ -2089,8 +2883,7 @@ callStateToString(RIL_CallState s) } const char * -requestToString(int request) -{ +requestToString(int request) { /* cat libs/telephony/ril_commands.h \ | egrep "^ *{RIL_" \ @@ -2129,7 +2922,7 @@ requestToString(int request) case RIL_REQUEST_DTMF: return "DTMF"; case RIL_REQUEST_SEND_SMS: return "SEND_SMS"; case RIL_REQUEST_SEND_SMS_EXPECT_MORE: return "SEND_SMS_EXPECT_MORE"; - case RIL_REQUEST_SETUP_DEFAULT_PDP: return "SETUP_DEFAULT_PDP"; + case RIL_REQUEST_SETUP_DATA_CALL: return "SETUP_DATA_CALL"; case RIL_REQUEST_SIM_IO: return "SIM_IO"; case RIL_REQUEST_SEND_USSD: return "SEND_USSD"; case RIL_REQUEST_CANCEL_USSD: return "CANCEL_USSD"; @@ -2143,7 +2936,7 @@ requestToString(int request) case RIL_REQUEST_GET_IMEI: return "GET_IMEI"; case RIL_REQUEST_GET_IMEISV: return "GET_IMEISV"; case RIL_REQUEST_ANSWER: return "ANSWER"; - case RIL_REQUEST_DEACTIVATE_DEFAULT_PDP: return "DEACTIVATE_DEFAULT_PDP"; + case RIL_REQUEST_DEACTIVATE_DATA_CALL: return "DEACTIVATE_DATA_CALL"; case RIL_REQUEST_QUERY_FACILITY_LOCK: return "QUERY_FACILITY_LOCK"; case RIL_REQUEST_SET_FACILITY_LOCK: return "SET_FACILITY_LOCK"; case RIL_REQUEST_CHANGE_BARRING_PASSWORD: return "CHANGE_BARRING_PASSWORD"; @@ -2161,13 +2954,13 @@ requestToString(int request) case RIL_REQUEST_SET_MUTE: return "SET_MUTE"; case RIL_REQUEST_GET_MUTE: return "GET_MUTE"; case RIL_REQUEST_QUERY_CLIP: return "QUERY_CLIP"; - case RIL_REQUEST_LAST_PDP_FAIL_CAUSE: return "LAST_PDP_FAIL_CAUSE"; - case RIL_REQUEST_PDP_CONTEXT_LIST: return "PDP_CONTEXT_LIST"; + case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: return "LAST_DATA_CALL_FAIL_CAUSE"; + case RIL_REQUEST_DATA_CALL_LIST: return "DATA_CALL_LIST"; case RIL_REQUEST_RESET_RADIO: return "RESET_RADIO"; case RIL_REQUEST_OEM_HOOK_RAW: return "OEM_HOOK_RAW"; case RIL_REQUEST_OEM_HOOK_STRINGS: return "OEM_HOOK_STRINGS"; - case RIL_REQUEST_SET_BAND_MODE: return "SET_BAND_MODE"; - case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: return "QUERY_AVAILABLE_BAND_MODE"; + case RIL_REQUEST_SET_BAND_MODE: return "SET_BAND_MODE"; + case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: return "QUERY_AVAILABLE_BAND_MODE"; case RIL_REQUEST_STK_GET_PROFILE: return "STK_GET_PROFILE"; case RIL_REQUEST_STK_SET_PROFILE: return "STK_SET_PROFILE"; case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: return "STK_SEND_ENVELOPE_COMMAND"; @@ -2176,7 +2969,30 @@ requestToString(int request) case RIL_REQUEST_SCREEN_STATE: return "SCREEN_STATE"; case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: return "EXPLICIT_CALL_TRANSFER"; case RIL_REQUEST_SET_LOCATION_UPDATES: return "SET_LOCATION_UPDATES"; - + case RIL_REQUEST_CDMA_SET_SUBSCRIPTION:return"CDMA_SET_SUBSCRIPTION"; + case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE:return"CDMA_SET_ROAMING_PREFERENCE"; + case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE:return"CDMA_QUERY_ROAMING_PREFERENCE"; + case RIL_REQUEST_SET_TTY_MODE:return"SET_TTY_MODE"; + case RIL_REQUEST_QUERY_TTY_MODE:return"QUERY_TTY_MODE"; + case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE"; + case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE"; + case RIL_REQUEST_CDMA_FLASH:return"CDMA_FLASH"; + case RIL_REQUEST_CDMA_BURST_DTMF:return"CDMA_BURST_DTMF"; + case RIL_REQUEST_CDMA_SEND_SMS:return"CDMA_SEND_SMS"; + case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE:return"CDMA_SMS_ACKNOWLEDGE"; + case RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG:return"GSM_GET_BROADCAST_SMS_CONFIG"; + case RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG:return"GSM_SET_BROADCAST_SMS_CONFIG"; + case RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG:return "CDMA_GET_BROADCAST_SMS_CONFIG"; + case RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG:return "CDMA_SET_BROADCAST_SMS_CONFIG"; + case RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION:return "CDMA_SMS_BROADCAST_ACTIVATION"; + case RIL_REQUEST_CDMA_VALIDATE_AKEY: return"CDMA_VALIDATE_AKEY"; + case RIL_REQUEST_CDMA_SUBSCRIPTION: return"CDMA_SUBSCRIPTION"; + case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: return "CDMA_WRITE_SMS_TO_RUIM"; + case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: return "CDMA_DELETE_SMS_ON_RUIM"; + case RIL_REQUEST_DEVICE_IDENTITY: return "DEVICE_IDENTITY"; + case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: return "EXIT_EMERGENCY_CALLBACK_MODE"; + case RIL_REQUEST_GET_SMSC_ADDRESS: return "GET_SMSC_ADDRESS"; + case RIL_REQUEST_SET_SMSC_ADDRESS: return "SET_SMSC_ADDRESS"; case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return "UNSOL_RESPONSE_RADIO_STATE_CHANGED"; case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return "UNSOL_RESPONSE_CALL_STATE_CHANGED"; case RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED: return "UNSOL_RESPONSE_NETWORK_STATE_CHANGED"; @@ -2193,8 +3009,18 @@ requestToString(int request) case RIL_UNSOL_STK_CALL_SETUP: return "UNSOL_STK_CALL_SETUP"; case RIL_UNSOL_SIM_SMS_STORAGE_FULL: return "UNSOL_SIM_SMS_STORAGE_FUL"; case RIL_UNSOL_SIM_REFRESH: return "UNSOL_SIM_REFRESH"; - case RIL_UNSOL_PDP_CONTEXT_LIST_CHANGED: return "UNSOL_PDP_CONTEXT_LIST_CHANGED"; + case RIL_UNSOL_DATA_CALL_LIST_CHANGED: return "UNSOL_DATA_CALL_LIST_CHANGED"; case RIL_UNSOL_CALL_RING: return "UNSOL_CALL_RING"; + case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: return "UNSOL_RESPONSE_SIM_STATUS_CHANGED"; + case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: return "UNSOL_NEW_CDMA_SMS"; + case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: return "UNSOL_NEW_BROADCAST_SMS"; + case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: return "UNSOL_CDMA_RUIM_SMS_STORAGE_FULL"; + case RIL_UNSOL_RESTRICTED_STATE_CHANGED: return "UNSOL_RESTRICTED_STATE_CHANGED"; + case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: return "UNSOL_ENTER_EMERGENCY_CALLBACK_MODE"; + case RIL_UNSOL_CDMA_CALL_WAITING: return "UNSOL_CDMA_CALL_WAITING"; + case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: return "UNSOL_CDMA_OTA_PROVISION_STATUS"; + case RIL_UNSOL_CDMA_INFO_REC: return "UNSOL_CDMA_INFO_REC"; + case RIL_UNSOL_OEM_HOOK_RAW: return "UNSOL_OEM_HOOK_RAW"; default: return ""; } }