OSDN Git Service

Cleanup whitespace.
[android-x86/hardware-ril.git] / libril / ril.cpp
index d06f0f3..fae17ca 100644 (file)
@@ -2,16 +2,16 @@
 **
 ** 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.
 */
 
@@ -128,7 +128,7 @@ typedef struct {
 } 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;
@@ -204,7 +204,7 @@ static void dispatchSmsWrite (Parcel &p, RequestInfo *pRI);
 
 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);
@@ -219,8 +219,8 @@ 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 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);
@@ -235,12 +235,12 @@ extern "C" const char * callStateToString(RIL_CallState);
 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 */
@@ -257,9 +257,9 @@ static char *
 strdupReadString(Parcel &p) {
     size_t stringlen;
     const char16_t *s16;
-            
+
     s16 = p.readString16Inplace(&stringlen);
-    
+
     return strndup16to8(s16, stringlen);
 }
 
@@ -285,10 +285,10 @@ void   nullParcelReleaseFunction (const uint8_t* data, size_t dataSize,
     // 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) {
@@ -360,19 +360,19 @@ processCommandBuffer(void *buffer, size_t buflen) {
 
 /*    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);
@@ -432,7 +432,7 @@ dispatchStrings (Parcel &p, RequestInfo *pRI) {
         datalen = 0;
     } else {
         datalen = sizeof(char *) * countStrings;
-    
+
         pStrings = (char **)alloca(datalen);
 
         for (int i = 0 ; i < countStrings ; i++) {
@@ -458,7 +458,7 @@ dispatchStrings (Parcel &p, RequestInfo *pRI) {
         memset(pStrings, 0, datalen);
 #endif
     }
-    
+
     return;
 invalid:
     invalidCommandBlock(pRI);
@@ -498,7 +498,7 @@ dispatchInts (Parcel &p, RequestInfo *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
@@ -512,8 +512,8 @@ invalid:
 }
 
 
-/** 
- * Callee expects const RIL_SMS_WriteArgs * 
+/**
+ * Callee expects const RIL_SMS_WriteArgs *
  * Payload is:
  *   int32_t status
  *   String pdu
@@ -542,7 +542,7 @@ dispatchSmsWrite (Parcel &p, RequestInfo *pRI) {
         (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
@@ -550,7 +550,7 @@ dispatchSmsWrite (Parcel &p, RequestInfo *pRI) {
 #endif
 
     free (args.pdu);
-    
+
 #ifdef MEMSET_FREED
     memset(&args, 0, sizeof(args));
 #endif
@@ -561,8 +561,8 @@ invalid:
     return;
 }
 
-/** 
- * Callee expects const RIL_Dial * 
+/**
+ * Callee expects const RIL_Dial *
  * Payload is:
  *   String address
  *   int32_t clir
@@ -596,7 +596,7 @@ dispatchDial (Parcel &p, RequestInfo *pRI) {
 #endif
 
     free (dial.address);
-    
+
 #ifdef MEMSET_FREED
     memset(&dial, 0, sizeof(dial));
 #endif
@@ -607,15 +607,15 @@ invalid:
     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) {
@@ -625,8 +625,8 @@ 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;
 
@@ -654,7 +654,7 @@ dispatchSIM_IO (Parcel &p, RequestInfo *pRI) {
         (char*)simIO.data,  (char*)simIO.pin2);
     closeRequest;
     printRequest(pRI->token, pRI->pCI->requestNumber);
-    
+
     if (status != NO_ERROR) {
         goto invalid;
     }
@@ -670,7 +670,7 @@ dispatchSIM_IO (Parcel &p, RequestInfo *pRI) {
     free (simIO.path);
     free (simIO.data);
     free (simIO.pin2);
-    
+
 #ifdef MEMSET_FREED
     memset(&simIO, 0, sizeof(simIO));
 #endif
@@ -691,7 +691,7 @@ invalid:
  *  String number  (0 length -> null)
  *  int32_t timeSeconds
  */
-static void 
+static void
 dispatchCallForward(Parcel &p, RequestInfo *pRI) {
     RIL_CallForwardInfo cff;
     int32_t t;
@@ -699,11 +699,11 @@ dispatchCallForward(Parcel &p, RequestInfo *pRI) {
 
     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;
 
@@ -754,7 +754,7 @@ invalid:
 }
 
 
-static void 
+static void
 dispatchRaw(Parcel &p, RequestInfo *pRI) {
     int32_t len;
     status_t status;
@@ -770,7 +770,7 @@ dispatchRaw(Parcel &p, RequestInfo *pRI) {
     if (((int)len) == -1) {
         data = NULL;
         len = 0;
-    } 
+    }
 
     data = p.readInplace(len);
 
@@ -787,7 +787,7 @@ invalid:
     return;
 }
 
-static void 
+static void
 dispatchCdmaSms(Parcel &p, RequestInfo *pRI) {
     RIL_CDMA_SMS_Message rcsm;
     int32_t  t;
@@ -795,7 +795,7 @@ dispatchCdmaSms(Parcel &p, RequestInfo *pRI) {
     status_t status;
     int32_t digitCount;
     int digitLimit;
-    
+
     memset(&rcsm, 0, sizeof(rcsm));
 
     status = p.readInt32(&t);
@@ -828,27 +828,27 @@ dispatchCdmaSms(Parcel &p, RequestInfo *pRI) {
         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;
     }
 
@@ -862,7 +862,7 @@ dispatchCdmaSms(Parcel &p, RequestInfo *pRI) {
             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);
@@ -878,7 +878,7 @@ invalid:
     return;
 }
 
-static void 
+static void
 dispatchCdmaSmsAck(Parcel &p, RequestInfo *pRI) {
     RIL_CDMA_SMS_Ack rcsa;
     int32_t  t;
@@ -917,46 +917,59 @@ invalid:
     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;
@@ -964,56 +977,53 @@ dispatchBrSmsCnf(Parcel &p, RequestInfo *pRI) {
 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;
@@ -1021,7 +1031,6 @@ dispatchCdmaBrSmsCnf(Parcel &p, RequestInfo *pRI) {
 invalid:
     invalidCommandBlock(pRI);
     return;
-
 }
 
 static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI) {
@@ -1036,7 +1045,7 @@ static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI) {
 
     status = p.readInt32(&t);
     rcsw.status = t;
-    
+
     status = p.readInt32(&t);
     rcsw.message.uTeleserviceID = (int) t;
 
@@ -1066,25 +1075,25 @@ static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI) {
         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;
     }
 
@@ -1121,7 +1130,7 @@ invalid:
 
 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;
@@ -1161,7 +1170,7 @@ sendResponseRaw (const void *data, size_t dataSize) {
 
         return -1;
     }
-    
+
 
     // FIXME is blocking here ok? issue #550970
 
@@ -1193,8 +1202,8 @@ sendResponse (Parcel &p) {
 }
 
 /** response is an int* pointing to an array of ints*/
-static int 
+
+static int
 responseInts(Parcel &p, void *response, size_t responselen) {
     int numInts;
 
@@ -1203,7 +1212,7 @@ responseInts(Parcel &p, void *response, size_t responselen) {
         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;
     }
@@ -1228,13 +1237,13 @@ 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) {
     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;
     }
@@ -1261,7 +1270,7 @@ static int responseStrings(Parcel &p, void *response, size_t responselen) {
 
 
 /**
- * NULL strings are accepted 
+ * NULL strings are accepted
  * FIXME currently ignores responselen
  */
 static int responseString(Parcel &p, void *response, size_t responselen) {
@@ -1301,9 +1310,6 @@ static int responseCallList(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);
@@ -1336,38 +1342,6 @@ static int responseCallList(Parcel &p, void *response, size_t responselen) {
             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;
@@ -1382,7 +1356,7 @@ static int responseSMS(Parcel &p, void *response, size_t responselen) {
     }
 
     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;
     }
@@ -1408,7 +1382,7 @@ static int responseDataCallList(Parcel &p, void *response, size_t responselen)
     }
 
     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;
     }
@@ -1446,7 +1420,7 @@ static int responseRaw(Parcel &p, void *response, size_t responselen) {
 
     // 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);
@@ -1484,14 +1458,14 @@ static int responseSIM_IO(Parcel &p, void *response, size_t 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;
     }
@@ -1518,7 +1492,7 @@ static int responseCallForwards(Parcel &p, void *response, size_t responselen) {
     }
     removeLastChar;
     closeResponse;
-    
+
     return 0;
 }
 
@@ -1588,208 +1562,182 @@ static int responseCellList(Parcel &p, void *response, size_t responselen) {
 /**
  * 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);
@@ -1797,27 +1745,52 @@ static int responseRilSignalStrength(Parcel &p, void *response, size_t responsel
         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;
 }
 
@@ -1858,7 +1831,8 @@ static int responseCdmaSignalInfoRecord(Parcel &p, void *response, size_t respon
     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;
@@ -1938,13 +1912,14 @@ static int responseSimStatus(Parcel &p, void *response, size_t responselen) {
         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,
@@ -1960,82 +1935,50 @@ static int responseSimStatus(Parcel &p, void *response, size_t responselen) {
     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;
 }
@@ -2112,7 +2055,7 @@ static void processWakeupCallback(int fd, short flags, void *param) {
     /* 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() {
@@ -2126,7 +2069,7 @@ 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
     ) {
@@ -2168,7 +2111,7 @@ static void processCommandsCallback(int fd, short flags, void *param) {
         } else {
             LOGW("EOS.  Closing command socket.");
         }
-        
+
         close(s_fdCommand);
         s_fdCommand = -1;
 
@@ -2202,7 +2145,7 @@ static void onNewCommandConnect() {
         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");
@@ -2227,7 +2170,7 @@ static void listenCallback (int fd, short flags, void *param) {
 
     assert (s_fdCommand < 0);
     assert (fd == s_fdListen);
-    
+
     s_fdCommand = accept(s_fdListen, (sockaddr *) &peeraddr, &socklen);
 
     if (s_fdCommand < 0 ) {
@@ -2239,7 +2182,7 @@ static void listenCallback (int fd, short flags, void *param) {
 
     /* check the credential of the other side and only accept socket from
      * phone process
-     */ 
+     */
     errno = 0;
     is_phone_socket = 0;
 
@@ -2263,7 +2206,7 @@ static void listenCallback (int fd, short flags, void *param) {
 
     if ( !is_phone_socket ) {
       LOGE("RILD must accept socket from %s", PHONE_PROCESS);
-        
+
       close(s_fdCommand);
       s_fdCommand = -1;
 
@@ -2285,7 +2228,7 @@ static void listenCallback (int fd, short flags, void *param) {
 
     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);
@@ -2337,7 +2280,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) 
+        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);
@@ -2373,7 +2316,7 @@ static void debugCallback (int fd, short flags, void *param) {
             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:
@@ -2398,12 +2341,12 @@ static void debugCallback (int fd, short flags, void *param) {
         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:
@@ -2418,7 +2361,7 @@ static void debugCallback (int fd, short flags, void *param) {
             break;
         case 10:
             LOGI("Debug port: End Call");
-            issueLocalRequest(RIL_REQUEST_HANGUP, &hangupData, 
+            issueLocalRequest(RIL_REQUEST_HANGUP, &hangupData,
                               sizeof(hangupData));
             break;
         default:
@@ -2485,17 +2428,17 @@ eventLoop(void *param) {
     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) {
@@ -2515,12 +2458,12 @@ extern "C" void RIL_setcallbacks (const RIL_RadioFunctions *callbacks) {
     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(
@@ -2546,7 +2489,7 @@ RIL_register (const RIL_RadioFunctions *callbacks) {
     }
 
     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);
     }
 
@@ -2560,7 +2503,7 @@ RIL_register (const RIL_RadioFunctions *callbacks) {
     // 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) {
@@ -2587,7 +2530,7 @@ RIL_register (const RIL_RadioFunctions *callbacks) {
 
 
     /* 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);
@@ -2620,15 +2563,15 @@ RIL_register (const RIL_RadioFunctions *callbacks) {
 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) {
@@ -2678,8 +2621,8 @@ RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responsel
 
         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 */
@@ -2687,8 +2630,10 @@ RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responsel
                 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) {
@@ -2741,7 +2686,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)
@@ -2848,11 +2793,11 @@ error_exit:
     }
 }
 
-/** 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;
@@ -2860,7 +2805,7 @@ internalRequestTimedCallback (RIL_TimedCallback callback, void *param,
 
     p_info = (UserCallbackInfo *) malloc (sizeof(UserCallbackInfo));
 
-    p_info->p_callback = callback; 
+    p_info->p_callback = callback;
     p_info->userParam = param;
 
     if (relativeTime == NULL) {
@@ -2881,7 +2826,7 @@ internalRequestTimedCallback (RIL_TimedCallback callback, void *param,
 
 
 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);
 }
@@ -2901,7 +2846,7 @@ failCauseToString(RIL_Errno e) {
         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
@@ -3037,11 +2982,11 @@ requestToString(int request) {
         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";