blob: 0bf1c6e9a75479e29c3c789f0500c99aff4fe5b8 [file] [log] [blame]
lh7b0674a2022-01-10 00:34:35 -08001/*
2**
3** Copyright 2006, The Android Open Source Project
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9** http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17#include<sys/types.h>
18#include<sys/socket.h>
19#include<unistd.h>
20#include<netinet/in.h>
21#include<arpa/inet.h>
22#include<netdb.h>
23#include<signal.h>
24#include <log/log.h>
25#include <hardware_legacy/power.h>
26#include <vendor-ril/telephony/ril.h>
27#include <telephony/ril_cdma_sms.h>
28#include <cutils/jstring.h>
29#include <telephony/record_stream.h>
30#include <utils/SystemClock.h>
31#include <pthread.h>
32#include <binder/Parcel.h>
33#include <cutils/jstring.h>
34#include <sys/types.h>
35#include <limits.h>
36#include <pwd.h>
37#include <stdio.h>
38#include <stdlib.h>
39#include <stdarg.h>
40#include <string.h>
41#include <unistd.h>
42#include <fcntl.h>
43#include <time.h>
44#include <errno.h>
45#include <assert.h>
46#include <ctype.h>
47#include <alloca.h>
48#include <sys/un.h>
49#include <assert.h>
50#include <netinet/in.h>
51#include <atomic>
52
53#include "utils/String8.h"
54#include "ss.h"
55#include "sim.h"
56#include "common.h"
57#include "cc.h"
58#include "network.h"
59#include "stk.h"
60#include "utils.h"
61
62#include "atci/ATCI.h"
63#include "data/data.h"
64#include "data/data_gdbus.h"
65#include "ecall/eCall.h"
66#include "em/em.h"
67#include "sms/sms.h"
68#include "sms/cdma/sms_pdu_cdma.h"
69#include "stateManager/stateManager.h"
70#include "Phone_utils.h"
71#include "utils.h"
72#include "Radio_capability_switch_util.h"
73/*Warren add for t800 RIL service 2021_12_10 start*/
74#include <sys/epoll.h>
75#include "lynq_interface.h"
76/*Warren add for t800 RIL service 2021_12_10 end*/
77
78#define LOG_TAG "DEMO_RIL"
79
80
81extern void ARspRequest (int request, RIL_SOCKET_ID socket_id);
82extern void responseDispatch();
83
84namespace android {
85extern "C" void
86RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responselen);
87
88#define SERVER_PORT 8000
89#define BUFFER_SIZE 8192
90#define MAX_ARGS 101
91#define BLOCK_LOCK() pthread_mutex_lock(&s_BlockMutex)
92#define BLOCK_UNLOCK() pthread_mutex_unlock(&s_BlockMutex)
93#define BLOCK_WAIT(a) pthread_cond_timedwait(&s_BlockCond, &s_BlockMutex,(a))
94#define BLOCK_WAKEUP() pthread_cond_broadcast(&s_BlockCond)
95#define SPECIA_BLOCK_LOCK() pthread_mutex_lock(&s_SpecialBlock)
96#define SPECIA_BLOCK_UNLOCK() pthread_mutex_unlock(&s_SpecialBlock)
97#define SPECIA_BLOCK_WAIT(a) pthread_cond_timedwait(&s_SpeciaBlockCond, &s_SpecialBlock,(a))
98#define SPECIA_BLOCK_WAKEUP() pthread_cond_signal(&s_SpeciaBlockCond)
99
100static int s_started = 0;
101static int s_responseDispatch = 0;
102static int s_isConnected[2] = {0,0}; //connect to modem;
103static pthread_mutex_t s_InitMutex = PTHREAD_MUTEX_INITIALIZER;
104static pthread_cond_t s_InitCond = PTHREAD_COND_INITIALIZER;
105
106static pthread_mutex_t s_BlockMutex = PTHREAD_MUTEX_INITIALIZER;
107static pthread_cond_t s_BlockCond = PTHREAD_COND_INITIALIZER;
108static pthread_mutex_t s_SpecialBlock = PTHREAD_MUTEX_INITIALIZER;
109static pthread_cond_t s_SpeciaBlockCond = PTHREAD_COND_INITIALIZER;
110
111int requestOneByOne = 0;
112int server_socket_fd;
113int enable_syslog = 1;
114int enable_bt_resp = 0;
115int wakeup_token = -1;
116struct sockaddr_in client_addr;
117
118#define ANDROID_WAKE_LOCK_NAME "radio-interface"
119
120// Basically: memset buffers that the client library
121// shouldn't be using anymore in an attempt to find
122// memory usage issues sooner.
123#define MEMSET_FREED 1
124
125#define NUM_ELEMS(a) (sizeof (a) / sizeof (a)[0])
126
127#define MIN(a,b) ((a)<(b) ? (a) : (b))
128
129/* Constants for response types */
130#define RESPONSE_SOLICITED 0
131#define RESPONSE_UNSOLICITED 1
132
133/* Negative values for private RIL errno's */
134#define RIL_ERRNO_INVALID_RESPONSE -1
135
136// request, response, and unsolicited msg print macro
137#define PRINTBUF_SIZE 8096
138
139// Enable verbose logging
140#define VDBG 0
141
142// Enable RILC log
143#define RILC_LOG 1
144/*Warren add for t800 RIL service 2021_12_10 start*/
145#define LYNQ_SOCKET_ENVNT_FD_MAX 100
146#define LYNQ_SERVICE_PORT 8088
147#define LYNQ_BRODCAST_PORT 8086
148#define LYNQ_SOCKET_BUFFER (1024*8+sizeof(int)*3+10)
149//int LYNQ_RIL_respSocket(Parcel &p,RIL_Token t);
150//int LYNQ_RIL_urcBroadcast(Parcel &p);
151
152int lynq_urc_socket_fd = 0;
153struct sockaddr_in urc_broadcast_addr;
154/*Warren add for t800 RIL service 2021_12_10 end*/
155
156
157#if RILC_LOG
158 static char printBuf[PRINTBUF_SIZE];
159 static char tempPrintBuf[PRINTBUF_SIZE];
160 #define startRequest sprintf(printBuf, "(")
161 #define closeRequest sprintf(printBuf, "%s)", printBuf)
162 #define printRequest(token, req) if(enable_syslog) { \
163 RLOGD("[%x]> %s %s", token, requestToString(req), printBuf);} else {\
164 printf("[%x]> %s %s\n", token, requestToString(req), printBuf);}
165
166 #define startResponse sprintf(printBuf, "%s {", printBuf)
167 #define closeResponse sprintf(printBuf, "%s}", printBuf)
168 #define printResponse if(enable_syslog) { \
169 RLOGD("%s", printBuf); } else { \
170 printf("%s\n", printBuf);}
171
172 #define clearPrintBuf printBuf[0] = 0
173 #define removeLastChar printBuf[strlen(printBuf)-1] = 0
174 #define appendPrintBuf(x...) snprintf(tempPrintBuf, PRINTBUF_SIZE, x); \
175 snprintf(printBuf, PRINTBUF_SIZE, "%s", tempPrintBuf)
176#endif
177
178enum WakeType {DONT_WAKE, WAKE_PARTIAL};
179
180#if 0
181typedef struct {
182 int requestNumber;
183 void (*dispatchFunction) (Parcel &p, struct RequestInfo *pRI);
184 int(*responseFunction) (Parcel &p, void *response, size_t responselen);
185} CommandInfo;
186#endif
187
188typedef struct {
189 int requestNumber;
190 int (*responseFunction) (Parcel &p, void *response, size_t responselen);
191 WakeType wakeType;
192} UnsolResponseInfo;
193
194#if 0
195typedef struct RequestInfo {
196 int32_t token; //this is not RIL_Token
197 CommandInfo *pCI;
198 struct RequestInfo *p_next;
199 char cancelled;
200 char local; // responses to local commands do not go back to command process
201 RIL_SOCKET_ID socket_id;
202} RequestInfo;
203
204typedef struct UserCallbackInfo {
205 RIL_TimedCallback p_callback;
206 void *userParam;
207 struct ril_event event;
208 struct UserCallbackInfo *p_next;
209} UserCallbackInfo;
210#endif
211
212const char *requestToString(int request);
213const char * failCauseToString(RIL_Errno);
214const char * callStateToString(RIL_CallState);
215
216RIL_RadioFunctions s_callbacks = {0, NULL, NULL, NULL, NULL, NULL};
217int s_registerCalled = 0;
218
219static pthread_t s_tid_dispatch;
220
221static const struct timeval TIMEVAL_WAKE_TIMEOUT = {1,0};
222
223#if EM_MODE_SUPPORT
224netwokInfoNotify networkCb = NULL;
225atCmdResponse atResponseCb = NULL;
226#endif
227
228static pthread_mutex_t s_startupMutex = PTHREAD_MUTEX_INITIALIZER;
229static pthread_cond_t s_startupCond = PTHREAD_COND_INITIALIZER;
230static void *s_lastNITZTimeData = NULL;
231static size_t s_lastNITZTimeDataSize;
232
233/*******************************************************************/
234static int sendResponse (Parcel &p, RIL_SOCKET_ID socket_id);
235
236static void dispatchVoid (Parcel& p, RequestInfo *pRI);
237static void dispatchString (Parcel& p, RequestInfo *pRI);
238static void dispatchStrings (Parcel& p, RequestInfo *pRI);
239static void dispatchInts (Parcel& p, RequestInfo *pRI);
240static void dispatchDial (Parcel& p, RequestInfo *pRI);
241static void dispatchSIM_IO (Parcel& p, RequestInfo *pRI);
242static void dispatchSIM_APDU (Parcel& p, RequestInfo *pRI);
243static void dispatchCallForward(Parcel& p, RequestInfo *pRI);
244static void dispatchRaw(Parcel& p, RequestInfo *pRI);
245static void dispatchSmsWrite (Parcel &p, RequestInfo *pRI);
246static void dispatchDataCall (Parcel& p, RequestInfo *pRI);
247static void dispatchSetInitialAttachApn (Parcel& p, RequestInfo *pRI);;
248static void dispatchCdmaSms(Parcel &p, RequestInfo *pRI);
249static void dispatchImsSms(Parcel &p, RequestInfo *pRI);
250static void dispatchImsCdmaSms(Parcel &p, RequestInfo *pRI, uint8_t retry, int32_t messageRef);
251static void dispatchImsGsmSms(Parcel &p, RequestInfo *pRI, uint8_t retry, int32_t messageRef);
252static void dispatchCdmaSmsAck(Parcel &p, RequestInfo *pRI);
253static void dispatchGsmBrSmsCnf(Parcel &p, RequestInfo *pRI);
254static void dispatchCdmaBrSmsCnf(Parcel &p, RequestInfo *pRI);
255static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI);
256static void dispatchNVReadItem(Parcel &p, RequestInfo *pRI);
257static void dispatchNVWriteItem(Parcel &p, RequestInfo *pRI);
258static void dispatchUiccSubscripton(Parcel &p, RequestInfo *pRI);
259static void dispatchSimAuthentication(Parcel &p, RequestInfo *pRI);
260static void dispatchDataProfile(Parcel &p, RequestInfo *pRI);
261static void dispatchRadioCapability(Parcel &p, RequestInfo *pRI);
262static int responseInts(Parcel &p, void *response, size_t responselen);
263static int responseFailCause(Parcel &p, void *response, size_t responselen);
264static int responseStrings(Parcel &p, void *response, size_t responselen);
265static int responseString(Parcel &p, void *response, size_t responselen);
266static int responseVoid(Parcel &p, void *response, size_t responselen);
267static int responseCallList(Parcel &p, void *response, size_t responselen);
268static int responseSMS(Parcel &p, void *response, size_t responselen);
269static int responseSIM_IO(Parcel &p, void *response, size_t responselen);
270static int responseCallForwards(Parcel &p, void *response, size_t responselen);
271static int responseDataCallList(Parcel &p, void *response, size_t responselen);
272static int responseSetupDataCall(Parcel &p, void *response, size_t responselen);
273static int responseRaw(Parcel &p, void *response, size_t responselen);
274static int responseSsn(Parcel &p, void *response, size_t responselen);
275static int responseSimStatus(Parcel &p, void *response, size_t responselen);
276static int responseGsmBrSmsCnf(Parcel &p, void *response, size_t responselen);
277static int responseCdmaBrSmsCnf(Parcel &p, void *response, size_t responselen);
278static int responseCdmaSms(Parcel &p, void *response, size_t responselen);
279static int responseCellList(Parcel &p, void *response, size_t responselen);
280static int responseCdmaInformationRecords(Parcel &p,void *response, size_t responselen);
281static int responseRilSignalStrength(Parcel &p,void *response, size_t responselen);
282static int responseCallRing(Parcel &p, void *response, size_t responselen);
283static int responseCdmaSignalInfoRecord(Parcel &p,void *response, size_t responselen);
284static int responseCdmaCallWaiting(Parcel &p,void *response, size_t responselen);
285static int responseSimRefresh(Parcel &p, void *response, size_t responselen);
286static int responseCellInfoList(Parcel &p, void *response, size_t responselen);
287static int responseHardwareConfig(Parcel &p, void *response, size_t responselen);
288static int responseDcRtInfo(Parcel &p, void *response, size_t responselen);
289static int responseRadioCapability(Parcel &p, void *response, size_t responselen);
290static int responseSSData(Parcel &p, void *response, size_t responselen);
291static int responseLceStatus(Parcel &p, void *response, size_t responselen);
292static int responseLceData(Parcel &p, void *response, size_t responselen);
293static int responseActivityData(Parcel &p, void *response, size_t responselen);
294static int responseSmsSimMemStatus(Parcel &p, void *response, size_t responselen);
295#ifdef ECALL_SUPPORT
296static void dispatchFastEcall (Parcel& p, RequestInfo *pRI);
297static int responseEcallStatus(Parcel &p, void *response, size_t responselen);
298static void dispatchSetMsd (Parcel &p, RequestInfo *pRI);
299static void dispatchEcallRecord (Parcel &p, RequestInfo *pRI);
300#endif /*ECALL_SUPPORT*/
301#ifdef KEEP_ALIVE
302static void dispatchStartKeepalivePro(Parcel &p, RequestInfo *pRI);
303#endif /*KEEP_ALIVE*/
304static int decodeVoiceRadioTechnology (RIL_RadioState radioState);
305static int decodeCdmaSubscriptionSource (RIL_RadioState radioState);
306static RIL_RadioState processRadioState(RIL_RadioState newRadioState);
307
308static bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType);
309
310static int onSupports (int requestCode);
311static UnsolResponseInfo* find_mtk_unsol_command(int request);
312static int com_quit(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI);
313static int enableSyslog(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI);
314static int enableBTResponse(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI);
315static void updateIccCardState(RIL_SOCKET_ID soc_id);
316static void initCoditions();
317
318static int SendRespToClient(const void *data, size_t dataSize);
319static void speciaRequest_wakeup();
320static void speciaRequest_wait();
321void processUnsolicited (Parcel &p, int type);
322void processSolicited (Parcel &p, int type);
323
324void printInputArgs(int argc, char** argv) ;
325void initRequestInfo(RequestInfo *pRI, int request, int mode, RIL_SOCKET_ID soc_id);
326void getVoiceAndDataRegistrationState(RIL_SOCKET_ID soc_id);
327const int waitResponse(int token);
328
329#ifdef RIL_SHLIB
330#if defined(ANDROID_MULTI_SIM)
331extern "C" void RIL_onUnsolicitedResponse(int unsolResponse, const void *data,
332 size_t datalen, RIL_SOCKET_ID socket_id);
333#else
334extern "C" void RIL_onUnsolicitedResponse(int unsolResponse, const void *data,
335 size_t datalen);
336#endif
337#endif
338
339#if defined(ANDROID_MULTI_SIM)
340#define RIL_UNSOL_RESPONSE(a, b, c, d) RIL_onUnsolicitedResponse((a), (b), (c), (d))
341#define CALL_ONREQUEST(a, b, c, d, e) s_callbacks.onRequest((a), (b), (c), (d), (e))
342#define CALL_ONSTATEREQUEST(a) s_callbacks.onStateRequest(a)
343#else
344#define RIL_UNSOL_RESPONSE(a, b, c, d) RIL_onUnsolicitedResponse((a), (b), (c))
345#define CALL_ONREQUEST(a, b, c, d, e) s_callbacks.onRequest((a), (b), (c), (d))
346#define CALL_ONSTATEREQUEST(a) s_callbacks.onStateRequest()
347#endif
348
349
350/** Index == requestNumber */
351static CommandInfo s_commands[] = {
352#include "ril_commands.h"
353};
354
355static UnsolResponseInfo s_unsolResponses[] = {
356#include "ril_unsol_commands.h"
357};
358
359COMMAND commands[] = {
360#include "commands.h"
361};
362
363static CommandInfo mtk_s_command[] = {
364#include "mtk_ril_commands.h"
365};
366
367static UnsolResponseInfo s_mtk_unsolResponses[] = {
368#include "mtk_ril_unsol_commands.h"
369};
370
371char respStr[PRINTBUF_SIZE]={0};
372
373/* For older RILs that do not support new commands RIL_REQUEST_VOICE_RADIO_TECH and
374 RIL_UNSOL_VOICE_RADIO_TECH_CHANGED messages, decode the voice radio tech from
375 radio state message and store it. Every time there is a change in Radio State
376 check to see if voice radio tech changes and notify telephony
377 */
378int voiceRadioTech = -1;
379
380/* For older RILs that do not support new commands RIL_REQUEST_GET_CDMA_SUBSCRIPTION_SOURCE
381 and RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED messages, decode the subscription
382 source from radio state and store it. Every time there is a change in Radio State
383 check to see if subscription source changed and notify telephony
384 */
385int cdmaSubscriptionSource = -1;
386
387/* For older RILs that do not send RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, decode the
388 SIM/RUIM state from radio state and store it. Every time there is a change in Radio State,
389 check to see if SIM/RUIM status changed and notify telephony
390 */
391int simRuimStatus = -1;
392
393
394static char *
395strdupReadString(Parcel &p) {
396 size_t stringlen;
397 const char16_t *s16;
398
399 s16 = p.readString16Inplace(&stringlen);
400
401 return strndup16to8(s16, stringlen);
402}
403
404static status_t
405readStringFromParcelInplace(Parcel &p, char *str, size_t maxLen) {
406 size_t s16Len;
407 const char16_t *s16;
408
409 s16 = p.readString16Inplace(&s16Len);
410 if (s16 == NULL) {
411 return NO_MEMORY;
412 }
413 size_t strLen = strnlen16to8(s16, s16Len);
414 if ((strLen + 1) > maxLen) {
415 return NO_MEMORY;
416 }
417 if (strncpy16to8(str, s16, strLen) == NULL) {
418 return NO_MEMORY;
419 } else {
420 return NO_ERROR;
421 }
422}
423
424/*static*/ void writeStringToParcel(Parcel &p, const char *s) {
425 char16_t *s16;
426 size_t s16_len;
427 s16 = strdup8to16(s, &s16_len);
428 p.writeString16(s16, s16_len);
429 free(s16);
430}
431
432
433static void
434memsetString (char *s) {
435 if (s != NULL) {
436 memset (s, 0, strlen(s));
437 }
438}
439
440
441static void
442invalidCommandBlock (RequestInfo *pRI) {
443 RLOGE("invalid command block for token %d request %s",
444 pRI->token, requestToString(pRI->pCI->requestNumber));
445}
446
447/** Callee expects NULL */
448static void
449dispatchVoid (Parcel& p, RequestInfo *pRI) {
450 clearPrintBuf;
451 printRequest(pRI->token, pRI->pCI->requestNumber);
452 CALL_ONREQUEST(pRI->pCI->requestNumber, NULL, 0, pRI, pRI->socket_id);
453}
454
455/** Callee expects const char * */
456static void
457dispatchString (Parcel& p, RequestInfo *pRI) {
458 status_t status;
459 size_t datalen;
460 size_t stringlen;
461 char *string8 = NULL;
462
463 string8 = strdupReadString(p);
464
465 startRequest;
466 appendPrintBuf("%s%s", printBuf, string8);
467 closeRequest;
468 printRequest(pRI->token, pRI->pCI->requestNumber);
469
470 CALL_ONREQUEST(pRI->pCI->requestNumber, string8,
471 sizeof(char *), pRI, pRI->socket_id);
472
473#ifdef MEMSET_FREED
474 memsetString(string8);
475#endif
476
477 free(string8);
478 return;
479invalid:
480 invalidCommandBlock(pRI);
481 return;
482}
483
484/** Callee expects const char ** */
485static void
486dispatchStrings (Parcel &p, RequestInfo *pRI) {
487 int32_t countStrings;
488 status_t status;
489 size_t datalen;
490 char **pStrings;
491
492 status = p.readInt32 (&countStrings);
493
494 if (status != NO_ERROR) {
495 goto invalid;
496 }
497
498 startRequest;
499 if (countStrings == 0) {
500 // just some non-null pointer
501 pStrings = (char **)alloca(sizeof(char *));
502 datalen = 0;
503 } else if (((int)countStrings) == -1) {
504 pStrings = NULL;
505 datalen = 0;
506 } else {
507 datalen = sizeof(char *) * countStrings;
508
509 pStrings = (char **)alloca(datalen);
510
511 for (int i = 0 ; i < countStrings ; i++) {
512 pStrings[i] = strdupReadString(p);
513 appendPrintBuf("%s%s,", printBuf, pStrings[i]);
514 }
515 }
516 removeLastChar;
517 closeRequest;
518 printRequest(pRI->token, pRI->pCI->requestNumber);
519
520 CALL_ONREQUEST(pRI->pCI->requestNumber, pStrings, datalen, pRI, pRI->socket_id);
521
522 if (pStrings != NULL) {
523 for (int i = 0 ; i < countStrings ; i++) {
524#ifdef MEMSET_FREED
525 memsetString (pStrings[i]);
526#endif
527 free(pStrings[i]);
528 }
529
530#ifdef MEMSET_FREED
531 memset(pStrings, 0, datalen);
532#endif
533 }
534
535 return;
536invalid:
537 invalidCommandBlock(pRI);
538 return;
539}
540
541/** Callee expects const int * */
542static void
543dispatchInts (Parcel &p, RequestInfo *pRI) {
544 int32_t count;
545 status_t status;
546 size_t datalen;
547 int *pInts;
548
549 status = p.readInt32 (&count);
550
551 if (status != NO_ERROR || count == 0) {
552 goto invalid;
553 }
554
555 datalen = sizeof(int) * count;
556 pInts = (int *)alloca(datalen);
557
558 startRequest;
559 for (int i = 0 ; i < count ; i++) {
560 int32_t t;
561
562 status = p.readInt32(&t);
563 pInts[i] = (int)t;
564 appendPrintBuf("%s%d,", printBuf, t);
565
566 if (status != NO_ERROR) {
567 goto invalid;
568 }
569 }
570 removeLastChar;
571 closeRequest;
572 printRequest(pRI->token, pRI->pCI->requestNumber);
573
574 CALL_ONREQUEST(pRI->pCI->requestNumber, const_cast<int *>(pInts),
575 datalen, pRI, pRI->socket_id);
576
577#ifdef MEMSET_FREED
578 memset(pInts, 0, datalen);
579#endif
580
581 return;
582invalid:
583 invalidCommandBlock(pRI);
584 return;
585}
586
587
588/**
589 * Callee expects const RIL_SMS_WriteArgs *
590 * Payload is:
591 * int32_t status
592 * String pdu
593 */
594static void
595dispatchSmsWrite (Parcel &p, RequestInfo *pRI) {
596 RIL_SMS_WriteArgs args;
597 int32_t t;
598 status_t status;
599
600 RLOGD("dispatchSmsWrite");
601 memset (&args, 0, sizeof(args));
602
603 status = p.readInt32(&t);
604 args.status = (int)t;
605
606 args.pdu = strdupReadString(p);
607
608 if (status != NO_ERROR || args.pdu == NULL) {
609 goto invalid;
610 }
611
612 args.smsc = strdupReadString(p);
613
614 startRequest;
615 appendPrintBuf("%s%d,%s,smsc=%s", printBuf, args.status,
616 (char*)args.pdu, (char*)args.smsc);
617 closeRequest;
618 printRequest(pRI->token, pRI->pCI->requestNumber);
619
620 CALL_ONREQUEST(pRI->pCI->requestNumber, &args, sizeof(args), pRI, pRI->socket_id);
621
622#ifdef MEMSET_FREED
623 memsetString (args.pdu);
624#endif
625
626 free (args.pdu);
627 free (args.smsc);
628#ifdef MEMSET_FREED
629 memset(&args, 0, sizeof(args));
630#endif
631
632 return;
633invalid:
634 invalidCommandBlock(pRI);
635 return;
636}
637
638/**
639 * Callee expects const RIL_Dial *
640 * Payload is:
641 * String address
642 * int32_t clir
643 */
644static void
645dispatchDial (Parcel &p, RequestInfo *pRI) {
646 RIL_Dial dial;
647 RIL_UUS_Info uusInfo;
648 int32_t sizeOfDial;
649 int32_t t;
650 int32_t uusPresent;
651 status_t status;
652
653 RLOGD("dispatchDial");
654 memset (&dial, 0, sizeof(dial));
655
656 dial.address = strdupReadString(p);
657
658 status = p.readInt32(&t);
659 dial.clir = (int)t;
660
661 if (status != NO_ERROR || dial.address == NULL) {
662 goto invalid;
663 }
664
665 if (s_callbacks.version < 3) { // Remove when partners upgrade to version 3
666 uusPresent = 0;
667 sizeOfDial = sizeof(dial) - sizeof(RIL_UUS_Info *);
668 } else {
669 status = p.readInt32(&uusPresent);
670
671 if (status != NO_ERROR) {
672 goto invalid;
673 }
674
675 if (uusPresent == 0) {
676 dial.uusInfo = NULL;
677 } else {
678 int32_t len;
679
680 memset(&uusInfo, 0, sizeof(RIL_UUS_Info));
681
682 status = p.readInt32(&t);
683 uusInfo.uusType = (RIL_UUS_Type) t;
684
685 status = p.readInt32(&t);
686 uusInfo.uusDcs = (RIL_UUS_DCS) t;
687
688 status = p.readInt32(&len);
689 if (status != NO_ERROR) {
690 goto invalid;
691 }
692
693 // The java code writes -1 for null arrays
694 if (((int) len) == -1) {
695 uusInfo.uusData = NULL;
696 len = 0;
697 } else {
698 uusInfo.uusData = (char*) p.readInplace(len);
699 }
700
701 uusInfo.uusLength = len;
702 dial.uusInfo = &uusInfo;
703 }
704 sizeOfDial = sizeof(dial);
705 }
706
707 startRequest;
708 appendPrintBuf("%snum=%s,clir=%d", printBuf, dial.address, dial.clir);
709 if (uusPresent) {
710 appendPrintBuf("%s,uusType=%d,uusDcs=%d,uusLen=%d", printBuf,
711 dial.uusInfo->uusType, dial.uusInfo->uusDcs,
712 dial.uusInfo->uusLength);
713 }
714
715 closeRequest;
716 printRequest(pRI->token, pRI->pCI->requestNumber);
717
718 CALL_ONREQUEST(pRI->pCI->requestNumber, &dial, sizeOfDial, pRI, pRI->socket_id);
719
720#ifdef MEMSET_FREED
721 memsetString (dial.address);
722#endif
723
724 free (dial.address);
725
726#ifdef MEMSET_FREED
727 memset(&uusInfo, 0, sizeof(RIL_UUS_Info));
728 memset(&dial, 0, sizeof(dial));
729#endif
730
731 return;
732invalid:
733 invalidCommandBlock(pRI);
734 return;
735}
736
737/**
738 * Callee expects const RIL_SIM_IO *
739 * Payload is:
740 * int32_t command
741 * int32_t fileid
742 * String path
743 * int32_t p1, p2, p3
744 * String data
745 * String pin2
746 * String aidPtr
747 */
748static void
749dispatchSIM_IO (Parcel &p, RequestInfo *pRI) {
750 union RIL_SIM_IO {
751 RIL_SIM_IO_v6 v6;
752 RIL_SIM_IO_v5 v5;
753 } simIO;
754
755 int32_t t;
756 int size;
757 status_t status;
758
759#if VDBG
760 RLOGD("dispatchSIM_IO");
761#endif
762 memset (&simIO, 0, sizeof(simIO));
763
764 // note we only check status at the end
765
766 status = p.readInt32(&t);
767 simIO.v6.command = (int)t;
768
769 status = p.readInt32(&t);
770 simIO.v6.fileid = (int)t;
771
772 simIO.v6.path = strdupReadString(p);
773
774 status = p.readInt32(&t);
775 simIO.v6.p1 = (int)t;
776
777 status = p.readInt32(&t);
778 simIO.v6.p2 = (int)t;
779
780 status = p.readInt32(&t);
781 simIO.v6.p3 = (int)t;
782
783 simIO.v6.data = strdupReadString(p);
784 simIO.v6.pin2 = strdupReadString(p);
785 simIO.v6.aidPtr = strdupReadString(p);
786
787 startRequest;
788 appendPrintBuf("%scmd=0x%X,efid=0x%X,path=%s,%d,%d,%d,%s,pin2=%s,aid=%s", printBuf,
789 simIO.v6.command, simIO.v6.fileid, (char*)simIO.v6.path,
790 simIO.v6.p1, simIO.v6.p2, simIO.v6.p3,
791 (char*)simIO.v6.data, (char*)simIO.v6.pin2, simIO.v6.aidPtr);
792 closeRequest;
793 printRequest(pRI->token, pRI->pCI->requestNumber);
794
795 if (status != NO_ERROR) {
796 goto invalid;
797 }
798
799 size = (s_callbacks.version < 6) ? sizeof(simIO.v5) : sizeof(simIO.v6);
800 CALL_ONREQUEST(pRI->pCI->requestNumber, &simIO, size, pRI, pRI->socket_id);
801
802#ifdef MEMSET_FREED
803 memsetString (simIO.v6.path);
804 memsetString (simIO.v6.data);
805 memsetString (simIO.v6.pin2);
806 memsetString (simIO.v6.aidPtr);
807#endif
808
809 free (simIO.v6.path);
810 free (simIO.v6.data);
811 free (simIO.v6.pin2);
812 free (simIO.v6.aidPtr);
813
814#ifdef MEMSET_FREED
815 memset(&simIO, 0, sizeof(simIO));
816#endif
817
818 return;
819invalid:
820 invalidCommandBlock(pRI);
821 return;
822}
823
824/**
825 * Callee expects const RIL_SIM_APDU *
826 * Payload is:
827 * int32_t sessionid
828 * int32_t cla
829 * int32_t instruction
830 * int32_t p1, p2, p3
831 * String data
832 */
833static void
834dispatchSIM_APDU (Parcel &p, RequestInfo *pRI) {
835 int32_t t;
836 status_t status;
837 RIL_SIM_APDU apdu;
838
839#if VDBG
840 RLOGD("dispatchSIM_APDU");
841#endif
842 memset (&apdu, 0, sizeof(RIL_SIM_APDU));
843
844 // Note we only check status at the end. Any single failure leads to
845 // subsequent reads filing.
846 status = p.readInt32(&t);
847 apdu.sessionid = (int)t;
848
849 status = p.readInt32(&t);
850 apdu.cla = (int)t;
851
852 status = p.readInt32(&t);
853 apdu.instruction = (int)t;
854
855 status = p.readInt32(&t);
856 apdu.p1 = (int)t;
857
858 status = p.readInt32(&t);
859 apdu.p2 = (int)t;
860
861 status = p.readInt32(&t);
862 apdu.p3 = (int)t;
863
864 apdu.data = strdupReadString(p);
865
866 startRequest;
867 appendPrintBuf("%ssessionid=%d,cla=%d,ins=%d,p1=%d,p2=%d,p3=%d,data=%s",
868 printBuf, apdu.sessionid, apdu.cla, apdu.instruction, apdu.p1, apdu.p2,
869 apdu.p3, (char*)apdu.data);
870 closeRequest;
871 printRequest(pRI->token, pRI->pCI->requestNumber);
872
873 if (status != NO_ERROR) {
874 goto invalid;
875 }
876
877 CALL_ONREQUEST(pRI->pCI->requestNumber, &apdu, sizeof(RIL_SIM_APDU), pRI, pRI->socket_id);
878
879#ifdef MEMSET_FREED
880 memsetString(apdu.data);
881#endif
882 free(apdu.data);
883
884#ifdef MEMSET_FREED
885 memset(&apdu, 0, sizeof(RIL_SIM_APDU));
886#endif
887
888 return;
889invalid:
890 invalidCommandBlock(pRI);
891 return;
892}
893
894
895/**
896 * Callee expects const RIL_CallForwardInfo *
897 * Payload is:
898 * int32_t status/action
899 * int32_t reason
900 * int32_t serviceCode
901 * int32_t toa
902 * String number (0 length -> null)
903 * int32_t timeSeconds
904 */
905static void
906dispatchCallForward(Parcel &p, RequestInfo *pRI) {
907 RIL_CallForwardInfo cff;
908 int32_t t;
909 status_t status;
910
911 RLOGD("dispatchCallForward");
912 memset (&cff, 0, sizeof(cff));
913
914 // note we only check status at the end
915
916 status = p.readInt32(&t);
917 cff.status = (int)t;
918
919 status = p.readInt32(&t);
920 cff.reason = (int)t;
921
922 status = p.readInt32(&t);
923 cff.serviceClass = (int)t;
924
925 status = p.readInt32(&t);
926 cff.toa = (int)t;
927
928 cff.number = strdupReadString(p);
929
930 status = p.readInt32(&t);
931 cff.timeSeconds = (int)t;
932
933 if (status != NO_ERROR) {
934 goto invalid;
935 }
936
937 // special case: number 0-length fields is null
938
939 if (cff.number != NULL && strlen (cff.number) == 0) {
940 cff.number = NULL;
941 }
942
943 startRequest;
944 appendPrintBuf("%sstat=%d,reason=%d,serv=%d,toa=%d,%s,tout=%d", printBuf,
945 cff.status, cff.reason, cff.serviceClass, cff.toa,
946 (char*)cff.number, cff.timeSeconds);
947 closeRequest;
948 printRequest(pRI->token, pRI->pCI->requestNumber);
949
950 CALL_ONREQUEST(pRI->pCI->requestNumber, &cff, sizeof(cff), pRI, pRI->socket_id);
951
952#ifdef MEMSET_FREED
953 memsetString(cff.number);
954#endif
955
956 free (cff.number);
957
958#ifdef MEMSET_FREED
959 memset(&cff, 0, sizeof(cff));
960#endif
961
962 return;
963invalid:
964 invalidCommandBlock(pRI);
965 return;
966}
967
968
969static void
970dispatchRaw(Parcel &p, RequestInfo *pRI) {
971 int32_t len;
972 status_t status;
973 const void *data;
974
975 status = p.readInt32(&len);
976
977 if (status != NO_ERROR) {
978 goto invalid;
979 }
980
981 // The java code writes -1 for null arrays
982 if (((int)len) == -1) {
983 data = NULL;
984 len = 0;
985 }
986
987 data = p.readInplace(len);
988
989 startRequest;
990 appendPrintBuf("%sraw_size=%d", printBuf, len);
991 closeRequest;
992 printRequest(pRI->token, pRI->pCI->requestNumber);
993
994 CALL_ONREQUEST(pRI->pCI->requestNumber, const_cast<void *>(data), len, pRI, pRI->socket_id);
995
996 return;
997invalid:
998 invalidCommandBlock(pRI);
999 return;
1000}
1001
1002static status_t
1003constructCdmaSms(Parcel &p, RequestInfo *pRI, RIL_CDMA_SMS_Message& rcsm) {
1004 int32_t t;
1005 uint8_t ut;
1006 status_t status;
1007 int32_t digitCount;
1008 int digitLimit;
1009
1010 memset(&rcsm, 0, sizeof(rcsm));
1011
1012 status = p.readInt32(&t);
1013 rcsm.uTeleserviceID = (int) t;
1014
1015 status = p.read(&ut,sizeof(ut));
1016 rcsm.bIsServicePresent = (uint8_t) ut;
1017
1018 status = p.readInt32(&t);
1019 rcsm.uServicecategory = (int) t;
1020
1021 status = p.readInt32(&t);
1022 rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) t;
1023
1024 status = p.readInt32(&t);
1025 rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) t;
1026
1027 status = p.readInt32(&t);
1028 rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) t;
1029
1030 status = p.readInt32(&t);
1031 rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) t;
1032
1033 status = p.read(&ut,sizeof(ut));
1034 rcsm.sAddress.number_of_digits= (uint8_t) ut;
1035
1036 digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
1037 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
1038 status = p.read(&ut,sizeof(ut));
1039 rcsm.sAddress.digits[digitCount] = (uint8_t) ut;
1040 }
1041
1042 status = p.readInt32(&t);
1043 rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) t;
1044
1045 status = p.read(&ut,sizeof(ut));
1046 rcsm.sSubAddress.odd = (uint8_t) ut;
1047
1048 status = p.read(&ut,sizeof(ut));
1049 rcsm.sSubAddress.number_of_digits = (uint8_t) ut;
1050
1051 digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
1052 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
1053 status = p.read(&ut,sizeof(ut));
1054 rcsm.sSubAddress.digits[digitCount] = (uint8_t) ut;
1055 }
1056
1057 status = p.readInt32(&t);
1058 rcsm.uBearerDataLen = (int) t;
1059
1060 digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
1061 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
1062 status = p.read(&ut, sizeof(ut));
1063 rcsm.aBearerData[digitCount] = (uint8_t) ut;
1064 }
1065
1066 if (status != NO_ERROR) {
1067 return status;
1068 }
1069
1070 startRequest;
1071 appendPrintBuf("%suTeleserviceID=%d, bIsServicePresent=%d, uServicecategory=%d, \
1072 sAddress.digit_mode=%d, sAddress.Number_mode=%d, sAddress.number_type=%d, ",
1073 printBuf, rcsm.uTeleserviceID,rcsm.bIsServicePresent,rcsm.uServicecategory,
1074 rcsm.sAddress.digit_mode, rcsm.sAddress.number_mode,rcsm.sAddress.number_type);
1075 closeRequest;
1076
1077 printRequest(pRI->token, pRI->pCI->requestNumber);
1078
1079 return status;
1080}
1081
1082static void
1083dispatchCdmaSms(Parcel &p, RequestInfo *pRI) {
1084 RIL_CDMA_SMS_Message rcsm;
1085
1086 RLOGD("dispatchCdmaSms");
1087 if (NO_ERROR != constructCdmaSms(p, pRI, rcsm)) {
1088 goto invalid;
1089 }
1090
1091 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm),pRI, pRI->socket_id);
1092
1093#ifdef MEMSET_FREED
1094 memset(&rcsm, 0, sizeof(rcsm));
1095#endif
1096
1097 return;
1098
1099invalid:
1100 invalidCommandBlock(pRI);
1101 return;
1102}
1103
1104static void
1105dispatchImsCdmaSms(Parcel &p, RequestInfo *pRI, uint8_t retry, int32_t messageRef) {
1106 RIL_IMS_SMS_Message rism;
1107 RIL_CDMA_SMS_Message rcsm;
1108
1109 RLOGD("dispatchImsCdmaSms: retry=%d, messageRef=%d", retry, messageRef);
1110
1111 if (NO_ERROR != constructCdmaSms(p, pRI, rcsm)) {
1112 goto invalid;
1113 }
1114 memset(&rism, 0, sizeof(rism));
1115 rism.tech = RADIO_TECH_3GPP2;
1116 rism.retry = retry;
1117 rism.messageRef = messageRef;
1118 rism.message.cdmaMessage = &rcsm;
1119
1120 CALL_ONREQUEST(pRI->pCI->requestNumber, &rism,
1121 sizeof(RIL_RadioTechnologyFamily)+sizeof(uint8_t)+sizeof(int32_t)
1122 +sizeof(rcsm),pRI, pRI->socket_id);
1123
1124#ifdef MEMSET_FREED
1125 memset(&rcsm, 0, sizeof(rcsm));
1126 memset(&rism, 0, sizeof(rism));
1127#endif
1128
1129 return;
1130
1131invalid:
1132 invalidCommandBlock(pRI);
1133 return;
1134}
1135
1136static void
1137dispatchImsGsmSms(Parcel &p, RequestInfo *pRI, uint8_t retry, int32_t messageRef) {
1138 RIL_IMS_SMS_Message rism;
1139 int32_t countStrings;
1140 status_t status;
1141 size_t datalen;
1142 char **pStrings;
1143 RLOGD("dispatchImsGsmSms: retry=%d, messageRef=%d", retry, messageRef);
1144
1145 status = p.readInt32 (&countStrings);
1146
1147 if (status != NO_ERROR) {
1148 goto invalid;
1149 }
1150
1151 memset(&rism, 0, sizeof(rism));
1152 rism.tech = RADIO_TECH_3GPP;
1153 rism.retry = retry;
1154 rism.messageRef = messageRef;
1155
1156 startRequest;
1157 appendPrintBuf("%stech=%d, retry=%d, messageRef=%d, ", printBuf,
1158 (int)rism.tech, (int)rism.retry, rism.messageRef);
1159 if (countStrings == 0) {
1160 // just some non-null pointer
1161 pStrings = (char **)alloca(sizeof(char *));
1162 datalen = 0;
1163 } else if (((int)countStrings) == -1) {
1164 pStrings = NULL;
1165 datalen = 0;
1166 } else {
1167 datalen = sizeof(char *) * countStrings;
1168
1169 pStrings = (char **)alloca(datalen);
1170
1171 for (int i = 0 ; i < countStrings ; i++) {
1172 pStrings[i] = strdupReadString(p);
1173 appendPrintBuf("%s%s,", printBuf, pStrings[i]);
1174 }
1175 }
1176 removeLastChar;
1177 closeRequest;
1178 printRequest(pRI->token, pRI->pCI->requestNumber);
1179
1180 rism.message.gsmMessage = pStrings;
1181 CALL_ONREQUEST(pRI->pCI->requestNumber, &rism,
1182 sizeof(RIL_RadioTechnologyFamily)+sizeof(uint8_t)+sizeof(int32_t)
1183 +datalen, pRI, pRI->socket_id);
1184
1185 if (pStrings != NULL) {
1186 for (int i = 0 ; i < countStrings ; i++) {
1187#ifdef MEMSET_FREED
1188 memsetString (pStrings[i]);
1189#endif
1190 free(pStrings[i]);
1191 }
1192
1193#ifdef MEMSET_FREED
1194 memset(pStrings, 0, datalen);
1195#endif
1196 }
1197
1198#ifdef MEMSET_FREED
1199 memset(&rism, 0, sizeof(rism));
1200#endif
1201 return;
1202invalid:
1203 ALOGE("dispatchImsGsmSms invalid block");
1204 invalidCommandBlock(pRI);
1205 return;
1206}
1207
1208static void
1209dispatchImsSms(Parcel &p, RequestInfo *pRI) {
1210 int32_t t;
1211 status_t status = p.readInt32(&t);
1212 RIL_RadioTechnologyFamily format;
1213 uint8_t retry;
1214 int32_t messageRef;
1215
1216 RLOGD("dispatchImsSms");
1217 if (status != NO_ERROR) {
1218 goto invalid;
1219 }
1220 format = (RIL_RadioTechnologyFamily) t;
1221
1222 // read retry field
1223 status = p.read(&retry,sizeof(retry));
1224 if (status != NO_ERROR) {
1225 goto invalid;
1226 }
1227 // read messageRef field
1228 status = p.read(&messageRef,sizeof(messageRef));
1229 if (status != NO_ERROR) {
1230 goto invalid;
1231 }
1232
1233 if (RADIO_TECH_3GPP == format) {
1234 dispatchImsGsmSms(p, pRI, retry, messageRef);
1235 } else if (RADIO_TECH_3GPP2 == format) {
1236 dispatchImsCdmaSms(p, pRI, retry, messageRef);
1237 } else {
1238 ALOGE("requestImsSendSMS invalid format value =%d", format);
1239 }
1240
1241 return;
1242
1243invalid:
1244 invalidCommandBlock(pRI);
1245 return;
1246}
1247
1248static void
1249dispatchCdmaSmsAck(Parcel &p, RequestInfo *pRI) {
1250 RIL_CDMA_SMS_Ack rcsa;
1251 int32_t t;
1252 status_t status;
1253 int32_t digitCount;
1254
1255 RLOGD("dispatchCdmaSmsAck");
1256 memset(&rcsa, 0, sizeof(rcsa));
1257
1258 status = p.readInt32(&t);
1259 rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) t;
1260
1261 status = p.readInt32(&t);
1262 rcsa.uSMSCauseCode = (int) t;
1263
1264 if (status != NO_ERROR) {
1265 goto invalid;
1266 }
1267
1268 startRequest;
1269 appendPrintBuf("%suErrorClass=%d, uTLStatus=%d, ",
1270 printBuf, rcsa.uErrorClass, rcsa.uSMSCauseCode);
1271 closeRequest;
1272
1273 printRequest(pRI->token, pRI->pCI->requestNumber);
1274
1275 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa),pRI, pRI->socket_id);
1276
1277#ifdef MEMSET_FREED
1278 memset(&rcsa, 0, sizeof(rcsa));
1279#endif
1280
1281 return;
1282
1283invalid:
1284 invalidCommandBlock(pRI);
1285 return;
1286}
1287
1288static void
1289dispatchGsmBrSmsCnf(Parcel &p, RequestInfo *pRI) {
1290 int32_t t;
1291 status_t status;
1292 int32_t num;
1293
1294 status = p.readInt32(&num);
1295 if (status != NO_ERROR) {
1296 goto invalid;
1297 }
1298
1299 {
1300 RIL_GSM_BroadcastSmsConfigInfo gsmBci[num];
1301 RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num];
1302
1303 startRequest;
1304 for (int i = 0 ; i < num ; i++ ) {
1305 gsmBciPtrs[i] = &gsmBci[i];
1306
1307 status = p.readInt32(&t);
1308 gsmBci[i].fromServiceId = (int) t;
1309
1310 status = p.readInt32(&t);
1311 gsmBci[i].toServiceId = (int) t;
1312
1313 status = p.readInt32(&t);
1314 gsmBci[i].fromCodeScheme = (int) t;
1315
1316 status = p.readInt32(&t);
1317 gsmBci[i].toCodeScheme = (int) t;
1318
1319 status = p.readInt32(&t);
1320 gsmBci[i].selected = (uint8_t) t;
1321
1322 appendPrintBuf("%s [%d: fromServiceId=%d, toServiceId =%d, \
1323 fromCodeScheme=%d, toCodeScheme=%d, selected =%d]", printBuf, i,
1324 gsmBci[i].fromServiceId, gsmBci[i].toServiceId,
1325 gsmBci[i].fromCodeScheme, gsmBci[i].toCodeScheme,
1326 gsmBci[i].selected);
1327 }
1328 closeRequest;
1329
1330 if (status != NO_ERROR) {
1331 goto invalid;
1332 }
1333
1334 printRequest(pRI->token, pRI->pCI->requestNumber);
1335
1336 CALL_ONREQUEST(pRI->pCI->requestNumber,
1337 gsmBciPtrs,
1338 num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *),
1339 pRI, pRI->socket_id);
1340
1341#ifdef MEMSET_FREED
1342 memset(gsmBci, 0, num * sizeof(RIL_GSM_BroadcastSmsConfigInfo));
1343 memset(gsmBciPtrs, 0, num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *));
1344#endif
1345 }
1346
1347 return;
1348
1349invalid:
1350 invalidCommandBlock(pRI);
1351 return;
1352}
1353
1354static void
1355dispatchCdmaBrSmsCnf(Parcel &p, RequestInfo *pRI) {
1356 int32_t t;
1357 status_t status;
1358 int32_t num;
1359
1360 status = p.readInt32(&num);
1361 if (status != NO_ERROR) {
1362 goto invalid;
1363 }
1364
1365 {
1366 RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num];
1367 RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num];
1368
1369 startRequest;
1370 for (int i = 0 ; i < num ; i++ ) {
1371 cdmaBciPtrs[i] = &cdmaBci[i];
1372
1373 status = p.readInt32(&t);
1374 cdmaBci[i].service_category = (int) t;
1375
1376 status = p.readInt32(&t);
1377 cdmaBci[i].language = (int) t;
1378
1379 status = p.readInt32(&t);
1380 cdmaBci[i].selected = (uint8_t) t;
1381
1382 appendPrintBuf("%s [%d: service_category=%d, language =%d, \
1383 entries.bSelected =%d]", printBuf, i, cdmaBci[i].service_category,
1384 cdmaBci[i].language, cdmaBci[i].selected);
1385 }
1386 closeRequest;
1387
1388 if (status != NO_ERROR) {
1389 goto invalid;
1390 }
1391 printRequest(pRI->token, pRI->pCI->requestNumber);
1392 CALL_ONREQUEST(pRI->pCI->requestNumber,
1393 cdmaBciPtrs,
1394 num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *),
1395 pRI, pRI->socket_id);
1396
1397#ifdef MEMSET_FREED
1398 memset(cdmaBci, 0, num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo));
1399 memset(cdmaBciPtrs, 0, num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *));
1400#endif
1401 }
1402
1403 return;
1404
1405invalid:
1406 invalidCommandBlock(pRI);
1407 return;
1408}
1409
1410static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI) {
1411 RIL_CDMA_SMS_WriteArgs rcsw;
1412 int32_t t;
1413 uint32_t ut;
1414 uint8_t uct;
1415 status_t status;
1416 int32_t digitCount;
1417 int32_t digitLimit;
1418
1419 memset(&rcsw, 0, sizeof(rcsw));
1420
1421 status = p.readInt32(&t);
1422 rcsw.status = t;
1423
1424 status = p.readInt32(&t);
1425 rcsw.message.uTeleserviceID = (int) t;
1426
1427 status = p.read(&uct,sizeof(uct));
1428 rcsw.message.bIsServicePresent = (uint8_t) uct;
1429
1430 status = p.readInt32(&t);
1431 rcsw.message.uServicecategory = (int) t;
1432
1433 status = p.readInt32(&t);
1434 rcsw.message.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) t;
1435
1436 status = p.readInt32(&t);
1437 rcsw.message.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) t;
1438
1439 status = p.readInt32(&t);
1440 rcsw.message.sAddress.number_type = (RIL_CDMA_SMS_NumberType) t;
1441
1442 status = p.readInt32(&t);
1443 rcsw.message.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) t;
1444
1445 status = p.read(&uct,sizeof(uct));
1446 rcsw.message.sAddress.number_of_digits = (uint8_t) uct;
1447
1448 digitLimit = MIN((rcsw.message.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
1449
1450 for(digitCount = 0 ; digitCount < digitLimit; digitCount ++) {
1451 status = p.read(&uct,sizeof(uct));
1452 rcsw.message.sAddress.digits[digitCount] = (uint8_t) uct;
1453 }
1454
1455 status = p.readInt32(&t);
1456 rcsw.message.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) t;
1457
1458 status = p.read(&uct,sizeof(uct));
1459 rcsw.message.sSubAddress.odd = (uint8_t) uct;
1460
1461 status = p.read(&uct,sizeof(uct));
1462 rcsw.message.sSubAddress.number_of_digits = (uint8_t) uct;
1463
1464 digitLimit = MIN((rcsw.message.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
1465
1466 for(digitCount = 0 ; digitCount < digitLimit; digitCount ++) {
1467 status = p.read(&uct,sizeof(uct));
1468 rcsw.message.sSubAddress.digits[digitCount] = (uint8_t) uct;
1469 }
1470
1471 status = p.readInt32(&t);
1472 rcsw.message.uBearerDataLen = (int) t;
1473
1474 digitLimit = MIN((rcsw.message.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
1475
1476 for(digitCount = 0 ; digitCount < digitLimit; digitCount ++) {
1477 status = p.read(&uct, sizeof(uct));
1478 rcsw.message.aBearerData[digitCount] = (uint8_t) uct;
1479 }
1480
1481 if (status != NO_ERROR) {
1482 goto invalid;
1483 }
1484
1485 startRequest;
1486 appendPrintBuf("%sstatus=%d, message.uTeleserviceID=%d, message.bIsServicePresent=%d, \
1487 message.uServicecategory=%d, message.sAddress.digit_mode=%d, \
1488 message.sAddress.number_mode=%d, \
1489 message.sAddress.number_type=%d, ",
1490 printBuf, rcsw.status, rcsw.message.uTeleserviceID, rcsw.message.bIsServicePresent,
1491 rcsw.message.uServicecategory, rcsw.message.sAddress.digit_mode,
1492 rcsw.message.sAddress.number_mode,
1493 rcsw.message.sAddress.number_type);
1494 closeRequest;
1495
1496 printRequest(pRI->token, pRI->pCI->requestNumber);
1497
1498 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw),pRI, pRI->socket_id);
1499
1500#ifdef MEMSET_FREED
1501 memset(&rcsw, 0, sizeof(rcsw));
1502#endif
1503
1504 return;
1505
1506invalid:
1507 invalidCommandBlock(pRI);
1508 return;
1509
1510}
1511
1512// For backwards compatibility in RIL_REQUEST_SETUP_DATA_CALL.
1513// Version 4 of the RIL interface adds a new PDP type parameter to support
1514// IPv6 and dual-stack PDP contexts. When dealing with a previous version of
1515// RIL, remove the parameter from the request.
1516static void dispatchDataCall(Parcel& p, RequestInfo *pRI) {
1517 // In RIL v3, REQUEST_SETUP_DATA_CALL takes 6 parameters.
1518 const int numParamsRilV3 = 6;
1519
1520 // The first bytes of the RIL parcel contain the request number and the
1521 // serial number - see processCommandBuffer(). Copy them over too.
1522 int pos = p.dataPosition();
1523
1524 int numParams = p.readInt32();
1525 if (s_callbacks.version < 4 && numParams > numParamsRilV3) {
1526/* Parcel p2;
1527 p2.appendFrom(&p, 0, pos);
1528 p2.writeInt32(numParamsRilV3);
1529 for(int i = 0; i < numParamsRilV3; i++) {
1530 p2.writeString16(p.readString16());
1531 }
1532 p2.setDataPosition(pos);
1533 dispatchStrings(p2, pRI);*/
1534 } else {
1535 p.setDataPosition(pos);
1536 dispatchStrings(p, pRI);
1537 }
1538}
1539
1540static void dispatchSetInitialAttachApn(Parcel &p, RequestInfo *pRI)
1541{
1542 RIL_InitialAttachApn pf;
1543 int32_t t;
1544 status_t status;
1545
1546 memset(&pf, 0, sizeof(pf));
1547
1548 pf.apn = strdupReadString(p);
1549 pf.protocol = strdupReadString(p);
1550
1551 status = p.readInt32(&t);
1552 pf.authtype = (int) t;
1553
1554 pf.username = strdupReadString(p);
1555 pf.password = strdupReadString(p);
1556
1557 startRequest;
1558 appendPrintBuf("%sapn=%s, protocol=%s, authtype=%d, username=%s, password=%s",
1559 printBuf, pf.apn, pf.protocol, pf.authtype, pf.username, pf.password);
1560 closeRequest;
1561 printRequest(pRI->token, pRI->pCI->requestNumber);
1562
1563 if (status != NO_ERROR) {
1564 goto invalid;
1565 }
1566 CALL_ONREQUEST(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI, pRI->socket_id);
1567
1568#ifdef MEMSET_FREED
1569 memsetString(pf.apn);
1570 memsetString(pf.protocol);
1571 memsetString(pf.username);
1572 memsetString(pf.password);
1573#endif
1574
1575 free(pf.apn);
1576 free(pf.protocol);
1577 free(pf.username);
1578 free(pf.password);
1579
1580#ifdef MEMSET_FREED
1581 memset(&pf, 0, sizeof(pf));
1582#endif
1583
1584 return;
1585invalid:
1586 invalidCommandBlock(pRI);
1587 return;
1588}
1589
1590static void dispatchNVReadItem(Parcel &p, RequestInfo *pRI) {
1591 RIL_NV_ReadItem nvri;
1592 int32_t t;
1593 status_t status;
1594
1595 memset(&nvri, 0, sizeof(nvri));
1596
1597 status = p.readInt32(&t);
1598 nvri.itemID = (RIL_NV_Item) t;
1599
1600 if (status != NO_ERROR) {
1601 goto invalid;
1602 }
1603
1604 startRequest;
1605 appendPrintBuf("%snvri.itemID=%d, ", printBuf, nvri.itemID);
1606 closeRequest;
1607
1608 printRequest(pRI->token, pRI->pCI->requestNumber);
1609
1610 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI, pRI->socket_id);
1611
1612#ifdef MEMSET_FREED
1613 memset(&nvri, 0, sizeof(nvri));
1614#endif
1615
1616 return;
1617
1618invalid:
1619 invalidCommandBlock(pRI);
1620 return;
1621}
1622
1623static void dispatchNVWriteItem(Parcel &p, RequestInfo *pRI) {
1624 RIL_NV_WriteItem nvwi;
1625 int32_t t;
1626 status_t status;
1627
1628 memset(&nvwi, 0, sizeof(nvwi));
1629
1630 status = p.readInt32(&t);
1631 nvwi.itemID = (RIL_NV_Item) t;
1632
1633 nvwi.value = strdupReadString(p);
1634
1635 if (status != NO_ERROR || nvwi.value == NULL) {
1636 goto invalid;
1637 }
1638
1639 startRequest;
1640 appendPrintBuf("%snvwi.itemID=%d, value=%s, ", printBuf, nvwi.itemID,
1641 nvwi.value);
1642 closeRequest;
1643
1644 printRequest(pRI->token, pRI->pCI->requestNumber);
1645
1646 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI, pRI->socket_id);
1647
1648#ifdef MEMSET_FREED
1649 memsetString(nvwi.value);
1650#endif
1651
1652 free(nvwi.value);
1653
1654#ifdef MEMSET_FREED
1655 memset(&nvwi, 0, sizeof(nvwi));
1656#endif
1657
1658 return;
1659
1660invalid:
1661 invalidCommandBlock(pRI);
1662 return;
1663}
1664
1665
1666static void dispatchUiccSubscripton(Parcel &p, RequestInfo *pRI) {
1667 RIL_SelectUiccSub uicc_sub;
1668 status_t status;
1669 int32_t t;
1670 memset(&uicc_sub, 0, sizeof(uicc_sub));
1671
1672 status = p.readInt32(&t);
1673 if (status != NO_ERROR) {
1674 goto invalid;
1675 }
1676 uicc_sub.slot = (int) t;
1677
1678 status = p.readInt32(&t);
1679 if (status != NO_ERROR) {
1680 goto invalid;
1681 }
1682 uicc_sub.app_index = (int) t;
1683
1684 status = p.readInt32(&t);
1685 if (status != NO_ERROR) {
1686 goto invalid;
1687 }
1688 uicc_sub.sub_type = (RIL_SubscriptionType) t;
1689
1690 status = p.readInt32(&t);
1691 if (status != NO_ERROR) {
1692 goto invalid;
1693 }
1694 uicc_sub.act_status = (RIL_UiccSubActStatus) t;
1695
1696 startRequest;
1697 appendPrintBuf("slot=%d, app_index=%d, act_status = %d", uicc_sub.slot, uicc_sub.app_index,
1698 uicc_sub.act_status);
1699 RLOGD("dispatchUiccSubscription, slot=%d, app_index=%d, act_status = %d", uicc_sub.slot,
1700 uicc_sub.app_index, uicc_sub.act_status);
1701 closeRequest;
1702 printRequest(pRI->token, pRI->pCI->requestNumber);
1703
1704 CALL_ONREQUEST(pRI->pCI->requestNumber, &uicc_sub, sizeof(uicc_sub), pRI, pRI->socket_id);
1705
1706#ifdef MEMSET_FREED
1707 memset(&uicc_sub, 0, sizeof(uicc_sub));
1708#endif
1709 return;
1710
1711invalid:
1712 invalidCommandBlock(pRI);
1713 return;
1714}
1715
1716static void dispatchSimAuthentication(Parcel &p, RequestInfo *pRI)
1717{
1718 RIL_SimAuthentication pf;
1719 int32_t t;
1720 status_t status;
1721
1722 memset(&pf, 0, sizeof(pf));
1723
1724 status = p.readInt32(&t);
1725 pf.authContext = (int) t;
1726 pf.authData = strdupReadString(p);
1727 pf.aid = strdupReadString(p);
1728
1729 startRequest;
1730 appendPrintBuf("authContext=%s, authData=%s, aid=%s", pf.authContext, pf.authData, pf.aid);
1731 closeRequest;
1732 printRequest(pRI->token, pRI->pCI->requestNumber);
1733
1734 if (status != NO_ERROR) {
1735 goto invalid;
1736 }
1737 CALL_ONREQUEST(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI, pRI->socket_id);
1738
1739#ifdef MEMSET_FREED
1740 memsetString(pf.authData);
1741 memsetString(pf.aid);
1742#endif
1743
1744 free(pf.authData);
1745 free(pf.aid);
1746
1747#ifdef MEMSET_FREED
1748 memset(&pf, 0, sizeof(pf));
1749#endif
1750
1751 return;
1752invalid:
1753 invalidCommandBlock(pRI);
1754 return;
1755}
1756
1757static void dispatchDataProfile(Parcel &p, RequestInfo *pRI) {
1758 int32_t t;
1759 status_t status;
1760 int32_t num;
1761
1762 status = p.readInt32(&num);
1763 if (status != NO_ERROR) {
1764 goto invalid;
1765 }
1766
1767 {
1768 RIL_DataProfileInfo dataProfiles[num];
1769 RIL_DataProfileInfo *dataProfilePtrs[num];
1770
1771 startRequest;
1772 for (int i = 0 ; i < num ; i++ ) {
1773 dataProfilePtrs[i] = &dataProfiles[i];
1774
1775 status = p.readInt32(&t);
1776 dataProfiles[i].profileId = (int) t;
1777
1778 dataProfiles[i].apn = strdupReadString(p);
1779 dataProfiles[i].protocol = strdupReadString(p);
1780 status = p.readInt32(&t);
1781 dataProfiles[i].authType = (int) t;
1782
1783 dataProfiles[i].user = strdupReadString(p);
1784 dataProfiles[i].password = strdupReadString(p);
1785
1786 status = p.readInt32(&t);
1787 dataProfiles[i].type = (int) t;
1788
1789 status = p.readInt32(&t);
1790 dataProfiles[i].maxConnsTime = (int) t;
1791 status = p.readInt32(&t);
1792 dataProfiles[i].maxConns = (int) t;
1793 status = p.readInt32(&t);
1794 dataProfiles[i].waitTime = (int) t;
1795
1796 status = p.readInt32(&t);
1797 dataProfiles[i].enabled = (int) t;
1798
1799 appendPrintBuf("%s [%d: profileId=%d, apn =%s, protocol =%s, authType =%d, \
1800 user =%s, password =%s, type =%d, maxConnsTime =%d, maxConns =%d, \
1801 waitTime =%d, enabled =%d]", printBuf, i, dataProfiles[i].profileId,
1802 dataProfiles[i].apn, dataProfiles[i].protocol, dataProfiles[i].authType,
1803 dataProfiles[i].user, dataProfiles[i].password, dataProfiles[i].type,
1804 dataProfiles[i].maxConnsTime, dataProfiles[i].maxConns,
1805 dataProfiles[i].waitTime, dataProfiles[i].enabled);
1806 RLOGD("[%d: profileId=%d, apn =%s, protocol =%s, authType =%d, \
1807user =%s, password =%s, type =%d, maxConnsTime =%d, maxConns =%d, \
1808waitTime =%d, enabled =%d]", i, dataProfiles[i].profileId,
1809 dataProfiles[i].apn, dataProfiles[i].protocol, dataProfiles[i].authType,
1810 dataProfiles[i].user, dataProfiles[i].password, dataProfiles[i].type,
1811 dataProfiles[i].maxConnsTime, dataProfiles[i].maxConns,
1812 dataProfiles[i].waitTime, dataProfiles[i].enabled);
1813 }
1814 closeRequest;
1815 printRequest(pRI->token, pRI->pCI->requestNumber);
1816
1817 if (status != NO_ERROR) {
1818 goto invalid;
1819 }
1820 CALL_ONREQUEST(pRI->pCI->requestNumber,
1821 dataProfilePtrs,
1822 num * sizeof(RIL_DataProfileInfo *),
1823 pRI, pRI->socket_id);
1824 for(int i = 0; i< num; i++) {
1825 free(dataProfiles[i].apn);
1826 free(dataProfiles[i].protocol);
1827 free(dataProfiles[i].user);
1828 free(dataProfiles[i].password);
1829 }
1830#ifdef MEMSET_FREED
1831 memset(dataProfiles, 0, num * sizeof(RIL_DataProfileInfo));
1832 memset(dataProfilePtrs, 0, num * sizeof(RIL_DataProfileInfo *));
1833#endif
1834 }
1835
1836 return;
1837
1838invalid:
1839 invalidCommandBlock(pRI);
1840 return;
1841}
1842
1843static void dispatchRadioCapability(Parcel &p, RequestInfo *pRI){
1844 RIL_RadioCapability rc;
1845 int32_t t;
1846 status_t status;
1847
1848 memset (&rc, 0, sizeof(RIL_RadioCapability));
1849
1850 status = p.readInt32(&t);
1851 rc.version = (int)t;
1852 if (status != NO_ERROR) {
1853 goto invalid;
1854 }
1855
1856 status = p.readInt32(&t);
1857 rc.session= (int)t;
1858 if (status != NO_ERROR) {
1859 goto invalid;
1860 }
1861
1862 status = p.readInt32(&t);
1863 rc.phase= (int)t;
1864 if (status != NO_ERROR) {
1865 goto invalid;
1866 }
1867
1868 status = p.readInt32(&t);
1869 rc.rat = (int)t;
1870 if (status != NO_ERROR) {
1871 goto invalid;
1872 }
1873
1874 status = readStringFromParcelInplace(p, rc.logicalModemUuid, sizeof(rc.logicalModemUuid));
1875 if (status != NO_ERROR) {
1876 goto invalid;
1877 }
1878
1879 status = p.readInt32(&t);
1880 rc.status = (int)t;
1881
1882 if (status != NO_ERROR) {
1883 goto invalid;
1884 }
1885
1886 startRequest;
1887 appendPrintBuf("%s [version:%d, session:%d, phase:%d, rat:%d, logicalModemUuid:%s, status:%d",
1888 printBuf, rc.version, rc.session, rc.phase, rc.rat, rc.logicalModemUuid, rc.status);
1889
1890 closeRequest;
1891 printRequest(pRI->token, pRI->pCI->requestNumber);
1892
1893 CALL_ONREQUEST(pRI->pCI->requestNumber,
1894 &rc,
1895 sizeof(RIL_RadioCapability),
1896 pRI, pRI->socket_id);
1897 return;
1898invalid:
1899 invalidCommandBlock(pRI);
1900 return;
1901}
1902
1903#if 0
1904static int
1905blockingWrite(int fd, const void *buffer, size_t len) {
1906 size_t writeOffset = 0;
1907 const uint8_t *toWrite;
1908
1909 toWrite = (const uint8_t *)buffer;
1910
1911 while (writeOffset < len) {
1912 ssize_t written;
1913 do {
1914 written = write (fd, toWrite + writeOffset,
1915 len - writeOffset);
1916 } while (written < 0 && ((errno == EINTR) || (errno == EAGAIN)));
1917
1918 if (written >= 0) {
1919 writeOffset += written;
1920 } else { // written < 0
1921 RLOGE ("RIL Response: unexpected error on write errno:%d", errno);
1922 close(fd);
1923 return -1;
1924 }
1925 }
1926#if VDBG
1927 RLOGE("RIL Response bytes written:%d", writeOffset);
1928#endif
1929 return 0;
1930}
1931
1932static int
1933sendResponseRaw (const void *data, size_t dataSize, RIL_SOCKET_ID socket_id) {
1934 int fd = s_ril_param_socket.fdCommand;
1935 int ret;
1936 uint32_t header;
1937 pthread_mutex_t * writeMutexHook = &s_writeMutex;
1938
1939#if VDBG
1940 RLOGE("Send Response to %s", rilSocketIdToString(socket_id));
1941#endif
1942
1943#if (SIM_COUNT >= 2)
1944 if (socket_id == RIL_SOCKET_2) {
1945 fd = s_ril_param_socket2.fdCommand;
1946 writeMutexHook = &s_writeMutex_socket2;
1947 }
1948#if (SIM_COUNT >= 3)
1949 else if (socket_id == RIL_SOCKET_3) {
1950 fd = s_ril_param_socket3.fdCommand;
1951 writeMutexHook = &s_writeMutex_socket3;
1952 }
1953#endif
1954#if (SIM_COUNT >= 4)
1955 else if (socket_id == RIL_SOCKET_4) {
1956 fd = s_ril_param_socket4.fdCommand;
1957 writeMutexHook = &s_writeMutex_socket4;
1958 }
1959#endif
1960#endif
1961 if (fd < 0) {
1962 return -1;
1963 }
1964
1965 if (dataSize > MAX_COMMAND_BYTES) {
1966 RLOGE("RIL: packet larger than %u (%u)",
1967 MAX_COMMAND_BYTES, (unsigned int )dataSize);
1968
1969 return -1;
1970 }
1971
1972 pthread_mutex_lock(writeMutexHook);
1973
1974 header = htonl(dataSize);
1975
1976 ret = blockingWrite(fd, (void *)&header, sizeof(header));
1977
1978 if (ret < 0) {
1979 pthread_mutex_unlock(writeMutexHook);
1980 return ret;
1981 }
1982
1983 ret = blockingWrite(fd, data, dataSize);
1984
1985 if (ret < 0) {
1986 pthread_mutex_unlock(writeMutexHook);
1987 return ret;
1988 }
1989
1990 pthread_mutex_unlock(writeMutexHook);
1991
1992 return 0;
1993}
1994
1995static int
1996sendResponse (Parcel &p, RIL_SOCKET_ID socket_id) {
1997 printResponse;
1998 return sendResponseRaw(p.data(), p.dataSize(), socket_id);
1999}
2000#endif
2001
2002/** response is an int* pointing to an array of ints */
2003
2004static int
2005responseInts(Parcel &p, void *response, size_t responselen) {
2006 int numInts;
2007
2008 if (response == NULL && responselen != 0) {
2009 RLOGE("invalid response: NULL");
2010 return RIL_ERRNO_INVALID_RESPONSE;
2011 }
2012 if (responselen % sizeof(int) != 0) {
2013 RLOGE("responseInts: invalid response length %d expected multiple of %d\n",
2014 (int)responselen, (int)sizeof(int));
2015 return RIL_ERRNO_INVALID_RESPONSE;
2016 }
2017
2018 int *p_int = (int *) response;
2019
2020 numInts = responselen / sizeof(int);
2021 p.writeInt32 (numInts);
2022
2023 /* each int*/
2024 startResponse;
2025 for (int i = 0 ; i < numInts ; i++) {
2026 appendPrintBuf("%s%d,", printBuf, p_int[i]);
2027 p.writeInt32(p_int[i]);
2028 }
2029 removeLastChar;
2030 closeResponse;
2031
2032 return 0;
2033}
2034
2035// Response is an int or RIL_LastCallFailCauseInfo.
2036// Currently, only Shamu plans to use RIL_LastCallFailCauseInfo.
2037// TODO(yjl): Let all implementations use RIL_LastCallFailCauseInfo.
2038static int responseFailCause(Parcel &p, void *response, size_t responselen) {
2039 if (response == NULL && responselen != 0) {
2040 RLOGE("invalid response: NULL");
2041 return RIL_ERRNO_INVALID_RESPONSE;
2042 }
2043
2044 if (responselen == sizeof(int)) {
2045 startResponse;
2046 int *p_int = (int *) response;
2047 appendPrintBuf("%s%d,", printBuf, p_int[0]);
2048 p.writeInt32(p_int[0]);
2049 removeLastChar;
2050 closeResponse;
2051 } else if (responselen == sizeof(RIL_LastCallFailCauseInfo)) {
2052 startResponse;
2053 RIL_LastCallFailCauseInfo *p_fail_cause_info = (RIL_LastCallFailCauseInfo *) response;
2054 appendPrintBuf("%s[cause_code=%d,vendor_cause=%s]", printBuf, p_fail_cause_info->cause_code,
2055 p_fail_cause_info->vendor_cause);
2056 p.writeInt32(p_fail_cause_info->cause_code);
2057 writeStringToParcel(p, p_fail_cause_info->vendor_cause);
2058 removeLastChar;
2059 closeResponse;
2060 } else {
2061 RLOGE("responseFailCause: invalid response length %d expected an int or "
2062 "RIL_LastCallFailCauseInfo", (int)responselen);
2063 return RIL_ERRNO_INVALID_RESPONSE;
2064 }
2065
2066 return 0;
2067}
2068
2069/** response is a char **, pointing to an array of char *'s
2070 The parcel will begin with the version */
2071static int responseStringsWithVersion(int version, Parcel &p, void *response, size_t responselen) {
2072 p.writeInt32(version);
2073 return responseStrings(p, response, responselen);
2074}
2075
2076/** response is a char **, pointing to an array of char *'s */
2077static int responseStrings(Parcel &p, void *response, size_t responselen) {
2078 int numStrings;
2079
2080 if (response == NULL && responselen != 0) {
2081 RLOGE("invalid response: NULL");
2082 return RIL_ERRNO_INVALID_RESPONSE;
2083 }
2084 if (responselen % sizeof(char *) != 0) {
2085 RLOGE("responseStrings: invalid response length %d expected multiple of %d\n",
2086 (int)responselen, (int)sizeof(char *));
2087 return RIL_ERRNO_INVALID_RESPONSE;
2088 }
2089
2090 if (response == NULL) {
2091 p.writeInt32 (0);
2092 } else {
2093 char **p_cur = (char **) response;
2094
2095 numStrings = responselen / sizeof(char *);
2096 p.writeInt32 (numStrings);
2097
2098 /* each string*/
2099 startResponse;
2100 for (int i = 0 ; i < numStrings ; i++) {
2101 appendPrintBuf("%s%s,", printBuf, (char*)p_cur[i]);
2102 writeStringToParcel (p, p_cur[i]);
2103 }
2104 removeLastChar;
2105 closeResponse;
2106 }
2107 return 0;
2108}
2109
2110
2111/**
2112 * NULL strings are accepted
2113 * FIXME currently ignores responselen
2114 */
2115static int responseString(Parcel &p, void *response, size_t responselen) {
2116 /* one string only */
2117 startResponse;
2118 appendPrintBuf("%s%s", printBuf, (char*)response);
2119 closeResponse;
2120
2121 writeStringToParcel(p, (const char *)response);
2122 return 0;
2123}
2124
2125static int responseVoid(Parcel &p, void *response, size_t responselen) {
2126 startResponse;
2127 removeLastChar;
2128 return 0;
2129}
2130
2131static int responseCallList(Parcel &p, void *response, size_t responselen) {
2132 int num;
2133
2134 if (response == NULL && responselen != 0) {
2135 RLOGE("invalid response: NULL");
2136 return RIL_ERRNO_INVALID_RESPONSE;
2137 }
2138
2139 if (responselen % sizeof (RIL_Call *) != 0) {
2140 RLOGE("responseCallList: invalid response length %d expected multiple of %d\n",
2141 (int)responselen, (int)sizeof (RIL_Call *));
2142 return RIL_ERRNO_INVALID_RESPONSE;
2143 }
2144
2145 startResponse;
2146 /* number of call info's */
2147 num = responselen / sizeof(RIL_Call *);
2148 p.writeInt32(num);
2149 for (int i = 0 ; i < num ; i++) {
2150 RIL_Call *p_cur = ((RIL_Call **) response)[i];
2151 /* each call info */
2152 p.writeInt32(p_cur->state);
2153 p.writeInt32(p_cur->index);
2154 p.writeInt32(p_cur->toa);
2155 p.writeInt32(p_cur->isMpty);
2156 p.writeInt32(p_cur->isMT);
2157 p.writeInt32(p_cur->als);
2158 p.writeInt32(p_cur->isVoice);
2159 p.writeInt32(p_cur->isVoicePrivacy);
2160 writeStringToParcel(p, p_cur->number);
2161 p.writeInt32(p_cur->numberPresentation);
2162 writeStringToParcel(p, p_cur->name);
2163 p.writeInt32(p_cur->namePresentation);
2164 // Remove when partners upgrade to version 3
2165 if ((s_callbacks.version < 3) || (p_cur->uusInfo == NULL || p_cur->uusInfo->uusData == NULL)) {
2166 p.writeInt32(0); /* UUS Information is absent */
2167 } else {
2168 RIL_UUS_Info *uusInfo = p_cur->uusInfo;
2169 p.writeInt32(1); /* UUS Information is present */
2170 p.writeInt32(uusInfo->uusType);
2171 p.writeInt32(uusInfo->uusDcs);
2172 p.writeInt32(uusInfo->uusLength);
2173 p.write(uusInfo->uusData, uusInfo->uusLength);
2174 }
2175 appendPrintBuf("%s[id=%d,%s,toa=%d,",
2176 printBuf,
2177 p_cur->index,
2178 callStateToString(p_cur->state),
2179 p_cur->toa);
2180 appendPrintBuf("%s%s,%s,als=%d,%s,%s,",
2181 printBuf,
2182 (p_cur->isMpty)?"conf":"norm",
2183 (p_cur->isMT)?"mt":"mo",
2184 p_cur->als,
2185 (p_cur->isVoice)?"voc":"nonvoc",
2186 (p_cur->isVoicePrivacy)?"evp":"noevp");
2187 appendPrintBuf("%s%s,cli=%d,name='%s',%d]",
2188 printBuf,
2189 p_cur->number,
2190 p_cur->numberPresentation,
2191 p_cur->name,
2192 p_cur->namePresentation);
2193 if(p_cur->isMT) {
2194 printf("[EVENT][MT_CALL] phone number is %s\n",p_cur->number);
2195 }
2196 }
2197 removeLastChar;
2198 closeResponse;
2199
2200 return 0;
2201}
2202
2203static int responseSMS(Parcel &p, void *response, size_t responselen) {
2204 if (response == NULL) {
2205 RLOGE("invalid response: NULL");
2206 return RIL_ERRNO_INVALID_RESPONSE;
2207 }
2208
2209 if (responselen != sizeof (RIL_SMS_Response) ) {
2210 RLOGE("invalid response length %d expected %d",
2211 (int)responselen, (int)sizeof (RIL_SMS_Response));
2212 return RIL_ERRNO_INVALID_RESPONSE;
2213 }
2214
2215 RIL_SMS_Response *p_cur = (RIL_SMS_Response *) response;
2216
2217 p.writeInt32(p_cur->messageRef);
2218 writeStringToParcel(p, p_cur->ackPDU);
2219 p.writeInt32(p_cur->errorCode);
2220
2221 startResponse;
2222 appendPrintBuf("%s%d,%s,%d", printBuf, p_cur->messageRef,
2223 (char*)p_cur->ackPDU, p_cur->errorCode);
2224 closeResponse;
2225 bool ifResend;
2226 if(isGostEcall())
2227 {
2228 if(p_cur->errorCode == 0)
2229 {
2230 //delete MSD
2231 gostDelSaveSmsData();
2232 //no resend
2233 ifResend = false;
2234 }
2235 else
2236 {
2237 //resend MSD
2238 ifResend = true;
2239 }
2240 gostEcallResendMsd(ifResend);
2241 }
2242 return 0;
2243}
2244
2245static int responseDataCallListV4(Parcel &p, void *response, size_t responselen)
2246{
2247 if (response == NULL && responselen != 0) {
2248 RLOGE("invalid response: NULL");
2249 return RIL_ERRNO_INVALID_RESPONSE;
2250 }
2251
2252 if (responselen % sizeof(RIL_Data_Call_Response_v4) != 0) {
2253 RLOGE("responseDataCallListV4: invalid response length %d expected multiple of %d",
2254 (int)responselen, (int)sizeof(RIL_Data_Call_Response_v4));
2255 return RIL_ERRNO_INVALID_RESPONSE;
2256 }
2257
2258 // Write version
2259 p.writeInt32(4);
2260
2261 int num = responselen / sizeof(RIL_Data_Call_Response_v4);
2262 p.writeInt32(num);
2263
2264 RIL_Data_Call_Response_v4 *p_cur = (RIL_Data_Call_Response_v4 *) response;
2265 startResponse;
2266 int i;
2267 for (i = 0; i < num; i++) {
2268 p.writeInt32(p_cur[i].cid);
2269 p.writeInt32(p_cur[i].active);
2270 writeStringToParcel(p, p_cur[i].type);
2271 // apn is not used, so don't send.
2272 writeStringToParcel(p, p_cur[i].address);
2273 appendPrintBuf("%s[cid=%d,%s,%s,%s],", printBuf,
2274 p_cur[i].cid,
2275 (p_cur[i].active==0)?"down":"up",
2276 (char*)p_cur[i].type,
2277 (char*)p_cur[i].address);
2278 }
2279 removeLastChar;
2280 closeResponse;
2281
2282 return 0;
2283}
2284
2285static int responseDataCallListV6(Parcel &p, void *response, size_t responselen)
2286{
2287 if (response == NULL && responselen != 0) {
2288 RLOGE("invalid response: NULL");
2289 return RIL_ERRNO_INVALID_RESPONSE;
2290 }
2291
2292 if (responselen % sizeof(RIL_Data_Call_Response_v6) != 0) {
2293 RLOGE("responseDataCallListV6: invalid response length %d expected multiple of %d",
2294 (int)responselen, (int)sizeof(RIL_Data_Call_Response_v6));
2295 return RIL_ERRNO_INVALID_RESPONSE;
2296 }
2297
2298 // Write version
2299 p.writeInt32(6);
2300
2301 int num = responselen / sizeof(RIL_Data_Call_Response_v6);
2302 p.writeInt32(num);
2303
2304 RIL_Data_Call_Response_v6 *p_cur = (RIL_Data_Call_Response_v6 *) response;
2305 startResponse;
2306 int i;
2307 for (i = 0; i < num; i++) {
2308 p.writeInt32((int)p_cur[i].status);
2309 p.writeInt32(p_cur[i].suggestedRetryTime);
2310 p.writeInt32(p_cur[i].cid);
2311 p.writeInt32(p_cur[i].active);
2312 writeStringToParcel(p, p_cur[i].type);
2313 writeStringToParcel(p, p_cur[i].ifname);
2314 writeStringToParcel(p, p_cur[i].addresses);
2315 writeStringToParcel(p, p_cur[i].dnses);
2316 writeStringToParcel(p, p_cur[i].gateways);
2317 appendPrintBuf("%s[status=%d,retry=%d,cid=%d,%s,%s,%s,%s,%s,%s],", printBuf,
2318 p_cur[i].status,
2319 p_cur[i].suggestedRetryTime,
2320 p_cur[i].cid,
2321 (p_cur[i].active==0)?"down":"up",
2322 (char*)p_cur[i].type,
2323 (char*)p_cur[i].ifname,
2324 (char*)p_cur[i].addresses,
2325 (char*)p_cur[i].dnses,
2326 (char*)p_cur[i].gateways);
2327 }
2328 removeLastChar;
2329 closeResponse;
2330 return 0;
2331}
2332
2333static int responseDataCallListV9(Parcel &p, void *response, size_t responselen)
2334{
2335 if (response == NULL && responselen != 0) {
2336 RLOGE("invalid response: NULL");
2337 return RIL_ERRNO_INVALID_RESPONSE;
2338 }
2339
2340 if (responselen % sizeof(RIL_Data_Call_Response_v9) != 0) {
2341 RLOGE("responseDataCallListV9: invalid response length %d expected multiple of %d",
2342 (int)responselen, (int)sizeof(RIL_Data_Call_Response_v9));
2343 return RIL_ERRNO_INVALID_RESPONSE;
2344 }
2345
2346 // Write version
2347 p.writeInt32(10);
2348
2349 int num = responselen / sizeof(RIL_Data_Call_Response_v9);
2350 p.writeInt32(num);
2351
2352 RIL_Data_Call_Response_v9 *p_cur = (RIL_Data_Call_Response_v9 *) response;
2353 startResponse;
2354 int i;
2355 for (i = 0; i < num; i++) {
2356 p.writeInt32((int)p_cur[i].status);
2357 p.writeInt32(p_cur[i].suggestedRetryTime);
2358 p.writeInt32(p_cur[i].cid);
2359 p.writeInt32(p_cur[i].active);
2360 writeStringToParcel(p, p_cur[i].type);
2361 writeStringToParcel(p, p_cur[i].ifname);
2362 writeStringToParcel(p, p_cur[i].addresses);
2363 writeStringToParcel(p, p_cur[i].dnses);
2364 writeStringToParcel(p, p_cur[i].gateways);
2365 writeStringToParcel(p, p_cur[i].pcscf);
2366 appendPrintBuf("%s[status=%d,retry=%d,cid=%d,%s,%s,%s,%s,%s,%s,%s],", printBuf,
2367 p_cur[i].status,
2368 p_cur[i].suggestedRetryTime,
2369 p_cur[i].cid,
2370 (p_cur[i].active==0)?"down":"up",
2371 (char*)p_cur[i].type,
2372 (char*)p_cur[i].ifname,
2373 (char*)p_cur[i].addresses,
2374 (char*)p_cur[i].dnses,
2375 (char*)p_cur[i].gateways,
2376 (char*)p_cur[i].pcscf);
2377 }
2378 removeLastChar;
2379 closeResponse;
2380
2381 return 0;
2382}
2383
2384
2385static int responseDataCallList(Parcel &p, void *response, size_t responselen)
2386{
2387 if (s_callbacks.version < 5) {
2388 RLOGD("responseDataCallList: v4");
2389 return responseDataCallListV4(p, response, responselen);
2390 } else if (responselen % sizeof(RIL_Data_Call_Response_v6) == 0) {
2391 return responseDataCallListV6(p, response, responselen);
2392 } else if (responselen % sizeof(RIL_Data_Call_Response_v9) == 0) {
2393 return responseDataCallListV9(p, response, responselen);
2394 } else {
2395 if (response == NULL && responselen != 0) {
2396 RLOGE("invalid response: NULL");
2397 return RIL_ERRNO_INVALID_RESPONSE;
2398 }
2399
2400 if (responselen % sizeof(RIL_Data_Call_Response_v11) != 0) {
2401 RLOGE("invalid response length %d expected multiple of %d",
2402 (int)responselen, (int)sizeof(RIL_Data_Call_Response_v11));
2403 return RIL_ERRNO_INVALID_RESPONSE;
2404 }
2405
2406 // Write version
2407 p.writeInt32(11);
2408
2409 int num = responselen / sizeof(RIL_Data_Call_Response_v11);
2410 p.writeInt32(num);
2411
2412 RIL_Data_Call_Response_v11 *p_cur = (RIL_Data_Call_Response_v11 *) response;
2413 startResponse;
2414 int i;
2415 for (i = 0; i < num; i++) {
2416 p.writeInt32((int)p_cur[i].status);
2417 p.writeInt32(p_cur[i].suggestedRetryTime);
2418 p.writeInt32(p_cur[i].cid);
2419 p.writeInt32(p_cur[i].active);
2420 writeStringToParcel(p, p_cur[i].type);
2421 writeStringToParcel(p, p_cur[i].ifname);
2422 writeStringToParcel(p, p_cur[i].addresses);
2423 writeStringToParcel(p, p_cur[i].dnses);
2424 writeStringToParcel(p, p_cur[i].gateways);
2425 writeStringToParcel(p, p_cur[i].pcscf);
2426 p.writeInt32(p_cur[i].mtu);
2427 appendPrintBuf("%s[status=%d,retry=%d,cid=%d,%s,%s,%s,%s,%s,%s,%s,mtu=%d],", printBuf,
2428 p_cur[i].status,
2429 p_cur[i].suggestedRetryTime,
2430 p_cur[i].cid,
2431 (p_cur[i].active==0)?"down":"up",
2432 (char*)p_cur[i].type,
2433 (char*)p_cur[i].ifname,
2434 (char*)p_cur[i].addresses,
2435 (char*)p_cur[i].dnses,
2436 (char*)p_cur[i].gateways,
2437 (char*)p_cur[i].pcscf,
2438 p_cur[i].mtu);
2439 }
2440 removeLastChar;
2441 closeResponse;
2442 }
2443
2444 return 0;
2445}
2446
2447static int responseSetupDataCall(Parcel &p, void *response, size_t responselen)
2448{
2449 if (s_callbacks.version < 5) {
2450 return responseStringsWithVersion(s_callbacks.version, p, response, responselen);
2451 } else {
2452 return responseDataCallList(p, response, responselen);
2453 }
2454}
2455
2456static int responseRaw(Parcel &p, void *response, size_t responselen) {
2457 if (response == NULL && responselen != 0) {
2458 RLOGE("invalid response: NULL with responselen != 0");
2459 return RIL_ERRNO_INVALID_RESPONSE;
2460 }
2461
2462 // The java code reads -1 size as null byte array
2463 if (response == NULL) {
2464 p.writeInt32(-1);
2465 } else {
2466 p.writeInt32(responselen);
2467 p.write(response, responselen);
2468 }
2469
2470 startResponse;
2471 appendPrintBuf("%slen=%d,%s", printBuf, responselen, (char*)response);
2472 closeResponse;
2473 return 0;
2474}
2475
2476
2477static int responseSIM_IO(Parcel &p, void *response, size_t responselen) {
2478 if (response == NULL) {
2479 RLOGE("invalid response: NULL");
2480 return RIL_ERRNO_INVALID_RESPONSE;
2481 }
2482
2483 if (responselen != sizeof (RIL_SIM_IO_Response) ) {
2484 RLOGE("invalid response length was %d expected %d",
2485 (int)responselen, (int)sizeof (RIL_SIM_IO_Response));
2486 return RIL_ERRNO_INVALID_RESPONSE;
2487 }
2488
2489 RIL_SIM_IO_Response *p_cur = (RIL_SIM_IO_Response *) response;
2490 p.writeInt32(p_cur->sw1);
2491 p.writeInt32(p_cur->sw2);
2492 writeStringToParcel(p, p_cur->simResponse);
2493
2494 startResponse;
2495 appendPrintBuf("%ssw1=0x%X,sw2=0x%X,%s", printBuf, p_cur->sw1, p_cur->sw2,
2496 (char*)p_cur->simResponse);
2497 closeResponse;
2498
2499
2500 return 0;
2501}
2502
2503static int responseCallForwards(Parcel &p, void *response, size_t responselen) {
2504 int num;
2505
2506 if (response == NULL && responselen != 0) {
2507 RLOGE("invalid response: NULL");
2508 return RIL_ERRNO_INVALID_RESPONSE;
2509 }
2510
2511 if (responselen % sizeof(RIL_CallForwardInfo *) != 0) {
2512 RLOGE("responseCallForwards: invalid response length %d expected multiple of %d",
2513 (int)responselen, (int)sizeof(RIL_CallForwardInfo *));
2514 return RIL_ERRNO_INVALID_RESPONSE;
2515 }
2516
2517 /* number of call info's */
2518 num = responselen / sizeof(RIL_CallForwardInfo *);
2519 p.writeInt32(num);
2520
2521 startResponse;
2522 for (int i = 0 ; i < num ; i++) {
2523 RIL_CallForwardInfo *p_cur = ((RIL_CallForwardInfo **) response)[i];
2524
2525 p.writeInt32(p_cur->status);
2526 p.writeInt32(p_cur->reason);
2527 p.writeInt32(p_cur->serviceClass);
2528 p.writeInt32(p_cur->toa);
2529 writeStringToParcel(p, p_cur->number);
2530 p.writeInt32(p_cur->timeSeconds);
2531 appendPrintBuf("%s[%s,reason=%d,cls=%d,toa=%d,%s,tout=%d],", printBuf,
2532 (p_cur->status==1)?"enable":"disable",
2533 p_cur->reason, p_cur->serviceClass, p_cur->toa,
2534 (char*)p_cur->number,
2535 p_cur->timeSeconds);
2536 }
2537 removeLastChar;
2538 closeResponse;
2539
2540 return 0;
2541}
2542
2543static int responseSsn(Parcel &p, void *response, size_t responselen) {
2544 if (response == NULL) {
2545 RLOGE("invalid response: NULL");
2546 return RIL_ERRNO_INVALID_RESPONSE;
2547 }
2548
2549 if (responselen != sizeof(RIL_SuppSvcNotification)) {
2550 RLOGE("invalid response length was %d expected %d",
2551 (int)responselen, (int)sizeof (RIL_SuppSvcNotification));
2552 return RIL_ERRNO_INVALID_RESPONSE;
2553 }
2554
2555 RIL_SuppSvcNotification *p_cur = (RIL_SuppSvcNotification *) response;
2556 p.writeInt32(p_cur->notificationType);
2557 p.writeInt32(p_cur->code);
2558 p.writeInt32(p_cur->index);
2559 p.writeInt32(p_cur->type);
2560 writeStringToParcel(p, p_cur->number);
2561
2562 startResponse;
2563 appendPrintBuf("%s%s,code=%d,id=%d,type=%d,%s", printBuf,
2564 (p_cur->notificationType==0)?"mo":"mt",
2565 p_cur->code, p_cur->index, p_cur->type,
2566 (char*)p_cur->number);
2567 closeResponse;
2568
2569 return 0;
2570}
2571
2572static int responseCellList(Parcel &p, void *response, size_t responselen) {
2573 int num;
2574
2575 if (response == NULL && responselen != 0) {
2576 RLOGE("invalid response: NULL");
2577 return RIL_ERRNO_INVALID_RESPONSE;
2578 }
2579
2580 if (responselen % sizeof (RIL_NeighboringCell *) != 0) {
2581 RLOGE("responseCellList: invalid response length %d expected multiple of %d\n",
2582 (int)responselen, (int)sizeof (RIL_NeighboringCell *));
2583 return RIL_ERRNO_INVALID_RESPONSE;
2584 }
2585
2586 startResponse;
2587 /* number of records */
2588 num = responselen / sizeof(RIL_NeighboringCell *);
2589 p.writeInt32(num);
2590
2591 for (int i = 0 ; i < num ; i++) {
2592 RIL_NeighboringCell *p_cur = ((RIL_NeighboringCell **) response)[i];
2593
2594 p.writeInt32(p_cur->rssi);
2595 writeStringToParcel (p, p_cur->cid);
2596
2597 appendPrintBuf("%s[cid=%s,rssi=%d],", printBuf,
2598 p_cur->cid, p_cur->rssi);
2599 }
2600 removeLastChar;
2601 closeResponse;
2602
2603 return 0;
2604}
2605
2606/**
2607 * Marshall the signalInfoRecord into the parcel if it exists.
2608 */
2609static void marshallSignalInfoRecord(Parcel &p,
2610 RIL_CDMA_SignalInfoRecord &p_signalInfoRecord) {
2611 p.writeInt32(p_signalInfoRecord.isPresent);
2612 p.writeInt32(p_signalInfoRecord.signalType);
2613 p.writeInt32(p_signalInfoRecord.alertPitch);
2614 p.writeInt32(p_signalInfoRecord.signal);
2615}
2616
2617static int responseCdmaInformationRecords(Parcel &p,
2618 void *response, size_t responselen) {
2619 int num;
2620 char* string8 = NULL;
2621 int buffer_lenght;
2622 RIL_CDMA_InformationRecord *infoRec;
2623
2624 if (response == NULL && responselen != 0) {
2625 RLOGE("invalid response: NULL");
2626 return RIL_ERRNO_INVALID_RESPONSE;
2627 }
2628
2629 if (responselen != sizeof (RIL_CDMA_InformationRecords)) {
2630 RLOGE("responseCdmaInformationRecords: invalid response length %d expected multiple of %d\n",
2631 (int)responselen, (int)sizeof (RIL_CDMA_InformationRecords *));
2632 return RIL_ERRNO_INVALID_RESPONSE;
2633 }
2634
2635 RIL_CDMA_InformationRecords *p_cur =
2636 (RIL_CDMA_InformationRecords *) response;
2637 num = MIN(p_cur->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
2638
2639 startResponse;
2640 p.writeInt32(num);
2641
2642 for (int i = 0 ; i < num ; i++) {
2643 infoRec = &p_cur->infoRec[i];
2644 p.writeInt32(infoRec->name);
2645 switch (infoRec->name) {
2646 case RIL_CDMA_DISPLAY_INFO_REC:
2647 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC:
2648 if (infoRec->rec.display.alpha_len >
2649 CDMA_ALPHA_INFO_BUFFER_LENGTH) {
2650 RLOGE("invalid display info response length %d \
2651 expected not more than %d\n",
2652 (int)infoRec->rec.display.alpha_len,
2653 CDMA_ALPHA_INFO_BUFFER_LENGTH);
2654 return RIL_ERRNO_INVALID_RESPONSE;
2655 }
2656 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1)
2657 * sizeof(char) );
2658 for (int i = 0 ; i < infoRec->rec.display.alpha_len ; i++) {
2659 string8[i] = infoRec->rec.display.alpha_buf[i];
2660 }
2661 string8[(int)infoRec->rec.display.alpha_len] = '\0';
2662 writeStringToParcel(p, (const char*)string8);
2663 free(string8);
2664 string8 = NULL;
2665 break;
2666 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
2667 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
2668 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC:
2669 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
2670 RLOGE("invalid display info response length %d \
2671 expected not more than %d\n",
2672 (int)infoRec->rec.number.len,
2673 CDMA_NUMBER_INFO_BUFFER_LENGTH);
2674 return RIL_ERRNO_INVALID_RESPONSE;
2675 }
2676 string8 = (char*) malloc((infoRec->rec.number.len + 1)
2677 * sizeof(char) );
2678 for (int i = 0 ; i < infoRec->rec.number.len; i++) {
2679 string8[i] = infoRec->rec.number.buf[i];
2680 }
2681 string8[(int)infoRec->rec.number.len] = '\0';
2682 writeStringToParcel(p, (const char*)string8);
2683 free(string8);
2684 string8 = NULL;
2685 p.writeInt32(infoRec->rec.number.number_type);
2686 p.writeInt32(infoRec->rec.number.number_plan);
2687 p.writeInt32(infoRec->rec.number.pi);
2688 p.writeInt32(infoRec->rec.number.si);
2689 break;
2690 case RIL_CDMA_SIGNAL_INFO_REC:
2691 p.writeInt32(infoRec->rec.signal.isPresent);
2692 p.writeInt32(infoRec->rec.signal.signalType);
2693 p.writeInt32(infoRec->rec.signal.alertPitch);
2694 p.writeInt32(infoRec->rec.signal.signal);
2695
2696 appendPrintBuf("%sisPresent=%X, signalType=%X, \
2697 alertPitch=%X, signal=%X, ",
2698 printBuf, (int)infoRec->rec.signal.isPresent,
2699 (int)infoRec->rec.signal.signalType,
2700 (int)infoRec->rec.signal.alertPitch,
2701 (int)infoRec->rec.signal.signal);
2702 removeLastChar;
2703 break;
2704 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC:
2705 if (infoRec->rec.redir.redirectingNumber.len >
2706 CDMA_NUMBER_INFO_BUFFER_LENGTH) {
2707 RLOGE("invalid display info response length %d \
2708 expected not more than %d\n",
2709 (int)infoRec->rec.redir.redirectingNumber.len,
2710 CDMA_NUMBER_INFO_BUFFER_LENGTH);
2711 return RIL_ERRNO_INVALID_RESPONSE;
2712 }
2713 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber
2714 .len + 1) * sizeof(char) );
2715 for (int i = 0;
2716 i < infoRec->rec.redir.redirectingNumber.len;
2717 i++) {
2718 string8[i] = infoRec->rec.redir.redirectingNumber.buf[i];
2719 }
2720 string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0';
2721 writeStringToParcel(p, (const char*)string8);
2722 free(string8);
2723 string8 = NULL;
2724 p.writeInt32(infoRec->rec.redir.redirectingNumber.number_type);
2725 p.writeInt32(infoRec->rec.redir.redirectingNumber.number_plan);
2726 p.writeInt32(infoRec->rec.redir.redirectingNumber.pi);
2727 p.writeInt32(infoRec->rec.redir.redirectingNumber.si);
2728 p.writeInt32(infoRec->rec.redir.redirectingReason);
2729 break;
2730 case RIL_CDMA_LINE_CONTROL_INFO_REC:
2731 p.writeInt32(infoRec->rec.lineCtrl.lineCtrlPolarityIncluded);
2732 p.writeInt32(infoRec->rec.lineCtrl.lineCtrlToggle);
2733 p.writeInt32(infoRec->rec.lineCtrl.lineCtrlReverse);
2734 p.writeInt32(infoRec->rec.lineCtrl.lineCtrlPowerDenial);
2735
2736 appendPrintBuf("%slineCtrlPolarityIncluded=%d, \
2737 lineCtrlToggle=%d, lineCtrlReverse=%d, \
2738 lineCtrlPowerDenial=%d, ", printBuf,
2739 (int)infoRec->rec.lineCtrl.lineCtrlPolarityIncluded,
2740 (int)infoRec->rec.lineCtrl.lineCtrlToggle,
2741 (int)infoRec->rec.lineCtrl.lineCtrlReverse,
2742 (int)infoRec->rec.lineCtrl.lineCtrlPowerDenial);
2743 removeLastChar;
2744 break;
2745 case RIL_CDMA_T53_CLIR_INFO_REC:
2746 p.writeInt32((int)(infoRec->rec.clir.cause));
2747
2748 appendPrintBuf("%scause%d", printBuf, infoRec->rec.clir.cause);
2749 removeLastChar;
2750 break;
2751 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC:
2752 p.writeInt32(infoRec->rec.audioCtrl.upLink);
2753 p.writeInt32(infoRec->rec.audioCtrl.downLink);
2754
2755 appendPrintBuf("%supLink=%d, downLink=%d, ", printBuf,
2756 infoRec->rec.audioCtrl.upLink,
2757 infoRec->rec.audioCtrl.downLink);
2758 removeLastChar;
2759 break;
2760 case RIL_CDMA_T53_RELEASE_INFO_REC:
2761 // TODO(Moto): See David Krause, he has the answer:)
2762 RLOGE("RIL_CDMA_T53_RELEASE_INFO_REC: return INVALID_RESPONSE");
2763 return RIL_ERRNO_INVALID_RESPONSE;
2764 default:
2765 RLOGE("Incorrect name value");
2766 return RIL_ERRNO_INVALID_RESPONSE;
2767 }
2768 }
2769 closeResponse;
2770
2771 return 0;
2772}
2773
2774static int responseRilSignalStrength(Parcel &p,
2775 void *response, size_t responselen) {
2776 if (response == NULL && responselen != 0) {
2777 RLOGE("invalid response: NULL");
2778 return RIL_ERRNO_INVALID_RESPONSE;
2779 }
2780
2781 if (responselen >= sizeof (RIL_SignalStrength_v5)) {
2782#ifdef TELEMATIC_5G_SUPPORT
2783 RIL_SignalStrength_v14 *p_cur = ((RIL_SignalStrength_v14 *) response);
2784#else
2785 RIL_SignalStrength_v10 *p_cur = ((RIL_SignalStrength_v10 *) response);
2786#endif
2787 p.writeInt32(p_cur->GW_SignalStrength.signalStrength);
2788 p.writeInt32(p_cur->GW_SignalStrength.bitErrorRate);
2789 p.writeInt32(p_cur->GW_SignalStrength.timingAdvance);
2790 p.writeInt32(p_cur->CDMA_SignalStrength.dbm);
2791 p.writeInt32(p_cur->CDMA_SignalStrength.ecio);
2792 p.writeInt32(p_cur->EVDO_SignalStrength.dbm);
2793 p.writeInt32(p_cur->EVDO_SignalStrength.ecio);
2794 p.writeInt32(p_cur->EVDO_SignalStrength.signalNoiseRatio);
2795 p.writeInt32(p_cur->LTE_SignalStrength.signalStrength);
2796 p.writeInt32(p_cur->LTE_SignalStrength.rsrp);
2797 p.writeInt32(p_cur->LTE_SignalStrength.rsrq);
2798 p.writeInt32(p_cur->LTE_SignalStrength.rssnr);
2799 p.writeInt32(p_cur->LTE_SignalStrength.cqi);
2800 p.writeInt32(p_cur->LTE_SignalStrength.timingAdvance);
2801 p.writeInt32(p_cur->TD_SCDMA_SignalStrength.signalStrength);
2802 p.writeInt32(p_cur->TD_SCDMA_SignalStrength.bitErrorRate);
2803 p.writeInt32(p_cur->TD_SCDMA_SignalStrength.rscp);
2804 p.writeInt32(p_cur->WCDMA_SignalStrength.signalStrength);
2805 p.writeInt32(p_cur->WCDMA_SignalStrength.bitErrorRate);
2806 p.writeInt32(p_cur->WCDMA_SignalStrength.rscp);
2807 p.writeInt32(p_cur->WCDMA_SignalStrength.ecno);
2808#ifdef TELEMATIC_5G_SUPPORT
2809 p.writeInt32(p_cur->NR_SignalStrength.ssRsrp);
2810 p.writeInt32(p_cur->NR_SignalStrength.ssRsrq);
2811 p.writeInt32(p_cur->NR_SignalStrength.ssSinr);
2812 p.writeInt32(p_cur->NR_SignalStrength.csiRsrp);
2813 p.writeInt32(p_cur->NR_SignalStrength.csiRsrq);
2814 p.writeInt32(p_cur->NR_SignalStrength.csiSinr);
2815#endif
2816 startResponse;
2817
2818#ifdef TELEMATIC_5G_SUPPORT
2819 appendPrintBuf("%s[GW_SS.signalStrength=%d,GW_SS.bitErrorRate=%d,GW_SS.timingAdvance=%d,\
2820 CDMA_SS.dbm=%d,CDMA_SS.ecio=%d,\
2821 EVDO_SS.dbm=%d,EVDO_SS.ecio=%d,EVDO_SS.signalNoiseRatio=%d,\
2822 LTE_SS.signalStrength=%d,LTE_SS.rsrp=%d,LTE_SS.rsrq=%d,LTE_SS.rssnr=%d,LTE_SS.cqi=%d,LTE_SS.timingAdvance=%d,\
2823 TDSCDMA_SS.signalStrength=%d,TDSCDMA_SS.bitErrorRate=%d,TDSCDMA_SS.rscp=%d,\
2824 WCDMA_SS.signalStrength=%d,WCDMA_SS.bitErrorRate=%d,WCDMA_SS.rscp=%d,WCDMA_SS.ecno=%d,\
2825 NR_SignalStrength.ssRsrp=%d,NR_SignalStrength.ssRsrq=%d,NR_SignalStrength.ssSinr=%d,\
2826 NR_SignalStrength.csiRsrp=%d,NR_SignalStrength.csiRsrq=%d,NR_SignalStrength.csiSinr=%d]",
2827 printBuf,
2828 p_cur->GW_SignalStrength.signalStrength,
2829 p_cur->GW_SignalStrength.bitErrorRate,
2830 p_cur->GW_SignalStrength.timingAdvance,
2831 p_cur->CDMA_SignalStrength.dbm,
2832 p_cur->CDMA_SignalStrength.ecio,
2833 p_cur->EVDO_SignalStrength.dbm,
2834 p_cur->EVDO_SignalStrength.ecio,
2835 p_cur->EVDO_SignalStrength.signalNoiseRatio,
2836 p_cur->LTE_SignalStrength.signalStrength,
2837 p_cur->LTE_SignalStrength.rsrp,
2838 p_cur->LTE_SignalStrength.rsrq,
2839 p_cur->LTE_SignalStrength.rssnr,
2840 p_cur->LTE_SignalStrength.cqi,
2841 p_cur->LTE_SignalStrength.timingAdvance,
2842 p_cur->TD_SCDMA_SignalStrength.signalStrength,
2843 p_cur->TD_SCDMA_SignalStrength.bitErrorRate,
2844 p_cur->TD_SCDMA_SignalStrength.rscp,
2845 p_cur->WCDMA_SignalStrength.signalStrength,
2846 p_cur->WCDMA_SignalStrength.bitErrorRate,
2847 p_cur->WCDMA_SignalStrength.rscp,
2848 p_cur->WCDMA_SignalStrength.ecno,
2849 p_cur->NR_SignalStrength.ssRsrp,
2850 p_cur->NR_SignalStrength.ssRsrq,
2851 p_cur->NR_SignalStrength.ssSinr,
2852 p_cur->NR_SignalStrength.csiRsrp,
2853 p_cur->NR_SignalStrength.csiRsrq,
2854 p_cur->NR_SignalStrength.csiSinr);
2855#else
2856 appendPrintBuf("%s[GW_SS.signalStrength=%d,GW_SS.bitErrorRate=%d,GW_SS.timingAdvance=%d,\
2857 CDMA_SS.dbm=%d,CDMA_SS.ecio=%d,\
2858 EVDO_SS.dbm=%d,EVDO_SS.ecio=%d,EVDO_SS.signalNoiseRatio=%d,\
2859 LTE_SS.signalStrength=%d,LTE_SS.rsrp=%d,LTE_SS.rsrq=%d,LTE_SS.rssnr=%d,LTE_SS.cqi=%d,LTE_SS.timingAdvance=%d,\
2860 TDSCDMA_SS.signalStrength=%d,TDSCDMA_SS.bitErrorRate=%d,TDSCDMA_SS.rscp=%d,\
2861 WCDMA_SS.signalStrength=%d,WCDMA_SS.bitErrorRate=%d,WCDMA_SS.rscp=%d,WCDMA_SS.ecno=%d]",
2862 printBuf,
2863 p_cur->GW_SignalStrength.signalStrength,
2864 p_cur->GW_SignalStrength.bitErrorRate,
2865 p_cur->GW_SignalStrength.timingAdvance,
2866 p_cur->CDMA_SignalStrength.dbm,
2867 p_cur->CDMA_SignalStrength.ecio,
2868 p_cur->EVDO_SignalStrength.dbm,
2869 p_cur->EVDO_SignalStrength.ecio,
2870 p_cur->EVDO_SignalStrength.signalNoiseRatio,
2871 p_cur->LTE_SignalStrength.signalStrength,
2872 p_cur->LTE_SignalStrength.rsrp,
2873 p_cur->LTE_SignalStrength.rsrq,
2874 p_cur->LTE_SignalStrength.rssnr,
2875 p_cur->LTE_SignalStrength.cqi,
2876 p_cur->LTE_SignalStrength.timingAdvance,
2877 p_cur->TD_SCDMA_SignalStrength.signalStrength,
2878 p_cur->TD_SCDMA_SignalStrength.bitErrorRate,
2879 p_cur->TD_SCDMA_SignalStrength.rscp,
2880 p_cur->WCDMA_SignalStrength.signalStrength,
2881 p_cur->WCDMA_SignalStrength.bitErrorRate,
2882 p_cur->WCDMA_SignalStrength.rscp,
2883 p_cur->WCDMA_SignalStrength.ecno);
2884#endif
2885 closeResponse;
2886
2887 if (signal_strength_printf != 0) {
2888 printf(
2889 "\n\n[QUERY][SIGNAL]\nsignalStrength=%d,\nbitErrorRate=%d,\nLTE_SS.signalStrength=%d,\n"
2890 "LTE_SS.rsrp=%d,\nLTE_SS.rsrq=%d,\nLTE_SS.rssnr=%d,\nLTE_SS.cqi=%d\n\n",
2891 p_cur->GW_SignalStrength.signalStrength,
2892 p_cur->GW_SignalStrength.bitErrorRate,
2893 p_cur->LTE_SignalStrength.signalStrength,
2894 p_cur->LTE_SignalStrength.rsrp,
2895 p_cur->LTE_SignalStrength.rsrq,
2896 p_cur->LTE_SignalStrength.rssnr,
2897 p_cur->LTE_SignalStrength.cqi);
2898 }
2899 } else {
2900 RLOGE("invalid response length");
2901 return RIL_ERRNO_INVALID_RESPONSE;
2902 }
2903
2904 return 0;
2905}
2906
2907static int responseCallRing(Parcel &p, void *response, size_t responselen) {
2908 if ((response == NULL) || (responselen == 0)) {
2909 return responseVoid(p, response, responselen);
2910 } else {
2911 return responseCdmaSignalInfoRecord(p, response, responselen);
2912 }
2913}
2914
2915static int responseCdmaSignalInfoRecord(Parcel &p, void *response, size_t responselen) {
2916 if (response == NULL || responselen == 0) {
2917 RLOGE("invalid response: NULL");
2918 return RIL_ERRNO_INVALID_RESPONSE;
2919 }
2920
2921 if (responselen != sizeof (RIL_CDMA_SignalInfoRecord)) {
2922 RLOGE("invalid response length %d expected sizeof (RIL_CDMA_SignalInfoRecord) of %d\n",
2923 (int)responselen, (int)sizeof (RIL_CDMA_SignalInfoRecord));
2924 return RIL_ERRNO_INVALID_RESPONSE;
2925 }
2926
2927 startResponse;
2928
2929 RIL_CDMA_SignalInfoRecord *p_cur = ((RIL_CDMA_SignalInfoRecord *) response);
2930 marshallSignalInfoRecord(p, *p_cur);
2931
2932 appendPrintBuf("%s[isPresent=%d,signalType=%d,alertPitch=%d\
2933 signal=%d]",
2934 printBuf,
2935 p_cur->isPresent,
2936 p_cur->signalType,
2937 p_cur->alertPitch,
2938 p_cur->signal);
2939
2940 closeResponse;
2941 return 0;
2942}
2943
2944static int responseCdmaCallWaiting(Parcel &p, void *response,
2945 size_t responselen) {
2946 if (response == NULL && responselen != 0) {
2947 RLOGE("invalid response: NULL");
2948 return RIL_ERRNO_INVALID_RESPONSE;
2949 }
2950
2951 if (responselen < sizeof(RIL_CDMA_CallWaiting_v6)) {
2952 RLOGW("Upgrade to ril version %d\n", RIL_VERSION);
2953 }
2954
2955 RIL_CDMA_CallWaiting_v6 *p_cur = ((RIL_CDMA_CallWaiting_v6 *) response);
2956
2957 writeStringToParcel(p, p_cur->number);
2958 p.writeInt32(p_cur->numberPresentation);
2959 writeStringToParcel(p, p_cur->name);
2960 marshallSignalInfoRecord(p, p_cur->signalInfoRecord);
2961
2962 if (responselen >= sizeof(RIL_CDMA_CallWaiting_v6)) {
2963 p.writeInt32(p_cur->number_type);
2964 p.writeInt32(p_cur->number_plan);
2965 } else {
2966 p.writeInt32(0);
2967 p.writeInt32(0);
2968 }
2969
2970 printf("[EVENT][MT_CALL] phone number is %s\n",p_cur->number);
2971 startResponse;
2972 appendPrintBuf("%snumber=%s,numberPresentation=%d, name=%s,\
2973 signalInfoRecord[isPresent=%d,signalType=%d,alertPitch=%d\
2974 signal=%d,number_type=%d,number_plan=%d]",
2975 printBuf,
2976 p_cur->number,
2977 p_cur->numberPresentation,
2978 p_cur->name,
2979 p_cur->signalInfoRecord.isPresent,
2980 p_cur->signalInfoRecord.signalType,
2981 p_cur->signalInfoRecord.alertPitch,
2982 p_cur->signalInfoRecord.signal,
2983 p_cur->number_type,
2984 p_cur->number_plan);
2985 closeResponse;
2986
2987 return 0;
2988}
2989
2990static int responseSimRefresh(Parcel &p, void *response, size_t responselen) {
2991 if (response == NULL && responselen != 0) {
2992 RLOGE("responseSimRefresh: invalid response: NULL");
2993 return RIL_ERRNO_INVALID_RESPONSE;
2994 }
2995
2996 startResponse;
2997 if (s_callbacks.version == 7) {
2998 RIL_SimRefreshResponse_v7 *p_cur = ((RIL_SimRefreshResponse_v7 *) response);
2999 p.writeInt32(p_cur->result);
3000 p.writeInt32(p_cur->ef_id);
3001 writeStringToParcel(p, p_cur->aid);
3002
3003 appendPrintBuf("%sresult=%d, ef_id=%d, aid=%s",
3004 printBuf,
3005 p_cur->result,
3006 p_cur->ef_id,
3007 p_cur->aid);
3008 } else {
3009 int *p_cur = ((int *) response);
3010 p.writeInt32(p_cur[0]);
3011 p.writeInt32(p_cur[1]);
3012 writeStringToParcel(p, NULL);
3013
3014 appendPrintBuf("%sresult=%d, ef_id=%d",
3015 printBuf,
3016 p_cur[0],
3017 p_cur[1]);
3018 }
3019 closeResponse;
3020
3021 return 0;
3022}
3023
3024static int responseCellInfoList(Parcel &p, void *response, size_t responselen)
3025{
3026 if (response == NULL && responselen != 0) {
3027 RLOGE("invalid response: NULL");
3028 return RIL_ERRNO_INVALID_RESPONSE;
3029 }
3030
3031 if (responselen % sizeof(RIL_CellInfo) != 0) {
3032 RLOGE("responseCellInfoList: invalid response length %d expected multiple of %d",
3033 (int)responselen, (int)sizeof(RIL_CellInfo));
3034 return RIL_ERRNO_INVALID_RESPONSE;
3035 }
3036
3037 int num = responselen / sizeof(RIL_CellInfo);
3038 p.writeInt32(num);
3039
3040 RIL_CellInfo *p_cur = (RIL_CellInfo *) response;
3041 startResponse;
3042 int i;
3043 for (i = 0; i < num; i++) {
3044 appendPrintBuf("%s[%d: type=%d,registered=%d,timeStampType=%d,timeStamp=%lld", printBuf, i,
3045 p_cur->cellInfoType, p_cur->registered, p_cur->timeStampType, p_cur->timeStamp);
3046 p.writeInt32((int)p_cur->cellInfoType);
3047 p.writeInt32(p_cur->registered);
3048 p.writeInt32(p_cur->timeStampType);
3049 p.writeInt64(p_cur->timeStamp);
3050 switch(p_cur->cellInfoType) {
3051 case RIL_CELL_INFO_TYPE_GSM: {
3052 appendPrintBuf("%s GSM id: mcc=%d,mnc=%d,lac=%d,cid=%d,", printBuf,
3053 p_cur->CellInfo.gsm.cellIdentityGsm.mcc,
3054 p_cur->CellInfo.gsm.cellIdentityGsm.mnc,
3055 p_cur->CellInfo.gsm.cellIdentityGsm.lac,
3056 p_cur->CellInfo.gsm.cellIdentityGsm.cid);
3057 appendPrintBuf("%s gsmSS: ss=%d,ber=%d],", printBuf,
3058 p_cur->CellInfo.gsm.signalStrengthGsm.signalStrength,
3059 p_cur->CellInfo.gsm.signalStrengthGsm.bitErrorRate);
3060
3061 p.writeInt32(p_cur->CellInfo.gsm.cellIdentityGsm.mcc);
3062 p.writeInt32(p_cur->CellInfo.gsm.cellIdentityGsm.mnc);
3063 p.writeInt32(p_cur->CellInfo.gsm.cellIdentityGsm.lac);
3064 p.writeInt32(p_cur->CellInfo.gsm.cellIdentityGsm.cid);
3065 p.writeInt32(p_cur->CellInfo.gsm.signalStrengthGsm.signalStrength);
3066 p.writeInt32(p_cur->CellInfo.gsm.signalStrengthGsm.bitErrorRate);
3067 break;
3068 }
3069 case RIL_CELL_INFO_TYPE_WCDMA: {
3070 appendPrintBuf("%s WCDMA id: mcc=%d,mnc=%d,lac=%d,cid=%d,psc=%d,", printBuf,
3071 p_cur->CellInfo.wcdma.cellIdentityWcdma.mcc,
3072 p_cur->CellInfo.wcdma.cellIdentityWcdma.mnc,
3073 p_cur->CellInfo.wcdma.cellIdentityWcdma.lac,
3074 p_cur->CellInfo.wcdma.cellIdentityWcdma.cid,
3075 p_cur->CellInfo.wcdma.cellIdentityWcdma.psc);
3076 appendPrintBuf("%s wcdmaSS: ss=%d,ber=%d],", printBuf,
3077 p_cur->CellInfo.wcdma.signalStrengthWcdma.signalStrength,
3078 p_cur->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate);
3079
3080 p.writeInt32(p_cur->CellInfo.wcdma.cellIdentityWcdma.mcc);
3081 p.writeInt32(p_cur->CellInfo.wcdma.cellIdentityWcdma.mnc);
3082 p.writeInt32(p_cur->CellInfo.wcdma.cellIdentityWcdma.lac);
3083 p.writeInt32(p_cur->CellInfo.wcdma.cellIdentityWcdma.cid);
3084 p.writeInt32(p_cur->CellInfo.wcdma.cellIdentityWcdma.psc);
3085 p.writeInt32(p_cur->CellInfo.wcdma.signalStrengthWcdma.signalStrength);
3086 p.writeInt32(p_cur->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate);
3087 break;
3088 }
3089 case RIL_CELL_INFO_TYPE_CDMA: {
3090 appendPrintBuf("%s CDMA id: nId=%d,sId=%d,bsId=%d,long=%d,lat=%d", printBuf,
3091 p_cur->CellInfo.cdma.cellIdentityCdma.networkId,
3092 p_cur->CellInfo.cdma.cellIdentityCdma.systemId,
3093 p_cur->CellInfo.cdma.cellIdentityCdma.basestationId,
3094 p_cur->CellInfo.cdma.cellIdentityCdma.longitude,
3095 p_cur->CellInfo.cdma.cellIdentityCdma.latitude);
3096
3097 p.writeInt32(p_cur->CellInfo.cdma.cellIdentityCdma.networkId);
3098 p.writeInt32(p_cur->CellInfo.cdma.cellIdentityCdma.systemId);
3099 p.writeInt32(p_cur->CellInfo.cdma.cellIdentityCdma.basestationId);
3100 p.writeInt32(p_cur->CellInfo.cdma.cellIdentityCdma.longitude);
3101 p.writeInt32(p_cur->CellInfo.cdma.cellIdentityCdma.latitude);
3102
3103 appendPrintBuf("%s cdmaSS: dbm=%d ecio=%d evdoSS: dbm=%d,ecio=%d,snr=%d", printBuf,
3104 p_cur->CellInfo.cdma.signalStrengthCdma.dbm,
3105 p_cur->CellInfo.cdma.signalStrengthCdma.ecio,
3106 p_cur->CellInfo.cdma.signalStrengthEvdo.dbm,
3107 p_cur->CellInfo.cdma.signalStrengthEvdo.ecio,
3108 p_cur->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio);
3109
3110 p.writeInt32(p_cur->CellInfo.cdma.signalStrengthCdma.dbm);
3111 p.writeInt32(p_cur->CellInfo.cdma.signalStrengthCdma.ecio);
3112 p.writeInt32(p_cur->CellInfo.cdma.signalStrengthEvdo.dbm);
3113 p.writeInt32(p_cur->CellInfo.cdma.signalStrengthEvdo.ecio);
3114 p.writeInt32(p_cur->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio);
3115 break;
3116 }
3117 case RIL_CELL_INFO_TYPE_LTE: {
3118 appendPrintBuf("%s LTE id: mcc=%d,mnc=%d,ci=%d,pci=%d,tac=%d", printBuf,
3119 p_cur->CellInfo.lte.cellIdentityLte.mcc,
3120 p_cur->CellInfo.lte.cellIdentityLte.mnc,
3121 p_cur->CellInfo.lte.cellIdentityLte.ci,
3122 p_cur->CellInfo.lte.cellIdentityLte.pci,
3123 p_cur->CellInfo.lte.cellIdentityLte.tac);
3124
3125 p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.mcc);
3126 p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.mnc);
3127 p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.ci);
3128 p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.pci);
3129 p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.tac);
3130
3131 appendPrintBuf("%s lteSS: ss=%d,rsrp=%d,rsrq=%d,rssnr=%d,cqi=%d,ta=%d", printBuf,
3132 p_cur->CellInfo.lte.signalStrengthLte.signalStrength,
3133 p_cur->CellInfo.lte.signalStrengthLte.rsrp,
3134 p_cur->CellInfo.lte.signalStrengthLte.rsrq,
3135 p_cur->CellInfo.lte.signalStrengthLte.rssnr,
3136 p_cur->CellInfo.lte.signalStrengthLte.cqi,
3137 p_cur->CellInfo.lte.signalStrengthLte.timingAdvance);
3138 p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.signalStrength);
3139 p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.rsrp);
3140 p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.rsrq);
3141 p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.rssnr);
3142 p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.cqi);
3143 p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.timingAdvance);
3144 break;
3145 }
3146 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
3147 appendPrintBuf("%s TDSCDMA id: mcc=%d,mnc=%d,lac=%d,cid=%d,cpid=%d,", printBuf,
3148 p_cur->CellInfo.tdscdma.cellIdentityTdscdma.mcc,
3149 p_cur->CellInfo.tdscdma.cellIdentityTdscdma.mnc,
3150 p_cur->CellInfo.tdscdma.cellIdentityTdscdma.lac,
3151 p_cur->CellInfo.tdscdma.cellIdentityTdscdma.cid,
3152 p_cur->CellInfo.tdscdma.cellIdentityTdscdma.cpid);
3153 appendPrintBuf("%s tdscdmaSS: rscp=%d],", printBuf,
3154 p_cur->CellInfo.tdscdma.signalStrengthTdscdma.rscp);
3155
3156 p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
3157 p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
3158 p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.lac);
3159 p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.cid);
3160 p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.cpid);
3161 p.writeInt32(p_cur->CellInfo.tdscdma.signalStrengthTdscdma.rscp);
3162 break;
3163 }
3164#ifdef TELEMATIC_5G_SUPPORT
3165 case RIL_CELL_INFO_TYPE_NR: {
3166 appendPrintBuf("%s NR id: mcc=%d,mnc=%d,nci=%d,pci=%d,tac=%d", printBuf,
3167 p_cur->CellInfo.nr.cellidentity.mcc,
3168 p_cur->CellInfo.nr.cellidentity.mnc,
3169 p_cur->CellInfo.nr.cellidentity.nci,
3170 p_cur->CellInfo.nr.cellidentity.pci,
3171 p_cur->CellInfo.nr.cellidentity.tac,
3172 p_cur->CellInfo.nr.cellidentity.nrarfcn);
3173
3174 p.writeInt32(p_cur->CellInfo.nr.cellidentity.mcc);
3175 p.writeInt32(p_cur->CellInfo.nr.cellidentity.mnc);
3176 p.writeInt32(p_cur->CellInfo.nr.cellidentity.nci);
3177 p.writeInt32(p_cur->CellInfo.nr.cellidentity.pci);
3178 p.writeInt32(p_cur->CellInfo.nr.cellidentity.tac);
3179 p.writeInt32(p_cur->CellInfo.nr.cellidentity.nrarfcn);
3180
3181 appendPrintBuf("%s NRSS: ssRsrp=%d,ssRsrq=%d,ssSinr=%d,csiRsrp=%d,csiRsrq=%d,csiSinr=%d", printBuf,
3182 p_cur->CellInfo.nr.signalStrength.ssRsrp,
3183 p_cur->CellInfo.nr.signalStrength.ssRsrq,
3184 p_cur->CellInfo.nr.signalStrength.ssSinr,
3185 p_cur->CellInfo.nr.signalStrength.csiRsrp,
3186 p_cur->CellInfo.nr.signalStrength.csiRsrq,
3187 p_cur->CellInfo.nr.signalStrength.csiSinr);
3188 p.writeInt32(p_cur->CellInfo.nr.signalStrength.ssRsrp);
3189 p.writeInt32(p_cur->CellInfo.nr.signalStrength.ssRsrq);
3190 p.writeInt32(p_cur->CellInfo.nr.signalStrength.ssSinr);
3191 p.writeInt32(p_cur->CellInfo.nr.signalStrength.csiRsrp);
3192 p.writeInt32(p_cur->CellInfo.nr.signalStrength.csiRsrq);
3193 p.writeInt32(p_cur->CellInfo.nr.signalStrength.csiSinr);
3194 break;
3195 }
3196#endif
3197 }
3198 p_cur += 1;
3199 }
3200 removeLastChar;
3201 closeResponse;
3202
3203 return 0;
3204}
3205
3206static int responseHardwareConfig(Parcel &p, void *response, size_t responselen)
3207{
3208 if (response == NULL && responselen != 0) {
3209 RLOGE("invalid response: NULL");
3210 return RIL_ERRNO_INVALID_RESPONSE;
3211 }
3212
3213 if (responselen % sizeof(RIL_HardwareConfig) != 0) {
3214 RLOGE("responseHardwareConfig: invalid response length %d expected multiple of %d",
3215 (int)responselen, (int)sizeof(RIL_HardwareConfig));
3216 return RIL_ERRNO_INVALID_RESPONSE;
3217 }
3218
3219 int num = responselen / sizeof(RIL_HardwareConfig);
3220 int i;
3221 RIL_HardwareConfig *p_cur = (RIL_HardwareConfig *) response;
3222
3223 p.writeInt32(num);
3224
3225 startResponse;
3226 for (i = 0; i < num; i++) {
3227 switch (p_cur[i].type) {
3228 case RIL_HARDWARE_CONFIG_MODEM: {
3229 writeStringToParcel(p, p_cur[i].uuid);
3230 p.writeInt32((int)p_cur[i].state);
3231 p.writeInt32(p_cur[i].cfg.modem.rat);
3232 p.writeInt32(p_cur[i].cfg.modem.maxVoice);
3233 p.writeInt32(p_cur[i].cfg.modem.maxData);
3234 p.writeInt32(p_cur[i].cfg.modem.maxStandby);
3235
3236 appendPrintBuf("%s modem: uuid=%s,state=%d,rat=%08x,maxV=%d,maxD=%d,maxS=%d", printBuf,
3237 p_cur[i].uuid, (int)p_cur[i].state, p_cur[i].cfg.modem.rat,
3238 p_cur[i].cfg.modem.maxVoice, p_cur[i].cfg.modem.maxData, p_cur[i].cfg.modem.maxStandby);
3239 break;
3240 }
3241 case RIL_HARDWARE_CONFIG_SIM: {
3242 writeStringToParcel(p, p_cur[i].uuid);
3243 p.writeInt32((int)p_cur[i].state);
3244 writeStringToParcel(p, p_cur[i].cfg.sim.modemUuid);
3245
3246 appendPrintBuf("%s sim: uuid=%s,state=%d,modem-uuid=%s", printBuf,
3247 p_cur[i].uuid, (int)p_cur[i].state, p_cur[i].cfg.sim.modemUuid);
3248 break;
3249 }
3250 }
3251 }
3252 removeLastChar;
3253 closeResponse;
3254 return 0;
3255}
3256
3257static int responseRadioCapability(Parcel &p, void *response, size_t responselen) {
3258 if (response == NULL) {
3259 RLOGE("invalid response: NULL");
3260 return RIL_ERRNO_INVALID_RESPONSE;
3261 }
3262
3263 if (responselen != sizeof (RIL_RadioCapability) ) {
3264 RLOGE("invalid response length was %d expected %d",
3265 (int)responselen, (int)sizeof (RIL_SIM_IO_Response));
3266 return RIL_ERRNO_INVALID_RESPONSE;
3267 }
3268
3269 RIL_RadioCapability *p_cur = (RIL_RadioCapability *) response;
3270 p.writeInt32(p_cur->version);
3271 p.writeInt32(p_cur->session);
3272 p.writeInt32(p_cur->phase);
3273 p.writeInt32(p_cur->rat);
3274 writeStringToParcel(p, p_cur->logicalModemUuid);
3275 p.writeInt32(p_cur->status);
3276
3277 startResponse;
3278 appendPrintBuf("%s[version=%d,session=%d,phase=%d,\
3279 rat=%d,logicalModemUuid=%s,status=%d]",
3280 printBuf,
3281 p_cur->version,
3282 p_cur->session,
3283 p_cur->phase,
3284 p_cur->rat,
3285 p_cur->logicalModemUuid,
3286 p_cur->status);
3287 closeResponse;
3288 return 0;
3289}
3290
3291static int responseSSData(Parcel &p, void *response, size_t responselen) {
3292 RLOGD("In responseSSData");
3293 int num;
3294
3295 if (response == NULL && responselen != 0) {
3296 RLOGE("invalid response length was %d expected %d",
3297 (int)responselen, (int)sizeof (RIL_SIM_IO_Response));
3298 return RIL_ERRNO_INVALID_RESPONSE;
3299 }
3300
3301 if (responselen != sizeof(RIL_StkCcUnsolSsResponse)) {
3302 RLOGE("invalid response length %d, expected %d",
3303 (int)responselen, (int)sizeof(RIL_StkCcUnsolSsResponse));
3304 return RIL_ERRNO_INVALID_RESPONSE;
3305 }
3306
3307 startResponse;
3308 RIL_StkCcUnsolSsResponse *p_cur = (RIL_StkCcUnsolSsResponse *) response;
3309 p.writeInt32(p_cur->serviceType);
3310 p.writeInt32(p_cur->requestType);
3311 p.writeInt32(p_cur->teleserviceType);
3312 p.writeInt32(p_cur->serviceClass);
3313 p.writeInt32(p_cur->result);
3314
3315 if (isServiceTypeCfQuery(p_cur->serviceType, p_cur->requestType)) {
3316 RLOGD("responseSSData CF type, num of Cf elements %d", p_cur->cfData.numValidIndexes);
3317 if (p_cur->cfData.numValidIndexes > NUM_SERVICE_CLASSES) {
3318 RLOGE("numValidIndexes is greater than max value %d, "
3319 "truncating it to max value", NUM_SERVICE_CLASSES);
3320 p_cur->cfData.numValidIndexes = NUM_SERVICE_CLASSES;
3321 }
3322 /* number of call info's */
3323 p.writeInt32(p_cur->cfData.numValidIndexes);
3324
3325 for (int i = 0; i < p_cur->cfData.numValidIndexes; i++) {
3326 RIL_CallForwardInfo cf = p_cur->cfData.cfInfo[i];
3327
3328 p.writeInt32(cf.status);
3329 p.writeInt32(cf.reason);
3330 p.writeInt32(cf.serviceClass);
3331 p.writeInt32(cf.toa);
3332 writeStringToParcel(p, cf.number);
3333 p.writeInt32(cf.timeSeconds);
3334 appendPrintBuf("%s[%s,reason=%d,cls=%d,toa=%d,%s,tout=%d],", printBuf,
3335 (cf.status==1)?"enable":"disable", cf.reason, cf.serviceClass, cf.toa,
3336 (char*)cf.number, cf.timeSeconds);
3337 RLOGD("Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status,
3338 cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds);
3339 }
3340 } else {
3341 p.writeInt32 (SS_INFO_MAX);
3342
3343 /* each int*/
3344 for (int i = 0; i < SS_INFO_MAX; i++) {
3345 appendPrintBuf("%s%d,", printBuf, p_cur->ssInfo[i]);
3346 RLOGD("Data: %d",p_cur->ssInfo[i]);
3347 p.writeInt32(p_cur->ssInfo[i]);
3348 }
3349 }
3350 removeLastChar;
3351 closeResponse;
3352
3353 return 0;
3354}
3355
3356static bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) {
3357 if ((reqType == SS_INTERROGATION) &&
3358 (serType == SS_CFU ||
3359 serType == SS_CF_BUSY ||
3360 serType == SS_CF_NO_REPLY ||
3361 serType == SS_CF_NOT_REACHABLE ||
3362 serType == SS_CF_ALL ||
3363 serType == SS_CF_ALL_CONDITIONAL)) {
3364 return true;
3365 }
3366 return false;
3367}
3368
3369static void sendSimStatusAppInfo(Parcel &p, int num_apps, RIL_AppStatus appStatus[]) {
3370 p.writeInt32(num_apps);
3371 startResponse;
3372 for (int i = 0; i < num_apps; i++) {
3373 p.writeInt32(appStatus[i].app_type);
3374 p.writeInt32(appStatus[i].app_state);
3375 p.writeInt32(appStatus[i].perso_substate);
3376 writeStringToParcel(p, (const char*)(appStatus[i].aid_ptr));
3377 writeStringToParcel(p, (const char*)
3378 (appStatus[i].app_label_ptr));
3379 p.writeInt32(appStatus[i].pin1_replaced);
3380 p.writeInt32(appStatus[i].pin1);
3381 p.writeInt32(appStatus[i].pin2);
3382 appendPrintBuf("%s[app_type=%d,app_state=%d,perso_substate=%d,\
3383 aid_ptr=%s,app_label_ptr=%s,pin1_replaced=%d,pin1=%d,pin2=%d],",
3384 printBuf,
3385 appStatus[i].app_type,
3386 appStatus[i].app_state,
3387 appStatus[i].perso_substate,
3388 appStatus[i].aid_ptr,
3389 appStatus[i].app_label_ptr,
3390 appStatus[i].pin1_replaced,
3391 appStatus[i].pin1,
3392 appStatus[i].pin2);
3393 }
3394 closeResponse;
3395}
3396
3397static int responseSimStatus(Parcel &p, void *response, size_t responselen) {
3398 int i;
3399
3400 if (response == NULL && responselen != 0) {
3401 RLOGE("invalid response: NULL");
3402 return RIL_ERRNO_INVALID_RESPONSE;
3403 }
3404
3405 RLOGD("responselen: %d, v6: %d, v5: %d", responselen, sizeof (RIL_CardStatus_v6),sizeof (RIL_CardStatus_v5));
3406 if (responselen == sizeof (RIL_CardStatus_v6)) {
3407 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
3408 p.writeInt32(p_cur->card_state);
3409 p.writeInt32(p_cur->universal_pin_state);
3410 p.writeInt32(p_cur->gsm_umts_subscription_app_index);
3411 p.writeInt32(p_cur->cdma_subscription_app_index);
3412 p.writeInt32(p_cur->ims_subscription_app_index);
3413
3414 sendSimStatusAppInfo(p, p_cur->num_applications, p_cur->applications);
3415 } else if (responselen == sizeof (RIL_CardStatus_v5)) {
3416 RIL_CardStatus_v5 *p_cur = ((RIL_CardStatus_v5 *) response);
3417
3418 p.writeInt32(p_cur->card_state);
3419 p.writeInt32(p_cur->universal_pin_state);
3420 p.writeInt32(p_cur->gsm_umts_subscription_app_index);
3421 p.writeInt32(p_cur->cdma_subscription_app_index);
3422 p.writeInt32(-1);
3423
3424 sendSimStatusAppInfo(p, p_cur->num_applications, p_cur->applications);
3425 } else {
3426 RLOGE("responseSimStatus: A RilCardStatus_v6 or _v5 expected\n");
3427 return RIL_ERRNO_INVALID_RESPONSE;
3428 }
3429
3430 return 0;
3431}
3432
3433static int responseGsmBrSmsCnf(Parcel &p, void *response, size_t responselen) {
3434 int num = responselen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
3435 p.writeInt32(num);
3436
3437 startResponse;
3438 RIL_GSM_BroadcastSmsConfigInfo **p_cur =
3439 (RIL_GSM_BroadcastSmsConfigInfo **) response;
3440 for (int i = 0; i < num; i++) {
3441 p.writeInt32(p_cur[i]->fromServiceId);
3442 p.writeInt32(p_cur[i]->toServiceId);
3443 p.writeInt32(p_cur[i]->fromCodeScheme);
3444 p.writeInt32(p_cur[i]->toCodeScheme);
3445 p.writeInt32(p_cur[i]->selected);
3446
3447 appendPrintBuf("%s [%d: fromServiceId=%d, toServiceId=%d, \
3448 fromCodeScheme=%d, toCodeScheme=%d, selected =%d]",
3449 printBuf, i, p_cur[i]->fromServiceId, p_cur[i]->toServiceId,
3450 p_cur[i]->fromCodeScheme, p_cur[i]->toCodeScheme,
3451 p_cur[i]->selected);
3452 }
3453 closeResponse;
3454
3455 return 0;
3456}
3457
3458static int responseCdmaBrSmsCnf(Parcel &p, void *response, size_t responselen) {
3459 RIL_CDMA_BroadcastSmsConfigInfo **p_cur =
3460 (RIL_CDMA_BroadcastSmsConfigInfo **) response;
3461
3462 int num = responselen / sizeof (RIL_CDMA_BroadcastSmsConfigInfo *);
3463 p.writeInt32(num);
3464
3465 startResponse;
3466 for (int i = 0 ; i < num ; i++ ) {
3467 p.writeInt32(p_cur[i]->service_category);
3468 p.writeInt32(p_cur[i]->language);
3469 p.writeInt32(p_cur[i]->selected);
3470
3471 appendPrintBuf("%s [%d: srvice_category=%d, language =%d, \
3472 selected =%d], ",
3473 printBuf, i, p_cur[i]->service_category, p_cur[i]->language,
3474 p_cur[i]->selected);
3475 }
3476 closeResponse;
3477
3478 return 0;
3479}
3480
3481static int responseCdmaSms(Parcel &p, void *response, size_t responselen) {
3482 int num;
3483 int digitCount;
3484 int digitLimit;
3485 uint8_t uct;
3486 void* dest;
3487
3488 RLOGD("Inside responseCdmaSms");
3489
3490 if (response == NULL && responselen != 0) {
3491 RLOGE("invalid response: NULL");
3492 return RIL_ERRNO_INVALID_RESPONSE;
3493 }
3494
3495 if (responselen != sizeof(RIL_CDMA_SMS_Message)) {
3496 RLOGE("invalid response length was %d expected %d",
3497 (int)responselen, (int)sizeof(RIL_CDMA_SMS_Message));
3498 return RIL_ERRNO_INVALID_RESPONSE;
3499 }
3500
3501 RIL_CDMA_SMS_Message *p_cur = (RIL_CDMA_SMS_Message *) response;
3502 p.writeInt32(p_cur->uTeleserviceID);
3503 p.write(&(p_cur->bIsServicePresent),sizeof(uct));
3504 p.writeInt32(p_cur->uServicecategory);
3505 p.writeInt32(p_cur->sAddress.digit_mode);
3506 p.writeInt32(p_cur->sAddress.number_mode);
3507 p.writeInt32(p_cur->sAddress.number_type);
3508 p.writeInt32(p_cur->sAddress.number_plan);
3509 RLOGD("MT CDMA SMS: sAddress.number_plan = %d", p_cur->sAddress.number_plan);
3510 p.write(&(p_cur->sAddress.number_of_digits), sizeof(uct));
3511 RLOGD("MT CDMA SMS: sAddress.number_of_digits = %d", p_cur->sAddress.number_of_digits);
3512 digitLimit= MIN((p_cur->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
3513 String8 str(""), temp;
3514 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
3515 p.write(&(p_cur->sAddress.digits[digitCount]),sizeof(uct));
3516 temp = String8::format("%d,", p_cur->sAddress.digits[digitCount]);
3517 str.append(temp);
3518 }
3519 RLOGD("MT CDMA SMS: sAddress.digits: {%s}", str.isEmpty()? "" : str.string());
3520
3521 p.writeInt32(p_cur->sSubAddress.subaddressType);
3522 RLOGD("MT CDMA SMS: sSubAddress.subaddressType = %d", p_cur->sSubAddress.subaddressType);
3523 p.write(&(p_cur->sSubAddress.odd),sizeof(uct));
3524 RLOGD("MT CDMA SMS: sSubAddress.odd = %d", p_cur->sSubAddress.odd);
3525 p.write(&(p_cur->sSubAddress.number_of_digits),sizeof(uct));
3526 RLOGD("MT CDMA SMS: sSubAddress.number_of_digits = %d", p_cur->sSubAddress.number_of_digits);
3527 digitLimit= MIN((p_cur->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
3528 str.clear();
3529 temp.clear();
3530 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
3531 p.write(&(p_cur->sSubAddress.digits[digitCount]),sizeof(uct));
3532 temp = String8::format("%d,", p_cur->sSubAddress.digits[digitCount]);
3533 str.append(temp);
3534 }
3535 RLOGD("MT CDMA SMS: sSubAddress.digits: {%s}", str.isEmpty() ? "" : str.string());
3536
3537 digitLimit= MIN((p_cur->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
3538 RLOGD("MT CDMA SMS: uBearerDataLen = %d", p_cur->uBearerDataLen);
3539 p.writeInt32(p_cur->uBearerDataLen);
3540 str.clear();
3541 temp.clear();
3542 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
3543 p.write(&(p_cur->aBearerData[digitCount]), sizeof(uct));
3544 temp = String8::format("%d,", p_cur->aBearerData[digitCount]);
3545 str.append(temp);
3546 }
3547 RLOGD("MT CDMA SMS: aBearerData: {%s}", str.isEmpty() ? "" : str.string());
3548
3549 startResponse;
3550 appendPrintBuf("%suTeleserviceID=%d, bIsServicePresent=%d, uServicecategory=%d, \
3551 sAddress.digit_mode=%d, sAddress.number_mode=%d, sAddress.number_type=%d, ",
3552 printBuf, p_cur->uTeleserviceID,p_cur->bIsServicePresent,p_cur->uServicecategory,
3553 p_cur->sAddress.digit_mode, p_cur->sAddress.number_mode,p_cur->sAddress.number_type);
3554 closeResponse;
3555 resposeCdmaSms(p_cur);
3556 return 0;
3557}
3558
3559static int responseDcRtInfo(Parcel &p, void *response, size_t responselen)
3560{
3561 int num = responselen / sizeof(RIL_DcRtInfo);
3562 if ((responselen % sizeof(RIL_DcRtInfo) != 0) || (num != 1)) {
3563 RLOGE("responseDcRtInfo: invalid response length %d expected multiple of %d",
3564 (int)responselen, (int)sizeof(RIL_DcRtInfo));
3565 return RIL_ERRNO_INVALID_RESPONSE;
3566 }
3567
3568 startResponse;
3569 RIL_DcRtInfo *pDcRtInfo = (RIL_DcRtInfo *)response;
3570 p.writeInt64(pDcRtInfo->time);
3571 p.writeInt32(pDcRtInfo->powerState);
3572 appendPrintBuf("%s[time=%d,powerState=%d]", printBuf,
3573 pDcRtInfo->time,
3574 pDcRtInfo->powerState);
3575 closeResponse;
3576
3577 return 0;
3578}
3579
3580static int responseLceStatus(Parcel &p, void *response, size_t responselen) {
3581 if (response == NULL || responselen != sizeof(RIL_LceStatusInfo)) {
3582 if (response == NULL) {
3583 RLOGE("invalid response: NULL");
3584 }
3585 else {
3586 RLOGE("responseLceStatus: invalid response length %d expecting len: %d",
3587 sizeof(RIL_LceStatusInfo), responselen);
3588 }
3589 return RIL_ERRNO_INVALID_RESPONSE;
3590 }
3591
3592 RIL_LceStatusInfo *p_cur = (RIL_LceStatusInfo *)response;
3593 p.write((void *)p_cur, 1); // p_cur->lce_status takes one byte.
3594 p.writeInt32(p_cur->actual_interval_ms);
3595
3596 startResponse;
3597 appendPrintBuf("LCE Status: %d, actual_interval_ms: %d",
3598 p_cur->lce_status, p_cur->actual_interval_ms);
3599 closeResponse;
3600
3601 return 0;
3602}
3603
3604static int responseLceData(Parcel &p, void *response, size_t responselen) {
3605 if (response == NULL || responselen != sizeof(RIL_LceDataInfo)) {
3606 if (response == NULL) {
3607 RLOGE("invalid response: NULL");
3608 }
3609 else {
3610 RLOGE("responseLceData: invalid response length %d expecting len: %d",
3611 sizeof(RIL_LceDataInfo), responselen);
3612 }
3613 return RIL_ERRNO_INVALID_RESPONSE;
3614 }
3615
3616 RIL_LceDataInfo *p_cur = (RIL_LceDataInfo *)response;
3617 p.writeInt32(p_cur->last_hop_capacity_kbps);
3618
3619 /* p_cur->confidence_level and p_cur->lce_suspended take 1 byte each.*/
3620 p.write((void *)&(p_cur->confidence_level), 1);
3621 p.write((void *)&(p_cur->lce_suspended), 1);
3622
3623 startResponse;
3624 appendPrintBuf("LCE info received: capacity %d confidence level %d and suspended %d",
3625 p_cur->last_hop_capacity_kbps, p_cur->confidence_level,
3626 p_cur->lce_suspended);
3627 closeResponse;
3628
3629 return 0;
3630}
3631
3632static int responseActivityData(Parcel &p, void *response, size_t responselen) {
3633 if (response == NULL || responselen != sizeof(RIL_ActivityStatsInfo)) {
3634 if (response == NULL) {
3635 RLOGE("invalid response: NULL");
3636 }
3637 else {
3638 RLOGE("responseActivityData: invalid response length %d expecting len: %d",
3639 sizeof(RIL_ActivityStatsInfo), responselen);
3640 }
3641 return RIL_ERRNO_INVALID_RESPONSE;
3642 }
3643
3644 RIL_ActivityStatsInfo *p_cur = (RIL_ActivityStatsInfo *)response;
3645 p.writeInt32(p_cur->sleep_mode_time_ms);
3646 p.writeInt32(p_cur->idle_mode_time_ms);
3647 for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) {
3648 p.writeInt32(p_cur->tx_mode_time_ms[i]);
3649 }
3650 p.writeInt32(p_cur->rx_mode_time_ms);
3651
3652 startResponse;
3653 appendPrintBuf("Modem activity info received: sleep_mode_time_ms %d idle_mode_time_ms %d tx_mode_time_ms %d %d %d %d %d and rx_mode_time_ms %d",
3654 p_cur->sleep_mode_time_ms, p_cur->idle_mode_time_ms, p_cur->tx_mode_time_ms[0],
3655 p_cur->tx_mode_time_ms[1], p_cur->tx_mode_time_ms[2], p_cur->tx_mode_time_ms[3],
3656 p_cur->tx_mode_time_ms[4], p_cur->rx_mode_time_ms);
3657 closeResponse;
3658
3659 return 0;
3660}
3661
3662static int responseSmsSimMemStatus(Parcel &p, void *response, size_t responselen) {
3663 printf("=============%s\n", __FUNCTION__);
3664 if (response == NULL) {
3665 RLOGE("invalid response: NULL");
3666 return RIL_ERRNO_INVALID_RESPONSE;
3667 }
3668
3669 if (responselen != sizeof (RIL_SMS_Memory_Status) ) {
3670 RLOGE("invalid response length %d expected %d",
3671 (int)responselen, (int)sizeof (RIL_SMS_Memory_Status));
3672 return RIL_ERRNO_INVALID_RESPONSE;
3673 }
3674
3675 RIL_SMS_Memory_Status *p_cur = (RIL_SMS_Memory_Status *) response;
3676
3677 p.writeInt32(p_cur->used);
3678 p.writeInt32(p_cur->total);
3679
3680 startResponse;
3681 appendPrintBuf("%s%d,%d", printBuf, p_cur->used, p_cur->total);
3682 closeResponse;
3683
3684 printf("%s%d,%d\n", printBuf, p_cur->used, p_cur->total);
3685 RLOGE("===========================%s%d,%d", printBuf, p_cur->used, p_cur->total);
3686 return 0;
3687}
3688
3689void RIL_startEventLoop(void);
3690extern "C" void
3691RIL_register (const RIL_RadioFunctions *callbacks) {
3692 if (callbacks == NULL) {
3693 RLOGE("RIL_register: RIL_RadioFunctions * null");
3694 return;
3695 }
3696#if 0
3697 if (callbacks->version < RIL_VERSION_MIN) {
3698 RLOGE("RIL_register: version %d is to old, min version is %d",
3699 callbacks->version, RIL_VERSION_MIN);
3700 return;
3701 }
3702 if (callbacks->version > RIL_VERSION) {
3703 RLOGE("RIL_register: version %d is too new, max version is %d",
3704 callbacks->version, RIL_VERSION);
3705 return;
3706 }
3707#endif
3708 RLOGE("RIL_register: RIL version %d", callbacks->version);
3709
3710 if (s_registerCalled > 0) {
3711 RLOGE("RIL_register has been called more than once. "
3712 "Subsequent call ignored");
3713 return;
3714 }
3715
3716 memcpy(&s_callbacks, callbacks, sizeof (RIL_RadioFunctions));
3717
3718 s_registerCalled = 1;
3719
3720 pthread_mutex_lock(&s_InitMutex);
3721 if(utils::is_support_dsds()) {
3722 while (s_isConnected[0] == 0 || s_isConnected[1] == 0) {
3723 pthread_cond_wait(&s_InitCond, &s_InitMutex);
3724 }
3725 } else {
3726 while (s_isConnected[0] == 0 && s_isConnected[1] == 0) {
3727 pthread_cond_wait(&s_InitCond, &s_InitMutex);
3728 }
3729 }
3730 pthread_mutex_unlock(&s_InitMutex);
3731 initCoditions();
3732 // New rild impl calls RIL_startEventLoop() first
3733 // old standalone impl wants it here.
3734
3735 if (s_started == 0) {
3736 RIL_startEventLoop();
3737 }
3738
3739}
3740
3741#if 0
3742static int
3743checkAndDequeueRequestInfo(struct RequestInfo *pRI) {
3744 int ret = 0;
3745 /* Hook for current context
3746 pendingRequestsMutextHook refer to &s_pendingRequestsMutex */
3747 pthread_mutex_t* pendingRequestsMutexHook = &s_pendingRequestsMutex;
3748 /* pendingRequestsHook refer to &s_pendingRequests */
3749 RequestInfo ** pendingRequestsHook = &s_pendingRequests;
3750
3751 if (pRI == NULL) {
3752 return 0;
3753 }
3754
3755#if (SIM_COUNT >= 2)
3756 if (pRI->socket_id == RIL_SOCKET_2) {
3757 pendingRequestsMutexHook = &s_pendingRequestsMutex_socket2;
3758 pendingRequestsHook = &s_pendingRequests_socket2;
3759 }
3760#if (SIM_COUNT >= 3)
3761 if (pRI->socket_id == RIL_SOCKET_3) {
3762 pendingRequestsMutexHook = &s_pendingRequestsMutex_socket3;
3763 pendingRequestsHook = &s_pendingRequests_socket3;
3764 }
3765#endif
3766#if (SIM_COUNT >= 4)
3767 if (pRI->socket_id == RIL_SOCKET_4) {
3768 pendingRequestsMutexHook = &s_pendingRequestsMutex_socket4;
3769 pendingRequestsHook = &s_pendingRequests_socket4;
3770 }
3771#endif
3772#endif
3773 pthread_mutex_lock(pendingRequestsMutexHook);
3774
3775 for(RequestInfo **ppCur = pendingRequestsHook
3776 ; *ppCur != NULL
3777 ; ppCur = &((*ppCur)->p_next)
3778 ) {
3779 if (pRI == *ppCur) {
3780 ret = 1;
3781
3782 *ppCur = (*ppCur)->p_next;
3783 break;
3784 }
3785 }
3786
3787 pthread_mutex_unlock(pendingRequestsMutexHook);
3788
3789 return ret;
3790}
3791
3792#endif
3793
3794extern "C" void
3795RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responselen) {
3796 RequestInfo *pRI;
3797 int ret;
3798 //int fd = s_ril_param_socket.fdCommand;
3799 size_t errorOffset;
3800 RIL_SOCKET_ID socket_id = RIL_SOCKET_1;
3801
3802 pRI = (RequestInfo *)t;
3803#if 0
3804 if (!checkAndDequeueRequestInfo(pRI)) {
3805 RLOGE ("RIL_onRequestComplete: invalid RIL_Token");
3806 return;
3807 }
3808#endif
3809
3810 socket_id = pRI->socket_id;
3811#if 0
3812#if (SIM_COUNT >= 2)
3813 if (socket_id == RIL_SOCKET_2) {
3814 fd = s_ril_param_socket2.fdCommand;
3815 }
3816#if (SIM_COUNT >= 3)
3817 if (socket_id == RIL_SOCKET_3) {
3818 fd = s_ril_param_socket3.fdCommand;
3819 }
3820#endif
3821#if (SIM_COUNT >= 4)
3822 if (socket_id == RIL_SOCKET_4) {
3823 fd = s_ril_param_socket4.fdCommand;
3824 }
3825#endif
3826#endif
3827#endif
3828#if VDBG
3829 RLOGD("RequestComplete, %s", rilSocketIdToString(socket_id));
3830#endif
3831
3832 if (pRI->local > 0) {
3833 // Locally issued command...void only!
3834 // response does not go back up the command socket
3835 RLOGD("C[locl]< %s", requestToString(pRI->pCI->requestNumber));
3836
3837 goto done;
3838 }
3839
3840 appendPrintBuf("[%x][SIM%d]< %s", pRI->token,socket_id,requestToString(pRI->pCI->requestNumber));
3841
3842 if (pRI->cancelled == 0) {
3843 Parcel p;
3844
3845 p.writeInt32 (RESPONSE_SOLICITED);
3846 p.writeInt32 (pRI->pCI->requestNumber);
3847 /*warren add for t800 ril servie 2021/12/15 start*/
3848 p.writeInt32(socket_id);
3849 /*warren add for t800 ril servie 2021/12/15 end*/
3850 errorOffset = p.dataPosition();
3851
3852 p.writeInt32 (e);
3853
3854 if (response != NULL) {
3855 // there is a response payload, no matter success or not.
3856 ret = pRI->pCI->responseFunction(p, response, responselen);
3857
3858 /* if an error occurred, rewind and mark it */
3859 if (ret != 0) {
3860 RLOGE ("responseFunction error, ret %d", ret);
3861 p.setDataPosition(errorOffset);
3862 p.writeInt32 (ret);
3863 }
3864 switch (pRI->pCI->requestNumber) {
3865 case RIL_REQUEST_QUERY_FACILITY_LOCK:
3866 {
3867 int numInts = responselen / sizeof(int);
3868 if(numInts > 0) {
3869 int *p_int = (int *) response;
3870 RLOGD("RIL_REQUEST_QUERY_FACILITY_LOCK: %s", (p_int[0] != 0 ? "PIN enable" : "PIN1 disable"));
3871 } else {
3872 RLOGD("RIL_REQUEST_QUERY_FACILITY_LOCK response numInts: %d", numInts);
3873 }
3874 break;
3875 }
3876 case RIL_REQUEST_IMS_REGISTRATION_STATE:
3877 {
3878 int numInts = responselen / sizeof(int);
3879 if(numInts > 0) {
3880 int *p_int = (int *) response;
3881 printf("[SIM%d][QUERY][REG_STATUS] IMS is %s\n", socket_id, (p_int[0] == 0 ? "Not registered" : "Registered"));
3882 } else {
3883 RLOGD("RIL_REQUEST_IMS_REGISTRATION_STATE response numInts: %d", numInts);
3884 }
3885 break;
3886 }
3887 case RIL_REQUEST_VOICE_REGISTRATION_STATE:
3888 {
3889 char **p_cur = (char **) response;
3890 int numStrings = responselen / sizeof(char *);
3891 update_reg_voice_service_state(RIL_REQUEST_VOICE_REGISTRATION_STATE, (char *)p_cur[0], socket_id, pRI->token);
3892 int tempVal=0;
3893 memset(respStr,0,sizeof(respStr));
3894 tempVal = atoi((char *)p_cur[0]);
3895 if(tempVal == 1 || tempVal==5){
3896 sprintf(respStr,"[SIM%d]%s register is in service!",socket_id +1, respStr);
3897 }else{
3898 sprintf(respStr,"[SIM%d]%s register is not in service!",socket_id +1, respStr);
3899 }
3900 if(numStrings >=4 && p_cur[3] != NULL)
3901 {
3902 update_reg_voice_radio_tech(RIL_REQUEST_VOICE_REGISTRATION_STATE, atoi((char *)p_cur[3]), socket_id, pRI->token);
3903 tempVal = atoi((char *)p_cur[3]);
3904 if(tempVal == RADIO_TECH_LTE){//4G
3905 sprintf(respStr,"%s radioTech is 4G!",respStr);
3906 } else if( tempVal == RADIO_TECH_GSM ||
3907 tempVal == RADIO_TECH_GPRS ||
3908 tempVal == RADIO_TECH_EDGE ||
3909 tempVal == RADIO_TECH_IS95A ||
3910 tempVal == RADIO_TECH_IS95B ||
3911 tempVal == RADIO_TECH_1xRTT) { //2G
3912 sprintf(respStr,"%s radioTech is 2G!",respStr);
3913 } else if( tempVal == RADIO_TECH_UMTS ||
3914 tempVal == RADIO_TECH_HSDPA ||
3915 tempVal == RADIO_TECH_HSUPA ||
3916 tempVal == RADIO_TECH_HSPA ||
3917 tempVal == RADIO_TECH_EHRPD ||
3918 tempVal == RADIO_TECH_HSPAP ||
3919 tempVal == RADIO_TECH_TD_SCDMA ||
3920 tempVal == RADIO_TECH_EVDO_0 ||
3921 tempVal == RADIO_TECH_EVDO_A ||
3922 tempVal == RADIO_TECH_EVDO_B) { //3G
3923 sprintf(respStr,"%s radioTech is 3G!",respStr);
3924#ifdef TELEMATIC_5G_SUPPORT
3925 } else if(tempVal == RADIO_TECH_NR) { //5G
3926 sprintf(respStr,"%s radioTech is 5G!",respStr);
3927#endif
3928 } else { //unknown
3929 sprintf(respStr,"%s radioTech is unkown!",respStr);
3930 }
3931 }
3932 sprintf(respStr,"%s\n",respStr);
3933 break;
3934 }
3935 case RIL_REQUEST_DATA_REGISTRATION_STATE:
3936 {
3937 char **p_cur = (char **) response;
3938 int numStrings = responselen / sizeof(char *);
3939 update_reg_data_service_state(RIL_REQUEST_DATA_REGISTRATION_STATE, (char *)p_cur[0], socket_id, pRI->token);
3940 if(numStrings >=4 && p_cur[3] != NULL)
3941 {
3942 update_reg_data_radio_tech(RIL_REQUEST_DATA_REGISTRATION_STATE, atoi((char *)p_cur[3]), socket_id, pRI->token);
3943 }
3944 break;
3945 }
3946 case RIL_REQUEST_GET_CURRENT_CALLS:
3947 {
3948 update_call_state(response,responselen, socket_id);
3949 int num = responselen / sizeof(RIL_Call *);
3950 speechonoff(num);
3951 printf("%s\n", printBuf);
3952 break;
3953 }
3954 case RIL_REQUEST_SETUP_DATA_CALL:
3955 {
3956 int num = responselen / sizeof(RIL_Data_Call_Response_v6);
3957 RIL_Data_Call_Response_v6 *p_cur = (RIL_Data_Call_Response_v6 *) response;
3958 updateRILDataCallResponsev6(num,p_cur);
3959 break;
3960 }
3961 case RIL_REQUEST_GET_SIM_STATUS:
3962 {
3963 if (responselen == sizeof (RIL_CardStatus_v6)) {
3964 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
3965 updateCardStatusV6(p_cur, socket_id);
3966 }
3967 break;
3968 }
3969 case RIL_REQUEST_VOICE_RADIO_TECH:
3970 {
3971 update_voice_radio_tech(((int *) response)[0], socket_id);
3972 break;
3973 }
3974 case RIL_REQUEST_GET_RADIO_CAPABILITY:
3975 {
3976 update_radio_capa((RIL_RadioCapability *) response, socket_id);
3977 break;
3978 }
3979 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE:
3980 {
3981 update_preferred_network_type(((int *) response)[0], socket_id);
3982 break;
3983 }
3984 case RIL_REQUEST_DELETE_SMS_ON_SIM:
3985 {
3986 setSimSmsStorageFullFlag(false);
3987 break;
3988 }
3989 case RIL_REQUEST_SEND_SMS:
3990 case RIL_REQUEST_SEND_SMS_EXPECT_MORE:
3991 case RIL_REQUEST_IMS_SEND_SMS:
3992 {
3993 //for auto save sms to sim
3994 sendStatusWriteSmsToSim(socket_id);
3995 break;
3996 }
3997 case RIL_REQUEST_ECALL_SET_REGISTRATION_STATE:
3998 {
3999 int numInts = responselen / sizeof(int);
4000 if(numInts > 0) {
4001 int *p_int = (int *) response;
4002 RLOGD("RIL_REQUEST_ECALL_SET_REGISTRATION_STATE: %d", p_int[0]);
4003 if(p_int[0] == ECALL_DEREGISTRATION)
4004 {
4005 gostSetInNeedRegister(true);
4006 }
4007
4008 } else {
4009 RLOGD("RIL_REQUEST_ECALL_SET_REGISTRATION_STATE response numInts: %d", numInts);
4010 }
4011 break;
4012 }
4013 default:
4014 break;
4015 }
4016 }
4017
4018 if (e != RIL_E_SUCCESS) {
4019 appendPrintBuf("%s fails by %s", printBuf, failCauseToString(e));
4020 }
4021
4022 if ((pRI->token & RIL_TOKEN_MARK) == RIL_TOKEN_MARK) {
4023 printf("%s\n", printBuf ? printBuf : "unkonwn");
4024 } else if (((pRI->pCI->requestNumber == RIL_REQUEST_DEVICE_IDENTITY)
4025 || (pRI->pCI->requestNumber == RIL_REQUEST_OEM_HOOK_RAW))
4026 && (pRI->token & INIT_TOKEN_MARK) == INIT_TOKEN_MARK) {
4027 printf("%s\n", printBuf ? printBuf : "unkonwn");
4028 if (pRI->pCI->requestNumber == RIL_REQUEST_DEVICE_IDENTITY) {
4029 if (e != RIL_E_SUCCESS) {
4030 printf(
4031 "*******************************************\n*** NOTICE: IMEI don't wirite in slot%d ***\n*******************************************\n",
4032 socket_id);
4033 }
4034 }
4035 }
4036
4037#if 0
4038 if (fd < 0) {
4039 RLOGD ("RIL onRequestComplete: Command channel closed");
4040 }
4041#endif
4042 LYNQ_RIL_respSocket(p,t);
4043 sendResponse(p, socket_id);
4044 }
4045#if ATCI_ENABLE_RESPONSE
4046 if((pRI->token & ATCI_TOKEN_MARK) == ATCI_TOKEN_MARK) //ATCI_Rsp
4047 {
4048 int error;
4049 memset(Respose_buf, 0, sizeof(Respose_buf));
4050 if(e != RIL_E_SUCCESS)
4051 error = 1; //fail
4052 else
4053 error = 0; //ok
4054 ATCIResponse(pRI->token,error,Respose_buf, pRI->pCI->requestNumber);
4055 }
4056#endif
4057 if(pRI->pCI->requestNumber == RIL_REQUEST_VOICE_REGISTRATION_STATE && (pRI->token & RIL_TOKEN_MARK) == RIL_TOKEN_MARK){
4058 int len_s = sendto(server_socket_fd,respStr,strlen(respStr),0,(struct sockaddr *)&client_addr,sizeof(client_addr));
4059 }
4060 RLOGW("RIL_onRequestComplete %s end!",requestToString(pRI->pCI->requestNumber));
4061 if((pRI->token&BLOCK_MARK) == BLOCK_MARK) {
4062 //need wakeup dispatch function
4063 BLOCK_LOCK();
4064 wakeup_token = pRI->token;
4065 RLOGW("RIL_onRequestComplete wakeup, token is %x!",wakeup_token);
4066 BLOCK_WAKEUP();
4067 BLOCK_UNLOCK();
4068 }
4069 switch (pRI->pCI->requestNumber) {
4070 case RIL_REQUEST_RADIO_POWER:
4071 speciaRequest_wakeup();
4072 break;
4073 case RIL_REQUEST_SET_RADIO_CAPABILITY:
4074 {
4075 if(utils::is_support_dsds()) {
4076 for (int id = 0; id < SIM_COUNT; id++) {
4077 ARspRequest(RIL_REQUEST_ALLOW_DATA, (RIL_SOCKET_ID)id);
4078 }
4079 }
4080 break;
4081 }
4082 case RIL_REQUEST_ALLOW_DATA:
4083 {
4084 if(utils::is_support_dsds() && isNeedConnect() && get_default_sim_data() == socket_id) {
4085 RLOGD("recreate PDN with sim switch");
4086 resetConnect();
4087 setupDataCall(0, NULL, (RIL_SOCKET_ID)0, NULL);
4088 }
4089 break;
4090 }
4091#ifdef KEEP_ALIVE
4092 case RIL_REQUEST_START_KEEPALIVE_PRO:
4093 case RIL_REQUEST_STOP_KEEPALIVE_PRO:
4094 {
4095 handleKeepAliveResponse(pRI->pCI->requestNumber, response, responselen, socket_id, (e != RIL_E_SUCCESS));
4096 break;
4097 }
4098#endif /*KEEP_ALIVE*/
4099 case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC:
4100 {
4101 if(e == RIL_E_SUCCESS)
4102 {
4103 gostSetInNeedRegister(false);
4104 gostFastEcallFlgSet(false);
4105 }
4106 else
4107 {
4108 gostNetworkSelectionSet(socket_id);
4109 }
4110 break;
4111 }
4112 default:
4113 break;
4114 }
4115done:
4116 free(pRI);
4117}
4118
4119
4120static void
4121grabPartialWakeLock() {
4122 acquire_wake_lock(PARTIAL_WAKE_LOCK, ANDROID_WAKE_LOCK_NAME);
4123}
4124
4125static void
4126releaseWakeLock() {
4127 release_wake_lock(ANDROID_WAKE_LOCK_NAME);
4128}
4129
4130
4131static int
4132decodeVoiceRadioTechnology (RIL_RadioState radioState) {
4133 switch (radioState) {
4134 case RADIO_STATE_SIM_NOT_READY:
4135 case RADIO_STATE_SIM_LOCKED_OR_ABSENT:
4136 case RADIO_STATE_SIM_READY:
4137 return RADIO_TECH_UMTS;
4138
4139 case RADIO_STATE_RUIM_NOT_READY:
4140 case RADIO_STATE_RUIM_READY:
4141 case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:
4142 case RADIO_STATE_NV_NOT_READY:
4143 case RADIO_STATE_NV_READY:
4144 return RADIO_TECH_1xRTT;
4145
4146 default:
4147 RLOGD("decodeVoiceRadioTechnology: Invoked with incorrect RadioState");
4148 return -1;
4149 }
4150}
4151
4152static int
4153decodeCdmaSubscriptionSource (RIL_RadioState radioState) {
4154 switch (radioState) {
4155 case RADIO_STATE_SIM_NOT_READY:
4156 case RADIO_STATE_SIM_LOCKED_OR_ABSENT:
4157 case RADIO_STATE_SIM_READY:
4158 case RADIO_STATE_RUIM_NOT_READY:
4159 case RADIO_STATE_RUIM_READY:
4160 case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:
4161 return CDMA_SUBSCRIPTION_SOURCE_RUIM_SIM;
4162
4163 case RADIO_STATE_NV_NOT_READY:
4164 case RADIO_STATE_NV_READY:
4165 return CDMA_SUBSCRIPTION_SOURCE_NV;
4166
4167 default:
4168 RLOGD("decodeCdmaSubscriptionSource: Invoked with incorrect RadioState");
4169 return -1;
4170 }
4171}
4172
4173static int
4174decodeSimStatus (RIL_RadioState radioState) {
4175 switch (radioState) {
4176 case RADIO_STATE_SIM_NOT_READY:
4177 case RADIO_STATE_RUIM_NOT_READY:
4178 case RADIO_STATE_NV_NOT_READY:
4179 case RADIO_STATE_NV_READY:
4180 return -1;
4181 case RADIO_STATE_SIM_LOCKED_OR_ABSENT:
4182 case RADIO_STATE_SIM_READY:
4183 case RADIO_STATE_RUIM_READY:
4184 case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:
4185 return radioState;
4186 default:
4187 RLOGD("decodeSimStatus: Invoked with incorrect RadioState");
4188 return -1;
4189 }
4190}
4191
4192static bool is3gpp2(int radioTech) {
4193 switch (radioTech) {
4194 case RADIO_TECH_IS95A:
4195 case RADIO_TECH_IS95B:
4196 case RADIO_TECH_1xRTT:
4197 case RADIO_TECH_EVDO_0:
4198 case RADIO_TECH_EVDO_A:
4199 case RADIO_TECH_EVDO_B:
4200 case RADIO_TECH_EHRPD:
4201 return true;
4202 default:
4203 return false;
4204 }
4205}
4206
4207/* If RIL sends SIM states or RUIM states, store the voice radio
4208 * technology and subscription source information so that they can be
4209 * returned when telephony framework requests them
4210 */
4211static RIL_RadioState
4212processRadioState(RIL_RadioState newRadioState, RIL_SOCKET_ID socket_id) {
4213
4214 if((newRadioState > RADIO_STATE_UNAVAILABLE) && (newRadioState < RADIO_STATE_ON)) {
4215 int newVoiceRadioTech;
4216 int newCdmaSubscriptionSource;
4217 int newSimStatus;
4218
4219 /* This is old RIL. Decode Subscription source and Voice Radio Technology
4220 from Radio State and send change notifications if there has been a change */
4221 newVoiceRadioTech = decodeVoiceRadioTechnology(newRadioState);
4222 if(newVoiceRadioTech != voiceRadioTech) {
4223 voiceRadioTech = newVoiceRadioTech;
4224 RIL_UNSOL_RESPONSE(RIL_UNSOL_VOICE_RADIO_TECH_CHANGED,
4225 &voiceRadioTech, sizeof(voiceRadioTech), socket_id);
4226 }
4227 if(is3gpp2(newVoiceRadioTech)) {
4228 newCdmaSubscriptionSource = decodeCdmaSubscriptionSource(newRadioState);
4229 if(newCdmaSubscriptionSource != cdmaSubscriptionSource) {
4230 cdmaSubscriptionSource = newCdmaSubscriptionSource;
4231 RIL_UNSOL_RESPONSE(RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED,
4232 &cdmaSubscriptionSource, sizeof(cdmaSubscriptionSource), socket_id);
4233 }
4234 }
4235 newSimStatus = decodeSimStatus(newRadioState);
4236 if(newSimStatus != simRuimStatus) {
4237 simRuimStatus = newSimStatus;
4238 RIL_UNSOL_RESPONSE(RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, NULL, 0, socket_id);
4239 }
4240
4241 /* Send RADIO_ON to telephony */
4242 newRadioState = RADIO_STATE_ON;
4243 }
4244
4245 return newRadioState;
4246}
4247
4248
4249#if defined(ANDROID_MULTI_SIM)
4250extern "C"
4251void RIL_onUnsolicitedResponse(int unsolResponse, const void *data,
4252 size_t datalen, RIL_SOCKET_ID socket_id)
4253#else
4254extern "C"
4255void RIL_onUnsolicitedResponse(int unsolResponse, const void *data,
4256 size_t datalen)
4257#endif
4258{
4259 int unsolResponseIndex;
4260 int ret;
4261 int64_t timeReceived = 0;
4262 bool shouldScheduleTimeout = false;
4263 RIL_RadioState newState;
4264 RIL_SOCKET_ID soc_id = (RIL_SOCKET_ID)Phone_utils::get_enable_sim_for_dsss();
4265
4266#if defined(ANDROID_MULTI_SIM)
4267 soc_id = socket_id;
4268#endif
4269
4270 handle_wakeup_reason(unsolResponse);
4271
4272 if (s_registerCalled == 0) {
4273 // Ignore RIL_onUnsolicitedResponse before RIL_register
4274 RLOGW("RIL_onUnsolicitedResponse called before RIL_register");
4275 return;
4276 }
4277 if(onSupports(unsolResponse) == 0)
4278 {
4279 RLOGE("unsupported unsolicited response code %d", unsolResponse);
4280 return;
4281 }
4282
4283#ifdef TARGET_PLATFORM_MT2635
4284 //Reset modem, exit DemoApp.
4285 if(unsolResponse==RIL_UNSOL_MAL_RESTART ) {
4286 RLOGD("Modem Reset, Exit DemoApp!");
4287 printf("Modem Reset, Exit DemoApp!\n");
4288 speechonoff(0);
4289 mixer_reset_set(1);
4290 com_quit(0,NULL,soc_id,NULL);
4291 }
4292#endif
4293 if (unsolResponse < RIL_UNSOL_VENDOR_BASE) {
4294 unsolResponseIndex = unsolResponse - RIL_UNSOL_RESPONSE_BASE;
4295 }
4296#if 0
4297 WakeType wakeType;
4298 if (unsolResponse >= RIL_UNSOL_VENDOR_BASE) {
4299 //unsolResponseIndex = unsolResponse - RIL_UNSOL_VENDOR_BASE;
4300 wakeType = WAKE_PARTIAL;
4301 } else {
4302 unsolResponseIndex = unsolResponse - RIL_UNSOL_RESPONSE_BASE;
4303 wakeType = s_unsolResponses[unsolResponseIndex].wakeType;
4304 }
4305
4306 // Grab a wake lock if needed for this reponse,
4307 // as we exit we'll either release it immediately
4308 // or set a timer to release it later.
4309 switch (wakeType) {
4310 case WAKE_PARTIAL:
4311 grabPartialWakeLock();
4312 shouldScheduleTimeout = false;
4313 break;
4314
4315 case DONT_WAKE:
4316 default:
4317 // No wake lock is grabed so don't set timeout
4318 shouldScheduleTimeout = false;
4319 break;
4320 }
4321
4322 // Mark the time this was received, doing this
4323 // after grabing the wakelock incase getting
4324 // the elapsedRealTime might cause us to goto
4325 // sleep.
4326 if (unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) {
4327 timeReceived = elapsedRealtime();
4328 }
4329#endif
4330 appendPrintBuf("[UNSL][SIM%d]< %s", soc_id, requestToString(unsolResponse));
4331
4332 Parcel p;
4333
4334 p.writeInt32 (RESPONSE_UNSOLICITED);
4335 p.writeInt32 (unsolResponse);
4336 /*Warren add for t800 ril service 2021/12/16 start*/
4337 p.writeInt32 (soc_id);
4338 /*Warren add for t800 ril service 2021/12/16 end*/
4339 if (unsolResponse >= RIL_UNSOL_VENDOR_BASE) {
4340 UnsolResponseInfo* unsolRspInof = find_mtk_unsol_command(unsolResponse);
4341 if(unsolRspInof == NULL){
4342 RLOGE("no unsolicited response function -- %d", unsolResponse);
4343 return;
4344 } else {
4345 ret = unsolRspInof->responseFunction(p,const_cast<void*>(data),datalen);
4346 }
4347 } else {
4348 ret = s_unsolResponses[unsolResponseIndex].responseFunction(p, const_cast<void*>(data), datalen);
4349 }
4350 if (ret != 0) {
4351 // Problem with the response. Don't continue;
4352 goto error_exit;
4353 }
4354
4355 // some things get more payload
4356 switch(unsolResponse) {
4357 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED:
4358 newState = CALL_ONSTATEREQUEST(soc_id);
4359 p.writeInt32(newState);
4360 appendPrintBuf("%s {%s}", printBuf,
4361 radioStateToString(CALL_ONSTATEREQUEST(soc_id)));
4362 break;
4363
4364#if 0
4365 case RIL_UNSOL_NITZ_TIME_RECEIVED:
4366 // Store the time that this was received so the
4367 // handler of this message can account for
4368 // the time it takes to arrive and process. In
4369 // particular the system has been known to sleep
4370 // before this message can be processed.
4371 p.writeInt64(timeReceived);
4372 break;
4373#endif
4374 }
4375
4376#if VDBG
4377 RLOGI("%s UNSOLICITED: %s length:%d", rilSocketIdToString(soc_id), requestToString(unsolResponse), p.dataSize());
4378#endif
4379 /*Warren add for t800 ril service 2021/12/16 start*/
4380 ret = LYNQ_RIL_urcBroadcast(p);
4381 /*Warren add for t800 ril service 2021/12/16 end*/
4382 ret = sendResponse(p, soc_id);
4383
4384//unsol trigger other things.
4385 switch(unsolResponse) {
4386 //case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED:
4387 //ARspRequest(RIL_REQUEST_GET_CURRENT_CALLS, soc_id);
4388 //break;
4389 case RIL_UNSOL_CALL_RING:
4390 callRing(soc_id);
4391 break;
4392 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED:
4393 updateIccCardState(soc_id);
4394 break;
4395 case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED:
4396 getVoiceAndDataRegistrationState(soc_id);
4397 break;
4398 case RIL_UNSOL_RESPONSE_NEW_SMS:
4399 responseNewSMS((const char*)data, datalen,soc_id);
4400 unreadStatusWriteSMSToSim((const char*)data, datalen, soc_id);
4401 sendSMSACK(soc_id);
4402 break;
4403 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS:
4404 {
4405 RLOGD("Receive RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS data: %s, length: %d", (char*)data, datalen);
4406 break;
4407 }
4408 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT:
4409 sendSMSACK(soc_id);
4410 break;
4411 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED:
4412 updateRadioStatus(newState,soc_id);
4413 break;
4414 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS:
4415 {
4416 ARspRequest(RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE, soc_id);
4417 break;
4418 }
4419 case RIL_UNSOL_STK_PROACTIVE_COMMAND:
4420 {
4421 RLOGD("STk proactive command raw date: %s, length: %d", (char*)data, datalen);
4422 handleStkCommand((char*)data, datalen,soc_id);
4423 break;
4424 }
4425 case RIL_UNSOL_RIL_CONNECTED:
4426 {
4427 RLOGD("vendor-ril socket(%d) connect start", soc_id);
4428 pthread_mutex_lock(&s_InitMutex);
4429 s_isConnected[soc_id] = 1;
4430 if(utils::is_support_dsds()) {
4431 if (s_isConnected[0] == 1 && s_isConnected[1] == 1) {
4432 pthread_cond_broadcast(&s_InitCond);
4433 }
4434 } else {
4435 if (s_isConnected[0] == 1 || s_isConnected[1] == 1) {
4436 pthread_cond_broadcast(&s_InitCond);
4437 }
4438 }
4439 pthread_mutex_unlock(&s_InitMutex);
4440 RLOGD("vendor-ril socket(%d) connect end", soc_id);
4441 break;
4442 }
4443 case RIL_UNSOL_TX_POWER: {
4444 int *p_int = (int *) data;
4445 int numInts = datalen / sizeof(int);
4446 if (numInts > 1) {
4447 m_RfDesense->emOemHookRaw(p_int[1],soc_id);
4448 } else {
4449 m_RfDesense->emOemHookRaw(0, soc_id);
4450 }
4451 break;
4452 }
4453 case RIL_UNSOL_NETWORK_INFO: {
4454 if(networkCb){
4455 //TBD
4456 char **p_cur = (char **) data;
4457 char *ctype = (char*)p_cur[0];
4458 int type = atoi(ctype);
4459 char *data = (char*)p_cur[1];
4460 RLOGD("ctype %s type %d data %s\n",ctype,type,data);
4461 networkCb(type,data);
4462 }
4463 break;
4464 }
4465 case RIL_UNSOL_DATA_CALL_LIST_CHANGED:
4466 {
4467 int num = datalen / sizeof(RIL_Data_Call_Response_v6);
4468 RIL_Data_Call_Response_v6 *p_cur = (RIL_Data_Call_Response_v6 *) data;
4469 handleUnsolDataCalllistChange(num,p_cur);
4470 break;
4471 }
4472 case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED:
4473 {
4474 update_voice_radio_tech(((int *) data)[0], soc_id);
4475 break;
4476 }
4477 case RIL_UNSOL_RADIO_CAPABILITY:
4478 {
4479 update_radio_capa((RIL_RadioCapability *) data, soc_id);
4480 //Proxy_controller::getInstance()->handle_message_notify((RIL_RadioCapability *) data, soc_id);
4481 break;
4482 }
4483 case RIL_UNSOL_CDMA_CALL_WAITING:
4484 {
4485 autoAnswerForCdma(soc_id);
4486 break;
4487 }
4488 case RIL_UNSOL_NITZ_TIME_RECEIVED:
4489 {
4490 updateSystemTime(data, datalen);
4491 break;
4492 }
4493 case RIL_UNSOL_ECALL_INDICATIONS:
4494 {
4495 handleEcallIndication(data, datalen, soc_id);
4496 break;
4497 }
4498#ifdef KEEP_ALIVE
4499 case RIL_UNSOL_KEEPALIVE_STATUS_PRO:
4500 {
4501 handleKeepAliveResponse(unsolResponse, data, datalen, soc_id, false);
4502 break;
4503 }
4504#endif /*KEEP_ALIVE*/
4505 case RIL_UNSOL_SIM_SMS_STORAGE_FULL:
4506 {
4507 setSimSmsStorageFullFlag(true);
4508 break;
4509 }
4510 case RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR:
4511 {
4512 handleUnsolSipCallProgressInd(data, datalen);
4513 break;
4514 }
4515 case RIL_UNSOL_ECC_NUM:
4516 {
4517 handleECCNumResponse(data, datalen,soc_id);
4518 break;
4519 }
4520 case RIL_UNSOL_CALL_INFO_INDICATION:
4521 {
4522 handleUnsolCallInfoInd(data, datalen, soc_id);
4523 break;
4524 }
4525 case RIL_UNSOL_RINGBACK_TONE:
4526 {
4527 handleRingbackTone(data, datalen, soc_id);
4528 break;
4529 }
4530 default:
4531 break;
4532 }
4533#if 0
4534 if (ret != 0 && unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) {
4535
4536 // Unfortunately, NITZ time is not poll/update like everything
4537 // else in the system. So, if the upstream client isn't connected,
4538 // keep a copy of the last NITZ response (with receive time noted
4539 // above) around so we can deliver it when it is connected
4540
4541 if (s_lastNITZTimeData != NULL) {
4542 free (s_lastNITZTimeData);
4543 s_lastNITZTimeData = NULL;
4544 }
4545
4546 s_lastNITZTimeData = malloc(p.dataSize());
4547 s_lastNITZTimeDataSize = p.dataSize();
4548 memcpy(s_lastNITZTimeData, p.data(), p.dataSize());
4549 }
4550
4551#endif
4552 // Normal exit
4553 return;
4554
4555error_exit:
4556 RLOGD("unsol handle fail");
4557#if 0
4558 if (shouldScheduleTimeout) {
4559 releaseWakeLock();
4560 }
4561#endif
4562}
4563
4564extern "C" void
4565RIL_requestTimedCallback (RIL_TimedCallback callback, void *param,
4566 const struct timeval *relativeTime) {
4567}
4568
4569const char *
4570failCauseToString(RIL_Errno e) {
4571 switch(e) {
4572 case RIL_E_SUCCESS: return "E_SUCCESS";
4573 case RIL_E_RADIO_NOT_AVAILABLE: return "E_RADIO_NOT_AVAILABLE";
4574 case RIL_E_GENERIC_FAILURE: return "E_GENERIC_FAILURE";
4575 case RIL_E_PASSWORD_INCORRECT: return "E_PASSWORD_INCORRECT";
4576 case RIL_E_SIM_PIN2: return "E_SIM_PIN2";
4577 case RIL_E_SIM_PUK2: return "E_SIM_PUK2";
4578 case RIL_E_REQUEST_NOT_SUPPORTED: return "E_REQUEST_NOT_SUPPORTED";
4579 case RIL_E_CANCELLED: return "E_CANCELLED";
4580 case RIL_E_OP_NOT_ALLOWED_DURING_VOICE_CALL: return "E_OP_NOT_ALLOWED_DURING_VOICE_CALL";
4581 case RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW: return "E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW";
4582 case RIL_E_SMS_SEND_FAIL_RETRY: return "E_SMS_SEND_FAIL_RETRY";
4583 case RIL_E_SIM_ABSENT:return "E_SIM_ABSENT";
4584 case RIL_E_ILLEGAL_SIM_OR_ME:return "E_ILLEGAL_SIM_OR_ME";
4585#ifdef FEATURE_MULTIMODE_ANDROID
4586 case RIL_E_SUBSCRIPTION_NOT_AVAILABLE:return "E_SUBSCRIPTION_NOT_AVAILABLE";
4587 case RIL_E_MODE_NOT_SUPPORTED:return "E_MODE_NOT_SUPPORTED";
4588#endif
4589 case RIL_E_SIM_MEM_FULL: return "E_SIM_MEM_FULL";
4590 default: return "<unknown error>";
4591 }
4592}
4593
4594const char *
4595callStateToString(RIL_CallState s) {
4596 switch(s) {
4597 case RIL_CALL_ACTIVE : return "ACTIVE";
4598 case RIL_CALL_HOLDING: return "HOLDING";
4599 case RIL_CALL_DIALING: return "DIALING";
4600 case RIL_CALL_ALERTING: return "ALERTING";
4601 case RIL_CALL_INCOMING: return "INCOMING";
4602 case RIL_CALL_WAITING: return "WAITING";
4603 default: return "<unknown state>";
4604 }
4605}
4606const char *lynq_requset_to_string(int request)
4607{
4608 switch(request) {
4609 case RIL_REQUEST_GET_SIM_STATUS: return "RIL_REQUEST_GET_SIM_STATUS";
4610 case RIL_REQUEST_ENTER_SIM_PIN: return "RIL_REQUEST_ENTER_SIM_PIN";
4611 case RIL_REQUEST_ENTER_SIM_PUK: return "RIL_REQUEST_ENTER_SIM_PUK";
4612 case RIL_REQUEST_ENTER_SIM_PIN2: return "RIL_REQUEST_ENTER_SIM_PIN2";
4613 case RIL_REQUEST_ENTER_SIM_PUK2: return "RIL_REQUEST_ENTER_SIM_PUK2";
4614 case RIL_REQUEST_CHANGE_SIM_PIN: return "RIL_REQUEST_CHANGE_SIM_PIN";
4615 case RIL_REQUEST_CHANGE_SIM_PIN2: return "RIL_REQUEST_CHANGE_SIM_PIN2";
4616 case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: return "RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION";
4617 case RIL_REQUEST_GET_CURRENT_CALLS: return "RIL_REQUEST_GET_CURRENT_CALLS";
4618 case RIL_REQUEST_DIAL: return "RIL_REQUEST_DIAL";
4619 case RIL_REQUEST_GET_IMSI: return "RIL_REQUEST_GET_IMSI";
4620 case RIL_REQUEST_HANGUP: return "RIL_REQUEST_HANGUP";
4621 case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: return "RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND";
4622 case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: return "RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND";
4623 case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: return "RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE";
4624 case RIL_REQUEST_CONFERENCE: return "RIL_REQUEST_CONFERENCE";
4625 case RIL_REQUEST_UDUB: return "RIL_REQUEST_UDUB";
4626 case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: return "RIL_REQUEST_LAST_CALL_FAIL_CAUSE";
4627 case RIL_REQUEST_SIGNAL_STRENGTH: return "RIL_REQUEST_SIGNAL_STRENGTH";
4628 case RIL_REQUEST_VOICE_REGISTRATION_STATE: return "RIL_REQUEST_VOICE_REGISTRATION_STATE";
4629 case RIL_REQUEST_DATA_REGISTRATION_STATE: return "RIL_REQUEST_DATA_REGISTRATION_STATE";
4630 case RIL_REQUEST_OPERATOR: return "RIL_REQUEST_OPERATOR";
4631 case RIL_REQUEST_RADIO_POWER: return "RIL_REQUEST_RADIO_POWER";
4632 case RIL_REQUEST_DTMF: return "RIL_REQUEST_DTMF";
4633 case RIL_REQUEST_SEND_SMS: return "RIL_REQUEST_SEND_SMS";
4634 case RIL_REQUEST_SEND_SMS_EXPECT_MORE: return "RIL_REQUEST_SEND_SMS_EXPECT_MORE";
4635 case RIL_REQUEST_SETUP_DATA_CALL: return "RIL_REQUEST_SETUP_DATA_CALL";
4636 case RIL_REQUEST_SIM_IO: return "RIL_REQUEST_SIM_IO";
4637 case RIL_REQUEST_SEND_USSD: return "RIL_REQUEST_SEND_USSD";
4638 case RIL_REQUEST_CANCEL_USSD: return "RIL_REQUEST_CANCEL_USSD";
4639 case RIL_REQUEST_GET_CLIR: return "RIL_REQUEST_GET_CLIR";
4640 case RIL_REQUEST_SET_CLIR: return "RIL_REQUEST_SET_CLIR";
4641 case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: return "RIL_REQUEST_QUERY_CALL_FORWARD_STATUS";
4642 case RIL_REQUEST_SET_CALL_FORWARD: return "RIL_REQUEST_SET_CALL_FORWARD";
4643 case RIL_REQUEST_QUERY_CALL_WAITING: return "RIL_REQUEST_QUERY_CALL_WAITING";
4644 case RIL_REQUEST_SET_CALL_WAITING: return "RIL_REQUEST_SET_CALL_WAITING";
4645 case RIL_REQUEST_SMS_ACKNOWLEDGE: return "RIL_REQUEST_SMS_ACKNOWLEDGE";
4646 case RIL_REQUEST_GET_IMEI: return "RIL_REQUEST_GET_IMEI";
4647 case RIL_REQUEST_GET_IMEISV: return "RIL_REQUEST_GET_IMEISV";
4648 case RIL_REQUEST_ANSWER: return "RIL_REQUEST_ANSWER";
4649 case RIL_REQUEST_DEACTIVATE_DATA_CALL: return "RIL_REQUEST_DEACTIVATE_DATA_CALL";
4650 case RIL_REQUEST_QUERY_FACILITY_LOCK: return "RIL_REQUEST_QUERY_FACILITY_LOCK";
4651 case RIL_REQUEST_SET_FACILITY_LOCK: return "RIL_REQUEST_SET_FACILITY_LOCK";
4652 case RIL_REQUEST_CHANGE_BARRING_PASSWORD: return "RIL_REQUEST_CHANGE_BARRING_PASSWORD";
4653 case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: return "RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE";
4654 case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: return "RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC";
4655 case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: return "RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL";
4656 case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : return "RIL_REQUEST_QUERY_AVAILABLE_NETWORKS";
4657 case RIL_REQUEST_DTMF_START: return "RIL_REQUEST_DTMF_START";
4658 case RIL_REQUEST_DTMF_STOP: return "RIL_REQUEST_DTMF_STOP";
4659 case RIL_REQUEST_BASEBAND_VERSION: return "RIL_REQUEST_BASEBAND_VERSION";
4660 case RIL_REQUEST_SEPARATE_CONNECTION: return "RIL_REQUEST_SEPARATE_CONNECTION";
4661 case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: return "RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE";
4662 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: return "RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE";
4663 case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: return "RIL_REQUEST_GET_NEIGHBORING_CELL_IDS";
4664 case RIL_REQUEST_SET_MUTE: return "RIL_REQUEST_SET_MUTE";
4665 case RIL_REQUEST_GET_MUTE: return "RIL_REQUEST_GET_MUTE";
4666 case RIL_REQUEST_QUERY_CLIP: return "RIL_REQUEST_QUERY_CLIP";
4667 case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: return "RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE";
4668 case RIL_REQUEST_DATA_CALL_LIST: return "RIL_REQUEST_DATA_CALL_LIST";
4669 case RIL_REQUEST_RESET_RADIO: return "RIL_REQUEST_RESET_RADIO";
4670 case RIL_REQUEST_OEM_HOOK_RAW: return "RIL_REQUEST_OEM_HOOK_RAW";
4671 case RIL_REQUEST_OEM_HOOK_STRINGS: return "RIL_REQUEST_OEM_HOOK_STRINGS";
4672 case RIL_REQUEST_SET_BAND_MODE: return "RIL_REQUEST_SET_BAND_MODE";
4673 case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: return "RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE";
4674 case RIL_REQUEST_STK_GET_PROFILE: return "RIL_REQUEST_STK_GET_PROFILE";
4675 case RIL_REQUEST_STK_SET_PROFILE: return "RIL_REQUEST_STK_SET_PROFILE";
4676 case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: return "RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND";
4677 case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: return "RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE";
4678 case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: return "RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM";
4679 case RIL_REQUEST_SCREEN_STATE: return "RIL_REQUEST_SCREEN_STATE";
4680 case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: return "RIL_REQUEST_EXPLICIT_CALL_TRANSFER";
4681 case RIL_REQUEST_SET_LOCATION_UPDATES: return "RIL_REQUEST_SET_LOCATION_UPDATES";
4682 case RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE:return"RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE";
4683 case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE:return"RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE";
4684 case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE:return"RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE";
4685 case RIL_REQUEST_SET_TTY_MODE:return"RIL_REQUEST_SET_TTY_MODE";
4686 case RIL_REQUEST_QUERY_TTY_MODE:return"RIL_REQUEST_QUERY_TTY_MODE";
4687 case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE:return"RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE";
4688 case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE:return"RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE";
4689 case RIL_REQUEST_CDMA_FLASH:return"RIL_REQUEST_CDMA_FLASH";
4690 case RIL_REQUEST_CDMA_BURST_DTMF:return"RIL_REQUEST_CDMA_BURST_DTMF";
4691 case RIL_REQUEST_CDMA_SEND_SMS:return"RIL_REQUEST_CDMA_SEND_SMS";
4692 case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE:return"RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE";
4693 case RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG:return"RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG";
4694 case RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG:return"RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG";
4695 case RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION:return "RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION";
4696 case RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG:return "RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG";
4697 case RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG:return "RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG";
4698 case RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION:return "RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION";
4699 case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: return"RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY";
4700 case RIL_REQUEST_CDMA_SUBSCRIPTION: return"RIL_REQUEST_CDMA_SUBSCRIPTION";
4701 case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: return "RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM";
4702 case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: return "RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM";
4703 case RIL_REQUEST_DEVICE_IDENTITY: return "RIL_REQUEST_DEVICE_IDENTITY";
4704 case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: return "RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE";
4705 case RIL_REQUEST_GET_SMSC_ADDRESS: return "RIL_REQUEST_GET_SMSC_ADDRESS";
4706 case RIL_REQUEST_SET_SMSC_ADDRESS: return "RIL_REQUEST_SET_SMSC_ADDRESS";
4707 case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: return "RIL_REQUEST_REPORT_SMS_MEMORY_STATUS";
4708 case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: return "RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING";
4709 case RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE: return "RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE";
4710 case RIL_REQUEST_ISIM_AUTHENTICATION: return "RIL_REQUEST_ISIM_AUTHENTICATION";
4711 case RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU: return "RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU";
4712 case RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS: return "RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS";
4713 case RIL_REQUEST_VOICE_RADIO_TECH: return "RIL_REQUEST_VOICE_RADIO_TECH";
4714 case RIL_REQUEST_GET_CELL_INFO_LIST: return"RIL_REQUEST_GET_CELL_INFO_LIST";
4715 case RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE: return"RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE";
4716 case RIL_REQUEST_SET_INITIAL_ATTACH_APN: return "RIL_REQUEST_SET_INITIAL_ATTACH_APN";
4717 case RIL_REQUEST_IMS_REGISTRATION_STATE: return "RIL_REQUEST_IMS_REGISTRATION_STATE";
4718 case RIL_REQUEST_IMS_SEND_SMS: return "RIL_REQUEST_IMS_SEND_SMS";
4719 case RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC: return "RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC";
4720 case RIL_REQUEST_SIM_OPEN_CHANNEL: return "RIL_REQUEST_SIM_OPEN_CHANNEL";
4721 case RIL_REQUEST_SIM_CLOSE_CHANNEL: return "RIL_REQUEST_SIM_CLOSE_CHANNEL";
4722 case RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL: return "RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL";
4723 case RIL_REQUEST_GET_RADIO_CAPABILITY: return "RIL_REQUEST_GET_RADIO_CAPABILITY";
4724 case RIL_REQUEST_SET_RADIO_CAPABILITY: return "RIL_REQUEST_SET_RADIO_CAPABILITY";
4725 case RIL_REQUEST_SET_UICC_SUBSCRIPTION: return "RIL_REQUEST_SET_UICC_SUBSCRIPTION";
4726 case RIL_REQUEST_ALLOW_DATA: return "RIL_REQUEST_ALLOW_DATA";
4727 case RIL_REQUEST_GET_HARDWARE_CONFIG: return "RIL_REQUEST_GET_HARDWARE_CONFIG";
4728 case RIL_REQUEST_SIM_AUTHENTICATION: return "RIL_REQUEST_SIM_AUTHENTICATION";
4729 case RIL_REQUEST_GET_DC_RT_INFO: return "RIL_REQUEST_GET_DC_RT_INFO";
4730 case RIL_REQUEST_SET_DC_RT_INFO_RATE: return "RIL_REQUEST_SET_DC_RT_INFO_RATE";
4731 case RIL_REQUEST_SET_DATA_PROFILE: return "RIL_REQUEST_SET_DATA_PROFILE";
4732 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return "RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED";
4733 case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return "RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED";
4734 case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: return "RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED";
4735 case RIL_UNSOL_RESPONSE_NEW_SMS: return "RIL_UNSOL_RESPONSE_NEW_SMS";
4736 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: return "RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT";
4737 case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: return "RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM";
4738 case RIL_UNSOL_ON_USSD: return "RIL_UNSOL_ON_USSD";
4739 case RIL_UNSOL_ON_USSD_REQUEST: return "RIL_UNSOL_ON_USSD_REQUEST";
4740 case RIL_UNSOL_NITZ_TIME_RECEIVED: return "RIL_UNSOL_NITZ_TIME_RECEIVED";
4741 case RIL_UNSOL_SIGNAL_STRENGTH: return "RIL_UNSOL_SIGNAL_STRENGTH";
4742 case RIL_UNSOL_STK_SESSION_END: return "RIL_UNSOL_STK_SESSION_END";
4743 case RIL_UNSOL_STK_PROACTIVE_COMMAND: return "RIL_UNSOL_STK_PROACTIVE_COMMAND";
4744 case RIL_UNSOL_STK_EVENT_NOTIFY: return "RIL_UNSOL_STK_EVENT_NOTIFY";
4745 case RIL_UNSOL_STK_CALL_SETUP: return "RIL_UNSOL_STK_CALL_SETUP";
4746 case RIL_UNSOL_SIM_SMS_STORAGE_FULL: return "RIL_UNSOL_SIM_SMS_STORAGE_FULL";
4747 case RIL_UNSOL_SIM_REFRESH: return "RIL_UNSOL_SIM_REFRESH";
4748 case RIL_UNSOL_DATA_CALL_LIST_CHANGED: return "RIL_UNSOL_DATA_CALL_LIST_CHANGED";
4749 case RIL_UNSOL_CALL_RING: return "RIL_UNSOL_CALL_RING";
4750 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: return "RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED";
4751 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: return "RIL_UNSOL_RESPONSE_CDMA_NEW_SMS";
4752 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: return "RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS";
4753 case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: return "RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL";
4754 case RIL_UNSOL_RESTRICTED_STATE_CHANGED: return "RIL_UNSOL_RESTRICTED_STATE_CHANGED";
4755 case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: return "RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE";
4756 case RIL_UNSOL_CDMA_CALL_WAITING: return "RIL_UNSOL_CDMA_CALL_WAITING";
4757 case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: return "RIL_UNSOL_CDMA_OTA_PROVISION_STATUS";
4758 case RIL_UNSOL_CDMA_INFO_REC: return "RIL_UNSOL_CDMA_INFO_REC";
4759 case RIL_UNSOL_OEM_HOOK_RAW: return "RIL_UNSOL_OEM_HOOK_RAW";
4760 case RIL_UNSOL_RINGBACK_TONE: return "RIL_UNSOL_RINGBACK_TONE";
4761 case RIL_UNSOL_RESEND_INCALL_MUTE: return "RIL_UNSOL_RESEND_INCALL_MUTE";
4762 case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: return "RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED";
4763 case RIL_UNSOL_CDMA_PRL_CHANGED: return "RIL_UNSOL_CDMA_PRL_CHANGED";
4764 case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: return "RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE";
4765 case RIL_UNSOL_RIL_CONNECTED: return "RIL_UNSOL_RIL_CONNECTED";
4766 case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED: return "RIL_UNSOL_VOICE_RADIO_TECH_CHANGED";
4767 case RIL_UNSOL_CELL_INFO_LIST: return "RIL_UNSOL_CELL_INFO_LIST";
4768 case RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED: return "RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED";
4769 case RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED: return "RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED";
4770 case RIL_UNSOL_SRVCC_STATE_NOTIFY: return "RIL_UNSOL_SRVCC_STATE_NOTIFY";
4771 case RIL_UNSOL_HARDWARE_CONFIG_CHANGED: return "RIL_UNSOL_HARDWARE_CONFIG_CHANGED";
4772 case RIL_UNSOL_DC_RT_INFO_CHANGED: return "RIL_UNSOL_DC_RT_INFO_CHANGED";
4773 case RIL_REQUEST_SHUTDOWN: return "RIL_REQUEST_SHUTDOWN";
4774 case RIL_UNSOL_RADIO_CAPABILITY: return "RIL_UNSOL_RADIO_CAPABILITY";
4775 case RIL_REQUEST_SET_TRM: return "RIL_REQUEST_SET_TRM";
4776 case RIL_REQUEST_SET_IMS_ENABLE:return "RIL_REQUEST_SET_IMS_ENABLE";
4777 case RIL_REQUEST_SET_AUDIO_PATH: return "RIL_REQUEST_SET_AUDIO_PATH";
4778 case RIL_REQUEST_HANGUP_ALL: return "RIL_REQUEST_HANGUP_ALL";
4779 case RIL_REQUEST_FORCE_RELEASE_CALL: return "RIL_REQUEST_FORCE_RELEASE_CALL";
4780 case RIL_REQUEST_EMERGENCY_DIAL: return "RIL_REQUEST_EMERGENCY_DIAL";
4781 case RIL_REQUEST_SET_ECC_SERVICE_CATEGORY: return "RIL_REQUEST_SET_ECC_SERVICE_CATEGORY";
4782 case RIL_REQUEST_SET_ECC_LIST: return "RIL_REQUEST_SET_ECC_LIST";
4783 case RIL_REQUEST_AT_COMMAND_WITH_PROXY: return "RIL_REQUEST_AT_COMMAND_WITH_PROXY";
4784 case RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION: return "RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION";
4785 case RIL_REQUEST_SET_CLIP: return "RIL_REQUEST_SET_CLIP";
4786 case RIL_REQUEST_GET_COLP: return "RIL_REQUEST_GET_COLP";
4787 case RIL_REQUEST_SET_COLP: return "RIL_REQUEST_SET_COLP";
4788 case RIL_REQUEST_GET_COLR: return "RIL_REQUEST_GET_COLR";
4789 case RIL_REQUEST_ADD_IMS_CONFERENCE_CALL_MEMBER: return "RIL_REQUEST_ADD_IMS_CONFERENCE_CALL_MEMBER";
4790 case RIL_REQUEST_REMOVE_IMS_CONFERENCE_CALL_MEMBER: return "RIL_REQUEST_REMOVE_IMS_CONFERENCE_CALL_MEMBER";
4791 case RIL_REQUEST_CONFERENCE_DIAL: return "RIL_REQUEST_CONFERENCE_DIAL";
4792 case RIL_REQUEST_DIAL_WITH_SIP_URI: return "RIL_REQUEST_DIAL_WITH_SIP_URI";
4793 case RIL_REQUEST_HOLD_CALL: return "RIL_REQUEST_HOLD_CALL";
4794 case RIL_REQUEST_RESUME_CALL: return "RIL_REQUEST_RESUME_CALL";
4795 case RIL_UNSOL_ECONF_SRVCC_INDICATION : return "RIL_UNSOL_ECONF_SRVCC_INDICATION";
4796 case RIL_UNSOL_ECONF_RESULT_INDICATION : return "RIL_UNSOL_ECONF_RESULT_INDICATION";
4797 case RIL_UNSOL_MAL_AT_INFO : return "RIL_UNSOL_MAL_AT_INFO";
4798 case RIL_REQUEST_MODEM_POWEROFF: return "RIL_REQUEST_MODEM_POWEROFF";
4799 case RIL_REQUEST_MODEM_POWERON: return "RIL_REQUEST_MODEM_POWERON";
4800 case RIL_REQUEST_WRITE_SMS_TO_SIM: return "RIL_REQUEST_WRITE_SMS_TO_SIM";
4801 case RIL_REQUEST_QUERY_ICCID: return "RIL_REQUEST_QUERY_ICCID";
4802 case RIL_UNSOL_TX_POWER: return "RIL_UNSOL_TX_POWER";
4803 case RIL_UNSOL_NETWORK_INFO: return "RIL_UNSOL_NETWORK_INFO";
4804 case RIL_REQUEST_DELETE_SMS_ON_SIM: return "RIL_REQUEST_DELETE_SMS_ON_SIM";
4805 case RIL_REQUEST_SET_IMSCFG: return "RIL_REQUEST_SET_IMSCFG";
4806#ifdef ECALL_SUPPORT
4807 case RIL_REQUEST_ECALL_FAST_MAKE_ECALL: return "RIL_REQUEST_ECALL_FAST_MAKE_ECALL";
4808 case RIL_REQUEST_ECALL_SET_IVS: return "RIL_REQUEST_ECALL_SET_IVS";
4809 case RIL_REQUEST_ECALL_SET_PSAP: return "RIL_REQUEST_ECALL_SET_PSAP";
4810 case RIL_REQUEST_ECALL_MAKE_ECALL: return "RIL_REQUEST_ECALL_MAKE_ECALL";
4811 case RIL_REQUEST_ECALL_IVS_PUSH_MSD: return "RIL_REQUEST_ECALL_IVS_PUSH_MSD";
4812 case RIL_REQUEST_ECALL_PSAP_PULL_MSD: return "RIL_REQUEST_ECALL_PSAP_PULL_MSD";
4813 case RIL_UNSOL_ECALL_MSDHACK : return "RIL_UNSOL_ECALL_MSDHACK";
4814 case RIL_REQUEST_ECALL_SET_MSD: return "RIL_REQUEST_ECALL_SET_MSD";
4815 case RIL_REQUEST_ECALL_CTRL_SEQUENCE: return "RIL_REQUEST_ECALL_CTRL_SEQUENCE";
4816 case RIL_UNSOL_ECALL_INDICATIONS : return "RIL_UNSOL_ECALL_INDICATIONS";
4817 case RIL_REQUEST_ECALL_RESET_IVS: return "RIL_REQUEST_ECALL_RESET_IVS";
4818 case RIL_REQUEST_ECALL_SET_PRI: return "RIL_REQUEST_ECALL_SET_PRI";
4819 case RIL_REQUEST_ECALL_SET_TEST_NUM: return "RIL_REQUEST_ECALL_SET_TEST_NUM";
4820 case RIL_REQUEST_ECALL_SET_RECONF_NUM: return "RIL_REQUEST_ECALL_SET_RECONF_NUM";
4821 case RIL_REQUEST_SYNC_DATA_SETTINGS_TO_MD: return "RIL_REQUEST_SYNC_DATA_SETTINGS_TO_MD";
4822 case RIL_REQUEST_ECALL_SET_NAD_DEREGISTRATION_TIME: return "RIL_REQUEST_ECALL_SET_NAD_DEREGISTRATION_TIME";
4823 case RIL_REQUEST_ECALL_SET_REGISTRATION_STATE: return "RIL_REQUEST_ECALL_SET_REGISTRATION_STATE";
4824#endif /*ECALL_SUPPORT*/
4825#ifdef KEEP_ALIVE
4826 case RIL_REQUEST_START_KEEPALIVE_PRO: return "RIL_REQUEST_START_KEEPALIVE_PRO";
4827 case RIL_REQUEST_STOP_KEEPALIVE_PRO: return "RIL_REQUEST_STOP_KEEPALIVE_PRO";
4828 case RIL_UNSOL_KEEPALIVE_STATUS_PRO: return "RIL_UNSOL_KEEPALIVE_STATUS_PRO";
4829#endif /*KEEP_ALIVE*/
4830 case RIL_REQUEST_SEND_USSI: return "RIL_REQUEST_SEND_USSI";
4831 case RIL_REQUEST_CANCEL_USSI: return "RIL_REQUEST_CANCEL_USSI";
4832 case RIL_REQUEST_GET_SMS_SIM_MEM_STATUS: return "RIL_REQUEST_GET_SMS_SIM_MEM_STATUS";
4833 case RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR: return "RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR";
4834 case RIL_REQUEST_REPORT_AIRPLANE_MODE: return "RIL_REQUEST_REPORT_AIRPLANE_MODE";
4835 case RIL_REQUEST_SET_ECC_NUM: return "RIL_REQUEST_SET_ECC_NUM";
4836 case RIL_REQUEST_GET_ECC_NUM: return "RIL_REQUEST_GET_ECC_NUM";
4837 case RIL_UNSOL_ECC_NUM: return "RIL_UNSOL_ECC_NUM";
4838 case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS_WITH_ACT: return "RIL_REQUEST_QUERY_AVAILABLE_NETWORKS_WITH_ACT";
4839 case RIL_REQUEST_GSM_GET_BROADCAST_LANGUAGE: return "RIL_REQUEST_GSM_GET_BROADCAST_LANGUAGE";
4840 case RIL_REQUEST_GSM_SET_BROADCAST_LANGUAGE: return "RIL_REQUEST_GSM_SET_BROADCAST_LANGUAGE";
4841 case RIL_UNSOL_CALL_INFO_INDICATION: return "RIL_UNSOL_CALL_INFO_INDICATION";
4842#ifdef TARGET_PLATFORM_MT2731
4843 case RIL_REQUEST_MODIFY_APN: return "RIL_REQUEST_MODIFY_APN";
4844 case RIL_REQUEST_RESET_APN: return "RIL_REQUEST_RESET_APN";
4845#endif
4846 case RIL_REQUEST_QUERY_SIM_RETRY_COUNT: return "RIL_REQUEST_QUERY_SIM_RETRY_COUNT";
4847 case RIL_REQUEST_QUERY_EID: return "RIL_REQUEST_QUERY_EID";
4848 /*LYNQ CMD*/
4849 case LYNQ_AUTO_ANSWER_CALL: return "LYNQ_AUTO_ANSWER_CALL";
4850 case LYNQ_REQUEST_SET_DTMF_VOLUME: return "RIL_REQUEST_SET_DTMF_VOLUME";
4851 default: return "<unknown request>";
4852 }
4853}
4854
4855const char *
4856requestToString(int request) {
4857/*
4858 cat libs/telephony/ril_commands.h \
4859 | egrep "^ *{RIL_" \
4860 | sed -re 's/\{RIL_([^,]+),[^,]+,([^}]+).+/case RIL_\1: return "\1";/'
4861
4862
4863 cat libs/telephony/ril_unsol_commands.h \
4864 | egrep "^ *{RIL_" \
4865 | sed -re 's/\{RIL_([^,]+),([^}]+).+/case RIL_\1: return "\1";/'
4866
4867*/
4868 switch(request) {
4869 case RIL_REQUEST_GET_SIM_STATUS: return "GET_SIM_STATUS";
4870 case RIL_REQUEST_ENTER_SIM_PIN: return "ENTER_SIM_PIN";
4871 case RIL_REQUEST_ENTER_SIM_PUK: return "ENTER_SIM_PUK";
4872 case RIL_REQUEST_ENTER_SIM_PIN2: return "ENTER_SIM_PIN2";
4873 case RIL_REQUEST_ENTER_SIM_PUK2: return "ENTER_SIM_PUK2";
4874 case RIL_REQUEST_CHANGE_SIM_PIN: return "CHANGE_SIM_PIN";
4875 case RIL_REQUEST_CHANGE_SIM_PIN2: return "CHANGE_SIM_PIN2";
4876 case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: return "ENTER_NETWORK_DEPERSONALIZATION";
4877 case RIL_REQUEST_GET_CURRENT_CALLS: return "GET_CURRENT_CALLS";
4878 case RIL_REQUEST_DIAL: return "DIAL";
4879 case RIL_REQUEST_GET_IMSI: return "GET_IMSI";
4880 case RIL_REQUEST_HANGUP: return "HANGUP";
4881 case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: return "HANGUP_WAITING_OR_BACKGROUND";
4882 case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: return "HANGUP_FOREGROUND_RESUME_BACKGROUND";
4883 case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: return "SWITCH_WAITING_OR_HOLDING_AND_ACTIVE";
4884 case RIL_REQUEST_CONFERENCE: return "CONFERENCE";
4885 case RIL_REQUEST_UDUB: return "UDUB";
4886 case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: return "LAST_CALL_FAIL_CAUSE";
4887 case RIL_REQUEST_SIGNAL_STRENGTH: return "SIGNAL_STRENGTH";
4888 case RIL_REQUEST_VOICE_REGISTRATION_STATE: return "VOICE_REGISTRATION_STATE";
4889 case RIL_REQUEST_DATA_REGISTRATION_STATE: return "DATA_REGISTRATION_STATE";
4890 case RIL_REQUEST_OPERATOR: return "OPERATOR";
4891 case RIL_REQUEST_RADIO_POWER: return "RADIO_POWER";
4892 case RIL_REQUEST_DTMF: return "DTMF";
4893 case RIL_REQUEST_SEND_SMS: return "SEND_SMS";
4894 case RIL_REQUEST_SEND_SMS_EXPECT_MORE: return "SEND_SMS_EXPECT_MORE";
4895 case RIL_REQUEST_SETUP_DATA_CALL: return "SETUP_DATA_CALL";
4896 case RIL_REQUEST_SIM_IO: return "SIM_IO";
4897 case RIL_REQUEST_SEND_USSD: return "SEND_USSD";
4898 case RIL_REQUEST_CANCEL_USSD: return "CANCEL_USSD";
4899 case RIL_REQUEST_GET_CLIR: return "GET_CLIR";
4900 case RIL_REQUEST_SET_CLIR: return "SET_CLIR";
4901 case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: return "QUERY_CALL_FORWARD_STATUS";
4902 case RIL_REQUEST_SET_CALL_FORWARD: return "SET_CALL_FORWARD";
4903 case RIL_REQUEST_QUERY_CALL_WAITING: return "QUERY_CALL_WAITING";
4904 case RIL_REQUEST_SET_CALL_WAITING: return "SET_CALL_WAITING";
4905 case RIL_REQUEST_SMS_ACKNOWLEDGE: return "SMS_ACKNOWLEDGE";
4906 case RIL_REQUEST_GET_IMEI: return "GET_IMEI";
4907 case RIL_REQUEST_GET_IMEISV: return "GET_IMEISV";
4908 case RIL_REQUEST_ANSWER: return "ANSWER";
4909 case RIL_REQUEST_DEACTIVATE_DATA_CALL: return "DEACTIVATE_DATA_CALL";
4910 case RIL_REQUEST_QUERY_FACILITY_LOCK: return "QUERY_FACILITY_LOCK";
4911 case RIL_REQUEST_SET_FACILITY_LOCK: return "SET_FACILITY_LOCK";
4912 case RIL_REQUEST_CHANGE_BARRING_PASSWORD: return "CHANGE_BARRING_PASSWORD";
4913 case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: return "QUERY_NETWORK_SELECTION_MODE";
4914 case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: return "SET_NETWORK_SELECTION_AUTOMATIC";
4915 case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: return "SET_NETWORK_SELECTION_MANUAL";
4916 case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : return "QUERY_AVAILABLE_NETWORKS ";
4917 case RIL_REQUEST_DTMF_START: return "DTMF_START";
4918 case RIL_REQUEST_DTMF_STOP: return "DTMF_STOP";
4919 case RIL_REQUEST_BASEBAND_VERSION: return "BASEBAND_VERSION";
4920 case RIL_REQUEST_SEPARATE_CONNECTION: return "SEPARATE_CONNECTION";
4921 case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: return "SET_PREFERRED_NETWORK_TYPE";
4922 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: return "GET_PREFERRED_NETWORK_TYPE";
4923 case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: return "GET_NEIGHBORING_CELL_IDS";
4924 case RIL_REQUEST_SET_MUTE: return "SET_MUTE";
4925 case RIL_REQUEST_GET_MUTE: return "GET_MUTE";
4926 case RIL_REQUEST_QUERY_CLIP: return "QUERY_CLIP";
4927 case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: return "LAST_DATA_CALL_FAIL_CAUSE";
4928 case RIL_REQUEST_DATA_CALL_LIST: return "DATA_CALL_LIST";
4929 case RIL_REQUEST_RESET_RADIO: return "RESET_RADIO";
4930 case RIL_REQUEST_OEM_HOOK_RAW: return "OEM_HOOK_RAW";
4931 case RIL_REQUEST_OEM_HOOK_STRINGS: return "OEM_HOOK_STRINGS";
4932 case RIL_REQUEST_SET_BAND_MODE: return "SET_BAND_MODE";
4933 case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: return "QUERY_AVAILABLE_BAND_MODE";
4934 case RIL_REQUEST_STK_GET_PROFILE: return "STK_GET_PROFILE";
4935 case RIL_REQUEST_STK_SET_PROFILE: return "STK_SET_PROFILE";
4936 case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: return "STK_SEND_ENVELOPE_COMMAND";
4937 case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: return "STK_SEND_TERMINAL_RESPONSE";
4938 case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: return "STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM";
4939 case RIL_REQUEST_SCREEN_STATE: return "SCREEN_STATE";
4940 case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: return "EXPLICIT_CALL_TRANSFER";
4941 case RIL_REQUEST_SET_LOCATION_UPDATES: return "SET_LOCATION_UPDATES";
4942 case RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE:return"CDMA_SET_SUBSCRIPTION_SOURCE";
4943 case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE:return"CDMA_SET_ROAMING_PREFERENCE";
4944 case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE:return"CDMA_QUERY_ROAMING_PREFERENCE";
4945 case RIL_REQUEST_SET_TTY_MODE:return"SET_TTY_MODE";
4946 case RIL_REQUEST_QUERY_TTY_MODE:return"QUERY_TTY_MODE";
4947 case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE";
4948 case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE";
4949 case RIL_REQUEST_CDMA_FLASH:return"CDMA_FLASH";
4950 case RIL_REQUEST_CDMA_BURST_DTMF:return"CDMA_BURST_DTMF";
4951 case RIL_REQUEST_CDMA_SEND_SMS:return"CDMA_SEND_SMS";
4952 case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE:return"CDMA_SMS_ACKNOWLEDGE";
4953 case RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG:return"GSM_GET_BROADCAST_SMS_CONFIG";
4954 case RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG:return"GSM_SET_BROADCAST_SMS_CONFIG";
4955 case RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION:return "GSM_SMS_BROADCAST_ACTIVATION";
4956 case RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG:return "CDMA_GET_BROADCAST_SMS_CONFIG";
4957 case RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG:return "CDMA_SET_BROADCAST_SMS_CONFIG";
4958 case RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION:return "CDMA_SMS_BROADCAST_ACTIVATION";
4959 case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: return"CDMA_VALIDATE_AND_WRITE_AKEY";
4960 case RIL_REQUEST_CDMA_SUBSCRIPTION: return"CDMA_SUBSCRIPTION";
4961 case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: return "CDMA_WRITE_SMS_TO_RUIM";
4962 case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: return "CDMA_DELETE_SMS_ON_RUIM";
4963 case RIL_REQUEST_DEVICE_IDENTITY: return "DEVICE_IDENTITY";
4964 case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: return "EXIT_EMERGENCY_CALLBACK_MODE";
4965 case RIL_REQUEST_GET_SMSC_ADDRESS: return "GET_SMSC_ADDRESS";
4966 case RIL_REQUEST_SET_SMSC_ADDRESS: return "SET_SMSC_ADDRESS";
4967 case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: return "REPORT_SMS_MEMORY_STATUS";
4968 case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: return "REPORT_STK_SERVICE_IS_RUNNING";
4969 case RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE: return "CDMA_GET_SUBSCRIPTION_SOURCE";
4970 case RIL_REQUEST_ISIM_AUTHENTICATION: return "ISIM_AUTHENTICATION";
4971 case RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU: return "RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU";
4972 case RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS: return "RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS";
4973 case RIL_REQUEST_VOICE_RADIO_TECH: return "VOICE_RADIO_TECH";
4974 case RIL_REQUEST_GET_CELL_INFO_LIST: return"GET_CELL_INFO_LIST";
4975 case RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE: return"SET_UNSOL_CELL_INFO_LIST_RATE";
4976 case RIL_REQUEST_SET_INITIAL_ATTACH_APN: return "RIL_REQUEST_SET_INITIAL_ATTACH_APN";
4977 case RIL_REQUEST_IMS_REGISTRATION_STATE: return "IMS_REGISTRATION_STATE";
4978 case RIL_REQUEST_IMS_SEND_SMS: return "IMS_SEND_SMS";
4979 case RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC: return "SIM_TRANSMIT_APDU_BASIC";
4980 case RIL_REQUEST_SIM_OPEN_CHANNEL: return "SIM_OPEN_CHANNEL";
4981 case RIL_REQUEST_SIM_CLOSE_CHANNEL: return "SIM_CLOSE_CHANNEL";
4982 case RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL: return "SIM_TRANSMIT_APDU_CHANNEL";
4983 case RIL_REQUEST_GET_RADIO_CAPABILITY: return "RIL_REQUEST_GET_RADIO_CAPABILITY";
4984 case RIL_REQUEST_SET_RADIO_CAPABILITY: return "RIL_REQUEST_SET_RADIO_CAPABILITY";
4985 case RIL_REQUEST_SET_UICC_SUBSCRIPTION: return "SET_UICC_SUBSCRIPTION";
4986 case RIL_REQUEST_ALLOW_DATA: return "ALLOW_DATA";
4987 case RIL_REQUEST_GET_HARDWARE_CONFIG: return "GET_HARDWARE_CONFIG";
4988 case RIL_REQUEST_SIM_AUTHENTICATION: return "SIM_AUTHENTICATION";
4989 case RIL_REQUEST_GET_DC_RT_INFO: return "GET_DC_RT_INFO";
4990 case RIL_REQUEST_SET_DC_RT_INFO_RATE: return "SET_DC_RT_INFO_RATE";
4991 case RIL_REQUEST_SET_DATA_PROFILE: return "SET_DATA_PROFILE";
4992 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return "UNSOL_RESPONSE_RADIO_STATE_CHANGED";
4993 case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return "UNSOL_RESPONSE_CALL_STATE_CHANGED";
4994 case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: return "UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED";
4995 case RIL_UNSOL_RESPONSE_NEW_SMS: return "UNSOL_RESPONSE_NEW_SMS";
4996 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: return "UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT";
4997 case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: return "UNSOL_RESPONSE_NEW_SMS_ON_SIM";
4998 case RIL_UNSOL_ON_USSD: return "UNSOL_ON_USSD";
4999 case RIL_UNSOL_ON_USSD_REQUEST: return "UNSOL_ON_USSD_REQUEST(obsolete)";
5000 case RIL_UNSOL_NITZ_TIME_RECEIVED: return "UNSOL_NITZ_TIME_RECEIVED";
5001 case RIL_UNSOL_SIGNAL_STRENGTH: return "UNSOL_SIGNAL_STRENGTH";
5002 case RIL_UNSOL_STK_SESSION_END: return "UNSOL_STK_SESSION_END";
5003 case RIL_UNSOL_STK_PROACTIVE_COMMAND: return "UNSOL_STK_PROACTIVE_COMMAND";
5004 case RIL_UNSOL_STK_EVENT_NOTIFY: return "UNSOL_STK_EVENT_NOTIFY";
5005 case RIL_UNSOL_STK_CALL_SETUP: return "UNSOL_STK_CALL_SETUP";
5006 case RIL_UNSOL_SIM_SMS_STORAGE_FULL: return "UNSOL_SIM_SMS_STORAGE_FUL";
5007 case RIL_UNSOL_SIM_REFRESH: return "UNSOL_SIM_REFRESH";
5008 case RIL_UNSOL_DATA_CALL_LIST_CHANGED: return "UNSOL_DATA_CALL_LIST_CHANGED";
5009 case RIL_UNSOL_CALL_RING: return "UNSOL_CALL_RING";
5010 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: return "UNSOL_RESPONSE_SIM_STATUS_CHANGED";
5011 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: return "UNSOL_NEW_CDMA_SMS";
5012 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: return "UNSOL_NEW_BROADCAST_SMS";
5013 case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: return "UNSOL_CDMA_RUIM_SMS_STORAGE_FULL";
5014 case RIL_UNSOL_RESTRICTED_STATE_CHANGED: return "UNSOL_RESTRICTED_STATE_CHANGED";
5015 case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: return "UNSOL_ENTER_EMERGENCY_CALLBACK_MODE";
5016 case RIL_UNSOL_CDMA_CALL_WAITING: return "UNSOL_CDMA_CALL_WAITING";
5017 case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: return "UNSOL_CDMA_OTA_PROVISION_STATUS";
5018 case RIL_UNSOL_CDMA_INFO_REC: return "UNSOL_CDMA_INFO_REC";
5019 case RIL_UNSOL_OEM_HOOK_RAW: return "UNSOL_OEM_HOOK_RAW";
5020 case RIL_UNSOL_RINGBACK_TONE: return "UNSOL_RINGBACK_TONE";
5021 case RIL_UNSOL_RESEND_INCALL_MUTE: return "UNSOL_RESEND_INCALL_MUTE";
5022 case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: return "UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED";
5023 case RIL_UNSOL_CDMA_PRL_CHANGED: return "UNSOL_CDMA_PRL_CHANGED";
5024 case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: return "UNSOL_EXIT_EMERGENCY_CALLBACK_MODE";
5025 case RIL_UNSOL_RIL_CONNECTED: return "UNSOL_RIL_CONNECTED";
5026 case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED: return "UNSOL_VOICE_RADIO_TECH_CHANGED";
5027 case RIL_UNSOL_CELL_INFO_LIST: return "UNSOL_CELL_INFO_LIST";
5028 case RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED: return "RESPONSE_IMS_NETWORK_STATE_CHANGED";
5029 case RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED: return "UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED";
5030 case RIL_UNSOL_SRVCC_STATE_NOTIFY: return "UNSOL_SRVCC_STATE_NOTIFY";
5031 case RIL_UNSOL_HARDWARE_CONFIG_CHANGED: return "HARDWARE_CONFIG_CHANGED";
5032 case RIL_UNSOL_DC_RT_INFO_CHANGED: return "UNSOL_DC_RT_INFO_CHANGED";
5033 case RIL_REQUEST_SHUTDOWN: return "SHUTDOWN";
5034 case RIL_UNSOL_RADIO_CAPABILITY: return "RIL_UNSOL_RADIO_CAPABILITY";
5035 case RIL_REQUEST_SET_TRM: return "RIL_REQUEST_SET_TRM";
5036 case RIL_REQUEST_SET_IMS_ENABLE:return "RIL_REQUEST_SET_IMS_ENABLE";
5037 case RIL_REQUEST_SET_AUDIO_PATH: return "SET_AUDIO_PATH";
5038 case RIL_REQUEST_HANGUP_ALL: return "HANGUP_ALL";
5039 case RIL_REQUEST_FORCE_RELEASE_CALL: return "FORCE_RELEASE_CALL";
5040 case RIL_REQUEST_EMERGENCY_DIAL: return "RIL_REQUEST_EMERGENCY_DIAL";
5041 case RIL_REQUEST_SET_ECC_SERVICE_CATEGORY: return "RIL_REQUEST_SET_ECC_SERVICE_CATEGORY";
5042 case RIL_REQUEST_SET_ECC_LIST: return "RIL_REQUEST_SET_ECC_LIST";
5043 case RIL_REQUEST_AT_COMMAND_WITH_PROXY: return "AT_COMMAND_WITH_PROXY";
5044 case RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION: return "RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION";
5045 case RIL_REQUEST_SET_CLIP: return "RIL_REQUEST_SET_CLIP";
5046 case RIL_REQUEST_GET_COLP: return "RIL_REQUEST_GET_COLP";
5047 case RIL_REQUEST_SET_COLP: return "RIL_REQUEST_SET_COLP";
5048 case RIL_REQUEST_GET_COLR: return "RIL_REQUEST_GET_COLR";
5049 case RIL_REQUEST_ADD_IMS_CONFERENCE_CALL_MEMBER: return "ADD_IMS_CONFERENCE_CALL_MEMBER";
5050 case RIL_REQUEST_REMOVE_IMS_CONFERENCE_CALL_MEMBER: return "REMOVE_IMS_CONFERENCE_CALL_MEMBER";
5051 case RIL_REQUEST_CONFERENCE_DIAL: return "CONFERENCE_DIAL";
5052 case RIL_REQUEST_DIAL_WITH_SIP_URI: return "DIAL_WITH_SIP_URI";
5053 case RIL_REQUEST_HOLD_CALL: return "HOLD_CALL";
5054 case RIL_REQUEST_RESUME_CALL: return "RESUME_CALL";
5055 case RIL_UNSOL_ECONF_SRVCC_INDICATION : return "ECONF_SRVCC_INDICATION";
5056 case RIL_UNSOL_ECONF_RESULT_INDICATION : return "ECONF_RESULT_INDICATION";
5057 case RIL_UNSOL_MAL_AT_INFO : return "UNSOL_MAL_AT_INFO";
5058 case RIL_REQUEST_MODEM_POWEROFF: return "MODEM_POWEROFF";
5059 case RIL_REQUEST_MODEM_POWERON: return "MODEM_POWERON";
5060 case RIL_REQUEST_WRITE_SMS_TO_SIM: return "WRITE_SMS_TO_SIM";
5061 case RIL_REQUEST_QUERY_ICCID: return "RIL_REQUEST_QUERY_ICCID";
5062 case RIL_UNSOL_TX_POWER: return "RIL_UNSOL_TX_POWER";
5063 case RIL_UNSOL_NETWORK_INFO: return "RIL_UNSOL_NETWORK_INFO";
5064 case RIL_REQUEST_DELETE_SMS_ON_SIM: return "DELETE_SMS_ON_SIM";
5065 case RIL_REQUEST_SET_IMSCFG: return "RIL_REQUEST_SET_IMSCFG";
5066#ifdef ECALL_SUPPORT
5067 case RIL_REQUEST_ECALL_FAST_MAKE_ECALL: return "ECALL_FAST_MAKE_ECALL";
5068 case RIL_REQUEST_ECALL_SET_IVS: return "RIL_REQUEST_ECALL_SET_IVS";
5069 case RIL_REQUEST_ECALL_SET_PSAP: return "RIL_REQUEST_ECALL_SET_PSAP";
5070 case RIL_REQUEST_ECALL_MAKE_ECALL: return "RIL_REQUEST_ECALL_MAKE_ECALL";
5071 case RIL_REQUEST_ECALL_IVS_PUSH_MSD: return "RIL_REQUEST_ECALL_IVS_PUSH_MSD";
5072 case RIL_REQUEST_ECALL_PSAP_PULL_MSD: return "RIL_REQUEST_ECALL_PSAP_PULL_MSD";
5073 case RIL_UNSOL_ECALL_MSDHACK : return "ECALL_MSDHACK";
5074 case RIL_REQUEST_ECALL_SET_MSD: return "RIL_REQUEST_ECALL_SET_MSD";
5075 case RIL_REQUEST_ECALL_CTRL_SEQUENCE: return "ECALL_SET_CTRL_SEQUENCE";
5076 case RIL_UNSOL_ECALL_INDICATIONS : return "ECALL_INDICATIONS";
5077 case RIL_REQUEST_ECALL_RESET_IVS: return "RIL_REQUEST_ECALL_RESET_IVS";
5078 case RIL_REQUEST_ECALL_SET_PRI: return "RIL_REQUEST_ECALL_SET_PRI";
5079 case RIL_REQUEST_ECALL_SET_TEST_NUM: return "RIL_REQUEST_ECALL_SET_TEST_NUM";
5080 case RIL_REQUEST_ECALL_SET_RECONF_NUM: return "RIL_REQUEST_ECALL_SET_RECONF_NUM";
5081 case RIL_REQUEST_SYNC_DATA_SETTINGS_TO_MD: return "RIL_REQUEST_SYNC_DATA_SETTINGS_TO_MD";
5082 case RIL_REQUEST_ECALL_SET_NAD_DEREGISTRATION_TIME: return "RIL_REQUEST_ECALL_SET_NAD_DEREGISTRATION_TIME";
5083 case RIL_REQUEST_ECALL_SET_REGISTRATION_STATE: return "RIL_REQUEST_ECALL_SET_REGISTRATION_STATE";
5084#endif /*ECALL_SUPPORT*/
5085#ifdef KEEP_ALIVE
5086 case RIL_REQUEST_START_KEEPALIVE_PRO: return "RIL_REQUEST_START_KEEPALIVE_PRO";
5087 case RIL_REQUEST_STOP_KEEPALIVE_PRO: return "RIL_REQUEST_STOP_KEEPALIVE_PRO";
5088 case RIL_UNSOL_KEEPALIVE_STATUS_PRO: return "RIL_UNSOL_KEEPALIVE_STATUS_PRO";
5089#endif /*KEEP_ALIVE*/
5090 case RIL_REQUEST_SEND_USSI: return "SEND_USSI";
5091 case RIL_REQUEST_CANCEL_USSI: return "CANCEL_USSI";
5092 case RIL_REQUEST_GET_SMS_SIM_MEM_STATUS: return "GET_SMS_SIM_MEM_STATUS";
5093 case RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR: return "RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR";
5094 case RIL_REQUEST_REPORT_AIRPLANE_MODE: return "RIL_REQUEST_REPORT_AIRPLANE_MODE";
5095 case RIL_REQUEST_SET_ECC_NUM: return "RIL_REQUEST_SET_ECC_NUM";
5096 case RIL_REQUEST_GET_ECC_NUM: return "RIL_REQUEST_GET_ECC_NUM";
5097 case RIL_UNSOL_ECC_NUM: return "RIL_UNSOL_ECC_NUM";
5098 case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS_WITH_ACT: return "RIL_REQUEST_QUERY_AVAILABLE_NETWORKS_WITH_ACT";
5099 case RIL_REQUEST_GSM_GET_BROADCAST_LANGUAGE: return "RIL_REQUEST_GSM_GET_BROADCAST_LANGUAGE";
5100 case RIL_REQUEST_GSM_SET_BROADCAST_LANGUAGE: return "RIL_REQUEST_GSM_SET_BROADCAST_LANGUAGE";
5101 case RIL_UNSOL_CALL_INFO_INDICATION: return "RIL_UNSOL_CALL_INFO_INDICATION";
5102 case RIL_REQUEST_MODIFY_APN: return "RIL_REQUEST_MODIFY_APN";
5103 case RIL_REQUEST_RESET_APN: return "RIL_REQUEST_RESET_APN";
5104 case RIL_REQUEST_QUERY_SIM_RETRY_COUNT: return "RIL_REQUEST_QUERY_SIM_RETRY_COUNT";
5105 case RIL_REQUEST_QUERY_EID: return "RIL_REQUEST_QUERY_EID";
5106 case LYNQ_REQUEST_SET_DTMF_VOLUME: return "RIL_REQUEST_SET_DTMF_VOLUME";
5107 default: return "<unknown request>";
5108 }
5109}
5110
5111static int sendResponse (Parcel &p, RIL_SOCKET_ID socket_id) {
5112 printResponse;
5113 int type;
5114 if(enable_bt_resp){
5115 SendRespToClient(p.data(), p.dataSize());
5116 }
5117 p.setDataPosition(0);
5118 p.readInt32(&type);
5119 if(type == RESPONSE_UNSOLICITED){
5120 processUnsolicited(p,type);
5121 }else if (type == RESPONSE_SOLICITED){
5122 processSolicited(p,type);
5123 }
5124 return 0;
5125}
5126
5127static void speciaRequest_wait()
5128{
5129 struct timeval now;
5130 struct timespec timeout;
5131
5132 gettimeofday(&now,NULL);
5133 timeout.tv_sec = now.tv_sec+1200; //timeout is 2omin. maybe radio on/off need 10s to complete.
5134 timeout.tv_nsec = now.tv_usec*1000;
5135
5136 SPECIA_BLOCK_LOCK();
5137 while(!(requestOneByOne == 0)) {
5138 int ret = SPECIA_BLOCK_WAIT(&timeout);
5139 if(ret == ETIMEDOUT){
5140 RLOGD("special request wait timeout");
5141 break;
5142 }
5143 }
5144 requestOneByOne = 1;
5145 SPECIA_BLOCK_UNLOCK();
5146}
5147
5148static void speciaRequest_wakeup()
5149{
5150 SPECIA_BLOCK_LOCK();
5151 requestOneByOne = 0;
5152 SPECIA_BLOCK_WAKEUP();
5153 SPECIA_BLOCK_UNLOCK();
5154}
5155
5156static void updateIccCardState(RIL_SOCKET_ID soc_id)
5157{
5158 ARspRequest(RIL_REQUEST_GET_SIM_STATUS, soc_id);
5159}
5160
5161void sendRequestToMd(int request, int id) {
5162 RequestInfo* info = creatRILInfoAndInit(request, INIT, (RIL_SOCKET_ID) ((id)));
5163 switch(request){
5164 case RIL_REQUEST_DEVICE_IDENTITY:
5165 {
5166 getDeviceIdentity(1, NULL, (RIL_SOCKET_ID) ((id)), info);
5167 break;
5168 }
5169 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE:
5170 {
5171 getPreferredNetworkType(1, NULL, (RIL_SOCKET_ID) ((id)), info);
5172 break;
5173 }
5174 case RIL_REQUEST_GET_SIM_STATUS:
5175 {
5176 getIccCardStatus(1, NULL, (RIL_SOCKET_ID) (id), info);
5177 break;
5178 }
5179 case RIL_REQUEST_DATA_REGISTRATION_STATE:
5180 {
5181 getDataRegistrationState(1, NULL, (RIL_SOCKET_ID) (id), info);
5182 break;
5183 }
5184 case RIL_REQUEST_VOICE_REGISTRATION_STATE:
5185 {
5186 getVoiceRegistrationState(1, NULL, (RIL_SOCKET_ID) (id), info);
5187 break;
5188 }
5189 case RIL_REQUEST_VOICE_RADIO_TECH:
5190 {
5191 getVoiceRadioTechnology(1, NULL, (RIL_SOCKET_ID) (id), info);
5192 break;
5193 }
5194 case RIL_REQUEST_OEM_HOOK_RAW:
5195 {
5196 char* tmp[2] = {"RIL_REQUEST_OEM_HOOK_RAW", "AT+ECAL"};
5197 sendATCMD(2, tmp, (RIL_SOCKET_ID) (id), info);
5198 break;
5199 }
5200 case RIL_REQUEST_GET_RADIO_CAPABILITY:
5201 {
5202 getRadioCapability(1, NULL, (RIL_SOCKET_ID) ((id)), info);
5203 break;
5204 }
5205 default:
5206 RLOGE("don't support %d in init", id);
5207 if(info) {
5208 free(info);
5209 }
5210 }
5211}
5212
5213static void init(int id) {
5214 int waittoken;
5215 RIL_RadioState radioState = CALL_ONSTATEREQUEST((RIL_SOCKET_ID )id);
5216 while (radioState == RADIO_STATE_UNAVAILABLE) {
5217 sleep(1);
5218 radioState = CALL_ONSTATEREQUEST((RIL_SOCKET_ID )id);
5219 RLOGD("init socket id: %d, %s", id, radioStateToString(radioState));
5220 }
5221 RLOGD("init socket id: %d, %s", id, radioStateToString(radioState));
5222
5223 sendRequestToMd(RIL_REQUEST_GET_SIM_STATUS, id);
5224
5225#if 0
5226 if (radioState != RADIO_STATE_ON) {
5227 RequestInfo* radio = creatRILInfoAndInit(RIL_REQUEST_RADIO_POWER, INIT, (RIL_SOCKET_ID) (id));
5228 waittoken = radio->token;
5229 RLOGD("[%s-%d]:token is %x", __FUNCTION__, __LINE__, radio->token);
5230 char* tmp[2] = { "RIL_REQUEST_RADIO_POWER", "1" };
5231 setRadioPower(2, tmp, (RIL_SOCKET_ID) (id), radio);
5232 waitResponse(waittoken);
5233 sleep(2);
5234 radioState = CALL_ONSTATEREQUEST((RIL_SOCKET_ID )id);
5235 RLOGD("NOW radio status %s", radioStateToString(radioState));
5236 }
5237# endif
5238 sendRequestToMd(RIL_REQUEST_DATA_REGISTRATION_STATE, id);
5239 sendRequestToMd(RIL_REQUEST_VOICE_REGISTRATION_STATE, id);
5240 sendRequestToMd(RIL_REQUEST_VOICE_RADIO_TECH, id);
5241 sendRequestToMd(RIL_REQUEST_DEVICE_IDENTITY,id);
5242 sendRequestToMd(RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE, id);
5243 sendRequestToMd(RIL_REQUEST_OEM_HOOK_RAW, id);
5244 sendRequestToMd(RIL_REQUEST_GET_RADIO_CAPABILITY,id);
5245}
5246
5247static void initCoditions()
5248{
5249 mixer_init();
5250 if(utils::is_support_dsds()) {
5251 for(int i = 0; i < 2 ; i++) {
5252 init(i);
5253 }
5254 }
5255
5256 if(utils::is_suppport_dsss()) {
5257 int id = Phone_utils::get_enable_sim_for_dsss();
5258 init(id);
5259 }
5260}
5261
5262
5263//For UDP sokcet send response to client
5264static int SendRespToClient(const void *data, size_t dataSize)
5265{
5266 const uint8_t *toWrite;
5267 size_t writeOffset = 0;
5268
5269 toWrite = (const uint8_t *)data;
5270
5271 if (toWrite == NULL) {
5272 //buf is invaild
5273 return -1;
5274 }
5275
5276 while (writeOffset < dataSize) {
5277 ssize_t written;
5278 do {
5279 //written = write (fd, toWrite + writeOffset,dataSize - writeOffset);
5280 written = sendto(server_socket_fd, toWrite + writeOffset, dataSize - writeOffset,
5281 0, (struct sockaddr *)&client_addr, sizeof(client_addr));
5282 } while (written < 0 && ((errno == EINTR) || (errno == EAGAIN)));
5283
5284 if (written >= 0) {
5285 writeOffset += written;
5286 } else { // written < 0
5287 RLOGE ("RIL Response: unexpected error on write errno:%d", errno);
5288 return -1;
5289 }
5290 }
5291
5292 return 0;
5293}
5294
5295static UnsolResponseInfo* find_mtk_unsol_command(int request)
5296{
5297 int i;
5298 for (i = 0; i < (int32_t)NUM_ELEMS(s_mtk_unsolResponses); i++)
5299 if (s_mtk_unsolResponses[i].requestNumber == request)
5300 return (&s_mtk_unsolResponses[i]);
5301 return ((UnsolResponseInfo *)NULL);
5302}
5303
5304static int
5305onSupports (int requestCode)
5306{
5307 switch(requestCode)
5308 {
5309 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return 1;
5310 case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return 1;
5311 case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: return 1;
5312 case RIL_UNSOL_RESPONSE_NEW_SMS: return 1;
5313 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: return 1;
5314 case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: return 1;
5315 case RIL_UNSOL_ON_USSD: return 1;
5316 case RIL_UNSOL_ON_USSD_REQUEST: return 1;
5317 case RIL_UNSOL_NITZ_TIME_RECEIVED: return 1;
5318 case RIL_UNSOL_SIGNAL_STRENGTH: return 1;
5319 case RIL_UNSOL_DATA_CALL_LIST_CHANGED: return 1;
5320 case RIL_UNSOL_SUPP_SVC_NOTIFICATION: return 1;
5321 case RIL_UNSOL_STK_SESSION_END: return 1;
5322 case RIL_UNSOL_STK_PROACTIVE_COMMAND: return 1;
5323 case RIL_UNSOL_STK_EVENT_NOTIFY: return 1;
5324 case RIL_UNSOL_STK_CALL_SETUP: return 1;
5325 case RIL_UNSOL_SIM_SMS_STORAGE_FULL: return 1;
5326 case RIL_UNSOL_SIM_REFRESH: return 1;
5327 case RIL_UNSOL_CALL_RING: return 1;
5328 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: return 1;
5329 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: return 1;
5330 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: return 1;
5331 case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: return 0;
5332 case RIL_UNSOL_RESTRICTED_STATE_CHANGED: return 1;
5333 case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: return 1;
5334 case RIL_UNSOL_CDMA_CALL_WAITING: return 1;
5335 case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: return 0;
5336 case RIL_UNSOL_CDMA_INFO_REC: return 0;
5337 case RIL_UNSOL_OEM_HOOK_RAW: return 1;
5338 case RIL_UNSOL_RINGBACK_TONE: return 1;
5339 case RIL_UNSOL_RESEND_INCALL_MUTE: return 0;
5340 case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: return 0;
5341 case RIL_UNSOL_CDMA_PRL_CHANGED: return 0;
5342 case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: return 1;
5343 case RIL_UNSOL_RIL_CONNECTED: return 1;
5344 case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED: return 1;
5345 case RIL_UNSOL_CELL_INFO_LIST: return 1;
5346 case RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED: return 1;
5347 case RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED: return 1;
5348 case RIL_UNSOL_SRVCC_STATE_NOTIFY: return 1;
5349 case RIL_UNSOL_HARDWARE_CONFIG_CHANGED: return 0;
5350 case RIL_UNSOL_DC_RT_INFO_CHANGED: return 0;
5351 case RIL_UNSOL_RADIO_CAPABILITY : return 1;
5352 case RIL_UNSOL_MAL_RESTART : return 1;
5353 case RIL_UNSOL_CALL_INFO_INDICATION : return 1;
5354 case RIL_UNSOL_CRSS_NOTIFICATION : return 0;
5355 case RIL_UNSOL_ECONF_SRVCC_INDICATION : return 1;
5356 case RIL_UNSOL_ECONF_RESULT_INDICATION : return 1;
5357 case RIL_UNSOL_STK_BIP_PROACTIVE_COMMAND : return 0;
5358 case RIL_UNSOL_MAL_AT_INFO: return 1;
5359 case RIL_UNSOL_ECALL_MSDHACK: return 1;
5360 case RIL_UNSOL_TX_POWER: return 1;
5361 case RIL_UNSOL_NETWORK_INFO: return 1;
5362#ifdef ECALL_SUPPORT
5363 case RIL_UNSOL_ECALL_INDICATIONS: return 1;
5364#endif /*ECALL_SUPPORT*/
5365#ifdef KEEP_ALIVE
5366 case RIL_UNSOL_KEEPALIVE_STATUS_PRO: return 1;
5367#endif /*KEEP_ALIVE*/
5368 case RIL_UNSOL_ON_USSI: return 1;
5369 case RIL_UNSOL_ECC_NUM: return 1;
5370 case RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR: return 1;
5371 default: return 0;
5372 }
5373}
5374
5375int parse_param(char *cmd, char *argv[], int max_args)
5376{
5377 char *pos, *pos2;
5378 int argc = 0;
5379 printf("warren test cmd=%s\n",cmd);
5380 pos = cmd;
5381 while (1) {
5382 // Trim the space characters.
5383 while (*pos == ' ') {
5384 pos++;
5385 }
5386
5387 if (*pos == '\0') {
5388 break;
5389 }
5390
5391 // One token may start with '"' or other characters.
5392 if (*pos == '"' && (pos2 = strrchr(pos+1, '"'))) {
5393 argv[argc++] = pos + 1;
5394 *pos2 = '\0';
5395 pos = pos2 + 1;
5396 if(*pos == '\n'){
5397 *pos = '\0';
5398 pos = pos + 1;
5399 }
5400
5401 } else {
5402 argv[argc++] = pos;
5403 while (*pos != '\0' && *pos != ' '&& *pos != '\n') {
5404 pos++;
5405 }
5406 *pos++ = '\0';
5407
5408 if(argc == 1) {
5409 char* at_cmd = strstr(argv[0], "RIL_REQUEST_OEM_HOOK_RAW");
5410 if(at_cmd != NULL) {
5411 while (*pos == ' ') {
5412 pos++;
5413 }
5414 argv[argc++] = pos;
5415 while (*pos != '\0' && *pos != '\n') {
5416 pos++;
5417 }
5418 *pos++ = '\0';
5419 break;
5420 }
5421 }
5422
5423 }
5424
5425 // Check if the maximum of arguments is reached.
5426 if (argc == max_args) {
5427 break;
5428 }
5429 }
5430
5431 return argc;
5432}
5433
5434/* Look up NAME as the name of a command, and return a pointer to that
5435 command. Return a NULL pointer if NAME isn't a command name. */
5436COMMAND* find_command (char *name)
5437{
5438 register int i;
5439
5440 for (i = 0; commands[i].name; i++)
5441 if (strcmp (name, commands[i].name) == 0)
5442 return (&commands[i]);
5443
5444 return ((COMMAND *)NULL);
5445}
5446
5447CommandInfo* find_mtk_command (int request)
5448{
5449 int i;
5450 for (i = 0; i < (int32_t)NUM_ELEMS(mtk_s_command); i++)
5451 if (mtk_s_command[i].requestNumber == request)
5452 return (&mtk_s_command[i]);
5453 return ((CommandInfo *)NULL);
5454}
5455
5456/* The user wishes to quit using this program. Just set DONE non-zero. */
5457static int com_quit (int argc, char *argv[], RIL_SOCKET_ID socket_id, RequestInfo *pRI)
5458{
5459 exit(EXIT_SUCCESS);
5460 return (0);
5461}
5462
5463static int enableSyslog(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
5464{
5465 if(argc < 2)
5466 {
5467 RLOGE("[Error] enable syslog paramter is error\n");
5468 free(pRI);
5469 return -1;
5470 }
5471 enable_syslog = atoi(argv[1]);
5472 RLOGE("%s syslog\n",enable_syslog ? "enable" :"disable");
5473 free(pRI);
5474 return 0;
5475}
5476
5477static int enableBTResponse(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
5478{
5479 if(argc < 2)
5480 {
5481 RLOGE("[Error] enable BT response paramter is error\n");
5482 free(pRI);
5483 return -1;
5484 }
5485 enable_bt_resp = atoi(argv[1]);
5486 RLOGE("%s bt response!\n",enable_bt_resp ? "enable" :"disable");
5487 free(pRI);
5488 return 0;
5489
5490}
5491
5492char Time_buf[24];
5493void GetTimeString(char * buf)
5494{
5495 time_t timep;
5496 struct tm p;
5497
5498 if(buf == NULL){
5499 RLOGE("[Error] GetTimeString: buf is Null\n");
5500 return;
5501 }
5502 //memset(buf,0,sizeof(buf));
5503 time(&timep);
5504 localtime_r(&timep,&p);
5505 sprintf(buf,"%d_%d_%d %d:%d:%d",(1900+p.tm_year),(1+p.tm_mon),p.tm_mday,
5506 (p.tm_hour),p.tm_min,p.tm_sec);
5507// printf("data is %s\n",buf);
5508
5509 return;
5510}
5511/*Warren add for t800 RIL Service 2021/12/10 start*/
5512int lynqAssemblyParcelheader(Parcel &p,int slot,int request,int respType,int error)
5513{
5514 p.writeInt32 (respType);
5515 p.writeInt32 (request);
5516 /*warren add for t800 ril servie 2021/12/15 start*/
5517 p.writeInt32(slot);
5518 /*warren add for t800 ril servie 2021/12/15 end*/
5519 p.writeInt32 (error);
5520 return 0;
5521}
5522void LYNQ_RIL_urcClientInit()
5523{
5524 int len = 0;
5525 int on=1;
5526 int ret = 0;
5527 lynq_urc_socket_fd = socket(AF_INET,SOCK_DGRAM,0);
5528 if(lynq_urc_socket_fd < 0)
5529 {
5530 perror("creaet socket for udp fail");
5531 return;
5532 }
5533 /* 设置socket允许重复使用地址与端口,SO_REUSEADDR值为2 */
5534 //setsockopt(socket_fd,SOL_SOCKET,SO_REUSEADDR,&on,sizeof on);
5535 /* 使能广播功能,SO_BROADCAST值为6 */
5536 ret= setsockopt(lynq_urc_socket_fd,SOL_SOCKET,SO_BROADCAST,&on,sizeof(on));
5537 if(ret<0)
5538 {
5539 RLOGD("set broadcast fail!!!\n");
5540 exit(1);
5541 }
5542 urc_broadcast_addr.sin_family = AF_INET; //IPv4
5543 urc_broadcast_addr.sin_port = htons(LYNQ_BRODCAST_PORT);
5544 urc_broadcast_addr.sin_addr.s_addr = inet_addr("255.255.255.255" );//255.255.255.255 broadcast addrress.
5545 printf("LYNQ_RIL_urcClientInit success!!!\n");
5546 return;
5547 /*
5548 while(1)
5549 {
5550 len = sendto(lynq_urc_socket_fd,"hello world",11,0,(struct sockaddr *)&urc_broadcast_addr,sizeof(urc_broadcast_addr));
5551 if(len > 0)
5552 {
5553 printf("sendto success,len=%d\n",len);
5554 }
5555 else
5556 {
5557 printf("sendto fail\n");
5558 }
5559 sleep(1);
5560 }
5561 */
5562}
5563void LYNQ_RIL_RecSocket()
5564{
5565 RLOGD("LYNQ_RIL_RecSocket start\n");
5566 char *argv[MAX_ARGS];
5567 int argc = 0;
5568 int ep_fd = 0;
5569 int en_fd = 0;
5570 struct epoll_event lynq_ev;
5571 struct epoll_event lynq_events[LYNQ_SOCKET_ENVNT_FD_MAX];
5572 //prctl(PR_SET_NAME,(unsigned long)"UDP_Thr");
5573
5574 /*listen UPD SOCKET port */
5575 struct sockaddr_in server_addr;
5576 struct sockaddr_in lynqClient_addr;
5577 bzero(&server_addr, sizeof(server_addr));
5578 server_addr.sin_family = AF_INET;
5579 server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
5580 server_addr.sin_port = htons(LYNQ_SERVICE_PORT);
5581 /* create socket */
5582 //int server_socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
5583 server_socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
5584 if(server_socket_fd == -1)
5585 {
5586 RLOGE("Create Socket Failed:");
5587 exit(1);
5588 }
5589
5590 /* bind socket port*/
5591 if(-1 == (bind(server_socket_fd,(struct sockaddr*)&server_addr,sizeof(server_addr))))
5592 {
5593 RLOGE("Server Bind Failed:");
5594 exit(1);
5595 }
5596 /* create epoll fd,add socket to epoll */
5597 ep_fd = epoll_create(LYNQ_SOCKET_ENVNT_FD_MAX);
5598 //int len = sizeof(struct sockaddr_in);
5599 lynq_ev.events = EPOLLIN | EPOLLET;
5600 lynq_ev.data.fd = server_socket_fd;
5601 if(epoll_ctl(ep_fd, EPOLL_CTL_ADD, server_socket_fd, &lynq_ev) < 0)
5602 {
5603 fprintf(stderr, "epoll set insertion error: fd=%d\n", server_socket_fd);
5604 return;
5605 }
5606 else
5607 {
5608 printf("monitor socket add epoll success!!!\n");
5609 }
5610 char buffer[LYNQ_SOCKET_BUFFER];
5611 lynq_client_t *client_tmp = NULL;
5612 /* tranlate data */
5613 while(true)
5614 {
5615 if(!s_registerCalled)
5616 {
5617 sleep(1);
5618 continue;
5619 }
5620 en_fd = epoll_wait(ep_fd, lynq_events, 10000, -1);//###Check valid
5621 if(en_fd <=0 )
5622 {
5623 continue;
5624 }
5625 for (int n = 0; n < en_fd; ++n)
5626 {
5627 if (lynq_events[n].data.fd == server_socket_fd)
5628 {
5629 /* define address to catch the client addreess*/
5630 //struct sockaddr_in client_addr;
5631 socklen_t client_addr_length = sizeof(lynqClient_addr);
5632 /* receive the data */
5633 bzero(buffer, LYNQ_SOCKET_BUFFER);
5634 if(recvfrom(server_socket_fd, buffer, LYNQ_SOCKET_BUFFER,0,(struct sockaddr*)&lynqClient_addr, &client_addr_length) == -1)
5635 {
5636 RLOGE("Receive Data Failed:");
5637 continue;
5638 }
5639 client_tmp = (lynq_client_t*)buffer;
5640 RLOGD("[LYNQ socketId] utoken=%d,request=%d,len=%d,param=%s",client_tmp->uToken,client_tmp->request,client_tmp->paramLen,client_tmp->param);
5641 //char test[36] = {};
5642 //sprintf(test,"test okay len = %d",client_tmp->paramLen);
5643 //sendto(server_socket_fd,test,strlen(test),0,(struct sockaddr*)&client_addr,client_addr_length);
5644 argv[0] = (char *)lynq_requset_to_string(client_tmp->request);
5645 argc = 0;
5646 if(client_tmp->paramLen > 0)
5647 {
5648 /*transfer struct*/
5649 argc = parse_param(client_tmp->param, argv+1, MAX_ARGS);
5650 if(argc < 1)
5651 {
5652 RLOGE("%s: error input.", buffer);
5653 continue;
5654 }
5655 }
5656 printf("argc =%d\n",argc);
5657 argc = argc+1;
5658 for(int t = 0;t<argc;t++)
5659 {
5660 RLOGD("warren test argv[%d]=%s\n",t,argv[t]);
5661 }
5662 COMMAND *command = find_command(argv[0]);
5663 if(!command)
5664 {
5665 RLOGE("%s: No such command for DemoApp", argv[0]);
5666 continue;
5667 }
5668 int32_t request;
5669 request = command->request;
5670 RIL_SOCKET_ID id = RIL_SOCKET_1;
5671 if(utils::is_support_dsds()) {
5672 id = (RIL_SOCKET_ID)get_default_sim_all_except_data();
5673 } else if(utils::is_suppport_dsss()) {
5674 id = (RIL_SOCKET_ID)Phone_utils::get_enable_sim_for_dsss();
5675 }
5676 if(request == -1)
5677 {
5678 (*(command->func)) (argc, argv, id, NULL);
5679 continue;
5680 }
5681 if (request < 1 || (request >= (int32_t)NUM_ELEMS(s_commands) && request < RIL_REQUEST_VENDOR_BASE)) {
5682 RLOGW("unsupported request code %d token %d", request);
5683 // FIXME this should perhaps return a response
5684 continue;
5685 }
5686 RLOGD("REQUEST: %s ParamterNum:%d", requestToString(request), argc);
5687 RequestInfo *pRI = creatRILInfoAndInit(request, UDP, (RIL_SOCKET_ID)(id));
5688 pRI->uToken = client_tmp->uToken;
5689 pRI->lynqEvent = 1;
5690 pRI->uClient_addr.sin_family = lynqClient_addr.sin_family;
5691 pRI->uClient_addr.sin_addr.s_addr = lynqClient_addr.sin_addr.s_addr;
5692 pRI->uClient_addr.sin_port = lynqClient_addr.sin_port;
5693 //sendto(server_socket_fd,test,strlen(test),0,(struct sockaddr*)&pRI->uClient_addr,client_addr_length);
5694 //pRI->uClient_addr.sa_family = (struct sockaddr)client_addr.sa_family;
5695 //memcpy(pRI->uClient_addr.sa_data,&client_addr
5696 //Radio on/off only allow one thread operate.
5697 if(request == RIL_REQUEST_RADIO_POWER)
5698 {
5699 speciaRequest_wait();
5700 }
5701 memset(Time_buf,0,sizeof(Time_buf));
5702 GetTimeString(Time_buf);
5703 //FUNCTION_CALLED(Time_buf,requestToString(request));
5704 int waittoken = pRI->token;
5705 (*(command->func)) (argc, argv, pRI->socket_id, pRI);
5706 FUNCTION_CALLED(Time_buf,requestToString(request));
5707 waitResponse(waittoken);
5708 memset(Time_buf,0,sizeof(Time_buf));
5709 GetTimeString(Time_buf);
5710 FUNCTION_RETURN(Time_buf,requestToString(request));
5711 }
5712 }
5713 }
5714 RLOGD("close socket fd");
5715 close(server_socket_fd);
5716 return ;
5717}
5718int LYNQ_RIL_respSocket(Parcel &p,RIL_Token t)
5719{
5720 RLOGD("LYNQ_RIL_respSocket send start");
5721 int ret =0;
5722 bool sendResult =false;
5723 ssize_t sent = 0;
5724 uint8_t dataLength[4];
5725 int verify = 0x55aa;
5726 RequestInfo *pRI = (RequestInfo *)t;
5727 if(pRI->lynqEvent!=1)
5728 {
5729 RLOGD("this is internal event!!!");
5730 return -1;
5731 }
5732 int dataSize = p.dataSize();
5733 const uint8_t* data = p.data();
5734 RLOGD("lynqSocketSend RESPONSE!!!! ");
5735 printf("lynqSocketSend RESPONSE!!!!\n");
5736 sent = sendto(server_socket_fd, data, dataSize, 0, (struct sockaddr *)&pRI->uClient_addr, sizeof(pRI->uClient_addr));
5737 if( sent < 0 )
5738 {
5739 RLOGE("lynqSocketSend send datalen fail (sent=%d, sendFD=%d, dataSize=%d)",
5740 sent,server_socket_fd, dataSize);
5741 printf("lynqSocketSend send datalen fail (sent=%d, sendFD=%d, dataSize=%d)",
5742 sent,server_socket_fd, dataSize);
5743 return -1;
5744 }
5745 return 0;
5746}
5747int LYNQ_RIL_respSocket_sp(Parcel &p,RequestInfo *pRI)
5748{
5749 RLOGD("LYNQ_RIL_respSocket send start");
5750 int ret =0;
5751 bool sendResult =false;
5752 ssize_t sent = 0;
5753 uint8_t dataLength[4];
5754 int verify = 0x55aa;
5755 int dataSize = p.dataSize();
5756 const uint8_t* data = p.data();
5757 if(pRI->lynqEvent!=1)
5758 {
5759 RLOGD("this is internal event!!!");
5760 return -1;
5761 }
5762 RLOGD("lynqSocketSend RESPONSE!!!! ");
5763 printf("lynqSocketSend RESPONSE!!!!\n");
5764
5765 sent = sendto(server_socket_fd, data, dataSize, 0, (struct sockaddr *)&pRI->uClient_addr, sizeof(pRI->uClient_addr));
5766 if( sent < 0 )
5767 {
5768 RLOGE("lynqSocketSend send datalen fail (sent=%d, sendFD=%d, dataSize=%d)",
5769 sent,server_socket_fd, dataSize);
5770 printf("lynqSocketSend send datalen fail (sent=%d, sendFD=%d, dataSize=%d)",
5771 sent,server_socket_fd, dataSize);
5772 return -1;
5773 }
5774 return 0;
5775}
5776
5777int LYNQ_RIL_urcBroadcast(Parcel &p)
5778{
5779 RLOGD("LYNQ_RIL_urcBroadcast send start");
5780 int ret =0;
5781 bool sendResult =false;
5782 ssize_t sent = 0;
5783 uint8_t dataLength[4];
5784 int verify = 0x55aa;
5785 int dataSize = p.dataSize();
5786 const uint8_t* data = p.data();
5787 sent = sendto(lynq_urc_socket_fd, data, dataSize, 0, (struct sockaddr *)&urc_broadcast_addr, sizeof(urc_broadcast_addr));
5788 if( sent < 0 )
5789 {
5790 RLOGE("LYNQ_RIL_urcBroadcast send datalen fail (sent=%d, sendFD=%d, dataSize=%d)",
5791 sent,lynq_urc_socket_fd, dataSize);
5792 return -1;
5793 }
5794 return 0;
5795}
5796/*Warren add for t800 RIL Service 2021/12/10 end*/
5797
5798void
5799RIL_StartRevSocket()
5800{
5801 RLOGD("RIL_StartRevSocket start\n");
5802 char *argv[MAX_ARGS];
5803 int argc = 0;
5804
5805 prctl(PR_SET_NAME,(unsigned long)"UDP_Thr");
5806
5807 /*listen UPD SOCKET port */
5808 struct sockaddr_in server_addr;
5809 bzero(&server_addr, sizeof(server_addr));
5810 server_addr.sin_family = AF_INET;
5811 server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
5812 server_addr.sin_port = htons(SERVER_PORT);
5813 /* create socket */
5814 //int server_socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
5815 server_socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
5816 if(server_socket_fd == -1)
5817 {
5818 RLOGE("Create Socket Failed:");
5819 exit(1);
5820 }
5821
5822 /* bind socket port*/
5823 if(-1 == (bind(server_socket_fd,(struct sockaddr*)&server_addr,sizeof(server_addr))))
5824 {
5825 RLOGE("Server Bind Failed:");
5826 exit(1);
5827 }
5828
5829 /* tranlate data */
5830 while(true)
5831 {
5832 if(!s_registerCalled)
5833 {
5834 sleep(1);
5835 continue;
5836 }
5837 /* define address to catch the client addreess*/
5838 //struct sockaddr_in client_addr;
5839 socklen_t client_addr_length = sizeof(client_addr);
5840
5841 /* receive the data */
5842 char buffer[BUFFER_SIZE];
5843 bzero(buffer, BUFFER_SIZE);
5844 if(recvfrom(server_socket_fd, buffer, BUFFER_SIZE,0,(struct sockaddr*)&client_addr, &client_addr_length) == -1)
5845 {
5846 RLOGE("Receive Data Failed:");
5847 continue;
5848 }
5849 RLOGD("DemoAPP:%s, receve: %s", inet_ntoa(client_addr.sin_addr), buffer);
5850 if(mtkItTest(buffer)) {
5851 RLOGD("mtkItTest() handle.");
5852 continue;
5853 }
5854 int argc = parse_param(buffer, argv, MAX_ARGS);
5855 if(argc < 1)
5856 {
5857 RLOGE("%s: error input.", buffer);
5858 continue;
5859 }
5860 COMMAND *command = find_command(argv[0]);
5861 if(!command)
5862 {
5863 RLOGE("%s: No such command for DemoApp", argv[0]);
5864 continue;
5865 }
5866
5867 int32_t request;
5868
5869 request = command->request;
5870
5871 RIL_SOCKET_ID id = RIL_SOCKET_1;
5872 if(utils::is_support_dsds()) {
5873 id = (RIL_SOCKET_ID)get_default_sim_all_except_data();
5874 } else if(utils::is_suppport_dsss()) {
5875 id = (RIL_SOCKET_ID)Phone_utils::get_enable_sim_for_dsss();
5876 }
5877
5878 if(request == -1)
5879 {
5880 (*(command->func)) (argc, argv, id, NULL);
5881 continue;
5882 }
5883
5884 if (request < 1 || (request >= (int32_t)NUM_ELEMS(s_commands) && request < RIL_REQUEST_VENDOR_BASE)) {
5885 RLOGW("unsupported request code %d token %d", request);
5886 // FIXME this should perhaps return a response
5887 continue;
5888 }
5889
5890 RLOGD("REQUEST: %s ParamterNum:%d", requestToString(request), argc);
5891
5892
5893 RequestInfo *pRI = creatRILInfoAndInit(request, UDP, (RIL_SOCKET_ID)(id));
5894 //Radio on/off only allow one thread operate.
5895 if(request == RIL_REQUEST_RADIO_POWER)
5896 {
5897 speciaRequest_wait();
5898 }
5899 memset(Time_buf,0,sizeof(Time_buf));
5900 GetTimeString(Time_buf);
5901 //FUNCTION_CALLED(Time_buf,requestToString(request));
5902 int waittoken = pRI->token;
5903 (*(command->func)) (argc, argv, pRI->socket_id, pRI);
5904 FUNCTION_CALLED(Time_buf,requestToString(request));
5905 waitResponse(waittoken);
5906 memset(Time_buf,0,sizeof(Time_buf));
5907 GetTimeString(Time_buf);
5908 FUNCTION_RETURN(Time_buf,requestToString(request));
5909 }
5910
5911 RLOGD("close socket fd");
5912 close(server_socket_fd);
5913 return ;
5914}
5915
5916const int waitResponse(int token)
5917{
5918 int waitToken = token;
5919 struct timeval now;
5920 struct timespec timeout;
5921 if((token&BLOCK_MARK) != BLOCK_MARK){
5922 RLOGD("No need wait!,token is %x!",token);
5923 return 0;
5924 }
5925
5926 gettimeofday(&now,NULL);
5927 timeout.tv_sec = now.tv_sec+60; //timeout is 1min
5928 timeout.tv_nsec = now.tv_usec*1000;
5929
5930 RLOGD("Block Request, wait token is %x,",waitToken);
5931 BLOCK_LOCK();
5932 if(waitToken == wakeup_token)
5933 RLOGD("response early than return, wait token is %x, wakeup token is %x",waitToken, wakeup_token);
5934 while(!(waitToken == wakeup_token)) {
5935 RLOGD("Wait Response, wait token is %x, wakeup token is %x",waitToken, wakeup_token);
5936 int ret = BLOCK_WAIT(&timeout);
5937 if(ret == ETIMEDOUT){
5938 RLOGD("Wait Response timeout, wait token is %x, wakeup token is %x",waitToken, wakeup_token);
5939 goto out;
5940 }
5941 }
5942 RLOGD("Response wakeup,token is %x!",wakeup_token);
5943 wakeup_token = -1;
5944out:
5945 BLOCK_UNLOCK();
5946 return 0;
5947}
5948
5949void *
5950eventLoop(void *param) {
5951 pthread_mutex_lock(&s_startupMutex);
5952 s_started = 1;
5953 pthread_cond_broadcast(&s_startupCond);
5954 pthread_mutex_unlock(&s_startupMutex);
5955 #ifdef ECALL_SUPPORT
5956 init_ecall_timer_all();
5957 #endif /**/ECALL_SUPPORT
5958 /*warren add for t800 ril service 2021/12/13 start*/
5959 //RIL_StartRevSocket();
5960 LYNQ_RIL_urcClientInit();
5961 LYNQ_RIL_RecSocket();
5962 /*warren add for t800 ril service 2021/12/13 end*/
5963 RLOGD("error in event_loop_base errno:%d", errno);
5964 // kill self to restart on error
5965 kill(0, SIGKILL);
5966
5967 return NULL;
5968}
5969
5970const int RspDispFunction(int request,char* arg, RIL_SOCKET_ID socket_id)
5971{
5972 int waittoken;
5973 RequestInfo *pRI = creatRILInfoAndInit(request, RSPD, socket_id);
5974 if(pRI == NULL)
5975 return 0;
5976 waittoken = pRI->token;
5977 switch (request) {
5978 case RIL_REQUEST_GET_CURRENT_CALLS:
5979 {
5980 RLOGD("request Current list start!");
5981 Parcel p;
5982 pRI->pCI->dispatchFunction(p, pRI);
5983 waitResponse(waittoken);
5984 RLOGD("request Current list end!");
5985 }
5986 break;
5987
5988 case RIL_REQUEST_ANSWER:
5989 {
5990 RLOGD("request Answer a MT call start!");
5991 Parcel p;
5992 pRI->pCI->dispatchFunction(p, pRI);
5993 waitResponse(waittoken);
5994 RLOGD("request Answer a MT call end!");
5995 }
5996 break;
5997
5998 case RIL_REQUEST_GET_SIM_STATUS:
5999 {
6000 int ret=getIccCardStatus(1, NULL, socket_id, pRI);
6001 if(ret == 0)
6002 waitResponse(waittoken);
6003 }
6004 break;
6005
6006 case RIL_REQUEST_DATA_REGISTRATION_STATE:
6007 {
6008 int ret=getDataRegistrationState(1, NULL, socket_id,pRI);
6009 if(ret == 0)
6010 waitResponse(waittoken);
6011 }
6012 break;
6013
6014 case RIL_REQUEST_VOICE_REGISTRATION_STATE:
6015 {
6016 int ret=getVoiceRegistrationState(1, NULL, socket_id,pRI);
6017 if(ret == 0)
6018 waitResponse(waittoken);
6019 }
6020 break;
6021 case RIL_REQUEST_SMS_ACKNOWLEDGE:
6022 {
6023 char* tmp[3] = {"RIL_REQUEST_SMS_ACKNOWLEDGE", "1", "0"};
6024 acknowledgeIncomingGsmSmsWithPdu(3,tmp,socket_id,pRI);
6025 waitResponse(waittoken);
6026 RLOGD("acknowledge last Incoming Gsm Sms : RIL_REQUEST_SMS_ACKNOWLEDGE end!");
6027 }
6028 break;
6029 case RIL_REQUEST_OEM_HOOK_RAW:
6030 {
6031 if(arg != NULL)
6032 {
6033 RLOGD("request OEM HOOK RAW start!");
6034 pRI->token = pRI->token|BLOCK_MARK;
6035 int waittokenOEM = pRI->token;
6036 Parcel p;
6037
6038 size_t pos = p.dataPosition();
6039 int len = strlen(arg);
6040 p.writeInt32(len);
6041 p.write((const void*)arg,len);
6042
6043 p.setDataPosition(pos);
6044 RLOGD("emSendATCommand: %s %d\n",arg,strlen(arg));
6045 pRI->pCI->dispatchFunction(p, pRI);
6046 waitResponse(waittokenOEM);
6047 } else {
6048 if(pRI){
6049 free(pRI);
6050 }
6051 RLOGE("at command shouldn't null");
6052 }
6053 break;
6054 }
6055 case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM:
6056 {
6057 char* tmp[2] = {"RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM", "no"};
6058 handleCallSetupRequestFromSim(2, tmp, socket_id,pRI);
6059 waitResponse(waittoken);
6060 RLOGD("timeout 1 minutes, response no by RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM");
6061 break;
6062 }
6063 case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE:
6064 {
6065 char* tmp[2] ={"RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE", arg};
6066 RLOGD("tmp[0]=%s, tmp[1]=%s, arg=%s", tmp[0], tmp[1], arg);
6067 sendTerminalResponse(2, tmp, socket_id, pRI);
6068 waitResponse(waittoken);
6069 break;
6070 }
6071 case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE:
6072 {
6073 acknowledgeLastIncomingCdmaSms(1, NULL,socket_id,pRI);
6074 waitResponse(waittoken);
6075 break;
6076 }
6077 case RIL_REQUEST_RADIO_POWER:
6078 {
6079 RLOGD("response loop, RIL_REQUEST_RADIO_POWER: %s", (arg == NULL ? "nul": arg));
6080 if(arg != NULL) {
6081 char* tmp[2] = {"RIL_REQUEST_RADIO_POWER", arg};
6082 setRadioPower(2,tmp,socket_id,pRI);
6083 waitResponse(waittoken);
6084 } else {
6085 if(pRI){
6086 free(pRI);
6087 }
6088 RLOGE("response loop, RIL_REQUEST_RADIO_POWER fail");
6089 }
6090 break;
6091 }
6092 case RIL_REQUEST_ALLOW_DATA:
6093 {
6094 int default_id = get_default_sim_data();
6095 RLOGD("RspDispFunction: socket_id=%d switch_id=%d", socket_id, default_id);
6096 char* argv[2] = {"RIL_REQUEST_ALLOW_DATA","0"};
6097 if(socket_id == default_id) {
6098 utils::mtk_property_set(PROP_DEFAULT_DATA_SIM, std::to_string(socket_id + 1).c_str());
6099 argv[1] = "1";
6100 }
6101 while(!isRadioAvailable(socket_id)) {
6102 sleep(1);
6103 RLOGD("[SIM%d]RspDispFunction(RIL_REQUEST_ALLOW_DATA): wait radio available", socket_id);
6104 }
6105 setDataAllowed(2, argv, socket_id, pRI);
6106 waitResponse(waittoken);
6107 break;
6108 }
6109 case RIL_REQUEST_CDMA_FLASH:
6110 {
6111 sendCDMAFeatureCode(1, NULL, socket_id, pRI);
6112 waitResponse(waittoken);
6113 break;
6114 }
6115 default:
6116 break;
6117 }
6118 return 0;
6119}
6120
6121void * responseLoop(void *param) {
6122 pthread_mutex_lock(&s_startupMutex);
6123 s_responseDispatch= 1;
6124 pthread_cond_broadcast(&s_startupCond);
6125 pthread_mutex_unlock(&s_startupMutex);
6126 responseDispatch();
6127 RLOGD("error in response_loop_base errno:%d", errno);
6128 // kill self to restart on error
6129 kill(0, SIGKILL);
6130
6131 return NULL;
6132}
6133
6134void ATCIRequest(int request,char* reqString, void* t,int argc,char**argv)
6135{
6136 RequestInfo *pRI = (RequestInfo *)t;
6137 int waittoken;
6138 if (request < RIL_REQUEST_VENDOR_BASE) {
6139 pRI->pCI = &(s_commands[request]);
6140 } else {
6141 pRI->pCI = find_mtk_command(request);
6142 }
6143 if(pRI->pCI == NULL)
6144 RLOGE("pCI command not found!");
6145
6146 if(utils::is_suppport_dsss()){
6147 pRI->socket_id = (RIL_SOCKET_ID)Phone_utils::get_enable_sim_for_dsss();
6148 }
6149
6150 if(utils::is_support_dsds() && (request != RIL_REQUEST_RADIO_POWER)){
6151 pRI->socket_id = (RIL_SOCKET_ID)get_atci_sim();
6152 }
6153
6154 pRI->p_next = NULL;
6155
6156 COMMAND *command = find_command(reqString);
6157
6158 if(command == NULL) {
6159 RLOGE("ATCI request command find error!");
6160 } else {
6161 RLOGE("ATCI request name is %s!",command->name);
6162 }
6163
6164 pRI->token = GenerateToken(ATCI, request);
6165 waittoken = pRI->token;
6166 if(request == RIL_REQUEST_RADIO_POWER) {
6167 speciaRequest_wait();
6168 }
6169 (*(command->func)) (argc, argv, pRI->socket_id, pRI);
6170 //need wait Ril_onRequestComplete return.
6171 waitResponse(waittoken);
6172 return;
6173}
6174
6175void startWakupLoop(void)
6176{
6177 pthread_t WakeupReasonThread;
6178
6179 RLOGD("startWakupLoop()");
6180 pthread_mutex_lock(&s_startupMutex);
6181
6182 pthread_attr_t attr;
6183 pthread_attr_init(&attr);
6184 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
6185
6186 int result = pthread_create(&WakeupReasonThread, &attr, wakeup_reason_loop, NULL);
6187 if (result != 0) {
6188 RLOGW("Failed to create wakeup reason thread: %s", strerror(result));
6189 goto done;
6190 }
6191
6192done:
6193 pthread_mutex_unlock(&s_startupMutex);
6194}
6195
6196void startPMLoop(void)
6197{
6198 pthread_t atciSocketThread;
6199
6200 RLOGD("startPMLoop()");
6201 pthread_mutex_lock(&s_startupMutex);
6202
6203 pthread_attr_t attr;
6204 pthread_attr_init(&attr);
6205 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
6206
6207 int result = pthread_create(&atciSocketThread, &attr, StartPMSocket, NULL);
6208 if (result != 0) {
6209 RLOGW("Failed to create PM thread: %s", strerror(result));
6210 goto done;
6211 }
6212
6213done:
6214 pthread_mutex_unlock(&s_startupMutex);
6215}
6216
6217void startGdbusLoop(void)
6218{
6219 pthread_t atciSocketThread;
6220
6221 RLOGD("startGdbusLoop()");
6222 pthread_mutex_lock(&s_startupMutex);
6223
6224 pthread_attr_t attr;
6225 pthread_attr_init(&attr);
6226 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
6227
6228 int result = pthread_create(&atciSocketThread, &attr, init_data_gdbus_cb, NULL);
6229 if (result != 0) {
6230 RLOGW("Failed to create gdbus thread: %s", strerror(result));
6231 goto done;
6232 }
6233
6234done:
6235 pthread_mutex_unlock(&s_startupMutex);
6236}
6237
6238void startATCILoop(void)
6239{
6240 pthread_t atciSocketThread;
6241
6242 RLOGD("startATCILoop()");
6243 pthread_mutex_lock(&s_startupMutex);
6244
6245 pthread_attr_t attr;
6246 pthread_attr_init(&attr);
6247 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
6248
6249 int result = pthread_create(&atciSocketThread, &attr, StartATCISocket, NULL);
6250 if (result != 0) {
6251 RLOGW("Failed to create ATCI thread: %s", strerror(result));
6252 goto done;
6253 }
6254
6255done:
6256 pthread_mutex_unlock(&s_startupMutex);
6257}
6258
6259void RIL_startEventLoop(void)
6260{
6261 RLOGD("RIL_startEventLoop()");
6262 /* spin up eventLoop thread and wait for it to get started */
6263 s_started = 0;
6264 pthread_mutex_lock(&s_startupMutex);
6265
6266 pthread_attr_t attr;
6267 pthread_attr_init(&attr);
6268 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
6269
6270 int result = pthread_create(&s_tid_dispatch, &attr, eventLoop, NULL);
6271 if (result != 0) {
6272 RLOGW("Failed to create dispatch thread: %s", strerror(result));
6273 goto done;
6274 }
6275
6276 while (s_started == 0) {
6277 pthread_cond_wait(&s_startupCond, &s_startupMutex);
6278 }
6279
6280 result = pthread_create(&s_tid_dispatch, &attr, responseLoop, NULL);
6281 if (result != 0) {
6282 RLOGW("Failed to create response dispatch thread: %s", strerror(result));
6283 goto done;
6284 }
6285
6286 while (s_responseDispatch == 0) {
6287 pthread_cond_wait(&s_startupCond, &s_startupMutex);
6288 }
6289done:
6290 pthread_mutex_unlock(&s_startupMutex);
6291}
6292
6293void printInputArgs(int argc, char** argv)
6294{
6295 int i=0;
6296
6297 for(i=0; i<argc; i++)
6298 {
6299 RLOGD("%s", argv[i]);
6300 }
6301}
6302
6303void initRequestInfo(RequestInfo *pRI, int request, int mode, RIL_SOCKET_ID soc_id)
6304{
6305 pRI->token = GenerateToken(mode, request);
6306 if (request < RIL_REQUEST_VENDOR_BASE) {
6307 pRI->pCI = &(s_commands[request]);
6308 } else {
6309 pRI->pCI = find_mtk_command(request);
6310 }
6311 pRI->socket_id = soc_id;
6312
6313 pRI->p_next = NULL;
6314}
6315
6316void getVoiceAndDataRegistrationState(RIL_SOCKET_ID soc_id)
6317{
6318 ARspRequest(RIL_REQUEST_DATA_REGISTRATION_STATE,soc_id);
6319 ARspRequest(RIL_REQUEST_VOICE_REGISTRATION_STATE,soc_id);
6320}
6321
6322void requestAnswer(RIL_SOCKET_ID soc_id)
6323{
6324 ARspRequest(RIL_REQUEST_ANSWER,soc_id);
6325 return;
6326}
6327void requestSMSACKNOWLEDGE(RIL_SOCKET_ID soc_id)
6328{
6329 ARspRequest(RIL_REQUEST_SMS_ACKNOWLEDGE,soc_id);
6330 return;
6331}
6332
6333#if EM_MODE_SUPPORT
6334void registerForNetworkInfo(netwokInfoNotify cb)
6335{
6336 networkCb = cb;
6337 return ;
6338}
6339void unregisterNetwork()
6340{
6341 networkCb = NULL;
6342 //AT+EINFO= flag & 0xFFFFFFF7
6343}
6344void registerForATcmdResponse(atCmdResponse cb)
6345{
6346 atResponseCb = cb;
6347 return ;
6348}
6349
6350void unregisterATcmd()
6351{
6352 atResponseCb = NULL;
6353}
6354
6355#endif
6356int emResultNotify(const char *str)
6357{
6358 RLOGD("emResultNotify %s",str);
6359 int len_s = sendto(server_socket_fd,str,strlen(str),0,(struct sockaddr *)&client_addr,sizeof(client_addr));
6360
6361 sendto(server_socket_fd,"stopemdone",strlen("stopemdone"),0,(struct sockaddr *)&client_addr,sizeof(client_addr));
6362 return len_s;
6363}
6364
6365void processUnsolicited (Parcel &p, int type)
6366{
6367 int32_t response;
6368 p.readInt32(&response);
6369 switch(response){
6370 case RIL_UNSOL_MAL_AT_INFO:
6371 {
6372#if EM_MODE_SUPPORT
6373 char *stringresponse = strdupReadString(p);
6374 if(strstr(stringresponse,"+ENWINFO") != NULL){
6375 RLOGD("processUnsolicited ENWINFO \n");
6376 char *start = strstr(stringresponse,":");
6377 char *end = strstr(stringresponse,",");
6378 if(start == NULL ||end == NULL ){
6379 break;
6380 }
6381 if(networkCb){
6382 //parse type & data, notify to registrants
6383 char ctype[5] = {0};
6384 int type = 0;
6385 memcpy(ctype,start+1, end - start -1);
6386 type = atoi(ctype);
6387 char *data = end+1;
6388 RLOGD("ctype %s type %d data %s\n",ctype,type,data);
6389 //parse response
6390 networkCb(type,data);
6391 }
6392 }
6393 if(stringresponse){
6394 free(stringresponse);
6395 }
6396#endif
6397 break;
6398 }
6399 default:
6400 break;
6401 }
6402}
6403void processSolicited(Parcel &p, int type) {
6404 int32_t serial, error;
6405 p.readInt32(&serial); //telematic it is the same as ril request num
6406 p.readInt32(&error);
6407 RLOGD("processSolicited serial %d\n", serial);
6408 switch (serial) {
6409 case RIL_REQUEST_OEM_HOOK_RAW: {
6410 if (error != RIL_E_SUCCESS) {
6411 RLOGW("RIL_E_fail");
6412 if (atResponseCb) {
6413 atResponseCb(NULL, 0);
6414 }
6415 if(m_RfDesense){
6416 m_RfDesense->handle_request("", 0, 0, (RIL_Errno)error);
6417 }
6418 return;
6419 }
6420 int len;
6421 status_t status = 0;
6422 status = p.readInt32(&len);
6423 if (status != 0) {
6424 RLOGW("read int32 fail");
6425 return;
6426 }
6427 char *stringresponse = (char*) calloc(len, sizeof(char));
6428 status = p.read((void*) stringresponse, len);
6429 if (status != 0) {
6430 if (stringresponse) {
6431 free(stringresponse);
6432 }
6433 RLOGW("read int32 fail");
6434 return;
6435 }
6436 parseAtCmd(stringresponse);
6437 RLOGD("processSolicited AT string %s %d\n", stringresponse, len);
6438#if EM_MODE_SUPPORT
6439 if (atResponseCb) {
6440 if (stringresponse) {
6441
6442 atResponseCb(stringresponse, len);
6443 } else {
6444 atResponseCb(stringresponse, 0);
6445 }
6446 }
6447 if(m_RfDesense){
6448 if(stringresponse && (!isFinalResponseErrorEx(stringresponse))) {
6449 m_RfDesense->handle_request(stringresponse,len,0, (RIL_Errno)RIL_E_SUCCESS);
6450 } else {
6451 RLOGD("isFinalResponseErrorEx error or response is null");
6452 m_RfDesense->handle_request(stringresponse, 0, 0, (RIL_Errno)RIL_E_GENERIC_FAILURE);
6453 }
6454 }
6455#endif
6456 if (stringresponse) {
6457 free(stringresponse);
6458 }
6459 break;
6460 }
6461 case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: {
6462#if EM_MODE_SUPPORT
6463 if (atResponseCb) {
6464 if (error != RIL_E_SUCCESS) {
6465 atResponseCb(NULL, 0);
6466 } else {
6467 atResponseCb("OK", 2);
6468 }
6469 }
6470#endif
6471 break;
6472 }
6473 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: {
6474#if EM_MODE_SUPPORT
6475 int nums = 0;
6476 int prefertype = 0;
6477 p.readInt32(&nums);
6478 if (nums != 1) {
6479 RLOGD("getpreferrednetworktype nums > 1");
6480 }
6481 p.readInt32(&prefertype);
6482 char prefertype_str[3] = { 0 };
6483 sprintf(prefertype_str, "%d", prefertype);
6484 if (atResponseCb) {
6485 if (error != RIL_E_SUCCESS) {
6486 atResponseCb(NULL, 0);
6487 } else {
6488 atResponseCb(prefertype_str, strlen(prefertype_str));
6489 }
6490 }
6491#endif
6492 break;
6493 }
6494 case RIL_REQUEST_GET_IMSI: {
6495 if (error != RIL_E_SUCCESS) {
6496 RLOGD("RIL_REQUEST_GET_IMSI error %d\n", error);
6497 }
6498 break;
6499 }
6500 }
6501}
6502
6503#ifdef ECALL_SUPPORT
6504static int responseEcallStatus(Parcel &p, void *response, size_t responselen) {
6505 if (response == NULL || responselen != sizeof(RIL_Ecall_Unsol_Indications)) {
6506 if (response == NULL) {
6507 RLOGE("invalid response: NULL");
6508 }
6509 else {
6510 RLOGE("responseEcallStatus: invalid response length %d expecting len: %d",
6511 sizeof(RIL_Ecall_Unsol_Indications), responselen);
6512 }
6513 return RIL_ERRNO_INVALID_RESPONSE;
6514 }
6515
6516 RIL_Ecall_Unsol_Indications *p_cur = (RIL_Ecall_Unsol_Indications *)response;
6517 p.writeInt32(p_cur->ind);
6518 p.writeInt32(p_cur->call_id);
6519
6520 startResponse;
6521 appendPrintBuf("ECall Status: %d, call_id: %d",
6522 p_cur->ind, p_cur->call_id);
6523 closeResponse;
6524
6525 return 0;
6526}
6527
6528/**
6529 * Callee expects const RIL_ECallReqMsg *
6530 * Payload is:
6531 * RIL_ECall_Category ecall_cat
6532 * RIL_ECall_Variant ecall_variant
6533 * String address
6534 * String msd_data
6535 */
6536static void dispatchFastEcall (Parcel &p, RequestInfo *pRI) {
6537 RIL_ECallReqMsg eCallReqMsg;
6538
6539 int32_t t;
6540 int size;
6541 status_t status;
6542 int digitCount;
6543 int digitLimit;
6544 uint8_t uct;
6545
6546 memset(&eCallReqMsg, 0, sizeof(eCallReqMsg));
6547
6548 status = p.readInt32(&t);
6549 eCallReqMsg.ecall_cat= (RIL_ECall_Category)t;
6550
6551 status = p.readInt32(&t);
6552 eCallReqMsg.ecall_variant = (RIL_ECall_Variant)t;
6553
6554 eCallReqMsg.address = strdupReadString(p);
6555
6556 status = p.readInt32(&t);
6557 eCallReqMsg.length = (uint8_t) t;
6558
6559 digitLimit= MIN((eCallReqMsg.length), MSD_MAX_LENGTH);
6560 eCallReqMsg.msd_data = (unsigned char *)alloca(digitLimit);
6561
6562 for(digitCount = 0 ; digitCount < digitLimit; digitCount ++) {
6563 status = p.read(&uct, sizeof(uint8_t));
6564 eCallReqMsg.msd_data[digitCount] = (uint8_t) uct;
6565 }
6566
6567 startRequest;
6568 appendPrintBuf("%secall_cat=%d,ecall_variant=%d, address=%s", printBuf,
6569 eCallReqMsg.ecall_cat, eCallReqMsg.ecall_variant, (char*)eCallReqMsg.address);
6570 closeRequest;
6571 printRequest(pRI->token, pRI->pCI->requestNumber);
6572
6573 if (status != NO_ERROR) {
6574 goto invalid;
6575 }
6576
6577 size = sizeof(eCallReqMsg);
6578 CALL_ONREQUEST(pRI->pCI->requestNumber, &eCallReqMsg, size, pRI, pRI->socket_id);
6579
6580#ifdef MEMSET_FREED
6581 memsetString(eCallReqMsg.address);
6582 memset(eCallReqMsg.msd_data, 0, eCallReqMsg.length);
6583#endif
6584
6585 free(eCallReqMsg.address);
6586
6587#ifdef MEMSET_FREED
6588 memset(&eCallReqMsg, 0, sizeof(eCallReqMsg));
6589#endif
6590
6591 return;
6592invalid:
6593 invalidCommandBlock(pRI);
6594 return;
6595}
6596
6597/**
6598 * Callee expects const RIL_ECallSetMSD *
6599 * Payload is:
6600 * int call_id
6601 * String msd_data
6602 */
6603static void dispatchSetMsd (Parcel &p, RequestInfo *pRI) {
6604 RIL_ECallSetMSD eCallSetMsd;
6605
6606 int32_t t;
6607 int size;
6608 status_t status;
6609 int digitCount;
6610 int digitLimit;
6611 uint8_t uct;
6612
6613 memset(&eCallSetMsd, 0, sizeof(eCallSetMsd));
6614
6615 status = p.readInt32(&t);
6616 eCallSetMsd.call_id = (int)t;
6617
6618 status = p.readInt32(&t);
6619 eCallSetMsd.length = (uint8_t) t;
6620
6621 digitLimit= MIN((eCallSetMsd.length), MSD_MAX_LENGTH);
6622 eCallSetMsd.msd_data = (unsigned char *)alloca(digitLimit);
6623
6624 for(digitCount = 0 ; digitCount < digitLimit; digitCount ++) {
6625 status = p.read(&uct, sizeof(uint8_t));
6626 eCallSetMsd.msd_data[digitCount] = (uint8_t) uct;
6627 }
6628
6629 startRequest;
6630 appendPrintBuf("%scall_id=%d,msd_data=%s", printBuf, eCallSetMsd.call_id, (char*)eCallSetMsd.msd_data);
6631 closeRequest;
6632 printRequest(pRI->token, pRI->pCI->requestNumber);
6633
6634 if (status != NO_ERROR) {
6635 goto invalid;
6636 }
6637
6638 size = sizeof(eCallSetMsd);
6639 CALL_ONREQUEST(pRI->pCI->requestNumber, &eCallSetMsd, size, pRI, pRI->socket_id);
6640
6641#ifdef MEMSET_FREED
6642 memset(eCallSetMsd.msd_data, 0, eCallSetMsd.length);
6643#endif
6644
6645#ifdef MEMSET_FREED
6646 memset(&eCallSetMsd, 0, sizeof(eCallSetMsd));
6647#endif
6648
6649 return;
6650invalid:
6651 invalidCommandBlock(pRI);
6652 return;
6653}
6654
6655/**
6656 * Callee expects const RIL_ECallSetNum *
6657 * Payload is:
6658 * int arg_num;
6659 * int type
6660 * char* address
6661 */
6662static void dispatchEcallRecord (Parcel &p, RequestInfo *pRI) {
6663 RIL_ECallSetNum args;
6664 int32_t t;
6665 status_t status;
6666
6667 RLOGD("dispatchSmsWrite");
6668 memset (&args, 0, sizeof(args));
6669
6670 status = p.readInt32(&t);
6671 args.arg_num = (int)t;
6672
6673 status = p.readInt32(&t);
6674 args.type = (int)t;
6675
6676 args.address = strdupReadString(p);
6677
6678 if (status != NO_ERROR || args.address == NULL) {
6679 goto invalid;
6680 }
6681
6682 startRequest;
6683 appendPrintBuf("%s%d,%s,%d", printBuf, args.type, args.address,args.arg_num);
6684 closeRequest;
6685 printRequest(pRI->token, pRI->pCI->requestNumber);
6686
6687 CALL_ONREQUEST(pRI->pCI->requestNumber, &args, sizeof(args), pRI, pRI->socket_id);
6688
6689#ifdef MEMSET_FREED
6690 memsetString (args.address);
6691#endif
6692
6693 free (args.address);
6694#ifdef MEMSET_FREED
6695 memset(&args, 0, sizeof(args));
6696#endif
6697 return;
6698invalid:
6699 invalidCommandBlock(pRI);
6700 return;
6701}
6702#endif /*ECALL_SUPPORT*/
6703
6704#ifdef KEEP_ALIVE
6705static void dispatchStartKeepalivePro(Parcel &p, RequestInfo *pRI){
6706 RIL_RequestKeepalive_Pro kp;
6707 int32_t t;
6708 status_t status;
6709 std::vector<uint8_t> sadr;
6710 std::vector<uint8_t> dadr;
6711
6712 memset (&kp, 0, sizeof(RIL_RequestKeepalive_Pro));
6713
6714 status = p.readInt32(&t);
6715 kp.type = (RIL_PacketType)t;
6716 if (status != NO_ERROR) {
6717 goto invalid;
6718 }
6719
6720
6721 status = p.readByteVector(&sadr);
6722 if (status != NO_ERROR) {
6723 goto invalid;
6724 } else {
6725 for(int i = 0; i < sadr.size(); i++) {
6726 kp.sourceAddress[i] = sadr[i];
6727 }
6728 }
6729
6730 status = p.readInt32(&t);
6731 kp.sourcePort= (int)t;
6732 if (status != NO_ERROR) {
6733 goto invalid;
6734 }
6735
6736 status = p.readByteVector(&dadr);
6737 if (status != NO_ERROR) {
6738 goto invalid;
6739 } else {
6740 for(int i = 0; i < dadr.size(); i++) {
6741 kp.destinationAddress[i] = dadr[i];
6742 }
6743 }
6744
6745 status = p.readInt32(&t);
6746 kp.destinationPort= (int)t;
6747 if (status != NO_ERROR) {
6748 goto invalid;
6749 }
6750
6751 status = p.readInt32(&t);
6752 kp.netif_id = (int)t;
6753 if (status != NO_ERROR) {
6754 goto invalid;
6755 }
6756
6757 status = p.readInt32(&t);
6758 kp.keepIdleTime = (int)t;
6759 if (status != NO_ERROR) {
6760 goto invalid;
6761 }
6762
6763 status = p.readInt32(&t);
6764 kp.keepIntervalTime = (int)t;
6765 if (status != NO_ERROR) {
6766 goto invalid;
6767 }
6768
6769 status = p.readInt32(&t);
6770 kp.retryCount = (int)t;
6771 if (status != NO_ERROR) {
6772 goto invalid;
6773 }
6774 startRequest;
6775 appendPrintBuf("%s [type:%d, sourceAddress:",printBuf, kp.type);
6776
6777 for(auto v: sadr) {
6778 appendPrintBuf("%s %d",printBuf,v);
6779 }
6780 appendPrintBuf("%s, sourcePort:%d, destinationAddress:",printBuf, kp.sourcePort);
6781
6782 for(auto v: dadr) {
6783 appendPrintBuf("%s %d",printBuf,v);
6784 }
6785 appendPrintBuf("%s, destinationPort:%d, netif_id:%d, keepIdleTime:%d,, keepIntervalTime:%d, retryCount:%d",
6786 printBuf, kp.destinationPort, kp.netif_id, kp.keepIdleTime, kp.keepIntervalTime, kp.retryCount);
6787
6788 closeRequest;
6789 printRequest(pRI->token, pRI->pCI->requestNumber);
6790
6791 CALL_ONREQUEST(pRI->pCI->requestNumber,&kp,sizeof(RIL_RequestKeepalive_Pro),pRI, pRI->socket_id);
6792 return;
6793invalid:
6794 invalidCommandBlock(pRI);
6795 return;
6796}
6797#endif /* KEEP_ALIVE*/
6798} /* namespace android */
6799
6800#if 0
6801void rilEventAddWakeup_helper(struct ril_event *ev) {
6802 android::rilEventAddWakeup(ev);
6803}
6804
6805void listenCallback_helper(int fd, short flags, void *param) {
6806 android::listenCallback(fd, flags, param);
6807}
6808
6809int blockingWrite_helper(int fd, void *buffer, size_t len) {
6810 return android::blockingWrite(fd, buffer, len);
6811}
6812#endif