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