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