blob: 1d2622929facc35164f22f9479a0a8ce8ab04a81 [file] [log] [blame]
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001/* //device/libs/telephony/ril.cpp
2**
3** Copyright 2006, The Android Open Source Project
4**
Wink Saville7f856802009-06-09 10:23:37 -07005** 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
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08008**
Wink Saville7f856802009-06-09 10:23:37 -07009** http://www.apache.org/licenses/LICENSE-2.0
The Android Open Source Project00f06fc2009-03-03 19:32:15 -080010**
Wink Saville7f856802009-06-09 10:23:37 -070011** 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
The Android Open Source Project00f06fc2009-03-03 19:32:15 -080015** limitations under the License.
16*/
17
18#define LOG_TAG "RILC"
19
20#include <hardware_legacy/power.h>
21
22#include <telephony/ril.h>
Wink Savillef4c4d362009-04-02 01:37:03 -070023#include <telephony/ril_cdma_sms.h>
The Android Open Source Project00f06fc2009-03-03 19:32:15 -080024#include <cutils/sockets.h>
25#include <cutils/jstring.h>
26#include <cutils/record_stream.h>
27#include <utils/Log.h>
28#include <utils/SystemClock.h>
29#include <pthread.h>
Mathias Agopian8a3c48c2009-05-19 19:11:50 -070030#include <binder/Parcel.h>
The Android Open Source Project00f06fc2009-03-03 19:32:15 -080031#include <cutils/jstring.h>
32
33#include <sys/types.h>
34#include <pwd.h>
35
36#include <stdio.h>
37#include <stdlib.h>
38#include <stdarg.h>
39#include <string.h>
40#include <unistd.h>
41#include <fcntl.h>
42#include <time.h>
43#include <errno.h>
44#include <assert.h>
45#include <ctype.h>
46#include <alloca.h>
47#include <sys/un.h>
48#include <assert.h>
49#include <netinet/in.h>
50#include <cutils/properties.h>
51
52#include <ril_event.h>
53
54namespace android {
55
56#define PHONE_PROCESS "radio"
57
58#define SOCKET_NAME_RIL "rild"
59#define SOCKET_NAME_RIL_DEBUG "rild-debug"
60
61#define ANDROID_WAKE_LOCK_NAME "radio-interface"
62
63
64#define PROPERTY_RIL_IMPL "gsm.version.ril-impl"
65
66// match with constant in RIL.java
67#define MAX_COMMAND_BYTES (8 * 1024)
68
69// Basically: memset buffers that the client library
70// shouldn't be using anymore in an attempt to find
71// memory usage issues sooner.
72#define MEMSET_FREED 1
73
74#define NUM_ELEMS(a) (sizeof (a) / sizeof (a)[0])
75
Wink Savillef4c4d362009-04-02 01:37:03 -070076#define MIN(a,b) ((a)<(b) ? (a) : (b))
77
The Android Open Source Project00f06fc2009-03-03 19:32:15 -080078/* Constants for response types */
79#define RESPONSE_SOLICITED 0
80#define RESPONSE_UNSOLICITED 1
81
82/* Negative values for private RIL errno's */
83#define RIL_ERRNO_INVALID_RESPONSE -1
84
85// request, response, and unsolicited msg print macro
86#define PRINTBUF_SIZE 8096
87
88// Enable RILC log
89#define RILC_LOG 0
90
91#if RILC_LOG
92 #define startRequest sprintf(printBuf, "(")
93 #define closeRequest sprintf(printBuf, "%s)", printBuf)
94 #define printRequest(token, req) \
Steve Block64640682011-12-20 20:47:51 +000095 ALOGD("[%04d]> %s %s", token, requestToString(req), printBuf)
The Android Open Source Project00f06fc2009-03-03 19:32:15 -080096
97 #define startResponse sprintf(printBuf, "%s {", printBuf)
98 #define closeResponse sprintf(printBuf, "%s}", printBuf)
Steve Block64640682011-12-20 20:47:51 +000099 #define printResponse ALOGD("%s", printBuf)
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800100
101 #define clearPrintBuf printBuf[0] = 0
102 #define removeLastChar printBuf[strlen(printBuf)-1] = 0
103 #define appendPrintBuf(x...) sprintf(printBuf, x)
104#else
105 #define startRequest
106 #define closeRequest
107 #define printRequest(token, req)
108 #define startResponse
109 #define closeResponse
110 #define printResponse
111 #define clearPrintBuf
112 #define removeLastChar
113 #define appendPrintBuf(x...)
114#endif
115
116enum WakeType {DONT_WAKE, WAKE_PARTIAL};
117
118typedef struct {
119 int requestNumber;
120 void (*dispatchFunction) (Parcel &p, struct RequestInfo *pRI);
121 int(*responseFunction) (Parcel &p, void *response, size_t responselen);
122} CommandInfo;
123
124typedef struct {
125 int requestNumber;
126 int (*responseFunction) (Parcel &p, void *response, size_t responselen);
127 WakeType wakeType;
128} UnsolResponseInfo;
129
130typedef struct RequestInfo {
Wink Saville7f856802009-06-09 10:23:37 -0700131 int32_t token; //this is not RIL_Token
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800132 CommandInfo *pCI;
133 struct RequestInfo *p_next;
134 char cancelled;
135 char local; // responses to local commands do not go back to command process
136} RequestInfo;
137
Wink Saville3d54e742009-05-18 18:00:44 -0700138typedef struct UserCallbackInfo {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800139 RIL_TimedCallback p_callback;
140 void *userParam;
141 struct ril_event event;
142 struct UserCallbackInfo *p_next;
143} UserCallbackInfo;
144
Dianne Hackborn0d9f0c02010-06-25 16:50:46 -0700145
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800146/*******************************************************************/
147
148RIL_RadioFunctions s_callbacks = {0, NULL, NULL, NULL, NULL, NULL};
149static int s_registerCalled = 0;
150
151static pthread_t s_tid_dispatch;
152static pthread_t s_tid_reader;
153static int s_started = 0;
154
155static int s_fdListen = -1;
156static int s_fdCommand = -1;
157static int s_fdDebug = -1;
158
159static int s_fdWakeupRead;
160static int s_fdWakeupWrite;
161
162static struct ril_event s_commands_event;
163static struct ril_event s_wakeupfd_event;
164static struct ril_event s_listen_event;
165static struct ril_event s_wake_timeout_event;
166static struct ril_event s_debug_event;
167
168
169static const struct timeval TIMEVAL_WAKE_TIMEOUT = {1,0};
170
171static pthread_mutex_t s_pendingRequestsMutex = PTHREAD_MUTEX_INITIALIZER;
172static pthread_mutex_t s_writeMutex = PTHREAD_MUTEX_INITIALIZER;
173static pthread_mutex_t s_startupMutex = PTHREAD_MUTEX_INITIALIZER;
174static pthread_cond_t s_startupCond = PTHREAD_COND_INITIALIZER;
175
176static pthread_mutex_t s_dispatchMutex = PTHREAD_MUTEX_INITIALIZER;
177static pthread_cond_t s_dispatchCond = PTHREAD_COND_INITIALIZER;
178
179static RequestInfo *s_pendingRequests = NULL;
180
181static RequestInfo *s_toDispatchHead = NULL;
182static RequestInfo *s_toDispatchTail = NULL;
183
184static UserCallbackInfo *s_last_wake_timeout_info = NULL;
185
186static void *s_lastNITZTimeData = NULL;
187static size_t s_lastNITZTimeDataSize;
188
189#if RILC_LOG
190 static char printBuf[PRINTBUF_SIZE];
191#endif
192
193/*******************************************************************/
194
195static void dispatchVoid (Parcel& p, RequestInfo *pRI);
196static void dispatchString (Parcel& p, RequestInfo *pRI);
197static void dispatchStrings (Parcel& p, RequestInfo *pRI);
198static void dispatchInts (Parcel& p, RequestInfo *pRI);
199static void dispatchDial (Parcel& p, RequestInfo *pRI);
200static void dispatchSIM_IO (Parcel& p, RequestInfo *pRI);
201static void dispatchCallForward(Parcel& p, RequestInfo *pRI);
202static void dispatchRaw(Parcel& p, RequestInfo *pRI);
203static void dispatchSmsWrite (Parcel &p, RequestInfo *pRI);
Lorenzo Colitti4f81dcf2010-09-01 19:38:57 -0700204static void dispatchDataCall (Parcel& p, RequestInfo *pRI);
Naveen Kalla2bc78d62011-12-07 16:22:53 -0800205static void dispatchVoiceRadioTech (Parcel& p, RequestInfo *pRI);
206static void dispatchCdmaSubscriptionSource (Parcel& p, RequestInfo *pRI);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800207
Wink Savillef4c4d362009-04-02 01:37:03 -0700208static void dispatchCdmaSms(Parcel &p, RequestInfo *pRI);
209static void dispatchCdmaSmsAck(Parcel &p, RequestInfo *pRI);
Wink Savillea592eeb2009-05-22 13:26:36 -0700210static void dispatchGsmBrSmsCnf(Parcel &p, RequestInfo *pRI);
Wink Savillef4c4d362009-04-02 01:37:03 -0700211static void dispatchCdmaBrSmsCnf(Parcel &p, RequestInfo *pRI);
212static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800213static int responseInts(Parcel &p, void *response, size_t responselen);
214static int responseStrings(Parcel &p, void *response, size_t responselen);
215static int responseString(Parcel &p, void *response, size_t responselen);
216static int responseVoid(Parcel &p, void *response, size_t responselen);
217static int responseCallList(Parcel &p, void *response, size_t responselen);
218static int responseSMS(Parcel &p, void *response, size_t responselen);
219static int responseSIM_IO(Parcel &p, void *response, size_t responselen);
220static int responseCallForwards(Parcel &p, void *response, size_t responselen);
Wink Savillef4c4d362009-04-02 01:37:03 -0700221static int responseDataCallList(Parcel &p, void *response, size_t responselen);
Wink Saville43808972011-01-13 17:39:51 -0800222static int responseSetupDataCall(Parcel &p, void *response, size_t responselen);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800223static int responseRaw(Parcel &p, void *response, size_t responselen);
224static int responseSsn(Parcel &p, void *response, size_t responselen);
Wink Savillef4c4d362009-04-02 01:37:03 -0700225static int responseSimStatus(Parcel &p, void *response, size_t responselen);
Wink Savillea592eeb2009-05-22 13:26:36 -0700226static int responseGsmBrSmsCnf(Parcel &p, void *response, size_t responselen);
227static int responseCdmaBrSmsCnf(Parcel &p, void *response, size_t responselen);
Wink Savillef4c4d362009-04-02 01:37:03 -0700228static int responseCdmaSms(Parcel &p, void *response, size_t responselen);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800229static int responseCellList(Parcel &p, void *response, size_t responselen);
Wink Saville3d54e742009-05-18 18:00:44 -0700230static int responseCdmaInformationRecords(Parcel &p,void *response, size_t responselen);
231static int responseRilSignalStrength(Parcel &p,void *response, size_t responselen);
232static int responseCallRing(Parcel &p, void *response, size_t responselen);
233static int responseCdmaSignalInfoRecord(Parcel &p,void *response, size_t responselen);
234static int responseCdmaCallWaiting(Parcel &p,void *response, size_t responselen);
Alex Yakavenka45e740e2012-01-31 11:48:27 -0800235static int responseSimRefresh(Parcel &p, void *response, size_t responselen);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800236
Naveen Kalla2bc78d62011-12-07 16:22:53 -0800237static int decodeVoiceRadioTechnology (RIL_RadioState radioState);
238static int decodeCdmaSubscriptionSource (RIL_RadioState radioState);
239static RIL_RadioState processRadioState(RIL_RadioState newRadioState);
240
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800241extern "C" const char * requestToString(int request);
242extern "C" const char * failCauseToString(RIL_Errno);
243extern "C" const char * callStateToString(RIL_CallState);
244extern "C" const char * radioStateToString(RIL_RadioState);
245
246#ifdef RIL_SHLIB
Wink Saville7f856802009-06-09 10:23:37 -0700247extern "C" void RIL_onUnsolicitedResponse(int unsolResponse, void *data,
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800248 size_t datalen);
249#endif
250
Wink Saville7f856802009-06-09 10:23:37 -0700251static UserCallbackInfo * internalRequestTimedCallback
Dianne Hackborn0d9f0c02010-06-25 16:50:46 -0700252 (RIL_TimedCallback callback, void *param,
253 const struct timeval *relativeTime);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800254
255/** Index == requestNumber */
256static CommandInfo s_commands[] = {
257#include "ril_commands.h"
258};
259
260static UnsolResponseInfo s_unsolResponses[] = {
261#include "ril_unsol_commands.h"
262};
263
Naveen Kalla2bc78d62011-12-07 16:22:53 -0800264/* For older RILs that do not support new commands RIL_REQUEST_VOICE_RADIO_TECH and
265 RIL_UNSOL_VOICE_RADIO_TECH_CHANGED messages, decode the voice radio tech from
266 radio state message and store it. Every time there is a change in Radio State
267 check to see if voice radio tech changes and notify telephony
268 */
269int voiceRadioTech = -1;
270
271/* For older RILs that do not support new commands RIL_REQUEST_GET_CDMA_SUBSCRIPTION_SOURCE
272 and RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED messages, decode the subscription
273 source from radio state and store it. Every time there is a change in Radio State
274 check to see if subscription source changed and notify telephony
275 */
276int cdmaSubscriptionSource = -1;
277
278/* For older RILs that do not send RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, decode the
279 SIM/RUIM state from radio state and store it. Every time there is a change in Radio State,
280 check to see if SIM/RUIM status changed and notify telephony
281 */
282int simRuimStatus = -1;
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800283
284static char *
Wink Savillef4c4d362009-04-02 01:37:03 -0700285strdupReadString(Parcel &p) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800286 size_t stringlen;
287 const char16_t *s16;
Wink Saville7f856802009-06-09 10:23:37 -0700288
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800289 s16 = p.readString16Inplace(&stringlen);
Wink Saville7f856802009-06-09 10:23:37 -0700290
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800291 return strndup16to8(s16, stringlen);
292}
293
Wink Savillef4c4d362009-04-02 01:37:03 -0700294static void writeStringToParcel(Parcel &p, const char *s) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800295 char16_t *s16;
296 size_t s16_len;
297 s16 = strdup8to16(s, &s16_len);
298 p.writeString16(s16, s16_len);
299 free(s16);
300}
301
302
303static void
Wink Savillef4c4d362009-04-02 01:37:03 -0700304memsetString (char *s) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800305 if (s != NULL) {
306 memset (s, 0, strlen(s));
307 }
308}
309
310void nullParcelReleaseFunction (const uint8_t* data, size_t dataSize,
311 const size_t* objects, size_t objectsSize,
Wink Savillef4c4d362009-04-02 01:37:03 -0700312 void* cookie) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800313 // do nothing -- the data reference lives longer than the Parcel object
314}
315
Wink Saville7f856802009-06-09 10:23:37 -0700316/**
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800317 * To be called from dispatch thread
318 * Issue a single local request, ensuring that the response
Wink Saville7f856802009-06-09 10:23:37 -0700319 * is not sent back up to the command process
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800320 */
321static void
Wink Savillef4c4d362009-04-02 01:37:03 -0700322issueLocalRequest(int request, void *data, int len) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800323 RequestInfo *pRI;
324 int ret;
325
326 pRI = (RequestInfo *)calloc(1, sizeof(RequestInfo));
327
328 pRI->local = 1;
329 pRI->token = 0xffffffff; // token is not used in this context
330 pRI->pCI = &(s_commands[request]);
331
332 ret = pthread_mutex_lock(&s_pendingRequestsMutex);
333 assert (ret == 0);
334
335 pRI->p_next = s_pendingRequests;
336 s_pendingRequests = pRI;
337
338 ret = pthread_mutex_unlock(&s_pendingRequestsMutex);
339 assert (ret == 0);
340
Steve Block64640682011-12-20 20:47:51 +0000341 ALOGD("C[locl]> %s", requestToString(request));
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800342
343 s_callbacks.onRequest(request, data, len, pRI);
344}
345
346
347
348static int
Wink Savillef4c4d362009-04-02 01:37:03 -0700349processCommandBuffer(void *buffer, size_t buflen) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800350 Parcel p;
351 status_t status;
352 int32_t request;
353 int32_t token;
354 RequestInfo *pRI;
355 int ret;
356
357 p.setData((uint8_t *) buffer, buflen);
358
359 // status checked at end
360 status = p.readInt32(&request);
361 status = p.readInt32 (&token);
362
363 if (status != NO_ERROR) {
Steve Blockf423cde2012-01-08 13:48:26 +0000364 ALOGE("invalid request block");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800365 return 0;
366 }
367
368 if (request < 1 || request >= (int32_t)NUM_ELEMS(s_commands)) {
Steve Blockf423cde2012-01-08 13:48:26 +0000369 ALOGE("unsupported request code %d token %d", request, token);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800370 // FIXME this should perhaps return a response
371 return 0;
372 }
373
374
375 pRI = (RequestInfo *)calloc(1, sizeof(RequestInfo));
376
377 pRI->token = token;
378 pRI->pCI = &(s_commands[request]);
379
380 ret = pthread_mutex_lock(&s_pendingRequestsMutex);
381 assert (ret == 0);
382
383 pRI->p_next = s_pendingRequests;
384 s_pendingRequests = pRI;
385
386 ret = pthread_mutex_unlock(&s_pendingRequestsMutex);
387 assert (ret == 0);
388
389/* sLastDispatchedToken = token; */
390
Wink Saville7f856802009-06-09 10:23:37 -0700391 pRI->pCI->dispatchFunction(p, pRI);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800392
393 return 0;
394}
395
396static void
Wink Savillef4c4d362009-04-02 01:37:03 -0700397invalidCommandBlock (RequestInfo *pRI) {
Steve Blockf423cde2012-01-08 13:48:26 +0000398 ALOGE("invalid command block for token %d request %s",
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800399 pRI->token, requestToString(pRI->pCI->requestNumber));
400}
401
402/** Callee expects NULL */
Wink Saville7f856802009-06-09 10:23:37 -0700403static void
Wink Savillef4c4d362009-04-02 01:37:03 -0700404dispatchVoid (Parcel& p, RequestInfo *pRI) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800405 clearPrintBuf;
406 printRequest(pRI->token, pRI->pCI->requestNumber);
407 s_callbacks.onRequest(pRI->pCI->requestNumber, NULL, 0, pRI);
408}
409
410/** Callee expects const char * */
411static void
Wink Savillef4c4d362009-04-02 01:37:03 -0700412dispatchString (Parcel& p, RequestInfo *pRI) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800413 status_t status;
414 size_t datalen;
415 size_t stringlen;
416 char *string8 = NULL;
417
418 string8 = strdupReadString(p);
419
420 startRequest;
421 appendPrintBuf("%s%s", printBuf, string8);
422 closeRequest;
423 printRequest(pRI->token, pRI->pCI->requestNumber);
424
425 s_callbacks.onRequest(pRI->pCI->requestNumber, string8,
426 sizeof(char *), pRI);
427
428#ifdef MEMSET_FREED
429 memsetString(string8);
430#endif
431
432 free(string8);
433 return;
434invalid:
435 invalidCommandBlock(pRI);
436 return;
437}
438
439/** Callee expects const char ** */
440static void
Wink Savillef4c4d362009-04-02 01:37:03 -0700441dispatchStrings (Parcel &p, RequestInfo *pRI) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800442 int32_t countStrings;
443 status_t status;
444 size_t datalen;
445 char **pStrings;
446
447 status = p.readInt32 (&countStrings);
448
449 if (status != NO_ERROR) {
450 goto invalid;
451 }
452
453 startRequest;
454 if (countStrings == 0) {
455 // just some non-null pointer
456 pStrings = (char **)alloca(sizeof(char *));
457 datalen = 0;
458 } else if (((int)countStrings) == -1) {
459 pStrings = NULL;
460 datalen = 0;
461 } else {
462 datalen = sizeof(char *) * countStrings;
Wink Saville7f856802009-06-09 10:23:37 -0700463
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800464 pStrings = (char **)alloca(datalen);
465
466 for (int i = 0 ; i < countStrings ; i++) {
467 pStrings[i] = strdupReadString(p);
468 appendPrintBuf("%s%s,", printBuf, pStrings[i]);
469 }
470 }
471 removeLastChar;
472 closeRequest;
473 printRequest(pRI->token, pRI->pCI->requestNumber);
474
475 s_callbacks.onRequest(pRI->pCI->requestNumber, pStrings, datalen, pRI);
476
477 if (pStrings != NULL) {
478 for (int i = 0 ; i < countStrings ; i++) {
479#ifdef MEMSET_FREED
480 memsetString (pStrings[i]);
481#endif
482 free(pStrings[i]);
483 }
484
485#ifdef MEMSET_FREED
486 memset(pStrings, 0, datalen);
487#endif
488 }
Wink Saville7f856802009-06-09 10:23:37 -0700489
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800490 return;
491invalid:
492 invalidCommandBlock(pRI);
493 return;
494}
495
496/** Callee expects const int * */
497static void
Wink Savillef4c4d362009-04-02 01:37:03 -0700498dispatchInts (Parcel &p, RequestInfo *pRI) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800499 int32_t count;
500 status_t status;
501 size_t datalen;
502 int *pInts;
503
504 status = p.readInt32 (&count);
505
506 if (status != NO_ERROR || count == 0) {
507 goto invalid;
508 }
509
510 datalen = sizeof(int) * count;
511 pInts = (int *)alloca(datalen);
512
513 startRequest;
514 for (int i = 0 ; i < count ; i++) {
515 int32_t t;
516
517 status = p.readInt32(&t);
518 pInts[i] = (int)t;
519 appendPrintBuf("%s%d,", printBuf, t);
520
521 if (status != NO_ERROR) {
522 goto invalid;
523 }
524 }
525 removeLastChar;
526 closeRequest;
527 printRequest(pRI->token, pRI->pCI->requestNumber);
528
Wink Saville7f856802009-06-09 10:23:37 -0700529 s_callbacks.onRequest(pRI->pCI->requestNumber, const_cast<int *>(pInts),
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800530 datalen, pRI);
531
532#ifdef MEMSET_FREED
533 memset(pInts, 0, datalen);
534#endif
535
536 return;
537invalid:
538 invalidCommandBlock(pRI);
539 return;
540}
541
542
Wink Saville7f856802009-06-09 10:23:37 -0700543/**
544 * Callee expects const RIL_SMS_WriteArgs *
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800545 * Payload is:
546 * int32_t status
547 * String pdu
548 */
549static void
Wink Savillef4c4d362009-04-02 01:37:03 -0700550dispatchSmsWrite (Parcel &p, RequestInfo *pRI) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800551 RIL_SMS_WriteArgs args;
552 int32_t t;
553 status_t status;
554
555 memset (&args, 0, sizeof(args));
556
557 status = p.readInt32(&t);
558 args.status = (int)t;
559
560 args.pdu = strdupReadString(p);
561
562 if (status != NO_ERROR || args.pdu == NULL) {
563 goto invalid;
564 }
565
566 args.smsc = strdupReadString(p);
567
568 startRequest;
569 appendPrintBuf("%s%d,%s,smsc=%s", printBuf, args.status,
570 (char*)args.pdu, (char*)args.smsc);
571 closeRequest;
572 printRequest(pRI->token, pRI->pCI->requestNumber);
Wink Saville7f856802009-06-09 10:23:37 -0700573
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800574 s_callbacks.onRequest(pRI->pCI->requestNumber, &args, sizeof(args), pRI);
575
576#ifdef MEMSET_FREED
577 memsetString (args.pdu);
578#endif
579
580 free (args.pdu);
Wink Saville7f856802009-06-09 10:23:37 -0700581
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800582#ifdef MEMSET_FREED
583 memset(&args, 0, sizeof(args));
584#endif
585
586 return;
587invalid:
588 invalidCommandBlock(pRI);
589 return;
590}
591
Wink Saville7f856802009-06-09 10:23:37 -0700592/**
593 * Callee expects const RIL_Dial *
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800594 * Payload is:
595 * String address
596 * int32_t clir
597 */
598static void
Wink Savillef4c4d362009-04-02 01:37:03 -0700599dispatchDial (Parcel &p, RequestInfo *pRI) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800600 RIL_Dial dial;
Wink Saville74fa3882009-12-22 15:35:41 -0800601 RIL_UUS_Info uusInfo;
Wink Saville7bce0822010-01-08 15:20:12 -0800602 int32_t sizeOfDial;
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800603 int32_t t;
Wink Saville74fa3882009-12-22 15:35:41 -0800604 int32_t uusPresent;
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800605 status_t status;
606
607 memset (&dial, 0, sizeof(dial));
608
609 dial.address = strdupReadString(p);
610
611 status = p.readInt32(&t);
612 dial.clir = (int)t;
613
614 if (status != NO_ERROR || dial.address == NULL) {
615 goto invalid;
616 }
617
Wink Saville3a4840b2010-04-07 13:29:58 -0700618 if (s_callbacks.version < 3) { // Remove when partners upgrade to version 3
Wink Saville74fa3882009-12-22 15:35:41 -0800619 uusPresent = 0;
Wink Saville7bce0822010-01-08 15:20:12 -0800620 sizeOfDial = sizeof(dial) - sizeof(RIL_UUS_Info *);
Wink Saville74fa3882009-12-22 15:35:41 -0800621 } else {
622 status = p.readInt32(&uusPresent);
623
624 if (status != NO_ERROR) {
625 goto invalid;
626 }
627
628 if (uusPresent == 0) {
629 dial.uusInfo = NULL;
630 } else {
631 int32_t len;
632
633 memset(&uusInfo, 0, sizeof(RIL_UUS_Info));
634
635 status = p.readInt32(&t);
636 uusInfo.uusType = (RIL_UUS_Type) t;
637
638 status = p.readInt32(&t);
639 uusInfo.uusDcs = (RIL_UUS_DCS) t;
640
641 status = p.readInt32(&len);
642 if (status != NO_ERROR) {
643 goto invalid;
644 }
645
646 // The java code writes -1 for null arrays
647 if (((int) len) == -1) {
648 uusInfo.uusData = NULL;
649 len = 0;
650 } else {
651 uusInfo.uusData = (char*) p.readInplace(len);
652 }
653
654 uusInfo.uusLength = len;
655 dial.uusInfo = &uusInfo;
656 }
Wink Saville7bce0822010-01-08 15:20:12 -0800657 sizeOfDial = sizeof(dial);
Wink Saville74fa3882009-12-22 15:35:41 -0800658 }
659
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800660 startRequest;
661 appendPrintBuf("%snum=%s,clir=%d", printBuf, dial.address, dial.clir);
Wink Saville74fa3882009-12-22 15:35:41 -0800662 if (uusPresent) {
663 appendPrintBuf("%s,uusType=%d,uusDcs=%d,uusLen=%d", printBuf,
664 dial.uusInfo->uusType, dial.uusInfo->uusDcs,
665 dial.uusInfo->uusLength);
666 }
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800667 closeRequest;
668 printRequest(pRI->token, pRI->pCI->requestNumber);
669
Wink Saville7bce0822010-01-08 15:20:12 -0800670 s_callbacks.onRequest(pRI->pCI->requestNumber, &dial, sizeOfDial, pRI);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800671
672#ifdef MEMSET_FREED
673 memsetString (dial.address);
674#endif
675
676 free (dial.address);
Wink Saville7f856802009-06-09 10:23:37 -0700677
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800678#ifdef MEMSET_FREED
Wink Saville74fa3882009-12-22 15:35:41 -0800679 memset(&uusInfo, 0, sizeof(RIL_UUS_Info));
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800680 memset(&dial, 0, sizeof(dial));
681#endif
682
683 return;
684invalid:
685 invalidCommandBlock(pRI);
686 return;
687}
688
Wink Saville7f856802009-06-09 10:23:37 -0700689/**
690 * Callee expects const RIL_SIM_IO *
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800691 * Payload is:
692 * int32_t command
693 * int32_t fileid
694 * String path
695 * int32_t p1, p2, p3
Wink Saville7f856802009-06-09 10:23:37 -0700696 * String data
697 * String pin2
Wink Savillec0114b32011-02-18 10:14:07 -0800698 * String aidPtr
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800699 */
700static void
Wink Savillef4c4d362009-04-02 01:37:03 -0700701dispatchSIM_IO (Parcel &p, RequestInfo *pRI) {
Wink Savillec0114b32011-02-18 10:14:07 -0800702 union RIL_SIM_IO {
703 RIL_SIM_IO_v6 v6;
704 RIL_SIM_IO_v5 v5;
705 } simIO;
706
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800707 int32_t t;
Wink Savillec0114b32011-02-18 10:14:07 -0800708 int size;
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800709 status_t status;
710
711 memset (&simIO, 0, sizeof(simIO));
712
Wink Saville7f856802009-06-09 10:23:37 -0700713 // note we only check status at the end
714
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800715 status = p.readInt32(&t);
Wink Savillec0114b32011-02-18 10:14:07 -0800716 simIO.v6.command = (int)t;
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800717
718 status = p.readInt32(&t);
Wink Savillec0114b32011-02-18 10:14:07 -0800719 simIO.v6.fileid = (int)t;
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800720
Wink Savillec0114b32011-02-18 10:14:07 -0800721 simIO.v6.path = strdupReadString(p);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800722
723 status = p.readInt32(&t);
Wink Savillec0114b32011-02-18 10:14:07 -0800724 simIO.v6.p1 = (int)t;
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800725
726 status = p.readInt32(&t);
Wink Savillec0114b32011-02-18 10:14:07 -0800727 simIO.v6.p2 = (int)t;
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800728
729 status = p.readInt32(&t);
Wink Savillec0114b32011-02-18 10:14:07 -0800730 simIO.v6.p3 = (int)t;
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800731
Wink Savillec0114b32011-02-18 10:14:07 -0800732 simIO.v6.data = strdupReadString(p);
733 simIO.v6.pin2 = strdupReadString(p);
734 simIO.v6.aidPtr = strdupReadString(p);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800735
736 startRequest;
Wink Savillec0114b32011-02-18 10:14:07 -0800737 appendPrintBuf("%scmd=0x%X,efid=0x%X,path=%s,%d,%d,%d,%s,pin2=%s,aid=%s", printBuf,
738 simIO.v6.command, simIO.v6.fileid, (char*)simIO.v6.path,
739 simIO.v6.p1, simIO.v6.p2, simIO.v6.p3,
740 (char*)simIO.v6.data, (char*)simIO.v6.pin2, simIO.v6.aidPtr);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800741 closeRequest;
742 printRequest(pRI->token, pRI->pCI->requestNumber);
Wink Saville7f856802009-06-09 10:23:37 -0700743
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800744 if (status != NO_ERROR) {
745 goto invalid;
746 }
747
Wink Savillec0114b32011-02-18 10:14:07 -0800748 size = (s_callbacks.version < 6) ? sizeof(simIO.v5) : sizeof(simIO.v6);
749 s_callbacks.onRequest(pRI->pCI->requestNumber, &simIO, size, pRI);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800750
751#ifdef MEMSET_FREED
Wink Savillec0114b32011-02-18 10:14:07 -0800752 memsetString (simIO.v6.path);
753 memsetString (simIO.v6.data);
754 memsetString (simIO.v6.pin2);
755 memsetString (simIO.v6.aidPtr);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800756#endif
757
Wink Savillec0114b32011-02-18 10:14:07 -0800758 free (simIO.v6.path);
759 free (simIO.v6.data);
760 free (simIO.v6.pin2);
761 free (simIO.v6.aidPtr);
Wink Saville7f856802009-06-09 10:23:37 -0700762
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800763#ifdef MEMSET_FREED
764 memset(&simIO, 0, sizeof(simIO));
765#endif
766
767 return;
768invalid:
769 invalidCommandBlock(pRI);
770 return;
771}
772
773/**
774 * Callee expects const RIL_CallForwardInfo *
775 * Payload is:
776 * int32_t status/action
777 * int32_t reason
778 * int32_t serviceCode
779 * int32_t toa
780 * String number (0 length -> null)
781 * int32_t timeSeconds
782 */
Wink Saville7f856802009-06-09 10:23:37 -0700783static void
Wink Savillef4c4d362009-04-02 01:37:03 -0700784dispatchCallForward(Parcel &p, RequestInfo *pRI) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800785 RIL_CallForwardInfo cff;
786 int32_t t;
787 status_t status;
788
789 memset (&cff, 0, sizeof(cff));
790
Wink Saville7f856802009-06-09 10:23:37 -0700791 // note we only check status at the end
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800792
793 status = p.readInt32(&t);
794 cff.status = (int)t;
Wink Saville7f856802009-06-09 10:23:37 -0700795
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800796 status = p.readInt32(&t);
797 cff.reason = (int)t;
798
799 status = p.readInt32(&t);
800 cff.serviceClass = (int)t;
801
802 status = p.readInt32(&t);
803 cff.toa = (int)t;
804
805 cff.number = strdupReadString(p);
806
807 status = p.readInt32(&t);
808 cff.timeSeconds = (int)t;
809
810 if (status != NO_ERROR) {
811 goto invalid;
812 }
813
814 // special case: number 0-length fields is null
815
816 if (cff.number != NULL && strlen (cff.number) == 0) {
817 cff.number = NULL;
818 }
819
820 startRequest;
821 appendPrintBuf("%sstat=%d,reason=%d,serv=%d,toa=%d,%s,tout=%d", printBuf,
822 cff.status, cff.reason, cff.serviceClass, cff.toa,
823 (char*)cff.number, cff.timeSeconds);
824 closeRequest;
825 printRequest(pRI->token, pRI->pCI->requestNumber);
826
827 s_callbacks.onRequest(pRI->pCI->requestNumber, &cff, sizeof(cff), pRI);
828
829#ifdef MEMSET_FREED
830 memsetString(cff.number);
831#endif
832
833 free (cff.number);
834
835#ifdef MEMSET_FREED
836 memset(&cff, 0, sizeof(cff));
837#endif
838
839 return;
840invalid:
841 invalidCommandBlock(pRI);
842 return;
843}
844
845
Wink Saville7f856802009-06-09 10:23:37 -0700846static void
Wink Savillef4c4d362009-04-02 01:37:03 -0700847dispatchRaw(Parcel &p, RequestInfo *pRI) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800848 int32_t len;
849 status_t status;
850 const void *data;
851
852 status = p.readInt32(&len);
853
854 if (status != NO_ERROR) {
855 goto invalid;
856 }
857
858 // The java code writes -1 for null arrays
859 if (((int)len) == -1) {
860 data = NULL;
861 len = 0;
Wink Saville7f856802009-06-09 10:23:37 -0700862 }
The Android Open Source Project00f06fc2009-03-03 19:32:15 -0800863
864 data = p.readInplace(len);
865
866 startRequest;
867 appendPrintBuf("%sraw_size=%d", printBuf, len);
868 closeRequest;
869 printRequest(pRI->token, pRI->pCI->requestNumber);
870
871 s_callbacks.onRequest(pRI->pCI->requestNumber, const_cast<void *>(data), len, pRI);
872
873 return;
874invalid:
875 invalidCommandBlock(pRI);
876 return;
877}
878
Wink Saville7f856802009-06-09 10:23:37 -0700879static void
Wink Savillef4c4d362009-04-02 01:37:03 -0700880dispatchCdmaSms(Parcel &p, RequestInfo *pRI) {
881 RIL_CDMA_SMS_Message rcsm;
882 int32_t t;
883 uint8_t ut;
884 status_t status;
885 int32_t digitCount;
886 int digitLimit;
Wink Saville7f856802009-06-09 10:23:37 -0700887
Wink Savillef4c4d362009-04-02 01:37:03 -0700888 memset(&rcsm, 0, sizeof(rcsm));
889
890 status = p.readInt32(&t);
891 rcsm.uTeleserviceID = (int) t;
892
893 status = p.read(&ut,sizeof(ut));
894 rcsm.bIsServicePresent = (uint8_t) ut;
895
896 status = p.readInt32(&t);
897 rcsm.uServicecategory = (int) t;
898
899 status = p.readInt32(&t);
900 rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) t;
901
902 status = p.readInt32(&t);
903 rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) t;
904
905 status = p.readInt32(&t);
906 rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) t;
907
908 status = p.readInt32(&t);
909 rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) t;
910
911 status = p.read(&ut,sizeof(ut));
912 rcsm.sAddress.number_of_digits= (uint8_t) ut;
913
914 digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
915 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
916 status = p.read(&ut,sizeof(ut));
917 rcsm.sAddress.digits[digitCount] = (uint8_t) ut;
918 }
919
Wink Saville7f856802009-06-09 10:23:37 -0700920 status = p.readInt32(&t);
Wink Savillef4c4d362009-04-02 01:37:03 -0700921 rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) t;
922
Wink Saville7f856802009-06-09 10:23:37 -0700923 status = p.read(&ut,sizeof(ut));
Wink Savillef4c4d362009-04-02 01:37:03 -0700924 rcsm.sSubAddress.odd = (uint8_t) ut;
925
926 status = p.read(&ut,sizeof(ut));
927 rcsm.sSubAddress.number_of_digits = (uint8_t) ut;
928
929 digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
Wink Saville7f856802009-06-09 10:23:37 -0700930 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
931 status = p.read(&ut,sizeof(ut));
Wink Savillef4c4d362009-04-02 01:37:03 -0700932 rcsm.sSubAddress.digits[digitCount] = (uint8_t) ut;
933 }
934
Wink Saville7f856802009-06-09 10:23:37 -0700935 status = p.readInt32(&t);
Wink Savillef4c4d362009-04-02 01:37:03 -0700936 rcsm.uBearerDataLen = (int) t;
937
938 digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
Wink Saville7f856802009-06-09 10:23:37 -0700939 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
940 status = p.read(&ut, sizeof(ut));
Wink Savillef4c4d362009-04-02 01:37:03 -0700941 rcsm.aBearerData[digitCount] = (uint8_t) ut;
942 }
943
944 if (status != NO_ERROR) {
945 goto invalid;
946 }
947
948 startRequest;
949 appendPrintBuf("%suTeleserviceID=%d, bIsServicePresent=%d, uServicecategory=%d, \
Wink Saville1b5fd232009-04-22 14:50:00 -0700950 sAddress.digit_mode=%d, sAddress.Number_mode=%d, sAddress.number_type=%d, ",
Wink Savillef4c4d362009-04-02 01:37:03 -0700951 printBuf, rcsm.uTeleserviceID,rcsm.bIsServicePresent,rcsm.uServicecategory,
Wink Saville1b5fd232009-04-22 14:50:00 -0700952 rcsm.sAddress.digit_mode, rcsm.sAddress.number_mode,rcsm.sAddress.number_type);
Wink Savillef4c4d362009-04-02 01:37:03 -0700953 closeRequest;
Wink Saville7f856802009-06-09 10:23:37 -0700954
Wink Savillef4c4d362009-04-02 01:37:03 -0700955 printRequest(pRI->token, pRI->pCI->requestNumber);
956
957 s_callbacks.onRequest(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm),pRI);
958
959#ifdef MEMSET_FREED
960 memset(&rcsm, 0, sizeof(rcsm));
961#endif
962
963 return;
964
965invalid:
966 invalidCommandBlock(pRI);
967 return;
968}
969
Wink Saville7f856802009-06-09 10:23:37 -0700970static void
Wink Savillef4c4d362009-04-02 01:37:03 -0700971dispatchCdmaSmsAck(Parcel &p, RequestInfo *pRI) {
972 RIL_CDMA_SMS_Ack rcsa;
973 int32_t t;
974 status_t status;
975 int32_t digitCount;
976
977 memset(&rcsa, 0, sizeof(rcsa));
978
979 status = p.readInt32(&t);
980 rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) t;
981
982 status = p.readInt32(&t);
983 rcsa.uSMSCauseCode = (int) t;
984
985 if (status != NO_ERROR) {
986 goto invalid;
987 }
988
989 startRequest;
Wink Saville1b5fd232009-04-22 14:50:00 -0700990 appendPrintBuf("%suErrorClass=%d, uTLStatus=%d, ",
991 printBuf, rcsa.uErrorClass, rcsa.uSMSCauseCode);
Wink Savillef4c4d362009-04-02 01:37:03 -0700992 closeRequest;
993
994 printRequest(pRI->token, pRI->pCI->requestNumber);
995
996 s_callbacks.onRequest(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa),pRI);
997
998#ifdef MEMSET_FREED
999 memset(&rcsa, 0, sizeof(rcsa));
1000#endif
1001
1002 return;
1003
1004invalid:
1005 invalidCommandBlock(pRI);
1006 return;
1007}
1008
Wink Savillea592eeb2009-05-22 13:26:36 -07001009static void
1010dispatchGsmBrSmsCnf(Parcel &p, RequestInfo *pRI) {
1011 int32_t t;
Wink Savillef4c4d362009-04-02 01:37:03 -07001012 status_t status;
Wink Savillea592eeb2009-05-22 13:26:36 -07001013 int32_t num;
Wink Savillef4c4d362009-04-02 01:37:03 -07001014
Wink Savillea592eeb2009-05-22 13:26:36 -07001015 status = p.readInt32(&num);
Wink Savillef4c4d362009-04-02 01:37:03 -07001016 if (status != NO_ERROR) {
1017 goto invalid;
1018 }
1019
Wink Savillea592eeb2009-05-22 13:26:36 -07001020 RIL_GSM_BroadcastSmsConfigInfo gsmBci[num];
1021 RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num];
1022
Wink Savillef4c4d362009-04-02 01:37:03 -07001023 startRequest;
Wink Savillea592eeb2009-05-22 13:26:36 -07001024 for (int i = 0 ; i < num ; i++ ) {
1025 gsmBciPtrs[i] = &gsmBci[i];
Wink Savillef4c4d362009-04-02 01:37:03 -07001026
Wink Savillea592eeb2009-05-22 13:26:36 -07001027 status = p.readInt32(&t);
1028 gsmBci[i].fromServiceId = (int) t;
Wink Savillef4c4d362009-04-02 01:37:03 -07001029
Wink Savillea592eeb2009-05-22 13:26:36 -07001030 status = p.readInt32(&t);
1031 gsmBci[i].toServiceId = (int) t;
Wink Savillef4c4d362009-04-02 01:37:03 -07001032
Wink Savillea592eeb2009-05-22 13:26:36 -07001033 status = p.readInt32(&t);
1034 gsmBci[i].fromCodeScheme = (int) t;
Wink Savillef4c4d362009-04-02 01:37:03 -07001035
Wink Savillea592eeb2009-05-22 13:26:36 -07001036 status = p.readInt32(&t);
1037 gsmBci[i].toCodeScheme = (int) t;
Wink Savillef4c4d362009-04-02 01:37:03 -07001038
Wink Savillea592eeb2009-05-22 13:26:36 -07001039 status = p.readInt32(&t);
1040 gsmBci[i].selected = (uint8_t) t;
Wink Savillef4c4d362009-04-02 01:37:03 -07001041
Wink Savillea592eeb2009-05-22 13:26:36 -07001042 appendPrintBuf("%s [%d: fromServiceId=%d, toServiceId =%d, \
1043 fromCodeScheme=%d, toCodeScheme=%d, selected =%d]", printBuf, i,
1044 gsmBci[i].fromServiceId, gsmBci[i].toServiceId,
1045 gsmBci[i].fromCodeScheme, gsmBci[i].toCodeScheme,
1046 gsmBci[i].selected);
Wink Savillef5903df2009-04-24 11:54:14 -07001047 }
Wink Savillea592eeb2009-05-22 13:26:36 -07001048 closeRequest;
Wink Savillef4c4d362009-04-02 01:37:03 -07001049
1050 if (status != NO_ERROR) {
1051 goto invalid;
1052 }
1053
Wink Savillef5903df2009-04-24 11:54:14 -07001054 s_callbacks.onRequest(pRI->pCI->requestNumber,
Wink Savillea592eeb2009-05-22 13:26:36 -07001055 gsmBciPtrs,
1056 num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *),
Wink Savillef5903df2009-04-24 11:54:14 -07001057 pRI);
Wink Savillef4c4d362009-04-02 01:37:03 -07001058
1059#ifdef MEMSET_FREED
Wink Savillea592eeb2009-05-22 13:26:36 -07001060 memset(gsmBci, 0, num * sizeof(RIL_GSM_BroadcastSmsConfigInfo));
1061 memset(gsmBciPtrs, 0, num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *));
Wink Savillef4c4d362009-04-02 01:37:03 -07001062#endif
1063
1064 return;
1065
1066invalid:
1067 invalidCommandBlock(pRI);
1068 return;
Wink Savillea592eeb2009-05-22 13:26:36 -07001069}
Wink Savillef4c4d362009-04-02 01:37:03 -07001070
Wink Savillea592eeb2009-05-22 13:26:36 -07001071static void
1072dispatchCdmaBrSmsCnf(Parcel &p, RequestInfo *pRI) {
1073 int32_t t;
1074 status_t status;
1075 int32_t num;
1076
1077 status = p.readInt32(&num);
1078 if (status != NO_ERROR) {
1079 goto invalid;
1080 }
1081
1082 RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num];
1083 RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num];
1084
1085 startRequest;
1086 for (int i = 0 ; i < num ; i++ ) {
1087 cdmaBciPtrs[i] = &cdmaBci[i];
1088
1089 status = p.readInt32(&t);
1090 cdmaBci[i].service_category = (int) t;
1091
1092 status = p.readInt32(&t);
1093 cdmaBci[i].language = (int) t;
1094
1095 status = p.readInt32(&t);
1096 cdmaBci[i].selected = (uint8_t) t;
1097
1098 appendPrintBuf("%s [%d: service_category=%d, language =%d, \
1099 entries.bSelected =%d]", printBuf, i, cdmaBci[i].service_category,
1100 cdmaBci[i].language, cdmaBci[i].selected);
1101 }
1102 closeRequest;
1103
1104 if (status != NO_ERROR) {
1105 goto invalid;
1106 }
1107
1108 s_callbacks.onRequest(pRI->pCI->requestNumber,
1109 cdmaBciPtrs,
1110 num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *),
1111 pRI);
1112
1113#ifdef MEMSET_FREED
1114 memset(cdmaBci, 0, num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo));
1115 memset(cdmaBciPtrs, 0, num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *));
1116#endif
1117
1118 return;
1119
1120invalid:
1121 invalidCommandBlock(pRI);
1122 return;
Wink Savillef4c4d362009-04-02 01:37:03 -07001123}
1124
1125static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI) {
1126 RIL_CDMA_SMS_WriteArgs rcsw;
1127 int32_t t;
1128 uint32_t ut;
1129 uint8_t uct;
1130 status_t status;
1131 int32_t digitCount;
1132
1133 memset(&rcsw, 0, sizeof(rcsw));
1134
1135 status = p.readInt32(&t);
1136 rcsw.status = t;
Wink Savillea592eeb2009-05-22 13:26:36 -07001137
Wink Savillef4c4d362009-04-02 01:37:03 -07001138 status = p.readInt32(&t);
1139 rcsw.message.uTeleserviceID = (int) t;
1140
1141 status = p.read(&uct,sizeof(uct));
1142 rcsw.message.bIsServicePresent = (uint8_t) uct;
1143
1144 status = p.readInt32(&t);
1145 rcsw.message.uServicecategory = (int) t;
1146
1147 status = p.readInt32(&t);
1148 rcsw.message.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) t;
1149
1150 status = p.readInt32(&t);
1151 rcsw.message.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) t;
1152
1153 status = p.readInt32(&t);
1154 rcsw.message.sAddress.number_type = (RIL_CDMA_SMS_NumberType) t;
1155
1156 status = p.readInt32(&t);
1157 rcsw.message.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) t;
1158
1159 status = p.read(&uct,sizeof(uct));
1160 rcsw.message.sAddress.number_of_digits = (uint8_t) uct;
1161
1162 for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_ADDRESS_MAX; digitCount ++) {
1163 status = p.read(&uct,sizeof(uct));
1164 rcsw.message.sAddress.digits[digitCount] = (uint8_t) uct;
1165 }
1166
Wink Savillea592eeb2009-05-22 13:26:36 -07001167 status = p.readInt32(&t);
Wink Savillef4c4d362009-04-02 01:37:03 -07001168 rcsw.message.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) t;
1169
Wink Savillea592eeb2009-05-22 13:26:36 -07001170 status = p.read(&uct,sizeof(uct));
Wink Savillef4c4d362009-04-02 01:37:03 -07001171 rcsw.message.sSubAddress.odd = (uint8_t) uct;
1172
1173 status = p.read(&uct,sizeof(uct));
1174 rcsw.message.sSubAddress.number_of_digits = (uint8_t) uct;
1175
1176 for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_SUBADDRESS_MAX; digitCount ++) {
Wink Savillea592eeb2009-05-22 13:26:36 -07001177 status = p.read(&uct,sizeof(uct));
Wink Savillef4c4d362009-04-02 01:37:03 -07001178 rcsw.message.sSubAddress.digits[digitCount] = (uint8_t) uct;
1179 }
1180
Wink Savillea592eeb2009-05-22 13:26:36 -07001181 status = p.readInt32(&t);
Wink Savillef4c4d362009-04-02 01:37:03 -07001182 rcsw.message.uBearerDataLen = (int) t;
1183
1184 for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_BEARER_DATA_MAX; digitCount ++) {
Wink Savillea592eeb2009-05-22 13:26:36 -07001185 status = p.read(&uct, sizeof(uct));
Wink Savillef4c4d362009-04-02 01:37:03 -07001186 rcsw.message.aBearerData[digitCount] = (uint8_t) uct;
1187 }
1188
1189 if (status != NO_ERROR) {
1190 goto invalid;
1191 }
1192
1193 startRequest;
Wink Saville1b5fd232009-04-22 14:50:00 -07001194 appendPrintBuf("%sstatus=%d, message.uTeleserviceID=%d, message.bIsServicePresent=%d, \
1195 message.uServicecategory=%d, message.sAddress.digit_mode=%d, \
1196 message.sAddress.number_mode=%d, \
1197 message.sAddress.number_type=%d, ",
Wink Savillef4c4d362009-04-02 01:37:03 -07001198 printBuf, rcsw.status, rcsw.message.uTeleserviceID, rcsw.message.bIsServicePresent,
Wink Saville1b5fd232009-04-22 14:50:00 -07001199 rcsw.message.uServicecategory, rcsw.message.sAddress.digit_mode,
1200 rcsw.message.sAddress.number_mode,
1201 rcsw.message.sAddress.number_type);
Wink Savillef4c4d362009-04-02 01:37:03 -07001202 closeRequest;
1203
1204 printRequest(pRI->token, pRI->pCI->requestNumber);
1205
1206 s_callbacks.onRequest(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw),pRI);
1207
1208#ifdef MEMSET_FREED
1209 memset(&rcsw, 0, sizeof(rcsw));
1210#endif
1211
1212 return;
1213
1214invalid:
1215 invalidCommandBlock(pRI);
1216 return;
1217
1218}
1219
Lorenzo Colitti4f81dcf2010-09-01 19:38:57 -07001220// For backwards compatibility in RIL_REQUEST_SETUP_DATA_CALL.
1221// Version 4 of the RIL interface adds a new PDP type parameter to support
1222// IPv6 and dual-stack PDP contexts. When dealing with a previous version of
1223// RIL, remove the parameter from the request.
1224static void dispatchDataCall(Parcel& p, RequestInfo *pRI) {
1225 // In RIL v3, REQUEST_SETUP_DATA_CALL takes 6 parameters.
1226 const int numParamsRilV3 = 6;
1227
1228 // The first bytes of the RIL parcel contain the request number and the
1229 // serial number - see processCommandBuffer(). Copy them over too.
1230 int pos = p.dataPosition();
1231
1232 int numParams = p.readInt32();
1233 if (s_callbacks.version < 4 && numParams > numParamsRilV3) {
1234 Parcel p2;
1235 p2.appendFrom(&p, 0, pos);
1236 p2.writeInt32(numParamsRilV3);
1237 for(int i = 0; i < numParamsRilV3; i++) {
1238 p2.writeString16(p.readString16());
1239 }
1240 p2.setDataPosition(pos);
1241 dispatchStrings(p2, pRI);
1242 } else {
Lorenzo Colitti57ce1f22010-09-13 12:23:50 -07001243 p.setDataPosition(pos);
Lorenzo Colitti4f81dcf2010-09-01 19:38:57 -07001244 dispatchStrings(p, pRI);
1245 }
1246}
1247
Naveen Kalla2bc78d62011-12-07 16:22:53 -08001248// For backwards compatibility with RILs that dont support RIL_REQUEST_VOICE_RADIO_TECH.
1249// When all RILs handle this request, this function can be removed and
1250// the request can be sent directly to the RIL using dispatchVoid.
1251static void dispatchVoiceRadioTech(Parcel& p, RequestInfo *pRI) {
1252 RIL_RadioState state = s_callbacks.onStateRequest();
1253
1254 if ((RADIO_STATE_UNAVAILABLE == state) || (RADIO_STATE_OFF == state)) {
1255 RIL_onRequestComplete(pRI, RIL_E_RADIO_NOT_AVAILABLE, NULL, 0);
1256 }
1257
1258 // RILs that support RADIO_STATE_ON should support this request.
1259 if (RADIO_STATE_ON == state) {
1260 dispatchVoid(p, pRI);
1261 return;
1262 }
1263
1264 // For Older RILs, that do not support RADIO_STATE_ON, assume that they
1265 // will not support this new request either and decode Voice Radio Technology
1266 // from Radio State
1267 voiceRadioTech = decodeVoiceRadioTechnology(state);
1268
1269 if (voiceRadioTech < 0)
1270 RIL_onRequestComplete(pRI, RIL_E_GENERIC_FAILURE, NULL, 0);
1271 else
1272 RIL_onRequestComplete(pRI, RIL_E_SUCCESS, &voiceRadioTech, sizeof(int));
1273}
1274
1275// For backwards compatibility in RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE:.
1276// When all RILs handle this request, this function can be removed and
1277// the request can be sent directly to the RIL using dispatchVoid.
1278static void dispatchCdmaSubscriptionSource(Parcel& p, RequestInfo *pRI) {
1279 RIL_RadioState state = s_callbacks.onStateRequest();
1280
1281 if ((RADIO_STATE_UNAVAILABLE == state) || (RADIO_STATE_OFF == state)) {
1282 RIL_onRequestComplete(pRI, RIL_E_RADIO_NOT_AVAILABLE, NULL, 0);
1283 }
1284
1285 // RILs that support RADIO_STATE_ON should support this request.
1286 if (RADIO_STATE_ON == state) {
1287 dispatchVoid(p, pRI);
1288 return;
1289 }
1290
1291 // For Older RILs, that do not support RADIO_STATE_ON, assume that they
1292 // will not support this new request either and decode CDMA Subscription Source
1293 // from Radio State
1294 cdmaSubscriptionSource = decodeCdmaSubscriptionSource(state);
1295
1296 if (cdmaSubscriptionSource < 0)
1297 RIL_onRequestComplete(pRI, RIL_E_GENERIC_FAILURE, NULL, 0);
1298 else
1299 RIL_onRequestComplete(pRI, RIL_E_SUCCESS, &cdmaSubscriptionSource, sizeof(int));
1300}
1301
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001302static int
Wink Savillef4c4d362009-04-02 01:37:03 -07001303blockingWrite(int fd, const void *buffer, size_t len) {
Wink Saville7f856802009-06-09 10:23:37 -07001304 size_t writeOffset = 0;
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001305 const uint8_t *toWrite;
1306
1307 toWrite = (const uint8_t *)buffer;
1308
1309 while (writeOffset < len) {
1310 ssize_t written;
1311 do {
1312 written = write (fd, toWrite + writeOffset,
1313 len - writeOffset);
1314 } while (written < 0 && errno == EINTR);
1315
1316 if (written >= 0) {
1317 writeOffset += written;
1318 } else { // written < 0
Steve Blockf423cde2012-01-08 13:48:26 +00001319 ALOGE ("RIL Response: unexpected error on write errno:%d", errno);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001320 close(fd);
1321 return -1;
1322 }
1323 }
1324
1325 return 0;
1326}
1327
1328static int
Wink Savillef4c4d362009-04-02 01:37:03 -07001329sendResponseRaw (const void *data, size_t dataSize) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001330 int fd = s_fdCommand;
1331 int ret;
1332 uint32_t header;
1333
1334 if (s_fdCommand < 0) {
1335 return -1;
1336 }
1337
1338 if (dataSize > MAX_COMMAND_BYTES) {
Steve Blockf423cde2012-01-08 13:48:26 +00001339 ALOGE("RIL: packet larger than %u (%u)",
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001340 MAX_COMMAND_BYTES, (unsigned int )dataSize);
1341
1342 return -1;
1343 }
Wink Saville7f856802009-06-09 10:23:37 -07001344
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001345 pthread_mutex_lock(&s_writeMutex);
1346
1347 header = htonl(dataSize);
1348
1349 ret = blockingWrite(fd, (void *)&header, sizeof(header));
1350
1351 if (ret < 0) {
Jaikumar Ganesh084f6702009-08-18 16:40:29 -07001352 pthread_mutex_unlock(&s_writeMutex);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001353 return ret;
1354 }
1355
Kennyee1fadc2009-08-13 00:45:53 +08001356 ret = blockingWrite(fd, data, dataSize);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001357
1358 if (ret < 0) {
Jaikumar Ganesh084f6702009-08-18 16:40:29 -07001359 pthread_mutex_unlock(&s_writeMutex);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001360 return ret;
1361 }
1362
1363 pthread_mutex_unlock(&s_writeMutex);
1364
1365 return 0;
1366}
1367
1368static int
Wink Savillef4c4d362009-04-02 01:37:03 -07001369sendResponse (Parcel &p) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001370 printResponse;
1371 return sendResponseRaw(p.data(), p.dataSize());
1372}
1373
1374/** response is an int* pointing to an array of ints*/
Wink Saville7f856802009-06-09 10:23:37 -07001375
1376static int
Wink Savillef4c4d362009-04-02 01:37:03 -07001377responseInts(Parcel &p, void *response, size_t responselen) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001378 int numInts;
1379
1380 if (response == NULL && responselen != 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00001381 ALOGE("invalid response: NULL");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001382 return RIL_ERRNO_INVALID_RESPONSE;
1383 }
1384 if (responselen % sizeof(int) != 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00001385 ALOGE("invalid response length %d expected multiple of %d\n",
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001386 (int)responselen, (int)sizeof(int));
1387 return RIL_ERRNO_INVALID_RESPONSE;
1388 }
1389
1390 int *p_int = (int *) response;
1391
1392 numInts = responselen / sizeof(int *);
1393 p.writeInt32 (numInts);
1394
1395 /* each int*/
1396 startResponse;
1397 for (int i = 0 ; i < numInts ; i++) {
1398 appendPrintBuf("%s%d,", printBuf, p_int[i]);
1399 p.writeInt32(p_int[i]);
1400 }
1401 removeLastChar;
1402 closeResponse;
1403
1404 return 0;
1405}
1406
Wink Saville43808972011-01-13 17:39:51 -08001407/** response is a char **, pointing to an array of char *'s
1408 The parcel will begin with the version */
1409static int responseStringsWithVersion(int version, Parcel &p, void *response, size_t responselen) {
1410 p.writeInt32(version);
1411 return responseStrings(p, response, responselen);
1412}
1413
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001414/** response is a char **, pointing to an array of char *'s */
Wink Savillef4c4d362009-04-02 01:37:03 -07001415static int responseStrings(Parcel &p, void *response, size_t responselen) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001416 int numStrings;
Wink Saville7f856802009-06-09 10:23:37 -07001417
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001418 if (response == NULL && responselen != 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00001419 ALOGE("invalid response: NULL");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001420 return RIL_ERRNO_INVALID_RESPONSE;
1421 }
1422 if (responselen % sizeof(char *) != 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00001423 ALOGE("invalid response length %d expected multiple of %d\n",
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001424 (int)responselen, (int)sizeof(char *));
1425 return RIL_ERRNO_INVALID_RESPONSE;
1426 }
1427
1428 if (response == NULL) {
1429 p.writeInt32 (0);
1430 } else {
1431 char **p_cur = (char **) response;
1432
1433 numStrings = responselen / sizeof(char *);
1434 p.writeInt32 (numStrings);
1435
1436 /* each string*/
1437 startResponse;
1438 for (int i = 0 ; i < numStrings ; i++) {
1439 appendPrintBuf("%s%s,", printBuf, (char*)p_cur[i]);
1440 writeStringToParcel (p, p_cur[i]);
1441 }
1442 removeLastChar;
1443 closeResponse;
1444 }
1445 return 0;
1446}
1447
1448
1449/**
Wink Saville7f856802009-06-09 10:23:37 -07001450 * NULL strings are accepted
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001451 * FIXME currently ignores responselen
1452 */
Wink Savillef4c4d362009-04-02 01:37:03 -07001453static int responseString(Parcel &p, void *response, size_t responselen) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001454 /* one string only */
1455 startResponse;
1456 appendPrintBuf("%s%s", printBuf, (char*)response);
1457 closeResponse;
1458
1459 writeStringToParcel(p, (const char *)response);
1460
1461 return 0;
1462}
1463
Wink Savillef4c4d362009-04-02 01:37:03 -07001464static int responseVoid(Parcel &p, void *response, size_t responselen) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001465 startResponse;
1466 removeLastChar;
1467 return 0;
1468}
1469
Wink Savillef4c4d362009-04-02 01:37:03 -07001470static int responseCallList(Parcel &p, void *response, size_t responselen) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001471 int num;
1472
1473 if (response == NULL && responselen != 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00001474 ALOGE("invalid response: NULL");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001475 return RIL_ERRNO_INVALID_RESPONSE;
1476 }
1477
1478 if (responselen % sizeof (RIL_Call *) != 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00001479 ALOGE("invalid response length %d expected multiple of %d\n",
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001480 (int)responselen, (int)sizeof (RIL_Call *));
1481 return RIL_ERRNO_INVALID_RESPONSE;
1482 }
1483
1484 startResponse;
1485 /* number of call info's */
1486 num = responselen / sizeof(RIL_Call *);
1487 p.writeInt32(num);
1488
1489 for (int i = 0 ; i < num ; i++) {
1490 RIL_Call *p_cur = ((RIL_Call **) response)[i];
1491 /* each call info */
1492 p.writeInt32(p_cur->state);
1493 p.writeInt32(p_cur->index);
1494 p.writeInt32(p_cur->toa);
1495 p.writeInt32(p_cur->isMpty);
1496 p.writeInt32(p_cur->isMT);
1497 p.writeInt32(p_cur->als);
1498 p.writeInt32(p_cur->isVoice);
Wink Saville1b5fd232009-04-22 14:50:00 -07001499 p.writeInt32(p_cur->isVoicePrivacy);
1500 writeStringToParcel(p, p_cur->number);
John Wangff368742009-03-24 17:56:29 -07001501 p.writeInt32(p_cur->numberPresentation);
Wink Saville1b5fd232009-04-22 14:50:00 -07001502 writeStringToParcel(p, p_cur->name);
1503 p.writeInt32(p_cur->namePresentation);
Wink Saville3a4840b2010-04-07 13:29:58 -07001504 // Remove when partners upgrade to version 3
Wink Saville74fa3882009-12-22 15:35:41 -08001505 if ((s_callbacks.version < 3) || (p_cur->uusInfo == NULL || p_cur->uusInfo->uusData == NULL)) {
1506 p.writeInt32(0); /* UUS Information is absent */
1507 } else {
1508 RIL_UUS_Info *uusInfo = p_cur->uusInfo;
1509 p.writeInt32(1); /* UUS Information is present */
1510 p.writeInt32(uusInfo->uusType);
1511 p.writeInt32(uusInfo->uusDcs);
1512 p.writeInt32(uusInfo->uusLength);
1513 p.write(uusInfo->uusData, uusInfo->uusLength);
1514 }
Wink Saville3d54e742009-05-18 18:00:44 -07001515 appendPrintBuf("%s[id=%d,%s,toa=%d,",
John Wangff368742009-03-24 17:56:29 -07001516 printBuf,
Wink Saville1b5fd232009-04-22 14:50:00 -07001517 p_cur->index,
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001518 callStateToString(p_cur->state),
Wink Saville3d54e742009-05-18 18:00:44 -07001519 p_cur->toa);
1520 appendPrintBuf("%s%s,%s,als=%d,%s,%s,",
1521 printBuf,
Wink Saville1b5fd232009-04-22 14:50:00 -07001522 (p_cur->isMpty)?"conf":"norm",
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001523 (p_cur->isMT)?"mt":"mo",
1524 p_cur->als,
1525 (p_cur->isVoice)?"voc":"nonvoc",
Wink Saville3d54e742009-05-18 18:00:44 -07001526 (p_cur->isVoicePrivacy)?"evp":"noevp");
1527 appendPrintBuf("%s%s,cli=%d,name='%s',%d]",
1528 printBuf,
Wink Saville1b5fd232009-04-22 14:50:00 -07001529 p_cur->number,
1530 p_cur->numberPresentation,
1531 p_cur->name,
1532 p_cur->namePresentation);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001533 }
1534 removeLastChar;
1535 closeResponse;
1536
1537 return 0;
1538}
1539
Wink Savillef4c4d362009-04-02 01:37:03 -07001540static int responseSMS(Parcel &p, void *response, size_t responselen) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001541 if (response == NULL) {
Steve Blockf423cde2012-01-08 13:48:26 +00001542 ALOGE("invalid response: NULL");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001543 return RIL_ERRNO_INVALID_RESPONSE;
1544 }
1545
1546 if (responselen != sizeof (RIL_SMS_Response) ) {
Steve Blockf423cde2012-01-08 13:48:26 +00001547 ALOGE("invalid response length %d expected %d",
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001548 (int)responselen, (int)sizeof (RIL_SMS_Response));
1549 return RIL_ERRNO_INVALID_RESPONSE;
1550 }
1551
1552 RIL_SMS_Response *p_cur = (RIL_SMS_Response *) response;
1553
1554 p.writeInt32(p_cur->messageRef);
1555 writeStringToParcel(p, p_cur->ackPDU);
Jaikumar Ganesh920c78f2009-06-04 10:53:15 -07001556 p.writeInt32(p_cur->errorCode);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001557
1558 startResponse;
Jaikumar Ganesh920c78f2009-06-04 10:53:15 -07001559 appendPrintBuf("%s%d,%s,%d", printBuf, p_cur->messageRef,
1560 (char*)p_cur->ackPDU, p_cur->errorCode);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001561 closeResponse;
1562
1563 return 0;
1564}
1565
Wink Savillec0114b32011-02-18 10:14:07 -08001566static int responseDataCallListV4(Parcel &p, void *response, size_t responselen)
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001567{
1568 if (response == NULL && responselen != 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00001569 ALOGE("invalid response: NULL");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001570 return RIL_ERRNO_INVALID_RESPONSE;
1571 }
1572
Wink Savillec0114b32011-02-18 10:14:07 -08001573 if (responselen % sizeof(RIL_Data_Call_Response_v4) != 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00001574 ALOGE("invalid response length %d expected multiple of %d",
Wink Savillec0114b32011-02-18 10:14:07 -08001575 (int)responselen, (int)sizeof(RIL_Data_Call_Response_v4));
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001576 return RIL_ERRNO_INVALID_RESPONSE;
1577 }
1578
Wink Savillec0114b32011-02-18 10:14:07 -08001579 int num = responselen / sizeof(RIL_Data_Call_Response_v4);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001580 p.writeInt32(num);
1581
Wink Savillec0114b32011-02-18 10:14:07 -08001582 RIL_Data_Call_Response_v4 *p_cur = (RIL_Data_Call_Response_v4 *) response;
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001583 startResponse;
1584 int i;
1585 for (i = 0; i < num; i++) {
1586 p.writeInt32(p_cur[i].cid);
1587 p.writeInt32(p_cur[i].active);
1588 writeStringToParcel(p, p_cur[i].type);
Wink Savillec0114b32011-02-18 10:14:07 -08001589 // apn is not used, so don't send.
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001590 writeStringToParcel(p, p_cur[i].address);
Wink Savillec0114b32011-02-18 10:14:07 -08001591 appendPrintBuf("%s[cid=%d,%s,%s,%s],", printBuf,
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001592 p_cur[i].cid,
1593 (p_cur[i].active==0)?"down":"up",
1594 (char*)p_cur[i].type,
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001595 (char*)p_cur[i].address);
1596 }
1597 removeLastChar;
1598 closeResponse;
1599
1600 return 0;
1601}
1602
Wink Saville43808972011-01-13 17:39:51 -08001603static int responseDataCallList(Parcel &p, void *response, size_t responselen)
1604{
1605 // Write version
1606 p.writeInt32(s_callbacks.version);
1607
1608 if (s_callbacks.version < 5) {
Wink Savillec0114b32011-02-18 10:14:07 -08001609 return responseDataCallListV4(p, response, responselen);
Wink Saville43808972011-01-13 17:39:51 -08001610 } else {
1611 if (response == NULL && responselen != 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00001612 ALOGE("invalid response: NULL");
Wink Saville43808972011-01-13 17:39:51 -08001613 return RIL_ERRNO_INVALID_RESPONSE;
1614 }
1615
Wink Savillec0114b32011-02-18 10:14:07 -08001616 if (responselen % sizeof(RIL_Data_Call_Response_v6) != 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00001617 ALOGE("invalid response length %d expected multiple of %d",
Wink Savillec0114b32011-02-18 10:14:07 -08001618 (int)responselen, (int)sizeof(RIL_Data_Call_Response_v6));
Wink Saville43808972011-01-13 17:39:51 -08001619 return RIL_ERRNO_INVALID_RESPONSE;
1620 }
1621
Wink Savillec0114b32011-02-18 10:14:07 -08001622 int num = responselen / sizeof(RIL_Data_Call_Response_v6);
Wink Saville43808972011-01-13 17:39:51 -08001623 p.writeInt32(num);
1624
Wink Savillec0114b32011-02-18 10:14:07 -08001625 RIL_Data_Call_Response_v6 *p_cur = (RIL_Data_Call_Response_v6 *) response;
Wink Saville43808972011-01-13 17:39:51 -08001626 startResponse;
1627 int i;
1628 for (i = 0; i < num; i++) {
1629 p.writeInt32((int)p_cur[i].status);
Kazuhiro Ondobeb25b52011-06-17 16:26:45 -05001630 p.writeInt32(p_cur[i].suggestedRetryTime);
Wink Saville43808972011-01-13 17:39:51 -08001631 p.writeInt32(p_cur[i].cid);
1632 p.writeInt32(p_cur[i].active);
David 'Digit' Turneraf1298d2011-02-04 13:36:47 +01001633 writeStringToParcel(p, p_cur[i].type);
Wink Saville43808972011-01-13 17:39:51 -08001634 writeStringToParcel(p, p_cur[i].ifname);
1635 writeStringToParcel(p, p_cur[i].addresses);
1636 writeStringToParcel(p, p_cur[i].dnses);
Wink Savillec0114b32011-02-18 10:14:07 -08001637 writeStringToParcel(p, p_cur[i].gateways);
Naveen Kalla56384152011-11-16 11:12:37 -08001638 appendPrintBuf("%s[status=%d,retry=%d,cid=%d,%s,%s,%s,%s,%s,%s],", printBuf,
Wink Saville43808972011-01-13 17:39:51 -08001639 p_cur[i].status,
Kazuhiro Ondobeb25b52011-06-17 16:26:45 -05001640 p_cur[i].suggestedRetryTime,
Wink Saville43808972011-01-13 17:39:51 -08001641 p_cur[i].cid,
1642 (p_cur[i].active==0)?"down":"up",
Naveen Kalla56384152011-11-16 11:12:37 -08001643 (char*)p_cur[i].type,
Wink Saville43808972011-01-13 17:39:51 -08001644 (char*)p_cur[i].ifname,
1645 (char*)p_cur[i].addresses,
Wink Savillec0114b32011-02-18 10:14:07 -08001646 (char*)p_cur[i].dnses,
1647 (char*)p_cur[i].gateways);
Wink Saville43808972011-01-13 17:39:51 -08001648 }
1649 removeLastChar;
1650 closeResponse;
1651 }
1652
1653 return 0;
1654}
1655
1656static int responseSetupDataCall(Parcel &p, void *response, size_t responselen)
1657{
1658 if (s_callbacks.version < 5) {
1659 return responseStringsWithVersion(s_callbacks.version, p, response, responselen);
1660 } else {
1661 return responseDataCallList(p, response, responselen);
1662 }
1663}
1664
Wink Savillef4c4d362009-04-02 01:37:03 -07001665static int responseRaw(Parcel &p, void *response, size_t responselen) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001666 if (response == NULL && responselen != 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00001667 ALOGE("invalid response: NULL with responselen != 0");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001668 return RIL_ERRNO_INVALID_RESPONSE;
1669 }
1670
1671 // The java code reads -1 size as null byte array
1672 if (response == NULL) {
Wink Saville7f856802009-06-09 10:23:37 -07001673 p.writeInt32(-1);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001674 } else {
1675 p.writeInt32(responselen);
1676 p.write(response, responselen);
1677 }
1678
1679 return 0;
1680}
1681
1682
Wink Savillef4c4d362009-04-02 01:37:03 -07001683static int responseSIM_IO(Parcel &p, void *response, size_t responselen) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001684 if (response == NULL) {
Steve Blockf423cde2012-01-08 13:48:26 +00001685 ALOGE("invalid response: NULL");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001686 return RIL_ERRNO_INVALID_RESPONSE;
1687 }
1688
1689 if (responselen != sizeof (RIL_SIM_IO_Response) ) {
Steve Blockf423cde2012-01-08 13:48:26 +00001690 ALOGE("invalid response length was %d expected %d",
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001691 (int)responselen, (int)sizeof (RIL_SIM_IO_Response));
1692 return RIL_ERRNO_INVALID_RESPONSE;
1693 }
1694
1695 RIL_SIM_IO_Response *p_cur = (RIL_SIM_IO_Response *) response;
1696 p.writeInt32(p_cur->sw1);
1697 p.writeInt32(p_cur->sw2);
1698 writeStringToParcel(p, p_cur->simResponse);
1699
1700 startResponse;
1701 appendPrintBuf("%ssw1=0x%X,sw2=0x%X,%s", printBuf, p_cur->sw1, p_cur->sw2,
1702 (char*)p_cur->simResponse);
1703 closeResponse;
1704
1705
1706 return 0;
1707}
1708
Wink Savillef4c4d362009-04-02 01:37:03 -07001709static int responseCallForwards(Parcel &p, void *response, size_t responselen) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001710 int num;
Wink Saville7f856802009-06-09 10:23:37 -07001711
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001712 if (response == NULL && responselen != 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00001713 ALOGE("invalid response: NULL");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001714 return RIL_ERRNO_INVALID_RESPONSE;
1715 }
1716
1717 if (responselen % sizeof(RIL_CallForwardInfo *) != 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00001718 ALOGE("invalid response length %d expected multiple of %d",
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001719 (int)responselen, (int)sizeof(RIL_CallForwardInfo *));
1720 return RIL_ERRNO_INVALID_RESPONSE;
1721 }
1722
1723 /* number of call info's */
1724 num = responselen / sizeof(RIL_CallForwardInfo *);
1725 p.writeInt32(num);
1726
1727 startResponse;
1728 for (int i = 0 ; i < num ; i++) {
1729 RIL_CallForwardInfo *p_cur = ((RIL_CallForwardInfo **) response)[i];
1730
1731 p.writeInt32(p_cur->status);
1732 p.writeInt32(p_cur->reason);
1733 p.writeInt32(p_cur->serviceClass);
1734 p.writeInt32(p_cur->toa);
1735 writeStringToParcel(p, p_cur->number);
1736 p.writeInt32(p_cur->timeSeconds);
1737 appendPrintBuf("%s[%s,reason=%d,cls=%d,toa=%d,%s,tout=%d],", printBuf,
1738 (p_cur->status==1)?"enable":"disable",
1739 p_cur->reason, p_cur->serviceClass, p_cur->toa,
1740 (char*)p_cur->number,
1741 p_cur->timeSeconds);
1742 }
1743 removeLastChar;
1744 closeResponse;
Wink Saville7f856802009-06-09 10:23:37 -07001745
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001746 return 0;
1747}
1748
Wink Savillef4c4d362009-04-02 01:37:03 -07001749static int responseSsn(Parcel &p, void *response, size_t responselen) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001750 if (response == NULL) {
Steve Blockf423cde2012-01-08 13:48:26 +00001751 ALOGE("invalid response: NULL");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001752 return RIL_ERRNO_INVALID_RESPONSE;
1753 }
1754
1755 if (responselen != sizeof(RIL_SuppSvcNotification)) {
Steve Blockf423cde2012-01-08 13:48:26 +00001756 ALOGE("invalid response length was %d expected %d",
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001757 (int)responselen, (int)sizeof (RIL_SuppSvcNotification));
1758 return RIL_ERRNO_INVALID_RESPONSE;
1759 }
1760
1761 RIL_SuppSvcNotification *p_cur = (RIL_SuppSvcNotification *) response;
1762 p.writeInt32(p_cur->notificationType);
1763 p.writeInt32(p_cur->code);
1764 p.writeInt32(p_cur->index);
1765 p.writeInt32(p_cur->type);
1766 writeStringToParcel(p, p_cur->number);
1767
1768 startResponse;
1769 appendPrintBuf("%s%s,code=%d,id=%d,type=%d,%s", printBuf,
1770 (p_cur->notificationType==0)?"mo":"mt",
1771 p_cur->code, p_cur->index, p_cur->type,
1772 (char*)p_cur->number);
1773 closeResponse;
1774
1775 return 0;
1776}
1777
Wink Saville3d54e742009-05-18 18:00:44 -07001778static int responseCellList(Parcel &p, void *response, size_t responselen) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001779 int num;
1780
1781 if (response == NULL && responselen != 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00001782 ALOGE("invalid response: NULL");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001783 return RIL_ERRNO_INVALID_RESPONSE;
1784 }
1785
1786 if (responselen % sizeof (RIL_NeighboringCell *) != 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00001787 ALOGE("invalid response length %d expected multiple of %d\n",
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001788 (int)responselen, (int)sizeof (RIL_NeighboringCell *));
1789 return RIL_ERRNO_INVALID_RESPONSE;
1790 }
1791
1792 startResponse;
Wink Saville3d54e742009-05-18 18:00:44 -07001793 /* number of records */
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001794 num = responselen / sizeof(RIL_NeighboringCell *);
1795 p.writeInt32(num);
1796
1797 for (int i = 0 ; i < num ; i++) {
1798 RIL_NeighboringCell *p_cur = ((RIL_NeighboringCell **) response)[i];
1799
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08001800 p.writeInt32(p_cur->rssi);
1801 writeStringToParcel (p, p_cur->cid);
1802
1803 appendPrintBuf("%s[cid=%s,rssi=%d],", printBuf,
1804 p_cur->cid, p_cur->rssi);
1805 }
1806 removeLastChar;
1807 closeResponse;
1808
1809 return 0;
1810}
1811
Wink Saville3d54e742009-05-18 18:00:44 -07001812/**
1813 * Marshall the signalInfoRecord into the parcel if it exists.
1814 */
Wink Savillea592eeb2009-05-22 13:26:36 -07001815static void marshallSignalInfoRecord(Parcel &p,
1816 RIL_CDMA_SignalInfoRecord &p_signalInfoRecord) {
Wink Saville3d54e742009-05-18 18:00:44 -07001817 p.writeInt32(p_signalInfoRecord.isPresent);
1818 p.writeInt32(p_signalInfoRecord.signalType);
1819 p.writeInt32(p_signalInfoRecord.alertPitch);
1820 p.writeInt32(p_signalInfoRecord.signal);
1821}
1822
Wink Savillea592eeb2009-05-22 13:26:36 -07001823static int responseCdmaInformationRecords(Parcel &p,
1824 void *response, size_t responselen) {
Wink Saville3d54e742009-05-18 18:00:44 -07001825 int num;
Wink Savillea592eeb2009-05-22 13:26:36 -07001826 char* string8 = NULL;
1827 int buffer_lenght;
1828 RIL_CDMA_InformationRecord *infoRec;
Wink Saville3d54e742009-05-18 18:00:44 -07001829
1830 if (response == NULL && responselen != 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00001831 ALOGE("invalid response: NULL");
Wink Saville3d54e742009-05-18 18:00:44 -07001832 return RIL_ERRNO_INVALID_RESPONSE;
1833 }
1834
Wink Savillea592eeb2009-05-22 13:26:36 -07001835 if (responselen != sizeof (RIL_CDMA_InformationRecords)) {
Steve Blockf423cde2012-01-08 13:48:26 +00001836 ALOGE("invalid response length %d expected multiple of %d\n",
Wink Savillea592eeb2009-05-22 13:26:36 -07001837 (int)responselen, (int)sizeof (RIL_CDMA_InformationRecords *));
Wink Saville3d54e742009-05-18 18:00:44 -07001838 return RIL_ERRNO_INVALID_RESPONSE;
1839 }
1840
Wink Savillea592eeb2009-05-22 13:26:36 -07001841 RIL_CDMA_InformationRecords *p_cur =
1842 (RIL_CDMA_InformationRecords *) response;
1843 num = MIN(p_cur->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
Wink Saville3d54e742009-05-18 18:00:44 -07001844
1845 startResponse;
Wink Savillea592eeb2009-05-22 13:26:36 -07001846 p.writeInt32(num);
Wink Saville3d54e742009-05-18 18:00:44 -07001847
Wink Savillea592eeb2009-05-22 13:26:36 -07001848 for (int i = 0 ; i < num ; i++) {
1849 infoRec = &p_cur->infoRec[i];
1850 p.writeInt32(infoRec->name);
1851 switch (infoRec->name) {
Wink Saville3d54e742009-05-18 18:00:44 -07001852 case RIL_CDMA_DISPLAY_INFO_REC:
Wink Savillea592eeb2009-05-22 13:26:36 -07001853 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC:
1854 if (infoRec->rec.display.alpha_len >
1855 CDMA_ALPHA_INFO_BUFFER_LENGTH) {
Steve Blockf423cde2012-01-08 13:48:26 +00001856 ALOGE("invalid display info response length %d \
Wink Savillea592eeb2009-05-22 13:26:36 -07001857 expected not more than %d\n",
1858 (int)infoRec->rec.display.alpha_len,
1859 CDMA_ALPHA_INFO_BUFFER_LENGTH);
1860 return RIL_ERRNO_INVALID_RESPONSE;
Wink Saville3d54e742009-05-18 18:00:44 -07001861 }
Wink Savillea592eeb2009-05-22 13:26:36 -07001862 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1)
1863 * sizeof(char) );
1864 for (int i = 0 ; i < infoRec->rec.display.alpha_len ; i++) {
1865 string8[i] = infoRec->rec.display.alpha_buf[i];
1866 }
Wink Saville43808972011-01-13 17:39:51 -08001867 string8[(int)infoRec->rec.display.alpha_len] = '\0';
Wink Savillea592eeb2009-05-22 13:26:36 -07001868 writeStringToParcel(p, (const char*)string8);
1869 free(string8);
1870 string8 = NULL;
Wink Saville3d54e742009-05-18 18:00:44 -07001871 break;
1872 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
Wink Saville3d54e742009-05-18 18:00:44 -07001873 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
Wink Saville3d54e742009-05-18 18:00:44 -07001874 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC:
Wink Savillea592eeb2009-05-22 13:26:36 -07001875 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
Steve Blockf423cde2012-01-08 13:48:26 +00001876 ALOGE("invalid display info response length %d \
Wink Savillea592eeb2009-05-22 13:26:36 -07001877 expected not more than %d\n",
1878 (int)infoRec->rec.number.len,
1879 CDMA_NUMBER_INFO_BUFFER_LENGTH);
1880 return RIL_ERRNO_INVALID_RESPONSE;
Wink Saville3d54e742009-05-18 18:00:44 -07001881 }
Wink Savillea592eeb2009-05-22 13:26:36 -07001882 string8 = (char*) malloc((infoRec->rec.number.len + 1)
1883 * sizeof(char) );
1884 for (int i = 0 ; i < infoRec->rec.number.len; i++) {
1885 string8[i] = infoRec->rec.number.buf[i];
1886 }
Wink Saville43808972011-01-13 17:39:51 -08001887 string8[(int)infoRec->rec.number.len] = '\0';
Wink Savillea592eeb2009-05-22 13:26:36 -07001888 writeStringToParcel(p, (const char*)string8);
1889 free(string8);
1890 string8 = NULL;
1891 p.writeInt32(infoRec->rec.number.number_type);
1892 p.writeInt32(infoRec->rec.number.number_plan);
1893 p.writeInt32(infoRec->rec.number.pi);
1894 p.writeInt32(infoRec->rec.number.si);
Wink Saville3d54e742009-05-18 18:00:44 -07001895 break;
1896 case RIL_CDMA_SIGNAL_INFO_REC:
Wink Savillea592eeb2009-05-22 13:26:36 -07001897 p.writeInt32(infoRec->rec.signal.isPresent);
1898 p.writeInt32(infoRec->rec.signal.signalType);
1899 p.writeInt32(infoRec->rec.signal.alertPitch);
1900 p.writeInt32(infoRec->rec.signal.signal);
1901
1902 appendPrintBuf("%sisPresent=%X, signalType=%X, \
1903 alertPitch=%X, signal=%X, ",
1904 printBuf, (int)infoRec->rec.signal.isPresent,
1905 (int)infoRec->rec.signal.signalType,
1906 (int)infoRec->rec.signal.alertPitch,
1907 (int)infoRec->rec.signal.signal);
1908 removeLastChar;
Wink Saville3d54e742009-05-18 18:00:44 -07001909 break;
1910 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC:
Wink Savillea592eeb2009-05-22 13:26:36 -07001911 if (infoRec->rec.redir.redirectingNumber.len >
1912 CDMA_NUMBER_INFO_BUFFER_LENGTH) {
Steve Blockf423cde2012-01-08 13:48:26 +00001913 ALOGE("invalid display info response length %d \
Wink Savillea592eeb2009-05-22 13:26:36 -07001914 expected not more than %d\n",
1915 (int)infoRec->rec.redir.redirectingNumber.len,
1916 CDMA_NUMBER_INFO_BUFFER_LENGTH);
1917 return RIL_ERRNO_INVALID_RESPONSE;
Wink Saville3d54e742009-05-18 18:00:44 -07001918 }
Wink Savillea592eeb2009-05-22 13:26:36 -07001919 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber
1920 .len + 1) * sizeof(char) );
1921 for (int i = 0;
1922 i < infoRec->rec.redir.redirectingNumber.len;
1923 i++) {
1924 string8[i] = infoRec->rec.redir.redirectingNumber.buf[i];
1925 }
Wink Saville43808972011-01-13 17:39:51 -08001926 string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0';
Wink Savillea592eeb2009-05-22 13:26:36 -07001927 writeStringToParcel(p, (const char*)string8);
1928 free(string8);
1929 string8 = NULL;
1930 p.writeInt32(infoRec->rec.redir.redirectingNumber.number_type);
1931 p.writeInt32(infoRec->rec.redir.redirectingNumber.number_plan);
1932 p.writeInt32(infoRec->rec.redir.redirectingNumber.pi);
1933 p.writeInt32(infoRec->rec.redir.redirectingNumber.si);
1934 p.writeInt32(infoRec->rec.redir.redirectingReason);
Wink Saville3d54e742009-05-18 18:00:44 -07001935 break;
1936 case RIL_CDMA_LINE_CONTROL_INFO_REC:
Wink Savillea592eeb2009-05-22 13:26:36 -07001937 p.writeInt32(infoRec->rec.lineCtrl.lineCtrlPolarityIncluded);
1938 p.writeInt32(infoRec->rec.lineCtrl.lineCtrlToggle);
1939 p.writeInt32(infoRec->rec.lineCtrl.lineCtrlReverse);
1940 p.writeInt32(infoRec->rec.lineCtrl.lineCtrlPowerDenial);
1941
1942 appendPrintBuf("%slineCtrlPolarityIncluded=%d, \
1943 lineCtrlToggle=%d, lineCtrlReverse=%d, \
1944 lineCtrlPowerDenial=%d, ", printBuf,
1945 (int)infoRec->rec.lineCtrl.lineCtrlPolarityIncluded,
1946 (int)infoRec->rec.lineCtrl.lineCtrlToggle,
1947 (int)infoRec->rec.lineCtrl.lineCtrlReverse,
1948 (int)infoRec->rec.lineCtrl.lineCtrlPowerDenial);
1949 removeLastChar;
Wink Saville3d54e742009-05-18 18:00:44 -07001950 break;
1951 case RIL_CDMA_T53_CLIR_INFO_REC:
Wink Savillea592eeb2009-05-22 13:26:36 -07001952 p.writeInt32((int)(infoRec->rec.clir.cause));
Wink Saville3d54e742009-05-18 18:00:44 -07001953
Wink Savillea592eeb2009-05-22 13:26:36 -07001954 appendPrintBuf("%scause%d", printBuf, infoRec->rec.clir.cause);
1955 removeLastChar;
Wink Saville3d54e742009-05-18 18:00:44 -07001956 break;
1957 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC:
Wink Savillea592eeb2009-05-22 13:26:36 -07001958 p.writeInt32(infoRec->rec.audioCtrl.upLink);
1959 p.writeInt32(infoRec->rec.audioCtrl.downLink);
1960
1961 appendPrintBuf("%supLink=%d, downLink=%d, ", printBuf,
1962 infoRec->rec.audioCtrl.upLink,
1963 infoRec->rec.audioCtrl.downLink);
1964 removeLastChar;
Wink Saville3d54e742009-05-18 18:00:44 -07001965 break;
Wink Savillea592eeb2009-05-22 13:26:36 -07001966 case RIL_CDMA_T53_RELEASE_INFO_REC:
1967 // TODO(Moto): See David Krause, he has the answer:)
Steve Blockf423cde2012-01-08 13:48:26 +00001968 ALOGE("RIL_CDMA_T53_RELEASE_INFO_REC: return INVALID_RESPONSE");
Wink Savillea592eeb2009-05-22 13:26:36 -07001969 return RIL_ERRNO_INVALID_RESPONSE;
1970 default:
Steve Blockf423cde2012-01-08 13:48:26 +00001971 ALOGE("Incorrect name value");
Wink Savillea592eeb2009-05-22 13:26:36 -07001972 return RIL_ERRNO_INVALID_RESPONSE;
Wink Saville3d54e742009-05-18 18:00:44 -07001973 }
1974 }
Wink Savillea592eeb2009-05-22 13:26:36 -07001975 closeResponse;
Wink Saville3d54e742009-05-18 18:00:44 -07001976
Wink Savillea592eeb2009-05-22 13:26:36 -07001977 return 0;
Wink Saville3d54e742009-05-18 18:00:44 -07001978}
1979
Wink Savillea592eeb2009-05-22 13:26:36 -07001980static int responseRilSignalStrength(Parcel &p,
1981 void *response, size_t responselen) {
1982 if (response == NULL && responselen != 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00001983 ALOGE("invalid response: NULL");
Wink Saville3d54e742009-05-18 18:00:44 -07001984 return RIL_ERRNO_INVALID_RESPONSE;
1985 }
1986
Wink Savillec0114b32011-02-18 10:14:07 -08001987 if (responselen >= sizeof (RIL_SignalStrength_v5)) {
1988 RIL_SignalStrength_v6 *p_cur = ((RIL_SignalStrength_v6 *) response);
Wink Saville3d54e742009-05-18 18:00:44 -07001989
Wink Saville3d54e742009-05-18 18:00:44 -07001990 p.writeInt32(p_cur->GW_SignalStrength.signalStrength);
1991 p.writeInt32(p_cur->GW_SignalStrength.bitErrorRate);
1992 p.writeInt32(p_cur->CDMA_SignalStrength.dbm);
1993 p.writeInt32(p_cur->CDMA_SignalStrength.ecio);
1994 p.writeInt32(p_cur->EVDO_SignalStrength.dbm);
1995 p.writeInt32(p_cur->EVDO_SignalStrength.ecio);
1996 p.writeInt32(p_cur->EVDO_SignalStrength.signalNoiseRatio);
Wink Savillec0114b32011-02-18 10:14:07 -08001997 if (responselen >= sizeof (RIL_SignalStrength_v6)) {
1998 p.writeInt32(p_cur->LTE_SignalStrength.signalStrength);
Uma Maheswari Ramalingam9efcac52012-08-09 11:59:17 -07001999
2000 /*
2001 * ril version <=6 receives negative values for rsrp
2002 * workaround for backward compatibility
2003 */
2004 p_cur->LTE_SignalStrength.rsrp =
2005 ((s_callbacks.version <= 6) && (p_cur->LTE_SignalStrength.rsrp < 0 )) ?
2006 -(p_cur->LTE_SignalStrength.rsrp) : p_cur->LTE_SignalStrength.rsrp;
2007
Wink Savillec0114b32011-02-18 10:14:07 -08002008 p.writeInt32(p_cur->LTE_SignalStrength.rsrp);
2009 p.writeInt32(p_cur->LTE_SignalStrength.rsrq);
2010 p.writeInt32(p_cur->LTE_SignalStrength.rssnr);
2011 p.writeInt32(p_cur->LTE_SignalStrength.cqi);
2012 } else {
2013 memset(&p_cur->LTE_SignalStrength, sizeof (RIL_LTE_SignalStrength), 0);
2014 }
johnwangfdf825f2009-05-22 15:50:34 -07002015
2016 startResponse;
Wink Savillea592eeb2009-05-22 13:26:36 -07002017 appendPrintBuf("%s[signalStrength=%d,bitErrorRate=%d,\
Wink Savillec0114b32011-02-18 10:14:07 -08002018 CDMA_SS.dbm=%d,CDMA_SSecio=%d,\
2019 EVDO_SS.dbm=%d,EVDO_SS.ecio=%d,\
2020 EVDO_SS.signalNoiseRatio=%d,\
2021 LTE_SS.signalStrength=%d,LTE_SS.rsrp=%d,LTE_SS.rsrq=%d,\
2022 LTE_SS.rssnr=%d,LTE_SS.cqi=%d]",
Wink Savillea592eeb2009-05-22 13:26:36 -07002023 printBuf,
2024 p_cur->GW_SignalStrength.signalStrength,
2025 p_cur->GW_SignalStrength.bitErrorRate,
2026 p_cur->CDMA_SignalStrength.dbm,
2027 p_cur->CDMA_SignalStrength.ecio,
2028 p_cur->EVDO_SignalStrength.dbm,
2029 p_cur->EVDO_SignalStrength.ecio,
Wink Savillec0114b32011-02-18 10:14:07 -08002030 p_cur->EVDO_SignalStrength.signalNoiseRatio,
2031 p_cur->LTE_SignalStrength.signalStrength,
2032 p_cur->LTE_SignalStrength.rsrp,
2033 p_cur->LTE_SignalStrength.rsrq,
2034 p_cur->LTE_SignalStrength.rssnr,
2035 p_cur->LTE_SignalStrength.cqi);
Wink Savillea592eeb2009-05-22 13:26:36 -07002036 closeResponse;
2037
Wink Saville3d54e742009-05-18 18:00:44 -07002038 } else {
Steve Blockf423cde2012-01-08 13:48:26 +00002039 ALOGE("invalid response length");
Wink Saville3d54e742009-05-18 18:00:44 -07002040 return RIL_ERRNO_INVALID_RESPONSE;
2041 }
2042
Wink Saville3d54e742009-05-18 18:00:44 -07002043 return 0;
2044}
2045
2046static int responseCallRing(Parcel &p, void *response, size_t responselen) {
2047 if ((response == NULL) || (responselen == 0)) {
2048 return responseVoid(p, response, responselen);
2049 } else {
2050 return responseCdmaSignalInfoRecord(p, response, responselen);
2051 }
2052}
2053
2054static int responseCdmaSignalInfoRecord(Parcel &p, void *response, size_t responselen) {
2055 if (response == NULL || responselen == 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00002056 ALOGE("invalid response: NULL");
Wink Saville3d54e742009-05-18 18:00:44 -07002057 return RIL_ERRNO_INVALID_RESPONSE;
2058 }
2059
2060 if (responselen != sizeof (RIL_CDMA_SignalInfoRecord)) {
Steve Blockf423cde2012-01-08 13:48:26 +00002061 ALOGE("invalid response length %d expected sizeof (RIL_CDMA_SignalInfoRecord) of %d\n",
Wink Saville3d54e742009-05-18 18:00:44 -07002062 (int)responselen, (int)sizeof (RIL_CDMA_SignalInfoRecord));
2063 return RIL_ERRNO_INVALID_RESPONSE;
2064 }
2065
2066 startResponse;
2067
2068 RIL_CDMA_SignalInfoRecord *p_cur = ((RIL_CDMA_SignalInfoRecord *) response);
2069 marshallSignalInfoRecord(p, *p_cur);
2070
2071 appendPrintBuf("%s[isPresent=%d,signalType=%d,alertPitch=%d\
2072 signal=%d]",
2073 printBuf,
2074 p_cur->isPresent,
2075 p_cur->signalType,
2076 p_cur->alertPitch,
2077 p_cur->signal);
2078
2079 closeResponse;
2080 return 0;
2081}
2082
Wink Savillea592eeb2009-05-22 13:26:36 -07002083static int responseCdmaCallWaiting(Parcel &p, void *response,
2084 size_t responselen) {
Wink Saville3d54e742009-05-18 18:00:44 -07002085 if (response == NULL && responselen != 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00002086 ALOGE("invalid response: NULL");
Wink Saville3d54e742009-05-18 18:00:44 -07002087 return RIL_ERRNO_INVALID_RESPONSE;
2088 }
2089
Wink Savillec0114b32011-02-18 10:14:07 -08002090 if (responselen < sizeof(RIL_CDMA_CallWaiting_v6)) {
Steve Block43b9c522012-01-06 10:14:35 +00002091 ALOGW("Upgrade to ril version %d\n", RIL_VERSION);
Wink Savillec0114b32011-02-18 10:14:07 -08002092 }
2093
2094 RIL_CDMA_CallWaiting_v6 *p_cur = ((RIL_CDMA_CallWaiting_v6 *) response);
2095
2096 writeStringToParcel(p, p_cur->number);
2097 p.writeInt32(p_cur->numberPresentation);
2098 writeStringToParcel(p, p_cur->name);
2099 marshallSignalInfoRecord(p, p_cur->signalInfoRecord);
2100
2101 if (responselen >= sizeof(RIL_CDMA_CallWaiting_v6)) {
2102 p.writeInt32(p_cur->number_type);
2103 p.writeInt32(p_cur->number_plan);
2104 } else {
2105 p.writeInt32(0);
2106 p.writeInt32(0);
Wink Saville3d54e742009-05-18 18:00:44 -07002107 }
2108
2109 startResponse;
Wink Saville3d54e742009-05-18 18:00:44 -07002110 appendPrintBuf("%snumber=%s,numberPresentation=%d, name=%s,\
2111 signalInfoRecord[isPresent=%d,signalType=%d,alertPitch=%d\
Wink Savillec0114b32011-02-18 10:14:07 -08002112 signal=%d,number_type=%d,number_plan=%d]",
Wink Saville3d54e742009-05-18 18:00:44 -07002113 printBuf,
2114 p_cur->number,
2115 p_cur->numberPresentation,
2116 p_cur->name,
2117 p_cur->signalInfoRecord.isPresent,
2118 p_cur->signalInfoRecord.signalType,
2119 p_cur->signalInfoRecord.alertPitch,
Wink Savillec0114b32011-02-18 10:14:07 -08002120 p_cur->signalInfoRecord.signal,
2121 p_cur->number_type,
2122 p_cur->number_plan);
Wink Saville3d54e742009-05-18 18:00:44 -07002123 closeResponse;
2124
2125 return 0;
2126}
2127
Alex Yakavenka45e740e2012-01-31 11:48:27 -08002128static int responseSimRefresh(Parcel &p, void *response, size_t responselen) {
2129 if (response == NULL && responselen != 0) {
2130 ALOGE("responseSimRefresh: invalid response: NULL");
2131 return RIL_ERRNO_INVALID_RESPONSE;
2132 }
2133
2134 startResponse;
2135 if (s_callbacks.version == 7) {
2136 RIL_SimRefreshResponse_v7 *p_cur = ((RIL_SimRefreshResponse_v7 *) response);
2137 p.writeInt32(p_cur->result);
2138 p.writeInt32(p_cur->ef_id);
2139 writeStringToParcel(p, p_cur->aid);
2140
2141 appendPrintBuf("%sresult=%d, ef_id=%d, aid=%s",
2142 printBuf,
2143 p_cur->result,
2144 p_cur->ef_id,
2145 p_cur->aid);
2146 } else {
2147 int *p_cur = ((int *) response);
2148 p.writeInt32(p_cur[0]);
2149 p.writeInt32(p_cur[1]);
2150 writeStringToParcel(p, NULL);
2151
2152 appendPrintBuf("%sresult=%d, ef_id=%d",
2153 printBuf,
2154 p_cur[0],
2155 p_cur[1]);
2156 }
2157 closeResponse;
2158
2159 return 0;
2160}
2161
Wink Saville3d54e742009-05-18 18:00:44 -07002162static void triggerEvLoop() {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002163 int ret;
2164 if (!pthread_equal(pthread_self(), s_tid_dispatch)) {
2165 /* trigger event loop to wakeup. No reason to do this,
2166 * if we're in the event loop thread */
2167 do {
2168 ret = write (s_fdWakeupWrite, " ", 1);
2169 } while (ret < 0 && errno == EINTR);
2170 }
2171}
2172
Wink Saville3d54e742009-05-18 18:00:44 -07002173static void rilEventAddWakeup(struct ril_event *ev) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002174 ril_event_add(ev);
2175 triggerEvLoop();
2176}
2177
Wink Savillefd729372011-02-22 16:19:39 -08002178static void sendSimStatusAppInfo(Parcel &p, int num_apps, RIL_AppStatus appStatus[]) {
2179 p.writeInt32(num_apps);
2180 startResponse;
2181 for (int i = 0; i < num_apps; i++) {
2182 p.writeInt32(appStatus[i].app_type);
2183 p.writeInt32(appStatus[i].app_state);
2184 p.writeInt32(appStatus[i].perso_substate);
2185 writeStringToParcel(p, (const char*)(appStatus[i].aid_ptr));
2186 writeStringToParcel(p, (const char*)
2187 (appStatus[i].app_label_ptr));
2188 p.writeInt32(appStatus[i].pin1_replaced);
2189 p.writeInt32(appStatus[i].pin1);
2190 p.writeInt32(appStatus[i].pin2);
2191 appendPrintBuf("%s[app_type=%d,app_state=%d,perso_substate=%d,\
2192 aid_ptr=%s,app_label_ptr=%s,pin1_replaced=%d,pin1=%d,pin2=%d],",
2193 printBuf,
2194 appStatus[i].app_type,
2195 appStatus[i].app_state,
2196 appStatus[i].perso_substate,
2197 appStatus[i].aid_ptr,
2198 appStatus[i].app_label_ptr,
2199 appStatus[i].pin1_replaced,
2200 appStatus[i].pin1,
2201 appStatus[i].pin2);
2202 }
2203 closeResponse;
2204}
2205
Wink Savillef4c4d362009-04-02 01:37:03 -07002206static int responseSimStatus(Parcel &p, void *response, size_t responselen) {
2207 int i;
2208
2209 if (response == NULL && responselen != 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00002210 ALOGE("invalid response: NULL");
Wink Savillef4c4d362009-04-02 01:37:03 -07002211 return RIL_ERRNO_INVALID_RESPONSE;
2212 }
2213
Wink Saville2c1fb3a2011-03-19 13:42:45 -07002214 if (responselen == sizeof (RIL_CardStatus_v6)) {
Wink Savillefd729372011-02-22 16:19:39 -08002215 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
Wink Savillef4c4d362009-04-02 01:37:03 -07002216
Wink Savillefd729372011-02-22 16:19:39 -08002217 p.writeInt32(p_cur->card_state);
2218 p.writeInt32(p_cur->universal_pin_state);
2219 p.writeInt32(p_cur->gsm_umts_subscription_app_index);
2220 p.writeInt32(p_cur->cdma_subscription_app_index);
2221 p.writeInt32(p_cur->ims_subscription_app_index);
2222
2223 sendSimStatusAppInfo(p, p_cur->num_applications, p_cur->applications);
Wink Saville2c1fb3a2011-03-19 13:42:45 -07002224 } else if (responselen == sizeof (RIL_CardStatus_v5)) {
Wink Savillefd729372011-02-22 16:19:39 -08002225 RIL_CardStatus_v5 *p_cur = ((RIL_CardStatus_v5 *) response);
2226
2227 p.writeInt32(p_cur->card_state);
2228 p.writeInt32(p_cur->universal_pin_state);
2229 p.writeInt32(p_cur->gsm_umts_subscription_app_index);
2230 p.writeInt32(p_cur->cdma_subscription_app_index);
2231 p.writeInt32(-1);
2232
2233 sendSimStatusAppInfo(p, p_cur->num_applications, p_cur->applications);
Wink Saville2c1fb3a2011-03-19 13:42:45 -07002234 } else {
Steve Blockf423cde2012-01-08 13:48:26 +00002235 ALOGE("responseSimStatus: A RilCardStatus_v6 or _v5 expected\n");
Wink Saville2c1fb3a2011-03-19 13:42:45 -07002236 return RIL_ERRNO_INVALID_RESPONSE;
Wink Savillef4c4d362009-04-02 01:37:03 -07002237 }
Wink Savillef4c4d362009-04-02 01:37:03 -07002238
2239 return 0;
Wink Saville3d54e742009-05-18 18:00:44 -07002240}
Wink Savillef4c4d362009-04-02 01:37:03 -07002241
Wink Savillea592eeb2009-05-22 13:26:36 -07002242static int responseGsmBrSmsCnf(Parcel &p, void *response, size_t responselen) {
2243 int num = responselen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
Wink Savillef4c4d362009-04-02 01:37:03 -07002244 p.writeInt32(num);
2245
Wink Savillef4c4d362009-04-02 01:37:03 -07002246 startResponse;
Wink Savillea592eeb2009-05-22 13:26:36 -07002247 RIL_GSM_BroadcastSmsConfigInfo **p_cur =
2248 (RIL_GSM_BroadcastSmsConfigInfo **) response;
2249 for (int i = 0; i < num; i++) {
2250 p.writeInt32(p_cur[i]->fromServiceId);
2251 p.writeInt32(p_cur[i]->toServiceId);
2252 p.writeInt32(p_cur[i]->fromCodeScheme);
2253 p.writeInt32(p_cur[i]->toCodeScheme);
2254 p.writeInt32(p_cur[i]->selected);
2255
2256 appendPrintBuf("%s [%d: fromServiceId=%d, toServiceId=%d, \
2257 fromCodeScheme=%d, toCodeScheme=%d, selected =%d]",
2258 printBuf, i, p_cur[i]->fromServiceId, p_cur[i]->toServiceId,
2259 p_cur[i]->fromCodeScheme, p_cur[i]->toCodeScheme,
2260 p_cur[i]->selected);
2261 }
Wink Savillef4c4d362009-04-02 01:37:03 -07002262 closeResponse;
2263
2264 return 0;
2265}
2266
Wink Savillea592eeb2009-05-22 13:26:36 -07002267static int responseCdmaBrSmsCnf(Parcel &p, void *response, size_t responselen) {
2268 RIL_CDMA_BroadcastSmsConfigInfo **p_cur =
2269 (RIL_CDMA_BroadcastSmsConfigInfo **) response;
Wink Savillef4c4d362009-04-02 01:37:03 -07002270
Wink Savillea592eeb2009-05-22 13:26:36 -07002271 int num = responselen / sizeof (RIL_CDMA_BroadcastSmsConfigInfo *);
2272 p.writeInt32(num);
Wink Savillef4c4d362009-04-02 01:37:03 -07002273
2274 startResponse;
Wink Savillea592eeb2009-05-22 13:26:36 -07002275 for (int i = 0 ; i < num ; i++ ) {
2276 p.writeInt32(p_cur[i]->service_category);
2277 p.writeInt32(p_cur[i]->language);
2278 p.writeInt32(p_cur[i]->selected);
Wink Savillef4c4d362009-04-02 01:37:03 -07002279
Wink Savillea592eeb2009-05-22 13:26:36 -07002280 appendPrintBuf("%s [%d: srvice_category=%d, language =%d, \
2281 selected =%d], ",
2282 printBuf, i, p_cur[i]->service_category, p_cur[i]->language,
2283 p_cur[i]->selected);
Wink Savillef5903df2009-04-24 11:54:14 -07002284 }
Wink Savillea592eeb2009-05-22 13:26:36 -07002285 closeResponse;
Wink Savillef5903df2009-04-24 11:54:14 -07002286
Wink Savillef4c4d362009-04-02 01:37:03 -07002287 return 0;
2288}
2289
2290static int responseCdmaSms(Parcel &p, void *response, size_t responselen) {
2291 int num;
2292 int digitCount;
2293 int digitLimit;
2294 uint8_t uct;
2295 void* dest;
2296
Steve Block64640682011-12-20 20:47:51 +00002297 ALOGD("Inside responseCdmaSms");
Wink Savillef5903df2009-04-24 11:54:14 -07002298
Wink Savillef4c4d362009-04-02 01:37:03 -07002299 if (response == NULL && responselen != 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00002300 ALOGE("invalid response: NULL");
Wink Savillef4c4d362009-04-02 01:37:03 -07002301 return RIL_ERRNO_INVALID_RESPONSE;
2302 }
2303
Wink Savillef5903df2009-04-24 11:54:14 -07002304 if (responselen != sizeof(RIL_CDMA_SMS_Message)) {
Steve Blockf423cde2012-01-08 13:48:26 +00002305 ALOGE("invalid response length was %d expected %d",
Wink Savillef5903df2009-04-24 11:54:14 -07002306 (int)responselen, (int)sizeof(RIL_CDMA_SMS_Message));
Wink Savillef4c4d362009-04-02 01:37:03 -07002307 return RIL_ERRNO_INVALID_RESPONSE;
2308 }
2309
2310 RIL_CDMA_SMS_Message *p_cur = (RIL_CDMA_SMS_Message *) response;
2311 p.writeInt32(p_cur->uTeleserviceID);
2312 p.write(&(p_cur->bIsServicePresent),sizeof(uct));
2313 p.writeInt32(p_cur->uServicecategory);
2314 p.writeInt32(p_cur->sAddress.digit_mode);
2315 p.writeInt32(p_cur->sAddress.number_mode);
2316 p.writeInt32(p_cur->sAddress.number_type);
2317 p.writeInt32(p_cur->sAddress.number_plan);
2318 p.write(&(p_cur->sAddress.number_of_digits), sizeof(uct));
2319 digitLimit= MIN((p_cur->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
2320 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
2321 p.write(&(p_cur->sAddress.digits[digitCount]),sizeof(uct));
2322 }
2323
2324 p.writeInt32(p_cur->sSubAddress.subaddressType);
2325 p.write(&(p_cur->sSubAddress.odd),sizeof(uct));
2326 p.write(&(p_cur->sSubAddress.number_of_digits),sizeof(uct));
2327 digitLimit= MIN((p_cur->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
2328 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
2329 p.write(&(p_cur->sSubAddress.digits[digitCount]),sizeof(uct));
2330 }
2331
2332 digitLimit= MIN((p_cur->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
2333 p.writeInt32(p_cur->uBearerDataLen);
2334 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
2335 p.write(&(p_cur->aBearerData[digitCount]), sizeof(uct));
2336 }
2337
2338 startResponse;
2339 appendPrintBuf("%suTeleserviceID=%d, bIsServicePresent=%d, uServicecategory=%d, \
Wink Saville1b5fd232009-04-22 14:50:00 -07002340 sAddress.digit_mode=%d, sAddress.number_mode=%d, sAddress.number_type=%d, ",
Wink Savillef4c4d362009-04-02 01:37:03 -07002341 printBuf, p_cur->uTeleserviceID,p_cur->bIsServicePresent,p_cur->uServicecategory,
2342 p_cur->sAddress.digit_mode, p_cur->sAddress.number_mode,p_cur->sAddress.number_type);
2343 closeResponse;
2344
2345 return 0;
2346}
2347
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002348/**
2349 * A write on the wakeup fd is done just to pop us out of select()
2350 * We empty the buffer here and then ril_event will reset the timers on the
2351 * way back down
2352 */
Wink Savillef4c4d362009-04-02 01:37:03 -07002353static void processWakeupCallback(int fd, short flags, void *param) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002354 char buff[16];
2355 int ret;
2356
Steve Blockeb902b82011-10-26 11:02:56 +01002357 ALOGV("processWakeupCallback");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002358
2359 /* empty our wakeup socket out */
2360 do {
2361 ret = read(s_fdWakeupRead, &buff, sizeof(buff));
Wink Saville7f856802009-06-09 10:23:37 -07002362 } while (ret > 0 || (ret < 0 && errno == EINTR));
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002363}
2364
Wink Savillef4c4d362009-04-02 01:37:03 -07002365static void onCommandsSocketClosed() {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002366 int ret;
2367 RequestInfo *p_cur;
2368
2369 /* mark pending requests as "cancelled" so we dont report responses */
2370
2371 ret = pthread_mutex_lock(&s_pendingRequestsMutex);
2372 assert (ret == 0);
2373
2374 p_cur = s_pendingRequests;
2375
Wink Saville7f856802009-06-09 10:23:37 -07002376 for (p_cur = s_pendingRequests
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002377 ; p_cur != NULL
2378 ; p_cur = p_cur->p_next
2379 ) {
2380 p_cur->cancelled = 1;
2381 }
2382
2383 ret = pthread_mutex_unlock(&s_pendingRequestsMutex);
2384 assert (ret == 0);
2385}
2386
Wink Savillef4c4d362009-04-02 01:37:03 -07002387static void processCommandsCallback(int fd, short flags, void *param) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002388 RecordStream *p_rs;
2389 void *p_record;
2390 size_t recordlen;
2391 int ret;
2392
2393 assert(fd == s_fdCommand);
2394
2395 p_rs = (RecordStream *)param;
2396
2397 for (;;) {
2398 /* loop until EAGAIN/EINTR, end of stream, or other error */
2399 ret = record_stream_get_next(p_rs, &p_record, &recordlen);
2400
2401 if (ret == 0 && p_record == NULL) {
2402 /* end-of-stream */
2403 break;
2404 } else if (ret < 0) {
2405 break;
2406 } else if (ret == 0) { /* && p_record != NULL */
2407 processCommandBuffer(p_record, recordlen);
2408 }
2409 }
2410
2411 if (ret == 0 || !(errno == EAGAIN || errno == EINTR)) {
2412 /* fatal error or end-of-stream */
2413 if (ret != 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00002414 ALOGE("error on reading command socket errno:%d\n", errno);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002415 } else {
Steve Block43b9c522012-01-06 10:14:35 +00002416 ALOGW("EOS. Closing command socket.");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002417 }
Wink Saville7f856802009-06-09 10:23:37 -07002418
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002419 close(s_fdCommand);
2420 s_fdCommand = -1;
2421
2422 ril_event_del(&s_commands_event);
2423
2424 record_stream_free(p_rs);
2425
2426 /* start listening for new connections again */
2427 rilEventAddWakeup(&s_listen_event);
2428
2429 onCommandsSocketClosed();
2430 }
2431}
2432
2433
Wink Savillef4c4d362009-04-02 01:37:03 -07002434static void onNewCommandConnect() {
Wink Saville5b9df332011-04-06 16:24:21 -07002435 // Inform we are connected and the ril version
Jake Hambya9c18d12011-04-12 23:32:08 -07002436 int rilVer = s_callbacks.version;
Wink Saville5b9df332011-04-06 16:24:21 -07002437 RIL_onUnsolicitedResponse(RIL_UNSOL_RIL_CONNECTED,
2438 &rilVer, sizeof(rilVer));
2439
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002440 // implicit radio state changed
2441 RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED,
2442 NULL, 0);
2443
2444 // Send last NITZ time data, in case it was missed
2445 if (s_lastNITZTimeData != NULL) {
2446 sendResponseRaw(s_lastNITZTimeData, s_lastNITZTimeDataSize);
2447
2448 free(s_lastNITZTimeData);
2449 s_lastNITZTimeData = NULL;
2450 }
2451
2452 // Get version string
2453 if (s_callbacks.getVersion != NULL) {
2454 const char *version;
2455 version = s_callbacks.getVersion();
Steve Block9139bfb2012-01-05 00:10:31 +00002456 ALOGI("RIL Daemon version: %s\n", version);
Wink Saville7f856802009-06-09 10:23:37 -07002457
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002458 property_set(PROPERTY_RIL_IMPL, version);
2459 } else {
Steve Block9139bfb2012-01-05 00:10:31 +00002460 ALOGI("RIL Daemon version: unavailable\n");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002461 property_set(PROPERTY_RIL_IMPL, "unavailable");
2462 }
2463
2464}
2465
Wink Savillef4c4d362009-04-02 01:37:03 -07002466static void listenCallback (int fd, short flags, void *param) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002467 int ret;
2468 int err;
2469 int is_phone_socket;
2470 RecordStream *p_rs;
2471
2472 struct sockaddr_un peeraddr;
2473 socklen_t socklen = sizeof (peeraddr);
2474
2475 struct ucred creds;
2476 socklen_t szCreds = sizeof(creds);
2477
2478 struct passwd *pwd = NULL;
2479
2480 assert (s_fdCommand < 0);
2481 assert (fd == s_fdListen);
Wink Saville7f856802009-06-09 10:23:37 -07002482
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002483 s_fdCommand = accept(s_fdListen, (sockaddr *) &peeraddr, &socklen);
2484
2485 if (s_fdCommand < 0 ) {
Steve Blockf423cde2012-01-08 13:48:26 +00002486 ALOGE("Error on accept() errno:%d", errno);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002487 /* start listening for new connections again */
2488 rilEventAddWakeup(&s_listen_event);
Wink Savillef4c4d362009-04-02 01:37:03 -07002489 return;
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002490 }
2491
2492 /* check the credential of the other side and only accept socket from
2493 * phone process
Wink Saville7f856802009-06-09 10:23:37 -07002494 */
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002495 errno = 0;
2496 is_phone_socket = 0;
Wink Savillef4c4d362009-04-02 01:37:03 -07002497
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002498 err = getsockopt(s_fdCommand, SOL_SOCKET, SO_PEERCRED, &creds, &szCreds);
Wink Savillef4c4d362009-04-02 01:37:03 -07002499
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002500 if (err == 0 && szCreds > 0) {
Wink Savillef4c4d362009-04-02 01:37:03 -07002501 errno = 0;
2502 pwd = getpwuid(creds.uid);
2503 if (pwd != NULL) {
2504 if (strcmp(pwd->pw_name, PHONE_PROCESS) == 0) {
2505 is_phone_socket = 1;
2506 } else {
Steve Blockf423cde2012-01-08 13:48:26 +00002507 ALOGE("RILD can't accept socket from process %s", pwd->pw_name);
Wink Savillef4c4d362009-04-02 01:37:03 -07002508 }
2509 } else {
Steve Blockf423cde2012-01-08 13:48:26 +00002510 ALOGE("Error on getpwuid() errno: %d", errno);
Wink Savillef4c4d362009-04-02 01:37:03 -07002511 }
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002512 } else {
Steve Block64640682011-12-20 20:47:51 +00002513 ALOGD("Error on getsockopt() errno: %d", errno);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002514 }
2515
2516 if ( !is_phone_socket ) {
Steve Blockf423cde2012-01-08 13:48:26 +00002517 ALOGE("RILD must accept socket from %s", PHONE_PROCESS);
Wink Saville7f856802009-06-09 10:23:37 -07002518
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002519 close(s_fdCommand);
2520 s_fdCommand = -1;
2521
2522 onCommandsSocketClosed();
2523
2524 /* start listening for new connections again */
2525 rilEventAddWakeup(&s_listen_event);
2526
2527 return;
2528 }
2529
2530 ret = fcntl(s_fdCommand, F_SETFL, O_NONBLOCK);
2531
2532 if (ret < 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00002533 ALOGE ("Error setting O_NONBLOCK errno:%d", errno);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002534 }
2535
Steve Block9139bfb2012-01-05 00:10:31 +00002536 ALOGI("libril: new connection");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002537
2538 p_rs = record_stream_new(s_fdCommand, MAX_COMMAND_BYTES);
2539
Wink Saville7f856802009-06-09 10:23:37 -07002540 ril_event_set (&s_commands_event, s_fdCommand, 1,
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002541 processCommandsCallback, p_rs);
2542
2543 rilEventAddWakeup (&s_commands_event);
2544
2545 onNewCommandConnect();
2546}
2547
2548static void freeDebugCallbackArgs(int number, char **args) {
2549 for (int i = 0; i < number; i++) {
2550 if (args[i] != NULL) {
2551 free(args[i]);
2552 }
2553 }
2554 free(args);
2555}
2556
Wink Savillef4c4d362009-04-02 01:37:03 -07002557static void debugCallback (int fd, short flags, void *param) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002558 int acceptFD, option;
2559 struct sockaddr_un peeraddr;
2560 socklen_t socklen = sizeof (peeraddr);
2561 int data;
2562 unsigned int qxdm_data[6];
2563 const char *deactData[1] = {"1"};
2564 char *actData[1];
2565 RIL_Dial dialData;
2566 int hangupData[1] = {1};
2567 int number;
2568 char **args;
2569
2570 acceptFD = accept (fd, (sockaddr *) &peeraddr, &socklen);
2571
2572 if (acceptFD < 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00002573 ALOGE ("error accepting on debug port: %d\n", errno);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002574 return;
2575 }
2576
2577 if (recv(acceptFD, &number, sizeof(int), 0) != sizeof(int)) {
Steve Blockf423cde2012-01-08 13:48:26 +00002578 ALOGE ("error reading on socket: number of Args: \n");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002579 return;
2580 }
2581 args = (char **) malloc(sizeof(char*) * number);
2582
2583 for (int i = 0; i < number; i++) {
2584 int len;
2585 if (recv(acceptFD, &len, sizeof(int), 0) != sizeof(int)) {
Steve Blockf423cde2012-01-08 13:48:26 +00002586 ALOGE ("error reading on socket: Len of Args: \n");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002587 freeDebugCallbackArgs(i, args);
2588 return;
2589 }
2590 // +1 for null-term
2591 args[i] = (char *) malloc((sizeof(char) * len) + 1);
Wink Saville7f856802009-06-09 10:23:37 -07002592 if (recv(acceptFD, args[i], sizeof(char) * len, 0)
Wink Saville1b5fd232009-04-22 14:50:00 -07002593 != (int)sizeof(char) * len) {
Steve Blockf423cde2012-01-08 13:48:26 +00002594 ALOGE ("error reading on socket: Args[%d] \n", i);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002595 freeDebugCallbackArgs(i, args);
2596 return;
2597 }
2598 char * buf = args[i];
2599 buf[len] = 0;
2600 }
2601
2602 switch (atoi(args[0])) {
2603 case 0:
Steve Block9139bfb2012-01-05 00:10:31 +00002604 ALOGI ("Connection on debug port: issuing reset.");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002605 issueLocalRequest(RIL_REQUEST_RESET_RADIO, NULL, 0);
2606 break;
2607 case 1:
Steve Block9139bfb2012-01-05 00:10:31 +00002608 ALOGI ("Connection on debug port: issuing radio power off.");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002609 data = 0;
2610 issueLocalRequest(RIL_REQUEST_RADIO_POWER, &data, sizeof(int));
2611 // Close the socket
2612 close(s_fdCommand);
2613 s_fdCommand = -1;
2614 break;
2615 case 2:
Steve Block9139bfb2012-01-05 00:10:31 +00002616 ALOGI ("Debug port: issuing unsolicited voice network change.");
Wink Savillec0114b32011-02-18 10:14:07 -08002617 RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED,
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002618 NULL, 0);
2619 break;
2620 case 3:
Steve Block9139bfb2012-01-05 00:10:31 +00002621 ALOGI ("Debug port: QXDM log enable.");
Xia Wangd855ef42010-07-27 17:26:55 -07002622 qxdm_data[0] = 65536; // head.func_tag
2623 qxdm_data[1] = 16; // head.len
2624 qxdm_data[2] = 1; // mode: 1 for 'start logging'
2625 qxdm_data[3] = 32; // log_file_size: 32megabytes
2626 qxdm_data[4] = 0; // log_mask
2627 qxdm_data[5] = 8; // log_max_fileindex
Wink Saville7f856802009-06-09 10:23:37 -07002628 issueLocalRequest(RIL_REQUEST_OEM_HOOK_RAW, qxdm_data,
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002629 6 * sizeof(int));
2630 break;
2631 case 4:
Steve Block9139bfb2012-01-05 00:10:31 +00002632 ALOGI ("Debug port: QXDM log disable.");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002633 qxdm_data[0] = 65536;
2634 qxdm_data[1] = 16;
Xia Wangd855ef42010-07-27 17:26:55 -07002635 qxdm_data[2] = 0; // mode: 0 for 'stop logging'
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002636 qxdm_data[3] = 32;
2637 qxdm_data[4] = 0;
Xia Wangd855ef42010-07-27 17:26:55 -07002638 qxdm_data[5] = 8;
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002639 issueLocalRequest(RIL_REQUEST_OEM_HOOK_RAW, qxdm_data,
2640 6 * sizeof(int));
2641 break;
2642 case 5:
Steve Block9139bfb2012-01-05 00:10:31 +00002643 ALOGI("Debug port: Radio On");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002644 data = 1;
2645 issueLocalRequest(RIL_REQUEST_RADIO_POWER, &data, sizeof(int));
2646 sleep(2);
2647 // Set network selection automatic.
2648 issueLocalRequest(RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC, NULL, 0);
2649 break;
2650 case 6:
Steve Block9139bfb2012-01-05 00:10:31 +00002651 ALOGI("Debug port: Setup Data Call, Apn :%s\n", args[1]);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002652 actData[0] = args[1];
Wink Saville7f856802009-06-09 10:23:37 -07002653 issueLocalRequest(RIL_REQUEST_SETUP_DATA_CALL, &actData,
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002654 sizeof(actData));
2655 break;
2656 case 7:
Steve Block9139bfb2012-01-05 00:10:31 +00002657 ALOGI("Debug port: Deactivate Data Call");
Wink Saville7f856802009-06-09 10:23:37 -07002658 issueLocalRequest(RIL_REQUEST_DEACTIVATE_DATA_CALL, &deactData,
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002659 sizeof(deactData));
2660 break;
2661 case 8:
Steve Block9139bfb2012-01-05 00:10:31 +00002662 ALOGI("Debug port: Dial Call");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002663 dialData.clir = 0;
2664 dialData.address = args[1];
2665 issueLocalRequest(RIL_REQUEST_DIAL, &dialData, sizeof(dialData));
2666 break;
2667 case 9:
Steve Block9139bfb2012-01-05 00:10:31 +00002668 ALOGI("Debug port: Answer Call");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002669 issueLocalRequest(RIL_REQUEST_ANSWER, NULL, 0);
2670 break;
2671 case 10:
Steve Block9139bfb2012-01-05 00:10:31 +00002672 ALOGI("Debug port: End Call");
Wink Saville7f856802009-06-09 10:23:37 -07002673 issueLocalRequest(RIL_REQUEST_HANGUP, &hangupData,
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002674 sizeof(hangupData));
2675 break;
2676 default:
Steve Blockf423cde2012-01-08 13:48:26 +00002677 ALOGE ("Invalid request");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002678 break;
2679 }
2680 freeDebugCallbackArgs(number, args);
2681 close(acceptFD);
2682}
2683
2684
Wink Savillef4c4d362009-04-02 01:37:03 -07002685static void userTimerCallback (int fd, short flags, void *param) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002686 UserCallbackInfo *p_info;
2687
2688 p_info = (UserCallbackInfo *)param;
2689
2690 p_info->p_callback(p_info->userParam);
2691
2692
2693 // FIXME generalize this...there should be a cancel mechanism
2694 if (s_last_wake_timeout_info != NULL && s_last_wake_timeout_info == p_info) {
2695 s_last_wake_timeout_info = NULL;
2696 }
2697
2698 free(p_info);
2699}
2700
2701
2702static void *
Wink Savillef4c4d362009-04-02 01:37:03 -07002703eventLoop(void *param) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002704 int ret;
2705 int filedes[2];
2706
2707 ril_event_init();
2708
2709 pthread_mutex_lock(&s_startupMutex);
2710
2711 s_started = 1;
2712 pthread_cond_broadcast(&s_startupCond);
2713
2714 pthread_mutex_unlock(&s_startupMutex);
2715
2716 ret = pipe(filedes);
2717
2718 if (ret < 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00002719 ALOGE("Error in pipe() errno:%d", errno);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002720 return NULL;
2721 }
2722
2723 s_fdWakeupRead = filedes[0];
2724 s_fdWakeupWrite = filedes[1];
2725
2726 fcntl(s_fdWakeupRead, F_SETFL, O_NONBLOCK);
2727
2728 ril_event_set (&s_wakeupfd_event, s_fdWakeupRead, true,
2729 processWakeupCallback, NULL);
2730
2731 rilEventAddWakeup (&s_wakeupfd_event);
2732
2733 // Only returns on error
2734 ril_event_loop();
Steve Blockf423cde2012-01-08 13:48:26 +00002735 ALOGE ("error in event_loop_base errno:%d", errno);
Kazuhiro Ondo5cdc1352011-10-14 17:50:58 -05002736 // kill self to restart on error
2737 kill(0, SIGKILL);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002738
2739 return NULL;
2740}
2741
Wink Saville7f856802009-06-09 10:23:37 -07002742extern "C" void
Wink Savillef4c4d362009-04-02 01:37:03 -07002743RIL_startEventLoop(void) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002744 int ret;
2745 pthread_attr_t attr;
Wink Saville7f856802009-06-09 10:23:37 -07002746
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002747 /* spin up eventLoop thread and wait for it to get started */
2748 s_started = 0;
2749 pthread_mutex_lock(&s_startupMutex);
2750
2751 pthread_attr_init (&attr);
Wink Saville7f856802009-06-09 10:23:37 -07002752 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002753 ret = pthread_create(&s_tid_dispatch, &attr, eventLoop, NULL);
2754
2755 while (s_started == 0) {
2756 pthread_cond_wait(&s_startupCond, &s_startupMutex);
2757 }
2758
2759 pthread_mutex_unlock(&s_startupMutex);
2760
2761 if (ret < 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00002762 ALOGE("Failed to create dispatch thread errno:%d", errno);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002763 return;
2764 }
2765}
2766
2767// Used for testing purpose only.
2768extern "C" void RIL_setcallbacks (const RIL_RadioFunctions *callbacks) {
2769 memcpy(&s_callbacks, callbacks, sizeof (RIL_RadioFunctions));
2770}
2771
Wink Saville7f856802009-06-09 10:23:37 -07002772extern "C" void
Wink Savillef4c4d362009-04-02 01:37:03 -07002773RIL_register (const RIL_RadioFunctions *callbacks) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002774 int ret;
2775 int flags;
2776
Wink Saville43808972011-01-13 17:39:51 -08002777 if (callbacks == NULL) {
Steve Blockf423cde2012-01-08 13:48:26 +00002778 ALOGE("RIL_register: RIL_RadioFunctions * null");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002779 return;
2780 }
Wink Saville43808972011-01-13 17:39:51 -08002781 if (callbacks->version < RIL_VERSION_MIN) {
Steve Blockf423cde2012-01-08 13:48:26 +00002782 ALOGE("RIL_register: version %d is to old, min version is %d",
Wink Saville43808972011-01-13 17:39:51 -08002783 callbacks->version, RIL_VERSION_MIN);
2784 return;
Wink Saville3a4840b2010-04-07 13:29:58 -07002785 }
Wink Saville43808972011-01-13 17:39:51 -08002786 if (callbacks->version > RIL_VERSION) {
Steve Blockf423cde2012-01-08 13:48:26 +00002787 ALOGE("RIL_register: version %d is too new, max version is %d",
Wink Saville43808972011-01-13 17:39:51 -08002788 callbacks->version, RIL_VERSION);
2789 return;
2790 }
Steve Blockf423cde2012-01-08 13:48:26 +00002791 ALOGE("RIL_register: RIL version %d", callbacks->version);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002792
2793 if (s_registerCalled > 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00002794 ALOGE("RIL_register has been called more than once. "
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002795 "Subsequent call ignored");
2796 return;
2797 }
2798
2799 memcpy(&s_callbacks, callbacks, sizeof (RIL_RadioFunctions));
2800
2801 s_registerCalled = 1;
2802
2803 // Little self-check
2804
Wink Savillef4c4d362009-04-02 01:37:03 -07002805 for (int i = 0; i < (int)NUM_ELEMS(s_commands); i++) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002806 assert(i == s_commands[i].requestNumber);
2807 }
2808
Wink Savillef4c4d362009-04-02 01:37:03 -07002809 for (int i = 0; i < (int)NUM_ELEMS(s_unsolResponses); i++) {
Wink Saville7f856802009-06-09 10:23:37 -07002810 assert(i + RIL_UNSOL_RESPONSE_BASE
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002811 == s_unsolResponses[i].requestNumber);
2812 }
2813
2814 // New rild impl calls RIL_startEventLoop() first
2815 // old standalone impl wants it here.
2816
2817 if (s_started == 0) {
2818 RIL_startEventLoop();
2819 }
2820
2821 // start listen socket
2822
2823#if 0
Wink Saville7f856802009-06-09 10:23:37 -07002824 ret = socket_local_server (SOCKET_NAME_RIL,
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002825 ANDROID_SOCKET_NAMESPACE_ABSTRACT, SOCK_STREAM);
2826
2827 if (ret < 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00002828 ALOGE("Unable to bind socket errno:%d", errno);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002829 exit (-1);
2830 }
2831 s_fdListen = ret;
2832
2833#else
2834 s_fdListen = android_get_control_socket(SOCKET_NAME_RIL);
2835 if (s_fdListen < 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00002836 ALOGE("Failed to get socket '" SOCKET_NAME_RIL "'");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002837 exit(-1);
2838 }
2839
2840 ret = listen(s_fdListen, 4);
2841
2842 if (ret < 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00002843 ALOGE("Failed to listen on control socket '%d': %s",
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002844 s_fdListen, strerror(errno));
2845 exit(-1);
2846 }
2847#endif
2848
2849
2850 /* note: non-persistent so we can accept only one connection at a time */
Wink Saville7f856802009-06-09 10:23:37 -07002851 ril_event_set (&s_listen_event, s_fdListen, false,
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002852 listenCallback, NULL);
2853
2854 rilEventAddWakeup (&s_listen_event);
2855
2856#if 1
2857 // start debug interface socket
2858
2859 s_fdDebug = android_get_control_socket(SOCKET_NAME_RIL_DEBUG);
2860 if (s_fdDebug < 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00002861 ALOGE("Failed to get socket '" SOCKET_NAME_RIL_DEBUG "' errno:%d", errno);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002862 exit(-1);
2863 }
2864
2865 ret = listen(s_fdDebug, 4);
2866
2867 if (ret < 0) {
Steve Blockf423cde2012-01-08 13:48:26 +00002868 ALOGE("Failed to listen on ril debug socket '%d': %s",
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002869 s_fdDebug, strerror(errno));
2870 exit(-1);
2871 }
2872
2873 ril_event_set (&s_debug_event, s_fdDebug, true,
2874 debugCallback, NULL);
2875
2876 rilEventAddWakeup (&s_debug_event);
2877#endif
2878
2879}
2880
2881static int
Wink Savillef4c4d362009-04-02 01:37:03 -07002882checkAndDequeueRequestInfo(struct RequestInfo *pRI) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002883 int ret = 0;
Wink Saville7f856802009-06-09 10:23:37 -07002884
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002885 if (pRI == NULL) {
2886 return 0;
2887 }
2888
2889 pthread_mutex_lock(&s_pendingRequestsMutex);
2890
Wink Saville7f856802009-06-09 10:23:37 -07002891 for(RequestInfo **ppCur = &s_pendingRequests
2892 ; *ppCur != NULL
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002893 ; ppCur = &((*ppCur)->p_next)
2894 ) {
2895 if (pRI == *ppCur) {
2896 ret = 1;
2897
2898 *ppCur = (*ppCur)->p_next;
2899 break;
2900 }
2901 }
2902
2903 pthread_mutex_unlock(&s_pendingRequestsMutex);
2904
2905 return ret;
2906}
2907
2908
2909extern "C" void
Wink Savillef4c4d362009-04-02 01:37:03 -07002910RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responselen) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002911 RequestInfo *pRI;
2912 int ret;
2913 size_t errorOffset;
2914
2915 pRI = (RequestInfo *)t;
2916
2917 if (!checkAndDequeueRequestInfo(pRI)) {
Steve Blockf423cde2012-01-08 13:48:26 +00002918 ALOGE ("RIL_onRequestComplete: invalid RIL_Token");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002919 return;
2920 }
2921
2922 if (pRI->local > 0) {
2923 // Locally issued command...void only!
2924 // response does not go back up the command socket
Steve Block64640682011-12-20 20:47:51 +00002925 ALOGD("C[locl]< %s", requestToString(pRI->pCI->requestNumber));
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002926
2927 goto done;
2928 }
2929
2930 appendPrintBuf("[%04d]< %s",
2931 pRI->token, requestToString(pRI->pCI->requestNumber));
2932
2933 if (pRI->cancelled == 0) {
2934 Parcel p;
2935
2936 p.writeInt32 (RESPONSE_SOLICITED);
2937 p.writeInt32 (pRI->token);
2938 errorOffset = p.dataPosition();
2939
2940 p.writeInt32 (e);
2941
johnwangb2a61842009-06-02 14:55:45 -07002942 if (response != NULL) {
2943 // there is a response payload, no matter success or not.
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002944 ret = pRI->pCI->responseFunction(p, response, responselen);
2945
2946 /* if an error occurred, rewind and mark it */
2947 if (ret != 0) {
2948 p.setDataPosition(errorOffset);
2949 p.writeInt32 (ret);
2950 }
johnwangb2a61842009-06-02 14:55:45 -07002951 }
2952
2953 if (e != RIL_E_SUCCESS) {
2954 appendPrintBuf("%s fails by %s", printBuf, failCauseToString(e));
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002955 }
2956
2957 if (s_fdCommand < 0) {
Steve Block64640682011-12-20 20:47:51 +00002958 ALOGD ("RIL onRequestComplete: Command channel closed");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002959 }
2960 sendResponse(p);
2961 }
2962
2963done:
2964 free(pRI);
2965}
2966
2967
2968static void
Wink Savillef4c4d362009-04-02 01:37:03 -07002969grabPartialWakeLock() {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002970 acquire_wake_lock(PARTIAL_WAKE_LOCK, ANDROID_WAKE_LOCK_NAME);
2971}
2972
2973static void
Wink Savillef4c4d362009-04-02 01:37:03 -07002974releaseWakeLock() {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002975 release_wake_lock(ANDROID_WAKE_LOCK_NAME);
2976}
2977
2978/**
2979 * Timer callback to put us back to sleep before the default timeout
2980 */
2981static void
Wink Savillef4c4d362009-04-02 01:37:03 -07002982wakeTimeoutCallback (void *param) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002983 // We're using "param != NULL" as a cancellation mechanism
2984 if (param == NULL) {
Steve Block64640682011-12-20 20:47:51 +00002985 //ALOGD("wakeTimeout: releasing wake lock");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002986
2987 releaseWakeLock();
2988 } else {
Steve Block64640682011-12-20 20:47:51 +00002989 //ALOGD("wakeTimeout: releasing wake lock CANCELLED");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08002990 }
2991}
2992
Naveen Kalla2bc78d62011-12-07 16:22:53 -08002993static int
2994decodeVoiceRadioTechnology (RIL_RadioState radioState) {
2995 switch (radioState) {
2996 case RADIO_STATE_SIM_NOT_READY:
2997 case RADIO_STATE_SIM_LOCKED_OR_ABSENT:
2998 case RADIO_STATE_SIM_READY:
2999 return RADIO_TECH_UMTS;
3000
3001 case RADIO_STATE_RUIM_NOT_READY:
3002 case RADIO_STATE_RUIM_READY:
3003 case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:
3004 case RADIO_STATE_NV_NOT_READY:
3005 case RADIO_STATE_NV_READY:
3006 return RADIO_TECH_1xRTT;
3007
3008 default:
Steve Block64640682011-12-20 20:47:51 +00003009 ALOGD("decodeVoiceRadioTechnology: Invoked with incorrect RadioState");
Naveen Kalla2bc78d62011-12-07 16:22:53 -08003010 return -1;
3011 }
3012}
3013
3014static int
3015decodeCdmaSubscriptionSource (RIL_RadioState radioState) {
3016 switch (radioState) {
3017 case RADIO_STATE_SIM_NOT_READY:
3018 case RADIO_STATE_SIM_LOCKED_OR_ABSENT:
3019 case RADIO_STATE_SIM_READY:
3020 case RADIO_STATE_RUIM_NOT_READY:
3021 case RADIO_STATE_RUIM_READY:
3022 case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:
3023 return CDMA_SUBSCRIPTION_SOURCE_RUIM_SIM;
3024
3025 case RADIO_STATE_NV_NOT_READY:
3026 case RADIO_STATE_NV_READY:
3027 return CDMA_SUBSCRIPTION_SOURCE_NV;
3028
3029 default:
Steve Block64640682011-12-20 20:47:51 +00003030 ALOGD("decodeCdmaSubscriptionSource: Invoked with incorrect RadioState");
Naveen Kalla2bc78d62011-12-07 16:22:53 -08003031 return -1;
3032 }
3033}
3034
3035static int
3036decodeSimStatus (RIL_RadioState radioState) {
3037 switch (radioState) {
3038 case RADIO_STATE_SIM_NOT_READY:
3039 case RADIO_STATE_RUIM_NOT_READY:
3040 case RADIO_STATE_NV_NOT_READY:
3041 case RADIO_STATE_NV_READY:
3042 return -1;
3043 case RADIO_STATE_SIM_LOCKED_OR_ABSENT:
3044 case RADIO_STATE_SIM_READY:
3045 case RADIO_STATE_RUIM_READY:
3046 case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:
3047 return radioState;
3048 default:
Steve Block64640682011-12-20 20:47:51 +00003049 ALOGD("decodeSimStatus: Invoked with incorrect RadioState");
Naveen Kalla2bc78d62011-12-07 16:22:53 -08003050 return -1;
3051 }
3052}
3053
3054static bool is3gpp2(int radioTech) {
3055 switch (radioTech) {
3056 case RADIO_TECH_IS95A:
3057 case RADIO_TECH_IS95B:
3058 case RADIO_TECH_1xRTT:
3059 case RADIO_TECH_EVDO_0:
3060 case RADIO_TECH_EVDO_A:
3061 case RADIO_TECH_EVDO_B:
3062 case RADIO_TECH_EHRPD:
3063 return true;
3064 default:
3065 return false;
3066 }
3067}
3068
3069/* If RIL sends SIM states or RUIM states, store the voice radio
3070 * technology and subscription source information so that they can be
3071 * returned when telephony framework requests them
3072 */
3073static RIL_RadioState
3074processRadioState(RIL_RadioState newRadioState) {
3075
3076 if((newRadioState > RADIO_STATE_UNAVAILABLE) && (newRadioState < RADIO_STATE_ON)) {
3077 int newVoiceRadioTech;
3078 int newCdmaSubscriptionSource;
3079 int newSimStatus;
3080
3081 /* This is old RIL. Decode Subscription source and Voice Radio Technology
3082 from Radio State and send change notifications if there has been a change */
3083 newVoiceRadioTech = decodeVoiceRadioTechnology(newRadioState);
3084 if(newVoiceRadioTech != voiceRadioTech) {
3085 voiceRadioTech = newVoiceRadioTech;
3086 RIL_onUnsolicitedResponse (RIL_UNSOL_VOICE_RADIO_TECH_CHANGED,
3087 &voiceRadioTech, sizeof(voiceRadioTech));
3088 }
3089 if(is3gpp2(newVoiceRadioTech)) {
3090 newCdmaSubscriptionSource = decodeCdmaSubscriptionSource(newRadioState);
3091 if(newCdmaSubscriptionSource != cdmaSubscriptionSource) {
3092 cdmaSubscriptionSource = newCdmaSubscriptionSource;
3093 RIL_onUnsolicitedResponse (RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED,
3094 &cdmaSubscriptionSource, sizeof(cdmaSubscriptionSource));
3095 }
3096 }
3097 newSimStatus = decodeSimStatus(newRadioState);
3098 if(newSimStatus != simRuimStatus) {
3099 simRuimStatus = newSimStatus;
3100 RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, NULL, 0);
3101 }
3102
3103 /* Send RADIO_ON to telephony */
3104 newRadioState = RADIO_STATE_ON;
3105 }
3106
3107 return newRadioState;
3108}
3109
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08003110extern "C"
3111void RIL_onUnsolicitedResponse(int unsolResponse, void *data,
3112 size_t datalen)
3113{
3114 int unsolResponseIndex;
3115 int ret;
3116 int64_t timeReceived = 0;
3117 bool shouldScheduleTimeout = false;
Naveen Kalla2bc78d62011-12-07 16:22:53 -08003118 RIL_RadioState newState;
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08003119
3120 if (s_registerCalled == 0) {
3121 // Ignore RIL_onUnsolicitedResponse before RIL_register
Steve Block43b9c522012-01-06 10:14:35 +00003122 ALOGW("RIL_onUnsolicitedResponse called before RIL_register");
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08003123 return;
3124 }
Wink Saville7f856802009-06-09 10:23:37 -07003125
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08003126 unsolResponseIndex = unsolResponse - RIL_UNSOL_RESPONSE_BASE;
3127
3128 if ((unsolResponseIndex < 0)
3129 || (unsolResponseIndex >= (int32_t)NUM_ELEMS(s_unsolResponses))) {
Steve Blockf423cde2012-01-08 13:48:26 +00003130 ALOGE("unsupported unsolicited response code %d", unsolResponse);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08003131 return;
3132 }
3133
3134 // Grab a wake lock if needed for this reponse,
3135 // as we exit we'll either release it immediately
3136 // or set a timer to release it later.
3137 switch (s_unsolResponses[unsolResponseIndex].wakeType) {
3138 case WAKE_PARTIAL:
3139 grabPartialWakeLock();
3140 shouldScheduleTimeout = true;
3141 break;
3142
3143 case DONT_WAKE:
3144 default:
3145 // No wake lock is grabed so don't set timeout
3146 shouldScheduleTimeout = false;
3147 break;
3148 }
3149
3150 // Mark the time this was received, doing this
3151 // after grabing the wakelock incase getting
3152 // the elapsedRealTime might cause us to goto
3153 // sleep.
3154 if (unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) {
3155 timeReceived = elapsedRealtime();
3156 }
3157
3158 appendPrintBuf("[UNSL]< %s", requestToString(unsolResponse));
3159
3160 Parcel p;
3161
3162 p.writeInt32 (RESPONSE_UNSOLICITED);
3163 p.writeInt32 (unsolResponse);
3164
3165 ret = s_unsolResponses[unsolResponseIndex]
3166 .responseFunction(p, data, datalen);
3167 if (ret != 0) {
3168 // Problem with the response. Don't continue;
3169 goto error_exit;
3170 }
3171
3172 // some things get more payload
3173 switch(unsolResponse) {
3174 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED:
Naveen Kalla2bc78d62011-12-07 16:22:53 -08003175 newState = processRadioState(s_callbacks.onStateRequest());
3176 p.writeInt32(newState);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08003177 appendPrintBuf("%s {%s}", printBuf,
3178 radioStateToString(s_callbacks.onStateRequest()));
3179 break;
3180
3181
3182 case RIL_UNSOL_NITZ_TIME_RECEIVED:
3183 // Store the time that this was received so the
3184 // handler of this message can account for
3185 // the time it takes to arrive and process. In
3186 // particular the system has been known to sleep
3187 // before this message can be processed.
3188 p.writeInt64(timeReceived);
3189 break;
3190 }
3191
3192 ret = sendResponse(p);
3193 if (ret != 0 && unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) {
3194
3195 // Unfortunately, NITZ time is not poll/update like everything
3196 // else in the system. So, if the upstream client isn't connected,
3197 // keep a copy of the last NITZ response (with receive time noted
3198 // above) around so we can deliver it when it is connected
3199
3200 if (s_lastNITZTimeData != NULL) {
3201 free (s_lastNITZTimeData);
3202 s_lastNITZTimeData = NULL;
3203 }
3204
3205 s_lastNITZTimeData = malloc(p.dataSize());
3206 s_lastNITZTimeDataSize = p.dataSize();
3207 memcpy(s_lastNITZTimeData, p.data(), p.dataSize());
3208 }
3209
3210 // For now, we automatically go back to sleep after TIMEVAL_WAKE_TIMEOUT
3211 // FIXME The java code should handshake here to release wake lock
3212
3213 if (shouldScheduleTimeout) {
3214 // Cancel the previous request
3215 if (s_last_wake_timeout_info != NULL) {
3216 s_last_wake_timeout_info->userParam = (void *)1;
3217 }
3218
3219 s_last_wake_timeout_info
3220 = internalRequestTimedCallback(wakeTimeoutCallback, NULL,
3221 &TIMEVAL_WAKE_TIMEOUT);
3222 }
3223
3224 // Normal exit
3225 return;
3226
3227error_exit:
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08003228 if (shouldScheduleTimeout) {
3229 releaseWakeLock();
3230 }
3231}
3232
Wink Saville7f856802009-06-09 10:23:37 -07003233/** FIXME generalize this if you track UserCAllbackInfo, clear it
3234 when the callback occurs
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08003235*/
3236static UserCallbackInfo *
Wink Saville7f856802009-06-09 10:23:37 -07003237internalRequestTimedCallback (RIL_TimedCallback callback, void *param,
Dianne Hackborn0d9f0c02010-06-25 16:50:46 -07003238 const struct timeval *relativeTime)
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08003239{
3240 struct timeval myRelativeTime;
3241 UserCallbackInfo *p_info;
3242
3243 p_info = (UserCallbackInfo *) malloc (sizeof(UserCallbackInfo));
3244
Wink Saville7f856802009-06-09 10:23:37 -07003245 p_info->p_callback = callback;
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08003246 p_info->userParam = param;
Dianne Hackborn0d9f0c02010-06-25 16:50:46 -07003247
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08003248 if (relativeTime == NULL) {
3249 /* treat null parameter as a 0 relative time */
3250 memset (&myRelativeTime, 0, sizeof(myRelativeTime));
3251 } else {
3252 /* FIXME I think event_add's tv param is really const anyway */
3253 memcpy (&myRelativeTime, relativeTime, sizeof(myRelativeTime));
3254 }
3255
3256 ril_event_set(&(p_info->event), -1, false, userTimerCallback, p_info);
3257
3258 ril_timer_add(&(p_info->event), &myRelativeTime);
3259
3260 triggerEvLoop();
3261 return p_info;
3262}
3263
Naveen Kalla7edd07c2010-06-21 18:54:47 -07003264
3265extern "C" void
Dianne Hackborn0d9f0c02010-06-25 16:50:46 -07003266RIL_requestTimedCallback (RIL_TimedCallback callback, void *param,
3267 const struct timeval *relativeTime) {
3268 internalRequestTimedCallback (callback, param, relativeTime);
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08003269}
3270
3271const char *
Wink Savillef4c4d362009-04-02 01:37:03 -07003272failCauseToString(RIL_Errno e) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08003273 switch(e) {
3274 case RIL_E_SUCCESS: return "E_SUCCESS";
3275 case RIL_E_RADIO_NOT_AVAILABLE: return "E_RAIDO_NOT_AVAILABLE";
3276 case RIL_E_GENERIC_FAILURE: return "E_GENERIC_FAILURE";
3277 case RIL_E_PASSWORD_INCORRECT: return "E_PASSWORD_INCORRECT";
3278 case RIL_E_SIM_PIN2: return "E_SIM_PIN2";
3279 case RIL_E_SIM_PUK2: return "E_SIM_PUK2";
3280 case RIL_E_REQUEST_NOT_SUPPORTED: return "E_REQUEST_NOT_SUPPORTED";
3281 case RIL_E_CANCELLED: return "E_CANCELLED";
3282 case RIL_E_OP_NOT_ALLOWED_DURING_VOICE_CALL: return "E_OP_NOT_ALLOWED_DURING_VOICE_CALL";
3283 case RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW: return "E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW";
3284 case RIL_E_SMS_SEND_FAIL_RETRY: return "E_SMS_SEND_FAIL_RETRY";
Wink Savillef4c4d362009-04-02 01:37:03 -07003285 case RIL_E_SIM_ABSENT:return "E_SIM_ABSENT";
John Wang75534472010-04-20 15:11:42 -07003286 case RIL_E_ILLEGAL_SIM_OR_ME:return "E_ILLEGAL_SIM_OR_ME";
Wink Saville7f856802009-06-09 10:23:37 -07003287#ifdef FEATURE_MULTIMODE_ANDROID
Wink Savillef4c4d362009-04-02 01:37:03 -07003288 case RIL_E_SUBSCRIPTION_NOT_AVAILABLE:return "E_SUBSCRIPTION_NOT_AVAILABLE";
3289 case RIL_E_MODE_NOT_SUPPORTED:return "E_MODE_NOT_SUPPORTED";
3290#endif
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08003291 default: return "<unknown error>";
3292 }
3293}
3294
3295const char *
Wink Savillef4c4d362009-04-02 01:37:03 -07003296radioStateToString(RIL_RadioState s) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08003297 switch(s) {
3298 case RADIO_STATE_OFF: return "RADIO_OFF";
3299 case RADIO_STATE_UNAVAILABLE: return "RADIO_UNAVAILABLE";
3300 case RADIO_STATE_SIM_NOT_READY: return "RADIO_SIM_NOT_READY";
3301 case RADIO_STATE_SIM_LOCKED_OR_ABSENT: return "RADIO_SIM_LOCKED_OR_ABSENT";
3302 case RADIO_STATE_SIM_READY: return "RADIO_SIM_READY";
Wink Savillef4c4d362009-04-02 01:37:03 -07003303 case RADIO_STATE_RUIM_NOT_READY:return"RADIO_RUIM_NOT_READY";
3304 case RADIO_STATE_RUIM_READY:return"RADIO_RUIM_READY";
3305 case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:return"RADIO_RUIM_LOCKED_OR_ABSENT";
3306 case RADIO_STATE_NV_NOT_READY:return"RADIO_NV_NOT_READY";
3307 case RADIO_STATE_NV_READY:return"RADIO_NV_READY";
Naveen Kalla2bc78d62011-12-07 16:22:53 -08003308 case RADIO_STATE_ON:return"RADIO_ON";
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08003309 default: return "<unknown state>";
3310 }
3311}
3312
3313const char *
Wink Savillef4c4d362009-04-02 01:37:03 -07003314callStateToString(RIL_CallState s) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08003315 switch(s) {
3316 case RIL_CALL_ACTIVE : return "ACTIVE";
3317 case RIL_CALL_HOLDING: return "HOLDING";
3318 case RIL_CALL_DIALING: return "DIALING";
3319 case RIL_CALL_ALERTING: return "ALERTING";
3320 case RIL_CALL_INCOMING: return "INCOMING";
3321 case RIL_CALL_WAITING: return "WAITING";
3322 default: return "<unknown state>";
3323 }
3324}
3325
3326const char *
Wink Savillef4c4d362009-04-02 01:37:03 -07003327requestToString(int request) {
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08003328/*
3329 cat libs/telephony/ril_commands.h \
3330 | egrep "^ *{RIL_" \
3331 | sed -re 's/\{RIL_([^,]+),[^,]+,([^}]+).+/case RIL_\1: return "\1";/'
3332
3333
3334 cat libs/telephony/ril_unsol_commands.h \
3335 | egrep "^ *{RIL_" \
3336 | sed -re 's/\{RIL_([^,]+),([^}]+).+/case RIL_\1: return "\1";/'
3337
3338*/
3339 switch(request) {
3340 case RIL_REQUEST_GET_SIM_STATUS: return "GET_SIM_STATUS";
3341 case RIL_REQUEST_ENTER_SIM_PIN: return "ENTER_SIM_PIN";
3342 case RIL_REQUEST_ENTER_SIM_PUK: return "ENTER_SIM_PUK";
3343 case RIL_REQUEST_ENTER_SIM_PIN2: return "ENTER_SIM_PIN2";
3344 case RIL_REQUEST_ENTER_SIM_PUK2: return "ENTER_SIM_PUK2";
3345 case RIL_REQUEST_CHANGE_SIM_PIN: return "CHANGE_SIM_PIN";
3346 case RIL_REQUEST_CHANGE_SIM_PIN2: return "CHANGE_SIM_PIN2";
3347 case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: return "ENTER_NETWORK_DEPERSONALIZATION";
3348 case RIL_REQUEST_GET_CURRENT_CALLS: return "GET_CURRENT_CALLS";
3349 case RIL_REQUEST_DIAL: return "DIAL";
3350 case RIL_REQUEST_GET_IMSI: return "GET_IMSI";
3351 case RIL_REQUEST_HANGUP: return "HANGUP";
3352 case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: return "HANGUP_WAITING_OR_BACKGROUND";
3353 case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: return "HANGUP_FOREGROUND_RESUME_BACKGROUND";
3354 case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: return "SWITCH_WAITING_OR_HOLDING_AND_ACTIVE";
3355 case RIL_REQUEST_CONFERENCE: return "CONFERENCE";
3356 case RIL_REQUEST_UDUB: return "UDUB";
3357 case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: return "LAST_CALL_FAIL_CAUSE";
3358 case RIL_REQUEST_SIGNAL_STRENGTH: return "SIGNAL_STRENGTH";
Wink Savillec0114b32011-02-18 10:14:07 -08003359 case RIL_REQUEST_VOICE_REGISTRATION_STATE: return "VOICE_REGISTRATION_STATE";
3360 case RIL_REQUEST_DATA_REGISTRATION_STATE: return "DATA_REGISTRATION_STATE";
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08003361 case RIL_REQUEST_OPERATOR: return "OPERATOR";
3362 case RIL_REQUEST_RADIO_POWER: return "RADIO_POWER";
3363 case RIL_REQUEST_DTMF: return "DTMF";
3364 case RIL_REQUEST_SEND_SMS: return "SEND_SMS";
3365 case RIL_REQUEST_SEND_SMS_EXPECT_MORE: return "SEND_SMS_EXPECT_MORE";
Wink Savillef4c4d362009-04-02 01:37:03 -07003366 case RIL_REQUEST_SETUP_DATA_CALL: return "SETUP_DATA_CALL";
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08003367 case RIL_REQUEST_SIM_IO: return "SIM_IO";
3368 case RIL_REQUEST_SEND_USSD: return "SEND_USSD";
3369 case RIL_REQUEST_CANCEL_USSD: return "CANCEL_USSD";
3370 case RIL_REQUEST_GET_CLIR: return "GET_CLIR";
3371 case RIL_REQUEST_SET_CLIR: return "SET_CLIR";
3372 case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: return "QUERY_CALL_FORWARD_STATUS";
3373 case RIL_REQUEST_SET_CALL_FORWARD: return "SET_CALL_FORWARD";
3374 case RIL_REQUEST_QUERY_CALL_WAITING: return "QUERY_CALL_WAITING";
3375 case RIL_REQUEST_SET_CALL_WAITING: return "SET_CALL_WAITING";
3376 case RIL_REQUEST_SMS_ACKNOWLEDGE: return "SMS_ACKNOWLEDGE";
3377 case RIL_REQUEST_GET_IMEI: return "GET_IMEI";
3378 case RIL_REQUEST_GET_IMEISV: return "GET_IMEISV";
3379 case RIL_REQUEST_ANSWER: return "ANSWER";
Wink Savillef4c4d362009-04-02 01:37:03 -07003380 case RIL_REQUEST_DEACTIVATE_DATA_CALL: return "DEACTIVATE_DATA_CALL";
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08003381 case RIL_REQUEST_QUERY_FACILITY_LOCK: return "QUERY_FACILITY_LOCK";
3382 case RIL_REQUEST_SET_FACILITY_LOCK: return "SET_FACILITY_LOCK";
3383 case RIL_REQUEST_CHANGE_BARRING_PASSWORD: return "CHANGE_BARRING_PASSWORD";
3384 case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: return "QUERY_NETWORK_SELECTION_MODE";
3385 case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: return "SET_NETWORK_SELECTION_AUTOMATIC";
3386 case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: return "SET_NETWORK_SELECTION_MANUAL";
3387 case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : return "QUERY_AVAILABLE_NETWORKS ";
3388 case RIL_REQUEST_DTMF_START: return "DTMF_START";
3389 case RIL_REQUEST_DTMF_STOP: return "DTMF_STOP";
3390 case RIL_REQUEST_BASEBAND_VERSION: return "BASEBAND_VERSION";
3391 case RIL_REQUEST_SEPARATE_CONNECTION: return "SEPARATE_CONNECTION";
3392 case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: return "SET_PREFERRED_NETWORK_TYPE";
3393 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: return "GET_PREFERRED_NETWORK_TYPE";
3394 case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: return "GET_NEIGHBORING_CELL_IDS";
3395 case RIL_REQUEST_SET_MUTE: return "SET_MUTE";
3396 case RIL_REQUEST_GET_MUTE: return "GET_MUTE";
3397 case RIL_REQUEST_QUERY_CLIP: return "QUERY_CLIP";
Wink Savillef4c4d362009-04-02 01:37:03 -07003398 case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: return "LAST_DATA_CALL_FAIL_CAUSE";
3399 case RIL_REQUEST_DATA_CALL_LIST: return "DATA_CALL_LIST";
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08003400 case RIL_REQUEST_RESET_RADIO: return "RESET_RADIO";
3401 case RIL_REQUEST_OEM_HOOK_RAW: return "OEM_HOOK_RAW";
3402 case RIL_REQUEST_OEM_HOOK_STRINGS: return "OEM_HOOK_STRINGS";
Wink Savillef4c4d362009-04-02 01:37:03 -07003403 case RIL_REQUEST_SET_BAND_MODE: return "SET_BAND_MODE";
3404 case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: return "QUERY_AVAILABLE_BAND_MODE";
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08003405 case RIL_REQUEST_STK_GET_PROFILE: return "STK_GET_PROFILE";
3406 case RIL_REQUEST_STK_SET_PROFILE: return "STK_SET_PROFILE";
3407 case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: return "STK_SEND_ENVELOPE_COMMAND";
3408 case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: return "STK_SEND_TERMINAL_RESPONSE";
3409 case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: return "STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM";
3410 case RIL_REQUEST_SCREEN_STATE: return "SCREEN_STATE";
3411 case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: return "EXPLICIT_CALL_TRANSFER";
3412 case RIL_REQUEST_SET_LOCATION_UPDATES: return "SET_LOCATION_UPDATES";
Wink Savillec0114b32011-02-18 10:14:07 -08003413 case RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE:return"CDMA_SET_SUBSCRIPTION_SOURCE";
Wink Savillef4c4d362009-04-02 01:37:03 -07003414 case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE:return"CDMA_SET_ROAMING_PREFERENCE";
3415 case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE:return"CDMA_QUERY_ROAMING_PREFERENCE";
3416 case RIL_REQUEST_SET_TTY_MODE:return"SET_TTY_MODE";
3417 case RIL_REQUEST_QUERY_TTY_MODE:return"QUERY_TTY_MODE";
3418 case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE";
3419 case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE";
3420 case RIL_REQUEST_CDMA_FLASH:return"CDMA_FLASH";
3421 case RIL_REQUEST_CDMA_BURST_DTMF:return"CDMA_BURST_DTMF";
3422 case RIL_REQUEST_CDMA_SEND_SMS:return"CDMA_SEND_SMS";
3423 case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE:return"CDMA_SMS_ACKNOWLEDGE";
Wink Savillea592eeb2009-05-22 13:26:36 -07003424 case RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG:return"GSM_GET_BROADCAST_SMS_CONFIG";
3425 case RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG:return"GSM_SET_BROADCAST_SMS_CONFIG";
3426 case RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG:return "CDMA_GET_BROADCAST_SMS_CONFIG";
3427 case RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG:return "CDMA_SET_BROADCAST_SMS_CONFIG";
3428 case RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION:return "CDMA_SMS_BROADCAST_ACTIVATION";
Naveen Kalla03c1edf2009-09-23 11:18:35 -07003429 case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: return"CDMA_VALIDATE_AND_WRITE_AKEY";
Wink Savillef4c4d362009-04-02 01:37:03 -07003430 case RIL_REQUEST_CDMA_SUBSCRIPTION: return"CDMA_SUBSCRIPTION";
3431 case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: return "CDMA_WRITE_SMS_TO_RUIM";
3432 case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: return "CDMA_DELETE_SMS_ON_RUIM";
3433 case RIL_REQUEST_DEVICE_IDENTITY: return "DEVICE_IDENTITY";
jsh000a9fe2009-05-11 14:52:35 -07003434 case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: return "EXIT_EMERGENCY_CALLBACK_MODE";
3435 case RIL_REQUEST_GET_SMSC_ADDRESS: return "GET_SMSC_ADDRESS";
3436 case RIL_REQUEST_SET_SMSC_ADDRESS: return "SET_SMSC_ADDRESS";
jsh09a68ba2009-06-10 11:56:38 -07003437 case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: return "REPORT_SMS_MEMORY_STATUS";
jsh563fd722010-06-08 16:52:24 -07003438 case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: return "REPORT_STK_SERVICE_IS_RUNNING";
Wink Savillec0114b32011-02-18 10:14:07 -08003439 case RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE: return "CDMA_GET_SUBSCRIPTION_SOURCE";
Jake Hambyfa8d5842011-08-19 16:22:18 -07003440 case RIL_REQUEST_ISIM_AUTHENTICATION: return "ISIM_AUTHENTICATION";
Jake Hamby300105d2011-09-26 01:01:44 -07003441 case RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU: return "RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU";
3442 case RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS: return "RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS";
Naveen Kalla2bc78d62011-12-07 16:22:53 -08003443 case RIL_REQUEST_VOICE_RADIO_TECH: return "VOICE_RADIO_TECH";
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08003444 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return "UNSOL_RESPONSE_RADIO_STATE_CHANGED";
3445 case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return "UNSOL_RESPONSE_CALL_STATE_CHANGED";
Wink Savillec0114b32011-02-18 10:14:07 -08003446 case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: return "UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED";
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08003447 case RIL_UNSOL_RESPONSE_NEW_SMS: return "UNSOL_RESPONSE_NEW_SMS";
3448 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: return "UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT";
3449 case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: return "UNSOL_RESPONSE_NEW_SMS_ON_SIM";
3450 case RIL_UNSOL_ON_USSD: return "UNSOL_ON_USSD";
3451 case RIL_UNSOL_ON_USSD_REQUEST: return "UNSOL_ON_USSD_REQUEST(obsolete)";
3452 case RIL_UNSOL_NITZ_TIME_RECEIVED: return "UNSOL_NITZ_TIME_RECEIVED";
3453 case RIL_UNSOL_SIGNAL_STRENGTH: return "UNSOL_SIGNAL_STRENGTH";
3454 case RIL_UNSOL_STK_SESSION_END: return "UNSOL_STK_SESSION_END";
3455 case RIL_UNSOL_STK_PROACTIVE_COMMAND: return "UNSOL_STK_PROACTIVE_COMMAND";
3456 case RIL_UNSOL_STK_EVENT_NOTIFY: return "UNSOL_STK_EVENT_NOTIFY";
3457 case RIL_UNSOL_STK_CALL_SETUP: return "UNSOL_STK_CALL_SETUP";
3458 case RIL_UNSOL_SIM_SMS_STORAGE_FULL: return "UNSOL_SIM_SMS_STORAGE_FUL";
3459 case RIL_UNSOL_SIM_REFRESH: return "UNSOL_SIM_REFRESH";
Wink Savillef4c4d362009-04-02 01:37:03 -07003460 case RIL_UNSOL_DATA_CALL_LIST_CHANGED: return "UNSOL_DATA_CALL_LIST_CHANGED";
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08003461 case RIL_UNSOL_CALL_RING: return "UNSOL_CALL_RING";
Wink Savillef4c4d362009-04-02 01:37:03 -07003462 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: return "UNSOL_RESPONSE_SIM_STATUS_CHANGED";
3463 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: return "UNSOL_NEW_CDMA_SMS";
3464 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: return "UNSOL_NEW_BROADCAST_SMS";
3465 case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: return "UNSOL_CDMA_RUIM_SMS_STORAGE_FULL";
Wink Saville3d54e742009-05-18 18:00:44 -07003466 case RIL_UNSOL_RESTRICTED_STATE_CHANGED: return "UNSOL_RESTRICTED_STATE_CHANGED";
3467 case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: return "UNSOL_ENTER_EMERGENCY_CALLBACK_MODE";
3468 case RIL_UNSOL_CDMA_CALL_WAITING: return "UNSOL_CDMA_CALL_WAITING";
3469 case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: return "UNSOL_CDMA_OTA_PROVISION_STATUS";
3470 case RIL_UNSOL_CDMA_INFO_REC: return "UNSOL_CDMA_INFO_REC";
Jaikumar Ganeshaf6ecbf2009-04-29 13:27:51 -07003471 case RIL_UNSOL_OEM_HOOK_RAW: return "UNSOL_OEM_HOOK_RAW";
John Wang5d621da2009-09-18 17:17:48 -07003472 case RIL_UNSOL_RINGBACK_TONE: return "UNSOL_RINGBACK_TONE";
John Wang5909cf82010-01-29 00:18:54 -08003473 case RIL_UNSOL_RESEND_INCALL_MUTE: return "UNSOL_RESEND_INCALL_MUTE";
Wink Savilleee274582011-04-16 15:05:49 -07003474 case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: return "UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED";
Wink Savillec0114b32011-02-18 10:14:07 -08003475 case RIL_UNSOL_CDMA_PRL_CHANGED: return "UNSOL_CDMA_PRL_CHANGED";
3476 case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: return "UNSOL_EXIT_EMERGENCY_CALLBACK_MODE";
Wink Saville5b9df332011-04-06 16:24:21 -07003477 case RIL_UNSOL_RIL_CONNECTED: return "UNSOL_RIL_CONNECTED";
Naveen Kalla2bc78d62011-12-07 16:22:53 -08003478 case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED: return "UNSOL_VOICE_RADIO_TECH_CHANGED";
The Android Open Source Project00f06fc2009-03-03 19:32:15 -08003479 default: return "<unknown request>";
3480 }
3481}
3482
3483} /* namespace android */