1 /* //device/libs/telephony/ril.cpp
3 ** Copyright 2006, The Android Open Source Project
5 ** Licensed under the Apache License, Version 2.0 (the "License");
6 ** you may not use this file except in compliance with the License.
7 ** You may obtain a copy of the License at
9 ** http://www.apache.org/licenses/LICENSE-2.0
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
18 #define LOG_TAG "RILC"
20 #include <hardware_legacy/power.h>
22 #include <telephony/ril.h>
23 #include <telephony/ril_cdma_sms.h>
24 #include <cutils/sockets.h>
25 #include <cutils/jstring.h>
26 #include <cutils/record_stream.h>
27 #include <utils/Log.h>
28 #include <utils/SystemClock.h>
30 #include <binder/Parcel.h>
31 #include <cutils/jstring.h>
33 #include <sys/types.h>
49 #include <netinet/in.h>
50 #include <cutils/properties.h>
52 #include <ril_event.h>
56 #define PHONE_PROCESS "radio"
58 #define SOCKET_NAME_RIL "rild"
59 #define SOCKET_NAME_RIL_DEBUG "rild-debug"
61 #define ANDROID_WAKE_LOCK_NAME "radio-interface"
64 #define PROPERTY_RIL_IMPL "gsm.version.ril-impl"
66 // match with constant in RIL.java
67 #define MAX_COMMAND_BYTES (8 * 1024)
69 // Basically: memset buffers that the client library
70 // shouldn't be using anymore in an attempt to find
71 // memory usage issues sooner.
72 #define MEMSET_FREED 1
74 #define NUM_ELEMS(a) (sizeof (a) / sizeof (a)[0])
76 #define MIN(a,b) ((a)<(b) ? (a) : (b))
78 /* Constants for response types */
79 #define RESPONSE_SOLICITED 0
80 #define RESPONSE_UNSOLICITED 1
82 /* Negative values for private RIL errno's */
83 #define RIL_ERRNO_INVALID_RESPONSE -1
85 // request, response, and unsolicited msg print macro
86 #define PRINTBUF_SIZE 8096
92 #define startRequest sprintf(printBuf, "(")
93 #define closeRequest sprintf(printBuf, "%s)", printBuf)
94 #define printRequest(token, req) \
95 LOGD("[%04d]> %s %s", token, requestToString(req), printBuf)
97 #define startResponse sprintf(printBuf, "%s {", printBuf)
98 #define closeResponse sprintf(printBuf, "%s}", printBuf)
99 #define printResponse LOGD("%s", printBuf)
101 #define clearPrintBuf printBuf[0] = 0
102 #define removeLastChar printBuf[strlen(printBuf)-1] = 0
103 #define appendPrintBuf(x...) sprintf(printBuf, x)
107 #define printRequest(token, req)
108 #define startResponse
109 #define closeResponse
110 #define printResponse
111 #define clearPrintBuf
112 #define removeLastChar
113 #define appendPrintBuf(x...)
116 enum WakeType {DONT_WAKE, WAKE_PARTIAL};
120 void (*dispatchFunction) (Parcel &p, struct RequestInfo *pRI);
121 int(*responseFunction) (Parcel &p, void *response, size_t responselen);
126 int (*responseFunction) (Parcel &p, void *response, size_t responselen);
130 typedef struct RequestInfo {
131 int32_t token; //this is not RIL_Token
133 struct RequestInfo *p_next;
135 char local; // responses to local commands do not go back to command process
138 typedef struct UserCallbackInfo {
139 RIL_TimedCallback p_callback;
141 struct ril_event event;
142 struct UserCallbackInfo *p_next;
146 /*******************************************************************/
148 RIL_RadioFunctions s_callbacks = {0, NULL, NULL, NULL, NULL, NULL};
149 static int s_registerCalled = 0;
151 static pthread_t s_tid_dispatch;
152 static pthread_t s_tid_reader;
153 static int s_started = 0;
155 static int s_fdListen = -1;
156 static int s_fdCommand = -1;
157 static int s_fdDebug = -1;
159 static int s_fdWakeupRead;
160 static int s_fdWakeupWrite;
162 static struct ril_event s_commands_event;
163 static struct ril_event s_wakeupfd_event;
164 static struct ril_event s_listen_event;
165 static struct ril_event s_wake_timeout_event;
166 static struct ril_event s_debug_event;
169 static const struct timeval TIMEVAL_WAKE_TIMEOUT = {1,0};
171 static pthread_mutex_t s_pendingRequestsMutex = PTHREAD_MUTEX_INITIALIZER;
172 static pthread_mutex_t s_writeMutex = PTHREAD_MUTEX_INITIALIZER;
173 static pthread_mutex_t s_startupMutex = PTHREAD_MUTEX_INITIALIZER;
174 static pthread_cond_t s_startupCond = PTHREAD_COND_INITIALIZER;
176 static pthread_mutex_t s_dispatchMutex = PTHREAD_MUTEX_INITIALIZER;
177 static pthread_cond_t s_dispatchCond = PTHREAD_COND_INITIALIZER;
179 static RequestInfo *s_pendingRequests = NULL;
181 static RequestInfo *s_toDispatchHead = NULL;
182 static RequestInfo *s_toDispatchTail = NULL;
184 static UserCallbackInfo *s_last_wake_timeout_info = NULL;
186 static void *s_lastNITZTimeData = NULL;
187 static size_t s_lastNITZTimeDataSize;
190 static char printBuf[PRINTBUF_SIZE];
193 /*******************************************************************/
195 static void dispatchVoid (Parcel& p, RequestInfo *pRI);
196 static void dispatchString (Parcel& p, RequestInfo *pRI);
197 static void dispatchStrings (Parcel& p, RequestInfo *pRI);
198 static void dispatchInts (Parcel& p, RequestInfo *pRI);
199 static void dispatchDial (Parcel& p, RequestInfo *pRI);
200 static void dispatchSIM_IO (Parcel& p, RequestInfo *pRI);
201 static void dispatchCallForward(Parcel& p, RequestInfo *pRI);
202 static void dispatchRaw(Parcel& p, RequestInfo *pRI);
203 static void dispatchSmsWrite (Parcel &p, RequestInfo *pRI);
204 static void dispatchDataCall (Parcel& p, RequestInfo *pRI);
206 static void dispatchCdmaSms(Parcel &p, RequestInfo *pRI);
207 static void dispatchCdmaSmsAck(Parcel &p, RequestInfo *pRI);
208 static void dispatchGsmBrSmsCnf(Parcel &p, RequestInfo *pRI);
209 static void dispatchCdmaBrSmsCnf(Parcel &p, RequestInfo *pRI);
210 static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI);
211 static int responseInts(Parcel &p, void *response, size_t responselen);
212 static int responseStrings(Parcel &p, void *response, size_t responselen);
213 static int responseString(Parcel &p, void *response, size_t responselen);
214 static int responseVoid(Parcel &p, void *response, size_t responselen);
215 static int responseCallList(Parcel &p, void *response, size_t responselen);
216 static int responseSMS(Parcel &p, void *response, size_t responselen);
217 static int responseSIM_IO(Parcel &p, void *response, size_t responselen);
218 static int responseCallForwards(Parcel &p, void *response, size_t responselen);
219 static int responseDataCallList(Parcel &p, void *response, size_t responselen);
220 static int responseRaw(Parcel &p, void *response, size_t responselen);
221 static int responseSsn(Parcel &p, void *response, size_t responselen);
222 static int responseSimStatus(Parcel &p, void *response, size_t responselen);
223 static int responseGsmBrSmsCnf(Parcel &p, void *response, size_t responselen);
224 static int responseCdmaBrSmsCnf(Parcel &p, void *response, size_t responselen);
225 static int responseCdmaSms(Parcel &p, void *response, size_t responselen);
226 static int responseCellList(Parcel &p, void *response, size_t responselen);
227 static int responseCdmaInformationRecords(Parcel &p,void *response, size_t responselen);
228 static int responseRilSignalStrength(Parcel &p,void *response, size_t responselen);
229 static int responseCallRing(Parcel &p, void *response, size_t responselen);
230 static int responseCdmaSignalInfoRecord(Parcel &p,void *response, size_t responselen);
231 static int responseCdmaCallWaiting(Parcel &p,void *response, size_t responselen);
233 extern "C" const char * requestToString(int request);
234 extern "C" const char * failCauseToString(RIL_Errno);
235 extern "C" const char * callStateToString(RIL_CallState);
236 extern "C" const char * radioStateToString(RIL_RadioState);
239 extern "C" void RIL_onUnsolicitedResponse(int unsolResponse, void *data,
243 static UserCallbackInfo * internalRequestTimedCallback
244 (RIL_TimedCallback callback, void *param,
245 const struct timeval *relativeTime);
247 /** Index == requestNumber */
248 static CommandInfo s_commands[] = {
249 #include "ril_commands.h"
252 static UnsolResponseInfo s_unsolResponses[] = {
253 #include "ril_unsol_commands.h"
258 strdupReadString(Parcel &p) {
262 s16 = p.readString16Inplace(&stringlen);
264 return strndup16to8(s16, stringlen);
267 static void writeStringToParcel(Parcel &p, const char *s) {
270 s16 = strdup8to16(s, &s16_len);
271 p.writeString16(s16, s16_len);
277 memsetString (char *s) {
279 memset (s, 0, strlen(s));
283 void nullParcelReleaseFunction (const uint8_t* data, size_t dataSize,
284 const size_t* objects, size_t objectsSize,
286 // do nothing -- the data reference lives longer than the Parcel object
290 * To be called from dispatch thread
291 * Issue a single local request, ensuring that the response
292 * is not sent back up to the command process
295 issueLocalRequest(int request, void *data, int len) {
299 pRI = (RequestInfo *)calloc(1, sizeof(RequestInfo));
302 pRI->token = 0xffffffff; // token is not used in this context
303 pRI->pCI = &(s_commands[request]);
305 ret = pthread_mutex_lock(&s_pendingRequestsMutex);
308 pRI->p_next = s_pendingRequests;
309 s_pendingRequests = pRI;
311 ret = pthread_mutex_unlock(&s_pendingRequestsMutex);
314 LOGD("C[locl]> %s", requestToString(request));
316 s_callbacks.onRequest(request, data, len, pRI);
322 processCommandBuffer(void *buffer, size_t buflen) {
330 p.setData((uint8_t *) buffer, buflen);
332 // status checked at end
333 status = p.readInt32(&request);
334 status = p.readInt32 (&token);
336 if (status != NO_ERROR) {
337 LOGE("invalid request block");
341 if (request < 1 || request >= (int32_t)NUM_ELEMS(s_commands)) {
342 LOGE("unsupported request code %d token %d", request, token);
343 // FIXME this should perhaps return a response
348 pRI = (RequestInfo *)calloc(1, sizeof(RequestInfo));
351 pRI->pCI = &(s_commands[request]);
353 ret = pthread_mutex_lock(&s_pendingRequestsMutex);
356 pRI->p_next = s_pendingRequests;
357 s_pendingRequests = pRI;
359 ret = pthread_mutex_unlock(&s_pendingRequestsMutex);
362 /* sLastDispatchedToken = token; */
364 pRI->pCI->dispatchFunction(p, pRI);
370 invalidCommandBlock (RequestInfo *pRI) {
371 LOGE("invalid command block for token %d request %s",
372 pRI->token, requestToString(pRI->pCI->requestNumber));
375 /** Callee expects NULL */
377 dispatchVoid (Parcel& p, RequestInfo *pRI) {
379 printRequest(pRI->token, pRI->pCI->requestNumber);
380 s_callbacks.onRequest(pRI->pCI->requestNumber, NULL, 0, pRI);
383 /** Callee expects const char * */
385 dispatchString (Parcel& p, RequestInfo *pRI) {
389 char *string8 = NULL;
391 string8 = strdupReadString(p);
394 appendPrintBuf("%s%s", printBuf, string8);
396 printRequest(pRI->token, pRI->pCI->requestNumber);
398 s_callbacks.onRequest(pRI->pCI->requestNumber, string8,
399 sizeof(char *), pRI);
402 memsetString(string8);
408 invalidCommandBlock(pRI);
412 /** Callee expects const char ** */
414 dispatchStrings (Parcel &p, RequestInfo *pRI) {
415 int32_t countStrings;
420 status = p.readInt32 (&countStrings);
422 if (status != NO_ERROR) {
427 if (countStrings == 0) {
428 // just some non-null pointer
429 pStrings = (char **)alloca(sizeof(char *));
431 } else if (((int)countStrings) == -1) {
435 datalen = sizeof(char *) * countStrings;
437 pStrings = (char **)alloca(datalen);
439 for (int i = 0 ; i < countStrings ; i++) {
440 pStrings[i] = strdupReadString(p);
441 appendPrintBuf("%s%s,", printBuf, pStrings[i]);
446 printRequest(pRI->token, pRI->pCI->requestNumber);
448 s_callbacks.onRequest(pRI->pCI->requestNumber, pStrings, datalen, pRI);
450 if (pStrings != NULL) {
451 for (int i = 0 ; i < countStrings ; i++) {
453 memsetString (pStrings[i]);
459 memset(pStrings, 0, datalen);
465 invalidCommandBlock(pRI);
469 /** Callee expects const int * */
471 dispatchInts (Parcel &p, RequestInfo *pRI) {
477 status = p.readInt32 (&count);
479 if (status != NO_ERROR || count == 0) {
483 datalen = sizeof(int) * count;
484 pInts = (int *)alloca(datalen);
487 for (int i = 0 ; i < count ; i++) {
490 status = p.readInt32(&t);
492 appendPrintBuf("%s%d,", printBuf, t);
494 if (status != NO_ERROR) {
500 printRequest(pRI->token, pRI->pCI->requestNumber);
502 s_callbacks.onRequest(pRI->pCI->requestNumber, const_cast<int *>(pInts),
506 memset(pInts, 0, datalen);
511 invalidCommandBlock(pRI);
517 * Callee expects const RIL_SMS_WriteArgs *
523 dispatchSmsWrite (Parcel &p, RequestInfo *pRI) {
524 RIL_SMS_WriteArgs args;
528 memset (&args, 0, sizeof(args));
530 status = p.readInt32(&t);
531 args.status = (int)t;
533 args.pdu = strdupReadString(p);
535 if (status != NO_ERROR || args.pdu == NULL) {
539 args.smsc = strdupReadString(p);
542 appendPrintBuf("%s%d,%s,smsc=%s", printBuf, args.status,
543 (char*)args.pdu, (char*)args.smsc);
545 printRequest(pRI->token, pRI->pCI->requestNumber);
547 s_callbacks.onRequest(pRI->pCI->requestNumber, &args, sizeof(args), pRI);
550 memsetString (args.pdu);
556 memset(&args, 0, sizeof(args));
561 invalidCommandBlock(pRI);
566 * Callee expects const RIL_Dial *
572 dispatchDial (Parcel &p, RequestInfo *pRI) {
574 RIL_UUS_Info uusInfo;
580 memset (&dial, 0, sizeof(dial));
582 dial.address = strdupReadString(p);
584 status = p.readInt32(&t);
587 if (status != NO_ERROR || dial.address == NULL) {
591 if (s_callbacks.version < 3) { // Remove when partners upgrade to version 3
593 sizeOfDial = sizeof(dial) - sizeof(RIL_UUS_Info *);
595 status = p.readInt32(&uusPresent);
597 if (status != NO_ERROR) {
601 if (uusPresent == 0) {
606 memset(&uusInfo, 0, sizeof(RIL_UUS_Info));
608 status = p.readInt32(&t);
609 uusInfo.uusType = (RIL_UUS_Type) t;
611 status = p.readInt32(&t);
612 uusInfo.uusDcs = (RIL_UUS_DCS) t;
614 status = p.readInt32(&len);
615 if (status != NO_ERROR) {
619 // The java code writes -1 for null arrays
620 if (((int) len) == -1) {
621 uusInfo.uusData = NULL;
624 uusInfo.uusData = (char*) p.readInplace(len);
627 uusInfo.uusLength = len;
628 dial.uusInfo = &uusInfo;
630 sizeOfDial = sizeof(dial);
634 appendPrintBuf("%snum=%s,clir=%d", printBuf, dial.address, dial.clir);
636 appendPrintBuf("%s,uusType=%d,uusDcs=%d,uusLen=%d", printBuf,
637 dial.uusInfo->uusType, dial.uusInfo->uusDcs,
638 dial.uusInfo->uusLength);
641 printRequest(pRI->token, pRI->pCI->requestNumber);
643 s_callbacks.onRequest(pRI->pCI->requestNumber, &dial, sizeOfDial, pRI);
646 memsetString (dial.address);
652 memset(&uusInfo, 0, sizeof(RIL_UUS_Info));
653 memset(&dial, 0, sizeof(dial));
658 invalidCommandBlock(pRI);
663 * Callee expects const RIL_SIM_IO *
673 dispatchSIM_IO (Parcel &p, RequestInfo *pRI) {
678 memset (&simIO, 0, sizeof(simIO));
680 // note we only check status at the end
682 status = p.readInt32(&t);
683 simIO.command = (int)t;
685 status = p.readInt32(&t);
686 simIO.fileid = (int)t;
688 simIO.path = strdupReadString(p);
690 status = p.readInt32(&t);
693 status = p.readInt32(&t);
696 status = p.readInt32(&t);
699 simIO.data = strdupReadString(p);
700 simIO.pin2 = strdupReadString(p);
703 appendPrintBuf("%scmd=0x%X,efid=0x%X,path=%s,%d,%d,%d,%s,pin2=%s", printBuf,
704 simIO.command, simIO.fileid, (char*)simIO.path,
705 simIO.p1, simIO.p2, simIO.p3,
706 (char*)simIO.data, (char*)simIO.pin2);
708 printRequest(pRI->token, pRI->pCI->requestNumber);
710 if (status != NO_ERROR) {
714 s_callbacks.onRequest(pRI->pCI->requestNumber, &simIO, sizeof(simIO), pRI);
717 memsetString (simIO.path);
718 memsetString (simIO.data);
719 memsetString (simIO.pin2);
727 memset(&simIO, 0, sizeof(simIO));
732 invalidCommandBlock(pRI);
737 * Callee expects const RIL_CallForwardInfo *
739 * int32_t status/action
741 * int32_t serviceCode
743 * String number (0 length -> null)
744 * int32_t timeSeconds
747 dispatchCallForward(Parcel &p, RequestInfo *pRI) {
748 RIL_CallForwardInfo cff;
752 memset (&cff, 0, sizeof(cff));
754 // note we only check status at the end
756 status = p.readInt32(&t);
759 status = p.readInt32(&t);
762 status = p.readInt32(&t);
763 cff.serviceClass = (int)t;
765 status = p.readInt32(&t);
768 cff.number = strdupReadString(p);
770 status = p.readInt32(&t);
771 cff.timeSeconds = (int)t;
773 if (status != NO_ERROR) {
777 // special case: number 0-length fields is null
779 if (cff.number != NULL && strlen (cff.number) == 0) {
784 appendPrintBuf("%sstat=%d,reason=%d,serv=%d,toa=%d,%s,tout=%d", printBuf,
785 cff.status, cff.reason, cff.serviceClass, cff.toa,
786 (char*)cff.number, cff.timeSeconds);
788 printRequest(pRI->token, pRI->pCI->requestNumber);
790 s_callbacks.onRequest(pRI->pCI->requestNumber, &cff, sizeof(cff), pRI);
793 memsetString(cff.number);
799 memset(&cff, 0, sizeof(cff));
804 invalidCommandBlock(pRI);
810 dispatchRaw(Parcel &p, RequestInfo *pRI) {
815 status = p.readInt32(&len);
817 if (status != NO_ERROR) {
821 // The java code writes -1 for null arrays
822 if (((int)len) == -1) {
827 data = p.readInplace(len);
830 appendPrintBuf("%sraw_size=%d", printBuf, len);
832 printRequest(pRI->token, pRI->pCI->requestNumber);
834 s_callbacks.onRequest(pRI->pCI->requestNumber, const_cast<void *>(data), len, pRI);
838 invalidCommandBlock(pRI);
843 dispatchCdmaSms(Parcel &p, RequestInfo *pRI) {
844 RIL_CDMA_SMS_Message rcsm;
851 memset(&rcsm, 0, sizeof(rcsm));
853 status = p.readInt32(&t);
854 rcsm.uTeleserviceID = (int) t;
856 status = p.read(&ut,sizeof(ut));
857 rcsm.bIsServicePresent = (uint8_t) ut;
859 status = p.readInt32(&t);
860 rcsm.uServicecategory = (int) t;
862 status = p.readInt32(&t);
863 rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) t;
865 status = p.readInt32(&t);
866 rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) t;
868 status = p.readInt32(&t);
869 rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) t;
871 status = p.readInt32(&t);
872 rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) t;
874 status = p.read(&ut,sizeof(ut));
875 rcsm.sAddress.number_of_digits= (uint8_t) ut;
877 digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
878 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
879 status = p.read(&ut,sizeof(ut));
880 rcsm.sAddress.digits[digitCount] = (uint8_t) ut;
883 status = p.readInt32(&t);
884 rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) t;
886 status = p.read(&ut,sizeof(ut));
887 rcsm.sSubAddress.odd = (uint8_t) ut;
889 status = p.read(&ut,sizeof(ut));
890 rcsm.sSubAddress.number_of_digits = (uint8_t) ut;
892 digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
893 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
894 status = p.read(&ut,sizeof(ut));
895 rcsm.sSubAddress.digits[digitCount] = (uint8_t) ut;
898 status = p.readInt32(&t);
899 rcsm.uBearerDataLen = (int) t;
901 digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
902 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
903 status = p.read(&ut, sizeof(ut));
904 rcsm.aBearerData[digitCount] = (uint8_t) ut;
907 if (status != NO_ERROR) {
912 appendPrintBuf("%suTeleserviceID=%d, bIsServicePresent=%d, uServicecategory=%d, \
913 sAddress.digit_mode=%d, sAddress.Number_mode=%d, sAddress.number_type=%d, ",
914 printBuf, rcsm.uTeleserviceID,rcsm.bIsServicePresent,rcsm.uServicecategory,
915 rcsm.sAddress.digit_mode, rcsm.sAddress.number_mode,rcsm.sAddress.number_type);
918 printRequest(pRI->token, pRI->pCI->requestNumber);
920 s_callbacks.onRequest(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm),pRI);
923 memset(&rcsm, 0, sizeof(rcsm));
929 invalidCommandBlock(pRI);
934 dispatchCdmaSmsAck(Parcel &p, RequestInfo *pRI) {
935 RIL_CDMA_SMS_Ack rcsa;
940 memset(&rcsa, 0, sizeof(rcsa));
942 status = p.readInt32(&t);
943 rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) t;
945 status = p.readInt32(&t);
946 rcsa.uSMSCauseCode = (int) t;
948 if (status != NO_ERROR) {
953 appendPrintBuf("%suErrorClass=%d, uTLStatus=%d, ",
954 printBuf, rcsa.uErrorClass, rcsa.uSMSCauseCode);
957 printRequest(pRI->token, pRI->pCI->requestNumber);
959 s_callbacks.onRequest(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa),pRI);
962 memset(&rcsa, 0, sizeof(rcsa));
968 invalidCommandBlock(pRI);
973 dispatchGsmBrSmsCnf(Parcel &p, RequestInfo *pRI) {
978 status = p.readInt32(&num);
979 if (status != NO_ERROR) {
983 RIL_GSM_BroadcastSmsConfigInfo gsmBci[num];
984 RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num];
987 for (int i = 0 ; i < num ; i++ ) {
988 gsmBciPtrs[i] = &gsmBci[i];
990 status = p.readInt32(&t);
991 gsmBci[i].fromServiceId = (int) t;
993 status = p.readInt32(&t);
994 gsmBci[i].toServiceId = (int) t;
996 status = p.readInt32(&t);
997 gsmBci[i].fromCodeScheme = (int) t;
999 status = p.readInt32(&t);
1000 gsmBci[i].toCodeScheme = (int) t;
1002 status = p.readInt32(&t);
1003 gsmBci[i].selected = (uint8_t) t;
1005 appendPrintBuf("%s [%d: fromServiceId=%d, toServiceId =%d, \
1006 fromCodeScheme=%d, toCodeScheme=%d, selected =%d]", printBuf, i,
1007 gsmBci[i].fromServiceId, gsmBci[i].toServiceId,
1008 gsmBci[i].fromCodeScheme, gsmBci[i].toCodeScheme,
1009 gsmBci[i].selected);
1013 if (status != NO_ERROR) {
1017 s_callbacks.onRequest(pRI->pCI->requestNumber,
1019 num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *),
1023 memset(gsmBci, 0, num * sizeof(RIL_GSM_BroadcastSmsConfigInfo));
1024 memset(gsmBciPtrs, 0, num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *));
1030 invalidCommandBlock(pRI);
1035 dispatchCdmaBrSmsCnf(Parcel &p, RequestInfo *pRI) {
1040 status = p.readInt32(&num);
1041 if (status != NO_ERROR) {
1045 RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num];
1046 RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num];
1049 for (int i = 0 ; i < num ; i++ ) {
1050 cdmaBciPtrs[i] = &cdmaBci[i];
1052 status = p.readInt32(&t);
1053 cdmaBci[i].service_category = (int) t;
1055 status = p.readInt32(&t);
1056 cdmaBci[i].language = (int) t;
1058 status = p.readInt32(&t);
1059 cdmaBci[i].selected = (uint8_t) t;
1061 appendPrintBuf("%s [%d: service_category=%d, language =%d, \
1062 entries.bSelected =%d]", printBuf, i, cdmaBci[i].service_category,
1063 cdmaBci[i].language, cdmaBci[i].selected);
1067 if (status != NO_ERROR) {
1071 s_callbacks.onRequest(pRI->pCI->requestNumber,
1073 num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *),
1077 memset(cdmaBci, 0, num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo));
1078 memset(cdmaBciPtrs, 0, num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *));
1084 invalidCommandBlock(pRI);
1088 static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI) {
1089 RIL_CDMA_SMS_WriteArgs rcsw;
1096 memset(&rcsw, 0, sizeof(rcsw));
1098 status = p.readInt32(&t);
1101 status = p.readInt32(&t);
1102 rcsw.message.uTeleserviceID = (int) t;
1104 status = p.read(&uct,sizeof(uct));
1105 rcsw.message.bIsServicePresent = (uint8_t) uct;
1107 status = p.readInt32(&t);
1108 rcsw.message.uServicecategory = (int) t;
1110 status = p.readInt32(&t);
1111 rcsw.message.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) t;
1113 status = p.readInt32(&t);
1114 rcsw.message.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) t;
1116 status = p.readInt32(&t);
1117 rcsw.message.sAddress.number_type = (RIL_CDMA_SMS_NumberType) t;
1119 status = p.readInt32(&t);
1120 rcsw.message.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) t;
1122 status = p.read(&uct,sizeof(uct));
1123 rcsw.message.sAddress.number_of_digits = (uint8_t) uct;
1125 for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_ADDRESS_MAX; digitCount ++) {
1126 status = p.read(&uct,sizeof(uct));
1127 rcsw.message.sAddress.digits[digitCount] = (uint8_t) uct;
1130 status = p.readInt32(&t);
1131 rcsw.message.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) t;
1133 status = p.read(&uct,sizeof(uct));
1134 rcsw.message.sSubAddress.odd = (uint8_t) uct;
1136 status = p.read(&uct,sizeof(uct));
1137 rcsw.message.sSubAddress.number_of_digits = (uint8_t) uct;
1139 for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_SUBADDRESS_MAX; digitCount ++) {
1140 status = p.read(&uct,sizeof(uct));
1141 rcsw.message.sSubAddress.digits[digitCount] = (uint8_t) uct;
1144 status = p.readInt32(&t);
1145 rcsw.message.uBearerDataLen = (int) t;
1147 for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_BEARER_DATA_MAX; digitCount ++) {
1148 status = p.read(&uct, sizeof(uct));
1149 rcsw.message.aBearerData[digitCount] = (uint8_t) uct;
1152 if (status != NO_ERROR) {
1157 appendPrintBuf("%sstatus=%d, message.uTeleserviceID=%d, message.bIsServicePresent=%d, \
1158 message.uServicecategory=%d, message.sAddress.digit_mode=%d, \
1159 message.sAddress.number_mode=%d, \
1160 message.sAddress.number_type=%d, ",
1161 printBuf, rcsw.status, rcsw.message.uTeleserviceID, rcsw.message.bIsServicePresent,
1162 rcsw.message.uServicecategory, rcsw.message.sAddress.digit_mode,
1163 rcsw.message.sAddress.number_mode,
1164 rcsw.message.sAddress.number_type);
1167 printRequest(pRI->token, pRI->pCI->requestNumber);
1169 s_callbacks.onRequest(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw),pRI);
1172 memset(&rcsw, 0, sizeof(rcsw));
1178 invalidCommandBlock(pRI);
1183 // For backwards compatibility in RIL_REQUEST_SETUP_DATA_CALL.
1184 // Version 4 of the RIL interface adds a new PDP type parameter to support
1185 // IPv6 and dual-stack PDP contexts. When dealing with a previous version of
1186 // RIL, remove the parameter from the request.
1187 static void dispatchDataCall(Parcel& p, RequestInfo *pRI) {
1188 // In RIL v3, REQUEST_SETUP_DATA_CALL takes 6 parameters.
1189 const int numParamsRilV3 = 6;
1191 // The first bytes of the RIL parcel contain the request number and the
1192 // serial number - see processCommandBuffer(). Copy them over too.
1193 int pos = p.dataPosition();
1195 int numParams = p.readInt32();
1196 if (s_callbacks.version < 4 && numParams > numParamsRilV3) {
1198 p2.appendFrom(&p, 0, pos);
1199 p2.writeInt32(numParamsRilV3);
1200 for(int i = 0; i < numParamsRilV3; i++) {
1201 p2.writeString16(p.readString16());
1203 p2.setDataPosition(pos);
1204 dispatchStrings(p2, pRI);
1206 dispatchStrings(p, pRI);
1211 blockingWrite(int fd, const void *buffer, size_t len) {
1212 size_t writeOffset = 0;
1213 const uint8_t *toWrite;
1215 toWrite = (const uint8_t *)buffer;
1217 while (writeOffset < len) {
1220 written = write (fd, toWrite + writeOffset,
1222 } while (written < 0 && errno == EINTR);
1225 writeOffset += written;
1226 } else { // written < 0
1227 LOGE ("RIL Response: unexpected error on write errno:%d", errno);
1237 sendResponseRaw (const void *data, size_t dataSize) {
1238 int fd = s_fdCommand;
1242 if (s_fdCommand < 0) {
1246 if (dataSize > MAX_COMMAND_BYTES) {
1247 LOGE("RIL: packet larger than %u (%u)",
1248 MAX_COMMAND_BYTES, (unsigned int )dataSize);
1253 pthread_mutex_lock(&s_writeMutex);
1255 header = htonl(dataSize);
1257 ret = blockingWrite(fd, (void *)&header, sizeof(header));
1260 pthread_mutex_unlock(&s_writeMutex);
1264 ret = blockingWrite(fd, data, dataSize);
1267 pthread_mutex_unlock(&s_writeMutex);
1271 pthread_mutex_unlock(&s_writeMutex);
1277 sendResponse (Parcel &p) {
1279 return sendResponseRaw(p.data(), p.dataSize());
1282 /** response is an int* pointing to an array of ints*/
1285 responseInts(Parcel &p, void *response, size_t responselen) {
1288 if (response == NULL && responselen != 0) {
1289 LOGE("invalid response: NULL");
1290 return RIL_ERRNO_INVALID_RESPONSE;
1292 if (responselen % sizeof(int) != 0) {
1293 LOGE("invalid response length %d expected multiple of %d\n",
1294 (int)responselen, (int)sizeof(int));
1295 return RIL_ERRNO_INVALID_RESPONSE;
1298 int *p_int = (int *) response;
1300 numInts = responselen / sizeof(int *);
1301 p.writeInt32 (numInts);
1305 for (int i = 0 ; i < numInts ; i++) {
1306 appendPrintBuf("%s%d,", printBuf, p_int[i]);
1307 p.writeInt32(p_int[i]);
1315 /** response is a char **, pointing to an array of char *'s */
1316 static int responseStrings(Parcel &p, void *response, size_t responselen) {
1319 if (response == NULL && responselen != 0) {
1320 LOGE("invalid response: NULL");
1321 return RIL_ERRNO_INVALID_RESPONSE;
1323 if (responselen % sizeof(char *) != 0) {
1324 LOGE("invalid response length %d expected multiple of %d\n",
1325 (int)responselen, (int)sizeof(char *));
1326 return RIL_ERRNO_INVALID_RESPONSE;
1329 if (response == NULL) {
1332 char **p_cur = (char **) response;
1334 numStrings = responselen / sizeof(char *);
1335 p.writeInt32 (numStrings);
1339 for (int i = 0 ; i < numStrings ; i++) {
1340 appendPrintBuf("%s%s,", printBuf, (char*)p_cur[i]);
1341 writeStringToParcel (p, p_cur[i]);
1351 * NULL strings are accepted
1352 * FIXME currently ignores responselen
1354 static int responseString(Parcel &p, void *response, size_t responselen) {
1355 /* one string only */
1357 appendPrintBuf("%s%s", printBuf, (char*)response);
1360 writeStringToParcel(p, (const char *)response);
1365 static int responseVoid(Parcel &p, void *response, size_t responselen) {
1371 static int responseCallList(Parcel &p, void *response, size_t responselen) {
1374 if (response == NULL && responselen != 0) {
1375 LOGE("invalid response: NULL");
1376 return RIL_ERRNO_INVALID_RESPONSE;
1379 if (responselen % sizeof (RIL_Call *) != 0) {
1380 LOGE("invalid response length %d expected multiple of %d\n",
1381 (int)responselen, (int)sizeof (RIL_Call *));
1382 return RIL_ERRNO_INVALID_RESPONSE;
1386 /* number of call info's */
1387 num = responselen / sizeof(RIL_Call *);
1390 for (int i = 0 ; i < num ; i++) {
1391 RIL_Call *p_cur = ((RIL_Call **) response)[i];
1392 /* each call info */
1393 p.writeInt32(p_cur->state);
1394 p.writeInt32(p_cur->index);
1395 p.writeInt32(p_cur->toa);
1396 p.writeInt32(p_cur->isMpty);
1397 p.writeInt32(p_cur->isMT);
1398 p.writeInt32(p_cur->als);
1399 p.writeInt32(p_cur->isVoice);
1400 p.writeInt32(p_cur->isVoicePrivacy);
1401 writeStringToParcel(p, p_cur->number);
1402 p.writeInt32(p_cur->numberPresentation);
1403 writeStringToParcel(p, p_cur->name);
1404 p.writeInt32(p_cur->namePresentation);
1405 // Remove when partners upgrade to version 3
1406 if ((s_callbacks.version < 3) || (p_cur->uusInfo == NULL || p_cur->uusInfo->uusData == NULL)) {
1407 p.writeInt32(0); /* UUS Information is absent */
1409 RIL_UUS_Info *uusInfo = p_cur->uusInfo;
1410 p.writeInt32(1); /* UUS Information is present */
1411 p.writeInt32(uusInfo->uusType);
1412 p.writeInt32(uusInfo->uusDcs);
1413 p.writeInt32(uusInfo->uusLength);
1414 p.write(uusInfo->uusData, uusInfo->uusLength);
1416 appendPrintBuf("%s[id=%d,%s,toa=%d,",
1419 callStateToString(p_cur->state),
1421 appendPrintBuf("%s%s,%s,als=%d,%s,%s,",
1423 (p_cur->isMpty)?"conf":"norm",
1424 (p_cur->isMT)?"mt":"mo",
1426 (p_cur->isVoice)?"voc":"nonvoc",
1427 (p_cur->isVoicePrivacy)?"evp":"noevp");
1428 appendPrintBuf("%s%s,cli=%d,name='%s',%d]",
1431 p_cur->numberPresentation,
1433 p_cur->namePresentation);
1441 static int responseSMS(Parcel &p, void *response, size_t responselen) {
1442 if (response == NULL) {
1443 LOGE("invalid response: NULL");
1444 return RIL_ERRNO_INVALID_RESPONSE;
1447 if (responselen != sizeof (RIL_SMS_Response) ) {
1448 LOGE("invalid response length %d expected %d",
1449 (int)responselen, (int)sizeof (RIL_SMS_Response));
1450 return RIL_ERRNO_INVALID_RESPONSE;
1453 RIL_SMS_Response *p_cur = (RIL_SMS_Response *) response;
1455 p.writeInt32(p_cur->messageRef);
1456 writeStringToParcel(p, p_cur->ackPDU);
1457 p.writeInt32(p_cur->errorCode);
1460 appendPrintBuf("%s%d,%s,%d", printBuf, p_cur->messageRef,
1461 (char*)p_cur->ackPDU, p_cur->errorCode);
1467 static int responseDataCallList(Parcel &p, void *response, size_t responselen)
1469 if (response == NULL && responselen != 0) {
1470 LOGE("invalid response: NULL");
1471 return RIL_ERRNO_INVALID_RESPONSE;
1474 if (responselen % sizeof(RIL_Data_Call_Response) != 0) {
1475 LOGE("invalid response length %d expected multiple of %d",
1476 (int)responselen, (int)sizeof(RIL_Data_Call_Response));
1477 return RIL_ERRNO_INVALID_RESPONSE;
1480 int num = responselen / sizeof(RIL_Data_Call_Response);
1483 RIL_Data_Call_Response *p_cur = (RIL_Data_Call_Response *) response;
1486 for (i = 0; i < num; i++) {
1487 p.writeInt32(p_cur[i].cid);
1488 p.writeInt32(p_cur[i].active);
1489 writeStringToParcel(p, p_cur[i].type);
1490 writeStringToParcel(p, p_cur[i].apn);
1491 writeStringToParcel(p, p_cur[i].address);
1492 appendPrintBuf("%s[cid=%d,%s,%s,%s,%s],", printBuf,
1494 (p_cur[i].active==0)?"down":"up",
1495 (char*)p_cur[i].type,
1496 (char*)p_cur[i].apn,
1497 (char*)p_cur[i].address);
1505 static int responseRaw(Parcel &p, void *response, size_t responselen) {
1506 if (response == NULL && responselen != 0) {
1507 LOGE("invalid response: NULL with responselen != 0");
1508 return RIL_ERRNO_INVALID_RESPONSE;
1511 // The java code reads -1 size as null byte array
1512 if (response == NULL) {
1515 p.writeInt32(responselen);
1516 p.write(response, responselen);
1523 static int responseSIM_IO(Parcel &p, void *response, size_t responselen) {
1524 if (response == NULL) {
1525 LOGE("invalid response: NULL");
1526 return RIL_ERRNO_INVALID_RESPONSE;
1529 if (responselen != sizeof (RIL_SIM_IO_Response) ) {
1530 LOGE("invalid response length was %d expected %d",
1531 (int)responselen, (int)sizeof (RIL_SIM_IO_Response));
1532 return RIL_ERRNO_INVALID_RESPONSE;
1535 RIL_SIM_IO_Response *p_cur = (RIL_SIM_IO_Response *) response;
1536 p.writeInt32(p_cur->sw1);
1537 p.writeInt32(p_cur->sw2);
1538 writeStringToParcel(p, p_cur->simResponse);
1541 appendPrintBuf("%ssw1=0x%X,sw2=0x%X,%s", printBuf, p_cur->sw1, p_cur->sw2,
1542 (char*)p_cur->simResponse);
1549 static int responseCallForwards(Parcel &p, void *response, size_t responselen) {
1552 if (response == NULL && responselen != 0) {
1553 LOGE("invalid response: NULL");
1554 return RIL_ERRNO_INVALID_RESPONSE;
1557 if (responselen % sizeof(RIL_CallForwardInfo *) != 0) {
1558 LOGE("invalid response length %d expected multiple of %d",
1559 (int)responselen, (int)sizeof(RIL_CallForwardInfo *));
1560 return RIL_ERRNO_INVALID_RESPONSE;
1563 /* number of call info's */
1564 num = responselen / sizeof(RIL_CallForwardInfo *);
1568 for (int i = 0 ; i < num ; i++) {
1569 RIL_CallForwardInfo *p_cur = ((RIL_CallForwardInfo **) response)[i];
1571 p.writeInt32(p_cur->status);
1572 p.writeInt32(p_cur->reason);
1573 p.writeInt32(p_cur->serviceClass);
1574 p.writeInt32(p_cur->toa);
1575 writeStringToParcel(p, p_cur->number);
1576 p.writeInt32(p_cur->timeSeconds);
1577 appendPrintBuf("%s[%s,reason=%d,cls=%d,toa=%d,%s,tout=%d],", printBuf,
1578 (p_cur->status==1)?"enable":"disable",
1579 p_cur->reason, p_cur->serviceClass, p_cur->toa,
1580 (char*)p_cur->number,
1581 p_cur->timeSeconds);
1589 static int responseSsn(Parcel &p, void *response, size_t responselen) {
1590 if (response == NULL) {
1591 LOGE("invalid response: NULL");
1592 return RIL_ERRNO_INVALID_RESPONSE;
1595 if (responselen != sizeof(RIL_SuppSvcNotification)) {
1596 LOGE("invalid response length was %d expected %d",
1597 (int)responselen, (int)sizeof (RIL_SuppSvcNotification));
1598 return RIL_ERRNO_INVALID_RESPONSE;
1601 RIL_SuppSvcNotification *p_cur = (RIL_SuppSvcNotification *) response;
1602 p.writeInt32(p_cur->notificationType);
1603 p.writeInt32(p_cur->code);
1604 p.writeInt32(p_cur->index);
1605 p.writeInt32(p_cur->type);
1606 writeStringToParcel(p, p_cur->number);
1609 appendPrintBuf("%s%s,code=%d,id=%d,type=%d,%s", printBuf,
1610 (p_cur->notificationType==0)?"mo":"mt",
1611 p_cur->code, p_cur->index, p_cur->type,
1612 (char*)p_cur->number);
1618 static int responseCellList(Parcel &p, void *response, size_t responselen) {
1621 if (response == NULL && responselen != 0) {
1622 LOGE("invalid response: NULL");
1623 return RIL_ERRNO_INVALID_RESPONSE;
1626 if (responselen % sizeof (RIL_NeighboringCell *) != 0) {
1627 LOGE("invalid response length %d expected multiple of %d\n",
1628 (int)responselen, (int)sizeof (RIL_NeighboringCell *));
1629 return RIL_ERRNO_INVALID_RESPONSE;
1633 /* number of records */
1634 num = responselen / sizeof(RIL_NeighboringCell *);
1637 for (int i = 0 ; i < num ; i++) {
1638 RIL_NeighboringCell *p_cur = ((RIL_NeighboringCell **) response)[i];
1640 p.writeInt32(p_cur->rssi);
1641 writeStringToParcel (p, p_cur->cid);
1643 appendPrintBuf("%s[cid=%s,rssi=%d],", printBuf,
1644 p_cur->cid, p_cur->rssi);
1653 * Marshall the signalInfoRecord into the parcel if it exists.
1655 static void marshallSignalInfoRecord(Parcel &p,
1656 RIL_CDMA_SignalInfoRecord &p_signalInfoRecord) {
1657 p.writeInt32(p_signalInfoRecord.isPresent);
1658 p.writeInt32(p_signalInfoRecord.signalType);
1659 p.writeInt32(p_signalInfoRecord.alertPitch);
1660 p.writeInt32(p_signalInfoRecord.signal);
1663 static int responseCdmaInformationRecords(Parcel &p,
1664 void *response, size_t responselen) {
1666 char* string8 = NULL;
1668 RIL_CDMA_InformationRecord *infoRec;
1670 if (response == NULL && responselen != 0) {
1671 LOGE("invalid response: NULL");
1672 return RIL_ERRNO_INVALID_RESPONSE;
1675 if (responselen != sizeof (RIL_CDMA_InformationRecords)) {
1676 LOGE("invalid response length %d expected multiple of %d\n",
1677 (int)responselen, (int)sizeof (RIL_CDMA_InformationRecords *));
1678 return RIL_ERRNO_INVALID_RESPONSE;
1681 RIL_CDMA_InformationRecords *p_cur =
1682 (RIL_CDMA_InformationRecords *) response;
1683 num = MIN(p_cur->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
1688 for (int i = 0 ; i < num ; i++) {
1689 infoRec = &p_cur->infoRec[i];
1690 p.writeInt32(infoRec->name);
1691 switch (infoRec->name) {
1692 case RIL_CDMA_DISPLAY_INFO_REC:
1693 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC:
1694 if (infoRec->rec.display.alpha_len >
1695 CDMA_ALPHA_INFO_BUFFER_LENGTH) {
1696 LOGE("invalid display info response length %d \
1697 expected not more than %d\n",
1698 (int)infoRec->rec.display.alpha_len,
1699 CDMA_ALPHA_INFO_BUFFER_LENGTH);
1700 return RIL_ERRNO_INVALID_RESPONSE;
1702 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1)
1704 for (int i = 0 ; i < infoRec->rec.display.alpha_len ; i++) {
1705 string8[i] = infoRec->rec.display.alpha_buf[i];
1707 string8[infoRec->rec.display.alpha_len] = '\0';
1708 writeStringToParcel(p, (const char*)string8);
1712 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
1713 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
1714 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC:
1715 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
1716 LOGE("invalid display info response length %d \
1717 expected not more than %d\n",
1718 (int)infoRec->rec.number.len,
1719 CDMA_NUMBER_INFO_BUFFER_LENGTH);
1720 return RIL_ERRNO_INVALID_RESPONSE;
1722 string8 = (char*) malloc((infoRec->rec.number.len + 1)
1724 for (int i = 0 ; i < infoRec->rec.number.len; i++) {
1725 string8[i] = infoRec->rec.number.buf[i];
1727 string8[infoRec->rec.number.len] = '\0';
1728 writeStringToParcel(p, (const char*)string8);
1731 p.writeInt32(infoRec->rec.number.number_type);
1732 p.writeInt32(infoRec->rec.number.number_plan);
1733 p.writeInt32(infoRec->rec.number.pi);
1734 p.writeInt32(infoRec->rec.number.si);
1736 case RIL_CDMA_SIGNAL_INFO_REC:
1737 p.writeInt32(infoRec->rec.signal.isPresent);
1738 p.writeInt32(infoRec->rec.signal.signalType);
1739 p.writeInt32(infoRec->rec.signal.alertPitch);
1740 p.writeInt32(infoRec->rec.signal.signal);
1742 appendPrintBuf("%sisPresent=%X, signalType=%X, \
1743 alertPitch=%X, signal=%X, ",
1744 printBuf, (int)infoRec->rec.signal.isPresent,
1745 (int)infoRec->rec.signal.signalType,
1746 (int)infoRec->rec.signal.alertPitch,
1747 (int)infoRec->rec.signal.signal);
1750 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC:
1751 if (infoRec->rec.redir.redirectingNumber.len >
1752 CDMA_NUMBER_INFO_BUFFER_LENGTH) {
1753 LOGE("invalid display info response length %d \
1754 expected not more than %d\n",
1755 (int)infoRec->rec.redir.redirectingNumber.len,
1756 CDMA_NUMBER_INFO_BUFFER_LENGTH);
1757 return RIL_ERRNO_INVALID_RESPONSE;
1759 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber
1760 .len + 1) * sizeof(char) );
1762 i < infoRec->rec.redir.redirectingNumber.len;
1764 string8[i] = infoRec->rec.redir.redirectingNumber.buf[i];
1766 string8[infoRec->rec.redir.redirectingNumber.len] = '\0';
1767 writeStringToParcel(p, (const char*)string8);
1770 p.writeInt32(infoRec->rec.redir.redirectingNumber.number_type);
1771 p.writeInt32(infoRec->rec.redir.redirectingNumber.number_plan);
1772 p.writeInt32(infoRec->rec.redir.redirectingNumber.pi);
1773 p.writeInt32(infoRec->rec.redir.redirectingNumber.si);
1774 p.writeInt32(infoRec->rec.redir.redirectingReason);
1776 case RIL_CDMA_LINE_CONTROL_INFO_REC:
1777 p.writeInt32(infoRec->rec.lineCtrl.lineCtrlPolarityIncluded);
1778 p.writeInt32(infoRec->rec.lineCtrl.lineCtrlToggle);
1779 p.writeInt32(infoRec->rec.lineCtrl.lineCtrlReverse);
1780 p.writeInt32(infoRec->rec.lineCtrl.lineCtrlPowerDenial);
1782 appendPrintBuf("%slineCtrlPolarityIncluded=%d, \
1783 lineCtrlToggle=%d, lineCtrlReverse=%d, \
1784 lineCtrlPowerDenial=%d, ", printBuf,
1785 (int)infoRec->rec.lineCtrl.lineCtrlPolarityIncluded,
1786 (int)infoRec->rec.lineCtrl.lineCtrlToggle,
1787 (int)infoRec->rec.lineCtrl.lineCtrlReverse,
1788 (int)infoRec->rec.lineCtrl.lineCtrlPowerDenial);
1791 case RIL_CDMA_T53_CLIR_INFO_REC:
1792 p.writeInt32((int)(infoRec->rec.clir.cause));
1794 appendPrintBuf("%scause%d", printBuf, infoRec->rec.clir.cause);
1797 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC:
1798 p.writeInt32(infoRec->rec.audioCtrl.upLink);
1799 p.writeInt32(infoRec->rec.audioCtrl.downLink);
1801 appendPrintBuf("%supLink=%d, downLink=%d, ", printBuf,
1802 infoRec->rec.audioCtrl.upLink,
1803 infoRec->rec.audioCtrl.downLink);
1806 case RIL_CDMA_T53_RELEASE_INFO_REC:
1807 // TODO(Moto): See David Krause, he has the answer:)
1808 LOGE("RIL_CDMA_T53_RELEASE_INFO_REC: return INVALID_RESPONSE");
1809 return RIL_ERRNO_INVALID_RESPONSE;
1811 LOGE("Incorrect name value");
1812 return RIL_ERRNO_INVALID_RESPONSE;
1820 static int responseRilSignalStrength(Parcel &p,
1821 void *response, size_t responselen) {
1822 if (response == NULL && responselen != 0) {
1823 LOGE("invalid response: NULL");
1824 return RIL_ERRNO_INVALID_RESPONSE;
1827 if (responselen == sizeof (RIL_SignalStrength)) {
1829 RIL_SignalStrength *p_cur = ((RIL_SignalStrength *) response);
1831 p.writeInt32(p_cur->GW_SignalStrength.signalStrength);
1832 p.writeInt32(p_cur->GW_SignalStrength.bitErrorRate);
1833 p.writeInt32(p_cur->CDMA_SignalStrength.dbm);
1834 p.writeInt32(p_cur->CDMA_SignalStrength.ecio);
1835 p.writeInt32(p_cur->EVDO_SignalStrength.dbm);
1836 p.writeInt32(p_cur->EVDO_SignalStrength.ecio);
1837 p.writeInt32(p_cur->EVDO_SignalStrength.signalNoiseRatio);
1840 appendPrintBuf("%s[signalStrength=%d,bitErrorRate=%d,\
1841 CDMA_SignalStrength.dbm=%d,CDMA_SignalStrength.ecio=%d,\
1842 EVDO_SignalStrength.dbm =%d,EVDO_SignalStrength.ecio=%d,\
1843 EVDO_SignalStrength.signalNoiseRatio=%d]",
1845 p_cur->GW_SignalStrength.signalStrength,
1846 p_cur->GW_SignalStrength.bitErrorRate,
1847 p_cur->CDMA_SignalStrength.dbm,
1848 p_cur->CDMA_SignalStrength.ecio,
1849 p_cur->EVDO_SignalStrength.dbm,
1850 p_cur->EVDO_SignalStrength.ecio,
1851 p_cur->EVDO_SignalStrength.signalNoiseRatio);
1855 } else if (responselen % sizeof (int) == 0) {
1856 // Old RIL deprecated
1857 int *p_cur = (int *) response;
1861 // With the Old RIL we see one or 2 integers.
1862 size_t num = responselen / sizeof (int); // Number of integers from ril
1863 size_t totalIntegers = 7; // Number of integers in RIL_SignalStrength
1866 appendPrintBuf("%s[", printBuf);
1867 for (i = 0; i < num; i++) {
1868 appendPrintBuf("%s %d", printBuf, *p_cur);
1869 p.writeInt32(*p_cur++);
1871 appendPrintBuf("%s]", printBuf);
1873 // Fill the remainder with zero's.
1874 for (; i < totalIntegers; i++) {
1880 LOGE("invalid response length");
1881 return RIL_ERRNO_INVALID_RESPONSE;
1887 static int responseCallRing(Parcel &p, void *response, size_t responselen) {
1888 if ((response == NULL) || (responselen == 0)) {
1889 return responseVoid(p, response, responselen);
1891 return responseCdmaSignalInfoRecord(p, response, responselen);
1895 static int responseCdmaSignalInfoRecord(Parcel &p, void *response, size_t responselen) {
1896 if (response == NULL || responselen == 0) {
1897 LOGE("invalid response: NULL");
1898 return RIL_ERRNO_INVALID_RESPONSE;
1901 if (responselen != sizeof (RIL_CDMA_SignalInfoRecord)) {
1902 LOGE("invalid response length %d expected sizeof (RIL_CDMA_SignalInfoRecord) of %d\n",
1903 (int)responselen, (int)sizeof (RIL_CDMA_SignalInfoRecord));
1904 return RIL_ERRNO_INVALID_RESPONSE;
1909 RIL_CDMA_SignalInfoRecord *p_cur = ((RIL_CDMA_SignalInfoRecord *) response);
1910 marshallSignalInfoRecord(p, *p_cur);
1912 appendPrintBuf("%s[isPresent=%d,signalType=%d,alertPitch=%d\
1924 static int responseCdmaCallWaiting(Parcel &p, void *response,
1925 size_t responselen) {
1926 if (response == NULL && responselen != 0) {
1927 LOGE("invalid response: NULL");
1928 return RIL_ERRNO_INVALID_RESPONSE;
1931 if (responselen != sizeof(RIL_CDMA_CallWaiting)) {
1932 LOGE("invalid response length %d expected %d\n",
1933 (int)responselen, (int)sizeof(RIL_CDMA_CallWaiting));
1934 return RIL_ERRNO_INVALID_RESPONSE;
1938 RIL_CDMA_CallWaiting *p_cur = ((RIL_CDMA_CallWaiting *) response);
1940 writeStringToParcel (p, p_cur->number);
1941 p.writeInt32(p_cur->numberPresentation);
1942 writeStringToParcel (p, p_cur->name);
1943 marshallSignalInfoRecord(p, p_cur->signalInfoRecord);
1945 appendPrintBuf("%snumber=%s,numberPresentation=%d, name=%s,\
1946 signalInfoRecord[isPresent=%d,signalType=%d,alertPitch=%d\
1950 p_cur->numberPresentation,
1952 p_cur->signalInfoRecord.isPresent,
1953 p_cur->signalInfoRecord.signalType,
1954 p_cur->signalInfoRecord.alertPitch,
1955 p_cur->signalInfoRecord.signal);
1962 static void triggerEvLoop() {
1964 if (!pthread_equal(pthread_self(), s_tid_dispatch)) {
1965 /* trigger event loop to wakeup. No reason to do this,
1966 * if we're in the event loop thread */
1968 ret = write (s_fdWakeupWrite, " ", 1);
1969 } while (ret < 0 && errno == EINTR);
1973 static void rilEventAddWakeup(struct ril_event *ev) {
1978 static int responseSimStatus(Parcel &p, void *response, size_t responselen) {
1981 if (response == NULL && responselen != 0) {
1982 LOGE("invalid response: NULL");
1983 return RIL_ERRNO_INVALID_RESPONSE;
1986 if (responselen % sizeof (RIL_CardStatus *) != 0) {
1987 LOGE("invalid response length %d expected multiple of %d\n",
1988 (int)responselen, (int)sizeof (RIL_CardStatus *));
1989 return RIL_ERRNO_INVALID_RESPONSE;
1992 RIL_CardStatus *p_cur = ((RIL_CardStatus *) response);
1994 p.writeInt32(p_cur->card_state);
1995 p.writeInt32(p_cur->universal_pin_state);
1996 p.writeInt32(p_cur->gsm_umts_subscription_app_index);
1997 p.writeInt32(p_cur->cdma_subscription_app_index);
1998 p.writeInt32(p_cur->num_applications);
2001 for (i = 0; i < p_cur->num_applications; i++) {
2002 p.writeInt32(p_cur->applications[i].app_type);
2003 p.writeInt32(p_cur->applications[i].app_state);
2004 p.writeInt32(p_cur->applications[i].perso_substate);
2005 writeStringToParcel(p, (const char*)(p_cur->applications[i].aid_ptr));
2006 writeStringToParcel(p, (const char*)
2007 (p_cur->applications[i].app_label_ptr));
2008 p.writeInt32(p_cur->applications[i].pin1_replaced);
2009 p.writeInt32(p_cur->applications[i].pin1);
2010 p.writeInt32(p_cur->applications[i].pin2);
2011 appendPrintBuf("%s[app_type=%d,app_state=%d,perso_substate=%d,\
2012 aid_ptr=%s,app_label_ptr=%s,pin1_replaced=%d,pin1=%d,pin2=%d],",
2014 p_cur->applications[i].app_type,
2015 p_cur->applications[i].app_state,
2016 p_cur->applications[i].perso_substate,
2017 p_cur->applications[i].aid_ptr,
2018 p_cur->applications[i].app_label_ptr,
2019 p_cur->applications[i].pin1_replaced,
2020 p_cur->applications[i].pin1,
2021 p_cur->applications[i].pin2);
2028 static int responseGsmBrSmsCnf(Parcel &p, void *response, size_t responselen) {
2029 int num = responselen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
2033 RIL_GSM_BroadcastSmsConfigInfo **p_cur =
2034 (RIL_GSM_BroadcastSmsConfigInfo **) response;
2035 for (int i = 0; i < num; i++) {
2036 p.writeInt32(p_cur[i]->fromServiceId);
2037 p.writeInt32(p_cur[i]->toServiceId);
2038 p.writeInt32(p_cur[i]->fromCodeScheme);
2039 p.writeInt32(p_cur[i]->toCodeScheme);
2040 p.writeInt32(p_cur[i]->selected);
2042 appendPrintBuf("%s [%d: fromServiceId=%d, toServiceId=%d, \
2043 fromCodeScheme=%d, toCodeScheme=%d, selected =%d]",
2044 printBuf, i, p_cur[i]->fromServiceId, p_cur[i]->toServiceId,
2045 p_cur[i]->fromCodeScheme, p_cur[i]->toCodeScheme,
2046 p_cur[i]->selected);
2053 static int responseCdmaBrSmsCnf(Parcel &p, void *response, size_t responselen) {
2054 RIL_CDMA_BroadcastSmsConfigInfo **p_cur =
2055 (RIL_CDMA_BroadcastSmsConfigInfo **) response;
2057 int num = responselen / sizeof (RIL_CDMA_BroadcastSmsConfigInfo *);
2061 for (int i = 0 ; i < num ; i++ ) {
2062 p.writeInt32(p_cur[i]->service_category);
2063 p.writeInt32(p_cur[i]->language);
2064 p.writeInt32(p_cur[i]->selected);
2066 appendPrintBuf("%s [%d: srvice_category=%d, language =%d, \
2068 printBuf, i, p_cur[i]->service_category, p_cur[i]->language,
2069 p_cur[i]->selected);
2076 static int responseCdmaSms(Parcel &p, void *response, size_t responselen) {
2083 LOGD("Inside responseCdmaSms");
2085 if (response == NULL && responselen != 0) {
2086 LOGE("invalid response: NULL");
2087 return RIL_ERRNO_INVALID_RESPONSE;
2090 if (responselen != sizeof(RIL_CDMA_SMS_Message)) {
2091 LOGE("invalid response length was %d expected %d",
2092 (int)responselen, (int)sizeof(RIL_CDMA_SMS_Message));
2093 return RIL_ERRNO_INVALID_RESPONSE;
2096 RIL_CDMA_SMS_Message *p_cur = (RIL_CDMA_SMS_Message *) response;
2097 p.writeInt32(p_cur->uTeleserviceID);
2098 p.write(&(p_cur->bIsServicePresent),sizeof(uct));
2099 p.writeInt32(p_cur->uServicecategory);
2100 p.writeInt32(p_cur->sAddress.digit_mode);
2101 p.writeInt32(p_cur->sAddress.number_mode);
2102 p.writeInt32(p_cur->sAddress.number_type);
2103 p.writeInt32(p_cur->sAddress.number_plan);
2104 p.write(&(p_cur->sAddress.number_of_digits), sizeof(uct));
2105 digitLimit= MIN((p_cur->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
2106 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
2107 p.write(&(p_cur->sAddress.digits[digitCount]),sizeof(uct));
2110 p.writeInt32(p_cur->sSubAddress.subaddressType);
2111 p.write(&(p_cur->sSubAddress.odd),sizeof(uct));
2112 p.write(&(p_cur->sSubAddress.number_of_digits),sizeof(uct));
2113 digitLimit= MIN((p_cur->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
2114 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
2115 p.write(&(p_cur->sSubAddress.digits[digitCount]),sizeof(uct));
2118 digitLimit= MIN((p_cur->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
2119 p.writeInt32(p_cur->uBearerDataLen);
2120 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
2121 p.write(&(p_cur->aBearerData[digitCount]), sizeof(uct));
2125 appendPrintBuf("%suTeleserviceID=%d, bIsServicePresent=%d, uServicecategory=%d, \
2126 sAddress.digit_mode=%d, sAddress.number_mode=%d, sAddress.number_type=%d, ",
2127 printBuf, p_cur->uTeleserviceID,p_cur->bIsServicePresent,p_cur->uServicecategory,
2128 p_cur->sAddress.digit_mode, p_cur->sAddress.number_mode,p_cur->sAddress.number_type);
2135 * A write on the wakeup fd is done just to pop us out of select()
2136 * We empty the buffer here and then ril_event will reset the timers on the
2139 static void processWakeupCallback(int fd, short flags, void *param) {
2143 LOGV("processWakeupCallback");
2145 /* empty our wakeup socket out */
2147 ret = read(s_fdWakeupRead, &buff, sizeof(buff));
2148 } while (ret > 0 || (ret < 0 && errno == EINTR));
2151 static void onCommandsSocketClosed() {
2155 /* mark pending requests as "cancelled" so we dont report responses */
2157 ret = pthread_mutex_lock(&s_pendingRequestsMutex);
2160 p_cur = s_pendingRequests;
2162 for (p_cur = s_pendingRequests
2164 ; p_cur = p_cur->p_next
2166 p_cur->cancelled = 1;
2169 ret = pthread_mutex_unlock(&s_pendingRequestsMutex);
2173 static void processCommandsCallback(int fd, short flags, void *param) {
2179 assert(fd == s_fdCommand);
2181 p_rs = (RecordStream *)param;
2184 /* loop until EAGAIN/EINTR, end of stream, or other error */
2185 ret = record_stream_get_next(p_rs, &p_record, &recordlen);
2187 if (ret == 0 && p_record == NULL) {
2190 } else if (ret < 0) {
2192 } else if (ret == 0) { /* && p_record != NULL */
2193 processCommandBuffer(p_record, recordlen);
2197 if (ret == 0 || !(errno == EAGAIN || errno == EINTR)) {
2198 /* fatal error or end-of-stream */
2200 LOGE("error on reading command socket errno:%d\n", errno);
2202 LOGW("EOS. Closing command socket.");
2208 ril_event_del(&s_commands_event);
2210 record_stream_free(p_rs);
2212 /* start listening for new connections again */
2213 rilEventAddWakeup(&s_listen_event);
2215 onCommandsSocketClosed();
2220 static void onNewCommandConnect() {
2221 // implicit radio state changed
2222 RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED,
2225 // Send last NITZ time data, in case it was missed
2226 if (s_lastNITZTimeData != NULL) {
2227 sendResponseRaw(s_lastNITZTimeData, s_lastNITZTimeDataSize);
2229 free(s_lastNITZTimeData);
2230 s_lastNITZTimeData = NULL;
2233 // Get version string
2234 if (s_callbacks.getVersion != NULL) {
2235 const char *version;
2236 version = s_callbacks.getVersion();
2237 LOGI("RIL Daemon version: %s\n", version);
2239 property_set(PROPERTY_RIL_IMPL, version);
2241 LOGI("RIL Daemon version: unavailable\n");
2242 property_set(PROPERTY_RIL_IMPL, "unavailable");
2247 static void listenCallback (int fd, short flags, void *param) {
2250 int is_phone_socket;
2253 struct sockaddr_un peeraddr;
2254 socklen_t socklen = sizeof (peeraddr);
2257 socklen_t szCreds = sizeof(creds);
2259 struct passwd *pwd = NULL;
2261 assert (s_fdCommand < 0);
2262 assert (fd == s_fdListen);
2264 s_fdCommand = accept(s_fdListen, (sockaddr *) &peeraddr, &socklen);
2266 if (s_fdCommand < 0 ) {
2267 LOGE("Error on accept() errno:%d", errno);
2268 /* start listening for new connections again */
2269 rilEventAddWakeup(&s_listen_event);
2273 /* check the credential of the other side and only accept socket from
2277 is_phone_socket = 0;
2279 err = getsockopt(s_fdCommand, SOL_SOCKET, SO_PEERCRED, &creds, &szCreds);
2281 if (err == 0 && szCreds > 0) {
2283 pwd = getpwuid(creds.uid);
2285 if (strcmp(pwd->pw_name, PHONE_PROCESS) == 0) {
2286 is_phone_socket = 1;
2288 LOGE("RILD can't accept socket from process %s", pwd->pw_name);
2291 LOGE("Error on getpwuid() errno: %d", errno);
2294 LOGD("Error on getsockopt() errno: %d", errno);
2297 if ( !is_phone_socket ) {
2298 LOGE("RILD must accept socket from %s", PHONE_PROCESS);
2303 onCommandsSocketClosed();
2305 /* start listening for new connections again */
2306 rilEventAddWakeup(&s_listen_event);
2311 ret = fcntl(s_fdCommand, F_SETFL, O_NONBLOCK);
2314 LOGE ("Error setting O_NONBLOCK errno:%d", errno);
2317 LOGI("libril: new connection");
2319 p_rs = record_stream_new(s_fdCommand, MAX_COMMAND_BYTES);
2321 ril_event_set (&s_commands_event, s_fdCommand, 1,
2322 processCommandsCallback, p_rs);
2324 rilEventAddWakeup (&s_commands_event);
2326 onNewCommandConnect();
2329 static void freeDebugCallbackArgs(int number, char **args) {
2330 for (int i = 0; i < number; i++) {
2331 if (args[i] != NULL) {
2338 static void debugCallback (int fd, short flags, void *param) {
2339 int acceptFD, option;
2340 struct sockaddr_un peeraddr;
2341 socklen_t socklen = sizeof (peeraddr);
2343 unsigned int qxdm_data[6];
2344 const char *deactData[1] = {"1"};
2347 int hangupData[1] = {1};
2351 acceptFD = accept (fd, (sockaddr *) &peeraddr, &socklen);
2354 LOGE ("error accepting on debug port: %d\n", errno);
2358 if (recv(acceptFD, &number, sizeof(int), 0) != sizeof(int)) {
2359 LOGE ("error reading on socket: number of Args: \n");
2362 args = (char **) malloc(sizeof(char*) * number);
2364 for (int i = 0; i < number; i++) {
2366 if (recv(acceptFD, &len, sizeof(int), 0) != sizeof(int)) {
2367 LOGE ("error reading on socket: Len of Args: \n");
2368 freeDebugCallbackArgs(i, args);
2372 args[i] = (char *) malloc((sizeof(char) * len) + 1);
2373 if (recv(acceptFD, args[i], sizeof(char) * len, 0)
2374 != (int)sizeof(char) * len) {
2375 LOGE ("error reading on socket: Args[%d] \n", i);
2376 freeDebugCallbackArgs(i, args);
2379 char * buf = args[i];
2383 switch (atoi(args[0])) {
2385 LOGI ("Connection on debug port: issuing reset.");
2386 issueLocalRequest(RIL_REQUEST_RESET_RADIO, NULL, 0);
2389 LOGI ("Connection on debug port: issuing radio power off.");
2391 issueLocalRequest(RIL_REQUEST_RADIO_POWER, &data, sizeof(int));
2397 LOGI ("Debug port: issuing unsolicited network change.");
2398 RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED,
2402 LOGI ("Debug port: QXDM log enable.");
2403 qxdm_data[0] = 65536; // head.func_tag
2404 qxdm_data[1] = 16; // head.len
2405 qxdm_data[2] = 1; // mode: 1 for 'start logging'
2406 qxdm_data[3] = 32; // log_file_size: 32megabytes
2407 qxdm_data[4] = 0; // log_mask
2408 qxdm_data[5] = 8; // log_max_fileindex
2409 issueLocalRequest(RIL_REQUEST_OEM_HOOK_RAW, qxdm_data,
2413 LOGI ("Debug port: QXDM log disable.");
2414 qxdm_data[0] = 65536;
2416 qxdm_data[2] = 0; // mode: 0 for 'stop logging'
2420 issueLocalRequest(RIL_REQUEST_OEM_HOOK_RAW, qxdm_data,
2424 LOGI("Debug port: Radio On");
2426 issueLocalRequest(RIL_REQUEST_RADIO_POWER, &data, sizeof(int));
2428 // Set network selection automatic.
2429 issueLocalRequest(RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC, NULL, 0);
2432 LOGI("Debug port: Setup Data Call, Apn :%s\n", args[1]);
2433 actData[0] = args[1];
2434 issueLocalRequest(RIL_REQUEST_SETUP_DATA_CALL, &actData,
2438 LOGI("Debug port: Deactivate Data Call");
2439 issueLocalRequest(RIL_REQUEST_DEACTIVATE_DATA_CALL, &deactData,
2443 LOGI("Debug port: Dial Call");
2445 dialData.address = args[1];
2446 issueLocalRequest(RIL_REQUEST_DIAL, &dialData, sizeof(dialData));
2449 LOGI("Debug port: Answer Call");
2450 issueLocalRequest(RIL_REQUEST_ANSWER, NULL, 0);
2453 LOGI("Debug port: End Call");
2454 issueLocalRequest(RIL_REQUEST_HANGUP, &hangupData,
2455 sizeof(hangupData));
2458 LOGE ("Invalid request");
2461 freeDebugCallbackArgs(number, args);
2466 static void userTimerCallback (int fd, short flags, void *param) {
2467 UserCallbackInfo *p_info;
2469 p_info = (UserCallbackInfo *)param;
2471 p_info->p_callback(p_info->userParam);
2474 // FIXME generalize this...there should be a cancel mechanism
2475 if (s_last_wake_timeout_info != NULL && s_last_wake_timeout_info == p_info) {
2476 s_last_wake_timeout_info = NULL;
2484 eventLoop(void *param) {
2490 pthread_mutex_lock(&s_startupMutex);
2493 pthread_cond_broadcast(&s_startupCond);
2495 pthread_mutex_unlock(&s_startupMutex);
2497 ret = pipe(filedes);
2500 LOGE("Error in pipe() errno:%d", errno);
2504 s_fdWakeupRead = filedes[0];
2505 s_fdWakeupWrite = filedes[1];
2507 fcntl(s_fdWakeupRead, F_SETFL, O_NONBLOCK);
2509 ril_event_set (&s_wakeupfd_event, s_fdWakeupRead, true,
2510 processWakeupCallback, NULL);
2512 rilEventAddWakeup (&s_wakeupfd_event);
2514 // Only returns on error
2516 LOGE ("error in event_loop_base errno:%d", errno);
2522 RIL_startEventLoop(void) {
2524 pthread_attr_t attr;
2526 /* spin up eventLoop thread and wait for it to get started */
2528 pthread_mutex_lock(&s_startupMutex);
2530 pthread_attr_init (&attr);
2531 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
2532 ret = pthread_create(&s_tid_dispatch, &attr, eventLoop, NULL);
2534 while (s_started == 0) {
2535 pthread_cond_wait(&s_startupCond, &s_startupMutex);
2538 pthread_mutex_unlock(&s_startupMutex);
2541 LOGE("Failed to create dispatch thread errno:%d", errno);
2546 // Used for testing purpose only.
2547 extern "C" void RIL_setcallbacks (const RIL_RadioFunctions *callbacks) {
2548 memcpy(&s_callbacks, callbacks, sizeof (RIL_RadioFunctions));
2552 RIL_register (const RIL_RadioFunctions *callbacks) {
2556 if (callbacks == NULL || ((callbacks->version != RIL_VERSION)
2557 && (callbacks->version < 2))) { // Remove when partners upgrade to version 3
2559 "RIL_register: RIL_RadioFunctions * null or invalid version"
2560 " (expected %d)", RIL_VERSION);
2563 if (callbacks->version < RIL_VERSION) {
2564 LOGE ("RIL_register: upgrade RIL to version %d current version=%d",
2565 RIL_VERSION, callbacks->version);
2568 if (s_registerCalled > 0) {
2569 LOGE("RIL_register has been called more than once. "
2570 "Subsequent call ignored");
2574 memcpy(&s_callbacks, callbacks, sizeof (RIL_RadioFunctions));
2576 s_registerCalled = 1;
2578 // Little self-check
2580 for (int i = 0; i < (int)NUM_ELEMS(s_commands); i++) {
2581 assert(i == s_commands[i].requestNumber);
2584 for (int i = 0; i < (int)NUM_ELEMS(s_unsolResponses); i++) {
2585 assert(i + RIL_UNSOL_RESPONSE_BASE
2586 == s_unsolResponses[i].requestNumber);
2589 // New rild impl calls RIL_startEventLoop() first
2590 // old standalone impl wants it here.
2592 if (s_started == 0) {
2593 RIL_startEventLoop();
2596 // start listen socket
2599 ret = socket_local_server (SOCKET_NAME_RIL,
2600 ANDROID_SOCKET_NAMESPACE_ABSTRACT, SOCK_STREAM);
2603 LOGE("Unable to bind socket errno:%d", errno);
2609 s_fdListen = android_get_control_socket(SOCKET_NAME_RIL);
2610 if (s_fdListen < 0) {
2611 LOGE("Failed to get socket '" SOCKET_NAME_RIL "'");
2615 ret = listen(s_fdListen, 4);
2618 LOGE("Failed to listen on control socket '%d': %s",
2619 s_fdListen, strerror(errno));
2625 /* note: non-persistent so we can accept only one connection at a time */
2626 ril_event_set (&s_listen_event, s_fdListen, false,
2627 listenCallback, NULL);
2629 rilEventAddWakeup (&s_listen_event);
2632 // start debug interface socket
2634 s_fdDebug = android_get_control_socket(SOCKET_NAME_RIL_DEBUG);
2635 if (s_fdDebug < 0) {
2636 LOGE("Failed to get socket '" SOCKET_NAME_RIL_DEBUG "' errno:%d", errno);
2640 ret = listen(s_fdDebug, 4);
2643 LOGE("Failed to listen on ril debug socket '%d': %s",
2644 s_fdDebug, strerror(errno));
2648 ril_event_set (&s_debug_event, s_fdDebug, true,
2649 debugCallback, NULL);
2651 rilEventAddWakeup (&s_debug_event);
2657 checkAndDequeueRequestInfo(struct RequestInfo *pRI) {
2664 pthread_mutex_lock(&s_pendingRequestsMutex);
2666 for(RequestInfo **ppCur = &s_pendingRequests
2668 ; ppCur = &((*ppCur)->p_next)
2670 if (pRI == *ppCur) {
2673 *ppCur = (*ppCur)->p_next;
2678 pthread_mutex_unlock(&s_pendingRequestsMutex);
2685 RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responselen) {
2690 pRI = (RequestInfo *)t;
2692 if (!checkAndDequeueRequestInfo(pRI)) {
2693 LOGE ("RIL_onRequestComplete: invalid RIL_Token");
2697 if (pRI->local > 0) {
2698 // Locally issued command...void only!
2699 // response does not go back up the command socket
2700 LOGD("C[locl]< %s", requestToString(pRI->pCI->requestNumber));
2705 appendPrintBuf("[%04d]< %s",
2706 pRI->token, requestToString(pRI->pCI->requestNumber));
2708 if (pRI->cancelled == 0) {
2711 p.writeInt32 (RESPONSE_SOLICITED);
2712 p.writeInt32 (pRI->token);
2713 errorOffset = p.dataPosition();
2717 if (response != NULL) {
2718 // there is a response payload, no matter success or not.
2719 ret = pRI->pCI->responseFunction(p, response, responselen);
2721 /* if an error occurred, rewind and mark it */
2723 p.setDataPosition(errorOffset);
2728 if (e != RIL_E_SUCCESS) {
2729 appendPrintBuf("%s fails by %s", printBuf, failCauseToString(e));
2732 if (s_fdCommand < 0) {
2733 LOGD ("RIL onRequestComplete: Command channel closed");
2744 grabPartialWakeLock() {
2745 acquire_wake_lock(PARTIAL_WAKE_LOCK, ANDROID_WAKE_LOCK_NAME);
2750 release_wake_lock(ANDROID_WAKE_LOCK_NAME);
2754 * Timer callback to put us back to sleep before the default timeout
2757 wakeTimeoutCallback (void *param) {
2758 // We're using "param != NULL" as a cancellation mechanism
2759 if (param == NULL) {
2760 //LOGD("wakeTimeout: releasing wake lock");
2764 //LOGD("wakeTimeout: releasing wake lock CANCELLED");
2769 void RIL_onUnsolicitedResponse(int unsolResponse, void *data,
2772 int unsolResponseIndex;
2774 int64_t timeReceived = 0;
2775 bool shouldScheduleTimeout = false;
2777 if (s_registerCalled == 0) {
2778 // Ignore RIL_onUnsolicitedResponse before RIL_register
2779 LOGW("RIL_onUnsolicitedResponse called before RIL_register");
2783 unsolResponseIndex = unsolResponse - RIL_UNSOL_RESPONSE_BASE;
2785 if ((unsolResponseIndex < 0)
2786 || (unsolResponseIndex >= (int32_t)NUM_ELEMS(s_unsolResponses))) {
2787 LOGE("unsupported unsolicited response code %d", unsolResponse);
2791 // Grab a wake lock if needed for this reponse,
2792 // as we exit we'll either release it immediately
2793 // or set a timer to release it later.
2794 switch (s_unsolResponses[unsolResponseIndex].wakeType) {
2796 grabPartialWakeLock();
2797 shouldScheduleTimeout = true;
2802 // No wake lock is grabed so don't set timeout
2803 shouldScheduleTimeout = false;
2807 // Mark the time this was received, doing this
2808 // after grabing the wakelock incase getting
2809 // the elapsedRealTime might cause us to goto
2811 if (unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) {
2812 timeReceived = elapsedRealtime();
2815 appendPrintBuf("[UNSL]< %s", requestToString(unsolResponse));
2819 p.writeInt32 (RESPONSE_UNSOLICITED);
2820 p.writeInt32 (unsolResponse);
2822 ret = s_unsolResponses[unsolResponseIndex]
2823 .responseFunction(p, data, datalen);
2825 // Problem with the response. Don't continue;
2829 // some things get more payload
2830 switch(unsolResponse) {
2831 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED:
2832 p.writeInt32(s_callbacks.onStateRequest());
2833 appendPrintBuf("%s {%s}", printBuf,
2834 radioStateToString(s_callbacks.onStateRequest()));
2838 case RIL_UNSOL_NITZ_TIME_RECEIVED:
2839 // Store the time that this was received so the
2840 // handler of this message can account for
2841 // the time it takes to arrive and process. In
2842 // particular the system has been known to sleep
2843 // before this message can be processed.
2844 p.writeInt64(timeReceived);
2848 ret = sendResponse(p);
2849 if (ret != 0 && unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) {
2851 // Unfortunately, NITZ time is not poll/update like everything
2852 // else in the system. So, if the upstream client isn't connected,
2853 // keep a copy of the last NITZ response (with receive time noted
2854 // above) around so we can deliver it when it is connected
2856 if (s_lastNITZTimeData != NULL) {
2857 free (s_lastNITZTimeData);
2858 s_lastNITZTimeData = NULL;
2861 s_lastNITZTimeData = malloc(p.dataSize());
2862 s_lastNITZTimeDataSize = p.dataSize();
2863 memcpy(s_lastNITZTimeData, p.data(), p.dataSize());
2866 // For now, we automatically go back to sleep after TIMEVAL_WAKE_TIMEOUT
2867 // FIXME The java code should handshake here to release wake lock
2869 if (shouldScheduleTimeout) {
2870 // Cancel the previous request
2871 if (s_last_wake_timeout_info != NULL) {
2872 s_last_wake_timeout_info->userParam = (void *)1;
2875 s_last_wake_timeout_info
2876 = internalRequestTimedCallback(wakeTimeoutCallback, NULL,
2877 &TIMEVAL_WAKE_TIMEOUT);
2884 if (shouldScheduleTimeout) {
2889 /** FIXME generalize this if you track UserCAllbackInfo, clear it
2890 when the callback occurs
2892 static UserCallbackInfo *
2893 internalRequestTimedCallback (RIL_TimedCallback callback, void *param,
2894 const struct timeval *relativeTime)
2896 struct timeval myRelativeTime;
2897 UserCallbackInfo *p_info;
2899 p_info = (UserCallbackInfo *) malloc (sizeof(UserCallbackInfo));
2901 p_info->p_callback = callback;
2902 p_info->userParam = param;
2904 if (relativeTime == NULL) {
2905 /* treat null parameter as a 0 relative time */
2906 memset (&myRelativeTime, 0, sizeof(myRelativeTime));
2908 /* FIXME I think event_add's tv param is really const anyway */
2909 memcpy (&myRelativeTime, relativeTime, sizeof(myRelativeTime));
2912 ril_event_set(&(p_info->event), -1, false, userTimerCallback, p_info);
2914 ril_timer_add(&(p_info->event), &myRelativeTime);
2922 RIL_requestTimedCallback (RIL_TimedCallback callback, void *param,
2923 const struct timeval *relativeTime) {
2924 internalRequestTimedCallback (callback, param, relativeTime);
2928 failCauseToString(RIL_Errno e) {
2930 case RIL_E_SUCCESS: return "E_SUCCESS";
2931 case RIL_E_RADIO_NOT_AVAILABLE: return "E_RAIDO_NOT_AVAILABLE";
2932 case RIL_E_GENERIC_FAILURE: return "E_GENERIC_FAILURE";
2933 case RIL_E_PASSWORD_INCORRECT: return "E_PASSWORD_INCORRECT";
2934 case RIL_E_SIM_PIN2: return "E_SIM_PIN2";
2935 case RIL_E_SIM_PUK2: return "E_SIM_PUK2";
2936 case RIL_E_REQUEST_NOT_SUPPORTED: return "E_REQUEST_NOT_SUPPORTED";
2937 case RIL_E_CANCELLED: return "E_CANCELLED";
2938 case RIL_E_OP_NOT_ALLOWED_DURING_VOICE_CALL: return "E_OP_NOT_ALLOWED_DURING_VOICE_CALL";
2939 case RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW: return "E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW";
2940 case RIL_E_SMS_SEND_FAIL_RETRY: return "E_SMS_SEND_FAIL_RETRY";
2941 case RIL_E_SIM_ABSENT:return "E_SIM_ABSENT";
2942 case RIL_E_ILLEGAL_SIM_OR_ME:return "E_ILLEGAL_SIM_OR_ME";
2943 #ifdef FEATURE_MULTIMODE_ANDROID
2944 case RIL_E_SUBSCRIPTION_NOT_AVAILABLE:return "E_SUBSCRIPTION_NOT_AVAILABLE";
2945 case RIL_E_MODE_NOT_SUPPORTED:return "E_MODE_NOT_SUPPORTED";
2947 default: return "<unknown error>";
2952 radioStateToString(RIL_RadioState s) {
2954 case RADIO_STATE_OFF: return "RADIO_OFF";
2955 case RADIO_STATE_UNAVAILABLE: return "RADIO_UNAVAILABLE";
2956 case RADIO_STATE_SIM_NOT_READY: return "RADIO_SIM_NOT_READY";
2957 case RADIO_STATE_SIM_LOCKED_OR_ABSENT: return "RADIO_SIM_LOCKED_OR_ABSENT";
2958 case RADIO_STATE_SIM_READY: return "RADIO_SIM_READY";
2959 case RADIO_STATE_RUIM_NOT_READY:return"RADIO_RUIM_NOT_READY";
2960 case RADIO_STATE_RUIM_READY:return"RADIO_RUIM_READY";
2961 case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:return"RADIO_RUIM_LOCKED_OR_ABSENT";
2962 case RADIO_STATE_NV_NOT_READY:return"RADIO_NV_NOT_READY";
2963 case RADIO_STATE_NV_READY:return"RADIO_NV_READY";
2964 default: return "<unknown state>";
2969 callStateToString(RIL_CallState s) {
2971 case RIL_CALL_ACTIVE : return "ACTIVE";
2972 case RIL_CALL_HOLDING: return "HOLDING";
2973 case RIL_CALL_DIALING: return "DIALING";
2974 case RIL_CALL_ALERTING: return "ALERTING";
2975 case RIL_CALL_INCOMING: return "INCOMING";
2976 case RIL_CALL_WAITING: return "WAITING";
2977 default: return "<unknown state>";
2982 requestToString(int request) {
2984 cat libs/telephony/ril_commands.h \
2985 | egrep "^ *{RIL_" \
2986 | sed -re 's/\{RIL_([^,]+),[^,]+,([^}]+).+/case RIL_\1: return "\1";/'
2989 cat libs/telephony/ril_unsol_commands.h \
2990 | egrep "^ *{RIL_" \
2991 | sed -re 's/\{RIL_([^,]+),([^}]+).+/case RIL_\1: return "\1";/'
2995 case RIL_REQUEST_GET_SIM_STATUS: return "GET_SIM_STATUS";
2996 case RIL_REQUEST_ENTER_SIM_PIN: return "ENTER_SIM_PIN";
2997 case RIL_REQUEST_ENTER_SIM_PUK: return "ENTER_SIM_PUK";
2998 case RIL_REQUEST_ENTER_SIM_PIN2: return "ENTER_SIM_PIN2";
2999 case RIL_REQUEST_ENTER_SIM_PUK2: return "ENTER_SIM_PUK2";
3000 case RIL_REQUEST_CHANGE_SIM_PIN: return "CHANGE_SIM_PIN";
3001 case RIL_REQUEST_CHANGE_SIM_PIN2: return "CHANGE_SIM_PIN2";
3002 case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: return "ENTER_NETWORK_DEPERSONALIZATION";
3003 case RIL_REQUEST_GET_CURRENT_CALLS: return "GET_CURRENT_CALLS";
3004 case RIL_REQUEST_DIAL: return "DIAL";
3005 case RIL_REQUEST_GET_IMSI: return "GET_IMSI";
3006 case RIL_REQUEST_HANGUP: return "HANGUP";
3007 case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: return "HANGUP_WAITING_OR_BACKGROUND";
3008 case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: return "HANGUP_FOREGROUND_RESUME_BACKGROUND";
3009 case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: return "SWITCH_WAITING_OR_HOLDING_AND_ACTIVE";
3010 case RIL_REQUEST_CONFERENCE: return "CONFERENCE";
3011 case RIL_REQUEST_UDUB: return "UDUB";
3012 case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: return "LAST_CALL_FAIL_CAUSE";
3013 case RIL_REQUEST_SIGNAL_STRENGTH: return "SIGNAL_STRENGTH";
3014 case RIL_REQUEST_REGISTRATION_STATE: return "REGISTRATION_STATE";
3015 case RIL_REQUEST_GPRS_REGISTRATION_STATE: return "GPRS_REGISTRATION_STATE";
3016 case RIL_REQUEST_OPERATOR: return "OPERATOR";
3017 case RIL_REQUEST_RADIO_POWER: return "RADIO_POWER";
3018 case RIL_REQUEST_DTMF: return "DTMF";
3019 case RIL_REQUEST_SEND_SMS: return "SEND_SMS";
3020 case RIL_REQUEST_SEND_SMS_EXPECT_MORE: return "SEND_SMS_EXPECT_MORE";
3021 case RIL_REQUEST_SETUP_DATA_CALL: return "SETUP_DATA_CALL";
3022 case RIL_REQUEST_SIM_IO: return "SIM_IO";
3023 case RIL_REQUEST_SEND_USSD: return "SEND_USSD";
3024 case RIL_REQUEST_CANCEL_USSD: return "CANCEL_USSD";
3025 case RIL_REQUEST_GET_CLIR: return "GET_CLIR";
3026 case RIL_REQUEST_SET_CLIR: return "SET_CLIR";
3027 case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: return "QUERY_CALL_FORWARD_STATUS";
3028 case RIL_REQUEST_SET_CALL_FORWARD: return "SET_CALL_FORWARD";
3029 case RIL_REQUEST_QUERY_CALL_WAITING: return "QUERY_CALL_WAITING";
3030 case RIL_REQUEST_SET_CALL_WAITING: return "SET_CALL_WAITING";
3031 case RIL_REQUEST_SMS_ACKNOWLEDGE: return "SMS_ACKNOWLEDGE";
3032 case RIL_REQUEST_GET_IMEI: return "GET_IMEI";
3033 case RIL_REQUEST_GET_IMEISV: return "GET_IMEISV";
3034 case RIL_REQUEST_ANSWER: return "ANSWER";
3035 case RIL_REQUEST_DEACTIVATE_DATA_CALL: return "DEACTIVATE_DATA_CALL";
3036 case RIL_REQUEST_QUERY_FACILITY_LOCK: return "QUERY_FACILITY_LOCK";
3037 case RIL_REQUEST_SET_FACILITY_LOCK: return "SET_FACILITY_LOCK";
3038 case RIL_REQUEST_CHANGE_BARRING_PASSWORD: return "CHANGE_BARRING_PASSWORD";
3039 case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: return "QUERY_NETWORK_SELECTION_MODE";
3040 case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: return "SET_NETWORK_SELECTION_AUTOMATIC";
3041 case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: return "SET_NETWORK_SELECTION_MANUAL";
3042 case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : return "QUERY_AVAILABLE_NETWORKS ";
3043 case RIL_REQUEST_DTMF_START: return "DTMF_START";
3044 case RIL_REQUEST_DTMF_STOP: return "DTMF_STOP";
3045 case RIL_REQUEST_BASEBAND_VERSION: return "BASEBAND_VERSION";
3046 case RIL_REQUEST_SEPARATE_CONNECTION: return "SEPARATE_CONNECTION";
3047 case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: return "SET_PREFERRED_NETWORK_TYPE";
3048 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: return "GET_PREFERRED_NETWORK_TYPE";
3049 case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: return "GET_NEIGHBORING_CELL_IDS";
3050 case RIL_REQUEST_SET_MUTE: return "SET_MUTE";
3051 case RIL_REQUEST_GET_MUTE: return "GET_MUTE";
3052 case RIL_REQUEST_QUERY_CLIP: return "QUERY_CLIP";
3053 case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: return "LAST_DATA_CALL_FAIL_CAUSE";
3054 case RIL_REQUEST_DATA_CALL_LIST: return "DATA_CALL_LIST";
3055 case RIL_REQUEST_RESET_RADIO: return "RESET_RADIO";
3056 case RIL_REQUEST_OEM_HOOK_RAW: return "OEM_HOOK_RAW";
3057 case RIL_REQUEST_OEM_HOOK_STRINGS: return "OEM_HOOK_STRINGS";
3058 case RIL_REQUEST_SET_BAND_MODE: return "SET_BAND_MODE";
3059 case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: return "QUERY_AVAILABLE_BAND_MODE";
3060 case RIL_REQUEST_STK_GET_PROFILE: return "STK_GET_PROFILE";
3061 case RIL_REQUEST_STK_SET_PROFILE: return "STK_SET_PROFILE";
3062 case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: return "STK_SEND_ENVELOPE_COMMAND";
3063 case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: return "STK_SEND_TERMINAL_RESPONSE";
3064 case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: return "STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM";
3065 case RIL_REQUEST_SCREEN_STATE: return "SCREEN_STATE";
3066 case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: return "EXPLICIT_CALL_TRANSFER";
3067 case RIL_REQUEST_SET_LOCATION_UPDATES: return "SET_LOCATION_UPDATES";
3068 case RIL_REQUEST_CDMA_SET_SUBSCRIPTION:return"CDMA_SET_SUBSCRIPTION";
3069 case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE:return"CDMA_SET_ROAMING_PREFERENCE";
3070 case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE:return"CDMA_QUERY_ROAMING_PREFERENCE";
3071 case RIL_REQUEST_SET_TTY_MODE:return"SET_TTY_MODE";
3072 case RIL_REQUEST_QUERY_TTY_MODE:return"QUERY_TTY_MODE";
3073 case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE";
3074 case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE";
3075 case RIL_REQUEST_CDMA_FLASH:return"CDMA_FLASH";
3076 case RIL_REQUEST_CDMA_BURST_DTMF:return"CDMA_BURST_DTMF";
3077 case RIL_REQUEST_CDMA_SEND_SMS:return"CDMA_SEND_SMS";
3078 case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE:return"CDMA_SMS_ACKNOWLEDGE";
3079 case RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG:return"GSM_GET_BROADCAST_SMS_CONFIG";
3080 case RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG:return"GSM_SET_BROADCAST_SMS_CONFIG";
3081 case RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG:return "CDMA_GET_BROADCAST_SMS_CONFIG";
3082 case RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG:return "CDMA_SET_BROADCAST_SMS_CONFIG";
3083 case RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION:return "CDMA_SMS_BROADCAST_ACTIVATION";
3084 case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: return"CDMA_VALIDATE_AND_WRITE_AKEY";
3085 case RIL_REQUEST_CDMA_SUBSCRIPTION: return"CDMA_SUBSCRIPTION";
3086 case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: return "CDMA_WRITE_SMS_TO_RUIM";
3087 case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: return "CDMA_DELETE_SMS_ON_RUIM";
3088 case RIL_REQUEST_DEVICE_IDENTITY: return "DEVICE_IDENTITY";
3089 case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: return "EXIT_EMERGENCY_CALLBACK_MODE";
3090 case RIL_REQUEST_GET_SMSC_ADDRESS: return "GET_SMSC_ADDRESS";
3091 case RIL_REQUEST_SET_SMSC_ADDRESS: return "SET_SMSC_ADDRESS";
3092 case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: return "REPORT_SMS_MEMORY_STATUS";
3093 case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: return "REPORT_STK_SERVICE_IS_RUNNING";
3094 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return "UNSOL_RESPONSE_RADIO_STATE_CHANGED";
3095 case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return "UNSOL_RESPONSE_CALL_STATE_CHANGED";
3096 case RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED: return "UNSOL_RESPONSE_NETWORK_STATE_CHANGED";
3097 case RIL_UNSOL_RESPONSE_NEW_SMS: return "UNSOL_RESPONSE_NEW_SMS";
3098 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: return "UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT";
3099 case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: return "UNSOL_RESPONSE_NEW_SMS_ON_SIM";
3100 case RIL_UNSOL_ON_USSD: return "UNSOL_ON_USSD";
3101 case RIL_UNSOL_ON_USSD_REQUEST: return "UNSOL_ON_USSD_REQUEST(obsolete)";
3102 case RIL_UNSOL_NITZ_TIME_RECEIVED: return "UNSOL_NITZ_TIME_RECEIVED";
3103 case RIL_UNSOL_SIGNAL_STRENGTH: return "UNSOL_SIGNAL_STRENGTH";
3104 case RIL_UNSOL_STK_SESSION_END: return "UNSOL_STK_SESSION_END";
3105 case RIL_UNSOL_STK_PROACTIVE_COMMAND: return "UNSOL_STK_PROACTIVE_COMMAND";
3106 case RIL_UNSOL_STK_EVENT_NOTIFY: return "UNSOL_STK_EVENT_NOTIFY";
3107 case RIL_UNSOL_STK_CALL_SETUP: return "UNSOL_STK_CALL_SETUP";
3108 case RIL_UNSOL_SIM_SMS_STORAGE_FULL: return "UNSOL_SIM_SMS_STORAGE_FUL";
3109 case RIL_UNSOL_SIM_REFRESH: return "UNSOL_SIM_REFRESH";
3110 case RIL_UNSOL_DATA_CALL_LIST_CHANGED: return "UNSOL_DATA_CALL_LIST_CHANGED";
3111 case RIL_UNSOL_CALL_RING: return "UNSOL_CALL_RING";
3112 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: return "UNSOL_RESPONSE_SIM_STATUS_CHANGED";
3113 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: return "UNSOL_NEW_CDMA_SMS";
3114 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: return "UNSOL_NEW_BROADCAST_SMS";
3115 case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: return "UNSOL_CDMA_RUIM_SMS_STORAGE_FULL";
3116 case RIL_UNSOL_RESTRICTED_STATE_CHANGED: return "UNSOL_RESTRICTED_STATE_CHANGED";
3117 case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: return "UNSOL_ENTER_EMERGENCY_CALLBACK_MODE";
3118 case RIL_UNSOL_CDMA_CALL_WAITING: return "UNSOL_CDMA_CALL_WAITING";
3119 case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: return "UNSOL_CDMA_OTA_PROVISION_STATUS";
3120 case RIL_UNSOL_CDMA_INFO_REC: return "UNSOL_CDMA_INFO_REC";
3121 case RIL_UNSOL_OEM_HOOK_RAW: return "UNSOL_OEM_HOOK_RAW";
3122 case RIL_UNSOL_RINGBACK_TONE: return "UNSOL_RINGBACK_TONE";
3123 case RIL_UNSOL_RESEND_INCALL_MUTE: return "UNSOL_RESEND_INCALL_MUTE";
3124 default: return "<unknown request>";
3128 } /* namespace android */