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 <telephony/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>
34 #include <sys/limits.h>
50 #include <netinet/in.h>
51 #include <cutils/properties.h>
53 #include <ril_event.h>
57 #define PHONE_PROCESS "radio"
59 #define SOCKET_NAME_RIL "rild"
60 #define SOCKET2_NAME_RIL "rild2"
61 #define SOCKET3_NAME_RIL "rild3"
62 #define SOCKET4_NAME_RIL "rild4"
64 #define SOCKET_NAME_RIL_DEBUG "rild-debug"
66 #define ANDROID_WAKE_LOCK_NAME "radio-interface"
69 #define PROPERTY_RIL_IMPL "gsm.version.ril-impl"
71 // match with constant in RIL.java
72 #define MAX_COMMAND_BYTES (8 * 1024)
74 // Basically: memset buffers that the client library
75 // shouldn't be using anymore in an attempt to find
76 // memory usage issues sooner.
77 #define MEMSET_FREED 1
79 #define NUM_ELEMS(a) (sizeof (a) / sizeof (a)[0])
81 #define MIN(a,b) ((a)<(b) ? (a) : (b))
83 /* Constants for response types */
84 #define RESPONSE_SOLICITED 0
85 #define RESPONSE_UNSOLICITED 1
87 /* Negative values for private RIL errno's */
88 #define RIL_ERRNO_INVALID_RESPONSE -1
90 // request, response, and unsolicited msg print macro
91 #define PRINTBUF_SIZE 8096
97 #define startRequest sprintf(printBuf, "(")
98 #define closeRequest sprintf(printBuf, "%s)", printBuf)
99 #define printRequest(token, req) \
100 RLOGD("[%04d]> %s %s", token, requestToString(req), printBuf)
102 #define startResponse sprintf(printBuf, "%s {", printBuf)
103 #define closeResponse sprintf(printBuf, "%s}", printBuf)
104 #define printResponse RLOGD("%s", printBuf)
106 #define clearPrintBuf printBuf[0] = 0
107 #define removeLastChar printBuf[strlen(printBuf)-1] = 0
108 #define appendPrintBuf(x...) sprintf(printBuf, x)
112 #define printRequest(token, req)
113 #define startResponse
114 #define closeResponse
115 #define printResponse
116 #define clearPrintBuf
117 #define removeLastChar
118 #define appendPrintBuf(x...)
121 enum WakeType {DONT_WAKE, WAKE_PARTIAL};
125 void (*dispatchFunction) (Parcel &p, struct RequestInfo *pRI);
126 int(*responseFunction) (Parcel &p, void *response, size_t responselen);
131 int (*responseFunction) (Parcel &p, void *response, size_t responselen);
135 typedef struct RequestInfo {
136 int32_t token; //this is not RIL_Token
138 struct RequestInfo *p_next;
140 char local; // responses to local commands do not go back to command process
141 RIL_SOCKET_ID socket_id;
144 typedef struct UserCallbackInfo {
145 RIL_TimedCallback p_callback;
147 struct ril_event event;
148 struct UserCallbackInfo *p_next;
151 typedef struct SocketListenParam {
152 RIL_SOCKET_ID socket_id;
156 struct ril_event* commands_event;
157 struct ril_event* listen_event;
158 void (*processCommandsCallback)(int fd, short flags, void *param);
162 extern "C" const char * requestToString(int request);
163 extern "C" const char * failCauseToString(RIL_Errno);
164 extern "C" const char * callStateToString(RIL_CallState);
165 extern "C" const char * radioStateToString(RIL_RadioState);
166 extern "C" const char * rilSocketIdToString(RIL_SOCKET_ID socket_id);
169 char rild[MAX_SOCKET_NAME_LENGTH] = SOCKET_NAME_RIL;
170 /*******************************************************************/
172 RIL_RadioFunctions s_callbacks = {0, NULL, NULL, NULL, NULL, NULL};
173 static int s_registerCalled = 0;
175 static pthread_t s_tid_dispatch;
176 static pthread_t s_tid_reader;
177 static int s_started = 0;
179 static int s_fdDebug = -1;
180 static int s_fdDebug_socket2 = -1;
182 static int s_fdWakeupRead;
183 static int s_fdWakeupWrite;
185 static struct ril_event s_commands_event;
186 static struct ril_event s_wakeupfd_event;
187 static struct ril_event s_listen_event;
188 static SocketListenParam s_ril_param_socket;
190 static pthread_mutex_t s_pendingRequestsMutex = PTHREAD_MUTEX_INITIALIZER;
191 static pthread_mutex_t s_writeMutex = PTHREAD_MUTEX_INITIALIZER;
192 static RequestInfo *s_pendingRequests = NULL;
195 static struct ril_event s_commands_event_socket2;
196 static struct ril_event s_listen_event_socket2;
197 static SocketListenParam s_ril_param_socket2;
199 static pthread_mutex_t s_pendingRequestsMutex_socket2 = PTHREAD_MUTEX_INITIALIZER;
200 static pthread_mutex_t s_writeMutex_socket2 = PTHREAD_MUTEX_INITIALIZER;
201 static RequestInfo *s_pendingRequests_socket2 = NULL;
205 static struct ril_event s_commands_event_socket3;
206 static struct ril_event s_listen_event_socket3;
207 static SocketListenParam s_ril_param_socket3;
209 static pthread_mutex_t s_pendingRequestsMutex_socket3 = PTHREAD_MUTEX_INITIALIZER;
210 static pthread_mutex_t s_writeMutex_socket3 = PTHREAD_MUTEX_INITIALIZER;
211 static RequestInfo *s_pendingRequests_socket3 = NULL;
215 static struct ril_event s_commands_event_socket4;
216 static struct ril_event s_listen_event_socket4;
217 static SocketListenParam s_ril_param_socket4;
219 static pthread_mutex_t s_pendingRequestsMutex_socket4 = PTHREAD_MUTEX_INITIALIZER;
220 static pthread_mutex_t s_writeMutex_socket4 = PTHREAD_MUTEX_INITIALIZER;
221 static RequestInfo *s_pendingRequests_socket4 = NULL;
224 static struct ril_event s_wake_timeout_event;
225 static struct ril_event s_debug_event;
228 static const struct timeval TIMEVAL_WAKE_TIMEOUT = {1,0};
231 static pthread_mutex_t s_startupMutex = PTHREAD_MUTEX_INITIALIZER;
232 static pthread_cond_t s_startupCond = PTHREAD_COND_INITIALIZER;
234 static pthread_mutex_t s_dispatchMutex = PTHREAD_MUTEX_INITIALIZER;
235 static pthread_cond_t s_dispatchCond = PTHREAD_COND_INITIALIZER;
237 static RequestInfo *s_toDispatchHead = NULL;
238 static RequestInfo *s_toDispatchTail = NULL;
240 static UserCallbackInfo *s_last_wake_timeout_info = NULL;
242 static void *s_lastNITZTimeData = NULL;
243 static size_t s_lastNITZTimeDataSize;
246 static char printBuf[PRINTBUF_SIZE];
249 /*******************************************************************/
250 static int sendResponse (Parcel &p, RIL_SOCKET_ID socket_id);
252 static void dispatchVoid (Parcel& p, RequestInfo *pRI);
253 static void dispatchString (Parcel& p, RequestInfo *pRI);
254 static void dispatchStrings (Parcel& p, RequestInfo *pRI);
255 static void dispatchInts (Parcel& p, RequestInfo *pRI);
256 static void dispatchDial (Parcel& p, RequestInfo *pRI);
257 static void dispatchSIM_IO (Parcel& p, RequestInfo *pRI);
258 static void dispatchSIM_APDU (Parcel& p, RequestInfo *pRI);
259 static void dispatchCallForward(Parcel& p, RequestInfo *pRI);
260 static void dispatchRaw(Parcel& p, RequestInfo *pRI);
261 static void dispatchSmsWrite (Parcel &p, RequestInfo *pRI);
262 static void dispatchDataCall (Parcel& p, RequestInfo *pRI);
263 static void dispatchVoiceRadioTech (Parcel& p, RequestInfo *pRI);
264 static void dispatchSetInitialAttachApn (Parcel& p, RequestInfo *pRI);
265 static void dispatchCdmaSubscriptionSource (Parcel& p, RequestInfo *pRI);
267 static void dispatchCdmaSms(Parcel &p, RequestInfo *pRI);
268 static void dispatchImsSms(Parcel &p, RequestInfo *pRI);
269 static void dispatchImsCdmaSms(Parcel &p, RequestInfo *pRI, uint8_t retry, int32_t messageRef);
270 static void dispatchImsGsmSms(Parcel &p, RequestInfo *pRI, uint8_t retry, int32_t messageRef);
271 static void dispatchCdmaSmsAck(Parcel &p, RequestInfo *pRI);
272 static void dispatchGsmBrSmsCnf(Parcel &p, RequestInfo *pRI);
273 static void dispatchCdmaBrSmsCnf(Parcel &p, RequestInfo *pRI);
274 static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI);
275 static void dispatchNVReadItem(Parcel &p, RequestInfo *pRI);
276 static void dispatchNVWriteItem(Parcel &p, RequestInfo *pRI);
277 static void dispatchUiccSubscripton(Parcel &p, RequestInfo *pRI);
278 static void dispatchSimAuthentication(Parcel &p, RequestInfo *pRI);
279 static void dispatchDataProfile(Parcel &p, RequestInfo *pRI);
280 static int responseInts(Parcel &p, void *response, size_t responselen);
281 static int responseStrings(Parcel &p, void *response, size_t responselen);
282 static int responseString(Parcel &p, void *response, size_t responselen);
283 static int responseVoid(Parcel &p, void *response, size_t responselen);
284 static int responseCallList(Parcel &p, void *response, size_t responselen);
285 static int responseSMS(Parcel &p, void *response, size_t responselen);
286 static int responseSIM_IO(Parcel &p, void *response, size_t responselen);
287 static int responseCallForwards(Parcel &p, void *response, size_t responselen);
288 static int responseDataCallList(Parcel &p, void *response, size_t responselen);
289 static int responseSetupDataCall(Parcel &p, void *response, size_t responselen);
290 static int responseRaw(Parcel &p, void *response, size_t responselen);
291 static int responseSsn(Parcel &p, void *response, size_t responselen);
292 static int responseSimStatus(Parcel &p, void *response, size_t responselen);
293 static int responseGsmBrSmsCnf(Parcel &p, void *response, size_t responselen);
294 static int responseCdmaBrSmsCnf(Parcel &p, void *response, size_t responselen);
295 static int responseCdmaSms(Parcel &p, void *response, size_t responselen);
296 static int responseCellList(Parcel &p, void *response, size_t responselen);
297 static int responseCdmaInformationRecords(Parcel &p,void *response, size_t responselen);
298 static int responseRilSignalStrength(Parcel &p,void *response, size_t responselen);
299 static int responseCallRing(Parcel &p, void *response, size_t responselen);
300 static int responseCdmaSignalInfoRecord(Parcel &p,void *response, size_t responselen);
301 static int responseCdmaCallWaiting(Parcel &p,void *response, size_t responselen);
302 static int responseSimRefresh(Parcel &p, void *response, size_t responselen);
303 static int responseCellInfoList(Parcel &p, void *response, size_t responselen);
304 static int responseHardwareConfig(Parcel &p, void *response, size_t responselen);
305 static int responseDcRtInfo(Parcel &p, void *response, size_t responselen);
307 static int decodeVoiceRadioTechnology (RIL_RadioState radioState);
308 static int decodeCdmaSubscriptionSource (RIL_RadioState radioState);
309 static RIL_RadioState processRadioState(RIL_RadioState newRadioState);
312 #if defined(ANDROID_MULTI_SIM)
313 extern "C" void RIL_onUnsolicitedResponse(int unsolResponse, void *data,
314 size_t datalen, RIL_SOCKET_ID socket_id);
316 extern "C" void RIL_onUnsolicitedResponse(int unsolResponse, void *data,
321 #if defined(ANDROID_MULTI_SIM)
322 #define RIL_UNSOL_RESPONSE(a, b, c, d) RIL_onUnsolicitedResponse((a), (b), (c), (d))
323 #define CALL_ONREQUEST(a, b, c, d, e) s_callbacks.onRequest((a), (b), (c), (d), (e))
324 #define CALL_ONSTATEREQUEST(a) s_callbacks.onStateRequest(a)
326 #define RIL_UNSOL_RESPONSE(a, b, c, d) RIL_onUnsolicitedResponse((a), (b), (c))
327 #define CALL_ONREQUEST(a, b, c, d, e) s_callbacks.onRequest((a), (b), (c), (d))
328 #define CALL_ONSTATEREQUEST(a) s_callbacks.onStateRequest()
331 static UserCallbackInfo * internalRequestTimedCallback
332 (RIL_TimedCallback callback, void *param,
333 const struct timeval *relativeTime);
335 /** Index == requestNumber */
336 static CommandInfo s_commands[] = {
337 #include "ril_commands.h"
340 static UnsolResponseInfo s_unsolResponses[] = {
341 #include "ril_unsol_commands.h"
344 /* For older RILs that do not support new commands RIL_REQUEST_VOICE_RADIO_TECH and
345 RIL_UNSOL_VOICE_RADIO_TECH_CHANGED messages, decode the voice radio tech from
346 radio state message and store it. Every time there is a change in Radio State
347 check to see if voice radio tech changes and notify telephony
349 int voiceRadioTech = -1;
351 /* For older RILs that do not support new commands RIL_REQUEST_GET_CDMA_SUBSCRIPTION_SOURCE
352 and RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED messages, decode the subscription
353 source from radio state and store it. Every time there is a change in Radio State
354 check to see if subscription source changed and notify telephony
356 int cdmaSubscriptionSource = -1;
358 /* For older RILs that do not send RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, decode the
359 SIM/RUIM state from radio state and store it. Every time there is a change in Radio State,
360 check to see if SIM/RUIM status changed and notify telephony
362 int simRuimStatus = -1;
364 static char * RIL_getRilSocketName() {
369 void RIL_setRilSocketName(char * s) {
370 strncpy(rild, s, MAX_SOCKET_NAME_LENGTH);
374 strdupReadString(Parcel &p) {
378 s16 = p.readString16Inplace(&stringlen);
380 return strndup16to8(s16, stringlen);
383 static void writeStringToParcel(Parcel &p, const char *s) {
386 s16 = strdup8to16(s, &s16_len);
387 p.writeString16(s16, s16_len);
393 memsetString (char *s) {
395 memset (s, 0, strlen(s));
399 void nullParcelReleaseFunction (const uint8_t* data, size_t dataSize,
400 const size_t* objects, size_t objectsSize,
402 // do nothing -- the data reference lives longer than the Parcel object
406 * To be called from dispatch thread
407 * Issue a single local request, ensuring that the response
408 * is not sent back up to the command process
411 issueLocalRequest(int request, void *data, int len, RIL_SOCKET_ID socket_id) {
414 /* Hook for current context */
415 /* pendingRequestsMutextHook refer to &s_pendingRequestsMutex */
416 pthread_mutex_t* pendingRequestsMutexHook = &s_pendingRequestsMutex;
417 /* pendingRequestsHook refer to &s_pendingRequests */
418 RequestInfo** pendingRequestsHook = &s_pendingRequests;
421 if (socket_id == RIL_SOCKET_2) {
422 pendingRequestsMutexHook = &s_pendingRequestsMutex_socket2;
423 pendingRequestsHook = &s_pendingRequests_socket2;
427 pRI = (RequestInfo *)calloc(1, sizeof(RequestInfo));
430 pRI->token = 0xffffffff; // token is not used in this context
431 pRI->pCI = &(s_commands[request]);
432 pRI->socket_id = socket_id;
434 ret = pthread_mutex_lock(pendingRequestsMutexHook);
437 pRI->p_next = *pendingRequestsHook;
438 *pendingRequestsHook = pRI;
440 ret = pthread_mutex_unlock(pendingRequestsMutexHook);
443 RLOGD("C[locl]> %s", requestToString(request));
445 CALL_ONREQUEST(request, data, len, pRI, pRI->socket_id);
451 processCommandBuffer(void *buffer, size_t buflen, RIL_SOCKET_ID socket_id) {
458 /* Hook for current context */
459 /* pendingRequestsMutextHook refer to &s_pendingRequestsMutex */
460 pthread_mutex_t* pendingRequestsMutexHook = &s_pendingRequestsMutex;
461 /* pendingRequestsHook refer to &s_pendingRequests */
462 RequestInfo** pendingRequestsHook = &s_pendingRequests;
464 p.setData((uint8_t *) buffer, buflen);
466 // status checked at end
467 status = p.readInt32(&request);
468 status = p.readInt32 (&token);
470 RLOGD("SOCKET %s REQUEST: %s length:%d", rilSocketIdToString(socket_id), requestToString(request), buflen);
473 if (socket_id == RIL_SOCKET_2) {
474 pendingRequestsMutexHook = &s_pendingRequestsMutex_socket2;
475 pendingRequestsHook = &s_pendingRequests_socket2;
478 else if (socket_id == RIL_SOCKET_3) {
479 pendingRequestsMutexHook = &s_pendingRequestsMutex_socket3;
480 pendingRequestsHook = &s_pendingRequests_socket3;
484 else if (socket_id == RIL_SOCKET_4) {
485 pendingRequestsMutexHook = &s_pendingRequestsMutex_socket4;
486 pendingRequestsHook = &s_pendingRequests_socket4;
491 if (status != NO_ERROR) {
492 RLOGE("invalid request block");
496 if (request < 1 || request >= (int32_t)NUM_ELEMS(s_commands)) {
498 RLOGE("unsupported request code %d token %d", request, token);
499 // FIXME this should perhaps return a response
500 pErr.writeInt32 (RESPONSE_SOLICITED);
501 pErr.writeInt32 (token);
502 pErr.writeInt32 (RIL_E_GENERIC_FAILURE);
504 sendResponse(pErr, socket_id);
509 pRI = (RequestInfo *)calloc(1, sizeof(RequestInfo));
512 pRI->pCI = &(s_commands[request]);
513 pRI->socket_id = socket_id;
515 ret = pthread_mutex_lock(pendingRequestsMutexHook);
518 pRI->p_next = *pendingRequestsHook;
519 *pendingRequestsHook = pRI;
521 ret = pthread_mutex_unlock(pendingRequestsMutexHook);
524 /* sLastDispatchedToken = token; */
526 pRI->pCI->dispatchFunction(p, pRI);
532 invalidCommandBlock (RequestInfo *pRI) {
533 RLOGE("invalid command block for token %d request %s",
534 pRI->token, requestToString(pRI->pCI->requestNumber));
537 /** Callee expects NULL */
539 dispatchVoid (Parcel& p, RequestInfo *pRI) {
541 printRequest(pRI->token, pRI->pCI->requestNumber);
542 CALL_ONREQUEST(pRI->pCI->requestNumber, NULL, 0, pRI, pRI->socket_id);
545 /** Callee expects const char * */
547 dispatchString (Parcel& p, RequestInfo *pRI) {
551 char *string8 = NULL;
553 string8 = strdupReadString(p);
556 appendPrintBuf("%s%s", printBuf, string8);
558 printRequest(pRI->token, pRI->pCI->requestNumber);
560 CALL_ONREQUEST(pRI->pCI->requestNumber, string8,
561 sizeof(char *), pRI, pRI->socket_id);
564 memsetString(string8);
570 invalidCommandBlock(pRI);
574 /** Callee expects const char ** */
576 dispatchStrings (Parcel &p, RequestInfo *pRI) {
577 int32_t countStrings;
582 status = p.readInt32 (&countStrings);
584 if (status != NO_ERROR) {
589 if (countStrings == 0) {
590 // just some non-null pointer
591 pStrings = (char **)alloca(sizeof(char *));
593 } else if (((int)countStrings) == -1) {
597 datalen = sizeof(char *) * countStrings;
599 pStrings = (char **)alloca(datalen);
601 for (int i = 0 ; i < countStrings ; i++) {
602 pStrings[i] = strdupReadString(p);
603 appendPrintBuf("%s%s,", printBuf, pStrings[i]);
608 printRequest(pRI->token, pRI->pCI->requestNumber);
610 CALL_ONREQUEST(pRI->pCI->requestNumber, pStrings, datalen, pRI, pRI->socket_id);
612 if (pStrings != NULL) {
613 for (int i = 0 ; i < countStrings ; i++) {
615 memsetString (pStrings[i]);
621 memset(pStrings, 0, datalen);
627 invalidCommandBlock(pRI);
631 /** Callee expects const int * */
633 dispatchInts (Parcel &p, RequestInfo *pRI) {
639 status = p.readInt32 (&count);
641 if (status != NO_ERROR || count == 0) {
645 datalen = sizeof(int) * count;
646 pInts = (int *)alloca(datalen);
649 for (int i = 0 ; i < count ; i++) {
652 status = p.readInt32(&t);
654 appendPrintBuf("%s%d,", printBuf, t);
656 if (status != NO_ERROR) {
662 printRequest(pRI->token, pRI->pCI->requestNumber);
664 CALL_ONREQUEST(pRI->pCI->requestNumber, const_cast<int *>(pInts),
665 datalen, pRI, pRI->socket_id);
668 memset(pInts, 0, datalen);
673 invalidCommandBlock(pRI);
679 * Callee expects const RIL_SMS_WriteArgs *
685 dispatchSmsWrite (Parcel &p, RequestInfo *pRI) {
686 RIL_SMS_WriteArgs args;
690 memset (&args, 0, sizeof(args));
692 status = p.readInt32(&t);
693 args.status = (int)t;
695 args.pdu = strdupReadString(p);
697 if (status != NO_ERROR || args.pdu == NULL) {
701 args.smsc = strdupReadString(p);
704 appendPrintBuf("%s%d,%s,smsc=%s", printBuf, args.status,
705 (char*)args.pdu, (char*)args.smsc);
707 printRequest(pRI->token, pRI->pCI->requestNumber);
709 CALL_ONREQUEST(pRI->pCI->requestNumber, &args, sizeof(args), pRI, pRI->socket_id);
712 memsetString (args.pdu);
718 memset(&args, 0, sizeof(args));
723 invalidCommandBlock(pRI);
728 * Callee expects const RIL_Dial *
734 dispatchDial (Parcel &p, RequestInfo *pRI) {
736 RIL_UUS_Info uusInfo;
742 memset (&dial, 0, sizeof(dial));
744 dial.address = strdupReadString(p);
746 status = p.readInt32(&t);
749 if (status != NO_ERROR || dial.address == NULL) {
753 if (s_callbacks.version < 3) { // Remove when partners upgrade to version 3
755 sizeOfDial = sizeof(dial) - sizeof(RIL_UUS_Info *);
757 status = p.readInt32(&uusPresent);
759 if (status != NO_ERROR) {
763 if (uusPresent == 0) {
768 memset(&uusInfo, 0, sizeof(RIL_UUS_Info));
770 status = p.readInt32(&t);
771 uusInfo.uusType = (RIL_UUS_Type) t;
773 status = p.readInt32(&t);
774 uusInfo.uusDcs = (RIL_UUS_DCS) t;
776 status = p.readInt32(&len);
777 if (status != NO_ERROR) {
781 // The java code writes -1 for null arrays
782 if (((int) len) == -1) {
783 uusInfo.uusData = NULL;
786 uusInfo.uusData = (char*) p.readInplace(len);
789 uusInfo.uusLength = len;
790 dial.uusInfo = &uusInfo;
792 sizeOfDial = sizeof(dial);
796 appendPrintBuf("%snum=%s,clir=%d", printBuf, dial.address, dial.clir);
798 appendPrintBuf("%s,uusType=%d,uusDcs=%d,uusLen=%d", printBuf,
799 dial.uusInfo->uusType, dial.uusInfo->uusDcs,
800 dial.uusInfo->uusLength);
803 printRequest(pRI->token, pRI->pCI->requestNumber);
805 CALL_ONREQUEST(pRI->pCI->requestNumber, &dial, sizeOfDial, pRI, pRI->socket_id);
808 memsetString (dial.address);
814 memset(&uusInfo, 0, sizeof(RIL_UUS_Info));
815 memset(&dial, 0, sizeof(dial));
820 invalidCommandBlock(pRI);
825 * Callee expects const RIL_SIM_IO *
836 dispatchSIM_IO (Parcel &p, RequestInfo *pRI) {
846 memset (&simIO, 0, sizeof(simIO));
848 // note we only check status at the end
850 status = p.readInt32(&t);
851 simIO.v6.command = (int)t;
853 status = p.readInt32(&t);
854 simIO.v6.fileid = (int)t;
856 simIO.v6.path = strdupReadString(p);
858 status = p.readInt32(&t);
859 simIO.v6.p1 = (int)t;
861 status = p.readInt32(&t);
862 simIO.v6.p2 = (int)t;
864 status = p.readInt32(&t);
865 simIO.v6.p3 = (int)t;
867 simIO.v6.data = strdupReadString(p);
868 simIO.v6.pin2 = strdupReadString(p);
869 simIO.v6.aidPtr = strdupReadString(p);
872 appendPrintBuf("%scmd=0x%X,efid=0x%X,path=%s,%d,%d,%d,%s,pin2=%s,aid=%s", printBuf,
873 simIO.v6.command, simIO.v6.fileid, (char*)simIO.v6.path,
874 simIO.v6.p1, simIO.v6.p2, simIO.v6.p3,
875 (char*)simIO.v6.data, (char*)simIO.v6.pin2, simIO.v6.aidPtr);
877 printRequest(pRI->token, pRI->pCI->requestNumber);
879 if (status != NO_ERROR) {
883 size = (s_callbacks.version < 6) ? sizeof(simIO.v5) : sizeof(simIO.v6);
884 CALL_ONREQUEST(pRI->pCI->requestNumber, &simIO, size, pRI, pRI->socket_id);
887 memsetString (simIO.v6.path);
888 memsetString (simIO.v6.data);
889 memsetString (simIO.v6.pin2);
890 memsetString (simIO.v6.aidPtr);
893 free (simIO.v6.path);
894 free (simIO.v6.data);
895 free (simIO.v6.pin2);
896 free (simIO.v6.aidPtr);
899 memset(&simIO, 0, sizeof(simIO));
904 invalidCommandBlock(pRI);
909 * Callee expects const RIL_SIM_APDU *
913 * int32_t instruction
918 dispatchSIM_APDU (Parcel &p, RequestInfo *pRI) {
923 memset (&apdu, 0, sizeof(RIL_SIM_APDU));
925 // Note we only check status at the end. Any single failure leads to
926 // subsequent reads filing.
927 status = p.readInt32(&t);
928 apdu.sessionid = (int)t;
930 status = p.readInt32(&t);
933 status = p.readInt32(&t);
934 apdu.instruction = (int)t;
936 status = p.readInt32(&t);
939 status = p.readInt32(&t);
942 status = p.readInt32(&t);
945 apdu.data = strdupReadString(p);
948 appendPrintBuf("%ssessionid=%d,cla=%d,ins=%d,p1=%d,p2=%d,p3=%d,data=%s",
949 printBuf, apdu.sessionid, apdu.cla, apdu.instruction, apdu.p1, apdu.p2,
950 apdu.p3, (char*)apdu.data);
952 printRequest(pRI->token, pRI->pCI->requestNumber);
954 if (status != NO_ERROR) {
958 CALL_ONREQUEST(pRI->pCI->requestNumber, &apdu, sizeof(RIL_SIM_APDU), pRI, pRI->socket_id);
961 memsetString(apdu.data);
966 memset(&apdu, 0, sizeof(RIL_SIM_APDU));
971 invalidCommandBlock(pRI);
977 * Callee expects const RIL_CallForwardInfo *
979 * int32_t status/action
981 * int32_t serviceCode
983 * String number (0 length -> null)
984 * int32_t timeSeconds
987 dispatchCallForward(Parcel &p, RequestInfo *pRI) {
988 RIL_CallForwardInfo cff;
992 memset (&cff, 0, sizeof(cff));
994 // note we only check status at the end
996 status = p.readInt32(&t);
999 status = p.readInt32(&t);
1000 cff.reason = (int)t;
1002 status = p.readInt32(&t);
1003 cff.serviceClass = (int)t;
1005 status = p.readInt32(&t);
1008 cff.number = strdupReadString(p);
1010 status = p.readInt32(&t);
1011 cff.timeSeconds = (int)t;
1013 if (status != NO_ERROR) {
1017 // special case: number 0-length fields is null
1019 if (cff.number != NULL && strlen (cff.number) == 0) {
1024 appendPrintBuf("%sstat=%d,reason=%d,serv=%d,toa=%d,%s,tout=%d", printBuf,
1025 cff.status, cff.reason, cff.serviceClass, cff.toa,
1026 (char*)cff.number, cff.timeSeconds);
1028 printRequest(pRI->token, pRI->pCI->requestNumber);
1030 CALL_ONREQUEST(pRI->pCI->requestNumber, &cff, sizeof(cff), pRI, pRI->socket_id);
1033 memsetString(cff.number);
1039 memset(&cff, 0, sizeof(cff));
1044 invalidCommandBlock(pRI);
1050 dispatchRaw(Parcel &p, RequestInfo *pRI) {
1055 status = p.readInt32(&len);
1057 if (status != NO_ERROR) {
1061 // The java code writes -1 for null arrays
1062 if (((int)len) == -1) {
1067 data = p.readInplace(len);
1070 appendPrintBuf("%sraw_size=%d", printBuf, len);
1072 printRequest(pRI->token, pRI->pCI->requestNumber);
1074 CALL_ONREQUEST(pRI->pCI->requestNumber, const_cast<void *>(data), len, pRI, pRI->socket_id);
1078 invalidCommandBlock(pRI);
1083 constructCdmaSms(Parcel &p, RequestInfo *pRI, RIL_CDMA_SMS_Message& rcsm) {
1090 memset(&rcsm, 0, sizeof(rcsm));
1092 status = p.readInt32(&t);
1093 rcsm.uTeleserviceID = (int) t;
1095 status = p.read(&ut,sizeof(ut));
1096 rcsm.bIsServicePresent = (uint8_t) ut;
1098 status = p.readInt32(&t);
1099 rcsm.uServicecategory = (int) t;
1101 status = p.readInt32(&t);
1102 rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) t;
1104 status = p.readInt32(&t);
1105 rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) t;
1107 status = p.readInt32(&t);
1108 rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) t;
1110 status = p.readInt32(&t);
1111 rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) t;
1113 status = p.read(&ut,sizeof(ut));
1114 rcsm.sAddress.number_of_digits= (uint8_t) ut;
1116 digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
1117 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
1118 status = p.read(&ut,sizeof(ut));
1119 rcsm.sAddress.digits[digitCount] = (uint8_t) ut;
1122 status = p.readInt32(&t);
1123 rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) t;
1125 status = p.read(&ut,sizeof(ut));
1126 rcsm.sSubAddress.odd = (uint8_t) ut;
1128 status = p.read(&ut,sizeof(ut));
1129 rcsm.sSubAddress.number_of_digits = (uint8_t) ut;
1131 digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
1132 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
1133 status = p.read(&ut,sizeof(ut));
1134 rcsm.sSubAddress.digits[digitCount] = (uint8_t) ut;
1137 status = p.readInt32(&t);
1138 rcsm.uBearerDataLen = (int) t;
1140 digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
1141 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
1142 status = p.read(&ut, sizeof(ut));
1143 rcsm.aBearerData[digitCount] = (uint8_t) ut;
1146 if (status != NO_ERROR) {
1151 appendPrintBuf("%suTeleserviceID=%d, bIsServicePresent=%d, uServicecategory=%d, \
1152 sAddress.digit_mode=%d, sAddress.Number_mode=%d, sAddress.number_type=%d, ",
1153 printBuf, rcsm.uTeleserviceID,rcsm.bIsServicePresent,rcsm.uServicecategory,
1154 rcsm.sAddress.digit_mode, rcsm.sAddress.number_mode,rcsm.sAddress.number_type);
1157 printRequest(pRI->token, pRI->pCI->requestNumber);
1163 dispatchCdmaSms(Parcel &p, RequestInfo *pRI) {
1164 RIL_CDMA_SMS_Message rcsm;
1166 ALOGD("dispatchCdmaSms");
1167 if (NO_ERROR != constructCdmaSms(p, pRI, rcsm)) {
1171 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm),pRI, pRI->socket_id);
1174 memset(&rcsm, 0, sizeof(rcsm));
1180 invalidCommandBlock(pRI);
1185 dispatchImsCdmaSms(Parcel &p, RequestInfo *pRI, uint8_t retry, int32_t messageRef) {
1186 RIL_IMS_SMS_Message rism;
1187 RIL_CDMA_SMS_Message rcsm;
1189 ALOGD("dispatchImsCdmaSms: retry=%d, messageRef=%d", retry, messageRef);
1191 if (NO_ERROR != constructCdmaSms(p, pRI, rcsm)) {
1194 memset(&rism, 0, sizeof(rism));
1195 rism.tech = RADIO_TECH_3GPP2;
1197 rism.messageRef = messageRef;
1198 rism.message.cdmaMessage = &rcsm;
1200 CALL_ONREQUEST(pRI->pCI->requestNumber, &rism,
1201 sizeof(RIL_RadioTechnologyFamily)+sizeof(uint8_t)+sizeof(int32_t)
1202 +sizeof(rcsm),pRI, pRI->socket_id);
1205 memset(&rcsm, 0, sizeof(rcsm));
1206 memset(&rism, 0, sizeof(rism));
1212 invalidCommandBlock(pRI);
1217 dispatchImsGsmSms(Parcel &p, RequestInfo *pRI, uint8_t retry, int32_t messageRef) {
1218 RIL_IMS_SMS_Message rism;
1219 int32_t countStrings;
1223 ALOGD("dispatchImsGsmSms: retry=%d, messageRef=%d", retry, messageRef);
1225 status = p.readInt32 (&countStrings);
1227 if (status != NO_ERROR) {
1231 memset(&rism, 0, sizeof(rism));
1232 rism.tech = RADIO_TECH_3GPP;
1234 rism.messageRef = messageRef;
1237 appendPrintBuf("%stech=%d, retry=%d, messageRef=%d, ", printBuf,
1238 (int)rism.tech, (int)rism.retry, rism.messageRef);
1239 if (countStrings == 0) {
1240 // just some non-null pointer
1241 pStrings = (char **)alloca(sizeof(char *));
1243 } else if (((int)countStrings) == -1) {
1247 datalen = sizeof(char *) * countStrings;
1249 pStrings = (char **)alloca(datalen);
1251 for (int i = 0 ; i < countStrings ; i++) {
1252 pStrings[i] = strdupReadString(p);
1253 appendPrintBuf("%s%s,", printBuf, pStrings[i]);
1258 printRequest(pRI->token, pRI->pCI->requestNumber);
1260 rism.message.gsmMessage = pStrings;
1261 CALL_ONREQUEST(pRI->pCI->requestNumber, &rism,
1262 sizeof(RIL_RadioTechnologyFamily)+sizeof(uint8_t)+sizeof(int32_t)
1263 +datalen, pRI, pRI->socket_id);
1265 if (pStrings != NULL) {
1266 for (int i = 0 ; i < countStrings ; i++) {
1268 memsetString (pStrings[i]);
1274 memset(pStrings, 0, datalen);
1279 memset(&rism, 0, sizeof(rism));
1283 ALOGE("dispatchImsGsmSms invalid block");
1284 invalidCommandBlock(pRI);
1289 dispatchImsSms(Parcel &p, RequestInfo *pRI) {
1291 status_t status = p.readInt32(&t);
1292 RIL_RadioTechnologyFamily format;
1296 ALOGD("dispatchImsSms");
1297 if (status != NO_ERROR) {
1300 format = (RIL_RadioTechnologyFamily) t;
1303 status = p.read(&retry,sizeof(retry));
1304 if (status != NO_ERROR) {
1307 // read messageRef field
1308 status = p.read(&messageRef,sizeof(messageRef));
1309 if (status != NO_ERROR) {
1313 if (RADIO_TECH_3GPP == format) {
1314 dispatchImsGsmSms(p, pRI, retry, messageRef);
1315 } else if (RADIO_TECH_3GPP2 == format) {
1316 dispatchImsCdmaSms(p, pRI, retry, messageRef);
1318 ALOGE("requestImsSendSMS invalid format value =%d", format);
1324 invalidCommandBlock(pRI);
1329 dispatchCdmaSmsAck(Parcel &p, RequestInfo *pRI) {
1330 RIL_CDMA_SMS_Ack rcsa;
1335 memset(&rcsa, 0, sizeof(rcsa));
1337 status = p.readInt32(&t);
1338 rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) t;
1340 status = p.readInt32(&t);
1341 rcsa.uSMSCauseCode = (int) t;
1343 if (status != NO_ERROR) {
1348 appendPrintBuf("%suErrorClass=%d, uTLStatus=%d, ",
1349 printBuf, rcsa.uErrorClass, rcsa.uSMSCauseCode);
1352 printRequest(pRI->token, pRI->pCI->requestNumber);
1354 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa),pRI, pRI->socket_id);
1357 memset(&rcsa, 0, sizeof(rcsa));
1363 invalidCommandBlock(pRI);
1368 dispatchGsmBrSmsCnf(Parcel &p, RequestInfo *pRI) {
1373 status = p.readInt32(&num);
1374 if (status != NO_ERROR) {
1379 RIL_GSM_BroadcastSmsConfigInfo gsmBci[num];
1380 RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num];
1383 for (int i = 0 ; i < num ; i++ ) {
1384 gsmBciPtrs[i] = &gsmBci[i];
1386 status = p.readInt32(&t);
1387 gsmBci[i].fromServiceId = (int) t;
1389 status = p.readInt32(&t);
1390 gsmBci[i].toServiceId = (int) t;
1392 status = p.readInt32(&t);
1393 gsmBci[i].fromCodeScheme = (int) t;
1395 status = p.readInt32(&t);
1396 gsmBci[i].toCodeScheme = (int) t;
1398 status = p.readInt32(&t);
1399 gsmBci[i].selected = (uint8_t) t;
1401 appendPrintBuf("%s [%d: fromServiceId=%d, toServiceId =%d, \
1402 fromCodeScheme=%d, toCodeScheme=%d, selected =%d]", printBuf, i,
1403 gsmBci[i].fromServiceId, gsmBci[i].toServiceId,
1404 gsmBci[i].fromCodeScheme, gsmBci[i].toCodeScheme,
1405 gsmBci[i].selected);
1409 if (status != NO_ERROR) {
1413 CALL_ONREQUEST(pRI->pCI->requestNumber,
1415 num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *),
1416 pRI, pRI->socket_id);
1419 memset(gsmBci, 0, num * sizeof(RIL_GSM_BroadcastSmsConfigInfo));
1420 memset(gsmBciPtrs, 0, num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *));
1427 invalidCommandBlock(pRI);
1432 dispatchCdmaBrSmsCnf(Parcel &p, RequestInfo *pRI) {
1437 status = p.readInt32(&num);
1438 if (status != NO_ERROR) {
1443 RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num];
1444 RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num];
1447 for (int i = 0 ; i < num ; i++ ) {
1448 cdmaBciPtrs[i] = &cdmaBci[i];
1450 status = p.readInt32(&t);
1451 cdmaBci[i].service_category = (int) t;
1453 status = p.readInt32(&t);
1454 cdmaBci[i].language = (int) t;
1456 status = p.readInt32(&t);
1457 cdmaBci[i].selected = (uint8_t) t;
1459 appendPrintBuf("%s [%d: service_category=%d, language =%d, \
1460 entries.bSelected =%d]", printBuf, i, cdmaBci[i].service_category,
1461 cdmaBci[i].language, cdmaBci[i].selected);
1465 if (status != NO_ERROR) {
1469 CALL_ONREQUEST(pRI->pCI->requestNumber,
1471 num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *),
1472 pRI, pRI->socket_id);
1475 memset(cdmaBci, 0, num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo));
1476 memset(cdmaBciPtrs, 0, num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *));
1483 invalidCommandBlock(pRI);
1487 static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI) {
1488 RIL_CDMA_SMS_WriteArgs rcsw;
1495 memset(&rcsw, 0, sizeof(rcsw));
1497 status = p.readInt32(&t);
1500 status = p.readInt32(&t);
1501 rcsw.message.uTeleserviceID = (int) t;
1503 status = p.read(&uct,sizeof(uct));
1504 rcsw.message.bIsServicePresent = (uint8_t) uct;
1506 status = p.readInt32(&t);
1507 rcsw.message.uServicecategory = (int) t;
1509 status = p.readInt32(&t);
1510 rcsw.message.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) t;
1512 status = p.readInt32(&t);
1513 rcsw.message.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) t;
1515 status = p.readInt32(&t);
1516 rcsw.message.sAddress.number_type = (RIL_CDMA_SMS_NumberType) t;
1518 status = p.readInt32(&t);
1519 rcsw.message.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) t;
1521 status = p.read(&uct,sizeof(uct));
1522 rcsw.message.sAddress.number_of_digits = (uint8_t) uct;
1524 for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_ADDRESS_MAX; digitCount ++) {
1525 status = p.read(&uct,sizeof(uct));
1526 rcsw.message.sAddress.digits[digitCount] = (uint8_t) uct;
1529 status = p.readInt32(&t);
1530 rcsw.message.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) t;
1532 status = p.read(&uct,sizeof(uct));
1533 rcsw.message.sSubAddress.odd = (uint8_t) uct;
1535 status = p.read(&uct,sizeof(uct));
1536 rcsw.message.sSubAddress.number_of_digits = (uint8_t) uct;
1538 for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_SUBADDRESS_MAX; digitCount ++) {
1539 status = p.read(&uct,sizeof(uct));
1540 rcsw.message.sSubAddress.digits[digitCount] = (uint8_t) uct;
1543 status = p.readInt32(&t);
1544 rcsw.message.uBearerDataLen = (int) t;
1546 for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_BEARER_DATA_MAX; digitCount ++) {
1547 status = p.read(&uct, sizeof(uct));
1548 rcsw.message.aBearerData[digitCount] = (uint8_t) uct;
1551 if (status != NO_ERROR) {
1556 appendPrintBuf("%sstatus=%d, message.uTeleserviceID=%d, message.bIsServicePresent=%d, \
1557 message.uServicecategory=%d, message.sAddress.digit_mode=%d, \
1558 message.sAddress.number_mode=%d, \
1559 message.sAddress.number_type=%d, ",
1560 printBuf, rcsw.status, rcsw.message.uTeleserviceID, rcsw.message.bIsServicePresent,
1561 rcsw.message.uServicecategory, rcsw.message.sAddress.digit_mode,
1562 rcsw.message.sAddress.number_mode,
1563 rcsw.message.sAddress.number_type);
1566 printRequest(pRI->token, pRI->pCI->requestNumber);
1568 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw),pRI, pRI->socket_id);
1571 memset(&rcsw, 0, sizeof(rcsw));
1577 invalidCommandBlock(pRI);
1582 // For backwards compatibility in RIL_REQUEST_SETUP_DATA_CALL.
1583 // Version 4 of the RIL interface adds a new PDP type parameter to support
1584 // IPv6 and dual-stack PDP contexts. When dealing with a previous version of
1585 // RIL, remove the parameter from the request.
1586 static void dispatchDataCall(Parcel& p, RequestInfo *pRI) {
1587 // In RIL v3, REQUEST_SETUP_DATA_CALL takes 6 parameters.
1588 const int numParamsRilV3 = 6;
1590 // The first bytes of the RIL parcel contain the request number and the
1591 // serial number - see processCommandBuffer(). Copy them over too.
1592 int pos = p.dataPosition();
1594 int numParams = p.readInt32();
1595 if (s_callbacks.version < 4 && numParams > numParamsRilV3) {
1597 p2.appendFrom(&p, 0, pos);
1598 p2.writeInt32(numParamsRilV3);
1599 for(int i = 0; i < numParamsRilV3; i++) {
1600 p2.writeString16(p.readString16());
1602 p2.setDataPosition(pos);
1603 dispatchStrings(p2, pRI);
1605 p.setDataPosition(pos);
1606 dispatchStrings(p, pRI);
1610 // For backwards compatibility with RILs that dont support RIL_REQUEST_VOICE_RADIO_TECH.
1611 // When all RILs handle this request, this function can be removed and
1612 // the request can be sent directly to the RIL using dispatchVoid.
1613 static void dispatchVoiceRadioTech(Parcel& p, RequestInfo *pRI) {
1614 RIL_RadioState state = CALL_ONSTATEREQUEST((RIL_SOCKET_ID)pRI->socket_id);
1616 if ((RADIO_STATE_UNAVAILABLE == state) || (RADIO_STATE_OFF == state)) {
1617 RIL_onRequestComplete(pRI, RIL_E_RADIO_NOT_AVAILABLE, NULL, 0);
1620 // RILs that support RADIO_STATE_ON should support this request.
1621 if (RADIO_STATE_ON == state) {
1622 dispatchVoid(p, pRI);
1626 // For Older RILs, that do not support RADIO_STATE_ON, assume that they
1627 // will not support this new request either and decode Voice Radio Technology
1629 voiceRadioTech = decodeVoiceRadioTechnology(state);
1631 if (voiceRadioTech < 0)
1632 RIL_onRequestComplete(pRI, RIL_E_GENERIC_FAILURE, NULL, 0);
1634 RIL_onRequestComplete(pRI, RIL_E_SUCCESS, &voiceRadioTech, sizeof(int));
1637 // For backwards compatibility in RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE:.
1638 // When all RILs handle this request, this function can be removed and
1639 // the request can be sent directly to the RIL using dispatchVoid.
1640 static void dispatchCdmaSubscriptionSource(Parcel& p, RequestInfo *pRI) {
1641 RIL_RadioState state = CALL_ONSTATEREQUEST((RIL_SOCKET_ID)pRI->socket_id);
1643 if ((RADIO_STATE_UNAVAILABLE == state) || (RADIO_STATE_OFF == state)) {
1644 RIL_onRequestComplete(pRI, RIL_E_RADIO_NOT_AVAILABLE, NULL, 0);
1647 // RILs that support RADIO_STATE_ON should support this request.
1648 if (RADIO_STATE_ON == state) {
1649 dispatchVoid(p, pRI);
1653 // For Older RILs, that do not support RADIO_STATE_ON, assume that they
1654 // will not support this new request either and decode CDMA Subscription Source
1656 cdmaSubscriptionSource = decodeCdmaSubscriptionSource(state);
1658 if (cdmaSubscriptionSource < 0)
1659 RIL_onRequestComplete(pRI, RIL_E_GENERIC_FAILURE, NULL, 0);
1661 RIL_onRequestComplete(pRI, RIL_E_SUCCESS, &cdmaSubscriptionSource, sizeof(int));
1664 static void dispatchSetInitialAttachApn(Parcel &p, RequestInfo *pRI)
1666 RIL_InitialAttachApn pf;
1670 memset(&pf, 0, sizeof(pf));
1672 pf.apn = strdupReadString(p);
1673 pf.protocol = strdupReadString(p);
1675 status = p.readInt32(&t);
1676 pf.authtype = (int) t;
1678 pf.username = strdupReadString(p);
1679 pf.password = strdupReadString(p);
1682 appendPrintBuf("%sapn=%s, protocol=%s, authtype=%d, username=%s, password=%s",
1683 printBuf, pf.apn, pf.protocol, pf.authtype, pf.username, pf.password);
1685 printRequest(pRI->token, pRI->pCI->requestNumber);
1687 if (status != NO_ERROR) {
1690 CALL_ONREQUEST(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI, pRI->socket_id);
1693 memsetString(pf.apn);
1694 memsetString(pf.protocol);
1695 memsetString(pf.username);
1696 memsetString(pf.password);
1705 memset(&pf, 0, sizeof(pf));
1710 invalidCommandBlock(pRI);
1714 static void dispatchNVReadItem(Parcel &p, RequestInfo *pRI) {
1715 RIL_NV_ReadItem nvri;
1719 memset(&nvri, 0, sizeof(nvri));
1721 status = p.readInt32(&t);
1722 nvri.itemID = (RIL_NV_Item) t;
1724 if (status != NO_ERROR) {
1729 appendPrintBuf("%snvri.itemID=%d, ", printBuf, nvri.itemID);
1732 printRequest(pRI->token, pRI->pCI->requestNumber);
1734 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI, pRI->socket_id);
1737 memset(&nvri, 0, sizeof(nvri));
1743 invalidCommandBlock(pRI);
1747 static void dispatchNVWriteItem(Parcel &p, RequestInfo *pRI) {
1748 RIL_NV_WriteItem nvwi;
1752 memset(&nvwi, 0, sizeof(nvwi));
1754 status = p.readInt32(&t);
1755 nvwi.itemID = (RIL_NV_Item) t;
1757 nvwi.value = strdupReadString(p);
1759 if (status != NO_ERROR || nvwi.value == NULL) {
1764 appendPrintBuf("%snvwi.itemID=%d, value=%s, ", printBuf, nvwi.itemID,
1768 printRequest(pRI->token, pRI->pCI->requestNumber);
1770 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI, pRI->socket_id);
1773 memsetString(nvwi.value);
1779 memset(&nvwi, 0, sizeof(nvwi));
1785 invalidCommandBlock(pRI);
1790 static void dispatchUiccSubscripton(Parcel &p, RequestInfo *pRI) {
1791 RIL_SelectUiccSub uicc_sub;
1794 memset(&uicc_sub, 0, sizeof(uicc_sub));
1796 status = p.readInt32(&t);
1797 if (status != NO_ERROR) {
1800 uicc_sub.slot = (int) t;
1802 status = p.readInt32(&t);
1803 if (status != NO_ERROR) {
1806 uicc_sub.app_index = (int) t;
1808 status = p.readInt32(&t);
1809 if (status != NO_ERROR) {
1812 uicc_sub.sub_type = (RIL_SubscriptionType) t;
1814 status = p.readInt32(&t);
1815 if (status != NO_ERROR) {
1818 uicc_sub.act_status = (RIL_UiccSubActStatus) t;
1821 appendPrintBuf("slot=%d, app_index=%d, act_status = %d", uicc_sub.slot, uicc_sub.app_index,
1822 uicc_sub.act_status);
1823 RLOGD("dispatchUiccSubscription, slot=%d, app_index=%d, act_status = %d", uicc_sub.slot,
1824 uicc_sub.app_index, uicc_sub.act_status);
1826 printRequest(pRI->token, pRI->pCI->requestNumber);
1828 CALL_ONREQUEST(pRI->pCI->requestNumber, &uicc_sub, sizeof(uicc_sub), pRI, pRI->socket_id);
1831 memset(&uicc_sub, 0, sizeof(uicc_sub));
1836 invalidCommandBlock(pRI);
1840 static void dispatchSimAuthentication(Parcel &p, RequestInfo *pRI)
1842 RIL_SimAuthentication pf;
1846 memset(&pf, 0, sizeof(pf));
1848 status = p.readInt32(&t);
1849 pf.authContext = (int) t;
1850 pf.authData = strdupReadString(p);
1851 pf.aid = strdupReadString(p);
1854 appendPrintBuf("authContext=%s, authData=%s, aid=%s", pf.authContext, pf.authData, pf.aid);
1856 printRequest(pRI->token, pRI->pCI->requestNumber);
1858 if (status != NO_ERROR) {
1861 CALL_ONREQUEST(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI, pRI->socket_id);
1864 memsetString(pf.authData);
1865 memsetString(pf.aid);
1872 memset(&pf, 0, sizeof(pf));
1877 invalidCommandBlock(pRI);
1881 static void dispatchDataProfile(Parcel &p, RequestInfo *pRI) {
1886 status = p.readInt32(&num);
1887 if (status != NO_ERROR) {
1892 RIL_DataProfileInfo dataProfiles[num];
1893 RIL_DataProfileInfo *dataProfilePtrs[num];
1896 for (int i = 0 ; i < num ; i++ ) {
1897 dataProfilePtrs[i] = &dataProfiles[i];
1899 status = p.readInt32(&t);
1900 dataProfiles[i].profileId = (int) t;
1902 dataProfiles[i].apn = strdupReadString(p);
1903 dataProfiles[i].protocol = strdupReadString(p);
1904 status = p.readInt32(&t);
1905 dataProfiles[i].authType = (int) t;
1907 dataProfiles[i].user = strdupReadString(p);
1908 dataProfiles[i].password = strdupReadString(p);
1910 status = p.readInt32(&t);
1911 dataProfiles[i].type = (int) t;
1913 status = p.readInt32(&t);
1914 dataProfiles[i].maxConnsTime = (int) t;
1915 status = p.readInt32(&t);
1916 dataProfiles[i].maxConns = (int) t;
1917 status = p.readInt32(&t);
1918 dataProfiles[i].waitTime = (int) t;
1920 status = p.readInt32(&t);
1921 dataProfiles[i].enabled = (int) t;
1923 appendPrintBuf("%s [%d: profileId=%d, apn =%s, protocol =%s, authType =%d, \
1924 user =%s, password =%s, type =%d, maxConnsTime =%d, maxConns =%d, \
1925 waitTime =%d, enabled =%d]", printBuf, i, dataProfiles[i].profileId,
1926 dataProfiles[i].apn, dataProfiles[i].protocol, dataProfiles[i].authType,
1927 dataProfiles[i].user, dataProfiles[i].password, dataProfiles[i].type,
1928 dataProfiles[i].maxConnsTime, dataProfiles[i].maxConns,
1929 dataProfiles[i].waitTime, dataProfiles[i].enabled);
1932 printRequest(pRI->token, pRI->pCI->requestNumber);
1934 if (status != NO_ERROR) {
1937 CALL_ONREQUEST(pRI->pCI->requestNumber,
1939 num * sizeof(RIL_DataProfileInfo *),
1940 pRI, pRI->socket_id);
1943 memset(dataProfiles, 0, num * sizeof(RIL_DataProfileInfo));
1944 memset(dataProfilePtrs, 0, num * sizeof(RIL_DataProfileInfo *));
1951 invalidCommandBlock(pRI);
1956 blockingWrite(int fd, const void *buffer, size_t len) {
1957 size_t writeOffset = 0;
1958 const uint8_t *toWrite;
1960 toWrite = (const uint8_t *)buffer;
1962 while (writeOffset < len) {
1965 written = write (fd, toWrite + writeOffset,
1967 } while (written < 0 && ((errno == EINTR) || (errno == EAGAIN)));
1970 writeOffset += written;
1971 } else { // written < 0
1972 RLOGE ("RIL Response: unexpected error on write errno:%d", errno);
1982 sendResponseRaw (const void *data, size_t dataSize, RIL_SOCKET_ID socket_id) {
1983 int fd = s_ril_param_socket.fdCommand;
1986 pthread_mutex_t * writeMutexHook = &s_writeMutex;
1988 RLOGE("Send Response to %s", rilSocketIdToString(socket_id));
1990 #if (SIM_COUNT >= 2)
1991 if (socket_id == RIL_SOCKET_2) {
1992 fd = s_ril_param_socket2.fdCommand;
1993 writeMutexHook = &s_writeMutex_socket2;
1995 #if (SIM_COUNT >= 3)
1996 else if (socket_id == RIL_SOCKET_3) {
1997 fd = s_ril_param_socket3.fdCommand;
1998 writeMutexHook = &s_writeMutex_socket3;
2001 #if (SIM_COUNT >= 4)
2002 else if (socket_id == RIL_SOCKET_4) {
2003 fd = s_ril_param_socket4.fdCommand;
2004 writeMutexHook = &s_writeMutex_socket4;
2012 if (dataSize > MAX_COMMAND_BYTES) {
2013 RLOGE("RIL: packet larger than %u (%u)",
2014 MAX_COMMAND_BYTES, (unsigned int )dataSize);
2019 pthread_mutex_lock(writeMutexHook);
2021 header = htonl(dataSize);
2023 ret = blockingWrite(fd, (void *)&header, sizeof(header));
2026 pthread_mutex_unlock(writeMutexHook);
2030 ret = blockingWrite(fd, data, dataSize);
2033 pthread_mutex_unlock(writeMutexHook);
2037 pthread_mutex_unlock(writeMutexHook);
2043 sendResponse (Parcel &p, RIL_SOCKET_ID socket_id) {
2045 return sendResponseRaw(p.data(), p.dataSize(), socket_id);
2048 /** response is an int* pointing to an array of ints */
2051 responseInts(Parcel &p, void *response, size_t responselen) {
2054 if (response == NULL && responselen != 0) {
2055 RLOGE("invalid response: NULL");
2056 return RIL_ERRNO_INVALID_RESPONSE;
2058 if (responselen % sizeof(int) != 0) {
2059 RLOGE("responseInts: invalid response length %d expected multiple of %d\n",
2060 (int)responselen, (int)sizeof(int));
2061 return RIL_ERRNO_INVALID_RESPONSE;
2064 int *p_int = (int *) response;
2066 numInts = responselen / sizeof(int);
2067 p.writeInt32 (numInts);
2071 for (int i = 0 ; i < numInts ; i++) {
2072 appendPrintBuf("%s%d,", printBuf, p_int[i]);
2073 p.writeInt32(p_int[i]);
2081 /** response is a char **, pointing to an array of char *'s
2082 The parcel will begin with the version */
2083 static int responseStringsWithVersion(int version, Parcel &p, void *response, size_t responselen) {
2084 p.writeInt32(version);
2085 return responseStrings(p, response, responselen);
2088 /** response is a char **, pointing to an array of char *'s */
2089 static int responseStrings(Parcel &p, void *response, size_t responselen) {
2092 if (response == NULL && responselen != 0) {
2093 RLOGE("invalid response: NULL");
2094 return RIL_ERRNO_INVALID_RESPONSE;
2096 if (responselen % sizeof(char *) != 0) {
2097 RLOGE("responseStrings: invalid response length %d expected multiple of %d\n",
2098 (int)responselen, (int)sizeof(char *));
2099 return RIL_ERRNO_INVALID_RESPONSE;
2102 if (response == NULL) {
2105 char **p_cur = (char **) response;
2107 numStrings = responselen / sizeof(char *);
2108 p.writeInt32 (numStrings);
2112 for (int i = 0 ; i < numStrings ; i++) {
2113 appendPrintBuf("%s%s,", printBuf, (char*)p_cur[i]);
2114 writeStringToParcel (p, p_cur[i]);
2124 * NULL strings are accepted
2125 * FIXME currently ignores responselen
2127 static int responseString(Parcel &p, void *response, size_t responselen) {
2128 /* one string only */
2130 appendPrintBuf("%s%s", printBuf, (char*)response);
2133 writeStringToParcel(p, (const char *)response);
2138 static int responseVoid(Parcel &p, void *response, size_t responselen) {
2144 static int responseCallList(Parcel &p, void *response, size_t responselen) {
2147 if (response == NULL && responselen != 0) {
2148 RLOGE("invalid response: NULL");
2149 return RIL_ERRNO_INVALID_RESPONSE;
2152 if (responselen % sizeof (RIL_Call *) != 0) {
2153 RLOGE("responseCallList: invalid response length %d expected multiple of %d\n",
2154 (int)responselen, (int)sizeof (RIL_Call *));
2155 return RIL_ERRNO_INVALID_RESPONSE;
2159 /* number of call info's */
2160 num = responselen / sizeof(RIL_Call *);
2163 for (int i = 0 ; i < num ; i++) {
2164 RIL_Call *p_cur = ((RIL_Call **) response)[i];
2165 /* each call info */
2166 p.writeInt32(p_cur->state);
2167 p.writeInt32(p_cur->index);
2168 p.writeInt32(p_cur->toa);
2169 p.writeInt32(p_cur->isMpty);
2170 p.writeInt32(p_cur->isMT);
2171 p.writeInt32(p_cur->als);
2172 p.writeInt32(p_cur->isVoice);
2173 p.writeInt32(p_cur->isVoicePrivacy);
2174 writeStringToParcel(p, p_cur->number);
2175 p.writeInt32(p_cur->numberPresentation);
2176 writeStringToParcel(p, p_cur->name);
2177 p.writeInt32(p_cur->namePresentation);
2178 // Remove when partners upgrade to version 3
2179 if ((s_callbacks.version < 3) || (p_cur->uusInfo == NULL || p_cur->uusInfo->uusData == NULL)) {
2180 p.writeInt32(0); /* UUS Information is absent */
2182 RIL_UUS_Info *uusInfo = p_cur->uusInfo;
2183 p.writeInt32(1); /* UUS Information is present */
2184 p.writeInt32(uusInfo->uusType);
2185 p.writeInt32(uusInfo->uusDcs);
2186 p.writeInt32(uusInfo->uusLength);
2187 p.write(uusInfo->uusData, uusInfo->uusLength);
2189 appendPrintBuf("%s[id=%d,%s,toa=%d,",
2192 callStateToString(p_cur->state),
2194 appendPrintBuf("%s%s,%s,als=%d,%s,%s,",
2196 (p_cur->isMpty)?"conf":"norm",
2197 (p_cur->isMT)?"mt":"mo",
2199 (p_cur->isVoice)?"voc":"nonvoc",
2200 (p_cur->isVoicePrivacy)?"evp":"noevp");
2201 appendPrintBuf("%s%s,cli=%d,name='%s',%d]",
2204 p_cur->numberPresentation,
2206 p_cur->namePresentation);
2214 static int responseSMS(Parcel &p, void *response, size_t responselen) {
2215 if (response == NULL) {
2216 RLOGE("invalid response: NULL");
2217 return RIL_ERRNO_INVALID_RESPONSE;
2220 if (responselen != sizeof (RIL_SMS_Response) ) {
2221 RLOGE("invalid response length %d expected %d",
2222 (int)responselen, (int)sizeof (RIL_SMS_Response));
2223 return RIL_ERRNO_INVALID_RESPONSE;
2226 RIL_SMS_Response *p_cur = (RIL_SMS_Response *) response;
2228 p.writeInt32(p_cur->messageRef);
2229 writeStringToParcel(p, p_cur->ackPDU);
2230 p.writeInt32(p_cur->errorCode);
2233 appendPrintBuf("%s%d,%s,%d", printBuf, p_cur->messageRef,
2234 (char*)p_cur->ackPDU, p_cur->errorCode);
2240 static int responseDataCallListV4(Parcel &p, void *response, size_t responselen)
2242 if (response == NULL && responselen != 0) {
2243 RLOGE("invalid response: NULL");
2244 return RIL_ERRNO_INVALID_RESPONSE;
2247 if (responselen % sizeof(RIL_Data_Call_Response_v4) != 0) {
2248 RLOGE("responseDataCallListV4: invalid response length %d expected multiple of %d",
2249 (int)responselen, (int)sizeof(RIL_Data_Call_Response_v4));
2250 return RIL_ERRNO_INVALID_RESPONSE;
2256 int num = responselen / sizeof(RIL_Data_Call_Response_v4);
2259 RIL_Data_Call_Response_v4 *p_cur = (RIL_Data_Call_Response_v4 *) response;
2262 for (i = 0; i < num; i++) {
2263 p.writeInt32(p_cur[i].cid);
2264 p.writeInt32(p_cur[i].active);
2265 writeStringToParcel(p, p_cur[i].type);
2266 // apn is not used, so don't send.
2267 writeStringToParcel(p, p_cur[i].address);
2268 appendPrintBuf("%s[cid=%d,%s,%s,%s],", printBuf,
2270 (p_cur[i].active==0)?"down":"up",
2271 (char*)p_cur[i].type,
2272 (char*)p_cur[i].address);
2280 static int responseDataCallListV6(Parcel &p, void *response, size_t responselen)
2282 if (response == NULL && responselen != 0) {
2283 RLOGE("invalid response: NULL");
2284 return RIL_ERRNO_INVALID_RESPONSE;
2287 if (responselen % sizeof(RIL_Data_Call_Response_v6) != 0) {
2288 RLOGE("responseDataCallListV6: invalid response length %d expected multiple of %d",
2289 (int)responselen, (int)sizeof(RIL_Data_Call_Response_v6));
2290 return RIL_ERRNO_INVALID_RESPONSE;
2296 int num = responselen / sizeof(RIL_Data_Call_Response_v6);
2299 RIL_Data_Call_Response_v6 *p_cur = (RIL_Data_Call_Response_v6 *) response;
2302 for (i = 0; i < num; i++) {
2303 p.writeInt32((int)p_cur[i].status);
2304 p.writeInt32(p_cur[i].suggestedRetryTime);
2305 p.writeInt32(p_cur[i].cid);
2306 p.writeInt32(p_cur[i].active);
2307 writeStringToParcel(p, p_cur[i].type);
2308 writeStringToParcel(p, p_cur[i].ifname);
2309 writeStringToParcel(p, p_cur[i].addresses);
2310 writeStringToParcel(p, p_cur[i].dnses);
2311 writeStringToParcel(p, p_cur[i].gateways);
2312 appendPrintBuf("%s[status=%d,retry=%d,cid=%d,%s,%s,%s,%s,%s,%s],", printBuf,
2314 p_cur[i].suggestedRetryTime,
2316 (p_cur[i].active==0)?"down":"up",
2317 (char*)p_cur[i].type,
2318 (char*)p_cur[i].ifname,
2319 (char*)p_cur[i].addresses,
2320 (char*)p_cur[i].dnses,
2321 (char*)p_cur[i].gateways);
2329 static int responseDataCallList(Parcel &p, void *response, size_t responselen)
2331 if (s_callbacks.version < 5) {
2332 RLOGD("responseDataCallList: v4");
2333 return responseDataCallListV4(p, response, responselen);
2335 if (response == NULL && responselen != 0) {
2336 RLOGE("invalid response: NULL");
2337 return RIL_ERRNO_INVALID_RESPONSE;
2340 // Support v6 or v9 with new rils
2341 if (responselen % sizeof(RIL_Data_Call_Response_v6) == 0) {
2342 RLOGD("responseDataCallList: v6");
2343 return responseDataCallListV6(p, response, responselen);
2346 if (responselen % sizeof(RIL_Data_Call_Response_v9) != 0) {
2347 RLOGE("responseDataCallList: invalid response length %d expected multiple of %d",
2348 (int)responselen, (int)sizeof(RIL_Data_Call_Response_v9));
2349 return RIL_ERRNO_INVALID_RESPONSE;
2355 int num = responselen / sizeof(RIL_Data_Call_Response_v9);
2358 RIL_Data_Call_Response_v9 *p_cur = (RIL_Data_Call_Response_v9 *) response;
2361 for (i = 0; i < num; i++) {
2362 p.writeInt32((int)p_cur[i].status);
2363 p.writeInt32(p_cur[i].suggestedRetryTime);
2364 p.writeInt32(p_cur[i].cid);
2365 p.writeInt32(p_cur[i].active);
2366 writeStringToParcel(p, p_cur[i].type);
2367 writeStringToParcel(p, p_cur[i].ifname);
2368 writeStringToParcel(p, p_cur[i].addresses);
2369 writeStringToParcel(p, p_cur[i].dnses);
2370 writeStringToParcel(p, p_cur[i].gateways);
2371 writeStringToParcel(p, p_cur[i].pcscf);
2372 appendPrintBuf("%s[status=%d,retry=%d,cid=%d,%s,%s,%s,%s,%s,%s,%s],", printBuf,
2374 p_cur[i].suggestedRetryTime,
2376 (p_cur[i].active==0)?"down":"up",
2377 (char*)p_cur[i].type,
2378 (char*)p_cur[i].ifname,
2379 (char*)p_cur[i].addresses,
2380 (char*)p_cur[i].dnses,
2381 (char*)p_cur[i].gateways,
2382 (char*)p_cur[i].pcscf);
2391 static int responseSetupDataCall(Parcel &p, void *response, size_t responselen)
2393 if (s_callbacks.version < 5) {
2394 return responseStringsWithVersion(s_callbacks.version, p, response, responselen);
2396 return responseDataCallList(p, response, responselen);
2400 static int responseRaw(Parcel &p, void *response, size_t responselen) {
2401 if (response == NULL && responselen != 0) {
2402 RLOGE("invalid response: NULL with responselen != 0");
2403 return RIL_ERRNO_INVALID_RESPONSE;
2406 // The java code reads -1 size as null byte array
2407 if (response == NULL) {
2410 p.writeInt32(responselen);
2411 p.write(response, responselen);
2418 static int responseSIM_IO(Parcel &p, void *response, size_t responselen) {
2419 if (response == NULL) {
2420 RLOGE("invalid response: NULL");
2421 return RIL_ERRNO_INVALID_RESPONSE;
2424 if (responselen != sizeof (RIL_SIM_IO_Response) ) {
2425 RLOGE("invalid response length was %d expected %d",
2426 (int)responselen, (int)sizeof (RIL_SIM_IO_Response));
2427 return RIL_ERRNO_INVALID_RESPONSE;
2430 RIL_SIM_IO_Response *p_cur = (RIL_SIM_IO_Response *) response;
2431 p.writeInt32(p_cur->sw1);
2432 p.writeInt32(p_cur->sw2);
2433 writeStringToParcel(p, p_cur->simResponse);
2436 appendPrintBuf("%ssw1=0x%X,sw2=0x%X,%s", printBuf, p_cur->sw1, p_cur->sw2,
2437 (char*)p_cur->simResponse);
2444 static int responseCallForwards(Parcel &p, void *response, size_t responselen) {
2447 if (response == NULL && responselen != 0) {
2448 RLOGE("invalid response: NULL");
2449 return RIL_ERRNO_INVALID_RESPONSE;
2452 if (responselen % sizeof(RIL_CallForwardInfo *) != 0) {
2453 RLOGE("responseCallForwards: invalid response length %d expected multiple of %d",
2454 (int)responselen, (int)sizeof(RIL_CallForwardInfo *));
2455 return RIL_ERRNO_INVALID_RESPONSE;
2458 /* number of call info's */
2459 num = responselen / sizeof(RIL_CallForwardInfo *);
2463 for (int i = 0 ; i < num ; i++) {
2464 RIL_CallForwardInfo *p_cur = ((RIL_CallForwardInfo **) response)[i];
2466 p.writeInt32(p_cur->status);
2467 p.writeInt32(p_cur->reason);
2468 p.writeInt32(p_cur->serviceClass);
2469 p.writeInt32(p_cur->toa);
2470 writeStringToParcel(p, p_cur->number);
2471 p.writeInt32(p_cur->timeSeconds);
2472 appendPrintBuf("%s[%s,reason=%d,cls=%d,toa=%d,%s,tout=%d],", printBuf,
2473 (p_cur->status==1)?"enable":"disable",
2474 p_cur->reason, p_cur->serviceClass, p_cur->toa,
2475 (char*)p_cur->number,
2476 p_cur->timeSeconds);
2484 static int responseSsn(Parcel &p, void *response, size_t responselen) {
2485 if (response == NULL) {
2486 RLOGE("invalid response: NULL");
2487 return RIL_ERRNO_INVALID_RESPONSE;
2490 if (responselen != sizeof(RIL_SuppSvcNotification)) {
2491 RLOGE("invalid response length was %d expected %d",
2492 (int)responselen, (int)sizeof (RIL_SuppSvcNotification));
2493 return RIL_ERRNO_INVALID_RESPONSE;
2496 RIL_SuppSvcNotification *p_cur = (RIL_SuppSvcNotification *) response;
2497 p.writeInt32(p_cur->notificationType);
2498 p.writeInt32(p_cur->code);
2499 p.writeInt32(p_cur->index);
2500 p.writeInt32(p_cur->type);
2501 writeStringToParcel(p, p_cur->number);
2504 appendPrintBuf("%s%s,code=%d,id=%d,type=%d,%s", printBuf,
2505 (p_cur->notificationType==0)?"mo":"mt",
2506 p_cur->code, p_cur->index, p_cur->type,
2507 (char*)p_cur->number);
2513 static int responseCellList(Parcel &p, void *response, size_t responselen) {
2516 if (response == NULL && responselen != 0) {
2517 RLOGE("invalid response: NULL");
2518 return RIL_ERRNO_INVALID_RESPONSE;
2521 if (responselen % sizeof (RIL_NeighboringCell *) != 0) {
2522 RLOGE("responseCellList: invalid response length %d expected multiple of %d\n",
2523 (int)responselen, (int)sizeof (RIL_NeighboringCell *));
2524 return RIL_ERRNO_INVALID_RESPONSE;
2528 /* number of records */
2529 num = responselen / sizeof(RIL_NeighboringCell *);
2532 for (int i = 0 ; i < num ; i++) {
2533 RIL_NeighboringCell *p_cur = ((RIL_NeighboringCell **) response)[i];
2535 p.writeInt32(p_cur->rssi);
2536 writeStringToParcel (p, p_cur->cid);
2538 appendPrintBuf("%s[cid=%s,rssi=%d],", printBuf,
2539 p_cur->cid, p_cur->rssi);
2548 * Marshall the signalInfoRecord into the parcel if it exists.
2550 static void marshallSignalInfoRecord(Parcel &p,
2551 RIL_CDMA_SignalInfoRecord &p_signalInfoRecord) {
2552 p.writeInt32(p_signalInfoRecord.isPresent);
2553 p.writeInt32(p_signalInfoRecord.signalType);
2554 p.writeInt32(p_signalInfoRecord.alertPitch);
2555 p.writeInt32(p_signalInfoRecord.signal);
2558 static int responseCdmaInformationRecords(Parcel &p,
2559 void *response, size_t responselen) {
2561 char* string8 = NULL;
2563 RIL_CDMA_InformationRecord *infoRec;
2565 if (response == NULL && responselen != 0) {
2566 RLOGE("invalid response: NULL");
2567 return RIL_ERRNO_INVALID_RESPONSE;
2570 if (responselen != sizeof (RIL_CDMA_InformationRecords)) {
2571 RLOGE("responseCdmaInformationRecords: invalid response length %d expected multiple of %d\n",
2572 (int)responselen, (int)sizeof (RIL_CDMA_InformationRecords *));
2573 return RIL_ERRNO_INVALID_RESPONSE;
2576 RIL_CDMA_InformationRecords *p_cur =
2577 (RIL_CDMA_InformationRecords *) response;
2578 num = MIN(p_cur->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
2583 for (int i = 0 ; i < num ; i++) {
2584 infoRec = &p_cur->infoRec[i];
2585 p.writeInt32(infoRec->name);
2586 switch (infoRec->name) {
2587 case RIL_CDMA_DISPLAY_INFO_REC:
2588 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC:
2589 if (infoRec->rec.display.alpha_len >
2590 CDMA_ALPHA_INFO_BUFFER_LENGTH) {
2591 RLOGE("invalid display info response length %d \
2592 expected not more than %d\n",
2593 (int)infoRec->rec.display.alpha_len,
2594 CDMA_ALPHA_INFO_BUFFER_LENGTH);
2595 return RIL_ERRNO_INVALID_RESPONSE;
2597 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1)
2599 for (int i = 0 ; i < infoRec->rec.display.alpha_len ; i++) {
2600 string8[i] = infoRec->rec.display.alpha_buf[i];
2602 string8[(int)infoRec->rec.display.alpha_len] = '\0';
2603 writeStringToParcel(p, (const char*)string8);
2607 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
2608 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
2609 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC:
2610 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
2611 RLOGE("invalid display info response length %d \
2612 expected not more than %d\n",
2613 (int)infoRec->rec.number.len,
2614 CDMA_NUMBER_INFO_BUFFER_LENGTH);
2615 return RIL_ERRNO_INVALID_RESPONSE;
2617 string8 = (char*) malloc((infoRec->rec.number.len + 1)
2619 for (int i = 0 ; i < infoRec->rec.number.len; i++) {
2620 string8[i] = infoRec->rec.number.buf[i];
2622 string8[(int)infoRec->rec.number.len] = '\0';
2623 writeStringToParcel(p, (const char*)string8);
2626 p.writeInt32(infoRec->rec.number.number_type);
2627 p.writeInt32(infoRec->rec.number.number_plan);
2628 p.writeInt32(infoRec->rec.number.pi);
2629 p.writeInt32(infoRec->rec.number.si);
2631 case RIL_CDMA_SIGNAL_INFO_REC:
2632 p.writeInt32(infoRec->rec.signal.isPresent);
2633 p.writeInt32(infoRec->rec.signal.signalType);
2634 p.writeInt32(infoRec->rec.signal.alertPitch);
2635 p.writeInt32(infoRec->rec.signal.signal);
2637 appendPrintBuf("%sisPresent=%X, signalType=%X, \
2638 alertPitch=%X, signal=%X, ",
2639 printBuf, (int)infoRec->rec.signal.isPresent,
2640 (int)infoRec->rec.signal.signalType,
2641 (int)infoRec->rec.signal.alertPitch,
2642 (int)infoRec->rec.signal.signal);
2645 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC:
2646 if (infoRec->rec.redir.redirectingNumber.len >
2647 CDMA_NUMBER_INFO_BUFFER_LENGTH) {
2648 RLOGE("invalid display info response length %d \
2649 expected not more than %d\n",
2650 (int)infoRec->rec.redir.redirectingNumber.len,
2651 CDMA_NUMBER_INFO_BUFFER_LENGTH);
2652 return RIL_ERRNO_INVALID_RESPONSE;
2654 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber
2655 .len + 1) * sizeof(char) );
2657 i < infoRec->rec.redir.redirectingNumber.len;
2659 string8[i] = infoRec->rec.redir.redirectingNumber.buf[i];
2661 string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0';
2662 writeStringToParcel(p, (const char*)string8);
2665 p.writeInt32(infoRec->rec.redir.redirectingNumber.number_type);
2666 p.writeInt32(infoRec->rec.redir.redirectingNumber.number_plan);
2667 p.writeInt32(infoRec->rec.redir.redirectingNumber.pi);
2668 p.writeInt32(infoRec->rec.redir.redirectingNumber.si);
2669 p.writeInt32(infoRec->rec.redir.redirectingReason);
2671 case RIL_CDMA_LINE_CONTROL_INFO_REC:
2672 p.writeInt32(infoRec->rec.lineCtrl.lineCtrlPolarityIncluded);
2673 p.writeInt32(infoRec->rec.lineCtrl.lineCtrlToggle);
2674 p.writeInt32(infoRec->rec.lineCtrl.lineCtrlReverse);
2675 p.writeInt32(infoRec->rec.lineCtrl.lineCtrlPowerDenial);
2677 appendPrintBuf("%slineCtrlPolarityIncluded=%d, \
2678 lineCtrlToggle=%d, lineCtrlReverse=%d, \
2679 lineCtrlPowerDenial=%d, ", printBuf,
2680 (int)infoRec->rec.lineCtrl.lineCtrlPolarityIncluded,
2681 (int)infoRec->rec.lineCtrl.lineCtrlToggle,
2682 (int)infoRec->rec.lineCtrl.lineCtrlReverse,
2683 (int)infoRec->rec.lineCtrl.lineCtrlPowerDenial);
2686 case RIL_CDMA_T53_CLIR_INFO_REC:
2687 p.writeInt32((int)(infoRec->rec.clir.cause));
2689 appendPrintBuf("%scause%d", printBuf, infoRec->rec.clir.cause);
2692 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC:
2693 p.writeInt32(infoRec->rec.audioCtrl.upLink);
2694 p.writeInt32(infoRec->rec.audioCtrl.downLink);
2696 appendPrintBuf("%supLink=%d, downLink=%d, ", printBuf,
2697 infoRec->rec.audioCtrl.upLink,
2698 infoRec->rec.audioCtrl.downLink);
2701 case RIL_CDMA_T53_RELEASE_INFO_REC:
2702 // TODO(Moto): See David Krause, he has the answer:)
2703 RLOGE("RIL_CDMA_T53_RELEASE_INFO_REC: return INVALID_RESPONSE");
2704 return RIL_ERRNO_INVALID_RESPONSE;
2706 RLOGE("Incorrect name value");
2707 return RIL_ERRNO_INVALID_RESPONSE;
2715 static int responseRilSignalStrength(Parcel &p,
2716 void *response, size_t responselen) {
2717 if (response == NULL && responselen != 0) {
2718 RLOGE("invalid response: NULL");
2719 return RIL_ERRNO_INVALID_RESPONSE;
2722 if (responselen >= sizeof (RIL_SignalStrength_v5)) {
2723 RIL_SignalStrength_v10 *p_cur = ((RIL_SignalStrength_v10 *) response);
2725 p.writeInt32(p_cur->GW_SignalStrength.signalStrength);
2726 p.writeInt32(p_cur->GW_SignalStrength.bitErrorRate);
2727 p.writeInt32(p_cur->CDMA_SignalStrength.dbm);
2728 p.writeInt32(p_cur->CDMA_SignalStrength.ecio);
2729 p.writeInt32(p_cur->EVDO_SignalStrength.dbm);
2730 p.writeInt32(p_cur->EVDO_SignalStrength.ecio);
2731 p.writeInt32(p_cur->EVDO_SignalStrength.signalNoiseRatio);
2732 if (responselen >= sizeof (RIL_SignalStrength_v6)) {
2734 * Fixup LTE for backwards compatibility
2736 if (s_callbacks.version <= 6) {
2737 // signalStrength: -1 -> 99
2738 if (p_cur->LTE_SignalStrength.signalStrength == -1) {
2739 p_cur->LTE_SignalStrength.signalStrength = 99;
2741 // rsrp: -1 -> INT_MAX all other negative value to positive.
2743 if (p_cur->LTE_SignalStrength.rsrp == -1) {
2744 p_cur->LTE_SignalStrength.rsrp = INT_MAX;
2745 } else if (p_cur->LTE_SignalStrength.rsrp < -1) {
2746 p_cur->LTE_SignalStrength.rsrp = -p_cur->LTE_SignalStrength.rsrp;
2748 // rsrq: -1 -> INT_MAX
2749 if (p_cur->LTE_SignalStrength.rsrq == -1) {
2750 p_cur->LTE_SignalStrength.rsrq = INT_MAX;
2752 // Not remapping rssnr is already using INT_MAX
2754 // cqi: -1 -> INT_MAX
2755 if (p_cur->LTE_SignalStrength.cqi == -1) {
2756 p_cur->LTE_SignalStrength.cqi = INT_MAX;
2759 p.writeInt32(p_cur->LTE_SignalStrength.signalStrength);
2760 p.writeInt32(p_cur->LTE_SignalStrength.rsrp);
2761 p.writeInt32(p_cur->LTE_SignalStrength.rsrq);
2762 p.writeInt32(p_cur->LTE_SignalStrength.rssnr);
2763 p.writeInt32(p_cur->LTE_SignalStrength.cqi);
2764 if (responselen >= sizeof (RIL_SignalStrength_v10)) {
2765 p.writeInt32(p_cur->TD_SCDMA_SignalStrength.rscp);
2767 p.writeInt32(INT_MAX);
2771 p.writeInt32(INT_MAX);
2772 p.writeInt32(INT_MAX);
2773 p.writeInt32(INT_MAX);
2774 p.writeInt32(INT_MAX);
2775 p.writeInt32(INT_MAX);
2779 appendPrintBuf("%s[signalStrength=%d,bitErrorRate=%d,\
2780 CDMA_SS.dbm=%d,CDMA_SSecio=%d,\
2781 EVDO_SS.dbm=%d,EVDO_SS.ecio=%d,\
2782 EVDO_SS.signalNoiseRatio=%d,\
2783 LTE_SS.signalStrength=%d,LTE_SS.rsrp=%d,LTE_SS.rsrq=%d,\
2784 LTE_SS.rssnr=%d,LTE_SS.cqi=%d,TDSCDMA_SS.rscp=%d]",
2786 p_cur->GW_SignalStrength.signalStrength,
2787 p_cur->GW_SignalStrength.bitErrorRate,
2788 p_cur->CDMA_SignalStrength.dbm,
2789 p_cur->CDMA_SignalStrength.ecio,
2790 p_cur->EVDO_SignalStrength.dbm,
2791 p_cur->EVDO_SignalStrength.ecio,
2792 p_cur->EVDO_SignalStrength.signalNoiseRatio,
2793 p_cur->LTE_SignalStrength.signalStrength,
2794 p_cur->LTE_SignalStrength.rsrp,
2795 p_cur->LTE_SignalStrength.rsrq,
2796 p_cur->LTE_SignalStrength.rssnr,
2797 p_cur->LTE_SignalStrength.cqi,
2798 p_cur->TD_SCDMA_SignalStrength.rscp);
2802 RLOGE("invalid response length");
2803 return RIL_ERRNO_INVALID_RESPONSE;
2809 static int responseCallRing(Parcel &p, void *response, size_t responselen) {
2810 if ((response == NULL) || (responselen == 0)) {
2811 return responseVoid(p, response, responselen);
2813 return responseCdmaSignalInfoRecord(p, response, responselen);
2817 static int responseCdmaSignalInfoRecord(Parcel &p, void *response, size_t responselen) {
2818 if (response == NULL || responselen == 0) {
2819 RLOGE("invalid response: NULL");
2820 return RIL_ERRNO_INVALID_RESPONSE;
2823 if (responselen != sizeof (RIL_CDMA_SignalInfoRecord)) {
2824 RLOGE("invalid response length %d expected sizeof (RIL_CDMA_SignalInfoRecord) of %d\n",
2825 (int)responselen, (int)sizeof (RIL_CDMA_SignalInfoRecord));
2826 return RIL_ERRNO_INVALID_RESPONSE;
2831 RIL_CDMA_SignalInfoRecord *p_cur = ((RIL_CDMA_SignalInfoRecord *) response);
2832 marshallSignalInfoRecord(p, *p_cur);
2834 appendPrintBuf("%s[isPresent=%d,signalType=%d,alertPitch=%d\
2846 static int responseCdmaCallWaiting(Parcel &p, void *response,
2847 size_t responselen) {
2848 if (response == NULL && responselen != 0) {
2849 RLOGE("invalid response: NULL");
2850 return RIL_ERRNO_INVALID_RESPONSE;
2853 if (responselen < sizeof(RIL_CDMA_CallWaiting_v6)) {
2854 RLOGW("Upgrade to ril version %d\n", RIL_VERSION);
2857 RIL_CDMA_CallWaiting_v6 *p_cur = ((RIL_CDMA_CallWaiting_v6 *) response);
2859 writeStringToParcel(p, p_cur->number);
2860 p.writeInt32(p_cur->numberPresentation);
2861 writeStringToParcel(p, p_cur->name);
2862 marshallSignalInfoRecord(p, p_cur->signalInfoRecord);
2864 if (responselen >= sizeof(RIL_CDMA_CallWaiting_v6)) {
2865 p.writeInt32(p_cur->number_type);
2866 p.writeInt32(p_cur->number_plan);
2873 appendPrintBuf("%snumber=%s,numberPresentation=%d, name=%s,\
2874 signalInfoRecord[isPresent=%d,signalType=%d,alertPitch=%d\
2875 signal=%d,number_type=%d,number_plan=%d]",
2878 p_cur->numberPresentation,
2880 p_cur->signalInfoRecord.isPresent,
2881 p_cur->signalInfoRecord.signalType,
2882 p_cur->signalInfoRecord.alertPitch,
2883 p_cur->signalInfoRecord.signal,
2885 p_cur->number_plan);
2891 static int responseSimRefresh(Parcel &p, void *response, size_t responselen) {
2892 if (response == NULL && responselen != 0) {
2893 RLOGE("responseSimRefresh: invalid response: NULL");
2894 return RIL_ERRNO_INVALID_RESPONSE;
2898 if (s_callbacks.version == 7) {
2899 RIL_SimRefreshResponse_v7 *p_cur = ((RIL_SimRefreshResponse_v7 *) response);
2900 p.writeInt32(p_cur->result);
2901 p.writeInt32(p_cur->ef_id);
2902 writeStringToParcel(p, p_cur->aid);
2904 appendPrintBuf("%sresult=%d, ef_id=%d, aid=%s",
2910 int *p_cur = ((int *) response);
2911 p.writeInt32(p_cur[0]);
2912 p.writeInt32(p_cur[1]);
2913 writeStringToParcel(p, NULL);
2915 appendPrintBuf("%sresult=%d, ef_id=%d",
2925 static int responseCellInfoList(Parcel &p, void *response, size_t responselen)
2927 if (response == NULL && responselen != 0) {
2928 RLOGE("invalid response: NULL");
2929 return RIL_ERRNO_INVALID_RESPONSE;
2932 if (responselen % sizeof(RIL_CellInfo) != 0) {
2933 RLOGE("responseCellInfoList: invalid response length %d expected multiple of %d",
2934 (int)responselen, (int)sizeof(RIL_CellInfo));
2935 return RIL_ERRNO_INVALID_RESPONSE;
2938 int num = responselen / sizeof(RIL_CellInfo);
2941 RIL_CellInfo *p_cur = (RIL_CellInfo *) response;
2944 for (i = 0; i < num; i++) {
2945 appendPrintBuf("%s[%d: type=%d,registered=%d,timeStampType=%d,timeStamp=%lld", printBuf, i,
2946 p_cur->cellInfoType, p_cur->registered, p_cur->timeStampType, p_cur->timeStamp);
2947 p.writeInt32((int)p_cur->cellInfoType);
2948 p.writeInt32(p_cur->registered);
2949 p.writeInt32(p_cur->timeStampType);
2950 p.writeInt64(p_cur->timeStamp);
2951 switch(p_cur->cellInfoType) {
2952 case RIL_CELL_INFO_TYPE_GSM: {
2953 appendPrintBuf("%s GSM id: mcc=%d,mnc=%d,lac=%d,cid=%d,", printBuf,
2954 p_cur->CellInfo.gsm.cellIdentityGsm.mcc,
2955 p_cur->CellInfo.gsm.cellIdentityGsm.mnc,
2956 p_cur->CellInfo.gsm.cellIdentityGsm.lac,
2957 p_cur->CellInfo.gsm.cellIdentityGsm.cid);
2958 appendPrintBuf("%s gsmSS: ss=%d,ber=%d],", printBuf,
2959 p_cur->CellInfo.gsm.signalStrengthGsm.signalStrength,
2960 p_cur->CellInfo.gsm.signalStrengthGsm.bitErrorRate);
2962 p.writeInt32(p_cur->CellInfo.gsm.cellIdentityGsm.mcc);
2963 p.writeInt32(p_cur->CellInfo.gsm.cellIdentityGsm.mnc);
2964 p.writeInt32(p_cur->CellInfo.gsm.cellIdentityGsm.lac);
2965 p.writeInt32(p_cur->CellInfo.gsm.cellIdentityGsm.cid);
2966 p.writeInt32(p_cur->CellInfo.gsm.signalStrengthGsm.signalStrength);
2967 p.writeInt32(p_cur->CellInfo.gsm.signalStrengthGsm.bitErrorRate);
2970 case RIL_CELL_INFO_TYPE_WCDMA: {
2971 appendPrintBuf("%s WCDMA id: mcc=%d,mnc=%d,lac=%d,cid=%d,psc=%d,", printBuf,
2972 p_cur->CellInfo.wcdma.cellIdentityWcdma.mcc,
2973 p_cur->CellInfo.wcdma.cellIdentityWcdma.mnc,
2974 p_cur->CellInfo.wcdma.cellIdentityWcdma.lac,
2975 p_cur->CellInfo.wcdma.cellIdentityWcdma.cid,
2976 p_cur->CellInfo.wcdma.cellIdentityWcdma.psc);
2977 appendPrintBuf("%s wcdmaSS: ss=%d,ber=%d],", printBuf,
2978 p_cur->CellInfo.wcdma.signalStrengthWcdma.signalStrength,
2979 p_cur->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate);
2981 p.writeInt32(p_cur->CellInfo.wcdma.cellIdentityWcdma.mcc);
2982 p.writeInt32(p_cur->CellInfo.wcdma.cellIdentityWcdma.mnc);
2983 p.writeInt32(p_cur->CellInfo.wcdma.cellIdentityWcdma.lac);
2984 p.writeInt32(p_cur->CellInfo.wcdma.cellIdentityWcdma.cid);
2985 p.writeInt32(p_cur->CellInfo.wcdma.cellIdentityWcdma.psc);
2986 p.writeInt32(p_cur->CellInfo.wcdma.signalStrengthWcdma.signalStrength);
2987 p.writeInt32(p_cur->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate);
2990 case RIL_CELL_INFO_TYPE_CDMA: {
2991 appendPrintBuf("%s CDMA id: nId=%d,sId=%d,bsId=%d,long=%d,lat=%d", printBuf,
2992 p_cur->CellInfo.cdma.cellIdentityCdma.networkId,
2993 p_cur->CellInfo.cdma.cellIdentityCdma.systemId,
2994 p_cur->CellInfo.cdma.cellIdentityCdma.basestationId,
2995 p_cur->CellInfo.cdma.cellIdentityCdma.longitude,
2996 p_cur->CellInfo.cdma.cellIdentityCdma.latitude);
2998 p.writeInt32(p_cur->CellInfo.cdma.cellIdentityCdma.networkId);
2999 p.writeInt32(p_cur->CellInfo.cdma.cellIdentityCdma.systemId);
3000 p.writeInt32(p_cur->CellInfo.cdma.cellIdentityCdma.basestationId);
3001 p.writeInt32(p_cur->CellInfo.cdma.cellIdentityCdma.longitude);
3002 p.writeInt32(p_cur->CellInfo.cdma.cellIdentityCdma.latitude);
3004 appendPrintBuf("%s cdmaSS: dbm=%d ecio=%d evdoSS: dbm=%d,ecio=%d,snr=%d", printBuf,
3005 p_cur->CellInfo.cdma.signalStrengthCdma.dbm,
3006 p_cur->CellInfo.cdma.signalStrengthCdma.ecio,
3007 p_cur->CellInfo.cdma.signalStrengthEvdo.dbm,
3008 p_cur->CellInfo.cdma.signalStrengthEvdo.ecio,
3009 p_cur->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio);
3011 p.writeInt32(p_cur->CellInfo.cdma.signalStrengthCdma.dbm);
3012 p.writeInt32(p_cur->CellInfo.cdma.signalStrengthCdma.ecio);
3013 p.writeInt32(p_cur->CellInfo.cdma.signalStrengthEvdo.dbm);
3014 p.writeInt32(p_cur->CellInfo.cdma.signalStrengthEvdo.ecio);
3015 p.writeInt32(p_cur->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio);
3018 case RIL_CELL_INFO_TYPE_LTE: {
3019 appendPrintBuf("%s LTE id: mcc=%d,mnc=%d,ci=%d,pci=%d,tac=%d", printBuf,
3020 p_cur->CellInfo.lte.cellIdentityLte.mcc,
3021 p_cur->CellInfo.lte.cellIdentityLte.mnc,
3022 p_cur->CellInfo.lte.cellIdentityLte.ci,
3023 p_cur->CellInfo.lte.cellIdentityLte.pci,
3024 p_cur->CellInfo.lte.cellIdentityLte.tac);
3026 p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.mcc);
3027 p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.mnc);
3028 p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.ci);
3029 p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.pci);
3030 p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.tac);
3032 appendPrintBuf("%s lteSS: ss=%d,rsrp=%d,rsrq=%d,rssnr=%d,cqi=%d,ta=%d", printBuf,
3033 p_cur->CellInfo.lte.signalStrengthLte.signalStrength,
3034 p_cur->CellInfo.lte.signalStrengthLte.rsrp,
3035 p_cur->CellInfo.lte.signalStrengthLte.rsrq,
3036 p_cur->CellInfo.lte.signalStrengthLte.rssnr,
3037 p_cur->CellInfo.lte.signalStrengthLte.cqi,
3038 p_cur->CellInfo.lte.signalStrengthLte.timingAdvance);
3039 p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.signalStrength);
3040 p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.rsrp);
3041 p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.rsrq);
3042 p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.rssnr);
3043 p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.cqi);
3044 p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.timingAdvance);
3047 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
3048 appendPrintBuf("%s TDSCDMA id: mcc=%d,mnc=%d,lac=%d,cid=%d,cpid=%d,", printBuf,
3049 p_cur->CellInfo.tdscdma.cellIdentityTdscdma.mcc,
3050 p_cur->CellInfo.tdscdma.cellIdentityTdscdma.mnc,
3051 p_cur->CellInfo.tdscdma.cellIdentityTdscdma.lac,
3052 p_cur->CellInfo.tdscdma.cellIdentityTdscdma.cid,
3053 p_cur->CellInfo.tdscdma.cellIdentityTdscdma.cpid);
3054 appendPrintBuf("%s tdscdmaSS: rscp=%d],", printBuf,
3055 p_cur->CellInfo.tdscdma.signalStrengthTdscdma.rscp);
3057 p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
3058 p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
3059 p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.lac);
3060 p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.cid);
3061 p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.cpid);
3062 p.writeInt32(p_cur->CellInfo.tdscdma.signalStrengthTdscdma.rscp);
3074 static int responseHardwareConfig(Parcel &p, void *response, size_t responselen)
3076 if (response == NULL && responselen != 0) {
3077 RLOGE("invalid response: NULL");
3078 return RIL_ERRNO_INVALID_RESPONSE;
3081 if (responselen % sizeof(RIL_HardwareConfig) != 0) {
3082 RLOGE("responseHardwareConfig: invalid response length %d expected multiple of %d",
3083 (int)responselen, (int)sizeof(RIL_HardwareConfig));
3084 return RIL_ERRNO_INVALID_RESPONSE;
3087 int num = responselen / sizeof(RIL_HardwareConfig);
3089 RIL_HardwareConfig *p_cur = (RIL_HardwareConfig *) response;
3094 for (i = 0; i < num; i++) {
3095 switch (p_cur[i].type) {
3096 case RIL_HARDWARE_CONFIG_MODEM: {
3097 writeStringToParcel(p, p_cur[i].uuid);
3098 p.writeInt32((int)p_cur[i].state);
3099 p.writeInt32(p_cur[i].cfg.modem.rat);
3100 p.writeInt32(p_cur[i].cfg.modem.maxVoice);
3101 p.writeInt32(p_cur[i].cfg.modem.maxData);
3102 p.writeInt32(p_cur[i].cfg.modem.maxStandby);
3104 appendPrintBuf("%s modem: uuid=%s,state=%d,rat=%08x,maxV=%d,maxD=%d,maxS=%d", printBuf,
3105 p_cur[i].uuid, (int)p_cur[i].state, p_cur[i].cfg.modem.rat,
3106 p_cur[i].cfg.modem.maxVoice, p_cur[i].cfg.modem.maxData, p_cur[i].cfg.modem.maxStandby);
3109 case RIL_HARDWARE_CONFIG_SIM: {
3110 writeStringToParcel(p, p_cur[i].uuid);
3111 p.writeInt32((int)p_cur[i].state);
3112 writeStringToParcel(p, p_cur[i].cfg.sim.modemUuid);
3114 appendPrintBuf("%s sim: uuid=%s,state=%d,modem-uuid=%s", printBuf,
3115 p_cur[i].uuid, (int)p_cur[i].state, p_cur[i].cfg.sim.modemUuid);
3125 static void triggerEvLoop() {
3127 if (!pthread_equal(pthread_self(), s_tid_dispatch)) {
3128 /* trigger event loop to wakeup. No reason to do this,
3129 * if we're in the event loop thread */
3131 ret = write (s_fdWakeupWrite, " ", 1);
3132 } while (ret < 0 && errno == EINTR);
3136 static void rilEventAddWakeup(struct ril_event *ev) {
3141 static void sendSimStatusAppInfo(Parcel &p, int num_apps, RIL_AppStatus appStatus[]) {
3142 p.writeInt32(num_apps);
3144 for (int i = 0; i < num_apps; i++) {
3145 p.writeInt32(appStatus[i].app_type);
3146 p.writeInt32(appStatus[i].app_state);
3147 p.writeInt32(appStatus[i].perso_substate);
3148 writeStringToParcel(p, (const char*)(appStatus[i].aid_ptr));
3149 writeStringToParcel(p, (const char*)
3150 (appStatus[i].app_label_ptr));
3151 p.writeInt32(appStatus[i].pin1_replaced);
3152 p.writeInt32(appStatus[i].pin1);
3153 p.writeInt32(appStatus[i].pin2);
3154 appendPrintBuf("%s[app_type=%d,app_state=%d,perso_substate=%d,\
3155 aid_ptr=%s,app_label_ptr=%s,pin1_replaced=%d,pin1=%d,pin2=%d],",
3157 appStatus[i].app_type,
3158 appStatus[i].app_state,
3159 appStatus[i].perso_substate,
3160 appStatus[i].aid_ptr,
3161 appStatus[i].app_label_ptr,
3162 appStatus[i].pin1_replaced,
3169 static int responseSimStatus(Parcel &p, void *response, size_t responselen) {
3172 if (response == NULL && responselen != 0) {
3173 RLOGE("invalid response: NULL");
3174 return RIL_ERRNO_INVALID_RESPONSE;
3177 if (responselen == sizeof (RIL_CardStatus_v6)) {
3178 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
3180 p.writeInt32(p_cur->card_state);
3181 p.writeInt32(p_cur->universal_pin_state);
3182 p.writeInt32(p_cur->gsm_umts_subscription_app_index);
3183 p.writeInt32(p_cur->cdma_subscription_app_index);
3184 p.writeInt32(p_cur->ims_subscription_app_index);
3186 sendSimStatusAppInfo(p, p_cur->num_applications, p_cur->applications);
3187 } else if (responselen == sizeof (RIL_CardStatus_v5)) {
3188 RIL_CardStatus_v5 *p_cur = ((RIL_CardStatus_v5 *) response);
3190 p.writeInt32(p_cur->card_state);
3191 p.writeInt32(p_cur->universal_pin_state);
3192 p.writeInt32(p_cur->gsm_umts_subscription_app_index);
3193 p.writeInt32(p_cur->cdma_subscription_app_index);
3196 sendSimStatusAppInfo(p, p_cur->num_applications, p_cur->applications);
3198 RLOGE("responseSimStatus: A RilCardStatus_v6 or _v5 expected\n");
3199 return RIL_ERRNO_INVALID_RESPONSE;
3205 static int responseGsmBrSmsCnf(Parcel &p, void *response, size_t responselen) {
3206 int num = responselen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
3210 RIL_GSM_BroadcastSmsConfigInfo **p_cur =
3211 (RIL_GSM_BroadcastSmsConfigInfo **) response;
3212 for (int i = 0; i < num; i++) {
3213 p.writeInt32(p_cur[i]->fromServiceId);
3214 p.writeInt32(p_cur[i]->toServiceId);
3215 p.writeInt32(p_cur[i]->fromCodeScheme);
3216 p.writeInt32(p_cur[i]->toCodeScheme);
3217 p.writeInt32(p_cur[i]->selected);
3219 appendPrintBuf("%s [%d: fromServiceId=%d, toServiceId=%d, \
3220 fromCodeScheme=%d, toCodeScheme=%d, selected =%d]",
3221 printBuf, i, p_cur[i]->fromServiceId, p_cur[i]->toServiceId,
3222 p_cur[i]->fromCodeScheme, p_cur[i]->toCodeScheme,
3223 p_cur[i]->selected);
3230 static int responseCdmaBrSmsCnf(Parcel &p, void *response, size_t responselen) {
3231 RIL_CDMA_BroadcastSmsConfigInfo **p_cur =
3232 (RIL_CDMA_BroadcastSmsConfigInfo **) response;
3234 int num = responselen / sizeof (RIL_CDMA_BroadcastSmsConfigInfo *);
3238 for (int i = 0 ; i < num ; i++ ) {
3239 p.writeInt32(p_cur[i]->service_category);
3240 p.writeInt32(p_cur[i]->language);
3241 p.writeInt32(p_cur[i]->selected);
3243 appendPrintBuf("%s [%d: srvice_category=%d, language =%d, \
3245 printBuf, i, p_cur[i]->service_category, p_cur[i]->language,
3246 p_cur[i]->selected);
3253 static int responseCdmaSms(Parcel &p, void *response, size_t responselen) {
3260 RLOGD("Inside responseCdmaSms");
3262 if (response == NULL && responselen != 0) {
3263 RLOGE("invalid response: NULL");
3264 return RIL_ERRNO_INVALID_RESPONSE;
3267 if (responselen != sizeof(RIL_CDMA_SMS_Message)) {
3268 RLOGE("invalid response length was %d expected %d",
3269 (int)responselen, (int)sizeof(RIL_CDMA_SMS_Message));
3270 return RIL_ERRNO_INVALID_RESPONSE;
3273 RIL_CDMA_SMS_Message *p_cur = (RIL_CDMA_SMS_Message *) response;
3274 p.writeInt32(p_cur->uTeleserviceID);
3275 p.write(&(p_cur->bIsServicePresent),sizeof(uct));
3276 p.writeInt32(p_cur->uServicecategory);
3277 p.writeInt32(p_cur->sAddress.digit_mode);
3278 p.writeInt32(p_cur->sAddress.number_mode);
3279 p.writeInt32(p_cur->sAddress.number_type);
3280 p.writeInt32(p_cur->sAddress.number_plan);
3281 p.write(&(p_cur->sAddress.number_of_digits), sizeof(uct));
3282 digitLimit= MIN((p_cur->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
3283 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
3284 p.write(&(p_cur->sAddress.digits[digitCount]),sizeof(uct));
3287 p.writeInt32(p_cur->sSubAddress.subaddressType);
3288 p.write(&(p_cur->sSubAddress.odd),sizeof(uct));
3289 p.write(&(p_cur->sSubAddress.number_of_digits),sizeof(uct));
3290 digitLimit= MIN((p_cur->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
3291 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
3292 p.write(&(p_cur->sSubAddress.digits[digitCount]),sizeof(uct));
3295 digitLimit= MIN((p_cur->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
3296 p.writeInt32(p_cur->uBearerDataLen);
3297 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
3298 p.write(&(p_cur->aBearerData[digitCount]), sizeof(uct));
3302 appendPrintBuf("%suTeleserviceID=%d, bIsServicePresent=%d, uServicecategory=%d, \
3303 sAddress.digit_mode=%d, sAddress.number_mode=%d, sAddress.number_type=%d, ",
3304 printBuf, p_cur->uTeleserviceID,p_cur->bIsServicePresent,p_cur->uServicecategory,
3305 p_cur->sAddress.digit_mode, p_cur->sAddress.number_mode,p_cur->sAddress.number_type);
3311 static int responseDcRtInfo(Parcel &p, void *response, size_t responselen)
3313 int num = responselen / sizeof(RIL_DcRtInfo);
3314 if ((responselen % sizeof(RIL_DcRtInfo) != 0) || (num != 1)) {
3315 RLOGE("responseDcRtInfo: invalid response length %d expected multiple of %d",
3316 (int)responselen, (int)sizeof(RIL_DcRtInfo));
3317 return RIL_ERRNO_INVALID_RESPONSE;
3321 RIL_DcRtInfo *pDcRtInfo = (RIL_DcRtInfo *)response;
3322 p.writeInt64(pDcRtInfo->time);
3323 p.writeInt32(pDcRtInfo->powerState);
3324 appendPrintBuf("%s[time=%d,powerState=%d]", printBuf,
3326 pDcRtInfo->powerState);
3333 * A write on the wakeup fd is done just to pop us out of select()
3334 * We empty the buffer here and then ril_event will reset the timers on the
3337 static void processWakeupCallback(int fd, short flags, void *param) {
3341 RLOGV("processWakeupCallback");
3343 /* empty our wakeup socket out */
3345 ret = read(s_fdWakeupRead, &buff, sizeof(buff));
3346 } while (ret > 0 || (ret < 0 && errno == EINTR));
3349 static void onCommandsSocketClosed(RIL_SOCKET_ID socket_id) {
3352 /* Hook for current context
3353 pendingRequestsMutextHook refer to &s_pendingRequestsMutex */
3354 pthread_mutex_t * pendingRequestsMutexHook = &s_pendingRequestsMutex;
3355 /* pendingRequestsHook refer to &s_pendingRequests */
3356 RequestInfo ** pendingRequestsHook = &s_pendingRequests;
3358 #if (SIM_COUNT >= 2)
3359 if (socket_id == RIL_SOCKET_2) {
3360 pendingRequestsMutexHook = &s_pendingRequestsMutex_socket2;
3361 pendingRequestsHook = &s_pendingRequests_socket2;
3363 #if (SIM_COUNT >= 3)
3364 else if (socket_id == RIL_SOCKET_3) {
3365 pendingRequestsMutexHook = &s_pendingRequestsMutex_socket3;
3366 pendingRequestsHook = &s_pendingRequests_socket3;
3369 #if (SIM_COUNT >= 4)
3370 else if (socket_id == RIL_SOCKET_4) {
3371 pendingRequestsMutexHook = &s_pendingRequestsMutex_socket4;
3372 pendingRequestsHook = &s_pendingRequests_socket4;
3376 /* mark pending requests as "cancelled" so we dont report responses */
3377 ret = pthread_mutex_lock(pendingRequestsMutexHook);
3380 p_cur = *pendingRequestsHook;
3382 for (p_cur = *pendingRequestsHook
3384 ; p_cur = p_cur->p_next
3386 p_cur->cancelled = 1;
3389 ret = pthread_mutex_unlock(pendingRequestsMutexHook);
3393 static void processCommandsCallback(int fd, short flags, void *param) {
3398 SocketListenParam *p_info = (SocketListenParam *)param;
3400 assert(fd == p_info->fdCommand);
3402 p_rs = p_info->p_rs;
3405 /* loop until EAGAIN/EINTR, end of stream, or other error */
3406 ret = record_stream_get_next(p_rs, &p_record, &recordlen);
3408 if (ret == 0 && p_record == NULL) {
3411 } else if (ret < 0) {
3413 } else if (ret == 0) { /* && p_record != NULL */
3414 processCommandBuffer(p_record, recordlen, p_info->socket_id);
3418 if (ret == 0 || !(errno == EAGAIN || errno == EINTR)) {
3419 /* fatal error or end-of-stream */
3421 RLOGE("error on reading command socket errno:%d\n", errno);
3423 RLOGW("EOS. Closing command socket.");
3427 p_info->fdCommand = -1;
3429 ril_event_del(p_info->commands_event);
3431 record_stream_free(p_rs);
3433 /* start listening for new connections again */
3434 rilEventAddWakeup(&s_listen_event);
3436 onCommandsSocketClosed(p_info->socket_id);
3441 static void onNewCommandConnect(RIL_SOCKET_ID socket_id) {
3442 // Inform we are connected and the ril version
3443 int rilVer = s_callbacks.version;
3444 RIL_UNSOL_RESPONSE(RIL_UNSOL_RIL_CONNECTED,
3445 &rilVer, sizeof(rilVer), socket_id);
3447 // implicit radio state changed
3448 RIL_UNSOL_RESPONSE(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED,
3449 NULL, 0, socket_id);
3451 // Send last NITZ time data, in case it was missed
3452 if (s_lastNITZTimeData != NULL) {
3453 sendResponseRaw(s_lastNITZTimeData, s_lastNITZTimeDataSize, socket_id);
3455 free(s_lastNITZTimeData);
3456 s_lastNITZTimeData = NULL;
3459 // Get version string
3460 if (s_callbacks.getVersion != NULL) {
3461 const char *version;
3462 version = s_callbacks.getVersion();
3463 RLOGI("RIL Daemon version: %s\n", version);
3465 property_set(PROPERTY_RIL_IMPL, version);
3467 RLOGI("RIL Daemon version: unavailable\n");
3468 property_set(PROPERTY_RIL_IMPL, "unavailable");
3473 static void listenCallback (int fd, short flags, void *param) {
3476 int is_phone_socket;
3479 SocketListenParam *p_info = (SocketListenParam *)param;
3481 struct sockaddr_un peeraddr;
3482 socklen_t socklen = sizeof (peeraddr);
3485 socklen_t szCreds = sizeof(creds);
3487 struct passwd *pwd = NULL;
3489 assert (*p_info->fdCommand < 0);
3490 assert (fd == *p_info->fdListen);
3492 fdCommand = accept(fd, (sockaddr *) &peeraddr, &socklen);
3494 if (fdCommand < 0 ) {
3495 RLOGE("Error on accept() errno:%d", errno);
3496 /* start listening for new connections again */
3497 rilEventAddWakeup(p_info->listen_event);
3501 /* check the credential of the other side and only accept socket from
3505 is_phone_socket = 0;
3507 err = getsockopt(fdCommand, SOL_SOCKET, SO_PEERCRED, &creds, &szCreds);
3509 if (err == 0 && szCreds > 0) {
3511 pwd = getpwuid(creds.uid);
3513 if (strcmp(pwd->pw_name, p_info->processName) == 0) {
3514 is_phone_socket = 1;
3516 RLOGE("RILD can't accept socket from process %s", pwd->pw_name);
3519 RLOGE("Error on getpwuid() errno: %d", errno);
3522 RLOGD("Error on getsockopt() errno: %d", errno);
3525 if (!is_phone_socket) {
3526 RLOGE("RILD must accept socket from %s", p_info->processName);
3531 onCommandsSocketClosed(p_info->socket_id);
3533 /* start listening for new connections again */
3534 rilEventAddWakeup(p_info->listen_event);
3539 ret = fcntl(fdCommand, F_SETFL, O_NONBLOCK);
3542 RLOGE ("Error setting O_NONBLOCK errno:%d", errno);
3545 RLOGI("libril: new connection to %s", rilSocketIdToString(p_info->socket_id));
3547 p_info->fdCommand = fdCommand;
3549 p_rs = record_stream_new(p_info->fdCommand, MAX_COMMAND_BYTES);
3551 p_info->p_rs = p_rs;
3553 ril_event_set (p_info->commands_event, p_info->fdCommand, 1,
3554 p_info->processCommandsCallback, p_info);
3556 rilEventAddWakeup (p_info->commands_event);
3558 onNewCommandConnect(p_info->socket_id);
3561 static void freeDebugCallbackArgs(int number, char **args) {
3562 for (int i = 0; i < number; i++) {
3563 if (args[i] != NULL) {
3570 static void debugCallback (int fd, short flags, void *param) {
3571 int acceptFD, option;
3572 struct sockaddr_un peeraddr;
3573 socklen_t socklen = sizeof (peeraddr);
3575 unsigned int qxdm_data[6];
3576 const char *deactData[1] = {"1"};
3579 int hangupData[1] = {1};
3582 RIL_SOCKET_ID socket_id = RIL_SOCKET_1;
3585 RLOGI("debugCallback for socket %s", rilSocketIdToString(socket_id));
3587 acceptFD = accept (fd, (sockaddr *) &peeraddr, &socklen);
3590 RLOGE ("error accepting on debug port: %d\n", errno);
3594 if (recv(acceptFD, &number, sizeof(int), 0) != sizeof(int)) {
3595 RLOGE ("error reading on socket: number of Args: \n");
3598 args = (char **) malloc(sizeof(char*) * number);
3600 for (int i = 0; i < number; i++) {
3602 if (recv(acceptFD, &len, sizeof(int), 0) != sizeof(int)) {
3603 RLOGE ("error reading on socket: Len of Args: \n");
3604 freeDebugCallbackArgs(i, args);
3608 args[i] = (char *) malloc((sizeof(char) * len) + 1);
3609 if (recv(acceptFD, args[i], sizeof(char) * len, 0)
3610 != (int)sizeof(char) * len) {
3611 RLOGE ("error reading on socket: Args[%d] \n", i);
3612 freeDebugCallbackArgs(i, args);
3615 char * buf = args[i];
3617 if ((i+1) == number) {
3618 /* The last argument should be sim id 0(SIM1)~3(SIM4) */
3619 sim_id = atoi(args[i]);
3622 socket_id = RIL_SOCKET_1;
3624 #if (SIM_COUNT >= 2)
3626 socket_id = RIL_SOCKET_2;
3629 #if (SIM_COUNT >= 3)
3631 socket_id = RIL_SOCKET_3;
3634 #if (SIM_COUNT >= 4)
3636 socket_id = RIL_SOCKET_4;
3640 socket_id = RIL_SOCKET_1;
3646 switch (atoi(args[0])) {
3648 RLOGI ("Connection on debug port: issuing reset.");
3649 issueLocalRequest(RIL_REQUEST_RESET_RADIO, NULL, 0, socket_id);
3652 RLOGI ("Connection on debug port: issuing radio power off.");
3654 issueLocalRequest(RIL_REQUEST_RADIO_POWER, &data, sizeof(int), socket_id);
3656 if (socket_id == RIL_SOCKET_1 && s_ril_param_socket.fdCommand > 0) {
3657 close(s_ril_param_socket.fdCommand);
3658 s_ril_param_socket.fdCommand = -1;
3660 #if (SIM_COUNT == 2)
3661 else if (socket_id == RIL_SOCKET_2 && s_ril_param_socket2.fdCommand > 0) {
3662 close(s_ril_param_socket2.fdCommand);
3663 s_ril_param_socket2.fdCommand = -1;
3668 RLOGI ("Debug port: issuing unsolicited voice network change.");
3669 RIL_UNSOL_RESPONSE(RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED, NULL, 0, socket_id);
3672 RLOGI ("Debug port: QXDM log enable.");
3673 qxdm_data[0] = 65536; // head.func_tag
3674 qxdm_data[1] = 16; // head.len
3675 qxdm_data[2] = 1; // mode: 1 for 'start logging'
3676 qxdm_data[3] = 32; // log_file_size: 32megabytes
3677 qxdm_data[4] = 0; // log_mask
3678 qxdm_data[5] = 8; // log_max_fileindex
3679 issueLocalRequest(RIL_REQUEST_OEM_HOOK_RAW, qxdm_data,
3680 6 * sizeof(int), socket_id);
3683 RLOGI ("Debug port: QXDM log disable.");
3684 qxdm_data[0] = 65536;
3686 qxdm_data[2] = 0; // mode: 0 for 'stop logging'
3690 issueLocalRequest(RIL_REQUEST_OEM_HOOK_RAW, qxdm_data,
3691 6 * sizeof(int), socket_id);
3694 RLOGI("Debug port: Radio On");
3696 issueLocalRequest(RIL_REQUEST_RADIO_POWER, &data, sizeof(int), socket_id);
3698 // Set network selection automatic.
3699 issueLocalRequest(RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC, NULL, 0, socket_id);
3702 RLOGI("Debug port: Setup Data Call, Apn :%s\n", args[1]);
3703 actData[0] = args[1];
3704 issueLocalRequest(RIL_REQUEST_SETUP_DATA_CALL, &actData,
3705 sizeof(actData), socket_id);
3708 RLOGI("Debug port: Deactivate Data Call");
3709 issueLocalRequest(RIL_REQUEST_DEACTIVATE_DATA_CALL, &deactData,
3710 sizeof(deactData), socket_id);
3713 RLOGI("Debug port: Dial Call");
3715 dialData.address = args[1];
3716 issueLocalRequest(RIL_REQUEST_DIAL, &dialData, sizeof(dialData), socket_id);
3719 RLOGI("Debug port: Answer Call");
3720 issueLocalRequest(RIL_REQUEST_ANSWER, NULL, 0, socket_id);
3723 RLOGI("Debug port: End Call");
3724 issueLocalRequest(RIL_REQUEST_HANGUP, &hangupData,
3725 sizeof(hangupData), socket_id);
3728 RLOGE ("Invalid request");
3731 freeDebugCallbackArgs(number, args);
3736 static void userTimerCallback (int fd, short flags, void *param) {
3737 UserCallbackInfo *p_info;
3739 p_info = (UserCallbackInfo *)param;
3741 p_info->p_callback(p_info->userParam);
3744 // FIXME generalize this...there should be a cancel mechanism
3745 if (s_last_wake_timeout_info != NULL && s_last_wake_timeout_info == p_info) {
3746 s_last_wake_timeout_info = NULL;
3754 eventLoop(void *param) {
3760 pthread_mutex_lock(&s_startupMutex);
3763 pthread_cond_broadcast(&s_startupCond);
3765 pthread_mutex_unlock(&s_startupMutex);
3767 ret = pipe(filedes);
3770 RLOGE("Error in pipe() errno:%d", errno);
3774 s_fdWakeupRead = filedes[0];
3775 s_fdWakeupWrite = filedes[1];
3777 fcntl(s_fdWakeupRead, F_SETFL, O_NONBLOCK);
3779 ril_event_set (&s_wakeupfd_event, s_fdWakeupRead, true,
3780 processWakeupCallback, NULL);
3782 rilEventAddWakeup (&s_wakeupfd_event);
3784 // Only returns on error
3786 RLOGE ("error in event_loop_base errno:%d", errno);
3787 // kill self to restart on error
3794 RIL_startEventLoop(void) {
3795 /* spin up eventLoop thread and wait for it to get started */
3797 pthread_mutex_lock(&s_startupMutex);
3799 pthread_attr_t attr;
3800 pthread_attr_init(&attr);
3801 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
3803 int result = pthread_create(&s_tid_dispatch, &attr, eventLoop, NULL);
3805 RLOGE("Failed to create dispatch thread: %s", strerror(result));
3809 while (s_started == 0) {
3810 pthread_cond_wait(&s_startupCond, &s_startupMutex);
3814 pthread_mutex_unlock(&s_startupMutex);
3817 // Used for testing purpose only.
3818 extern "C" void RIL_setcallbacks (const RIL_RadioFunctions *callbacks) {
3819 memcpy(&s_callbacks, callbacks, sizeof (RIL_RadioFunctions));
3822 static void startListen(RIL_SOCKET_ID socket_id, SocketListenParam* socket_listen_p) {
3825 char socket_name[10];
3827 memset(socket_name, 0, sizeof(char)*10);
3831 strncpy(socket_name, RIL_getRilSocketName(), 9);
3833 #if (SIM_COUNT >= 2)
3835 strncpy(socket_name, SOCKET2_NAME_RIL, 9);
3838 #if (SIM_COUNT >= 3)
3840 strncpy(socket_name, SOCKET3_NAME_RIL, 9);
3843 #if (SIM_COUNT >= 4)
3845 strncpy(socket_name, SOCKET4_NAME_RIL, 9);
3849 RLOGE("Socket id is wrong!!");
3853 RLOGI("Start to listen %s", rilSocketIdToString(socket_id));
3855 fdListen = android_get_control_socket(socket_name);
3857 RLOGE("Failed to get socket %s", socket_name);
3861 ret = listen(fdListen, 4);
3864 RLOGE("Failed to listen on control socket '%d': %s",
3865 fdListen, strerror(errno));
3868 socket_listen_p->fdListen = fdListen;
3870 /* note: non-persistent so we can accept only one connection at a time */
3871 ril_event_set (socket_listen_p->listen_event, fdListen, false,
3872 listenCallback, socket_listen_p);
3874 rilEventAddWakeup (socket_listen_p->listen_event);
3878 RIL_register (const RIL_RadioFunctions *callbacks) {
3882 RLOGI("SIM_COUNT: %d", SIM_COUNT);
3884 if (callbacks == NULL) {
3885 RLOGE("RIL_register: RIL_RadioFunctions * null");
3888 if (callbacks->version < RIL_VERSION_MIN) {
3889 RLOGE("RIL_register: version %d is to old, min version is %d",
3890 callbacks->version, RIL_VERSION_MIN);
3893 if (callbacks->version > RIL_VERSION) {
3894 RLOGE("RIL_register: version %d is too new, max version is %d",
3895 callbacks->version, RIL_VERSION);
3898 RLOGE("RIL_register: RIL version %d", callbacks->version);
3900 if (s_registerCalled > 0) {
3901 RLOGE("RIL_register has been called more than once. "
3902 "Subsequent call ignored");
3906 memcpy(&s_callbacks, callbacks, sizeof (RIL_RadioFunctions));
3908 /* Initialize socket1 parameters */
3909 s_ril_param_socket = {
3910 RIL_SOCKET_1, /* socket_id */
3913 PHONE_PROCESS, /* processName */
3914 &s_commands_event, /* commands_event */
3915 &s_listen_event, /* listen_event */
3916 processCommandsCallback, /* processCommandsCallback */
3920 #if (SIM_COUNT >= 2)
3921 s_ril_param_socket2 = {
3922 RIL_SOCKET_2, /* socket_id */
3925 PHONE_PROCESS, /* processName */
3926 &s_commands_event_socket2, /* commands_event */
3927 &s_listen_event_socket2, /* listen_event */
3928 processCommandsCallback, /* processCommandsCallback */
3933 #if (SIM_COUNT >= 3)
3934 s_ril_param_socket3 = {
3935 RIL_SOCKET_3, /* socket_id */
3938 PHONE_PROCESS, /* processName */
3939 &s_commands_event_socket3, /* commands_event */
3940 &s_listen_event_socket3, /* listen_event */
3941 processCommandsCallback, /* processCommandsCallback */
3946 #if (SIM_COUNT >= 4)
3947 s_ril_param_socket4 = {
3948 RIL_SOCKET_4, /* socket_id */
3951 PHONE_PROCESS, /* processName */
3952 &s_commands_event_socket4, /* commands_event */
3953 &s_listen_event_socket4, /* listen_event */
3954 processCommandsCallback, /* processCommandsCallback */
3960 s_registerCalled = 1;
3962 RLOGI("s_registerCalled flag set, %d", s_started);
3963 // Little self-check
3965 for (int i = 0; i < (int)NUM_ELEMS(s_commands); i++) {
3966 assert(i == s_commands[i].requestNumber);
3969 for (int i = 0; i < (int)NUM_ELEMS(s_unsolResponses); i++) {
3970 assert(i + RIL_UNSOL_RESPONSE_BASE
3971 == s_unsolResponses[i].requestNumber);
3974 // New rild impl calls RIL_startEventLoop() first
3975 // old standalone impl wants it here.
3977 if (s_started == 0) {
3978 RIL_startEventLoop();
3981 // start listen socket1
3982 startListen(RIL_SOCKET_1, &s_ril_param_socket);
3984 #if (SIM_COUNT >= 2)
3985 // start listen socket2
3986 startListen(RIL_SOCKET_2, &s_ril_param_socket2);
3987 #endif /* (SIM_COUNT == 2) */
3989 #if (SIM_COUNT >= 3)
3990 // start listen socket3
3991 startListen(RIL_SOCKET_3, &s_ril_param_socket3);
3992 #endif /* (SIM_COUNT == 3) */
3994 #if (SIM_COUNT >= 4)
3995 // start listen socket4
3996 startListen(RIL_SOCKET_4, &s_ril_param_socket4);
3997 #endif /* (SIM_COUNT == 4) */
4001 // start debug interface socket
4004 if (strlen(RIL_getRilSocketName()) >= strlen(SOCKET_NAME_RIL)) {
4005 inst = RIL_getRilSocketName() + strlen(SOCKET_NAME_RIL);
4008 char rildebug[MAX_DEBUG_SOCKET_NAME_LENGTH] = SOCKET_NAME_RIL_DEBUG;
4010 strncat(rildebug, inst, MAX_DEBUG_SOCKET_NAME_LENGTH);
4013 s_fdDebug = android_get_control_socket(rildebug);
4014 if (s_fdDebug < 0) {
4015 RLOGE("Failed to get socket : %s errno:%d", rildebug, errno);
4019 ret = listen(s_fdDebug, 4);
4022 RLOGE("Failed to listen on ril debug socket '%d': %s",
4023 s_fdDebug, strerror(errno));
4027 ril_event_set (&s_debug_event, s_fdDebug, true,
4028 debugCallback, NULL);
4030 rilEventAddWakeup (&s_debug_event);
4036 checkAndDequeueRequestInfo(struct RequestInfo *pRI) {
4038 /* Hook for current context
4039 pendingRequestsMutextHook refer to &s_pendingRequestsMutex */
4040 pthread_mutex_t* pendingRequestsMutexHook = &s_pendingRequestsMutex;
4041 /* pendingRequestsHook refer to &s_pendingRequests */
4042 RequestInfo ** pendingRequestsHook = &s_pendingRequests;
4048 #if (SIM_COUNT >= 2)
4049 if (pRI->socket_id == RIL_SOCKET_2) {
4050 pendingRequestsMutexHook = &s_pendingRequestsMutex_socket2;
4051 pendingRequestsHook = &s_pendingRequests_socket2;
4053 #if (SIM_COUNT >= 3)
4054 if (pRI->socket_id == RIL_SOCKET_3) {
4055 pendingRequestsMutexHook = &s_pendingRequestsMutex_socket3;
4056 pendingRequestsHook = &s_pendingRequests_socket3;
4059 #if (SIM_COUNT >= 4)
4060 if (pRI->socket_id == RIL_SOCKET_4) {
4061 pendingRequestsMutexHook = &s_pendingRequestsMutex_socket4;
4062 pendingRequestsHook = &s_pendingRequests_socket4;
4066 pthread_mutex_lock(pendingRequestsMutexHook);
4068 for(RequestInfo **ppCur = pendingRequestsHook
4070 ; ppCur = &((*ppCur)->p_next)
4072 if (pRI == *ppCur) {
4075 *ppCur = (*ppCur)->p_next;
4080 pthread_mutex_unlock(pendingRequestsMutexHook);
4087 RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responselen) {
4090 int fd = s_ril_param_socket.fdCommand;
4092 RIL_SOCKET_ID socket_id = RIL_SOCKET_1;
4094 pRI = (RequestInfo *)t;
4096 if (!checkAndDequeueRequestInfo(pRI)) {
4097 RLOGE ("RIL_onRequestComplete: invalid RIL_Token");
4101 socket_id = pRI->socket_id;
4102 #if (SIM_COUNT >= 2)
4103 if (socket_id == RIL_SOCKET_2) {
4104 fd = s_ril_param_socket2.fdCommand;
4106 #if (SIM_COUNT >= 3)
4107 if (socket_id == RIL_SOCKET_3) {
4108 fd = s_ril_param_socket3.fdCommand;
4111 #if (SIM_COUNT >= 4)
4112 if (socket_id == RIL_SOCKET_4) {
4113 fd = s_ril_param_socket4.fdCommand;
4117 RLOGD("RequestComplete, %s", rilSocketIdToString(socket_id));
4119 if (pRI->local > 0) {
4120 // Locally issued command...void only!
4121 // response does not go back up the command socket
4122 RLOGD("C[locl]< %s", requestToString(pRI->pCI->requestNumber));
4127 appendPrintBuf("[%04d]< %s",
4128 pRI->token, requestToString(pRI->pCI->requestNumber));
4130 if (pRI->cancelled == 0) {
4133 p.writeInt32 (RESPONSE_SOLICITED);
4134 p.writeInt32 (pRI->token);
4135 errorOffset = p.dataPosition();
4139 if (response != NULL) {
4140 // there is a response payload, no matter success or not.
4141 ret = pRI->pCI->responseFunction(p, response, responselen);
4143 /* if an error occurred, rewind and mark it */
4145 RLOGE ("responseFunction error, ret %d", ret);
4146 p.setDataPosition(errorOffset);
4151 if (e != RIL_E_SUCCESS) {
4152 appendPrintBuf("%s fails by %s", printBuf, failCauseToString(e));
4156 RLOGD ("RIL onRequestComplete: Command channel closed");
4158 sendResponse(p, socket_id);
4167 grabPartialWakeLock() {
4168 acquire_wake_lock(PARTIAL_WAKE_LOCK, ANDROID_WAKE_LOCK_NAME);
4173 release_wake_lock(ANDROID_WAKE_LOCK_NAME);
4177 * Timer callback to put us back to sleep before the default timeout
4180 wakeTimeoutCallback (void *param) {
4181 // We're using "param != NULL" as a cancellation mechanism
4182 if (param == NULL) {
4183 //RLOGD("wakeTimeout: releasing wake lock");
4187 //RLOGD("wakeTimeout: releasing wake lock CANCELLED");
4192 decodeVoiceRadioTechnology (RIL_RadioState radioState) {
4193 switch (radioState) {
4194 case RADIO_STATE_SIM_NOT_READY:
4195 case RADIO_STATE_SIM_LOCKED_OR_ABSENT:
4196 case RADIO_STATE_SIM_READY:
4197 return RADIO_TECH_UMTS;
4199 case RADIO_STATE_RUIM_NOT_READY:
4200 case RADIO_STATE_RUIM_READY:
4201 case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:
4202 case RADIO_STATE_NV_NOT_READY:
4203 case RADIO_STATE_NV_READY:
4204 return RADIO_TECH_1xRTT;
4207 RLOGD("decodeVoiceRadioTechnology: Invoked with incorrect RadioState");
4213 decodeCdmaSubscriptionSource (RIL_RadioState radioState) {
4214 switch (radioState) {
4215 case RADIO_STATE_SIM_NOT_READY:
4216 case RADIO_STATE_SIM_LOCKED_OR_ABSENT:
4217 case RADIO_STATE_SIM_READY:
4218 case RADIO_STATE_RUIM_NOT_READY:
4219 case RADIO_STATE_RUIM_READY:
4220 case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:
4221 return CDMA_SUBSCRIPTION_SOURCE_RUIM_SIM;
4223 case RADIO_STATE_NV_NOT_READY:
4224 case RADIO_STATE_NV_READY:
4225 return CDMA_SUBSCRIPTION_SOURCE_NV;
4228 RLOGD("decodeCdmaSubscriptionSource: Invoked with incorrect RadioState");
4234 decodeSimStatus (RIL_RadioState radioState) {
4235 switch (radioState) {
4236 case RADIO_STATE_SIM_NOT_READY:
4237 case RADIO_STATE_RUIM_NOT_READY:
4238 case RADIO_STATE_NV_NOT_READY:
4239 case RADIO_STATE_NV_READY:
4241 case RADIO_STATE_SIM_LOCKED_OR_ABSENT:
4242 case RADIO_STATE_SIM_READY:
4243 case RADIO_STATE_RUIM_READY:
4244 case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:
4247 RLOGD("decodeSimStatus: Invoked with incorrect RadioState");
4252 static bool is3gpp2(int radioTech) {
4253 switch (radioTech) {
4254 case RADIO_TECH_IS95A:
4255 case RADIO_TECH_IS95B:
4256 case RADIO_TECH_1xRTT:
4257 case RADIO_TECH_EVDO_0:
4258 case RADIO_TECH_EVDO_A:
4259 case RADIO_TECH_EVDO_B:
4260 case RADIO_TECH_EHRPD:
4267 /* If RIL sends SIM states or RUIM states, store the voice radio
4268 * technology and subscription source information so that they can be
4269 * returned when telephony framework requests them
4271 static RIL_RadioState
4272 processRadioState(RIL_RadioState newRadioState, RIL_SOCKET_ID socket_id) {
4274 if((newRadioState > RADIO_STATE_UNAVAILABLE) && (newRadioState < RADIO_STATE_ON)) {
4275 int newVoiceRadioTech;
4276 int newCdmaSubscriptionSource;
4279 /* This is old RIL. Decode Subscription source and Voice Radio Technology
4280 from Radio State and send change notifications if there has been a change */
4281 newVoiceRadioTech = decodeVoiceRadioTechnology(newRadioState);
4282 if(newVoiceRadioTech != voiceRadioTech) {
4283 voiceRadioTech = newVoiceRadioTech;
4284 RIL_UNSOL_RESPONSE(RIL_UNSOL_VOICE_RADIO_TECH_CHANGED,
4285 &voiceRadioTech, sizeof(voiceRadioTech), socket_id);
4287 if(is3gpp2(newVoiceRadioTech)) {
4288 newCdmaSubscriptionSource = decodeCdmaSubscriptionSource(newRadioState);
4289 if(newCdmaSubscriptionSource != cdmaSubscriptionSource) {
4290 cdmaSubscriptionSource = newCdmaSubscriptionSource;
4291 RIL_UNSOL_RESPONSE(RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED,
4292 &cdmaSubscriptionSource, sizeof(cdmaSubscriptionSource), socket_id);
4295 newSimStatus = decodeSimStatus(newRadioState);
4296 if(newSimStatus != simRuimStatus) {
4297 simRuimStatus = newSimStatus;
4298 RIL_UNSOL_RESPONSE(RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, NULL, 0, socket_id);
4301 /* Send RADIO_ON to telephony */
4302 newRadioState = RADIO_STATE_ON;
4305 return newRadioState;
4309 #if defined(ANDROID_MULTI_SIM)
4311 void RIL_onUnsolicitedResponse(int unsolResponse, void *data,
4312 size_t datalen, RIL_SOCKET_ID socket_id)
4315 void RIL_onUnsolicitedResponse(int unsolResponse, void *data,
4319 int unsolResponseIndex;
4321 int64_t timeReceived = 0;
4322 bool shouldScheduleTimeout = false;
4323 RIL_RadioState newState;
4324 RIL_SOCKET_ID soc_id = RIL_SOCKET_1;
4326 #if defined(ANDROID_MULTI_SIM)
4331 if (s_registerCalled == 0) {
4332 // Ignore RIL_onUnsolicitedResponse before RIL_register
4333 RLOGW("RIL_onUnsolicitedResponse called before RIL_register");
4337 unsolResponseIndex = unsolResponse - RIL_UNSOL_RESPONSE_BASE;
4339 if ((unsolResponseIndex < 0)
4340 || (unsolResponseIndex >= (int32_t)NUM_ELEMS(s_unsolResponses))) {
4341 RLOGE("unsupported unsolicited response code %d", unsolResponse);
4345 // Grab a wake lock if needed for this reponse,
4346 // as we exit we'll either release it immediately
4347 // or set a timer to release it later.
4348 switch (s_unsolResponses[unsolResponseIndex].wakeType) {
4350 grabPartialWakeLock();
4351 shouldScheduleTimeout = true;
4356 // No wake lock is grabed so don't set timeout
4357 shouldScheduleTimeout = false;
4361 // Mark the time this was received, doing this
4362 // after grabing the wakelock incase getting
4363 // the elapsedRealTime might cause us to goto
4365 if (unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) {
4366 timeReceived = elapsedRealtime();
4369 appendPrintBuf("[UNSL]< %s", requestToString(unsolResponse));
4373 p.writeInt32 (RESPONSE_UNSOLICITED);
4374 p.writeInt32 (unsolResponse);
4376 ret = s_unsolResponses[unsolResponseIndex]
4377 .responseFunction(p, const_cast<void*>(data), datalen);
4379 // Problem with the response. Don't continue;
4383 // some things get more payload
4384 switch(unsolResponse) {
4385 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED:
4386 newState = processRadioState(CALL_ONSTATEREQUEST(soc_id), soc_id);
4387 p.writeInt32(newState);
4388 appendPrintBuf("%s {%s}", printBuf,
4389 radioStateToString(CALL_ONSTATEREQUEST(soc_id)));
4393 case RIL_UNSOL_NITZ_TIME_RECEIVED:
4394 // Store the time that this was received so the
4395 // handler of this message can account for
4396 // the time it takes to arrive and process. In
4397 // particular the system has been known to sleep
4398 // before this message can be processed.
4399 p.writeInt64(timeReceived);
4403 RLOGI("%s UNSOLICITED: %s length:%d", rilSocketIdToString(soc_id), requestToString(unsolResponse), p.dataSize());
4404 ret = sendResponse(p, soc_id);
4405 if (ret != 0 && unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) {
4407 // Unfortunately, NITZ time is not poll/update like everything
4408 // else in the system. So, if the upstream client isn't connected,
4409 // keep a copy of the last NITZ response (with receive time noted
4410 // above) around so we can deliver it when it is connected
4412 if (s_lastNITZTimeData != NULL) {
4413 free (s_lastNITZTimeData);
4414 s_lastNITZTimeData = NULL;
4417 s_lastNITZTimeData = malloc(p.dataSize());
4418 s_lastNITZTimeDataSize = p.dataSize();
4419 memcpy(s_lastNITZTimeData, p.data(), p.dataSize());
4422 // For now, we automatically go back to sleep after TIMEVAL_WAKE_TIMEOUT
4423 // FIXME The java code should handshake here to release wake lock
4425 if (shouldScheduleTimeout) {
4426 // Cancel the previous request
4427 if (s_last_wake_timeout_info != NULL) {
4428 s_last_wake_timeout_info->userParam = (void *)1;
4431 s_last_wake_timeout_info
4432 = internalRequestTimedCallback(wakeTimeoutCallback, NULL,
4433 &TIMEVAL_WAKE_TIMEOUT);
4440 if (shouldScheduleTimeout) {
4445 /** FIXME generalize this if you track UserCAllbackInfo, clear it
4446 when the callback occurs
4448 static UserCallbackInfo *
4449 internalRequestTimedCallback (RIL_TimedCallback callback, void *param,
4450 const struct timeval *relativeTime)
4452 struct timeval myRelativeTime;
4453 UserCallbackInfo *p_info;
4455 p_info = (UserCallbackInfo *) malloc (sizeof(UserCallbackInfo));
4457 p_info->p_callback = callback;
4458 p_info->userParam = param;
4460 if (relativeTime == NULL) {
4461 /* treat null parameter as a 0 relative time */
4462 memset (&myRelativeTime, 0, sizeof(myRelativeTime));
4464 /* FIXME I think event_add's tv param is really const anyway */
4465 memcpy (&myRelativeTime, relativeTime, sizeof(myRelativeTime));
4468 ril_event_set(&(p_info->event), -1, false, userTimerCallback, p_info);
4470 ril_timer_add(&(p_info->event), &myRelativeTime);
4478 RIL_requestTimedCallback (RIL_TimedCallback callback, void *param,
4479 const struct timeval *relativeTime) {
4480 internalRequestTimedCallback (callback, param, relativeTime);
4484 failCauseToString(RIL_Errno e) {
4486 case RIL_E_SUCCESS: return "E_SUCCESS";
4487 case RIL_E_RADIO_NOT_AVAILABLE: return "E_RADIO_NOT_AVAILABLE";
4488 case RIL_E_GENERIC_FAILURE: return "E_GENERIC_FAILURE";
4489 case RIL_E_PASSWORD_INCORRECT: return "E_PASSWORD_INCORRECT";
4490 case RIL_E_SIM_PIN2: return "E_SIM_PIN2";
4491 case RIL_E_SIM_PUK2: return "E_SIM_PUK2";
4492 case RIL_E_REQUEST_NOT_SUPPORTED: return "E_REQUEST_NOT_SUPPORTED";
4493 case RIL_E_CANCELLED: return "E_CANCELLED";
4494 case RIL_E_OP_NOT_ALLOWED_DURING_VOICE_CALL: return "E_OP_NOT_ALLOWED_DURING_VOICE_CALL";
4495 case RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW: return "E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW";
4496 case RIL_E_SMS_SEND_FAIL_RETRY: return "E_SMS_SEND_FAIL_RETRY";
4497 case RIL_E_SIM_ABSENT:return "E_SIM_ABSENT";
4498 case RIL_E_ILLEGAL_SIM_OR_ME:return "E_ILLEGAL_SIM_OR_ME";
4499 #ifdef FEATURE_MULTIMODE_ANDROID
4500 case RIL_E_SUBSCRIPTION_NOT_AVAILABLE:return "E_SUBSCRIPTION_NOT_AVAILABLE";
4501 case RIL_E_MODE_NOT_SUPPORTED:return "E_MODE_NOT_SUPPORTED";
4503 default: return "<unknown error>";
4508 radioStateToString(RIL_RadioState s) {
4510 case RADIO_STATE_OFF: return "RADIO_OFF";
4511 case RADIO_STATE_UNAVAILABLE: return "RADIO_UNAVAILABLE";
4512 case RADIO_STATE_SIM_NOT_READY: return "RADIO_SIM_NOT_READY";
4513 case RADIO_STATE_SIM_LOCKED_OR_ABSENT: return "RADIO_SIM_LOCKED_OR_ABSENT";
4514 case RADIO_STATE_SIM_READY: return "RADIO_SIM_READY";
4515 case RADIO_STATE_RUIM_NOT_READY:return"RADIO_RUIM_NOT_READY";
4516 case RADIO_STATE_RUIM_READY:return"RADIO_RUIM_READY";
4517 case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:return"RADIO_RUIM_LOCKED_OR_ABSENT";
4518 case RADIO_STATE_NV_NOT_READY:return"RADIO_NV_NOT_READY";
4519 case RADIO_STATE_NV_READY:return"RADIO_NV_READY";
4520 case RADIO_STATE_ON:return"RADIO_ON";
4521 default: return "<unknown state>";
4526 callStateToString(RIL_CallState s) {
4528 case RIL_CALL_ACTIVE : return "ACTIVE";
4529 case RIL_CALL_HOLDING: return "HOLDING";
4530 case RIL_CALL_DIALING: return "DIALING";
4531 case RIL_CALL_ALERTING: return "ALERTING";
4532 case RIL_CALL_INCOMING: return "INCOMING";
4533 case RIL_CALL_WAITING: return "WAITING";
4534 default: return "<unknown state>";
4539 requestToString(int request) {
4541 cat libs/telephony/ril_commands.h \
4542 | egrep "^ *{RIL_" \
4543 | sed -re 's/\{RIL_([^,]+),[^,]+,([^}]+).+/case RIL_\1: return "\1";/'
4546 cat libs/telephony/ril_unsol_commands.h \
4547 | egrep "^ *{RIL_" \
4548 | sed -re 's/\{RIL_([^,]+),([^}]+).+/case RIL_\1: return "\1";/'
4552 case RIL_REQUEST_GET_SIM_STATUS: return "GET_SIM_STATUS";
4553 case RIL_REQUEST_ENTER_SIM_PIN: return "ENTER_SIM_PIN";
4554 case RIL_REQUEST_ENTER_SIM_PUK: return "ENTER_SIM_PUK";
4555 case RIL_REQUEST_ENTER_SIM_PIN2: return "ENTER_SIM_PIN2";
4556 case RIL_REQUEST_ENTER_SIM_PUK2: return "ENTER_SIM_PUK2";
4557 case RIL_REQUEST_CHANGE_SIM_PIN: return "CHANGE_SIM_PIN";
4558 case RIL_REQUEST_CHANGE_SIM_PIN2: return "CHANGE_SIM_PIN2";
4559 case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: return "ENTER_NETWORK_DEPERSONALIZATION";
4560 case RIL_REQUEST_GET_CURRENT_CALLS: return "GET_CURRENT_CALLS";
4561 case RIL_REQUEST_DIAL: return "DIAL";
4562 case RIL_REQUEST_GET_IMSI: return "GET_IMSI";
4563 case RIL_REQUEST_HANGUP: return "HANGUP";
4564 case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: return "HANGUP_WAITING_OR_BACKGROUND";
4565 case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: return "HANGUP_FOREGROUND_RESUME_BACKGROUND";
4566 case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: return "SWITCH_WAITING_OR_HOLDING_AND_ACTIVE";
4567 case RIL_REQUEST_CONFERENCE: return "CONFERENCE";
4568 case RIL_REQUEST_UDUB: return "UDUB";
4569 case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: return "LAST_CALL_FAIL_CAUSE";
4570 case RIL_REQUEST_SIGNAL_STRENGTH: return "SIGNAL_STRENGTH";
4571 case RIL_REQUEST_VOICE_REGISTRATION_STATE: return "VOICE_REGISTRATION_STATE";
4572 case RIL_REQUEST_DATA_REGISTRATION_STATE: return "DATA_REGISTRATION_STATE";
4573 case RIL_REQUEST_OPERATOR: return "OPERATOR";
4574 case RIL_REQUEST_RADIO_POWER: return "RADIO_POWER";
4575 case RIL_REQUEST_DTMF: return "DTMF";
4576 case RIL_REQUEST_SEND_SMS: return "SEND_SMS";
4577 case RIL_REQUEST_SEND_SMS_EXPECT_MORE: return "SEND_SMS_EXPECT_MORE";
4578 case RIL_REQUEST_SETUP_DATA_CALL: return "SETUP_DATA_CALL";
4579 case RIL_REQUEST_SIM_IO: return "SIM_IO";
4580 case RIL_REQUEST_SEND_USSD: return "SEND_USSD";
4581 case RIL_REQUEST_CANCEL_USSD: return "CANCEL_USSD";
4582 case RIL_REQUEST_GET_CLIR: return "GET_CLIR";
4583 case RIL_REQUEST_SET_CLIR: return "SET_CLIR";
4584 case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: return "QUERY_CALL_FORWARD_STATUS";
4585 case RIL_REQUEST_SET_CALL_FORWARD: return "SET_CALL_FORWARD";
4586 case RIL_REQUEST_QUERY_CALL_WAITING: return "QUERY_CALL_WAITING";
4587 case RIL_REQUEST_SET_CALL_WAITING: return "SET_CALL_WAITING";
4588 case RIL_REQUEST_SMS_ACKNOWLEDGE: return "SMS_ACKNOWLEDGE";
4589 case RIL_REQUEST_GET_IMEI: return "GET_IMEI";
4590 case RIL_REQUEST_GET_IMEISV: return "GET_IMEISV";
4591 case RIL_REQUEST_ANSWER: return "ANSWER";
4592 case RIL_REQUEST_DEACTIVATE_DATA_CALL: return "DEACTIVATE_DATA_CALL";
4593 case RIL_REQUEST_QUERY_FACILITY_LOCK: return "QUERY_FACILITY_LOCK";
4594 case RIL_REQUEST_SET_FACILITY_LOCK: return "SET_FACILITY_LOCK";
4595 case RIL_REQUEST_CHANGE_BARRING_PASSWORD: return "CHANGE_BARRING_PASSWORD";
4596 case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: return "QUERY_NETWORK_SELECTION_MODE";
4597 case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: return "SET_NETWORK_SELECTION_AUTOMATIC";
4598 case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: return "SET_NETWORK_SELECTION_MANUAL";
4599 case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : return "QUERY_AVAILABLE_NETWORKS ";
4600 case RIL_REQUEST_DTMF_START: return "DTMF_START";
4601 case RIL_REQUEST_DTMF_STOP: return "DTMF_STOP";
4602 case RIL_REQUEST_BASEBAND_VERSION: return "BASEBAND_VERSION";
4603 case RIL_REQUEST_SEPARATE_CONNECTION: return "SEPARATE_CONNECTION";
4604 case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: return "SET_PREFERRED_NETWORK_TYPE";
4605 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: return "GET_PREFERRED_NETWORK_TYPE";
4606 case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: return "GET_NEIGHBORING_CELL_IDS";
4607 case RIL_REQUEST_SET_MUTE: return "SET_MUTE";
4608 case RIL_REQUEST_GET_MUTE: return "GET_MUTE";
4609 case RIL_REQUEST_QUERY_CLIP: return "QUERY_CLIP";
4610 case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: return "LAST_DATA_CALL_FAIL_CAUSE";
4611 case RIL_REQUEST_DATA_CALL_LIST: return "DATA_CALL_LIST";
4612 case RIL_REQUEST_RESET_RADIO: return "RESET_RADIO";
4613 case RIL_REQUEST_OEM_HOOK_RAW: return "OEM_HOOK_RAW";
4614 case RIL_REQUEST_OEM_HOOK_STRINGS: return "OEM_HOOK_STRINGS";
4615 case RIL_REQUEST_SET_BAND_MODE: return "SET_BAND_MODE";
4616 case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: return "QUERY_AVAILABLE_BAND_MODE";
4617 case RIL_REQUEST_STK_GET_PROFILE: return "STK_GET_PROFILE";
4618 case RIL_REQUEST_STK_SET_PROFILE: return "STK_SET_PROFILE";
4619 case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: return "STK_SEND_ENVELOPE_COMMAND";
4620 case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: return "STK_SEND_TERMINAL_RESPONSE";
4621 case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: return "STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM";
4622 case RIL_REQUEST_SCREEN_STATE: return "SCREEN_STATE";
4623 case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: return "EXPLICIT_CALL_TRANSFER";
4624 case RIL_REQUEST_SET_LOCATION_UPDATES: return "SET_LOCATION_UPDATES";
4625 case RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE:return"CDMA_SET_SUBSCRIPTION_SOURCE";
4626 case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE:return"CDMA_SET_ROAMING_PREFERENCE";
4627 case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE:return"CDMA_QUERY_ROAMING_PREFERENCE";
4628 case RIL_REQUEST_SET_TTY_MODE:return"SET_TTY_MODE";
4629 case RIL_REQUEST_QUERY_TTY_MODE:return"QUERY_TTY_MODE";
4630 case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE";
4631 case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE";
4632 case RIL_REQUEST_CDMA_FLASH:return"CDMA_FLASH";
4633 case RIL_REQUEST_CDMA_BURST_DTMF:return"CDMA_BURST_DTMF";
4634 case RIL_REQUEST_CDMA_SEND_SMS:return"CDMA_SEND_SMS";
4635 case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE:return"CDMA_SMS_ACKNOWLEDGE";
4636 case RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG:return"GSM_GET_BROADCAST_SMS_CONFIG";
4637 case RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG:return"GSM_SET_BROADCAST_SMS_CONFIG";
4638 case RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG:return "CDMA_GET_BROADCAST_SMS_CONFIG";
4639 case RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG:return "CDMA_SET_BROADCAST_SMS_CONFIG";
4640 case RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION:return "CDMA_SMS_BROADCAST_ACTIVATION";
4641 case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: return"CDMA_VALIDATE_AND_WRITE_AKEY";
4642 case RIL_REQUEST_CDMA_SUBSCRIPTION: return"CDMA_SUBSCRIPTION";
4643 case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: return "CDMA_WRITE_SMS_TO_RUIM";
4644 case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: return "CDMA_DELETE_SMS_ON_RUIM";
4645 case RIL_REQUEST_DEVICE_IDENTITY: return "DEVICE_IDENTITY";
4646 case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: return "EXIT_EMERGENCY_CALLBACK_MODE";
4647 case RIL_REQUEST_GET_SMSC_ADDRESS: return "GET_SMSC_ADDRESS";
4648 case RIL_REQUEST_SET_SMSC_ADDRESS: return "SET_SMSC_ADDRESS";
4649 case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: return "REPORT_SMS_MEMORY_STATUS";
4650 case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: return "REPORT_STK_SERVICE_IS_RUNNING";
4651 case RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE: return "CDMA_GET_SUBSCRIPTION_SOURCE";
4652 case RIL_REQUEST_ISIM_AUTHENTICATION: return "ISIM_AUTHENTICATION";
4653 case RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU: return "RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU";
4654 case RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS: return "RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS";
4655 case RIL_REQUEST_VOICE_RADIO_TECH: return "VOICE_RADIO_TECH";
4656 case RIL_REQUEST_GET_CELL_INFO_LIST: return"GET_CELL_INFO_LIST";
4657 case RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE: return"SET_UNSOL_CELL_INFO_LIST_RATE";
4658 case RIL_REQUEST_SET_INITIAL_ATTACH_APN: return "RIL_REQUEST_SET_INITIAL_ATTACH_APN";
4659 case RIL_REQUEST_IMS_REGISTRATION_STATE: return "IMS_REGISTRATION_STATE";
4660 case RIL_REQUEST_IMS_SEND_SMS: return "IMS_SEND_SMS";
4661 case RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC: return "SIM_TRANSMIT_APDU_BASIC";
4662 case RIL_REQUEST_SIM_OPEN_CHANNEL: return "SIM_OPEN_CHANNEL";
4663 case RIL_REQUEST_SIM_CLOSE_CHANNEL: return "SIM_CLOSE_CHANNEL";
4664 case RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL: return "SIM_TRANSMIT_APDU_CHANNEL";
4665 case RIL_REQUEST_SET_UICC_SUBSCRIPTION: return "SET_UICC_SUBSCRIPTION";
4666 case RIL_REQUEST_ALLOW_DATA: return "ALLOW_DATA";
4667 case RIL_REQUEST_GET_HARDWARE_CONFIG: return "GET_HARDWARE_CONFIG";
4668 case RIL_REQUEST_SIM_AUTHENTICATION: return "SIM_AUTHENTICATION";
4669 case RIL_REQUEST_GET_DC_RT_INFO: return "GET_DC_RT_INFO";
4670 case RIL_REQUEST_SET_DC_RT_INFO_RATE: return "SET_DC_RT_INFO_RATE";
4671 case RIL_REQUEST_SET_DATA_PROFILE: return "SET_DATA_PROFILE";
4672 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return "UNSOL_RESPONSE_RADIO_STATE_CHANGED";
4673 case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return "UNSOL_RESPONSE_CALL_STATE_CHANGED";
4674 case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: return "UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED";
4675 case RIL_UNSOL_RESPONSE_NEW_SMS: return "UNSOL_RESPONSE_NEW_SMS";
4676 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: return "UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT";
4677 case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: return "UNSOL_RESPONSE_NEW_SMS_ON_SIM";
4678 case RIL_UNSOL_ON_USSD: return "UNSOL_ON_USSD";
4679 case RIL_UNSOL_ON_USSD_REQUEST: return "UNSOL_ON_USSD_REQUEST(obsolete)";
4680 case RIL_UNSOL_NITZ_TIME_RECEIVED: return "UNSOL_NITZ_TIME_RECEIVED";
4681 case RIL_UNSOL_SIGNAL_STRENGTH: return "UNSOL_SIGNAL_STRENGTH";
4682 case RIL_UNSOL_STK_SESSION_END: return "UNSOL_STK_SESSION_END";
4683 case RIL_UNSOL_STK_PROACTIVE_COMMAND: return "UNSOL_STK_PROACTIVE_COMMAND";
4684 case RIL_UNSOL_STK_EVENT_NOTIFY: return "UNSOL_STK_EVENT_NOTIFY";
4685 case RIL_UNSOL_STK_CALL_SETUP: return "UNSOL_STK_CALL_SETUP";
4686 case RIL_UNSOL_SIM_SMS_STORAGE_FULL: return "UNSOL_SIM_SMS_STORAGE_FUL";
4687 case RIL_UNSOL_SIM_REFRESH: return "UNSOL_SIM_REFRESH";
4688 case RIL_UNSOL_DATA_CALL_LIST_CHANGED: return "UNSOL_DATA_CALL_LIST_CHANGED";
4689 case RIL_UNSOL_CALL_RING: return "UNSOL_CALL_RING";
4690 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: return "UNSOL_RESPONSE_SIM_STATUS_CHANGED";
4691 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: return "UNSOL_NEW_CDMA_SMS";
4692 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: return "UNSOL_NEW_BROADCAST_SMS";
4693 case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: return "UNSOL_CDMA_RUIM_SMS_STORAGE_FULL";
4694 case RIL_UNSOL_RESTRICTED_STATE_CHANGED: return "UNSOL_RESTRICTED_STATE_CHANGED";
4695 case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: return "UNSOL_ENTER_EMERGENCY_CALLBACK_MODE";
4696 case RIL_UNSOL_CDMA_CALL_WAITING: return "UNSOL_CDMA_CALL_WAITING";
4697 case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: return "UNSOL_CDMA_OTA_PROVISION_STATUS";
4698 case RIL_UNSOL_CDMA_INFO_REC: return "UNSOL_CDMA_INFO_REC";
4699 case RIL_UNSOL_OEM_HOOK_RAW: return "UNSOL_OEM_HOOK_RAW";
4700 case RIL_UNSOL_RINGBACK_TONE: return "UNSOL_RINGBACK_TONE";
4701 case RIL_UNSOL_RESEND_INCALL_MUTE: return "UNSOL_RESEND_INCALL_MUTE";
4702 case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: return "UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED";
4703 case RIL_UNSOL_CDMA_PRL_CHANGED: return "UNSOL_CDMA_PRL_CHANGED";
4704 case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: return "UNSOL_EXIT_EMERGENCY_CALLBACK_MODE";
4705 case RIL_UNSOL_RIL_CONNECTED: return "UNSOL_RIL_CONNECTED";
4706 case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED: return "UNSOL_VOICE_RADIO_TECH_CHANGED";
4707 case RIL_UNSOL_CELL_INFO_LIST: return "UNSOL_CELL_INFO_LIST";
4708 case RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED: return "RESPONSE_IMS_NETWORK_STATE_CHANGED";
4709 case RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED: return "UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED";
4710 case RIL_UNSOL_SRVCC_STATE_NOTIFY: return "UNSOL_SRVCC_STATE_NOTIFY";
4711 case RIL_UNSOL_HARDWARE_CONFIG_CHANGED: return "HARDWARE_CONFIG_CHANGED";
4712 case RIL_UNSOL_DC_RT_INFO_CHANGED: return "UNSOL_DC_RT_INFO_CHANGED";
4713 default: return "<unknown request>";
4718 rilSocketIdToString(RIL_SOCKET_ID socket_id)
4722 return "RIL_SOCKET_1";
4723 #if (SIM_COUNT >= 2)
4725 return "RIL_SOCKET_2";
4727 #if (SIM_COUNT >= 3)
4729 return "RIL_SOCKET_3";
4731 #if (SIM_COUNT >= 4)
4733 return "RIL_SOCKET_4";
4736 return "not a valid RIL";
4740 } /* namespace android */