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