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 p.setDataPosition(pos);
1207 dispatchStrings(p, pRI);
1212 blockingWrite(int fd, const void *buffer, size_t len) {
1213 size_t writeOffset = 0;
1214 const uint8_t *toWrite;
1216 toWrite = (const uint8_t *)buffer;
1218 while (writeOffset < len) {
1221 written = write (fd, toWrite + writeOffset,
1223 } while (written < 0 && errno == EINTR);
1226 writeOffset += written;
1227 } else { // written < 0
1228 LOGE ("RIL Response: unexpected error on write errno:%d", errno);
1238 sendResponseRaw (const void *data, size_t dataSize) {
1239 int fd = s_fdCommand;
1243 if (s_fdCommand < 0) {
1247 if (dataSize > MAX_COMMAND_BYTES) {
1248 LOGE("RIL: packet larger than %u (%u)",
1249 MAX_COMMAND_BYTES, (unsigned int )dataSize);
1254 pthread_mutex_lock(&s_writeMutex);
1256 header = htonl(dataSize);
1258 ret = blockingWrite(fd, (void *)&header, sizeof(header));
1261 pthread_mutex_unlock(&s_writeMutex);
1265 ret = blockingWrite(fd, data, dataSize);
1268 pthread_mutex_unlock(&s_writeMutex);
1272 pthread_mutex_unlock(&s_writeMutex);
1278 sendResponse (Parcel &p) {
1280 return sendResponseRaw(p.data(), p.dataSize());
1283 /** response is an int* pointing to an array of ints*/
1286 responseInts(Parcel &p, void *response, size_t responselen) {
1289 if (response == NULL && responselen != 0) {
1290 LOGE("invalid response: NULL");
1291 return RIL_ERRNO_INVALID_RESPONSE;
1293 if (responselen % sizeof(int) != 0) {
1294 LOGE("invalid response length %d expected multiple of %d\n",
1295 (int)responselen, (int)sizeof(int));
1296 return RIL_ERRNO_INVALID_RESPONSE;
1299 int *p_int = (int *) response;
1301 numInts = responselen / sizeof(int *);
1302 p.writeInt32 (numInts);
1306 for (int i = 0 ; i < numInts ; i++) {
1307 appendPrintBuf("%s%d,", printBuf, p_int[i]);
1308 p.writeInt32(p_int[i]);
1316 /** response is a char **, pointing to an array of char *'s */
1317 static int responseStrings(Parcel &p, void *response, size_t responselen) {
1320 if (response == NULL && responselen != 0) {
1321 LOGE("invalid response: NULL");
1322 return RIL_ERRNO_INVALID_RESPONSE;
1324 if (responselen % sizeof(char *) != 0) {
1325 LOGE("invalid response length %d expected multiple of %d\n",
1326 (int)responselen, (int)sizeof(char *));
1327 return RIL_ERRNO_INVALID_RESPONSE;
1330 if (response == NULL) {
1333 char **p_cur = (char **) response;
1335 numStrings = responselen / sizeof(char *);
1336 p.writeInt32 (numStrings);
1340 for (int i = 0 ; i < numStrings ; i++) {
1341 appendPrintBuf("%s%s,", printBuf, (char*)p_cur[i]);
1342 writeStringToParcel (p, p_cur[i]);
1352 * NULL strings are accepted
1353 * FIXME currently ignores responselen
1355 static int responseString(Parcel &p, void *response, size_t responselen) {
1356 /* one string only */
1358 appendPrintBuf("%s%s", printBuf, (char*)response);
1361 writeStringToParcel(p, (const char *)response);
1366 static int responseVoid(Parcel &p, void *response, size_t responselen) {
1372 static int responseCallList(Parcel &p, void *response, size_t responselen) {
1375 if (response == NULL && responselen != 0) {
1376 LOGE("invalid response: NULL");
1377 return RIL_ERRNO_INVALID_RESPONSE;
1380 if (responselen % sizeof (RIL_Call *) != 0) {
1381 LOGE("invalid response length %d expected multiple of %d\n",
1382 (int)responselen, (int)sizeof (RIL_Call *));
1383 return RIL_ERRNO_INVALID_RESPONSE;
1387 /* number of call info's */
1388 num = responselen / sizeof(RIL_Call *);
1391 for (int i = 0 ; i < num ; i++) {
1392 RIL_Call *p_cur = ((RIL_Call **) response)[i];
1393 /* each call info */
1394 p.writeInt32(p_cur->state);
1395 p.writeInt32(p_cur->index);
1396 p.writeInt32(p_cur->toa);
1397 p.writeInt32(p_cur->isMpty);
1398 p.writeInt32(p_cur->isMT);
1399 p.writeInt32(p_cur->als);
1400 p.writeInt32(p_cur->isVoice);
1401 p.writeInt32(p_cur->isVoicePrivacy);
1402 writeStringToParcel(p, p_cur->number);
1403 p.writeInt32(p_cur->numberPresentation);
1404 writeStringToParcel(p, p_cur->name);
1405 p.writeInt32(p_cur->namePresentation);
1406 // Remove when partners upgrade to version 3
1407 if ((s_callbacks.version < 3) || (p_cur->uusInfo == NULL || p_cur->uusInfo->uusData == NULL)) {
1408 p.writeInt32(0); /* UUS Information is absent */
1410 RIL_UUS_Info *uusInfo = p_cur->uusInfo;
1411 p.writeInt32(1); /* UUS Information is present */
1412 p.writeInt32(uusInfo->uusType);
1413 p.writeInt32(uusInfo->uusDcs);
1414 p.writeInt32(uusInfo->uusLength);
1415 p.write(uusInfo->uusData, uusInfo->uusLength);
1417 appendPrintBuf("%s[id=%d,%s,toa=%d,",
1420 callStateToString(p_cur->state),
1422 appendPrintBuf("%s%s,%s,als=%d,%s,%s,",
1424 (p_cur->isMpty)?"conf":"norm",
1425 (p_cur->isMT)?"mt":"mo",
1427 (p_cur->isVoice)?"voc":"nonvoc",
1428 (p_cur->isVoicePrivacy)?"evp":"noevp");
1429 appendPrintBuf("%s%s,cli=%d,name='%s',%d]",
1432 p_cur->numberPresentation,
1434 p_cur->namePresentation);
1442 static int responseSMS(Parcel &p, void *response, size_t responselen) {
1443 if (response == NULL) {
1444 LOGE("invalid response: NULL");
1445 return RIL_ERRNO_INVALID_RESPONSE;
1448 if (responselen != sizeof (RIL_SMS_Response) ) {
1449 LOGE("invalid response length %d expected %d",
1450 (int)responselen, (int)sizeof (RIL_SMS_Response));
1451 return RIL_ERRNO_INVALID_RESPONSE;
1454 RIL_SMS_Response *p_cur = (RIL_SMS_Response *) response;
1456 p.writeInt32(p_cur->messageRef);
1457 writeStringToParcel(p, p_cur->ackPDU);
1458 p.writeInt32(p_cur->errorCode);
1461 appendPrintBuf("%s%d,%s,%d", printBuf, p_cur->messageRef,
1462 (char*)p_cur->ackPDU, p_cur->errorCode);
1468 static int responseDataCallList(Parcel &p, void *response, size_t responselen)
1470 if (response == NULL && responselen != 0) {
1471 LOGE("invalid response: NULL");
1472 return RIL_ERRNO_INVALID_RESPONSE;
1475 if (responselen % sizeof(RIL_Data_Call_Response) != 0) {
1476 LOGE("invalid response length %d expected multiple of %d",
1477 (int)responselen, (int)sizeof(RIL_Data_Call_Response));
1478 return RIL_ERRNO_INVALID_RESPONSE;
1481 int num = responselen / sizeof(RIL_Data_Call_Response);
1484 RIL_Data_Call_Response *p_cur = (RIL_Data_Call_Response *) response;
1487 for (i = 0; i < num; i++) {
1488 p.writeInt32(p_cur[i].cid);
1489 p.writeInt32(p_cur[i].active);
1490 writeStringToParcel(p, p_cur[i].type);
1491 writeStringToParcel(p, p_cur[i].apn);
1492 writeStringToParcel(p, p_cur[i].address);
1493 appendPrintBuf("%s[cid=%d,%s,%s,%s,%s],", printBuf,
1495 (p_cur[i].active==0)?"down":"up",
1496 (char*)p_cur[i].type,
1497 (char*)p_cur[i].apn,
1498 (char*)p_cur[i].address);
1506 static int responseRaw(Parcel &p, void *response, size_t responselen) {
1507 if (response == NULL && responselen != 0) {
1508 LOGE("invalid response: NULL with responselen != 0");
1509 return RIL_ERRNO_INVALID_RESPONSE;
1512 // The java code reads -1 size as null byte array
1513 if (response == NULL) {
1516 p.writeInt32(responselen);
1517 p.write(response, responselen);
1524 static int responseSIM_IO(Parcel &p, void *response, size_t responselen) {
1525 if (response == NULL) {
1526 LOGE("invalid response: NULL");
1527 return RIL_ERRNO_INVALID_RESPONSE;
1530 if (responselen != sizeof (RIL_SIM_IO_Response) ) {
1531 LOGE("invalid response length was %d expected %d",
1532 (int)responselen, (int)sizeof (RIL_SIM_IO_Response));
1533 return RIL_ERRNO_INVALID_RESPONSE;
1536 RIL_SIM_IO_Response *p_cur = (RIL_SIM_IO_Response *) response;
1537 p.writeInt32(p_cur->sw1);
1538 p.writeInt32(p_cur->sw2);
1539 writeStringToParcel(p, p_cur->simResponse);
1542 appendPrintBuf("%ssw1=0x%X,sw2=0x%X,%s", printBuf, p_cur->sw1, p_cur->sw2,
1543 (char*)p_cur->simResponse);
1550 static int responseCallForwards(Parcel &p, void *response, size_t responselen) {
1553 if (response == NULL && responselen != 0) {
1554 LOGE("invalid response: NULL");
1555 return RIL_ERRNO_INVALID_RESPONSE;
1558 if (responselen % sizeof(RIL_CallForwardInfo *) != 0) {
1559 LOGE("invalid response length %d expected multiple of %d",
1560 (int)responselen, (int)sizeof(RIL_CallForwardInfo *));
1561 return RIL_ERRNO_INVALID_RESPONSE;
1564 /* number of call info's */
1565 num = responselen / sizeof(RIL_CallForwardInfo *);
1569 for (int i = 0 ; i < num ; i++) {
1570 RIL_CallForwardInfo *p_cur = ((RIL_CallForwardInfo **) response)[i];
1572 p.writeInt32(p_cur->status);
1573 p.writeInt32(p_cur->reason);
1574 p.writeInt32(p_cur->serviceClass);
1575 p.writeInt32(p_cur->toa);
1576 writeStringToParcel(p, p_cur->number);
1577 p.writeInt32(p_cur->timeSeconds);
1578 appendPrintBuf("%s[%s,reason=%d,cls=%d,toa=%d,%s,tout=%d],", printBuf,
1579 (p_cur->status==1)?"enable":"disable",
1580 p_cur->reason, p_cur->serviceClass, p_cur->toa,
1581 (char*)p_cur->number,
1582 p_cur->timeSeconds);
1590 static int responseSsn(Parcel &p, void *response, size_t responselen) {
1591 if (response == NULL) {
1592 LOGE("invalid response: NULL");
1593 return RIL_ERRNO_INVALID_RESPONSE;
1596 if (responselen != sizeof(RIL_SuppSvcNotification)) {
1597 LOGE("invalid response length was %d expected %d",
1598 (int)responselen, (int)sizeof (RIL_SuppSvcNotification));
1599 return RIL_ERRNO_INVALID_RESPONSE;
1602 RIL_SuppSvcNotification *p_cur = (RIL_SuppSvcNotification *) response;
1603 p.writeInt32(p_cur->notificationType);
1604 p.writeInt32(p_cur->code);
1605 p.writeInt32(p_cur->index);
1606 p.writeInt32(p_cur->type);
1607 writeStringToParcel(p, p_cur->number);
1610 appendPrintBuf("%s%s,code=%d,id=%d,type=%d,%s", printBuf,
1611 (p_cur->notificationType==0)?"mo":"mt",
1612 p_cur->code, p_cur->index, p_cur->type,
1613 (char*)p_cur->number);
1619 static int responseCellList(Parcel &p, void *response, size_t responselen) {
1622 if (response == NULL && responselen != 0) {
1623 LOGE("invalid response: NULL");
1624 return RIL_ERRNO_INVALID_RESPONSE;
1627 if (responselen % sizeof (RIL_NeighboringCell *) != 0) {
1628 LOGE("invalid response length %d expected multiple of %d\n",
1629 (int)responselen, (int)sizeof (RIL_NeighboringCell *));
1630 return RIL_ERRNO_INVALID_RESPONSE;
1634 /* number of records */
1635 num = responselen / sizeof(RIL_NeighboringCell *);
1638 for (int i = 0 ; i < num ; i++) {
1639 RIL_NeighboringCell *p_cur = ((RIL_NeighboringCell **) response)[i];
1641 p.writeInt32(p_cur->rssi);
1642 writeStringToParcel (p, p_cur->cid);
1644 appendPrintBuf("%s[cid=%s,rssi=%d],", printBuf,
1645 p_cur->cid, p_cur->rssi);
1654 * Marshall the signalInfoRecord into the parcel if it exists.
1656 static void marshallSignalInfoRecord(Parcel &p,
1657 RIL_CDMA_SignalInfoRecord &p_signalInfoRecord) {
1658 p.writeInt32(p_signalInfoRecord.isPresent);
1659 p.writeInt32(p_signalInfoRecord.signalType);
1660 p.writeInt32(p_signalInfoRecord.alertPitch);
1661 p.writeInt32(p_signalInfoRecord.signal);
1664 static int responseCdmaInformationRecords(Parcel &p,
1665 void *response, size_t responselen) {
1667 char* string8 = NULL;
1669 RIL_CDMA_InformationRecord *infoRec;
1671 if (response == NULL && responselen != 0) {
1672 LOGE("invalid response: NULL");
1673 return RIL_ERRNO_INVALID_RESPONSE;
1676 if (responselen != sizeof (RIL_CDMA_InformationRecords)) {
1677 LOGE("invalid response length %d expected multiple of %d\n",
1678 (int)responselen, (int)sizeof (RIL_CDMA_InformationRecords *));
1679 return RIL_ERRNO_INVALID_RESPONSE;
1682 RIL_CDMA_InformationRecords *p_cur =
1683 (RIL_CDMA_InformationRecords *) response;
1684 num = MIN(p_cur->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
1689 for (int i = 0 ; i < num ; i++) {
1690 infoRec = &p_cur->infoRec[i];
1691 p.writeInt32(infoRec->name);
1692 switch (infoRec->name) {
1693 case RIL_CDMA_DISPLAY_INFO_REC:
1694 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC:
1695 if (infoRec->rec.display.alpha_len >
1696 CDMA_ALPHA_INFO_BUFFER_LENGTH) {
1697 LOGE("invalid display info response length %d \
1698 expected not more than %d\n",
1699 (int)infoRec->rec.display.alpha_len,
1700 CDMA_ALPHA_INFO_BUFFER_LENGTH);
1701 return RIL_ERRNO_INVALID_RESPONSE;
1703 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1)
1705 for (int i = 0 ; i < infoRec->rec.display.alpha_len ; i++) {
1706 string8[i] = infoRec->rec.display.alpha_buf[i];
1708 string8[infoRec->rec.display.alpha_len] = '\0';
1709 writeStringToParcel(p, (const char*)string8);
1713 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
1714 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
1715 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC:
1716 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
1717 LOGE("invalid display info response length %d \
1718 expected not more than %d\n",
1719 (int)infoRec->rec.number.len,
1720 CDMA_NUMBER_INFO_BUFFER_LENGTH);
1721 return RIL_ERRNO_INVALID_RESPONSE;
1723 string8 = (char*) malloc((infoRec->rec.number.len + 1)
1725 for (int i = 0 ; i < infoRec->rec.number.len; i++) {
1726 string8[i] = infoRec->rec.number.buf[i];
1728 string8[infoRec->rec.number.len] = '\0';
1729 writeStringToParcel(p, (const char*)string8);
1732 p.writeInt32(infoRec->rec.number.number_type);
1733 p.writeInt32(infoRec->rec.number.number_plan);
1734 p.writeInt32(infoRec->rec.number.pi);
1735 p.writeInt32(infoRec->rec.number.si);
1737 case RIL_CDMA_SIGNAL_INFO_REC:
1738 p.writeInt32(infoRec->rec.signal.isPresent);
1739 p.writeInt32(infoRec->rec.signal.signalType);
1740 p.writeInt32(infoRec->rec.signal.alertPitch);
1741 p.writeInt32(infoRec->rec.signal.signal);
1743 appendPrintBuf("%sisPresent=%X, signalType=%X, \
1744 alertPitch=%X, signal=%X, ",
1745 printBuf, (int)infoRec->rec.signal.isPresent,
1746 (int)infoRec->rec.signal.signalType,
1747 (int)infoRec->rec.signal.alertPitch,
1748 (int)infoRec->rec.signal.signal);
1751 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC:
1752 if (infoRec->rec.redir.redirectingNumber.len >
1753 CDMA_NUMBER_INFO_BUFFER_LENGTH) {
1754 LOGE("invalid display info response length %d \
1755 expected not more than %d\n",
1756 (int)infoRec->rec.redir.redirectingNumber.len,
1757 CDMA_NUMBER_INFO_BUFFER_LENGTH);
1758 return RIL_ERRNO_INVALID_RESPONSE;
1760 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber
1761 .len + 1) * sizeof(char) );
1763 i < infoRec->rec.redir.redirectingNumber.len;
1765 string8[i] = infoRec->rec.redir.redirectingNumber.buf[i];
1767 string8[infoRec->rec.redir.redirectingNumber.len] = '\0';
1768 writeStringToParcel(p, (const char*)string8);
1771 p.writeInt32(infoRec->rec.redir.redirectingNumber.number_type);
1772 p.writeInt32(infoRec->rec.redir.redirectingNumber.number_plan);
1773 p.writeInt32(infoRec->rec.redir.redirectingNumber.pi);
1774 p.writeInt32(infoRec->rec.redir.redirectingNumber.si);
1775 p.writeInt32(infoRec->rec.redir.redirectingReason);
1777 case RIL_CDMA_LINE_CONTROL_INFO_REC:
1778 p.writeInt32(infoRec->rec.lineCtrl.lineCtrlPolarityIncluded);
1779 p.writeInt32(infoRec->rec.lineCtrl.lineCtrlToggle);
1780 p.writeInt32(infoRec->rec.lineCtrl.lineCtrlReverse);
1781 p.writeInt32(infoRec->rec.lineCtrl.lineCtrlPowerDenial);
1783 appendPrintBuf("%slineCtrlPolarityIncluded=%d, \
1784 lineCtrlToggle=%d, lineCtrlReverse=%d, \
1785 lineCtrlPowerDenial=%d, ", printBuf,
1786 (int)infoRec->rec.lineCtrl.lineCtrlPolarityIncluded,
1787 (int)infoRec->rec.lineCtrl.lineCtrlToggle,
1788 (int)infoRec->rec.lineCtrl.lineCtrlReverse,
1789 (int)infoRec->rec.lineCtrl.lineCtrlPowerDenial);
1792 case RIL_CDMA_T53_CLIR_INFO_REC:
1793 p.writeInt32((int)(infoRec->rec.clir.cause));
1795 appendPrintBuf("%scause%d", printBuf, infoRec->rec.clir.cause);
1798 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC:
1799 p.writeInt32(infoRec->rec.audioCtrl.upLink);
1800 p.writeInt32(infoRec->rec.audioCtrl.downLink);
1802 appendPrintBuf("%supLink=%d, downLink=%d, ", printBuf,
1803 infoRec->rec.audioCtrl.upLink,
1804 infoRec->rec.audioCtrl.downLink);
1807 case RIL_CDMA_T53_RELEASE_INFO_REC:
1808 // TODO(Moto): See David Krause, he has the answer:)
1809 LOGE("RIL_CDMA_T53_RELEASE_INFO_REC: return INVALID_RESPONSE");
1810 return RIL_ERRNO_INVALID_RESPONSE;
1812 LOGE("Incorrect name value");
1813 return RIL_ERRNO_INVALID_RESPONSE;
1821 static int responseRilSignalStrength(Parcel &p,
1822 void *response, size_t responselen) {
1823 if (response == NULL && responselen != 0) {
1824 LOGE("invalid response: NULL");
1825 return RIL_ERRNO_INVALID_RESPONSE;
1828 if (responselen == sizeof (RIL_SignalStrength)) {
1830 RIL_SignalStrength *p_cur = ((RIL_SignalStrength *) response);
1832 p.writeInt32(p_cur->GW_SignalStrength.signalStrength);
1833 p.writeInt32(p_cur->GW_SignalStrength.bitErrorRate);
1834 p.writeInt32(p_cur->CDMA_SignalStrength.dbm);
1835 p.writeInt32(p_cur->CDMA_SignalStrength.ecio);
1836 p.writeInt32(p_cur->EVDO_SignalStrength.dbm);
1837 p.writeInt32(p_cur->EVDO_SignalStrength.ecio);
1838 p.writeInt32(p_cur->EVDO_SignalStrength.signalNoiseRatio);
1841 appendPrintBuf("%s[signalStrength=%d,bitErrorRate=%d,\
1842 CDMA_SignalStrength.dbm=%d,CDMA_SignalStrength.ecio=%d,\
1843 EVDO_SignalStrength.dbm =%d,EVDO_SignalStrength.ecio=%d,\
1844 EVDO_SignalStrength.signalNoiseRatio=%d]",
1846 p_cur->GW_SignalStrength.signalStrength,
1847 p_cur->GW_SignalStrength.bitErrorRate,
1848 p_cur->CDMA_SignalStrength.dbm,
1849 p_cur->CDMA_SignalStrength.ecio,
1850 p_cur->EVDO_SignalStrength.dbm,
1851 p_cur->EVDO_SignalStrength.ecio,
1852 p_cur->EVDO_SignalStrength.signalNoiseRatio);
1856 } else if (responselen % sizeof (int) == 0) {
1857 // Old RIL deprecated
1858 int *p_cur = (int *) response;
1862 // With the Old RIL we see one or 2 integers.
1863 size_t num = responselen / sizeof (int); // Number of integers from ril
1864 size_t totalIntegers = 7; // Number of integers in RIL_SignalStrength
1867 appendPrintBuf("%s[", printBuf);
1868 for (i = 0; i < num; i++) {
1869 appendPrintBuf("%s %d", printBuf, *p_cur);
1870 p.writeInt32(*p_cur++);
1872 appendPrintBuf("%s]", printBuf);
1874 // Fill the remainder with zero's.
1875 for (; i < totalIntegers; i++) {
1881 LOGE("invalid response length");
1882 return RIL_ERRNO_INVALID_RESPONSE;
1888 static int responseCallRing(Parcel &p, void *response, size_t responselen) {
1889 if ((response == NULL) || (responselen == 0)) {
1890 return responseVoid(p, response, responselen);
1892 return responseCdmaSignalInfoRecord(p, response, responselen);
1896 static int responseCdmaSignalInfoRecord(Parcel &p, void *response, size_t responselen) {
1897 if (response == NULL || responselen == 0) {
1898 LOGE("invalid response: NULL");
1899 return RIL_ERRNO_INVALID_RESPONSE;
1902 if (responselen != sizeof (RIL_CDMA_SignalInfoRecord)) {
1903 LOGE("invalid response length %d expected sizeof (RIL_CDMA_SignalInfoRecord) of %d\n",
1904 (int)responselen, (int)sizeof (RIL_CDMA_SignalInfoRecord));
1905 return RIL_ERRNO_INVALID_RESPONSE;
1910 RIL_CDMA_SignalInfoRecord *p_cur = ((RIL_CDMA_SignalInfoRecord *) response);
1911 marshallSignalInfoRecord(p, *p_cur);
1913 appendPrintBuf("%s[isPresent=%d,signalType=%d,alertPitch=%d\
1925 static int responseCdmaCallWaiting(Parcel &p, void *response,
1926 size_t responselen) {
1927 if (response == NULL && responselen != 0) {
1928 LOGE("invalid response: NULL");
1929 return RIL_ERRNO_INVALID_RESPONSE;
1932 if (responselen != sizeof(RIL_CDMA_CallWaiting)) {
1933 LOGE("invalid response length %d expected %d\n",
1934 (int)responselen, (int)sizeof(RIL_CDMA_CallWaiting));
1935 return RIL_ERRNO_INVALID_RESPONSE;
1939 RIL_CDMA_CallWaiting *p_cur = ((RIL_CDMA_CallWaiting *) response);
1941 writeStringToParcel (p, p_cur->number);
1942 p.writeInt32(p_cur->numberPresentation);
1943 writeStringToParcel (p, p_cur->name);
1944 marshallSignalInfoRecord(p, p_cur->signalInfoRecord);
1946 appendPrintBuf("%snumber=%s,numberPresentation=%d, name=%s,\
1947 signalInfoRecord[isPresent=%d,signalType=%d,alertPitch=%d\
1951 p_cur->numberPresentation,
1953 p_cur->signalInfoRecord.isPresent,
1954 p_cur->signalInfoRecord.signalType,
1955 p_cur->signalInfoRecord.alertPitch,
1956 p_cur->signalInfoRecord.signal);
1963 static void triggerEvLoop() {
1965 if (!pthread_equal(pthread_self(), s_tid_dispatch)) {
1966 /* trigger event loop to wakeup. No reason to do this,
1967 * if we're in the event loop thread */
1969 ret = write (s_fdWakeupWrite, " ", 1);
1970 } while (ret < 0 && errno == EINTR);
1974 static void rilEventAddWakeup(struct ril_event *ev) {
1979 static int responseSimStatus(Parcel &p, void *response, size_t responselen) {
1982 if (response == NULL && responselen != 0) {
1983 LOGE("invalid response: NULL");
1984 return RIL_ERRNO_INVALID_RESPONSE;
1987 if (responselen % sizeof (RIL_CardStatus *) != 0) {
1988 LOGE("invalid response length %d expected multiple of %d\n",
1989 (int)responselen, (int)sizeof (RIL_CardStatus *));
1990 return RIL_ERRNO_INVALID_RESPONSE;
1993 RIL_CardStatus *p_cur = ((RIL_CardStatus *) response);
1995 p.writeInt32(p_cur->card_state);
1996 p.writeInt32(p_cur->universal_pin_state);
1997 p.writeInt32(p_cur->gsm_umts_subscription_app_index);
1998 p.writeInt32(p_cur->cdma_subscription_app_index);
1999 p.writeInt32(p_cur->num_applications);
2002 for (i = 0; i < p_cur->num_applications; i++) {
2003 p.writeInt32(p_cur->applications[i].app_type);
2004 p.writeInt32(p_cur->applications[i].app_state);
2005 p.writeInt32(p_cur->applications[i].perso_substate);
2006 writeStringToParcel(p, (const char*)(p_cur->applications[i].aid_ptr));
2007 writeStringToParcel(p, (const char*)
2008 (p_cur->applications[i].app_label_ptr));
2009 p.writeInt32(p_cur->applications[i].pin1_replaced);
2010 p.writeInt32(p_cur->applications[i].pin1);
2011 p.writeInt32(p_cur->applications[i].pin2);
2012 appendPrintBuf("%s[app_type=%d,app_state=%d,perso_substate=%d,\
2013 aid_ptr=%s,app_label_ptr=%s,pin1_replaced=%d,pin1=%d,pin2=%d],",
2015 p_cur->applications[i].app_type,
2016 p_cur->applications[i].app_state,
2017 p_cur->applications[i].perso_substate,
2018 p_cur->applications[i].aid_ptr,
2019 p_cur->applications[i].app_label_ptr,
2020 p_cur->applications[i].pin1_replaced,
2021 p_cur->applications[i].pin1,
2022 p_cur->applications[i].pin2);
2029 static int responseGsmBrSmsCnf(Parcel &p, void *response, size_t responselen) {
2030 int num = responselen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
2034 RIL_GSM_BroadcastSmsConfigInfo **p_cur =
2035 (RIL_GSM_BroadcastSmsConfigInfo **) response;
2036 for (int i = 0; i < num; i++) {
2037 p.writeInt32(p_cur[i]->fromServiceId);
2038 p.writeInt32(p_cur[i]->toServiceId);
2039 p.writeInt32(p_cur[i]->fromCodeScheme);
2040 p.writeInt32(p_cur[i]->toCodeScheme);
2041 p.writeInt32(p_cur[i]->selected);
2043 appendPrintBuf("%s [%d: fromServiceId=%d, toServiceId=%d, \
2044 fromCodeScheme=%d, toCodeScheme=%d, selected =%d]",
2045 printBuf, i, p_cur[i]->fromServiceId, p_cur[i]->toServiceId,
2046 p_cur[i]->fromCodeScheme, p_cur[i]->toCodeScheme,
2047 p_cur[i]->selected);
2054 static int responseCdmaBrSmsCnf(Parcel &p, void *response, size_t responselen) {
2055 RIL_CDMA_BroadcastSmsConfigInfo **p_cur =
2056 (RIL_CDMA_BroadcastSmsConfigInfo **) response;
2058 int num = responselen / sizeof (RIL_CDMA_BroadcastSmsConfigInfo *);
2062 for (int i = 0 ; i < num ; i++ ) {
2063 p.writeInt32(p_cur[i]->service_category);
2064 p.writeInt32(p_cur[i]->language);
2065 p.writeInt32(p_cur[i]->selected);
2067 appendPrintBuf("%s [%d: srvice_category=%d, language =%d, \
2069 printBuf, i, p_cur[i]->service_category, p_cur[i]->language,
2070 p_cur[i]->selected);
2077 static int responseCdmaSms(Parcel &p, void *response, size_t responselen) {
2084 LOGD("Inside responseCdmaSms");
2086 if (response == NULL && responselen != 0) {
2087 LOGE("invalid response: NULL");
2088 return RIL_ERRNO_INVALID_RESPONSE;
2091 if (responselen != sizeof(RIL_CDMA_SMS_Message)) {
2092 LOGE("invalid response length was %d expected %d",
2093 (int)responselen, (int)sizeof(RIL_CDMA_SMS_Message));
2094 return RIL_ERRNO_INVALID_RESPONSE;
2097 RIL_CDMA_SMS_Message *p_cur = (RIL_CDMA_SMS_Message *) response;
2098 p.writeInt32(p_cur->uTeleserviceID);
2099 p.write(&(p_cur->bIsServicePresent),sizeof(uct));
2100 p.writeInt32(p_cur->uServicecategory);
2101 p.writeInt32(p_cur->sAddress.digit_mode);
2102 p.writeInt32(p_cur->sAddress.number_mode);
2103 p.writeInt32(p_cur->sAddress.number_type);
2104 p.writeInt32(p_cur->sAddress.number_plan);
2105 p.write(&(p_cur->sAddress.number_of_digits), sizeof(uct));
2106 digitLimit= MIN((p_cur->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
2107 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
2108 p.write(&(p_cur->sAddress.digits[digitCount]),sizeof(uct));
2111 p.writeInt32(p_cur->sSubAddress.subaddressType);
2112 p.write(&(p_cur->sSubAddress.odd),sizeof(uct));
2113 p.write(&(p_cur->sSubAddress.number_of_digits),sizeof(uct));
2114 digitLimit= MIN((p_cur->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
2115 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
2116 p.write(&(p_cur->sSubAddress.digits[digitCount]),sizeof(uct));
2119 digitLimit= MIN((p_cur->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
2120 p.writeInt32(p_cur->uBearerDataLen);
2121 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
2122 p.write(&(p_cur->aBearerData[digitCount]), sizeof(uct));
2126 appendPrintBuf("%suTeleserviceID=%d, bIsServicePresent=%d, uServicecategory=%d, \
2127 sAddress.digit_mode=%d, sAddress.number_mode=%d, sAddress.number_type=%d, ",
2128 printBuf, p_cur->uTeleserviceID,p_cur->bIsServicePresent,p_cur->uServicecategory,
2129 p_cur->sAddress.digit_mode, p_cur->sAddress.number_mode,p_cur->sAddress.number_type);
2136 * A write on the wakeup fd is done just to pop us out of select()
2137 * We empty the buffer here and then ril_event will reset the timers on the
2140 static void processWakeupCallback(int fd, short flags, void *param) {
2144 LOGV("processWakeupCallback");
2146 /* empty our wakeup socket out */
2148 ret = read(s_fdWakeupRead, &buff, sizeof(buff));
2149 } while (ret > 0 || (ret < 0 && errno == EINTR));
2152 static void onCommandsSocketClosed() {
2156 /* mark pending requests as "cancelled" so we dont report responses */
2158 ret = pthread_mutex_lock(&s_pendingRequestsMutex);
2161 p_cur = s_pendingRequests;
2163 for (p_cur = s_pendingRequests
2165 ; p_cur = p_cur->p_next
2167 p_cur->cancelled = 1;
2170 ret = pthread_mutex_unlock(&s_pendingRequestsMutex);
2174 static void processCommandsCallback(int fd, short flags, void *param) {
2180 assert(fd == s_fdCommand);
2182 p_rs = (RecordStream *)param;
2185 /* loop until EAGAIN/EINTR, end of stream, or other error */
2186 ret = record_stream_get_next(p_rs, &p_record, &recordlen);
2188 if (ret == 0 && p_record == NULL) {
2191 } else if (ret < 0) {
2193 } else if (ret == 0) { /* && p_record != NULL */
2194 processCommandBuffer(p_record, recordlen);
2198 if (ret == 0 || !(errno == EAGAIN || errno == EINTR)) {
2199 /* fatal error or end-of-stream */
2201 LOGE("error on reading command socket errno:%d\n", errno);
2203 LOGW("EOS. Closing command socket.");
2209 ril_event_del(&s_commands_event);
2211 record_stream_free(p_rs);
2213 /* start listening for new connections again */
2214 rilEventAddWakeup(&s_listen_event);
2216 onCommandsSocketClosed();
2221 static void onNewCommandConnect() {
2222 // implicit radio state changed
2223 RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED,
2226 // Send last NITZ time data, in case it was missed
2227 if (s_lastNITZTimeData != NULL) {
2228 sendResponseRaw(s_lastNITZTimeData, s_lastNITZTimeDataSize);
2230 free(s_lastNITZTimeData);
2231 s_lastNITZTimeData = NULL;
2234 // Get version string
2235 if (s_callbacks.getVersion != NULL) {
2236 const char *version;
2237 version = s_callbacks.getVersion();
2238 LOGI("RIL Daemon version: %s\n", version);
2240 property_set(PROPERTY_RIL_IMPL, version);
2242 LOGI("RIL Daemon version: unavailable\n");
2243 property_set(PROPERTY_RIL_IMPL, "unavailable");
2248 static void listenCallback (int fd, short flags, void *param) {
2251 int is_phone_socket;
2254 struct sockaddr_un peeraddr;
2255 socklen_t socklen = sizeof (peeraddr);
2258 socklen_t szCreds = sizeof(creds);
2260 struct passwd *pwd = NULL;
2262 assert (s_fdCommand < 0);
2263 assert (fd == s_fdListen);
2265 s_fdCommand = accept(s_fdListen, (sockaddr *) &peeraddr, &socklen);
2267 if (s_fdCommand < 0 ) {
2268 LOGE("Error on accept() errno:%d", errno);
2269 /* start listening for new connections again */
2270 rilEventAddWakeup(&s_listen_event);
2274 /* check the credential of the other side and only accept socket from
2278 is_phone_socket = 0;
2280 err = getsockopt(s_fdCommand, SOL_SOCKET, SO_PEERCRED, &creds, &szCreds);
2282 if (err == 0 && szCreds > 0) {
2284 pwd = getpwuid(creds.uid);
2286 if (strcmp(pwd->pw_name, PHONE_PROCESS) == 0) {
2287 is_phone_socket = 1;
2289 LOGE("RILD can't accept socket from process %s", pwd->pw_name);
2292 LOGE("Error on getpwuid() errno: %d", errno);
2295 LOGD("Error on getsockopt() errno: %d", errno);
2298 if ( !is_phone_socket ) {
2299 LOGE("RILD must accept socket from %s", PHONE_PROCESS);
2304 onCommandsSocketClosed();
2306 /* start listening for new connections again */
2307 rilEventAddWakeup(&s_listen_event);
2312 ret = fcntl(s_fdCommand, F_SETFL, O_NONBLOCK);
2315 LOGE ("Error setting O_NONBLOCK errno:%d", errno);
2318 LOGI("libril: new connection");
2320 p_rs = record_stream_new(s_fdCommand, MAX_COMMAND_BYTES);
2322 ril_event_set (&s_commands_event, s_fdCommand, 1,
2323 processCommandsCallback, p_rs);
2325 rilEventAddWakeup (&s_commands_event);
2327 onNewCommandConnect();
2330 static void freeDebugCallbackArgs(int number, char **args) {
2331 for (int i = 0; i < number; i++) {
2332 if (args[i] != NULL) {
2339 static void debugCallback (int fd, short flags, void *param) {
2340 int acceptFD, option;
2341 struct sockaddr_un peeraddr;
2342 socklen_t socklen = sizeof (peeraddr);
2344 unsigned int qxdm_data[6];
2345 const char *deactData[1] = {"1"};
2348 int hangupData[1] = {1};
2352 acceptFD = accept (fd, (sockaddr *) &peeraddr, &socklen);
2355 LOGE ("error accepting on debug port: %d\n", errno);
2359 if (recv(acceptFD, &number, sizeof(int), 0) != sizeof(int)) {
2360 LOGE ("error reading on socket: number of Args: \n");
2363 args = (char **) malloc(sizeof(char*) * number);
2365 for (int i = 0; i < number; i++) {
2367 if (recv(acceptFD, &len, sizeof(int), 0) != sizeof(int)) {
2368 LOGE ("error reading on socket: Len of Args: \n");
2369 freeDebugCallbackArgs(i, args);
2373 args[i] = (char *) malloc((sizeof(char) * len) + 1);
2374 if (recv(acceptFD, args[i], sizeof(char) * len, 0)
2375 != (int)sizeof(char) * len) {
2376 LOGE ("error reading on socket: Args[%d] \n", i);
2377 freeDebugCallbackArgs(i, args);
2380 char * buf = args[i];
2384 switch (atoi(args[0])) {
2386 LOGI ("Connection on debug port: issuing reset.");
2387 issueLocalRequest(RIL_REQUEST_RESET_RADIO, NULL, 0);
2390 LOGI ("Connection on debug port: issuing radio power off.");
2392 issueLocalRequest(RIL_REQUEST_RADIO_POWER, &data, sizeof(int));
2398 LOGI ("Debug port: issuing unsolicited network change.");
2399 RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED,
2403 LOGI ("Debug port: QXDM log enable.");
2404 qxdm_data[0] = 65536; // head.func_tag
2405 qxdm_data[1] = 16; // head.len
2406 qxdm_data[2] = 1; // mode: 1 for 'start logging'
2407 qxdm_data[3] = 32; // log_file_size: 32megabytes
2408 qxdm_data[4] = 0; // log_mask
2409 qxdm_data[5] = 8; // log_max_fileindex
2410 issueLocalRequest(RIL_REQUEST_OEM_HOOK_RAW, qxdm_data,
2414 LOGI ("Debug port: QXDM log disable.");
2415 qxdm_data[0] = 65536;
2417 qxdm_data[2] = 0; // mode: 0 for 'stop logging'
2421 issueLocalRequest(RIL_REQUEST_OEM_HOOK_RAW, qxdm_data,
2425 LOGI("Debug port: Radio On");
2427 issueLocalRequest(RIL_REQUEST_RADIO_POWER, &data, sizeof(int));
2429 // Set network selection automatic.
2430 issueLocalRequest(RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC, NULL, 0);
2433 LOGI("Debug port: Setup Data Call, Apn :%s\n", args[1]);
2434 actData[0] = args[1];
2435 issueLocalRequest(RIL_REQUEST_SETUP_DATA_CALL, &actData,
2439 LOGI("Debug port: Deactivate Data Call");
2440 issueLocalRequest(RIL_REQUEST_DEACTIVATE_DATA_CALL, &deactData,
2444 LOGI("Debug port: Dial Call");
2446 dialData.address = args[1];
2447 issueLocalRequest(RIL_REQUEST_DIAL, &dialData, sizeof(dialData));
2450 LOGI("Debug port: Answer Call");
2451 issueLocalRequest(RIL_REQUEST_ANSWER, NULL, 0);
2454 LOGI("Debug port: End Call");
2455 issueLocalRequest(RIL_REQUEST_HANGUP, &hangupData,
2456 sizeof(hangupData));
2459 LOGE ("Invalid request");
2462 freeDebugCallbackArgs(number, args);
2467 static void userTimerCallback (int fd, short flags, void *param) {
2468 UserCallbackInfo *p_info;
2470 p_info = (UserCallbackInfo *)param;
2472 p_info->p_callback(p_info->userParam);
2475 // FIXME generalize this...there should be a cancel mechanism
2476 if (s_last_wake_timeout_info != NULL && s_last_wake_timeout_info == p_info) {
2477 s_last_wake_timeout_info = NULL;
2485 eventLoop(void *param) {
2491 pthread_mutex_lock(&s_startupMutex);
2494 pthread_cond_broadcast(&s_startupCond);
2496 pthread_mutex_unlock(&s_startupMutex);
2498 ret = pipe(filedes);
2501 LOGE("Error in pipe() errno:%d", errno);
2505 s_fdWakeupRead = filedes[0];
2506 s_fdWakeupWrite = filedes[1];
2508 fcntl(s_fdWakeupRead, F_SETFL, O_NONBLOCK);
2510 ril_event_set (&s_wakeupfd_event, s_fdWakeupRead, true,
2511 processWakeupCallback, NULL);
2513 rilEventAddWakeup (&s_wakeupfd_event);
2515 // Only returns on error
2517 LOGE ("error in event_loop_base errno:%d", errno);
2523 RIL_startEventLoop(void) {
2525 pthread_attr_t attr;
2527 /* spin up eventLoop thread and wait for it to get started */
2529 pthread_mutex_lock(&s_startupMutex);
2531 pthread_attr_init (&attr);
2532 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
2533 ret = pthread_create(&s_tid_dispatch, &attr, eventLoop, NULL);
2535 while (s_started == 0) {
2536 pthread_cond_wait(&s_startupCond, &s_startupMutex);
2539 pthread_mutex_unlock(&s_startupMutex);
2542 LOGE("Failed to create dispatch thread errno:%d", errno);
2547 // Used for testing purpose only.
2548 extern "C" void RIL_setcallbacks (const RIL_RadioFunctions *callbacks) {
2549 memcpy(&s_callbacks, callbacks, sizeof (RIL_RadioFunctions));
2553 RIL_register (const RIL_RadioFunctions *callbacks) {
2557 if (callbacks == NULL || ((callbacks->version != RIL_VERSION)
2558 && (callbacks->version < 2))) { // Remove when partners upgrade to version 3
2560 "RIL_register: RIL_RadioFunctions * null or invalid version"
2561 " (expected %d)", RIL_VERSION);
2564 if (callbacks->version < RIL_VERSION) {
2565 LOGE ("RIL_register: upgrade RIL to version %d current version=%d",
2566 RIL_VERSION, callbacks->version);
2569 if (s_registerCalled > 0) {
2570 LOGE("RIL_register has been called more than once. "
2571 "Subsequent call ignored");
2575 memcpy(&s_callbacks, callbacks, sizeof (RIL_RadioFunctions));
2577 s_registerCalled = 1;
2579 // Little self-check
2581 for (int i = 0; i < (int)NUM_ELEMS(s_commands); i++) {
2582 assert(i == s_commands[i].requestNumber);
2585 for (int i = 0; i < (int)NUM_ELEMS(s_unsolResponses); i++) {
2586 assert(i + RIL_UNSOL_RESPONSE_BASE
2587 == s_unsolResponses[i].requestNumber);
2590 // New rild impl calls RIL_startEventLoop() first
2591 // old standalone impl wants it here.
2593 if (s_started == 0) {
2594 RIL_startEventLoop();
2597 // start listen socket
2600 ret = socket_local_server (SOCKET_NAME_RIL,
2601 ANDROID_SOCKET_NAMESPACE_ABSTRACT, SOCK_STREAM);
2604 LOGE("Unable to bind socket errno:%d", errno);
2610 s_fdListen = android_get_control_socket(SOCKET_NAME_RIL);
2611 if (s_fdListen < 0) {
2612 LOGE("Failed to get socket '" SOCKET_NAME_RIL "'");
2616 ret = listen(s_fdListen, 4);
2619 LOGE("Failed to listen on control socket '%d': %s",
2620 s_fdListen, strerror(errno));
2626 /* note: non-persistent so we can accept only one connection at a time */
2627 ril_event_set (&s_listen_event, s_fdListen, false,
2628 listenCallback, NULL);
2630 rilEventAddWakeup (&s_listen_event);
2633 // start debug interface socket
2635 s_fdDebug = android_get_control_socket(SOCKET_NAME_RIL_DEBUG);
2636 if (s_fdDebug < 0) {
2637 LOGE("Failed to get socket '" SOCKET_NAME_RIL_DEBUG "' errno:%d", errno);
2641 ret = listen(s_fdDebug, 4);
2644 LOGE("Failed to listen on ril debug socket '%d': %s",
2645 s_fdDebug, strerror(errno));
2649 ril_event_set (&s_debug_event, s_fdDebug, true,
2650 debugCallback, NULL);
2652 rilEventAddWakeup (&s_debug_event);
2658 checkAndDequeueRequestInfo(struct RequestInfo *pRI) {
2665 pthread_mutex_lock(&s_pendingRequestsMutex);
2667 for(RequestInfo **ppCur = &s_pendingRequests
2669 ; ppCur = &((*ppCur)->p_next)
2671 if (pRI == *ppCur) {
2674 *ppCur = (*ppCur)->p_next;
2679 pthread_mutex_unlock(&s_pendingRequestsMutex);
2686 RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responselen) {
2691 pRI = (RequestInfo *)t;
2693 if (!checkAndDequeueRequestInfo(pRI)) {
2694 LOGE ("RIL_onRequestComplete: invalid RIL_Token");
2698 if (pRI->local > 0) {
2699 // Locally issued command...void only!
2700 // response does not go back up the command socket
2701 LOGD("C[locl]< %s", requestToString(pRI->pCI->requestNumber));
2706 appendPrintBuf("[%04d]< %s",
2707 pRI->token, requestToString(pRI->pCI->requestNumber));
2709 if (pRI->cancelled == 0) {
2712 p.writeInt32 (RESPONSE_SOLICITED);
2713 p.writeInt32 (pRI->token);
2714 errorOffset = p.dataPosition();
2718 if (response != NULL) {
2719 // there is a response payload, no matter success or not.
2720 ret = pRI->pCI->responseFunction(p, response, responselen);
2722 /* if an error occurred, rewind and mark it */
2724 p.setDataPosition(errorOffset);
2729 if (e != RIL_E_SUCCESS) {
2730 appendPrintBuf("%s fails by %s", printBuf, failCauseToString(e));
2733 if (s_fdCommand < 0) {
2734 LOGD ("RIL onRequestComplete: Command channel closed");
2745 grabPartialWakeLock() {
2746 acquire_wake_lock(PARTIAL_WAKE_LOCK, ANDROID_WAKE_LOCK_NAME);
2751 release_wake_lock(ANDROID_WAKE_LOCK_NAME);
2755 * Timer callback to put us back to sleep before the default timeout
2758 wakeTimeoutCallback (void *param) {
2759 // We're using "param != NULL" as a cancellation mechanism
2760 if (param == NULL) {
2761 //LOGD("wakeTimeout: releasing wake lock");
2765 //LOGD("wakeTimeout: releasing wake lock CANCELLED");
2770 void RIL_onUnsolicitedResponse(int unsolResponse, void *data,
2773 int unsolResponseIndex;
2775 int64_t timeReceived = 0;
2776 bool shouldScheduleTimeout = false;
2778 if (s_registerCalled == 0) {
2779 // Ignore RIL_onUnsolicitedResponse before RIL_register
2780 LOGW("RIL_onUnsolicitedResponse called before RIL_register");
2784 unsolResponseIndex = unsolResponse - RIL_UNSOL_RESPONSE_BASE;
2786 if ((unsolResponseIndex < 0)
2787 || (unsolResponseIndex >= (int32_t)NUM_ELEMS(s_unsolResponses))) {
2788 LOGE("unsupported unsolicited response code %d", unsolResponse);
2792 // Grab a wake lock if needed for this reponse,
2793 // as we exit we'll either release it immediately
2794 // or set a timer to release it later.
2795 switch (s_unsolResponses[unsolResponseIndex].wakeType) {
2797 grabPartialWakeLock();
2798 shouldScheduleTimeout = true;
2803 // No wake lock is grabed so don't set timeout
2804 shouldScheduleTimeout = false;
2808 // Mark the time this was received, doing this
2809 // after grabing the wakelock incase getting
2810 // the elapsedRealTime might cause us to goto
2812 if (unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) {
2813 timeReceived = elapsedRealtime();
2816 appendPrintBuf("[UNSL]< %s", requestToString(unsolResponse));
2820 p.writeInt32 (RESPONSE_UNSOLICITED);
2821 p.writeInt32 (unsolResponse);
2823 ret = s_unsolResponses[unsolResponseIndex]
2824 .responseFunction(p, data, datalen);
2826 // Problem with the response. Don't continue;
2830 // some things get more payload
2831 switch(unsolResponse) {
2832 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED:
2833 p.writeInt32(s_callbacks.onStateRequest());
2834 appendPrintBuf("%s {%s}", printBuf,
2835 radioStateToString(s_callbacks.onStateRequest()));
2839 case RIL_UNSOL_NITZ_TIME_RECEIVED:
2840 // Store the time that this was received so the
2841 // handler of this message can account for
2842 // the time it takes to arrive and process. In
2843 // particular the system has been known to sleep
2844 // before this message can be processed.
2845 p.writeInt64(timeReceived);
2849 ret = sendResponse(p);
2850 if (ret != 0 && unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) {
2852 // Unfortunately, NITZ time is not poll/update like everything
2853 // else in the system. So, if the upstream client isn't connected,
2854 // keep a copy of the last NITZ response (with receive time noted
2855 // above) around so we can deliver it when it is connected
2857 if (s_lastNITZTimeData != NULL) {
2858 free (s_lastNITZTimeData);
2859 s_lastNITZTimeData = NULL;
2862 s_lastNITZTimeData = malloc(p.dataSize());
2863 s_lastNITZTimeDataSize = p.dataSize();
2864 memcpy(s_lastNITZTimeData, p.data(), p.dataSize());
2867 // For now, we automatically go back to sleep after TIMEVAL_WAKE_TIMEOUT
2868 // FIXME The java code should handshake here to release wake lock
2870 if (shouldScheduleTimeout) {
2871 // Cancel the previous request
2872 if (s_last_wake_timeout_info != NULL) {
2873 s_last_wake_timeout_info->userParam = (void *)1;
2876 s_last_wake_timeout_info
2877 = internalRequestTimedCallback(wakeTimeoutCallback, NULL,
2878 &TIMEVAL_WAKE_TIMEOUT);
2885 if (shouldScheduleTimeout) {
2890 /** FIXME generalize this if you track UserCAllbackInfo, clear it
2891 when the callback occurs
2893 static UserCallbackInfo *
2894 internalRequestTimedCallback (RIL_TimedCallback callback, void *param,
2895 const struct timeval *relativeTime)
2897 struct timeval myRelativeTime;
2898 UserCallbackInfo *p_info;
2900 p_info = (UserCallbackInfo *) malloc (sizeof(UserCallbackInfo));
2902 p_info->p_callback = callback;
2903 p_info->userParam = param;
2905 if (relativeTime == NULL) {
2906 /* treat null parameter as a 0 relative time */
2907 memset (&myRelativeTime, 0, sizeof(myRelativeTime));
2909 /* FIXME I think event_add's tv param is really const anyway */
2910 memcpy (&myRelativeTime, relativeTime, sizeof(myRelativeTime));
2913 ril_event_set(&(p_info->event), -1, false, userTimerCallback, p_info);
2915 ril_timer_add(&(p_info->event), &myRelativeTime);
2923 RIL_requestTimedCallback (RIL_TimedCallback callback, void *param,
2924 const struct timeval *relativeTime) {
2925 internalRequestTimedCallback (callback, param, relativeTime);
2929 failCauseToString(RIL_Errno e) {
2931 case RIL_E_SUCCESS: return "E_SUCCESS";
2932 case RIL_E_RADIO_NOT_AVAILABLE: return "E_RAIDO_NOT_AVAILABLE";
2933 case RIL_E_GENERIC_FAILURE: return "E_GENERIC_FAILURE";
2934 case RIL_E_PASSWORD_INCORRECT: return "E_PASSWORD_INCORRECT";
2935 case RIL_E_SIM_PIN2: return "E_SIM_PIN2";
2936 case RIL_E_SIM_PUK2: return "E_SIM_PUK2";
2937 case RIL_E_REQUEST_NOT_SUPPORTED: return "E_REQUEST_NOT_SUPPORTED";
2938 case RIL_E_CANCELLED: return "E_CANCELLED";
2939 case RIL_E_OP_NOT_ALLOWED_DURING_VOICE_CALL: return "E_OP_NOT_ALLOWED_DURING_VOICE_CALL";
2940 case RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW: return "E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW";
2941 case RIL_E_SMS_SEND_FAIL_RETRY: return "E_SMS_SEND_FAIL_RETRY";
2942 case RIL_E_SIM_ABSENT:return "E_SIM_ABSENT";
2943 case RIL_E_ILLEGAL_SIM_OR_ME:return "E_ILLEGAL_SIM_OR_ME";
2944 #ifdef FEATURE_MULTIMODE_ANDROID
2945 case RIL_E_SUBSCRIPTION_NOT_AVAILABLE:return "E_SUBSCRIPTION_NOT_AVAILABLE";
2946 case RIL_E_MODE_NOT_SUPPORTED:return "E_MODE_NOT_SUPPORTED";
2948 default: return "<unknown error>";
2953 radioStateToString(RIL_RadioState s) {
2955 case RADIO_STATE_OFF: return "RADIO_OFF";
2956 case RADIO_STATE_UNAVAILABLE: return "RADIO_UNAVAILABLE";
2957 case RADIO_STATE_SIM_NOT_READY: return "RADIO_SIM_NOT_READY";
2958 case RADIO_STATE_SIM_LOCKED_OR_ABSENT: return "RADIO_SIM_LOCKED_OR_ABSENT";
2959 case RADIO_STATE_SIM_READY: return "RADIO_SIM_READY";
2960 case RADIO_STATE_RUIM_NOT_READY:return"RADIO_RUIM_NOT_READY";
2961 case RADIO_STATE_RUIM_READY:return"RADIO_RUIM_READY";
2962 case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:return"RADIO_RUIM_LOCKED_OR_ABSENT";
2963 case RADIO_STATE_NV_NOT_READY:return"RADIO_NV_NOT_READY";
2964 case RADIO_STATE_NV_READY:return"RADIO_NV_READY";
2965 default: return "<unknown state>";
2970 callStateToString(RIL_CallState s) {
2972 case RIL_CALL_ACTIVE : return "ACTIVE";
2973 case RIL_CALL_HOLDING: return "HOLDING";
2974 case RIL_CALL_DIALING: return "DIALING";
2975 case RIL_CALL_ALERTING: return "ALERTING";
2976 case RIL_CALL_INCOMING: return "INCOMING";
2977 case RIL_CALL_WAITING: return "WAITING";
2978 default: return "<unknown state>";
2983 requestToString(int request) {
2985 cat libs/telephony/ril_commands.h \
2986 | egrep "^ *{RIL_" \
2987 | sed -re 's/\{RIL_([^,]+),[^,]+,([^}]+).+/case RIL_\1: return "\1";/'
2990 cat libs/telephony/ril_unsol_commands.h \
2991 | egrep "^ *{RIL_" \
2992 | sed -re 's/\{RIL_([^,]+),([^}]+).+/case RIL_\1: return "\1";/'
2996 case RIL_REQUEST_GET_SIM_STATUS: return "GET_SIM_STATUS";
2997 case RIL_REQUEST_ENTER_SIM_PIN: return "ENTER_SIM_PIN";
2998 case RIL_REQUEST_ENTER_SIM_PUK: return "ENTER_SIM_PUK";
2999 case RIL_REQUEST_ENTER_SIM_PIN2: return "ENTER_SIM_PIN2";
3000 case RIL_REQUEST_ENTER_SIM_PUK2: return "ENTER_SIM_PUK2";
3001 case RIL_REQUEST_CHANGE_SIM_PIN: return "CHANGE_SIM_PIN";
3002 case RIL_REQUEST_CHANGE_SIM_PIN2: return "CHANGE_SIM_PIN2";
3003 case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: return "ENTER_NETWORK_DEPERSONALIZATION";
3004 case RIL_REQUEST_GET_CURRENT_CALLS: return "GET_CURRENT_CALLS";
3005 case RIL_REQUEST_DIAL: return "DIAL";
3006 case RIL_REQUEST_GET_IMSI: return "GET_IMSI";
3007 case RIL_REQUEST_HANGUP: return "HANGUP";
3008 case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: return "HANGUP_WAITING_OR_BACKGROUND";
3009 case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: return "HANGUP_FOREGROUND_RESUME_BACKGROUND";
3010 case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: return "SWITCH_WAITING_OR_HOLDING_AND_ACTIVE";
3011 case RIL_REQUEST_CONFERENCE: return "CONFERENCE";
3012 case RIL_REQUEST_UDUB: return "UDUB";
3013 case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: return "LAST_CALL_FAIL_CAUSE";
3014 case RIL_REQUEST_SIGNAL_STRENGTH: return "SIGNAL_STRENGTH";
3015 case RIL_REQUEST_REGISTRATION_STATE: return "REGISTRATION_STATE";
3016 case RIL_REQUEST_GPRS_REGISTRATION_STATE: return "GPRS_REGISTRATION_STATE";
3017 case RIL_REQUEST_OPERATOR: return "OPERATOR";
3018 case RIL_REQUEST_RADIO_POWER: return "RADIO_POWER";
3019 case RIL_REQUEST_DTMF: return "DTMF";
3020 case RIL_REQUEST_SEND_SMS: return "SEND_SMS";
3021 case RIL_REQUEST_SEND_SMS_EXPECT_MORE: return "SEND_SMS_EXPECT_MORE";
3022 case RIL_REQUEST_SETUP_DATA_CALL: return "SETUP_DATA_CALL";
3023 case RIL_REQUEST_SIM_IO: return "SIM_IO";
3024 case RIL_REQUEST_SEND_USSD: return "SEND_USSD";
3025 case RIL_REQUEST_CANCEL_USSD: return "CANCEL_USSD";
3026 case RIL_REQUEST_GET_CLIR: return "GET_CLIR";
3027 case RIL_REQUEST_SET_CLIR: return "SET_CLIR";
3028 case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: return "QUERY_CALL_FORWARD_STATUS";
3029 case RIL_REQUEST_SET_CALL_FORWARD: return "SET_CALL_FORWARD";
3030 case RIL_REQUEST_QUERY_CALL_WAITING: return "QUERY_CALL_WAITING";
3031 case RIL_REQUEST_SET_CALL_WAITING: return "SET_CALL_WAITING";
3032 case RIL_REQUEST_SMS_ACKNOWLEDGE: return "SMS_ACKNOWLEDGE";
3033 case RIL_REQUEST_GET_IMEI: return "GET_IMEI";
3034 case RIL_REQUEST_GET_IMEISV: return "GET_IMEISV";
3035 case RIL_REQUEST_ANSWER: return "ANSWER";
3036 case RIL_REQUEST_DEACTIVATE_DATA_CALL: return "DEACTIVATE_DATA_CALL";
3037 case RIL_REQUEST_QUERY_FACILITY_LOCK: return "QUERY_FACILITY_LOCK";
3038 case RIL_REQUEST_SET_FACILITY_LOCK: return "SET_FACILITY_LOCK";
3039 case RIL_REQUEST_CHANGE_BARRING_PASSWORD: return "CHANGE_BARRING_PASSWORD";
3040 case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: return "QUERY_NETWORK_SELECTION_MODE";
3041 case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: return "SET_NETWORK_SELECTION_AUTOMATIC";
3042 case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: return "SET_NETWORK_SELECTION_MANUAL";
3043 case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : return "QUERY_AVAILABLE_NETWORKS ";
3044 case RIL_REQUEST_DTMF_START: return "DTMF_START";
3045 case RIL_REQUEST_DTMF_STOP: return "DTMF_STOP";
3046 case RIL_REQUEST_BASEBAND_VERSION: return "BASEBAND_VERSION";
3047 case RIL_REQUEST_SEPARATE_CONNECTION: return "SEPARATE_CONNECTION";
3048 case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: return "SET_PREFERRED_NETWORK_TYPE";
3049 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: return "GET_PREFERRED_NETWORK_TYPE";
3050 case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: return "GET_NEIGHBORING_CELL_IDS";
3051 case RIL_REQUEST_SET_MUTE: return "SET_MUTE";
3052 case RIL_REQUEST_GET_MUTE: return "GET_MUTE";
3053 case RIL_REQUEST_QUERY_CLIP: return "QUERY_CLIP";
3054 case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: return "LAST_DATA_CALL_FAIL_CAUSE";
3055 case RIL_REQUEST_DATA_CALL_LIST: return "DATA_CALL_LIST";
3056 case RIL_REQUEST_RESET_RADIO: return "RESET_RADIO";
3057 case RIL_REQUEST_OEM_HOOK_RAW: return "OEM_HOOK_RAW";
3058 case RIL_REQUEST_OEM_HOOK_STRINGS: return "OEM_HOOK_STRINGS";
3059 case RIL_REQUEST_SET_BAND_MODE: return "SET_BAND_MODE";
3060 case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: return "QUERY_AVAILABLE_BAND_MODE";
3061 case RIL_REQUEST_STK_GET_PROFILE: return "STK_GET_PROFILE";
3062 case RIL_REQUEST_STK_SET_PROFILE: return "STK_SET_PROFILE";
3063 case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: return "STK_SEND_ENVELOPE_COMMAND";
3064 case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: return "STK_SEND_TERMINAL_RESPONSE";
3065 case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: return "STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM";
3066 case RIL_REQUEST_SCREEN_STATE: return "SCREEN_STATE";
3067 case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: return "EXPLICIT_CALL_TRANSFER";
3068 case RIL_REQUEST_SET_LOCATION_UPDATES: return "SET_LOCATION_UPDATES";
3069 case RIL_REQUEST_CDMA_SET_SUBSCRIPTION:return"CDMA_SET_SUBSCRIPTION";
3070 case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE:return"CDMA_SET_ROAMING_PREFERENCE";
3071 case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE:return"CDMA_QUERY_ROAMING_PREFERENCE";
3072 case RIL_REQUEST_SET_TTY_MODE:return"SET_TTY_MODE";
3073 case RIL_REQUEST_QUERY_TTY_MODE:return"QUERY_TTY_MODE";
3074 case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE";
3075 case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE";
3076 case RIL_REQUEST_CDMA_FLASH:return"CDMA_FLASH";
3077 case RIL_REQUEST_CDMA_BURST_DTMF:return"CDMA_BURST_DTMF";
3078 case RIL_REQUEST_CDMA_SEND_SMS:return"CDMA_SEND_SMS";
3079 case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE:return"CDMA_SMS_ACKNOWLEDGE";
3080 case RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG:return"GSM_GET_BROADCAST_SMS_CONFIG";
3081 case RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG:return"GSM_SET_BROADCAST_SMS_CONFIG";
3082 case RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG:return "CDMA_GET_BROADCAST_SMS_CONFIG";
3083 case RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG:return "CDMA_SET_BROADCAST_SMS_CONFIG";
3084 case RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION:return "CDMA_SMS_BROADCAST_ACTIVATION";
3085 case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: return"CDMA_VALIDATE_AND_WRITE_AKEY";
3086 case RIL_REQUEST_CDMA_SUBSCRIPTION: return"CDMA_SUBSCRIPTION";
3087 case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: return "CDMA_WRITE_SMS_TO_RUIM";
3088 case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: return "CDMA_DELETE_SMS_ON_RUIM";
3089 case RIL_REQUEST_DEVICE_IDENTITY: return "DEVICE_IDENTITY";
3090 case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: return "EXIT_EMERGENCY_CALLBACK_MODE";
3091 case RIL_REQUEST_GET_SMSC_ADDRESS: return "GET_SMSC_ADDRESS";
3092 case RIL_REQUEST_SET_SMSC_ADDRESS: return "SET_SMSC_ADDRESS";
3093 case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: return "REPORT_SMS_MEMORY_STATUS";
3094 case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: return "REPORT_STK_SERVICE_IS_RUNNING";
3095 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return "UNSOL_RESPONSE_RADIO_STATE_CHANGED";
3096 case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return "UNSOL_RESPONSE_CALL_STATE_CHANGED";
3097 case RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED: return "UNSOL_RESPONSE_NETWORK_STATE_CHANGED";
3098 case RIL_UNSOL_RESPONSE_NEW_SMS: return "UNSOL_RESPONSE_NEW_SMS";
3099 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: return "UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT";
3100 case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: return "UNSOL_RESPONSE_NEW_SMS_ON_SIM";
3101 case RIL_UNSOL_ON_USSD: return "UNSOL_ON_USSD";
3102 case RIL_UNSOL_ON_USSD_REQUEST: return "UNSOL_ON_USSD_REQUEST(obsolete)";
3103 case RIL_UNSOL_NITZ_TIME_RECEIVED: return "UNSOL_NITZ_TIME_RECEIVED";
3104 case RIL_UNSOL_SIGNAL_STRENGTH: return "UNSOL_SIGNAL_STRENGTH";
3105 case RIL_UNSOL_STK_SESSION_END: return "UNSOL_STK_SESSION_END";
3106 case RIL_UNSOL_STK_PROACTIVE_COMMAND: return "UNSOL_STK_PROACTIVE_COMMAND";
3107 case RIL_UNSOL_STK_EVENT_NOTIFY: return "UNSOL_STK_EVENT_NOTIFY";
3108 case RIL_UNSOL_STK_CALL_SETUP: return "UNSOL_STK_CALL_SETUP";
3109 case RIL_UNSOL_SIM_SMS_STORAGE_FULL: return "UNSOL_SIM_SMS_STORAGE_FUL";
3110 case RIL_UNSOL_SIM_REFRESH: return "UNSOL_SIM_REFRESH";
3111 case RIL_UNSOL_DATA_CALL_LIST_CHANGED: return "UNSOL_DATA_CALL_LIST_CHANGED";
3112 case RIL_UNSOL_CALL_RING: return "UNSOL_CALL_RING";
3113 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: return "UNSOL_RESPONSE_SIM_STATUS_CHANGED";
3114 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: return "UNSOL_NEW_CDMA_SMS";
3115 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: return "UNSOL_NEW_BROADCAST_SMS";
3116 case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: return "UNSOL_CDMA_RUIM_SMS_STORAGE_FULL";
3117 case RIL_UNSOL_RESTRICTED_STATE_CHANGED: return "UNSOL_RESTRICTED_STATE_CHANGED";
3118 case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: return "UNSOL_ENTER_EMERGENCY_CALLBACK_MODE";
3119 case RIL_UNSOL_CDMA_CALL_WAITING: return "UNSOL_CDMA_CALL_WAITING";
3120 case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: return "UNSOL_CDMA_OTA_PROVISION_STATUS";
3121 case RIL_UNSOL_CDMA_INFO_REC: return "UNSOL_CDMA_INFO_REC";
3122 case RIL_UNSOL_OEM_HOOK_RAW: return "UNSOL_OEM_HOOK_RAW";
3123 case RIL_UNSOL_RINGBACK_TONE: return "UNSOL_RINGBACK_TONE";
3124 case RIL_UNSOL_RESEND_INCALL_MUTE: return "UNSOL_RESEND_INCALL_MUTE";
3125 default: return "<unknown request>";
3129 } /* namespace android */