**
** Copyright 2006, The Android Open Source Project
**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
**
-** http://www.apache.org/licenses/LICENSE-2.0
+** http://www.apache.org/licenses/LICENSE-2.0
**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
** limitations under the License.
*/
} UnsolResponseInfo;
typedef struct RequestInfo {
- int32_t token; //this is not RIL_Token
+ int32_t token; //this is not RIL_Token
CommandInfo *pCI;
struct RequestInfo *p_next;
char cancelled;
static void dispatchCdmaSms(Parcel &p, RequestInfo *pRI);
static void dispatchCdmaSmsAck(Parcel &p, RequestInfo *pRI);
-static void dispatchBrSmsCnf(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 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 responseBrSmsCnf(Parcel &p, void *response, size_t responselen);
-static int responseCdmaBrCnf(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);
extern "C" const char * radioStateToString(RIL_RadioState);
#ifdef RIL_SHLIB
-extern "C" void RIL_onUnsolicitedResponse(int unsolResponse, void *data,
+extern "C" void RIL_onUnsolicitedResponse(int unsolResponse, void *data,
size_t datalen);
#endif
-static UserCallbackInfo * internalRequestTimedCallback
- (RIL_TimedCallback callback, void *param,
+static UserCallbackInfo * internalRequestTimedCallback
+ (RIL_TimedCallback callback, void *param,
const struct timeval *relativeTime);
/** Index == requestNumber */
strdupReadString(Parcel &p) {
size_t stringlen;
const char16_t *s16;
-
+
s16 = p.readString16Inplace(&stringlen);
-
+
return strndup16to8(s16, stringlen);
}
// do nothing -- the data reference lives longer than the Parcel object
}
-/**
+/**
* To be called from dispatch thread
* Issue a single local request, ensuring that the response
- * is not sent back up to the command process
+ * is not sent back up to the command process
*/
static void
issueLocalRequest(int request, void *data, int len) {
/* sLastDispatchedToken = token; */
- pRI->pCI->dispatchFunction(p, pRI);
+ pRI->pCI->dispatchFunction(p, pRI);
return 0;
}
static void
invalidCommandBlock (RequestInfo *pRI) {
- LOGE("invalid command block for token %d request %s",
+ LOGE("invalid command block for token %d request %s",
pRI->token, requestToString(pRI->pCI->requestNumber));
}
/** Callee expects NULL */
-static void
+static void
dispatchVoid (Parcel& p, RequestInfo *pRI) {
clearPrintBuf;
printRequest(pRI->token, pRI->pCI->requestNumber);
datalen = 0;
} else {
datalen = sizeof(char *) * countStrings;
-
+
pStrings = (char **)alloca(datalen);
for (int i = 0 ; i < countStrings ; i++) {
memset(pStrings, 0, datalen);
#endif
}
-
+
return;
invalid:
invalidCommandBlock(pRI);
closeRequest;
printRequest(pRI->token, pRI->pCI->requestNumber);
- s_callbacks.onRequest(pRI->pCI->requestNumber, const_cast<int *>(pInts),
+ s_callbacks.onRequest(pRI->pCI->requestNumber, const_cast<int *>(pInts),
datalen, pRI);
#ifdef MEMSET_FREED
}
-/**
- * Callee expects const RIL_SMS_WriteArgs *
+/**
+ * Callee expects const RIL_SMS_WriteArgs *
* Payload is:
* int32_t status
* String pdu
(char*)args.pdu, (char*)args.smsc);
closeRequest;
printRequest(pRI->token, pRI->pCI->requestNumber);
-
+
s_callbacks.onRequest(pRI->pCI->requestNumber, &args, sizeof(args), pRI);
#ifdef MEMSET_FREED
#endif
free (args.pdu);
-
+
#ifdef MEMSET_FREED
memset(&args, 0, sizeof(args));
#endif
return;
}
-/**
- * Callee expects const RIL_Dial *
+/**
+ * Callee expects const RIL_Dial *
* Payload is:
* String address
* int32_t clir
#endif
free (dial.address);
-
+
#ifdef MEMSET_FREED
memset(&dial, 0, sizeof(dial));
#endif
return;
}
-/**
- * Callee expects const RIL_SIM_IO *
+/**
+ * Callee expects const RIL_SIM_IO *
* Payload is:
* int32_t command
* int32_t fileid
* String path
* int32_t p1, p2, p3
- * String data
- * String pin2
+ * String data
+ * String pin2
*/
static void
dispatchSIM_IO (Parcel &p, RequestInfo *pRI) {
memset (&simIO, 0, sizeof(simIO));
- // note we only check status at the end
-
+ // note we only check status at the end
+
status = p.readInt32(&t);
simIO.command = (int)t;
(char*)simIO.data, (char*)simIO.pin2);
closeRequest;
printRequest(pRI->token, pRI->pCI->requestNumber);
-
+
if (status != NO_ERROR) {
goto invalid;
}
free (simIO.path);
free (simIO.data);
free (simIO.pin2);
-
+
#ifdef MEMSET_FREED
memset(&simIO, 0, sizeof(simIO));
#endif
* String number (0 length -> null)
* int32_t timeSeconds
*/
-static void
+static void
dispatchCallForward(Parcel &p, RequestInfo *pRI) {
RIL_CallForwardInfo cff;
int32_t t;
memset (&cff, 0, sizeof(cff));
- // note we only check status at the end
+ // note we only check status at the end
status = p.readInt32(&t);
cff.status = (int)t;
-
+
status = p.readInt32(&t);
cff.reason = (int)t;
}
-static void
+static void
dispatchRaw(Parcel &p, RequestInfo *pRI) {
int32_t len;
status_t status;
if (((int)len) == -1) {
data = NULL;
len = 0;
- }
+ }
data = p.readInplace(len);
return;
}
-static void
+static void
dispatchCdmaSms(Parcel &p, RequestInfo *pRI) {
RIL_CDMA_SMS_Message rcsm;
int32_t t;
status_t status;
int32_t digitCount;
int digitLimit;
-
+
memset(&rcsm, 0, sizeof(rcsm));
status = p.readInt32(&t);
rcsm.sAddress.digits[digitCount] = (uint8_t) ut;
}
- status = p.readInt32(&t);
+ status = p.readInt32(&t);
rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) t;
- status = p.read(&ut,sizeof(ut));
+ 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));
+ for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
+ status = p.read(&ut,sizeof(ut));
rcsm.sSubAddress.digits[digitCount] = (uint8_t) ut;
}
- status = p.readInt32(&t);
+ 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));
+ for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
+ status = p.read(&ut, sizeof(ut));
rcsm.aBearerData[digitCount] = (uint8_t) ut;
}
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);
return;
}
-static void
+static void
dispatchCdmaSmsAck(Parcel &p, RequestInfo *pRI) {
RIL_CDMA_SMS_Ack rcsa;
int32_t t;
return;
}
-static void
-dispatchBrSmsCnf(Parcel &p, RequestInfo *pRI) {
- RIL_BroadcastSMSConfig rbsc;
- int32_t t;
- uint8_t ut;
+static void
+dispatchGsmBrSmsCnf(Parcel &p, RequestInfo *pRI) {
+ int32_t t;
status_t status;
- int32_t digitCount;
+ int32_t num;
- memset(&rbsc, 0, sizeof(rbsc));
+ status = p.readInt32(&num);
+ if (status != NO_ERROR) {
+ goto invalid;
+ }
- status = p.readInt32(&t);
- rbsc.size = (int) t;
+ RIL_GSM_BroadcastSmsConfigInfo gsmBci[num];
+ RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num];
- status = p.readInt32(&t);
- rbsc.entries->uFromServiceID = (int) t;
+ startRequest;
+ for (int i = 0 ; i < num ; i++ ) {
+ gsmBciPtrs[i] = &gsmBci[i];
- status = p.readInt32(&t);
- rbsc.entries->uToserviceID = (int) t;
+ status = p.readInt32(&t);
+ gsmBci[i].fromServiceId = (int) t;
- //usage of read function on assumption that it reads any length given as 2nd argument
- status = p.read(&ut,sizeof(ut));
- rbsc.entries->bSelected = (uint8_t) ut;
+ status = p.readInt32(&t);
+ gsmBci[i].toServiceId = (int) t;
- if (status != NO_ERROR) {
- goto invalid;
- }
+ status = p.readInt32(&t);
+ gsmBci[i].fromCodeScheme = (int) t;
- startRequest;
- appendPrintBuf("%ssize=%d, entries.uFromServiceID=%d, \
- entries.uToserviceID=%d, entries.bSelected =%d, ", printBuf,
- rbsc.size,rbsc.entries->uFromServiceID, rbsc.entries->uToserviceID,
- rbsc.entries->bSelected);
+ 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;
- printRequest(pRI->token, pRI->pCI->requestNumber);
+ if (status != NO_ERROR) {
+ goto invalid;
+ }
- s_callbacks.onRequest(pRI->pCI->requestNumber, &rbsc, sizeof(rbsc),pRI);
+ s_callbacks.onRequest(pRI->pCI->requestNumber,
+ gsmBciPtrs,
+ num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *),
+ pRI);
#ifdef MEMSET_FREED
- memset(&rbsc, 0, sizeof(rbsc));
+ memset(gsmBci, 0, num * sizeof(RIL_GSM_BroadcastSmsConfigInfo));
+ memset(gsmBciPtrs, 0, num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *));
#endif
return;
invalid:
invalidCommandBlock(pRI);
return;
-
}
-static void
+static void
dispatchCdmaBrSmsCnf(Parcel &p, RequestInfo *pRI) {
- RIL_CDMA_BroadcastSMSConfig rcbsc;
- int32_t t;
- uint8_t ut;
+ int32_t t;
status_t status;
- int32_t digitCount;
+ int32_t num;
- status = p.readInt32(&t);
- rcbsc.size = (int) t;
+ status = p.readInt32(&num);
+ if (status != NO_ERROR) {
+ goto invalid;
+ }
- if (rcbsc.size != 0) {
- RIL_CDMA_BroadcastServiceInfo cdmaBsi[rcbsc.size];
- for (int i = 0 ; i < rcbsc.size ; i++ ) {
- status = p.readInt32(&t);
- cdmaBsi[i].uServiceCategory = (int) t;
+ RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num];
+ RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num];
- status = p.readInt32(&t);
- cdmaBsi[i].uLanguage = (int) t;
+ startRequest;
+ for (int i = 0 ; i < num ; i++ ) {
+ cdmaBciPtrs[i] = &cdmaBci[i];
- status = p.readInt32(&t);
- cdmaBsi[i].bSelected = (uint8_t) t;
+ status = p.readInt32(&t);
+ cdmaBci[i].service_category = (int) t;
- startRequest;
- appendPrintBuf("%sentries.uServicecategory=%d, entries.uLanguage =%d, \
- entries.bSelected =%d, ", printBuf, cdmaBsi[i].uServiceCategory,
- cdmaBsi[i].uLanguage, cdmaBsi[i].bSelected);
- closeRequest;
- }
- rcbsc.entries = (RIL_CDMA_BroadcastServiceInfo *)calloc(rcbsc.size,
- sizeof(RIL_CDMA_BroadcastServiceInfo));
- memcpy(rcbsc.entries, cdmaBsi, (sizeof(RIL_CDMA_BroadcastServiceInfo) * rcbsc.size));
- } else {
- rcbsc.entries = NULL;
+ 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,
- &rcbsc,
- (sizeof(RIL_CDMA_BroadcastServiceInfo) * rcbsc.size) + sizeof(int),
+ cdmaBciPtrs,
+ num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *),
pRI);
#ifdef MEMSET_FREED
- memset(&rcbsc, 0, sizeof(rcbsc));
+ 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) {
status = p.readInt32(&t);
rcsw.status = t;
-
+
status = p.readInt32(&t);
rcsw.message.uTeleserviceID = (int) t;
rcsw.message.sAddress.digits[digitCount] = (uint8_t) uct;
}
- status = p.readInt32(&t);
+ status = p.readInt32(&t);
rcsw.message.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) t;
- status = p.read(&uct,sizeof(uct));
+ 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));
+ status = p.read(&uct,sizeof(uct));
rcsw.message.sSubAddress.digits[digitCount] = (uint8_t) uct;
}
- status = p.readInt32(&t);
+ 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));
+ status = p.read(&uct, sizeof(uct));
rcsw.message.aBearerData[digitCount] = (uint8_t) uct;
}
static int
blockingWrite(int fd, const void *buffer, size_t len) {
- size_t writeOffset = 0;
+ size_t writeOffset = 0;
const uint8_t *toWrite;
toWrite = (const uint8_t *)buffer;
return -1;
}
-
+
// FIXME is blocking here ok? issue #550970
}
/** response is an int* pointing to an array of ints*/
-
-static int
+
+static int
responseInts(Parcel &p, void *response, size_t responselen) {
int numInts;
return RIL_ERRNO_INVALID_RESPONSE;
}
if (responselen % sizeof(int) != 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(int));
return RIL_ERRNO_INVALID_RESPONSE;
}
/** response is a char **, pointing to an array of char *'s */
static int responseStrings(Parcel &p, void *response, size_t responselen) {
int numStrings;
-
+
if (response == NULL && responselen != 0) {
LOGE("invalid response: NULL");
return RIL_ERRNO_INVALID_RESPONSE;
}
if (responselen % sizeof(char *) != 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(char *));
return RIL_ERRNO_INVALID_RESPONSE;
}
/**
- * NULL strings are accepted
+ * NULL strings are accepted
* FIXME currently ignores responselen
*/
static int responseString(Parcel &p, void *response, size_t responselen) {
p.writeInt32(num);
for (int i = 0 ; i < num ; i++) {
- /* NEWRIL:TODO Remove this conditional and the else clause when we have the new ril */
-#if NEWRIL
- LOGD("Compilied for NEWRIL"); // NEWRIL:TODO remove when we have the new ril
RIL_Call *p_cur = ((RIL_Call **) response)[i];
/* each call info */
p.writeInt32(p_cur->state);
p_cur->numberPresentation,
p_cur->name,
p_cur->namePresentation);
-#else
- LOGD("Old RIL");
- RIL_CallOld *p_cur = ((RIL_CallOld **) response)[i];
- /* each call info */
- p.writeInt32(p_cur->state);
- p.writeInt32(p_cur->index);
- p.writeInt32(p_cur->toa);
- p.writeInt32(p_cur->isMpty);
- p.writeInt32(p_cur->isMT);
- p.writeInt32(p_cur->als);
- p.writeInt32(p_cur->isVoice);
- p.writeInt32(0); // p_cur->isVoicePrivacy);
- writeStringToParcel (p, p_cur->number);
- p.writeInt32(p_cur->numberPresentation);
- writeStringToParcel (p, "a-person");
- p.writeInt32(2); // p_cur->namePresentation);
- appendPrintBuf("%s[id=%d,%s,toa=%d,",
- printBuf,
- p_cur->index,
- callStateToString(p_cur->state),
- 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");
- appendPrintBuf("%s%s,cli=%d]",
- printBuf,
- p_cur->number,
- p_cur->numberPresentation);
-#endif
}
removeLastChar;
closeResponse;
}
if (responselen != sizeof (RIL_SMS_Response) ) {
- LOGE("invalid response length %d expected %d",
+ LOGE("invalid response length %d expected %d",
(int)responselen, (int)sizeof (RIL_SMS_Response));
return RIL_ERRNO_INVALID_RESPONSE;
}
}
if (responselen % sizeof(RIL_Data_Call_Response) != 0) {
- LOGE("invalid response length %d expected multiple of %d",
+ LOGE("invalid response length %d expected multiple of %d",
(int)responselen, (int)sizeof(RIL_Data_Call_Response));
return RIL_ERRNO_INVALID_RESPONSE;
}
// The java code reads -1 size as null byte array
if (response == NULL) {
- p.writeInt32(-1);
+ p.writeInt32(-1);
} else {
p.writeInt32(responselen);
p.write(response, responselen);
static int responseCallForwards(Parcel &p, void *response, size_t responselen) {
int num;
-
+
if (response == NULL && responselen != 0) {
LOGE("invalid response: NULL");
return RIL_ERRNO_INVALID_RESPONSE;
}
if (responselen % sizeof(RIL_CallForwardInfo *) != 0) {
- LOGE("invalid response length %d expected multiple of %d",
+ LOGE("invalid response length %d expected multiple of %d",
(int)responselen, (int)sizeof(RIL_CallForwardInfo *));
return RIL_ERRNO_INVALID_RESPONSE;
}
}
removeLastChar;
closeResponse;
-
+
return 0;
}
/**
* Marshall the signalInfoRecord into the parcel if it exists.
*/
-static void marshallSignalInfoRecord(Parcel &p, RIL_CDMA_SignalInfoRecord &p_signalInfoRecord) {
+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) {
+static int responseCdmaInformationRecords(Parcel &p,
+ void *response, size_t responselen) {
int num;
- int digitCount;
- int digitLimit;
+ 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 %d\n",
- (int)responselen, (int)sizeof (RIL_CDMA_InformationRecords));
+ 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;
}
-
- /* TODO(Teleca): Wink believes this should be deleted? */
-// num = responselen / sizeof(RIL_CDMA_InformationRecords *);
-// p.writeInt32(num);
-
- RIL_CDMA_InformationRecords *p_cur = ((RIL_CDMA_InformationRecords *) response);
-
- /* Number of records */
- p.writeInt32(p_cur->numberOfInfoRecs);
+ 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);
- digitLimit = MIN((p_cur->numberOfInfoRecs),RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
- for (digitCount = 0 ; digitCount < digitLimit; digitCount ++) {
- switch(p_cur->infoRec[digitCount].name){
+ 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:
- p.writeInt32(p_cur->infoRec[digitCount].rec.display.alpha_len);
- for(int i =0;i<(int)(p_cur->infoRec[digitCount].rec.display.alpha_len);i++){
- p.writeInt32(p_cur->infoRec[digitCount].rec.display.alpha_buf[i]);
+ 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;
}
- appendPrintBuf("%s[rec.display.alpha_len%c, rec.display.alpha_buf%s],",
- printBuf,
- p_cur->infoRec[digitCount].rec.display.alpha_len,
- p_cur->infoRec[digitCount].rec.display.alpha_buf);
- break;
- case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
- p.writeInt32(p_cur->infoRec[digitCount].rec.number.len);
- for(int i =0;i<(int)(p_cur->infoRec[digitCount].rec.number.len);i++){
- p.writeInt32(p_cur->infoRec[digitCount].rec.number.buf[i]);
+ 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];
}
- p.writeInt32(p_cur->infoRec[digitCount].rec.number.number_type);
- p.writeInt32(p_cur->infoRec[digitCount].rec.number.number_plan);
- p.writeInt32(p_cur->infoRec[digitCount].rec.number.pi);
- p.writeInt32(p_cur->infoRec[digitCount].rec.number.si);
- appendPrintBuf("%s[len=%c,buf=%s,number_type=%c,number_plan=%c,",
- printBuf,
- p_cur->infoRec[digitCount].rec.number.len,
- p_cur->infoRec[digitCount].rec.number.buf,
- p_cur->infoRec[digitCount].rec.number.number_type,
- p_cur->infoRec[digitCount].rec.number.number_plan);
- appendPrintBuf("%spi=%c,si=%c]",
- printBuf,
- p_cur->infoRec[digitCount].rec.number.pi,
- p_cur->infoRec[digitCount].rec.number.si);
+ 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:
- p.writeInt32(p_cur->infoRec[digitCount].rec.number.len);
- for (int i =0;i<(int)(p_cur->infoRec[digitCount].rec.number.len);i++) {
- p.writeInt32(p_cur->infoRec[digitCount].rec.number.buf[i]);
- }
- p.writeInt32(p_cur->infoRec[digitCount].rec.number.number_type);
- p.writeInt32(p_cur->infoRec[digitCount].rec.number.number_plan);
- p.writeInt32(p_cur->infoRec[digitCount].rec.number.pi);
- p.writeInt32(p_cur->infoRec[digitCount].rec.number.si);
- appendPrintBuf("%s[len=%c,buf=%s,number_type=%c,number_plan=%c,",
- printBuf,
- p_cur->infoRec[digitCount].rec.number.len,
- p_cur->infoRec[digitCount].rec.number.buf,
- p_cur->infoRec[digitCount].rec.number.number_type,
- p_cur->infoRec[digitCount].rec.number.number_plan);
- appendPrintBuf("%spi=%c,si=%c]",
- printBuf,
- p_cur->infoRec[digitCount].rec.number.pi,
- p_cur->infoRec[digitCount].rec.number.si);
- break;
case RIL_CDMA_CONNECTED_NUMBER_INFO_REC:
- p.writeInt32(p_cur->infoRec[digitCount].rec.number.len);
- for(int i =0;i<(int)(p_cur->infoRec[digitCount].rec.number.len);i++){
- p.writeInt32(p_cur->infoRec[digitCount].rec.number.buf[i]);
+ 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];
}
- p.writeInt32(p_cur->infoRec[digitCount].rec.number.number_type);
- p.writeInt32(p_cur->infoRec[digitCount].rec.number.number_plan);
- p.writeInt32(p_cur->infoRec[digitCount].rec.number.pi);
- p.writeInt32(p_cur->infoRec[digitCount].rec.number.si);
- appendPrintBuf("%s[len=%c,buf=%s,number_type=%c,number_plan=%c,",
- printBuf,
- p_cur->infoRec[digitCount].rec.number.len,
- p_cur->infoRec[digitCount].rec.number.buf,
- p_cur->infoRec[digitCount].rec.number.number_type,
- p_cur->infoRec[digitCount].rec.number.number_plan);
- appendPrintBuf("%spi=%c,si=%c]",
- printBuf,
- p_cur->infoRec[digitCount].rec.number.pi,
- p_cur->infoRec[digitCount].rec.number.si);
+ 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:
- marshallSignalInfoRecord(p, p_cur->infoRec[digitCount].rec.signal);
- appendPrintBuf("%s[isPresent=%c,signalType=%c,alertPitch=%c,signal=%c]",
- printBuf,
- p_cur->infoRec[digitCount].rec.signal.isPresent,
- p_cur->infoRec[digitCount].rec.signal.signalType,
- p_cur->infoRec[digitCount].rec.signal.alertPitch,
- p_cur->infoRec[digitCount].rec.signal.signal);
+ 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:
- p.writeInt32(p_cur->infoRec[digitCount].rec.redir.redirectingNumber.len);
- for (int i =0;\
- i<(int)(p_cur->infoRec[digitCount].rec.redir.redirectingNumber.len);i++){
- p.writeInt32(p_cur->infoRec[digitCount].rec.redir.redirectingNumber.buf[i]);
+ 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];
}
- p.writeInt32(p_cur->infoRec[digitCount].rec.redir.redirectingNumber.number_type);
- p.writeInt32(p_cur->infoRec[digitCount].rec.redir.redirectingNumber.number_plan);
- p.writeInt32(p_cur->infoRec[digitCount].rec.redir.redirectingNumber.pi);
- p.writeInt32(p_cur->infoRec[digitCount].rec.redir.redirectingNumber.si);
- p.writeInt32(p_cur->infoRec[digitCount].rec.redir.redirectingReason);
- appendPrintBuf("%s[len=%c,buf=%s,number_type=%c,number_plan=%c,",
- printBuf,
- p_cur->infoRec[digitCount].rec.number.len,
- p_cur->infoRec[digitCount].rec.number.buf,
- p_cur->infoRec[digitCount].rec.number.number_type,
- p_cur->infoRec[digitCount].rec.number.number_plan);
- appendPrintBuf("%spi=%c,si=%c]",
- printBuf,
- p_cur->infoRec[digitCount].rec.number.pi,
- p_cur->infoRec[digitCount].rec.number.si);
+ 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(p_cur->infoRec[digitCount].rec.lineCtrl.lineCtrlPolarityIncluded);
- p.writeInt32(p_cur->infoRec[digitCount].rec.lineCtrl.lineCtrlToggle);
- p.writeInt32(p_cur->infoRec[digitCount].rec.lineCtrl.lineCtrlReverse);
- p.writeInt32( p_cur->infoRec[digitCount].rec.lineCtrl.lineCtrlPowerDenial);
- appendPrintBuf("%s[PolarityIncluded=%c,CtrlToggle=%c,CtrlReverse=%c,\
- CtrlPowerDenial=%c]",
- printBuf,
- p_cur->infoRec[digitCount].rec.lineCtrl.lineCtrlPolarityIncluded,
- p_cur->infoRec[digitCount].rec.lineCtrl.lineCtrlToggle,
- p_cur->infoRec[digitCount].rec.lineCtrl.lineCtrlReverse,
- p_cur->infoRec[digitCount].rec.lineCtrl.lineCtrlPowerDenial);
- break;
- case RIL_CDMA_EXTENDED_DISPLAY_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(p_cur->infoRec[digitCount].rec.clir.cause);
- appendPrintBuf("%s[cause=%c]",printBuf,p_cur->infoRec[digitCount].rec.clir.cause);
- break;
+ p.writeInt32((int)(infoRec->rec.clir.cause));
- case RIL_CDMA_T53_RELEASE_INFO_REC:
+ appendPrintBuf("%scause%d", printBuf, infoRec->rec.clir.cause);
+ removeLastChar;
break;
case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC:
- p.writeInt32(p_cur->infoRec[digitCount].rec.audioCtrl.upLink);
- p.writeInt32(p_cur->infoRec[digitCount].rec.audioCtrl.downLink);
- appendPrintBuf("%s[uplink=%c,downlink=%c]",
- printBuf,p_cur->infoRec[digitCount].rec.audioCtrl.upLink,
- p_cur->infoRec[digitCount].rec.audioCtrl.downLink);
- break;
- default:
- LOGE ("Invalid request");
+ 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;
-
- closeResponse;
-
- return 0;
+ return 0;
}
-static int responseRilSignalStrength(Parcel &p, void *response, size_t responselen) {
- if (response == NULL && responselen != 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))
- && (responselen % sizeof (void *) == 0)) {
- // Old RIL deprecated
- RIL_GW_SignalStrength *p_cur = ((RIL_GW_SignalStrength *) response);
-
- p.writeInt32(7);
- p.writeInt32(p_cur->signalStrength);
- p.writeInt32(p_cur->bitErrorRate);
- for (int i = 0; i < 5; i++) {
- p.writeInt32(0);
- }
- } else if (responselen == sizeof (RIL_SignalStrength)) {
+ if (responselen == sizeof (RIL_SignalStrength)) {
// New RIL
RIL_SignalStrength *p_cur = ((RIL_SignalStrength *) response);
- p.writeInt32(7);
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->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;
}
- 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;
-
return 0;
}
return 0;
}
-static int responseCdmaCallWaiting(Parcel &p,void *response, size_t responselen) {
+static int responseCdmaCallWaiting(Parcel &p, void *response,
+ size_t responselen) {
if (response == NULL && responselen != 0) {
LOGE("invalid response: NULL");
return RIL_ERRNO_INVALID_RESPONSE;
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));
+ 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],",
+ 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,
return 0;
}
-static int responseBrSmsCnf(Parcel &p, void *response, size_t responselen) {
- int num;
-
- if (response == NULL && responselen != 0) {
- LOGE("invalid response: NULL");
- return RIL_ERRNO_INVALID_RESPONSE;
- }
-
- if (responselen % sizeof(RIL_BroadcastSMSConfig) != 0) {
- LOGE("invalid response length %d expected multiple of %d",
- (int)responselen, (int)sizeof(RIL_BroadcastSMSConfig));
- return RIL_ERRNO_INVALID_RESPONSE;
- }
-
- /* number of call info's */
- num = responselen / sizeof(RIL_BroadcastSMSConfig *);
+static int responseGsmBrSmsCnf(Parcel &p, void *response, size_t responselen) {
+ int num = responselen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
p.writeInt32(num);
- RIL_BroadcastSMSConfig *p_cur = (RIL_BroadcastSMSConfig *) response;
- p.writeInt32(p_cur->size);
- p.writeInt32(p_cur->entries->uFromServiceID);
- p.writeInt32(p_cur->entries->uToserviceID);
- p.write(&(p_cur->entries->bSelected),sizeof(p_cur->entries->bSelected));
-
startResponse;
- appendPrintBuf("%s size=%d, entries.uFromServiceID=%d, \
- entries.uToserviceID=%d, entries.bSelected =%d, ",
- printBuf, p_cur->size,p_cur->entries->uFromServiceID,
- p_cur->entries->uToserviceID, p_cur->entries->bSelected);
+ 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 responseCdmaBrCnf(Parcel &p, void *response, size_t responselen) {
- int numServiceCategories;
+static int responseCdmaBrSmsCnf(Parcel &p, void *response, size_t responselen) {
+ RIL_CDMA_BroadcastSmsConfigInfo **p_cur =
+ (RIL_CDMA_BroadcastSmsConfigInfo **) response;
- if (response == NULL && responselen != 0) {
- LOGE("invalid response: NULL");
- return RIL_ERRNO_INVALID_RESPONSE;
- }
-
- if (responselen == 0) {
- LOGE("invalid response length %d expected >= of %d",
- (int)responselen, (int)sizeof(RIL_BroadcastSMSConfig));
- return RIL_ERRNO_INVALID_RESPONSE;
- }
-
- RIL_CDMA_BroadcastSMSConfig *p_cur = (RIL_CDMA_BroadcastSMSConfig *) response;
-
- numServiceCategories = p_cur->size;
- p.writeInt32(p_cur->size);
+ int num = responselen / sizeof (RIL_CDMA_BroadcastSmsConfigInfo *);
+ p.writeInt32(num);
startResponse;
- appendPrintBuf("%ssize=%d ", printBuf,p_cur->size);
- closeResponse;
+ 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);
- if (numServiceCategories != 0) {
- RIL_CDMA_BroadcastServiceInfo cdmaBsi[numServiceCategories];
- memcpy(cdmaBsi, p_cur->entries,
- sizeof(RIL_CDMA_BroadcastServiceInfo) * numServiceCategories);
-
- for (int i = 0 ; i < numServiceCategories ; i++ ) {
- p.writeInt32(cdmaBsi[i].uServiceCategory);
- p.writeInt32(cdmaBsi[i].uLanguage);
- p.writeInt32(cdmaBsi[i].bSelected);
-
- startResponse;
- appendPrintBuf("%sentries[%d].uServicecategory=%d, entries[%d].uLanguage =%d, \
- entries[%d].bSelected =%d, ", printBuf, i, cdmaBsi[i].uServiceCategory, i,
- cdmaBsi[i].uLanguage, i, cdmaBsi[i].bSelected);
- closeResponse;
- }
- } else {
- p.writeInt32(NULL);
+ 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;
}
/* empty our wakeup socket out */
do {
ret = read(s_fdWakeupRead, &buff, sizeof(buff));
- } while (ret > 0 || (ret < 0 && errno == EINTR));
+ } while (ret > 0 || (ret < 0 && errno == EINTR));
}
static void onCommandsSocketClosed() {
p_cur = s_pendingRequests;
- for (p_cur = s_pendingRequests
+ for (p_cur = s_pendingRequests
; p_cur != NULL
; p_cur = p_cur->p_next
) {
} else {
LOGW("EOS. Closing command socket.");
}
-
+
close(s_fdCommand);
s_fdCommand = -1;
const char *version;
version = s_callbacks.getVersion();
LOGI("RIL Daemon version: %s\n", version);
-
+
property_set(PROPERTY_RIL_IMPL, version);
} else {
LOGI("RIL Daemon version: unavailable\n");
assert (s_fdCommand < 0);
assert (fd == s_fdListen);
-
+
s_fdCommand = accept(s_fdListen, (sockaddr *) &peeraddr, &socklen);
if (s_fdCommand < 0 ) {
/* check the credential of the other side and only accept socket from
* phone process
- */
+ */
errno = 0;
is_phone_socket = 0;
if ( !is_phone_socket ) {
LOGE("RILD must accept socket from %s", PHONE_PROCESS);
-
+
close(s_fdCommand);
s_fdCommand = -1;
p_rs = record_stream_new(s_fdCommand, MAX_COMMAND_BYTES);
- ril_event_set (&s_commands_event, s_fdCommand, 1,
+ ril_event_set (&s_commands_event, s_fdCommand, 1,
processCommandsCallback, p_rs);
rilEventAddWakeup (&s_commands_event);
}
// +1 for null-term
args[i] = (char *) malloc((sizeof(char) * len) + 1);
- if (recv(acceptFD, args[i], sizeof(char) * len, 0)
+ if (recv(acceptFD, args[i], sizeof(char) * len, 0)
!= (int)sizeof(char) * len) {
LOGE ("error reading on socket: Args[%d] \n", i);
freeDebugCallbackArgs(i, args);
qxdm_data[3] = 32;
qxdm_data[4] = 0;
qxdm_data[4] = 8;
- issueLocalRequest(RIL_REQUEST_OEM_HOOK_RAW, qxdm_data,
+ issueLocalRequest(RIL_REQUEST_OEM_HOOK_RAW, qxdm_data,
6 * sizeof(int));
break;
case 4:
case 6:
LOGI("Debug port: Setup Data Call, Apn :%s\n", args[1]);
actData[0] = args[1];
- issueLocalRequest(RIL_REQUEST_SETUP_DATA_CALL, &actData,
+ issueLocalRequest(RIL_REQUEST_SETUP_DATA_CALL, &actData,
sizeof(actData));
break;
case 7:
LOGI("Debug port: Deactivate Data Call");
- issueLocalRequest(RIL_REQUEST_DEACTIVATE_DATA_CALL, &deactData,
+ issueLocalRequest(RIL_REQUEST_DEACTIVATE_DATA_CALL, &deactData,
sizeof(deactData));
break;
case 8:
break;
case 10:
LOGI("Debug port: End Call");
- issueLocalRequest(RIL_REQUEST_HANGUP, &hangupData,
+ issueLocalRequest(RIL_REQUEST_HANGUP, &hangupData,
sizeof(hangupData));
break;
default:
return NULL;
}
-extern "C" void
+extern "C" void
RIL_startEventLoop(void) {
int ret;
pthread_attr_t attr;
-
+
/* spin up eventLoop thread and wait for it to get started */
s_started = 0;
pthread_mutex_lock(&s_startupMutex);
pthread_attr_init (&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
ret = pthread_create(&s_tid_dispatch, &attr, eventLoop, NULL);
while (s_started == 0) {
memcpy(&s_callbacks, callbacks, sizeof (RIL_RadioFunctions));
}
-extern "C" void
+extern "C" void
RIL_register (const RIL_RadioFunctions *callbacks) {
int ret;
int flags;
- if (callbacks == NULL
+ if (callbacks == NULL
|| ! (callbacks->version == RIL_VERSION || callbacks->version == 1)
) {
LOGE(
}
for (int i = 0; i < (int)NUM_ELEMS(s_unsolResponses); i++) {
- assert(i + RIL_UNSOL_RESPONSE_BASE
+ assert(i + RIL_UNSOL_RESPONSE_BASE
== s_unsolResponses[i].requestNumber);
}
// start listen socket
#if 0
- ret = socket_local_server (SOCKET_NAME_RIL,
+ ret = socket_local_server (SOCKET_NAME_RIL,
ANDROID_SOCKET_NAMESPACE_ABSTRACT, SOCK_STREAM);
if (ret < 0) {
/* note: non-persistent so we can accept only one connection at a time */
- ril_event_set (&s_listen_event, s_fdListen, false,
+ ril_event_set (&s_listen_event, s_fdListen, false,
listenCallback, NULL);
rilEventAddWakeup (&s_listen_event);
static int
checkAndDequeueRequestInfo(struct RequestInfo *pRI) {
int ret = 0;
-
+
if (pRI == NULL) {
return 0;
}
pthread_mutex_lock(&s_pendingRequestsMutex);
- for(RequestInfo **ppCur = &s_pendingRequests
- ; *ppCur != NULL
+ for(RequestInfo **ppCur = &s_pendingRequests
+ ; *ppCur != NULL
; ppCur = &((*ppCur)->p_next)
) {
if (pRI == *ppCur) {
p.writeInt32 (e);
- if (e == RIL_E_SUCCESS) {
- /* process response on success */
+ if (response != NULL) {
+ // there is a response payload, no matter success or not.
ret = pRI->pCI->responseFunction(p, response, responselen);
/* if an error occurred, rewind and mark it */
p.setDataPosition(errorOffset);
p.writeInt32 (ret);
}
- } else {
- appendPrintBuf("%s returns %s", printBuf, failCauseToString(e));
+ }
+
+ if (e != RIL_E_SUCCESS) {
+ appendPrintBuf("%s fails by %s", printBuf, failCauseToString(e));
}
if (s_fdCommand < 0) {
LOGW("RIL_onUnsolicitedResponse called before RIL_register");
return;
}
-
+
unsolResponseIndex = unsolResponse - RIL_UNSOL_RESPONSE_BASE;
if ((unsolResponseIndex < 0)
}
}
-/** FIXME generalize this if you track UserCAllbackInfo, clear it
- when the callback occurs
+/** FIXME generalize this if you track UserCAllbackInfo, clear it
+ when the callback occurs
*/
static UserCallbackInfo *
-internalRequestTimedCallback (RIL_TimedCallback callback, void *param,
+internalRequestTimedCallback (RIL_TimedCallback callback, void *param,
const struct timeval *relativeTime)
{
struct timeval myRelativeTime;
p_info = (UserCallbackInfo *) malloc (sizeof(UserCallbackInfo));
- p_info->p_callback = callback;
+ p_info->p_callback = callback;
p_info->userParam = param;
if (relativeTime == NULL) {
extern "C" void
-RIL_requestTimedCallback (RIL_TimedCallback callback, void *param,
+RIL_requestTimedCallback (RIL_TimedCallback callback, void *param,
const struct timeval *relativeTime) {
internalRequestTimedCallback (callback, param, relativeTime);
}
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
+#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
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_GET_BROADCAST_CONFIG:return"GET_BROADCAST_CONFIG";
- case RIL_REQUEST_SET_BROADCAST_CONFIG:return"SET_BROADCAST_CONFIG";
- case RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG:return "CDMA_GET_BROADCAST_CONFIG";
- case RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG:return "SET_CDMA_BROADCAST_CONFIG";
- case RIL_REQUEST_BROADCAST_ACTIVATION:return "BROADCAST_ACTIVATION";
+ 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";