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