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