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