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 <utils/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);
205 static void dispatchCdmaSms(Parcel &p, RequestInfo *pRI);
206 static void dispatchCdmaSmsAck(Parcel &p, RequestInfo *pRI);
207 static void dispatchBrSmsCnf(Parcel &p, RequestInfo *pRI);
208 static void dispatchCdmaBrSmsCnf(Parcel &p, RequestInfo *pRI);
209 static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI);
210 static int responseInts(Parcel &p, void *response, size_t responselen);
211 static int responseStrings(Parcel &p, void *response, size_t responselen);
212 static int responseString(Parcel &p, void *response, size_t responselen);
213 static int responseVoid(Parcel &p, void *response, size_t responselen);
214 static int responseCallList(Parcel &p, void *response, size_t responselen);
215 static int responseSMS(Parcel &p, void *response, size_t responselen);
216 static int responseSIM_IO(Parcel &p, void *response, size_t responselen);
217 static int responseCallForwards(Parcel &p, void *response, size_t responselen);
218 static int responseDataCallList(Parcel &p, void *response, size_t responselen);
219 static int responseRaw(Parcel &p, void *response, size_t responselen);
220 static int responseSsn(Parcel &p, void *response, size_t responselen);
221 static int responseSimStatus(Parcel &p, void *response, size_t responselen);
222 static int responseBrSmsCnf(Parcel &p, void *response, size_t responselen);
223 static int responseCdmaBrCnf(Parcel &p, void *response, size_t responselen);
224 static int responseCdmaSms(Parcel &p, void *response, size_t responselen);
225 static int responseCellList(Parcel &p, void *response, size_t responselen);
226 static int responseCdmaInformationRecords(Parcel &p,void *response, size_t responselen);
227 static int responseRilSignalStrength(Parcel &p,void *response, size_t responselen);
228 static int responseCallRing(Parcel &p, void *response, size_t responselen);
229 static int responseCdmaSignalInfoRecord(Parcel &p,void *response, size_t responselen);
230 static int responseCdmaCallWaiting(Parcel &p,void *response, size_t responselen);
232 extern "C" const char * requestToString(int request);
233 extern "C" const char * failCauseToString(RIL_Errno);
234 extern "C" const char * callStateToString(RIL_CallState);
235 extern "C" const char * radioStateToString(RIL_RadioState);
238 extern "C" void RIL_onUnsolicitedResponse(int unsolResponse, void *data,
242 static UserCallbackInfo * internalRequestTimedCallback
243 (RIL_TimedCallback callback, void *param,
244 const struct timeval *relativeTime);
246 /** Index == requestNumber */
247 static CommandInfo s_commands[] = {
248 #include "ril_commands.h"
251 static UnsolResponseInfo s_unsolResponses[] = {
252 #include "ril_unsol_commands.h"
257 strdupReadString(Parcel &p) {
261 s16 = p.readString16Inplace(&stringlen);
263 return strndup16to8(s16, stringlen);
266 static void writeStringToParcel(Parcel &p, const char *s) {
269 s16 = strdup8to16(s, &s16_len);
270 p.writeString16(s16, s16_len);
276 memsetString (char *s) {
278 memset (s, 0, strlen(s));
282 void nullParcelReleaseFunction (const uint8_t* data, size_t dataSize,
283 const size_t* objects, size_t objectsSize,
285 // do nothing -- the data reference lives longer than the Parcel object
289 * To be called from dispatch thread
290 * Issue a single local request, ensuring that the response
291 * is not sent back up to the command process
294 issueLocalRequest(int request, void *data, int len) {
298 pRI = (RequestInfo *)calloc(1, sizeof(RequestInfo));
301 pRI->token = 0xffffffff; // token is not used in this context
302 pRI->pCI = &(s_commands[request]);
304 ret = pthread_mutex_lock(&s_pendingRequestsMutex);
307 pRI->p_next = s_pendingRequests;
308 s_pendingRequests = pRI;
310 ret = pthread_mutex_unlock(&s_pendingRequestsMutex);
313 LOGD("C[locl]> %s", requestToString(request));
315 s_callbacks.onRequest(request, data, len, pRI);
321 processCommandBuffer(void *buffer, size_t buflen) {
329 p.setData((uint8_t *) buffer, buflen);
331 // status checked at end
332 status = p.readInt32(&request);
333 status = p.readInt32 (&token);
335 if (status != NO_ERROR) {
336 LOGE("invalid request block");
340 if (request < 1 || request >= (int32_t)NUM_ELEMS(s_commands)) {
341 LOGE("unsupported request code %d token %d", request, token);
342 // FIXME this should perhaps return a response
347 pRI = (RequestInfo *)calloc(1, sizeof(RequestInfo));
350 pRI->pCI = &(s_commands[request]);
352 ret = pthread_mutex_lock(&s_pendingRequestsMutex);
355 pRI->p_next = s_pendingRequests;
356 s_pendingRequests = pRI;
358 ret = pthread_mutex_unlock(&s_pendingRequestsMutex);
361 /* sLastDispatchedToken = token; */
363 pRI->pCI->dispatchFunction(p, pRI);
369 invalidCommandBlock (RequestInfo *pRI) {
370 LOGE("invalid command block for token %d request %s",
371 pRI->token, requestToString(pRI->pCI->requestNumber));
374 /** Callee expects NULL */
376 dispatchVoid (Parcel& p, RequestInfo *pRI) {
378 printRequest(pRI->token, pRI->pCI->requestNumber);
379 s_callbacks.onRequest(pRI->pCI->requestNumber, NULL, 0, pRI);
382 /** Callee expects const char * */
384 dispatchString (Parcel& p, RequestInfo *pRI) {
388 char *string8 = NULL;
390 string8 = strdupReadString(p);
393 appendPrintBuf("%s%s", printBuf, string8);
395 printRequest(pRI->token, pRI->pCI->requestNumber);
397 s_callbacks.onRequest(pRI->pCI->requestNumber, string8,
398 sizeof(char *), pRI);
401 memsetString(string8);
407 invalidCommandBlock(pRI);
411 /** Callee expects const char ** */
413 dispatchStrings (Parcel &p, RequestInfo *pRI) {
414 int32_t countStrings;
419 status = p.readInt32 (&countStrings);
421 if (status != NO_ERROR) {
426 if (countStrings == 0) {
427 // just some non-null pointer
428 pStrings = (char **)alloca(sizeof(char *));
430 } else if (((int)countStrings) == -1) {
434 datalen = sizeof(char *) * countStrings;
436 pStrings = (char **)alloca(datalen);
438 for (int i = 0 ; i < countStrings ; i++) {
439 pStrings[i] = strdupReadString(p);
440 appendPrintBuf("%s%s,", printBuf, pStrings[i]);
445 printRequest(pRI->token, pRI->pCI->requestNumber);
447 s_callbacks.onRequest(pRI->pCI->requestNumber, pStrings, datalen, pRI);
449 if (pStrings != NULL) {
450 for (int i = 0 ; i < countStrings ; i++) {
452 memsetString (pStrings[i]);
458 memset(pStrings, 0, datalen);
464 invalidCommandBlock(pRI);
468 /** Callee expects const int * */
470 dispatchInts (Parcel &p, RequestInfo *pRI) {
476 status = p.readInt32 (&count);
478 if (status != NO_ERROR || count == 0) {
482 datalen = sizeof(int) * count;
483 pInts = (int *)alloca(datalen);
486 for (int i = 0 ; i < count ; i++) {
489 status = p.readInt32(&t);
491 appendPrintBuf("%s%d,", printBuf, t);
493 if (status != NO_ERROR) {
499 printRequest(pRI->token, pRI->pCI->requestNumber);
501 s_callbacks.onRequest(pRI->pCI->requestNumber, const_cast<int *>(pInts),
505 memset(pInts, 0, datalen);
510 invalidCommandBlock(pRI);
516 * Callee expects const RIL_SMS_WriteArgs *
522 dispatchSmsWrite (Parcel &p, RequestInfo *pRI) {
523 RIL_SMS_WriteArgs args;
527 memset (&args, 0, sizeof(args));
529 status = p.readInt32(&t);
530 args.status = (int)t;
532 args.pdu = strdupReadString(p);
534 if (status != NO_ERROR || args.pdu == NULL) {
538 args.smsc = strdupReadString(p);
541 appendPrintBuf("%s%d,%s,smsc=%s", printBuf, args.status,
542 (char*)args.pdu, (char*)args.smsc);
544 printRequest(pRI->token, pRI->pCI->requestNumber);
546 s_callbacks.onRequest(pRI->pCI->requestNumber, &args, sizeof(args), pRI);
549 memsetString (args.pdu);
555 memset(&args, 0, sizeof(args));
560 invalidCommandBlock(pRI);
565 * Callee expects const RIL_Dial *
571 dispatchDial (Parcel &p, RequestInfo *pRI) {
576 memset (&dial, 0, sizeof(dial));
578 dial.address = strdupReadString(p);
580 status = p.readInt32(&t);
583 if (status != NO_ERROR || dial.address == NULL) {
588 appendPrintBuf("%snum=%s,clir=%d", printBuf, dial.address, dial.clir);
590 printRequest(pRI->token, pRI->pCI->requestNumber);
592 s_callbacks.onRequest(pRI->pCI->requestNumber, &dial, sizeof(dial), pRI);
595 memsetString (dial.address);
601 memset(&dial, 0, sizeof(dial));
606 invalidCommandBlock(pRI);
611 * Callee expects const RIL_SIM_IO *
621 dispatchSIM_IO (Parcel &p, RequestInfo *pRI) {
626 memset (&simIO, 0, sizeof(simIO));
628 // note we only check status at the end
630 status = p.readInt32(&t);
631 simIO.command = (int)t;
633 status = p.readInt32(&t);
634 simIO.fileid = (int)t;
636 simIO.path = strdupReadString(p);
638 status = p.readInt32(&t);
641 status = p.readInt32(&t);
644 status = p.readInt32(&t);
647 simIO.data = strdupReadString(p);
648 simIO.pin2 = strdupReadString(p);
651 appendPrintBuf("%scmd=0x%X,efid=0x%X,path=%s,%d,%d,%d,%s,pin2=%s", printBuf,
652 simIO.command, simIO.fileid, (char*)simIO.path,
653 simIO.p1, simIO.p2, simIO.p3,
654 (char*)simIO.data, (char*)simIO.pin2);
656 printRequest(pRI->token, pRI->pCI->requestNumber);
658 if (status != NO_ERROR) {
662 s_callbacks.onRequest(pRI->pCI->requestNumber, &simIO, sizeof(simIO), pRI);
665 memsetString (simIO.path);
666 memsetString (simIO.data);
667 memsetString (simIO.pin2);
675 memset(&simIO, 0, sizeof(simIO));
680 invalidCommandBlock(pRI);
685 * Callee expects const RIL_CallForwardInfo *
687 * int32_t status/action
689 * int32_t serviceCode
691 * String number (0 length -> null)
692 * int32_t timeSeconds
695 dispatchCallForward(Parcel &p, RequestInfo *pRI) {
696 RIL_CallForwardInfo cff;
700 memset (&cff, 0, sizeof(cff));
702 // note we only check status at the end
704 status = p.readInt32(&t);
707 status = p.readInt32(&t);
710 status = p.readInt32(&t);
711 cff.serviceClass = (int)t;
713 status = p.readInt32(&t);
716 cff.number = strdupReadString(p);
718 status = p.readInt32(&t);
719 cff.timeSeconds = (int)t;
721 if (status != NO_ERROR) {
725 // special case: number 0-length fields is null
727 if (cff.number != NULL && strlen (cff.number) == 0) {
732 appendPrintBuf("%sstat=%d,reason=%d,serv=%d,toa=%d,%s,tout=%d", printBuf,
733 cff.status, cff.reason, cff.serviceClass, cff.toa,
734 (char*)cff.number, cff.timeSeconds);
736 printRequest(pRI->token, pRI->pCI->requestNumber);
738 s_callbacks.onRequest(pRI->pCI->requestNumber, &cff, sizeof(cff), pRI);
741 memsetString(cff.number);
747 memset(&cff, 0, sizeof(cff));
752 invalidCommandBlock(pRI);
758 dispatchRaw(Parcel &p, RequestInfo *pRI) {
763 status = p.readInt32(&len);
765 if (status != NO_ERROR) {
769 // The java code writes -1 for null arrays
770 if (((int)len) == -1) {
775 data = p.readInplace(len);
778 appendPrintBuf("%sraw_size=%d", printBuf, len);
780 printRequest(pRI->token, pRI->pCI->requestNumber);
782 s_callbacks.onRequest(pRI->pCI->requestNumber, const_cast<void *>(data), len, pRI);
786 invalidCommandBlock(pRI);
791 dispatchCdmaSms(Parcel &p, RequestInfo *pRI) {
792 RIL_CDMA_SMS_Message rcsm;
799 memset(&rcsm, 0, sizeof(rcsm));
801 status = p.readInt32(&t);
802 rcsm.uTeleserviceID = (int) t;
804 status = p.read(&ut,sizeof(ut));
805 rcsm.bIsServicePresent = (uint8_t) ut;
807 status = p.readInt32(&t);
808 rcsm.uServicecategory = (int) t;
810 status = p.readInt32(&t);
811 rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) t;
813 status = p.readInt32(&t);
814 rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) t;
816 status = p.readInt32(&t);
817 rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) t;
819 status = p.readInt32(&t);
820 rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) t;
822 status = p.read(&ut,sizeof(ut));
823 rcsm.sAddress.number_of_digits= (uint8_t) ut;
825 digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
826 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
827 status = p.read(&ut,sizeof(ut));
828 rcsm.sAddress.digits[digitCount] = (uint8_t) ut;
831 status = p.readInt32(&t);
832 rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) t;
834 status = p.read(&ut,sizeof(ut));
835 rcsm.sSubAddress.odd = (uint8_t) ut;
837 status = p.read(&ut,sizeof(ut));
838 rcsm.sSubAddress.number_of_digits = (uint8_t) ut;
840 digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
841 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
842 status = p.read(&ut,sizeof(ut));
843 rcsm.sSubAddress.digits[digitCount] = (uint8_t) ut;
846 status = p.readInt32(&t);
847 rcsm.uBearerDataLen = (int) t;
849 digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
850 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
851 status = p.read(&ut, sizeof(ut));
852 rcsm.aBearerData[digitCount] = (uint8_t) ut;
855 if (status != NO_ERROR) {
860 appendPrintBuf("%suTeleserviceID=%d, bIsServicePresent=%d, uServicecategory=%d, \
861 sAddress.digit_mode=%d, sAddress.Number_mode=%d, sAddress.number_type=%d, ",
862 printBuf, rcsm.uTeleserviceID,rcsm.bIsServicePresent,rcsm.uServicecategory,
863 rcsm.sAddress.digit_mode, rcsm.sAddress.number_mode,rcsm.sAddress.number_type);
866 printRequest(pRI->token, pRI->pCI->requestNumber);
868 s_callbacks.onRequest(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm),pRI);
871 memset(&rcsm, 0, sizeof(rcsm));
877 invalidCommandBlock(pRI);
882 dispatchCdmaSmsAck(Parcel &p, RequestInfo *pRI) {
883 RIL_CDMA_SMS_Ack rcsa;
888 memset(&rcsa, 0, sizeof(rcsa));
890 status = p.readInt32(&t);
891 rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) t;
893 status = p.readInt32(&t);
894 rcsa.uSMSCauseCode = (int) t;
896 if (status != NO_ERROR) {
901 appendPrintBuf("%suErrorClass=%d, uTLStatus=%d, ",
902 printBuf, rcsa.uErrorClass, rcsa.uSMSCauseCode);
905 printRequest(pRI->token, pRI->pCI->requestNumber);
907 s_callbacks.onRequest(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa),pRI);
910 memset(&rcsa, 0, sizeof(rcsa));
916 invalidCommandBlock(pRI);
921 dispatchBrSmsCnf(Parcel &p, RequestInfo *pRI) {
922 RIL_BroadcastSMSConfig rbsc;
928 memset(&rbsc, 0, sizeof(rbsc));
930 status = p.readInt32(&t);
933 status = p.readInt32(&t);
934 rbsc.entries->uFromServiceID = (int) t;
936 status = p.readInt32(&t);
937 rbsc.entries->uToserviceID = (int) t;
939 //usage of read function on assumption that it reads any length given as 2nd argument
940 status = p.read(&ut,sizeof(ut));
941 rbsc.entries->bSelected = (uint8_t) ut;
943 if (status != NO_ERROR) {
948 appendPrintBuf("%ssize=%d, entries.uFromServiceID=%d, \
949 entries.uToserviceID=%d, entries.bSelected =%d, ", printBuf,
950 rbsc.size,rbsc.entries->uFromServiceID, rbsc.entries->uToserviceID,
951 rbsc.entries->bSelected);
954 printRequest(pRI->token, pRI->pCI->requestNumber);
956 s_callbacks.onRequest(pRI->pCI->requestNumber, &rbsc, sizeof(rbsc),pRI);
959 memset(&rbsc, 0, sizeof(rbsc));
965 invalidCommandBlock(pRI);
971 dispatchCdmaBrSmsCnf(Parcel &p, RequestInfo *pRI) {
972 RIL_CDMA_BroadcastSMSConfig rcbsc;
978 status = p.readInt32(&t);
979 rcbsc.size = (int) t;
981 if (rcbsc.size != 0) {
982 RIL_CDMA_BroadcastServiceInfo cdmaBsi[rcbsc.size];
983 for (int i = 0 ; i < rcbsc.size ; i++ ) {
984 status = p.readInt32(&t);
985 cdmaBsi[i].uServiceCategory = (int) t;
987 status = p.readInt32(&t);
988 cdmaBsi[i].uLanguage = (int) t;
990 status = p.readInt32(&t);
991 cdmaBsi[i].bSelected = (uint8_t) t;
994 appendPrintBuf("%sentries.uServicecategory=%d, entries.uLanguage =%d, \
995 entries.bSelected =%d, ", printBuf, cdmaBsi[i].uServiceCategory,
996 cdmaBsi[i].uLanguage, cdmaBsi[i].bSelected);
999 rcbsc.entries = (RIL_CDMA_BroadcastServiceInfo *)calloc(rcbsc.size,
1000 sizeof(RIL_CDMA_BroadcastServiceInfo));
1001 memcpy(rcbsc.entries, cdmaBsi, (sizeof(RIL_CDMA_BroadcastServiceInfo) * rcbsc.size));
1003 rcbsc.entries = NULL;
1006 if (status != NO_ERROR) {
1010 s_callbacks.onRequest(pRI->pCI->requestNumber,
1012 (sizeof(RIL_CDMA_BroadcastServiceInfo) * rcbsc.size) + sizeof(int),
1016 memset(&rcbsc, 0, sizeof(rcbsc));
1022 invalidCommandBlock(pRI);
1027 static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI) {
1028 RIL_CDMA_SMS_WriteArgs rcsw;
1035 memset(&rcsw, 0, sizeof(rcsw));
1037 status = p.readInt32(&t);
1040 status = p.readInt32(&t);
1041 rcsw.message.uTeleserviceID = (int) t;
1043 status = p.read(&uct,sizeof(uct));
1044 rcsw.message.bIsServicePresent = (uint8_t) uct;
1046 status = p.readInt32(&t);
1047 rcsw.message.uServicecategory = (int) t;
1049 status = p.readInt32(&t);
1050 rcsw.message.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) t;
1052 status = p.readInt32(&t);
1053 rcsw.message.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) t;
1055 status = p.readInt32(&t);
1056 rcsw.message.sAddress.number_type = (RIL_CDMA_SMS_NumberType) t;
1058 status = p.readInt32(&t);
1059 rcsw.message.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) t;
1061 status = p.read(&uct,sizeof(uct));
1062 rcsw.message.sAddress.number_of_digits = (uint8_t) uct;
1064 for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_ADDRESS_MAX; digitCount ++) {
1065 status = p.read(&uct,sizeof(uct));
1066 rcsw.message.sAddress.digits[digitCount] = (uint8_t) uct;
1069 status = p.readInt32(&t);
1070 rcsw.message.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) t;
1072 status = p.read(&uct,sizeof(uct));
1073 rcsw.message.sSubAddress.odd = (uint8_t) uct;
1075 status = p.read(&uct,sizeof(uct));
1076 rcsw.message.sSubAddress.number_of_digits = (uint8_t) uct;
1078 for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_SUBADDRESS_MAX; digitCount ++) {
1079 status = p.read(&uct,sizeof(uct));
1080 rcsw.message.sSubAddress.digits[digitCount] = (uint8_t) uct;
1083 status = p.readInt32(&t);
1084 rcsw.message.uBearerDataLen = (int) t;
1086 for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_BEARER_DATA_MAX; digitCount ++) {
1087 status = p.read(&uct, sizeof(uct));
1088 rcsw.message.aBearerData[digitCount] = (uint8_t) uct;
1091 if (status != NO_ERROR) {
1096 appendPrintBuf("%sstatus=%d, message.uTeleserviceID=%d, message.bIsServicePresent=%d, \
1097 message.uServicecategory=%d, message.sAddress.digit_mode=%d, \
1098 message.sAddress.number_mode=%d, \
1099 message.sAddress.number_type=%d, ",
1100 printBuf, rcsw.status, rcsw.message.uTeleserviceID, rcsw.message.bIsServicePresent,
1101 rcsw.message.uServicecategory, rcsw.message.sAddress.digit_mode,
1102 rcsw.message.sAddress.number_mode,
1103 rcsw.message.sAddress.number_type);
1106 printRequest(pRI->token, pRI->pCI->requestNumber);
1108 s_callbacks.onRequest(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw),pRI);
1111 memset(&rcsw, 0, sizeof(rcsw));
1117 invalidCommandBlock(pRI);
1123 blockingWrite(int fd, const void *buffer, size_t len) {
1124 size_t writeOffset = 0;
1125 const uint8_t *toWrite;
1127 toWrite = (const uint8_t *)buffer;
1129 while (writeOffset < len) {
1132 written = write (fd, toWrite + writeOffset,
1134 } while (written < 0 && errno == EINTR);
1137 writeOffset += written;
1138 } else { // written < 0
1139 LOGE ("RIL Response: unexpected error on write errno:%d", errno);
1149 sendResponseRaw (const void *data, size_t dataSize) {
1150 int fd = s_fdCommand;
1154 if (s_fdCommand < 0) {
1158 if (dataSize > MAX_COMMAND_BYTES) {
1159 LOGE("RIL: packet larger than %u (%u)",
1160 MAX_COMMAND_BYTES, (unsigned int )dataSize);
1166 // FIXME is blocking here ok? issue #550970
1168 pthread_mutex_lock(&s_writeMutex);
1170 header = htonl(dataSize);
1172 ret = blockingWrite(fd, (void *)&header, sizeof(header));
1178 blockingWrite(fd, data, dataSize);
1184 pthread_mutex_unlock(&s_writeMutex);
1190 sendResponse (Parcel &p) {
1192 return sendResponseRaw(p.data(), p.dataSize());
1195 /** response is an int* pointing to an array of ints*/
1198 responseInts(Parcel &p, void *response, size_t responselen) {
1201 if (response == NULL && responselen != 0) {
1202 LOGE("invalid response: NULL");
1203 return RIL_ERRNO_INVALID_RESPONSE;
1205 if (responselen % sizeof(int) != 0) {
1206 LOGE("invalid response length %d expected multiple of %d\n",
1207 (int)responselen, (int)sizeof(int));
1208 return RIL_ERRNO_INVALID_RESPONSE;
1211 int *p_int = (int *) response;
1213 numInts = responselen / sizeof(int *);
1214 p.writeInt32 (numInts);
1218 for (int i = 0 ; i < numInts ; i++) {
1219 appendPrintBuf("%s%d,", printBuf, p_int[i]);
1220 p.writeInt32(p_int[i]);
1228 /** response is a char **, pointing to an array of char *'s */
1229 static int responseStrings(Parcel &p, void *response, size_t responselen) {
1232 if (response == NULL && responselen != 0) {
1233 LOGE("invalid response: NULL");
1234 return RIL_ERRNO_INVALID_RESPONSE;
1236 if (responselen % sizeof(char *) != 0) {
1237 LOGE("invalid response length %d expected multiple of %d\n",
1238 (int)responselen, (int)sizeof(char *));
1239 return RIL_ERRNO_INVALID_RESPONSE;
1242 if (response == NULL) {
1245 char **p_cur = (char **) response;
1247 numStrings = responselen / sizeof(char *);
1248 p.writeInt32 (numStrings);
1252 for (int i = 0 ; i < numStrings ; i++) {
1253 appendPrintBuf("%s%s,", printBuf, (char*)p_cur[i]);
1254 writeStringToParcel (p, p_cur[i]);
1264 * NULL strings are accepted
1265 * FIXME currently ignores responselen
1267 static int responseString(Parcel &p, void *response, size_t responselen) {
1268 /* one string only */
1270 appendPrintBuf("%s%s", printBuf, (char*)response);
1273 writeStringToParcel(p, (const char *)response);
1278 static int responseVoid(Parcel &p, void *response, size_t responselen) {
1284 static int responseCallList(Parcel &p, void *response, size_t responselen) {
1287 if (response == NULL && responselen != 0) {
1288 LOGE("invalid response: NULL");
1289 return RIL_ERRNO_INVALID_RESPONSE;
1292 if (responselen % sizeof (RIL_Call *) != 0) {
1293 LOGE("invalid response length %d expected multiple of %d\n",
1294 (int)responselen, (int)sizeof (RIL_Call *));
1295 return RIL_ERRNO_INVALID_RESPONSE;
1299 /* number of call info's */
1300 num = responselen / sizeof(RIL_Call *);
1303 for (int i = 0 ; i < num ; i++) {
1304 /* NEWRIL:TODO Remove this conditional and the else clause when we have the new ril */
1306 LOGD("Compilied for NEWRIL"); // NEWRIL:TODO remove when we have the new ril
1307 RIL_Call *p_cur = ((RIL_Call **) response)[i];
1308 /* each call info */
1309 p.writeInt32(p_cur->state);
1310 p.writeInt32(p_cur->index);
1311 p.writeInt32(p_cur->toa);
1312 p.writeInt32(p_cur->isMpty);
1313 p.writeInt32(p_cur->isMT);
1314 p.writeInt32(p_cur->als);
1315 p.writeInt32(p_cur->isVoice);
1316 p.writeInt32(p_cur->isVoicePrivacy);
1317 writeStringToParcel(p, p_cur->number);
1318 p.writeInt32(p_cur->numberPresentation);
1319 writeStringToParcel(p, p_cur->name);
1320 p.writeInt32(p_cur->namePresentation);
1321 appendPrintBuf("%s[id=%d,%s,toa=%d,",
1324 callStateToString(p_cur->state),
1326 appendPrintBuf("%s%s,%s,als=%d,%s,%s,",
1328 (p_cur->isMpty)?"conf":"norm",
1329 (p_cur->isMT)?"mt":"mo",
1331 (p_cur->isVoice)?"voc":"nonvoc",
1332 (p_cur->isVoicePrivacy)?"evp":"noevp");
1333 appendPrintBuf("%s%s,cli=%d,name='%s',%d]",
1336 p_cur->numberPresentation,
1338 p_cur->namePresentation);
1341 RIL_CallOld *p_cur = ((RIL_CallOld **) response)[i];
1342 /* each call info */
1343 p.writeInt32(p_cur->state);
1344 p.writeInt32(p_cur->index);
1345 p.writeInt32(p_cur->toa);
1346 p.writeInt32(p_cur->isMpty);
1347 p.writeInt32(p_cur->isMT);
1348 p.writeInt32(p_cur->als);
1349 p.writeInt32(p_cur->isVoice);
1350 p.writeInt32(0); // p_cur->isVoicePrivacy);
1351 writeStringToParcel (p, p_cur->number);
1352 p.writeInt32(p_cur->numberPresentation);
1353 writeStringToParcel (p, "a-person");
1354 p.writeInt32(2); // p_cur->namePresentation);
1355 appendPrintBuf("%s[id=%d,%s,toa=%d,",
1358 callStateToString(p_cur->state),
1360 appendPrintBuf("%s%s,%s,als=%d,%s,%s,",
1362 (p_cur->isMpty)?"conf":"norm",
1363 (p_cur->isMT)?"mt":"mo",
1365 (p_cur->isVoice)?"voc":"nonvoc");
1366 appendPrintBuf("%s%s,cli=%d]",
1369 p_cur->numberPresentation);
1378 static int responseSMS(Parcel &p, void *response, size_t responselen) {
1379 if (response == NULL) {
1380 LOGE("invalid response: NULL");
1381 return RIL_ERRNO_INVALID_RESPONSE;
1384 if (responselen != sizeof (RIL_SMS_Response) ) {
1385 LOGE("invalid response length %d expected %d",
1386 (int)responselen, (int)sizeof (RIL_SMS_Response));
1387 return RIL_ERRNO_INVALID_RESPONSE;
1390 RIL_SMS_Response *p_cur = (RIL_SMS_Response *) response;
1392 p.writeInt32(p_cur->messageRef);
1393 writeStringToParcel(p, p_cur->ackPDU);
1396 appendPrintBuf("%s%d,%s", printBuf, p_cur->messageRef,
1397 (char*)p_cur->ackPDU);
1403 static int responseDataCallList(Parcel &p, void *response, size_t responselen)
1405 if (response == NULL && responselen != 0) {
1406 LOGE("invalid response: NULL");
1407 return RIL_ERRNO_INVALID_RESPONSE;
1410 if (responselen % sizeof(RIL_Data_Call_Response) != 0) {
1411 LOGE("invalid response length %d expected multiple of %d",
1412 (int)responselen, (int)sizeof(RIL_Data_Call_Response));
1413 return RIL_ERRNO_INVALID_RESPONSE;
1416 int num = responselen / sizeof(RIL_Data_Call_Response);
1419 RIL_Data_Call_Response *p_cur = (RIL_Data_Call_Response *) response;
1422 for (i = 0; i < num; i++) {
1423 p.writeInt32(p_cur[i].cid);
1424 p.writeInt32(p_cur[i].active);
1425 writeStringToParcel(p, p_cur[i].type);
1426 writeStringToParcel(p, p_cur[i].apn);
1427 writeStringToParcel(p, p_cur[i].address);
1428 appendPrintBuf("%s[cid=%d,%s,%s,%s,%s],", printBuf,
1430 (p_cur[i].active==0)?"down":"up",
1431 (char*)p_cur[i].type,
1432 (char*)p_cur[i].apn,
1433 (char*)p_cur[i].address);
1441 static int responseRaw(Parcel &p, void *response, size_t responselen) {
1442 if (response == NULL && responselen != 0) {
1443 LOGE("invalid response: NULL with responselen != 0");
1444 return RIL_ERRNO_INVALID_RESPONSE;
1447 // The java code reads -1 size as null byte array
1448 if (response == NULL) {
1451 p.writeInt32(responselen);
1452 p.write(response, responselen);
1459 static int responseSIM_IO(Parcel &p, void *response, size_t responselen) {
1460 if (response == NULL) {
1461 LOGE("invalid response: NULL");
1462 return RIL_ERRNO_INVALID_RESPONSE;
1465 if (responselen != sizeof (RIL_SIM_IO_Response) ) {
1466 LOGE("invalid response length was %d expected %d",
1467 (int)responselen, (int)sizeof (RIL_SIM_IO_Response));
1468 return RIL_ERRNO_INVALID_RESPONSE;
1471 RIL_SIM_IO_Response *p_cur = (RIL_SIM_IO_Response *) response;
1472 p.writeInt32(p_cur->sw1);
1473 p.writeInt32(p_cur->sw2);
1474 writeStringToParcel(p, p_cur->simResponse);
1477 appendPrintBuf("%ssw1=0x%X,sw2=0x%X,%s", printBuf, p_cur->sw1, p_cur->sw2,
1478 (char*)p_cur->simResponse);
1485 static int responseCallForwards(Parcel &p, void *response, size_t responselen) {
1488 if (response == NULL && responselen != 0) {
1489 LOGE("invalid response: NULL");
1490 return RIL_ERRNO_INVALID_RESPONSE;
1493 if (responselen % sizeof(RIL_CallForwardInfo *) != 0) {
1494 LOGE("invalid response length %d expected multiple of %d",
1495 (int)responselen, (int)sizeof(RIL_CallForwardInfo *));
1496 return RIL_ERRNO_INVALID_RESPONSE;
1499 /* number of call info's */
1500 num = responselen / sizeof(RIL_CallForwardInfo *);
1504 for (int i = 0 ; i < num ; i++) {
1505 RIL_CallForwardInfo *p_cur = ((RIL_CallForwardInfo **) response)[i];
1507 p.writeInt32(p_cur->status);
1508 p.writeInt32(p_cur->reason);
1509 p.writeInt32(p_cur->serviceClass);
1510 p.writeInt32(p_cur->toa);
1511 writeStringToParcel(p, p_cur->number);
1512 p.writeInt32(p_cur->timeSeconds);
1513 appendPrintBuf("%s[%s,reason=%d,cls=%d,toa=%d,%s,tout=%d],", printBuf,
1514 (p_cur->status==1)?"enable":"disable",
1515 p_cur->reason, p_cur->serviceClass, p_cur->toa,
1516 (char*)p_cur->number,
1517 p_cur->timeSeconds);
1525 static int responseSsn(Parcel &p, void *response, size_t responselen) {
1526 if (response == NULL) {
1527 LOGE("invalid response: NULL");
1528 return RIL_ERRNO_INVALID_RESPONSE;
1531 if (responselen != sizeof(RIL_SuppSvcNotification)) {
1532 LOGE("invalid response length was %d expected %d",
1533 (int)responselen, (int)sizeof (RIL_SuppSvcNotification));
1534 return RIL_ERRNO_INVALID_RESPONSE;
1537 RIL_SuppSvcNotification *p_cur = (RIL_SuppSvcNotification *) response;
1538 p.writeInt32(p_cur->notificationType);
1539 p.writeInt32(p_cur->code);
1540 p.writeInt32(p_cur->index);
1541 p.writeInt32(p_cur->type);
1542 writeStringToParcel(p, p_cur->number);
1545 appendPrintBuf("%s%s,code=%d,id=%d,type=%d,%s", printBuf,
1546 (p_cur->notificationType==0)?"mo":"mt",
1547 p_cur->code, p_cur->index, p_cur->type,
1548 (char*)p_cur->number);
1554 static int responseCellList(Parcel &p, void *response, size_t responselen) {
1557 if (response == NULL && responselen != 0) {
1558 LOGE("invalid response: NULL");
1559 return RIL_ERRNO_INVALID_RESPONSE;
1562 if (responselen % sizeof (RIL_NeighboringCell *) != 0) {
1563 LOGE("invalid response length %d expected multiple of %d\n",
1564 (int)responselen, (int)sizeof (RIL_NeighboringCell *));
1565 return RIL_ERRNO_INVALID_RESPONSE;
1569 /* number of records */
1570 num = responselen / sizeof(RIL_NeighboringCell *);
1573 for (int i = 0 ; i < num ; i++) {
1574 RIL_NeighboringCell *p_cur = ((RIL_NeighboringCell **) response)[i];
1576 p.writeInt32(p_cur->rssi);
1577 writeStringToParcel (p, p_cur->cid);
1579 appendPrintBuf("%s[cid=%s,rssi=%d],", printBuf,
1580 p_cur->cid, p_cur->rssi);
1589 * Marshall the signalInfoRecord into the parcel if it exists.
1591 static void marshallSignalInfoRecord(Parcel &p, RIL_CDMA_SignalInfoRecord &p_signalInfoRecord) {
1592 p.writeInt32(p_signalInfoRecord.isPresent);
1593 p.writeInt32(p_signalInfoRecord.signalType);
1594 p.writeInt32(p_signalInfoRecord.alertPitch);
1595 p.writeInt32(p_signalInfoRecord.signal);
1598 static int responseCdmaInformationRecords(Parcel &p,void *response, size_t responselen) {
1603 if (response == NULL && responselen != 0) {
1604 LOGE("invalid response: NULL");
1605 return RIL_ERRNO_INVALID_RESPONSE;
1608 if (responselen != sizeof(RIL_CDMA_InformationRecords)) {
1609 LOGE("invalid response length %d expected %d\n",
1610 (int)responselen, (int)sizeof (RIL_CDMA_InformationRecords));
1611 return RIL_ERRNO_INVALID_RESPONSE;
1615 /* TODO(Teleca): Wink believes this should be deleted? */
1616 // num = responselen / sizeof(RIL_CDMA_InformationRecords *);
1617 // p.writeInt32(num);
1619 RIL_CDMA_InformationRecords *p_cur = ((RIL_CDMA_InformationRecords *) response);
1621 /* Number of records */
1622 p.writeInt32(p_cur->numberOfInfoRecs);
1626 digitLimit = MIN((p_cur->numberOfInfoRecs),RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
1627 for (digitCount = 0 ; digitCount < digitLimit; digitCount ++) {
1628 switch(p_cur->infoRec[digitCount].name){
1629 case RIL_CDMA_DISPLAY_INFO_REC:
1630 p.writeInt32(p_cur->infoRec[digitCount].rec.display.alpha_len);
1631 for(int i =0;i<(int)(p_cur->infoRec[digitCount].rec.display.alpha_len);i++){
1632 p.writeInt32(p_cur->infoRec[digitCount].rec.display.alpha_buf[i]);
1634 appendPrintBuf("%s[rec.display.alpha_len%c, rec.display.alpha_buf%s],",
1636 p_cur->infoRec[digitCount].rec.display.alpha_len,
1637 p_cur->infoRec[digitCount].rec.display.alpha_buf);
1639 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
1640 p.writeInt32(p_cur->infoRec[digitCount].rec.number.len);
1641 for(int i =0;i<(int)(p_cur->infoRec[digitCount].rec.number.len);i++){
1642 p.writeInt32(p_cur->infoRec[digitCount].rec.number.buf[i]);
1644 p.writeInt32(p_cur->infoRec[digitCount].rec.number.number_type);
1645 p.writeInt32(p_cur->infoRec[digitCount].rec.number.number_plan);
1646 p.writeInt32(p_cur->infoRec[digitCount].rec.number.pi);
1647 p.writeInt32(p_cur->infoRec[digitCount].rec.number.si);
1648 appendPrintBuf("%s[len=%c,buf=%s,number_type=%c,number_plan=%c,",
1650 p_cur->infoRec[digitCount].rec.number.len,
1651 p_cur->infoRec[digitCount].rec.number.buf,
1652 p_cur->infoRec[digitCount].rec.number.number_type,
1653 p_cur->infoRec[digitCount].rec.number.number_plan);
1654 appendPrintBuf("%spi=%c,si=%c]",
1656 p_cur->infoRec[digitCount].rec.number.pi,
1657 p_cur->infoRec[digitCount].rec.number.si);
1659 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
1660 p.writeInt32(p_cur->infoRec[digitCount].rec.number.len);
1661 for (int i =0;i<(int)(p_cur->infoRec[digitCount].rec.number.len);i++) {
1662 p.writeInt32(p_cur->infoRec[digitCount].rec.number.buf[i]);
1664 p.writeInt32(p_cur->infoRec[digitCount].rec.number.number_type);
1665 p.writeInt32(p_cur->infoRec[digitCount].rec.number.number_plan);
1666 p.writeInt32(p_cur->infoRec[digitCount].rec.number.pi);
1667 p.writeInt32(p_cur->infoRec[digitCount].rec.number.si);
1668 appendPrintBuf("%s[len=%c,buf=%s,number_type=%c,number_plan=%c,",
1670 p_cur->infoRec[digitCount].rec.number.len,
1671 p_cur->infoRec[digitCount].rec.number.buf,
1672 p_cur->infoRec[digitCount].rec.number.number_type,
1673 p_cur->infoRec[digitCount].rec.number.number_plan);
1674 appendPrintBuf("%spi=%c,si=%c]",
1676 p_cur->infoRec[digitCount].rec.number.pi,
1677 p_cur->infoRec[digitCount].rec.number.si);
1679 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC:
1680 p.writeInt32(p_cur->infoRec[digitCount].rec.number.len);
1681 for(int i =0;i<(int)(p_cur->infoRec[digitCount].rec.number.len);i++){
1682 p.writeInt32(p_cur->infoRec[digitCount].rec.number.buf[i]);
1684 p.writeInt32(p_cur->infoRec[digitCount].rec.number.number_type);
1685 p.writeInt32(p_cur->infoRec[digitCount].rec.number.number_plan);
1686 p.writeInt32(p_cur->infoRec[digitCount].rec.number.pi);
1687 p.writeInt32(p_cur->infoRec[digitCount].rec.number.si);
1688 appendPrintBuf("%s[len=%c,buf=%s,number_type=%c,number_plan=%c,",
1690 p_cur->infoRec[digitCount].rec.number.len,
1691 p_cur->infoRec[digitCount].rec.number.buf,
1692 p_cur->infoRec[digitCount].rec.number.number_type,
1693 p_cur->infoRec[digitCount].rec.number.number_plan);
1694 appendPrintBuf("%spi=%c,si=%c]",
1696 p_cur->infoRec[digitCount].rec.number.pi,
1697 p_cur->infoRec[digitCount].rec.number.si);
1699 case RIL_CDMA_SIGNAL_INFO_REC:
1700 marshallSignalInfoRecord(p, p_cur->infoRec[digitCount].rec.signal);
1701 appendPrintBuf("%s[isPresent=%c,signalType=%c,alertPitch=%c,signal=%c]",
1703 p_cur->infoRec[digitCount].rec.signal.isPresent,
1704 p_cur->infoRec[digitCount].rec.signal.signalType,
1705 p_cur->infoRec[digitCount].rec.signal.alertPitch,
1706 p_cur->infoRec[digitCount].rec.signal.signal);
1708 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC:
1709 p.writeInt32(p_cur->infoRec[digitCount].rec.redir.redirectingNumber.len);
1711 i<(int)(p_cur->infoRec[digitCount].rec.redir.redirectingNumber.len);i++){
1712 p.writeInt32(p_cur->infoRec[digitCount].rec.redir.redirectingNumber.buf[i]);
1714 p.writeInt32(p_cur->infoRec[digitCount].rec.redir.redirectingNumber.number_type);
1715 p.writeInt32(p_cur->infoRec[digitCount].rec.redir.redirectingNumber.number_plan);
1716 p.writeInt32(p_cur->infoRec[digitCount].rec.redir.redirectingNumber.pi);
1717 p.writeInt32(p_cur->infoRec[digitCount].rec.redir.redirectingNumber.si);
1718 p.writeInt32(p_cur->infoRec[digitCount].rec.redir.redirectingReason);
1719 appendPrintBuf("%s[len=%c,buf=%s,number_type=%c,number_plan=%c,",
1721 p_cur->infoRec[digitCount].rec.number.len,
1722 p_cur->infoRec[digitCount].rec.number.buf,
1723 p_cur->infoRec[digitCount].rec.number.number_type,
1724 p_cur->infoRec[digitCount].rec.number.number_plan);
1725 appendPrintBuf("%spi=%c,si=%c]",
1727 p_cur->infoRec[digitCount].rec.number.pi,
1728 p_cur->infoRec[digitCount].rec.number.si);
1730 case RIL_CDMA_LINE_CONTROL_INFO_REC:
1731 p.writeInt32(p_cur->infoRec[digitCount].rec.lineCtrl.lineCtrlPolarityIncluded);
1732 p.writeInt32(p_cur->infoRec[digitCount].rec.lineCtrl.lineCtrlToggle);
1733 p.writeInt32(p_cur->infoRec[digitCount].rec.lineCtrl.lineCtrlReverse);
1734 p.writeInt32( p_cur->infoRec[digitCount].rec.lineCtrl.lineCtrlPowerDenial);
1735 appendPrintBuf("%s[PolarityIncluded=%c,CtrlToggle=%c,CtrlReverse=%c,\
1736 CtrlPowerDenial=%c]",
1738 p_cur->infoRec[digitCount].rec.lineCtrl.lineCtrlPolarityIncluded,
1739 p_cur->infoRec[digitCount].rec.lineCtrl.lineCtrlToggle,
1740 p_cur->infoRec[digitCount].rec.lineCtrl.lineCtrlReverse,
1741 p_cur->infoRec[digitCount].rec.lineCtrl.lineCtrlPowerDenial);
1743 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC:
1745 case RIL_CDMA_T53_CLIR_INFO_REC:
1746 p.writeInt32(p_cur->infoRec[digitCount].rec.clir.cause);
1747 appendPrintBuf("%s[cause=%c]",printBuf,p_cur->infoRec[digitCount].rec.clir.cause);
1750 case RIL_CDMA_T53_RELEASE_INFO_REC:
1752 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC:
1753 p.writeInt32(p_cur->infoRec[digitCount].rec.audioCtrl.upLink);
1754 p.writeInt32(p_cur->infoRec[digitCount].rec.audioCtrl.downLink);
1755 appendPrintBuf("%s[uplink=%c,downlink=%c]",
1756 printBuf,p_cur->infoRec[digitCount].rec.audioCtrl.upLink,
1757 p_cur->infoRec[digitCount].rec.audioCtrl.downLink);
1760 LOGE ("Invalid request");
1771 static int responseRilSignalStrength(Parcel &p, void *response, size_t responselen) {
1772 if (response == NULL && responselen != 0) {
1773 LOGE("invalid response: NULL");
1774 return RIL_ERRNO_INVALID_RESPONSE;
1777 if ((responselen != sizeof (RIL_SignalStrength))
1778 && (responselen % sizeof (void *) == 0)) {
1779 // Old RIL deprecated
1780 RIL_GW_SignalStrength *p_cur = ((RIL_GW_SignalStrength *) response);
1783 p.writeInt32(p_cur->signalStrength);
1784 p.writeInt32(p_cur->bitErrorRate);
1785 for (int i = 0; i < 5; i++) {
1788 } else if (responselen == sizeof (RIL_SignalStrength)) {
1790 RIL_SignalStrength *p_cur = ((RIL_SignalStrength *) response);
1793 p.writeInt32(p_cur->GW_SignalStrength.signalStrength);
1794 p.writeInt32(p_cur->GW_SignalStrength.bitErrorRate);
1795 p.writeInt32(p_cur->CDMA_SignalStrength.dbm);
1796 p.writeInt32(p_cur->CDMA_SignalStrength.ecio);
1797 p.writeInt32(p_cur->EVDO_SignalStrength.dbm);
1798 p.writeInt32(p_cur->EVDO_SignalStrength.ecio);
1799 p.writeInt32(p_cur->EVDO_SignalStrength.signalNoiseRatio);
1801 LOGE("invalid response length");
1802 return RIL_ERRNO_INVALID_RESPONSE;
1806 appendPrintBuf("%s[signalStrength=%d,bitErrorRate=%d,\
1807 CDMA_SignalStrength.dbm=%d,CDMA_SignalStrength.ecio=%d,\
1808 EVDO_SignalStrength.dbm =%d,EVDO_SignalStrength.ecio=%d,\
1809 EVDO_SignalStrength.signalNoiseRatio=%d]",
1811 p_cur->GW_SignalStrength.signalStrength,
1812 p_cur->GW_SignalStrength.bitErrorRate,
1813 p_cur->CDMA_SignalStrength.dbm,
1814 p_cur->CDMA_SignalStrength.ecio,
1815 p_cur->EVDO_SignalStrength.dbm,
1816 p_cur->EVDO_SignalStrength.ecio,
1817 p_cur->EVDO_SignalStrength.signalNoiseRatio);
1824 static int responseCallRing(Parcel &p, void *response, size_t responselen) {
1825 if ((response == NULL) || (responselen == 0)) {
1826 return responseVoid(p, response, responselen);
1828 return responseCdmaSignalInfoRecord(p, response, responselen);
1832 static int responseCdmaSignalInfoRecord(Parcel &p, void *response, size_t responselen) {
1833 if (response == NULL || responselen == 0) {
1834 LOGE("invalid response: NULL");
1835 return RIL_ERRNO_INVALID_RESPONSE;
1838 if (responselen != sizeof (RIL_CDMA_SignalInfoRecord)) {
1839 LOGE("invalid response length %d expected sizeof (RIL_CDMA_SignalInfoRecord) of %d\n",
1840 (int)responselen, (int)sizeof (RIL_CDMA_SignalInfoRecord));
1841 return RIL_ERRNO_INVALID_RESPONSE;
1846 RIL_CDMA_SignalInfoRecord *p_cur = ((RIL_CDMA_SignalInfoRecord *) response);
1847 marshallSignalInfoRecord(p, *p_cur);
1849 appendPrintBuf("%s[isPresent=%d,signalType=%d,alertPitch=%d\
1861 static int responseCdmaCallWaiting(Parcel &p,void *response, size_t responselen) {
1862 if (response == NULL && responselen != 0) {
1863 LOGE("invalid response: NULL");
1864 return RIL_ERRNO_INVALID_RESPONSE;
1867 if (responselen != sizeof(RIL_CDMA_CallWaiting)) {
1868 LOGE("invalid response length %d expected %d\n",
1869 (int)responselen, (int)sizeof(RIL_CDMA_CallWaiting));
1870 return RIL_ERRNO_INVALID_RESPONSE;
1874 RIL_CDMA_CallWaiting *p_cur = ((RIL_CDMA_CallWaiting *) response);
1876 writeStringToParcel (p, p_cur->number);
1877 p.writeInt32(p_cur->numberPresentation);
1878 writeStringToParcel (p, p_cur->name);
1879 marshallSignalInfoRecord(p, p_cur->signalInfoRecord);
1881 appendPrintBuf("%snumber=%s,numberPresentation=%d, name=%s,\
1882 signalInfoRecord[isPresent=%d,signalType=%d,alertPitch=%d\
1886 p_cur->numberPresentation,
1888 p_cur->signalInfoRecord.isPresent,
1889 p_cur->signalInfoRecord.signalType,
1890 p_cur->signalInfoRecord.alertPitch,
1891 p_cur->signalInfoRecord.signal);
1898 static void triggerEvLoop() {
1900 if (!pthread_equal(pthread_self(), s_tid_dispatch)) {
1901 /* trigger event loop to wakeup. No reason to do this,
1902 * if we're in the event loop thread */
1904 ret = write (s_fdWakeupWrite, " ", 1);
1905 } while (ret < 0 && errno == EINTR);
1909 static void rilEventAddWakeup(struct ril_event *ev) {
1914 static int responseSimStatus(Parcel &p, void *response, size_t responselen) {
1917 if (response == NULL && responselen != 0) {
1918 LOGE("invalid response: NULL");
1919 return RIL_ERRNO_INVALID_RESPONSE;
1922 if (responselen % sizeof (RIL_CardStatus *) != 0) {
1923 LOGE("invalid response length %d expected multiple of %d\n",
1924 (int)responselen, (int)sizeof (RIL_CardStatus *));
1925 return RIL_ERRNO_INVALID_RESPONSE;
1928 RIL_CardStatus *p_cur = ((RIL_CardStatus *) response);
1930 p.writeInt32(p_cur->card_state);
1931 p.writeInt32(p_cur->universal_pin_state);
1932 p.writeInt32(p_cur->gsm_umts_subscription_app_index);
1933 p.writeInt32(p_cur->cdma_subscription_app_index);
1934 p.writeInt32(p_cur->num_applications);
1937 for (i = 0; i < p_cur->num_applications; i++) {
1938 p.writeInt32(p_cur->applications[i].app_type);
1939 p.writeInt32(p_cur->applications[i].app_state);
1940 p.writeInt32(p_cur->applications[i].perso_substate);
1941 writeStringToParcel (p, (const char*)(p_cur->applications[i].aid_ptr));
1942 writeStringToParcel (p, (const char*)(p_cur->applications[i].app_label_ptr));
1943 p.writeInt32(p_cur->applications[i].pin1_replaced);
1944 p.writeInt32(p_cur->applications[i].pin1);
1945 p.writeInt32(p_cur->applications[i].pin2);
1946 appendPrintBuf("%s[app_type=%d,app_state=%d,perso_substate=%d,aid_ptr=%s,\
1947 app_label_ptr=%s,pin1_replaced=%d,pin1=%d,pin2=%d],",
1949 p_cur->applications[i].app_type,
1950 p_cur->applications[i].app_state,
1951 p_cur->applications[i].perso_substate,
1952 p_cur->applications[i].aid_ptr,
1953 p_cur->applications[i].app_label_ptr,
1954 p_cur->applications[i].pin1_replaced,
1955 p_cur->applications[i].pin1,
1956 p_cur->applications[i].pin2);
1963 static int responseBrSmsCnf(Parcel &p, void *response, size_t responselen) {
1966 if (response == NULL && responselen != 0) {
1967 LOGE("invalid response: NULL");
1968 return RIL_ERRNO_INVALID_RESPONSE;
1971 if (responselen % sizeof(RIL_BroadcastSMSConfig) != 0) {
1972 LOGE("invalid response length %d expected multiple of %d",
1973 (int)responselen, (int)sizeof(RIL_BroadcastSMSConfig));
1974 return RIL_ERRNO_INVALID_RESPONSE;
1977 /* number of call info's */
1978 num = responselen / sizeof(RIL_BroadcastSMSConfig *);
1981 RIL_BroadcastSMSConfig *p_cur = (RIL_BroadcastSMSConfig *) response;
1982 p.writeInt32(p_cur->size);
1983 p.writeInt32(p_cur->entries->uFromServiceID);
1984 p.writeInt32(p_cur->entries->uToserviceID);
1985 p.write(&(p_cur->entries->bSelected),sizeof(p_cur->entries->bSelected));
1988 appendPrintBuf("%s size=%d, entries.uFromServiceID=%d, \
1989 entries.uToserviceID=%d, entries.bSelected =%d, ",
1990 printBuf, p_cur->size,p_cur->entries->uFromServiceID,
1991 p_cur->entries->uToserviceID, p_cur->entries->bSelected);
1997 static int responseCdmaBrCnf(Parcel &p, void *response, size_t responselen) {
1998 int numServiceCategories;
2000 if (response == NULL && responselen != 0) {
2001 LOGE("invalid response: NULL");
2002 return RIL_ERRNO_INVALID_RESPONSE;
2005 if (responselen == 0) {
2006 LOGE("invalid response length %d expected >= of %d",
2007 (int)responselen, (int)sizeof(RIL_BroadcastSMSConfig));
2008 return RIL_ERRNO_INVALID_RESPONSE;
2011 RIL_CDMA_BroadcastSMSConfig *p_cur = (RIL_CDMA_BroadcastSMSConfig *) response;
2013 numServiceCategories = p_cur->size;
2014 p.writeInt32(p_cur->size);
2017 appendPrintBuf("%ssize=%d ", printBuf,p_cur->size);
2020 if (numServiceCategories != 0) {
2021 RIL_CDMA_BroadcastServiceInfo cdmaBsi[numServiceCategories];
2022 memcpy(cdmaBsi, p_cur->entries,
2023 sizeof(RIL_CDMA_BroadcastServiceInfo) * numServiceCategories);
2025 for (int i = 0 ; i < numServiceCategories ; i++ ) {
2026 p.writeInt32(cdmaBsi[i].uServiceCategory);
2027 p.writeInt32(cdmaBsi[i].uLanguage);
2028 p.writeInt32(cdmaBsi[i].bSelected);
2031 appendPrintBuf("%sentries[%d].uServicecategory=%d, entries[%d].uLanguage =%d, \
2032 entries[%d].bSelected =%d, ", printBuf, i, cdmaBsi[i].uServiceCategory, i,
2033 cdmaBsi[i].uLanguage, i, cdmaBsi[i].bSelected);
2043 static int responseCdmaSms(Parcel &p, void *response, size_t responselen) {
2050 LOGD("Inside responseCdmaSms");
2052 if (response == NULL && responselen != 0) {
2053 LOGE("invalid response: NULL");
2054 return RIL_ERRNO_INVALID_RESPONSE;
2057 if (responselen != sizeof(RIL_CDMA_SMS_Message)) {
2058 LOGE("invalid response length was %d expected %d",
2059 (int)responselen, (int)sizeof(RIL_CDMA_SMS_Message));
2060 return RIL_ERRNO_INVALID_RESPONSE;
2063 RIL_CDMA_SMS_Message *p_cur = (RIL_CDMA_SMS_Message *) response;
2064 p.writeInt32(p_cur->uTeleserviceID);
2065 p.write(&(p_cur->bIsServicePresent),sizeof(uct));
2066 p.writeInt32(p_cur->uServicecategory);
2067 p.writeInt32(p_cur->sAddress.digit_mode);
2068 p.writeInt32(p_cur->sAddress.number_mode);
2069 p.writeInt32(p_cur->sAddress.number_type);
2070 p.writeInt32(p_cur->sAddress.number_plan);
2071 p.write(&(p_cur->sAddress.number_of_digits), sizeof(uct));
2072 digitLimit= MIN((p_cur->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
2073 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
2074 p.write(&(p_cur->sAddress.digits[digitCount]),sizeof(uct));
2077 p.writeInt32(p_cur->sSubAddress.subaddressType);
2078 p.write(&(p_cur->sSubAddress.odd),sizeof(uct));
2079 p.write(&(p_cur->sSubAddress.number_of_digits),sizeof(uct));
2080 digitLimit= MIN((p_cur->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
2081 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
2082 p.write(&(p_cur->sSubAddress.digits[digitCount]),sizeof(uct));
2085 digitLimit= MIN((p_cur->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
2086 p.writeInt32(p_cur->uBearerDataLen);
2087 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
2088 p.write(&(p_cur->aBearerData[digitCount]), sizeof(uct));
2092 appendPrintBuf("%suTeleserviceID=%d, bIsServicePresent=%d, uServicecategory=%d, \
2093 sAddress.digit_mode=%d, sAddress.number_mode=%d, sAddress.number_type=%d, ",
2094 printBuf, p_cur->uTeleserviceID,p_cur->bIsServicePresent,p_cur->uServicecategory,
2095 p_cur->sAddress.digit_mode, p_cur->sAddress.number_mode,p_cur->sAddress.number_type);
2102 * A write on the wakeup fd is done just to pop us out of select()
2103 * We empty the buffer here and then ril_event will reset the timers on the
2106 static void processWakeupCallback(int fd, short flags, void *param) {
2110 LOGV("processWakeupCallback");
2112 /* empty our wakeup socket out */
2114 ret = read(s_fdWakeupRead, &buff, sizeof(buff));
2115 } while (ret > 0 || (ret < 0 && errno == EINTR));
2118 static void onCommandsSocketClosed() {
2122 /* mark pending requests as "cancelled" so we dont report responses */
2124 ret = pthread_mutex_lock(&s_pendingRequestsMutex);
2127 p_cur = s_pendingRequests;
2129 for (p_cur = s_pendingRequests
2131 ; p_cur = p_cur->p_next
2133 p_cur->cancelled = 1;
2136 ret = pthread_mutex_unlock(&s_pendingRequestsMutex);
2140 static void processCommandsCallback(int fd, short flags, void *param) {
2146 assert(fd == s_fdCommand);
2148 p_rs = (RecordStream *)param;
2151 /* loop until EAGAIN/EINTR, end of stream, or other error */
2152 ret = record_stream_get_next(p_rs, &p_record, &recordlen);
2154 if (ret == 0 && p_record == NULL) {
2157 } else if (ret < 0) {
2159 } else if (ret == 0) { /* && p_record != NULL */
2160 processCommandBuffer(p_record, recordlen);
2164 if (ret == 0 || !(errno == EAGAIN || errno == EINTR)) {
2165 /* fatal error or end-of-stream */
2167 LOGE("error on reading command socket errno:%d\n", errno);
2169 LOGW("EOS. Closing command socket.");
2175 ril_event_del(&s_commands_event);
2177 record_stream_free(p_rs);
2179 /* start listening for new connections again */
2180 rilEventAddWakeup(&s_listen_event);
2182 onCommandsSocketClosed();
2187 static void onNewCommandConnect() {
2188 // implicit radio state changed
2189 RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED,
2192 // Send last NITZ time data, in case it was missed
2193 if (s_lastNITZTimeData != NULL) {
2194 sendResponseRaw(s_lastNITZTimeData, s_lastNITZTimeDataSize);
2196 free(s_lastNITZTimeData);
2197 s_lastNITZTimeData = NULL;
2200 // Get version string
2201 if (s_callbacks.getVersion != NULL) {
2202 const char *version;
2203 version = s_callbacks.getVersion();
2204 LOGI("RIL Daemon version: %s\n", version);
2206 property_set(PROPERTY_RIL_IMPL, version);
2208 LOGI("RIL Daemon version: unavailable\n");
2209 property_set(PROPERTY_RIL_IMPL, "unavailable");
2214 static void listenCallback (int fd, short flags, void *param) {
2217 int is_phone_socket;
2220 struct sockaddr_un peeraddr;
2221 socklen_t socklen = sizeof (peeraddr);
2224 socklen_t szCreds = sizeof(creds);
2226 struct passwd *pwd = NULL;
2228 assert (s_fdCommand < 0);
2229 assert (fd == s_fdListen);
2231 s_fdCommand = accept(s_fdListen, (sockaddr *) &peeraddr, &socklen);
2233 if (s_fdCommand < 0 ) {
2234 LOGE("Error on accept() errno:%d", errno);
2235 /* start listening for new connections again */
2236 rilEventAddWakeup(&s_listen_event);
2240 /* check the credential of the other side and only accept socket from
2244 is_phone_socket = 0;
2246 err = getsockopt(s_fdCommand, SOL_SOCKET, SO_PEERCRED, &creds, &szCreds);
2248 if (err == 0 && szCreds > 0) {
2250 pwd = getpwuid(creds.uid);
2252 if (strcmp(pwd->pw_name, PHONE_PROCESS) == 0) {
2253 is_phone_socket = 1;
2255 LOGE("RILD can't accept socket from process %s", pwd->pw_name);
2258 LOGE("Error on getpwuid() errno: %d", errno);
2261 LOGD("Error on getsockopt() errno: %d", errno);
2264 if ( !is_phone_socket ) {
2265 LOGE("RILD must accept socket from %s", PHONE_PROCESS);
2270 onCommandsSocketClosed();
2272 /* start listening for new connections again */
2273 rilEventAddWakeup(&s_listen_event);
2278 ret = fcntl(s_fdCommand, F_SETFL, O_NONBLOCK);
2281 LOGE ("Error setting O_NONBLOCK errno:%d", errno);
2284 LOGI("libril: new connection");
2286 p_rs = record_stream_new(s_fdCommand, MAX_COMMAND_BYTES);
2288 ril_event_set (&s_commands_event, s_fdCommand, 1,
2289 processCommandsCallback, p_rs);
2291 rilEventAddWakeup (&s_commands_event);
2293 onNewCommandConnect();
2296 static void freeDebugCallbackArgs(int number, char **args) {
2297 for (int i = 0; i < number; i++) {
2298 if (args[i] != NULL) {
2305 static void debugCallback (int fd, short flags, void *param) {
2306 int acceptFD, option;
2307 struct sockaddr_un peeraddr;
2308 socklen_t socklen = sizeof (peeraddr);
2310 unsigned int qxdm_data[6];
2311 const char *deactData[1] = {"1"};
2314 int hangupData[1] = {1};
2318 acceptFD = accept (fd, (sockaddr *) &peeraddr, &socklen);
2321 LOGE ("error accepting on debug port: %d\n", errno);
2325 if (recv(acceptFD, &number, sizeof(int), 0) != sizeof(int)) {
2326 LOGE ("error reading on socket: number of Args: \n");
2329 args = (char **) malloc(sizeof(char*) * number);
2331 for (int i = 0; i < number; i++) {
2333 if (recv(acceptFD, &len, sizeof(int), 0) != sizeof(int)) {
2334 LOGE ("error reading on socket: Len of Args: \n");
2335 freeDebugCallbackArgs(i, args);
2339 args[i] = (char *) malloc((sizeof(char) * len) + 1);
2340 if (recv(acceptFD, args[i], sizeof(char) * len, 0)
2341 != (int)sizeof(char) * len) {
2342 LOGE ("error reading on socket: Args[%d] \n", i);
2343 freeDebugCallbackArgs(i, args);
2346 char * buf = args[i];
2350 switch (atoi(args[0])) {
2352 LOGI ("Connection on debug port: issuing reset.");
2353 issueLocalRequest(RIL_REQUEST_RESET_RADIO, NULL, 0);
2356 LOGI ("Connection on debug port: issuing radio power off.");
2358 issueLocalRequest(RIL_REQUEST_RADIO_POWER, &data, sizeof(int));
2364 LOGI ("Debug port: issuing unsolicited network change.");
2365 RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED,
2369 LOGI ("Debug port: QXDM log enable.");
2370 qxdm_data[0] = 65536;
2376 issueLocalRequest(RIL_REQUEST_OEM_HOOK_RAW, qxdm_data,
2380 LOGI ("Debug port: QXDM log disable.");
2381 qxdm_data[0] = 65536;
2387 issueLocalRequest(RIL_REQUEST_OEM_HOOK_RAW, qxdm_data,
2391 LOGI("Debug port: Radio On");
2393 issueLocalRequest(RIL_REQUEST_RADIO_POWER, &data, sizeof(int));
2395 // Set network selection automatic.
2396 issueLocalRequest(RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC, NULL, 0);
2399 LOGI("Debug port: Setup Data Call, Apn :%s\n", args[1]);
2400 actData[0] = args[1];
2401 issueLocalRequest(RIL_REQUEST_SETUP_DATA_CALL, &actData,
2405 LOGI("Debug port: Deactivate Data Call");
2406 issueLocalRequest(RIL_REQUEST_DEACTIVATE_DATA_CALL, &deactData,
2410 LOGI("Debug port: Dial Call");
2412 dialData.address = args[1];
2413 issueLocalRequest(RIL_REQUEST_DIAL, &dialData, sizeof(dialData));
2416 LOGI("Debug port: Answer Call");
2417 issueLocalRequest(RIL_REQUEST_ANSWER, NULL, 0);
2420 LOGI("Debug port: End Call");
2421 issueLocalRequest(RIL_REQUEST_HANGUP, &hangupData,
2422 sizeof(hangupData));
2425 LOGE ("Invalid request");
2428 freeDebugCallbackArgs(number, args);
2433 static void userTimerCallback (int fd, short flags, void *param) {
2434 UserCallbackInfo *p_info;
2436 p_info = (UserCallbackInfo *)param;
2438 p_info->p_callback(p_info->userParam);
2441 // FIXME generalize this...there should be a cancel mechanism
2442 if (s_last_wake_timeout_info != NULL && s_last_wake_timeout_info == p_info) {
2443 s_last_wake_timeout_info = NULL;
2451 eventLoop(void *param) {
2457 pthread_mutex_lock(&s_startupMutex);
2460 pthread_cond_broadcast(&s_startupCond);
2462 pthread_mutex_unlock(&s_startupMutex);
2464 ret = pipe(filedes);
2467 LOGE("Error in pipe() errno:%d", errno);
2471 s_fdWakeupRead = filedes[0];
2472 s_fdWakeupWrite = filedes[1];
2474 fcntl(s_fdWakeupRead, F_SETFL, O_NONBLOCK);
2476 ril_event_set (&s_wakeupfd_event, s_fdWakeupRead, true,
2477 processWakeupCallback, NULL);
2479 rilEventAddWakeup (&s_wakeupfd_event);
2481 // Only returns on error
2483 LOGE ("error in event_loop_base errno:%d", errno);
2489 RIL_startEventLoop(void) {
2491 pthread_attr_t attr;
2493 /* spin up eventLoop thread and wait for it to get started */
2495 pthread_mutex_lock(&s_startupMutex);
2497 pthread_attr_init (&attr);
2498 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
2499 ret = pthread_create(&s_tid_dispatch, &attr, eventLoop, NULL);
2501 while (s_started == 0) {
2502 pthread_cond_wait(&s_startupCond, &s_startupMutex);
2505 pthread_mutex_unlock(&s_startupMutex);
2508 LOGE("Failed to create dispatch thread errno:%d", errno);
2513 // Used for testing purpose only.
2514 extern "C" void RIL_setcallbacks (const RIL_RadioFunctions *callbacks) {
2515 memcpy(&s_callbacks, callbacks, sizeof (RIL_RadioFunctions));
2519 RIL_register (const RIL_RadioFunctions *callbacks) {
2523 if (callbacks == NULL
2524 || ! (callbacks->version == RIL_VERSION || callbacks->version == 1)
2527 "RIL_register: RIL_RadioFunctions * null or invalid version"
2528 " (expected %d)", RIL_VERSION);
2532 if (s_registerCalled > 0) {
2533 LOGE("RIL_register has been called more than once. "
2534 "Subsequent call ignored");
2538 memcpy(&s_callbacks, callbacks, sizeof (RIL_RadioFunctions));
2540 s_registerCalled = 1;
2542 // Little self-check
2544 for (int i = 0; i < (int)NUM_ELEMS(s_commands); i++) {
2545 assert(i == s_commands[i].requestNumber);
2548 for (int i = 0; i < (int)NUM_ELEMS(s_unsolResponses); i++) {
2549 assert(i + RIL_UNSOL_RESPONSE_BASE
2550 == s_unsolResponses[i].requestNumber);
2553 // New rild impl calls RIL_startEventLoop() first
2554 // old standalone impl wants it here.
2556 if (s_started == 0) {
2557 RIL_startEventLoop();
2560 // start listen socket
2563 ret = socket_local_server (SOCKET_NAME_RIL,
2564 ANDROID_SOCKET_NAMESPACE_ABSTRACT, SOCK_STREAM);
2567 LOGE("Unable to bind socket errno:%d", errno);
2573 s_fdListen = android_get_control_socket(SOCKET_NAME_RIL);
2574 if (s_fdListen < 0) {
2575 LOGE("Failed to get socket '" SOCKET_NAME_RIL "'");
2579 ret = listen(s_fdListen, 4);
2582 LOGE("Failed to listen on control socket '%d': %s",
2583 s_fdListen, strerror(errno));
2589 /* note: non-persistent so we can accept only one connection at a time */
2590 ril_event_set (&s_listen_event, s_fdListen, false,
2591 listenCallback, NULL);
2593 rilEventAddWakeup (&s_listen_event);
2596 // start debug interface socket
2598 s_fdDebug = android_get_control_socket(SOCKET_NAME_RIL_DEBUG);
2599 if (s_fdDebug < 0) {
2600 LOGE("Failed to get socket '" SOCKET_NAME_RIL_DEBUG "' errno:%d", errno);
2604 ret = listen(s_fdDebug, 4);
2607 LOGE("Failed to listen on ril debug socket '%d': %s",
2608 s_fdDebug, strerror(errno));
2612 ril_event_set (&s_debug_event, s_fdDebug, true,
2613 debugCallback, NULL);
2615 rilEventAddWakeup (&s_debug_event);
2621 checkAndDequeueRequestInfo(struct RequestInfo *pRI) {
2628 pthread_mutex_lock(&s_pendingRequestsMutex);
2630 for(RequestInfo **ppCur = &s_pendingRequests
2632 ; ppCur = &((*ppCur)->p_next)
2634 if (pRI == *ppCur) {
2637 *ppCur = (*ppCur)->p_next;
2642 pthread_mutex_unlock(&s_pendingRequestsMutex);
2649 RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responselen) {
2654 pRI = (RequestInfo *)t;
2656 if (!checkAndDequeueRequestInfo(pRI)) {
2657 LOGE ("RIL_onRequestComplete: invalid RIL_Token");
2661 if (pRI->local > 0) {
2662 // Locally issued command...void only!
2663 // response does not go back up the command socket
2664 LOGD("C[locl]< %s", requestToString(pRI->pCI->requestNumber));
2669 appendPrintBuf("[%04d]< %s",
2670 pRI->token, requestToString(pRI->pCI->requestNumber));
2672 if (pRI->cancelled == 0) {
2675 p.writeInt32 (RESPONSE_SOLICITED);
2676 p.writeInt32 (pRI->token);
2677 errorOffset = p.dataPosition();
2681 if (e == RIL_E_SUCCESS) {
2682 /* process response on success */
2683 ret = pRI->pCI->responseFunction(p, response, responselen);
2685 /* if an error occurred, rewind and mark it */
2687 p.setDataPosition(errorOffset);
2691 appendPrintBuf("%s returns %s", printBuf, failCauseToString(e));
2694 if (s_fdCommand < 0) {
2695 LOGD ("RIL onRequestComplete: Command channel closed");
2706 grabPartialWakeLock() {
2707 acquire_wake_lock(PARTIAL_WAKE_LOCK, ANDROID_WAKE_LOCK_NAME);
2712 release_wake_lock(ANDROID_WAKE_LOCK_NAME);
2716 * Timer callback to put us back to sleep before the default timeout
2719 wakeTimeoutCallback (void *param) {
2720 // We're using "param != NULL" as a cancellation mechanism
2721 if (param == NULL) {
2722 //LOGD("wakeTimeout: releasing wake lock");
2726 //LOGD("wakeTimeout: releasing wake lock CANCELLED");
2731 void RIL_onUnsolicitedResponse(int unsolResponse, void *data,
2734 int unsolResponseIndex;
2736 int64_t timeReceived = 0;
2737 bool shouldScheduleTimeout = false;
2739 if (s_registerCalled == 0) {
2740 // Ignore RIL_onUnsolicitedResponse before RIL_register
2741 LOGW("RIL_onUnsolicitedResponse called before RIL_register");
2745 unsolResponseIndex = unsolResponse - RIL_UNSOL_RESPONSE_BASE;
2747 if ((unsolResponseIndex < 0)
2748 || (unsolResponseIndex >= (int32_t)NUM_ELEMS(s_unsolResponses))) {
2749 LOGE("unsupported unsolicited response code %d", unsolResponse);
2753 // Grab a wake lock if needed for this reponse,
2754 // as we exit we'll either release it immediately
2755 // or set a timer to release it later.
2756 switch (s_unsolResponses[unsolResponseIndex].wakeType) {
2758 grabPartialWakeLock();
2759 shouldScheduleTimeout = true;
2764 // No wake lock is grabed so don't set timeout
2765 shouldScheduleTimeout = false;
2769 // Mark the time this was received, doing this
2770 // after grabing the wakelock incase getting
2771 // the elapsedRealTime might cause us to goto
2773 if (unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) {
2774 timeReceived = elapsedRealtime();
2777 appendPrintBuf("[UNSL]< %s", requestToString(unsolResponse));
2781 p.writeInt32 (RESPONSE_UNSOLICITED);
2782 p.writeInt32 (unsolResponse);
2784 ret = s_unsolResponses[unsolResponseIndex]
2785 .responseFunction(p, data, datalen);
2787 // Problem with the response. Don't continue;
2791 // some things get more payload
2792 switch(unsolResponse) {
2793 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED:
2794 p.writeInt32(s_callbacks.onStateRequest());
2795 appendPrintBuf("%s {%s}", printBuf,
2796 radioStateToString(s_callbacks.onStateRequest()));
2800 case RIL_UNSOL_NITZ_TIME_RECEIVED:
2801 // Store the time that this was received so the
2802 // handler of this message can account for
2803 // the time it takes to arrive and process. In
2804 // particular the system has been known to sleep
2805 // before this message can be processed.
2806 p.writeInt64(timeReceived);
2810 ret = sendResponse(p);
2811 if (ret != 0 && unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) {
2813 // Unfortunately, NITZ time is not poll/update like everything
2814 // else in the system. So, if the upstream client isn't connected,
2815 // keep a copy of the last NITZ response (with receive time noted
2816 // above) around so we can deliver it when it is connected
2818 if (s_lastNITZTimeData != NULL) {
2819 free (s_lastNITZTimeData);
2820 s_lastNITZTimeData = NULL;
2823 s_lastNITZTimeData = malloc(p.dataSize());
2824 s_lastNITZTimeDataSize = p.dataSize();
2825 memcpy(s_lastNITZTimeData, p.data(), p.dataSize());
2828 // For now, we automatically go back to sleep after TIMEVAL_WAKE_TIMEOUT
2829 // FIXME The java code should handshake here to release wake lock
2831 if (shouldScheduleTimeout) {
2832 // Cancel the previous request
2833 if (s_last_wake_timeout_info != NULL) {
2834 s_last_wake_timeout_info->userParam = (void *)1;
2837 s_last_wake_timeout_info
2838 = internalRequestTimedCallback(wakeTimeoutCallback, NULL,
2839 &TIMEVAL_WAKE_TIMEOUT);
2846 if (shouldScheduleTimeout) {
2851 /** FIXME generalize this if you track UserCAllbackInfo, clear it
2852 when the callback occurs
2854 static UserCallbackInfo *
2855 internalRequestTimedCallback (RIL_TimedCallback callback, void *param,
2856 const struct timeval *relativeTime)
2858 struct timeval myRelativeTime;
2859 UserCallbackInfo *p_info;
2861 p_info = (UserCallbackInfo *) malloc (sizeof(UserCallbackInfo));
2863 p_info->p_callback = callback;
2864 p_info->userParam = param;
2866 if (relativeTime == NULL) {
2867 /* treat null parameter as a 0 relative time */
2868 memset (&myRelativeTime, 0, sizeof(myRelativeTime));
2870 /* FIXME I think event_add's tv param is really const anyway */
2871 memcpy (&myRelativeTime, relativeTime, sizeof(myRelativeTime));
2874 ril_event_set(&(p_info->event), -1, false, userTimerCallback, p_info);
2876 ril_timer_add(&(p_info->event), &myRelativeTime);
2884 RIL_requestTimedCallback (RIL_TimedCallback callback, void *param,
2885 const struct timeval *relativeTime) {
2886 internalRequestTimedCallback (callback, param, relativeTime);
2890 failCauseToString(RIL_Errno e) {
2892 case RIL_E_SUCCESS: return "E_SUCCESS";
2893 case RIL_E_RADIO_NOT_AVAILABLE: return "E_RAIDO_NOT_AVAILABLE";
2894 case RIL_E_GENERIC_FAILURE: return "E_GENERIC_FAILURE";
2895 case RIL_E_PASSWORD_INCORRECT: return "E_PASSWORD_INCORRECT";
2896 case RIL_E_SIM_PIN2: return "E_SIM_PIN2";
2897 case RIL_E_SIM_PUK2: return "E_SIM_PUK2";
2898 case RIL_E_REQUEST_NOT_SUPPORTED: return "E_REQUEST_NOT_SUPPORTED";
2899 case RIL_E_CANCELLED: return "E_CANCELLED";
2900 case RIL_E_OP_NOT_ALLOWED_DURING_VOICE_CALL: return "E_OP_NOT_ALLOWED_DURING_VOICE_CALL";
2901 case RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW: return "E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW";
2902 case RIL_E_SMS_SEND_FAIL_RETRY: return "E_SMS_SEND_FAIL_RETRY";
2903 case RIL_E_SIM_ABSENT:return "E_SIM_ABSENT";
2904 #ifdef FEATURE_MULTIMODE_ANDROID
2905 case RIL_E_SUBSCRIPTION_NOT_AVAILABLE:return "E_SUBSCRIPTION_NOT_AVAILABLE";
2906 case RIL_E_MODE_NOT_SUPPORTED:return "E_MODE_NOT_SUPPORTED";
2908 default: return "<unknown error>";
2913 radioStateToString(RIL_RadioState s) {
2915 case RADIO_STATE_OFF: return "RADIO_OFF";
2916 case RADIO_STATE_UNAVAILABLE: return "RADIO_UNAVAILABLE";
2917 case RADIO_STATE_SIM_NOT_READY: return "RADIO_SIM_NOT_READY";
2918 case RADIO_STATE_SIM_LOCKED_OR_ABSENT: return "RADIO_SIM_LOCKED_OR_ABSENT";
2919 case RADIO_STATE_SIM_READY: return "RADIO_SIM_READY";
2920 case RADIO_STATE_RUIM_NOT_READY:return"RADIO_RUIM_NOT_READY";
2921 case RADIO_STATE_RUIM_READY:return"RADIO_RUIM_READY";
2922 case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:return"RADIO_RUIM_LOCKED_OR_ABSENT";
2923 case RADIO_STATE_NV_NOT_READY:return"RADIO_NV_NOT_READY";
2924 case RADIO_STATE_NV_READY:return"RADIO_NV_READY";
2925 default: return "<unknown state>";
2930 callStateToString(RIL_CallState s) {
2932 case RIL_CALL_ACTIVE : return "ACTIVE";
2933 case RIL_CALL_HOLDING: return "HOLDING";
2934 case RIL_CALL_DIALING: return "DIALING";
2935 case RIL_CALL_ALERTING: return "ALERTING";
2936 case RIL_CALL_INCOMING: return "INCOMING";
2937 case RIL_CALL_WAITING: return "WAITING";
2938 default: return "<unknown state>";
2943 requestToString(int request) {
2945 cat libs/telephony/ril_commands.h \
2946 | egrep "^ *{RIL_" \
2947 | sed -re 's/\{RIL_([^,]+),[^,]+,([^}]+).+/case RIL_\1: return "\1";/'
2950 cat libs/telephony/ril_unsol_commands.h \
2951 | egrep "^ *{RIL_" \
2952 | sed -re 's/\{RIL_([^,]+),([^}]+).+/case RIL_\1: return "\1";/'
2956 case RIL_REQUEST_GET_SIM_STATUS: return "GET_SIM_STATUS";
2957 case RIL_REQUEST_ENTER_SIM_PIN: return "ENTER_SIM_PIN";
2958 case RIL_REQUEST_ENTER_SIM_PUK: return "ENTER_SIM_PUK";
2959 case RIL_REQUEST_ENTER_SIM_PIN2: return "ENTER_SIM_PIN2";
2960 case RIL_REQUEST_ENTER_SIM_PUK2: return "ENTER_SIM_PUK2";
2961 case RIL_REQUEST_CHANGE_SIM_PIN: return "CHANGE_SIM_PIN";
2962 case RIL_REQUEST_CHANGE_SIM_PIN2: return "CHANGE_SIM_PIN2";
2963 case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: return "ENTER_NETWORK_DEPERSONALIZATION";
2964 case RIL_REQUEST_GET_CURRENT_CALLS: return "GET_CURRENT_CALLS";
2965 case RIL_REQUEST_DIAL: return "DIAL";
2966 case RIL_REQUEST_GET_IMSI: return "GET_IMSI";
2967 case RIL_REQUEST_HANGUP: return "HANGUP";
2968 case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: return "HANGUP_WAITING_OR_BACKGROUND";
2969 case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: return "HANGUP_FOREGROUND_RESUME_BACKGROUND";
2970 case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: return "SWITCH_WAITING_OR_HOLDING_AND_ACTIVE";
2971 case RIL_REQUEST_CONFERENCE: return "CONFERENCE";
2972 case RIL_REQUEST_UDUB: return "UDUB";
2973 case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: return "LAST_CALL_FAIL_CAUSE";
2974 case RIL_REQUEST_SIGNAL_STRENGTH: return "SIGNAL_STRENGTH";
2975 case RIL_REQUEST_REGISTRATION_STATE: return "REGISTRATION_STATE";
2976 case RIL_REQUEST_GPRS_REGISTRATION_STATE: return "GPRS_REGISTRATION_STATE";
2977 case RIL_REQUEST_OPERATOR: return "OPERATOR";
2978 case RIL_REQUEST_RADIO_POWER: return "RADIO_POWER";
2979 case RIL_REQUEST_DTMF: return "DTMF";
2980 case RIL_REQUEST_SEND_SMS: return "SEND_SMS";
2981 case RIL_REQUEST_SEND_SMS_EXPECT_MORE: return "SEND_SMS_EXPECT_MORE";
2982 case RIL_REQUEST_SETUP_DATA_CALL: return "SETUP_DATA_CALL";
2983 case RIL_REQUEST_SIM_IO: return "SIM_IO";
2984 case RIL_REQUEST_SEND_USSD: return "SEND_USSD";
2985 case RIL_REQUEST_CANCEL_USSD: return "CANCEL_USSD";
2986 case RIL_REQUEST_GET_CLIR: return "GET_CLIR";
2987 case RIL_REQUEST_SET_CLIR: return "SET_CLIR";
2988 case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: return "QUERY_CALL_FORWARD_STATUS";
2989 case RIL_REQUEST_SET_CALL_FORWARD: return "SET_CALL_FORWARD";
2990 case RIL_REQUEST_QUERY_CALL_WAITING: return "QUERY_CALL_WAITING";
2991 case RIL_REQUEST_SET_CALL_WAITING: return "SET_CALL_WAITING";
2992 case RIL_REQUEST_SMS_ACKNOWLEDGE: return "SMS_ACKNOWLEDGE";
2993 case RIL_REQUEST_GET_IMEI: return "GET_IMEI";
2994 case RIL_REQUEST_GET_IMEISV: return "GET_IMEISV";
2995 case RIL_REQUEST_ANSWER: return "ANSWER";
2996 case RIL_REQUEST_DEACTIVATE_DATA_CALL: return "DEACTIVATE_DATA_CALL";
2997 case RIL_REQUEST_QUERY_FACILITY_LOCK: return "QUERY_FACILITY_LOCK";
2998 case RIL_REQUEST_SET_FACILITY_LOCK: return "SET_FACILITY_LOCK";
2999 case RIL_REQUEST_CHANGE_BARRING_PASSWORD: return "CHANGE_BARRING_PASSWORD";
3000 case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: return "QUERY_NETWORK_SELECTION_MODE";
3001 case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: return "SET_NETWORK_SELECTION_AUTOMATIC";
3002 case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: return "SET_NETWORK_SELECTION_MANUAL";
3003 case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : return "QUERY_AVAILABLE_NETWORKS ";
3004 case RIL_REQUEST_DTMF_START: return "DTMF_START";
3005 case RIL_REQUEST_DTMF_STOP: return "DTMF_STOP";
3006 case RIL_REQUEST_BASEBAND_VERSION: return "BASEBAND_VERSION";
3007 case RIL_REQUEST_SEPARATE_CONNECTION: return "SEPARATE_CONNECTION";
3008 case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: return "SET_PREFERRED_NETWORK_TYPE";
3009 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: return "GET_PREFERRED_NETWORK_TYPE";
3010 case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: return "GET_NEIGHBORING_CELL_IDS";
3011 case RIL_REQUEST_SET_MUTE: return "SET_MUTE";
3012 case RIL_REQUEST_GET_MUTE: return "GET_MUTE";
3013 case RIL_REQUEST_QUERY_CLIP: return "QUERY_CLIP";
3014 case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: return "LAST_DATA_CALL_FAIL_CAUSE";
3015 case RIL_REQUEST_DATA_CALL_LIST: return "DATA_CALL_LIST";
3016 case RIL_REQUEST_RESET_RADIO: return "RESET_RADIO";
3017 case RIL_REQUEST_OEM_HOOK_RAW: return "OEM_HOOK_RAW";
3018 case RIL_REQUEST_OEM_HOOK_STRINGS: return "OEM_HOOK_STRINGS";
3019 case RIL_REQUEST_SET_BAND_MODE: return "SET_BAND_MODE";
3020 case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: return "QUERY_AVAILABLE_BAND_MODE";
3021 case RIL_REQUEST_STK_GET_PROFILE: return "STK_GET_PROFILE";
3022 case RIL_REQUEST_STK_SET_PROFILE: return "STK_SET_PROFILE";
3023 case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: return "STK_SEND_ENVELOPE_COMMAND";
3024 case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: return "STK_SEND_TERMINAL_RESPONSE";
3025 case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: return "STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM";
3026 case RIL_REQUEST_SCREEN_STATE: return "SCREEN_STATE";
3027 case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: return "EXPLICIT_CALL_TRANSFER";
3028 case RIL_REQUEST_SET_LOCATION_UPDATES: return "SET_LOCATION_UPDATES";
3029 case RIL_REQUEST_CDMA_SET_SUBSCRIPTION:return"CDMA_SET_SUBSCRIPTION";
3030 case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE:return"CDMA_SET_ROAMING_PREFERENCE";
3031 case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE:return"CDMA_QUERY_ROAMING_PREFERENCE";
3032 case RIL_REQUEST_SET_TTY_MODE:return"SET_TTY_MODE";
3033 case RIL_REQUEST_QUERY_TTY_MODE:return"QUERY_TTY_MODE";
3034 case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE";
3035 case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE";
3036 case RIL_REQUEST_CDMA_FLASH:return"CDMA_FLASH";
3037 case RIL_REQUEST_CDMA_BURST_DTMF:return"CDMA_BURST_DTMF";
3038 case RIL_REQUEST_CDMA_SEND_SMS:return"CDMA_SEND_SMS";
3039 case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE:return"CDMA_SMS_ACKNOWLEDGE";
3040 case RIL_REQUEST_GET_BROADCAST_CONFIG:return"GET_BROADCAST_CONFIG";
3041 case RIL_REQUEST_SET_BROADCAST_CONFIG:return"SET_BROADCAST_CONFIG";
3042 case RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG:return "CDMA_GET_BROADCAST_CONFIG";
3043 case RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG:return "SET_CDMA_BROADCAST_CONFIG";
3044 case RIL_REQUEST_BROADCAST_ACTIVATION:return "BROADCAST_ACTIVATION";
3045 case RIL_REQUEST_CDMA_VALIDATE_AKEY: return"CDMA_VALIDATE_AKEY";
3046 case RIL_REQUEST_CDMA_SUBSCRIPTION: return"CDMA_SUBSCRIPTION";
3047 case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: return "CDMA_WRITE_SMS_TO_RUIM";
3048 case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: return "CDMA_DELETE_SMS_ON_RUIM";
3049 case RIL_REQUEST_DEVICE_IDENTITY: return "DEVICE_IDENTITY";
3050 case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: return "EXIT_EMERGENCY_CALLBACK_MODE";
3051 case RIL_REQUEST_GET_SMSC_ADDRESS: return "GET_SMSC_ADDRESS";
3052 case RIL_REQUEST_SET_SMSC_ADDRESS: return "SET_SMSC_ADDRESS";
3053 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return "UNSOL_RESPONSE_RADIO_STATE_CHANGED";
3054 case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return "UNSOL_RESPONSE_CALL_STATE_CHANGED";
3055 case RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED: return "UNSOL_RESPONSE_NETWORK_STATE_CHANGED";
3056 case RIL_UNSOL_RESPONSE_NEW_SMS: return "UNSOL_RESPONSE_NEW_SMS";
3057 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: return "UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT";
3058 case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: return "UNSOL_RESPONSE_NEW_SMS_ON_SIM";
3059 case RIL_UNSOL_ON_USSD: return "UNSOL_ON_USSD";
3060 case RIL_UNSOL_ON_USSD_REQUEST: return "UNSOL_ON_USSD_REQUEST(obsolete)";
3061 case RIL_UNSOL_NITZ_TIME_RECEIVED: return "UNSOL_NITZ_TIME_RECEIVED";
3062 case RIL_UNSOL_SIGNAL_STRENGTH: return "UNSOL_SIGNAL_STRENGTH";
3063 case RIL_UNSOL_STK_SESSION_END: return "UNSOL_STK_SESSION_END";
3064 case RIL_UNSOL_STK_PROACTIVE_COMMAND: return "UNSOL_STK_PROACTIVE_COMMAND";
3065 case RIL_UNSOL_STK_EVENT_NOTIFY: return "UNSOL_STK_EVENT_NOTIFY";
3066 case RIL_UNSOL_STK_CALL_SETUP: return "UNSOL_STK_CALL_SETUP";
3067 case RIL_UNSOL_SIM_SMS_STORAGE_FULL: return "UNSOL_SIM_SMS_STORAGE_FUL";
3068 case RIL_UNSOL_SIM_REFRESH: return "UNSOL_SIM_REFRESH";
3069 case RIL_UNSOL_DATA_CALL_LIST_CHANGED: return "UNSOL_DATA_CALL_LIST_CHANGED";
3070 case RIL_UNSOL_CALL_RING: return "UNSOL_CALL_RING";
3071 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: return "UNSOL_RESPONSE_SIM_STATUS_CHANGED";
3072 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: return "UNSOL_NEW_CDMA_SMS";
3073 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: return "UNSOL_NEW_BROADCAST_SMS";
3074 case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: return "UNSOL_CDMA_RUIM_SMS_STORAGE_FULL";
3075 case RIL_UNSOL_RESTRICTED_STATE_CHANGED: return "UNSOL_RESTRICTED_STATE_CHANGED";
3076 case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: return "UNSOL_ENTER_EMERGENCY_CALLBACK_MODE";
3077 case RIL_UNSOL_CDMA_CALL_WAITING: return "UNSOL_CDMA_CALL_WAITING";
3078 case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: return "UNSOL_CDMA_OTA_PROVISION_STATUS";
3079 case RIL_UNSOL_CDMA_INFO_REC: return "UNSOL_CDMA_INFO_REC";
3080 case RIL_UNSOL_OEM_HOOK_RAW: return "UNSOL_OEM_HOOK_RAW";
3081 default: return "<unknown request>";
3085 } /* namespace android */