blob: 724bcb533594b53060d3bbd72670d4752576eef1 [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);
ll112f8b82023-01-14 11:48:23 +08004274 lynq_send_result_already();
ll2bba45a2023-01-12 22:04:37 +08004275 break;
ll6bdd7702022-12-02 15:15:56 +08004276 }
lh7b0674a2022-01-10 00:34:35 -08004277 default:
4278 break;
4279 }
4280 }
lh7b0674a2022-01-10 00:34:35 -08004281 if (e != RIL_E_SUCCESS) {
4282 appendPrintBuf("%s fails by %s", printBuf, failCauseToString(e));
4283 }
4284
4285 if ((pRI->token & RIL_TOKEN_MARK) == RIL_TOKEN_MARK) {
4286 printf("%s\n", printBuf ? printBuf : "unkonwn");
4287 } else if (((pRI->pCI->requestNumber == RIL_REQUEST_DEVICE_IDENTITY)
4288 || (pRI->pCI->requestNumber == RIL_REQUEST_OEM_HOOK_RAW))
4289 && (pRI->token & INIT_TOKEN_MARK) == INIT_TOKEN_MARK) {
4290 printf("%s\n", printBuf ? printBuf : "unkonwn");
4291 if (pRI->pCI->requestNumber == RIL_REQUEST_DEVICE_IDENTITY) {
4292 if (e != RIL_E_SUCCESS) {
4293 printf(
4294 "*******************************************\n*** NOTICE: IMEI don't wirite in slot%d ***\n*******************************************\n",
4295 socket_id);
4296 }
4297 }
4298 }
4299
4300#if 0
4301 if (fd < 0) {
4302 RLOGD ("RIL onRequestComplete: Command channel closed");
4303 }
4304#endif
4305 LYNQ_RIL_respSocket(p,t);
4306 sendResponse(p, socket_id);
4307 }
4308#if ATCI_ENABLE_RESPONSE
4309 if((pRI->token & ATCI_TOKEN_MARK) == ATCI_TOKEN_MARK) //ATCI_Rsp
4310 {
4311 int error;
4312 memset(Respose_buf, 0, sizeof(Respose_buf));
4313 if(e != RIL_E_SUCCESS)
4314 error = 1; //fail
4315 else
4316 error = 0; //ok
4317 ATCIResponse(pRI->token,error,Respose_buf, pRI->pCI->requestNumber);
4318 }
4319#endif
4320 if(pRI->pCI->requestNumber == RIL_REQUEST_VOICE_REGISTRATION_STATE && (pRI->token & RIL_TOKEN_MARK) == RIL_TOKEN_MARK){
4321 int len_s = sendto(server_socket_fd,respStr,strlen(respStr),0,(struct sockaddr *)&client_addr,sizeof(client_addr));
4322 }
4323 RLOGW("RIL_onRequestComplete %s end!",requestToString(pRI->pCI->requestNumber));
4324 if((pRI->token&BLOCK_MARK) == BLOCK_MARK) {
4325 //need wakeup dispatch function
4326 BLOCK_LOCK();
4327 wakeup_token = pRI->token;
4328 RLOGW("RIL_onRequestComplete wakeup, token is %x!",wakeup_token);
4329 BLOCK_WAKEUP();
4330 BLOCK_UNLOCK();
4331 }
4332 switch (pRI->pCI->requestNumber) {
4333 case RIL_REQUEST_RADIO_POWER:
4334 speciaRequest_wakeup();
4335 break;
4336 case RIL_REQUEST_SET_RADIO_CAPABILITY:
4337 {
4338 if(utils::is_support_dsds()) {
4339 for (int id = 0; id < SIM_COUNT; id++) {
4340 ARspRequest(RIL_REQUEST_ALLOW_DATA, (RIL_SOCKET_ID)id);
4341 }
4342 }
4343 break;
4344 }
4345 case RIL_REQUEST_ALLOW_DATA:
4346 {
4347 if(utils::is_support_dsds() && isNeedConnect() && get_default_sim_data() == socket_id) {
xja1c30b82022-01-25 16:13:48 +08004348 RLOGD("wait and recreate PDN with sim switch");
lh7b0674a2022-01-10 00:34:35 -08004349 resetConnect();
xja1c30b82022-01-25 16:13:48 +08004350 sleep(WAIT_TIME_FOR_SIM_SWITCH);
lh7b0674a2022-01-10 00:34:35 -08004351 setupDataCall(0, NULL, (RIL_SOCKET_ID)0, NULL);
4352 }
4353 break;
4354 }
4355#ifdef KEEP_ALIVE
4356 case RIL_REQUEST_START_KEEPALIVE_PRO:
4357 case RIL_REQUEST_STOP_KEEPALIVE_PRO:
4358 {
4359 handleKeepAliveResponse(pRI->pCI->requestNumber, response, responselen, socket_id, (e != RIL_E_SUCCESS));
4360 break;
4361 }
4362#endif /*KEEP_ALIVE*/
4363 case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC:
4364 {
4365 if(e == RIL_E_SUCCESS)
4366 {
4367 gostSetInNeedRegister(false);
4368 gostFastEcallFlgSet(false);
4369 }
4370 else
4371 {
4372 gostNetworkSelectionSet(socket_id);
4373 }
4374 break;
4375 }
4376 default:
4377 break;
4378 }
4379done:
4380 free(pRI);
4381}
4382
4383
4384static void
4385grabPartialWakeLock() {
4386 acquire_wake_lock(PARTIAL_WAKE_LOCK, ANDROID_WAKE_LOCK_NAME);
4387}
4388
4389static void
4390releaseWakeLock() {
4391 release_wake_lock(ANDROID_WAKE_LOCK_NAME);
4392}
4393
4394
4395static int
4396decodeVoiceRadioTechnology (RIL_RadioState radioState) {
4397 switch (radioState) {
4398 case RADIO_STATE_SIM_NOT_READY:
4399 case RADIO_STATE_SIM_LOCKED_OR_ABSENT:
4400 case RADIO_STATE_SIM_READY:
4401 return RADIO_TECH_UMTS;
4402
4403 case RADIO_STATE_RUIM_NOT_READY:
4404 case RADIO_STATE_RUIM_READY:
4405 case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:
4406 case RADIO_STATE_NV_NOT_READY:
4407 case RADIO_STATE_NV_READY:
4408 return RADIO_TECH_1xRTT;
4409
4410 default:
4411 RLOGD("decodeVoiceRadioTechnology: Invoked with incorrect RadioState");
4412 return -1;
4413 }
4414}
4415
4416static int
4417decodeCdmaSubscriptionSource (RIL_RadioState radioState) {
4418 switch (radioState) {
4419 case RADIO_STATE_SIM_NOT_READY:
4420 case RADIO_STATE_SIM_LOCKED_OR_ABSENT:
4421 case RADIO_STATE_SIM_READY:
4422 case RADIO_STATE_RUIM_NOT_READY:
4423 case RADIO_STATE_RUIM_READY:
4424 case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:
4425 return CDMA_SUBSCRIPTION_SOURCE_RUIM_SIM;
4426
4427 case RADIO_STATE_NV_NOT_READY:
4428 case RADIO_STATE_NV_READY:
4429 return CDMA_SUBSCRIPTION_SOURCE_NV;
4430
4431 default:
4432 RLOGD("decodeCdmaSubscriptionSource: Invoked with incorrect RadioState");
4433 return -1;
4434 }
4435}
4436
4437static int
4438decodeSimStatus (RIL_RadioState radioState) {
4439 switch (radioState) {
4440 case RADIO_STATE_SIM_NOT_READY:
4441 case RADIO_STATE_RUIM_NOT_READY:
4442 case RADIO_STATE_NV_NOT_READY:
4443 case RADIO_STATE_NV_READY:
4444 return -1;
4445 case RADIO_STATE_SIM_LOCKED_OR_ABSENT:
4446 case RADIO_STATE_SIM_READY:
4447 case RADIO_STATE_RUIM_READY:
4448 case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:
4449 return radioState;
4450 default:
4451 RLOGD("decodeSimStatus: Invoked with incorrect RadioState");
4452 return -1;
4453 }
4454}
4455
4456static bool is3gpp2(int radioTech) {
4457 switch (radioTech) {
4458 case RADIO_TECH_IS95A:
4459 case RADIO_TECH_IS95B:
4460 case RADIO_TECH_1xRTT:
4461 case RADIO_TECH_EVDO_0:
4462 case RADIO_TECH_EVDO_A:
4463 case RADIO_TECH_EVDO_B:
4464 case RADIO_TECH_EHRPD:
4465 return true;
4466 default:
4467 return false;
4468 }
4469}
4470
4471/* If RIL sends SIM states or RUIM states, store the voice radio
4472 * technology and subscription source information so that they can be
4473 * returned when telephony framework requests them
4474 */
4475static RIL_RadioState
4476processRadioState(RIL_RadioState newRadioState, RIL_SOCKET_ID socket_id) {
4477
4478 if((newRadioState > RADIO_STATE_UNAVAILABLE) && (newRadioState < RADIO_STATE_ON)) {
4479 int newVoiceRadioTech;
4480 int newCdmaSubscriptionSource;
4481 int newSimStatus;
4482
4483 /* This is old RIL. Decode Subscription source and Voice Radio Technology
4484 from Radio State and send change notifications if there has been a change */
4485 newVoiceRadioTech = decodeVoiceRadioTechnology(newRadioState);
4486 if(newVoiceRadioTech != voiceRadioTech) {
4487 voiceRadioTech = newVoiceRadioTech;
4488 RIL_UNSOL_RESPONSE(RIL_UNSOL_VOICE_RADIO_TECH_CHANGED,
4489 &voiceRadioTech, sizeof(voiceRadioTech), socket_id);
4490 }
4491 if(is3gpp2(newVoiceRadioTech)) {
4492 newCdmaSubscriptionSource = decodeCdmaSubscriptionSource(newRadioState);
4493 if(newCdmaSubscriptionSource != cdmaSubscriptionSource) {
4494 cdmaSubscriptionSource = newCdmaSubscriptionSource;
4495 RIL_UNSOL_RESPONSE(RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED,
4496 &cdmaSubscriptionSource, sizeof(cdmaSubscriptionSource), socket_id);
4497 }
4498 }
4499 newSimStatus = decodeSimStatus(newRadioState);
4500 if(newSimStatus != simRuimStatus) {
4501 simRuimStatus = newSimStatus;
4502 RIL_UNSOL_RESPONSE(RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, NULL, 0, socket_id);
4503 }
4504
4505 /* Send RADIO_ON to telephony */
4506 newRadioState = RADIO_STATE_ON;
4507 }
4508
4509 return newRadioState;
4510}
4511
4512
4513#if defined(ANDROID_MULTI_SIM)
4514extern "C"
4515void RIL_onUnsolicitedResponse(int unsolResponse, const void *data,
4516 size_t datalen, RIL_SOCKET_ID socket_id)
4517#else
4518extern "C"
4519void RIL_onUnsolicitedResponse(int unsolResponse, const void *data,
4520 size_t datalen)
4521#endif
4522{
4523 int unsolResponseIndex;
4524 int ret;
4525 int64_t timeReceived = 0;
4526 bool shouldScheduleTimeout = false;
4527 RIL_RadioState newState;
lhf6eea122022-01-20 19:32:14 -08004528 int temp = 0;
4529 char *tempChar=NULL;
lh7b0674a2022-01-10 00:34:35 -08004530 RIL_SOCKET_ID soc_id = (RIL_SOCKET_ID)Phone_utils::get_enable_sim_for_dsss();
4531
4532#if defined(ANDROID_MULTI_SIM)
4533 soc_id = socket_id;
4534#endif
4535
4536 handle_wakeup_reason(unsolResponse);
4537
4538 if (s_registerCalled == 0) {
4539 // Ignore RIL_onUnsolicitedResponse before RIL_register
4540 RLOGW("RIL_onUnsolicitedResponse called before RIL_register");
4541 return;
4542 }
4543 if(onSupports(unsolResponse) == 0)
4544 {
4545 RLOGE("unsupported unsolicited response code %d", unsolResponse);
4546 return;
4547 }
4548
4549#ifdef TARGET_PLATFORM_MT2635
4550 //Reset modem, exit DemoApp.
4551 if(unsolResponse==RIL_UNSOL_MAL_RESTART ) {
4552 RLOGD("Modem Reset, Exit DemoApp!");
4553 printf("Modem Reset, Exit DemoApp!\n");
4554 speechonoff(0);
4555 mixer_reset_set(1);
4556 com_quit(0,NULL,soc_id,NULL);
4557 }
4558#endif
4559 if (unsolResponse < RIL_UNSOL_VENDOR_BASE) {
4560 unsolResponseIndex = unsolResponse - RIL_UNSOL_RESPONSE_BASE;
4561 }
4562#if 0
4563 WakeType wakeType;
4564 if (unsolResponse >= RIL_UNSOL_VENDOR_BASE) {
4565 //unsolResponseIndex = unsolResponse - RIL_UNSOL_VENDOR_BASE;
4566 wakeType = WAKE_PARTIAL;
4567 } else {
4568 unsolResponseIndex = unsolResponse - RIL_UNSOL_RESPONSE_BASE;
4569 wakeType = s_unsolResponses[unsolResponseIndex].wakeType;
4570 }
4571
4572 // Grab a wake lock if needed for this reponse,
4573 // as we exit we'll either release it immediately
4574 // or set a timer to release it later.
4575 switch (wakeType) {
4576 case WAKE_PARTIAL:
4577 grabPartialWakeLock();
4578 shouldScheduleTimeout = false;
4579 break;
4580
4581 case DONT_WAKE:
4582 default:
4583 // No wake lock is grabed so don't set timeout
4584 shouldScheduleTimeout = false;
4585 break;
4586 }
4587
4588 // Mark the time this was received, doing this
4589 // after grabing the wakelock incase getting
4590 // the elapsedRealTime might cause us to goto
4591 // sleep.
4592 if (unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) {
4593 timeReceived = elapsedRealtime();
4594 }
4595#endif
4596 appendPrintBuf("[UNSL][SIM%d]< %s", soc_id, requestToString(unsolResponse));
4597
4598 Parcel p;
lh7b0674a2022-01-10 00:34:35 -08004599 p.writeInt32 (RESPONSE_UNSOLICITED);
4600 p.writeInt32 (unsolResponse);
4601 /*Warren add for t800 ril service 2021/12/16 start*/
4602 p.writeInt32 (soc_id);
4603 /*Warren add for t800 ril service 2021/12/16 end*/
4604 if (unsolResponse >= RIL_UNSOL_VENDOR_BASE) {
4605 UnsolResponseInfo* unsolRspInof = find_mtk_unsol_command(unsolResponse);
4606 if(unsolRspInof == NULL){
4607 RLOGE("no unsolicited response function -- %d", unsolResponse);
4608 return;
4609 } else {
4610 ret = unsolRspInof->responseFunction(p,const_cast<void*>(data),datalen);
4611 }
4612 } else {
4613 ret = s_unsolResponses[unsolResponseIndex].responseFunction(p, const_cast<void*>(data), datalen);
4614 }
4615 if (ret != 0) {
4616 // Problem with the response. Don't continue;
4617 goto error_exit;
4618 }
4619
4620 // some things get more payload
4621 switch(unsolResponse) {
4622 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED:
4623 newState = CALL_ONSTATEREQUEST(soc_id);
4624 p.writeInt32(newState);
4625 appendPrintBuf("%s {%s}", printBuf,
4626 radioStateToString(CALL_ONSTATEREQUEST(soc_id)));
4627 break;
4628
4629#if 0
4630 case RIL_UNSOL_NITZ_TIME_RECEIVED:
4631 // Store the time that this was received so the
4632 // handler of this message can account for
4633 // the time it takes to arrive and process. In
4634 // particular the system has been known to sleep
4635 // before this message can be processed.
4636 p.writeInt64(timeReceived);
4637 break;
4638#endif
4639 }
4640
4641#if VDBG
4642 RLOGI("%s UNSOLICITED: %s length:%d", rilSocketIdToString(soc_id), requestToString(unsolResponse), p.dataSize());
4643#endif
lhf6eea122022-01-20 19:32:14 -08004644 //ret = sendResponse(p, soc_id);
lh7b0674a2022-01-10 00:34:35 -08004645
4646//unsol trigger other things.
4647 switch(unsolResponse) {
q.huangc8261a62022-12-30 19:01:34 +08004648#ifdef LED_SUPPORT
4649 case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: //add this for API-720
4650 ARspRequest(RIL_REQUEST_GET_CURRENT_CALLS, soc_id);
4651 break;
4652#endif
lh7b0674a2022-01-10 00:34:35 -08004653 case RIL_UNSOL_CALL_RING:
4654 callRing(soc_id);
4655 break;
4656 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED:
4657 updateIccCardState(soc_id);
4658 break;
4659 case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED:
4660 getVoiceAndDataRegistrationState(soc_id);
4661 break;
4662 case RIL_UNSOL_RESPONSE_NEW_SMS:
lhf6eea122022-01-20 19:32:14 -08004663 responseNewSMS((const char*)data, datalen,soc_id,unsolResponse,p);
lh7b0674a2022-01-10 00:34:35 -08004664 unreadStatusWriteSMSToSim((const char*)data, datalen, soc_id);
4665 sendSMSACK(soc_id);
4666 break;
4667 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS:
4668 {
4669 RLOGD("Receive RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS data: %s, length: %d", (char*)data, datalen);
4670 break;
4671 }
4672 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT:
4673 sendSMSACK(soc_id);
4674 break;
4675 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED:
4676 updateRadioStatus(newState,soc_id);
4677 break;
4678 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS:
4679 {
4680 ARspRequest(RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE, soc_id);
4681 break;
4682 }
4683 case RIL_UNSOL_STK_PROACTIVE_COMMAND:
4684 {
4685 RLOGD("STk proactive command raw date: %s, length: %d", (char*)data, datalen);
4686 handleStkCommand((char*)data, datalen,soc_id);
4687 break;
4688 }
4689 case RIL_UNSOL_RIL_CONNECTED:
4690 {
4691 RLOGD("vendor-ril socket(%d) connect start", soc_id);
4692 pthread_mutex_lock(&s_InitMutex);
4693 s_isConnected[soc_id] = 1;
4694 if(utils::is_support_dsds()) {
4695 if (s_isConnected[0] == 1 && s_isConnected[1] == 1) {
4696 pthread_cond_broadcast(&s_InitCond);
4697 }
4698 } else {
4699 if (s_isConnected[0] == 1 || s_isConnected[1] == 1) {
4700 pthread_cond_broadcast(&s_InitCond);
4701 }
4702 }
4703 pthread_mutex_unlock(&s_InitMutex);
4704 RLOGD("vendor-ril socket(%d) connect end", soc_id);
4705 break;
4706 }
4707 case RIL_UNSOL_TX_POWER: {
4708 int *p_int = (int *) data;
4709 int numInts = datalen / sizeof(int);
4710 if (numInts > 1) {
4711 m_RfDesense->emOemHookRaw(p_int[1],soc_id);
4712 } else {
4713 m_RfDesense->emOemHookRaw(0, soc_id);
4714 }
4715 break;
4716 }
4717 case RIL_UNSOL_NETWORK_INFO: {
4718 if(networkCb){
4719 //TBD
4720 char **p_cur = (char **) data;
4721 char *ctype = (char*)p_cur[0];
4722 int type = atoi(ctype);
4723 char *data = (char*)p_cur[1];
4724 RLOGD("ctype %s type %d data %s\n",ctype,type,data);
4725 networkCb(type,data);
4726 }
4727 break;
4728 }
4729 case RIL_UNSOL_DATA_CALL_LIST_CHANGED:
4730 {
4731 int num = datalen / sizeof(RIL_Data_Call_Response_v6);
4732 RIL_Data_Call_Response_v6 *p_cur = (RIL_Data_Call_Response_v6 *) data;
4733 handleUnsolDataCalllistChange(num,p_cur);
4734 break;
4735 }
4736 case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED:
4737 {
4738 update_voice_radio_tech(((int *) data)[0], soc_id);
4739 break;
4740 }
4741 case RIL_UNSOL_RADIO_CAPABILITY:
4742 {
4743 update_radio_capa((RIL_RadioCapability *) data, soc_id);
4744 //Proxy_controller::getInstance()->handle_message_notify((RIL_RadioCapability *) data, soc_id);
4745 break;
4746 }
4747 case RIL_UNSOL_CDMA_CALL_WAITING:
4748 {
4749 autoAnswerForCdma(soc_id);
4750 break;
4751 }
4752 case RIL_UNSOL_NITZ_TIME_RECEIVED:
4753 {
4754 updateSystemTime(data, datalen);
4755 break;
4756 }
4757 case RIL_UNSOL_ECALL_INDICATIONS:
4758 {
4759 handleEcallIndication(data, datalen, soc_id);
4760 break;
4761 }
4762#ifdef KEEP_ALIVE
4763 case RIL_UNSOL_KEEPALIVE_STATUS_PRO:
4764 {
4765 handleKeepAliveResponse(unsolResponse, data, datalen, soc_id, false);
4766 break;
4767 }
4768#endif /*KEEP_ALIVE*/
4769 case RIL_UNSOL_SIM_SMS_STORAGE_FULL:
4770 {
4771 setSimSmsStorageFullFlag(true);
4772 break;
4773 }
4774 case RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR:
4775 {
4776 handleUnsolSipCallProgressInd(data, datalen);
4777 break;
4778 }
4779 case RIL_UNSOL_ECC_NUM:
4780 {
4781 handleECCNumResponse(data, datalen,soc_id);
4782 break;
4783 }
4784 case RIL_UNSOL_CALL_INFO_INDICATION:
4785 {
4786 handleUnsolCallInfoInd(data, datalen, soc_id);
4787 break;
4788 }
4789 case RIL_UNSOL_RINGBACK_TONE:
4790 {
4791 handleRingbackTone(data, datalen, soc_id);
4792 break;
4793 }
4794 default:
4795 break;
4796 }
lhf6eea122022-01-20 19:32:14 -08004797 /*Warren add for t800 ril service 2021/12/16 start*/
q.huang036b6cf2023-01-10 14:29:20 +08004798 ret = LYNQ_RIL_urcBroadcast(p,unsolResponse);
lhf6eea122022-01-20 19:32:14 -08004799 /*Warren add for t800 ril service 2021/12/16 end*/
lh7b0674a2022-01-10 00:34:35 -08004800#if 0
4801 if (ret != 0 && unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) {
4802
4803 // Unfortunately, NITZ time is not poll/update like everything
4804 // else in the system. So, if the upstream client isn't connected,
4805 // keep a copy of the last NITZ response (with receive time noted
4806 // above) around so we can deliver it when it is connected
4807
4808 if (s_lastNITZTimeData != NULL) {
4809 free (s_lastNITZTimeData);
4810 s_lastNITZTimeData = NULL;
4811 }
4812
4813 s_lastNITZTimeData = malloc(p.dataSize());
4814 s_lastNITZTimeDataSize = p.dataSize();
4815 memcpy(s_lastNITZTimeData, p.data(), p.dataSize());
4816 }
4817
4818#endif
4819 // Normal exit
4820 return;
4821
4822error_exit:
4823 RLOGD("unsol handle fail");
4824#if 0
4825 if (shouldScheduleTimeout) {
4826 releaseWakeLock();
4827 }
4828#endif
4829}
4830
4831extern "C" void
4832RIL_requestTimedCallback (RIL_TimedCallback callback, void *param,
4833 const struct timeval *relativeTime) {
4834}
4835
4836const char *
4837failCauseToString(RIL_Errno e) {
4838 switch(e) {
4839 case RIL_E_SUCCESS: return "E_SUCCESS";
4840 case RIL_E_RADIO_NOT_AVAILABLE: return "E_RADIO_NOT_AVAILABLE";
4841 case RIL_E_GENERIC_FAILURE: return "E_GENERIC_FAILURE";
4842 case RIL_E_PASSWORD_INCORRECT: return "E_PASSWORD_INCORRECT";
4843 case RIL_E_SIM_PIN2: return "E_SIM_PIN2";
4844 case RIL_E_SIM_PUK2: return "E_SIM_PUK2";
4845 case RIL_E_REQUEST_NOT_SUPPORTED: return "E_REQUEST_NOT_SUPPORTED";
4846 case RIL_E_CANCELLED: return "E_CANCELLED";
4847 case RIL_E_OP_NOT_ALLOWED_DURING_VOICE_CALL: return "E_OP_NOT_ALLOWED_DURING_VOICE_CALL";
4848 case RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW: return "E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW";
4849 case RIL_E_SMS_SEND_FAIL_RETRY: return "E_SMS_SEND_FAIL_RETRY";
4850 case RIL_E_SIM_ABSENT:return "E_SIM_ABSENT";
4851 case RIL_E_ILLEGAL_SIM_OR_ME:return "E_ILLEGAL_SIM_OR_ME";
4852#ifdef FEATURE_MULTIMODE_ANDROID
4853 case RIL_E_SUBSCRIPTION_NOT_AVAILABLE:return "E_SUBSCRIPTION_NOT_AVAILABLE";
4854 case RIL_E_MODE_NOT_SUPPORTED:return "E_MODE_NOT_SUPPORTED";
4855#endif
4856 case RIL_E_SIM_MEM_FULL: return "E_SIM_MEM_FULL";
4857 default: return "<unknown error>";
4858 }
4859}
4860
4861const char *
4862callStateToString(RIL_CallState s) {
4863 switch(s) {
4864 case RIL_CALL_ACTIVE : return "ACTIVE";
4865 case RIL_CALL_HOLDING: return "HOLDING";
4866 case RIL_CALL_DIALING: return "DIALING";
4867 case RIL_CALL_ALERTING: return "ALERTING";
4868 case RIL_CALL_INCOMING: return "INCOMING";
4869 case RIL_CALL_WAITING: return "WAITING";
4870 default: return "<unknown state>";
4871 }
4872}
4873const char *lynq_requset_to_string(int request)
4874{
4875 switch(request) {
4876 case RIL_REQUEST_GET_SIM_STATUS: return "RIL_REQUEST_GET_SIM_STATUS";
4877 case RIL_REQUEST_ENTER_SIM_PIN: return "RIL_REQUEST_ENTER_SIM_PIN";
4878 case RIL_REQUEST_ENTER_SIM_PUK: return "RIL_REQUEST_ENTER_SIM_PUK";
4879 case RIL_REQUEST_ENTER_SIM_PIN2: return "RIL_REQUEST_ENTER_SIM_PIN2";
4880 case RIL_REQUEST_ENTER_SIM_PUK2: return "RIL_REQUEST_ENTER_SIM_PUK2";
4881 case RIL_REQUEST_CHANGE_SIM_PIN: return "RIL_REQUEST_CHANGE_SIM_PIN";
4882 case RIL_REQUEST_CHANGE_SIM_PIN2: return "RIL_REQUEST_CHANGE_SIM_PIN2";
4883 case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: return "RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION";
4884 case RIL_REQUEST_GET_CURRENT_CALLS: return "RIL_REQUEST_GET_CURRENT_CALLS";
4885 case RIL_REQUEST_DIAL: return "RIL_REQUEST_DIAL";
4886 case RIL_REQUEST_GET_IMSI: return "RIL_REQUEST_GET_IMSI";
4887 case RIL_REQUEST_HANGUP: return "RIL_REQUEST_HANGUP";
4888 case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: return "RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND";
4889 case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: return "RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND";
4890 case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: return "RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE";
4891 case RIL_REQUEST_CONFERENCE: return "RIL_REQUEST_CONFERENCE";
4892 case RIL_REQUEST_UDUB: return "RIL_REQUEST_UDUB";
4893 case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: return "RIL_REQUEST_LAST_CALL_FAIL_CAUSE";
4894 case RIL_REQUEST_SIGNAL_STRENGTH: return "RIL_REQUEST_SIGNAL_STRENGTH";
4895 case RIL_REQUEST_VOICE_REGISTRATION_STATE: return "RIL_REQUEST_VOICE_REGISTRATION_STATE";
4896 case RIL_REQUEST_DATA_REGISTRATION_STATE: return "RIL_REQUEST_DATA_REGISTRATION_STATE";
4897 case RIL_REQUEST_OPERATOR: return "RIL_REQUEST_OPERATOR";
4898 case RIL_REQUEST_RADIO_POWER: return "RIL_REQUEST_RADIO_POWER";
4899 case RIL_REQUEST_DTMF: return "RIL_REQUEST_DTMF";
4900 case RIL_REQUEST_SEND_SMS: return "RIL_REQUEST_SEND_SMS";
4901 case RIL_REQUEST_SEND_SMS_EXPECT_MORE: return "RIL_REQUEST_SEND_SMS_EXPECT_MORE";
4902 case RIL_REQUEST_SETUP_DATA_CALL: return "RIL_REQUEST_SETUP_DATA_CALL";
4903 case RIL_REQUEST_SIM_IO: return "RIL_REQUEST_SIM_IO";
4904 case RIL_REQUEST_SEND_USSD: return "RIL_REQUEST_SEND_USSD";
4905 case RIL_REQUEST_CANCEL_USSD: return "RIL_REQUEST_CANCEL_USSD";
4906 case RIL_REQUEST_GET_CLIR: return "RIL_REQUEST_GET_CLIR";
4907 case RIL_REQUEST_SET_CLIR: return "RIL_REQUEST_SET_CLIR";
4908 case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: return "RIL_REQUEST_QUERY_CALL_FORWARD_STATUS";
4909 case RIL_REQUEST_SET_CALL_FORWARD: return "RIL_REQUEST_SET_CALL_FORWARD";
4910 case RIL_REQUEST_QUERY_CALL_WAITING: return "RIL_REQUEST_QUERY_CALL_WAITING";
4911 case RIL_REQUEST_SET_CALL_WAITING: return "RIL_REQUEST_SET_CALL_WAITING";
4912 case RIL_REQUEST_SMS_ACKNOWLEDGE: return "RIL_REQUEST_SMS_ACKNOWLEDGE";
4913 case RIL_REQUEST_GET_IMEI: return "RIL_REQUEST_GET_IMEI";
4914 case RIL_REQUEST_GET_IMEISV: return "RIL_REQUEST_GET_IMEISV";
4915 case RIL_REQUEST_ANSWER: return "RIL_REQUEST_ANSWER";
4916 case RIL_REQUEST_DEACTIVATE_DATA_CALL: return "RIL_REQUEST_DEACTIVATE_DATA_CALL";
4917 case RIL_REQUEST_QUERY_FACILITY_LOCK: return "RIL_REQUEST_QUERY_FACILITY_LOCK";
4918 case RIL_REQUEST_SET_FACILITY_LOCK: return "RIL_REQUEST_SET_FACILITY_LOCK";
4919 case RIL_REQUEST_CHANGE_BARRING_PASSWORD: return "RIL_REQUEST_CHANGE_BARRING_PASSWORD";
4920 case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: return "RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE";
4921 case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: return "RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC";
4922 case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: return "RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL";
4923 case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : return "RIL_REQUEST_QUERY_AVAILABLE_NETWORKS";
4924 case RIL_REQUEST_DTMF_START: return "RIL_REQUEST_DTMF_START";
4925 case RIL_REQUEST_DTMF_STOP: return "RIL_REQUEST_DTMF_STOP";
4926 case RIL_REQUEST_BASEBAND_VERSION: return "RIL_REQUEST_BASEBAND_VERSION";
4927 case RIL_REQUEST_SEPARATE_CONNECTION: return "RIL_REQUEST_SEPARATE_CONNECTION";
4928 case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: return "RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE";
4929 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: return "RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE";
4930 case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: return "RIL_REQUEST_GET_NEIGHBORING_CELL_IDS";
4931 case RIL_REQUEST_SET_MUTE: return "RIL_REQUEST_SET_MUTE";
4932 case RIL_REQUEST_GET_MUTE: return "RIL_REQUEST_GET_MUTE";
4933 case RIL_REQUEST_QUERY_CLIP: return "RIL_REQUEST_QUERY_CLIP";
4934 case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: return "RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE";
4935 case RIL_REQUEST_DATA_CALL_LIST: return "RIL_REQUEST_DATA_CALL_LIST";
4936 case RIL_REQUEST_RESET_RADIO: return "RIL_REQUEST_RESET_RADIO";
4937 case RIL_REQUEST_OEM_HOOK_RAW: return "RIL_REQUEST_OEM_HOOK_RAW";
4938 case RIL_REQUEST_OEM_HOOK_STRINGS: return "RIL_REQUEST_OEM_HOOK_STRINGS";
4939 case RIL_REQUEST_SET_BAND_MODE: return "RIL_REQUEST_SET_BAND_MODE";
4940 case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: return "RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE";
4941 case RIL_REQUEST_STK_GET_PROFILE: return "RIL_REQUEST_STK_GET_PROFILE";
4942 case RIL_REQUEST_STK_SET_PROFILE: return "RIL_REQUEST_STK_SET_PROFILE";
4943 case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: return "RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND";
4944 case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: return "RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE";
4945 case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: return "RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM";
4946 case RIL_REQUEST_SCREEN_STATE: return "RIL_REQUEST_SCREEN_STATE";
4947 case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: return "RIL_REQUEST_EXPLICIT_CALL_TRANSFER";
4948 case RIL_REQUEST_SET_LOCATION_UPDATES: return "RIL_REQUEST_SET_LOCATION_UPDATES";
4949 case RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE:return"RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE";
4950 case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE:return"RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE";
4951 case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE:return"RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE";
4952 case RIL_REQUEST_SET_TTY_MODE:return"RIL_REQUEST_SET_TTY_MODE";
4953 case RIL_REQUEST_QUERY_TTY_MODE:return"RIL_REQUEST_QUERY_TTY_MODE";
4954 case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE:return"RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE";
4955 case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE:return"RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE";
4956 case RIL_REQUEST_CDMA_FLASH:return"RIL_REQUEST_CDMA_FLASH";
4957 case RIL_REQUEST_CDMA_BURST_DTMF:return"RIL_REQUEST_CDMA_BURST_DTMF";
4958 case RIL_REQUEST_CDMA_SEND_SMS:return"RIL_REQUEST_CDMA_SEND_SMS";
4959 case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE:return"RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE";
4960 case RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG:return"RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG";
4961 case RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG:return"RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG";
4962 case RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION:return "RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION";
4963 case RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG:return "RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG";
4964 case RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG:return "RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG";
4965 case RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION:return "RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION";
4966 case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: return"RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY";
4967 case RIL_REQUEST_CDMA_SUBSCRIPTION: return"RIL_REQUEST_CDMA_SUBSCRIPTION";
4968 case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: return "RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM";
4969 case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: return "RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM";
4970 case RIL_REQUEST_DEVICE_IDENTITY: return "RIL_REQUEST_DEVICE_IDENTITY";
4971 case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: return "RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE";
4972 case RIL_REQUEST_GET_SMSC_ADDRESS: return "RIL_REQUEST_GET_SMSC_ADDRESS";
4973 case RIL_REQUEST_SET_SMSC_ADDRESS: return "RIL_REQUEST_SET_SMSC_ADDRESS";
4974 case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: return "RIL_REQUEST_REPORT_SMS_MEMORY_STATUS";
4975 case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: return "RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING";
4976 case RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE: return "RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE";
4977 case RIL_REQUEST_ISIM_AUTHENTICATION: return "RIL_REQUEST_ISIM_AUTHENTICATION";
4978 case RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU: return "RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU";
4979 case RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS: return "RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS";
4980 case RIL_REQUEST_VOICE_RADIO_TECH: return "RIL_REQUEST_VOICE_RADIO_TECH";
4981 case RIL_REQUEST_GET_CELL_INFO_LIST: return"RIL_REQUEST_GET_CELL_INFO_LIST";
4982 case RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE: return"RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE";
4983 case RIL_REQUEST_SET_INITIAL_ATTACH_APN: return "RIL_REQUEST_SET_INITIAL_ATTACH_APN";
4984 case RIL_REQUEST_IMS_REGISTRATION_STATE: return "RIL_REQUEST_IMS_REGISTRATION_STATE";
4985 case RIL_REQUEST_IMS_SEND_SMS: return "RIL_REQUEST_IMS_SEND_SMS";
4986 case RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC: return "RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC";
4987 case RIL_REQUEST_SIM_OPEN_CHANNEL: return "RIL_REQUEST_SIM_OPEN_CHANNEL";
4988 case RIL_REQUEST_SIM_CLOSE_CHANNEL: return "RIL_REQUEST_SIM_CLOSE_CHANNEL";
4989 case RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL: return "RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL";
4990 case RIL_REQUEST_GET_RADIO_CAPABILITY: return "RIL_REQUEST_GET_RADIO_CAPABILITY";
4991 case RIL_REQUEST_SET_RADIO_CAPABILITY: return "RIL_REQUEST_SET_RADIO_CAPABILITY";
4992 case RIL_REQUEST_SET_UICC_SUBSCRIPTION: return "RIL_REQUEST_SET_UICC_SUBSCRIPTION";
4993 case RIL_REQUEST_ALLOW_DATA: return "RIL_REQUEST_ALLOW_DATA";
4994 case RIL_REQUEST_GET_HARDWARE_CONFIG: return "RIL_REQUEST_GET_HARDWARE_CONFIG";
4995 case RIL_REQUEST_SIM_AUTHENTICATION: return "RIL_REQUEST_SIM_AUTHENTICATION";
4996 case RIL_REQUEST_GET_DC_RT_INFO: return "RIL_REQUEST_GET_DC_RT_INFO";
4997 case RIL_REQUEST_SET_DC_RT_INFO_RATE: return "RIL_REQUEST_SET_DC_RT_INFO_RATE";
4998 case RIL_REQUEST_SET_DATA_PROFILE: return "RIL_REQUEST_SET_DATA_PROFILE";
4999 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return "RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED";
5000 case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return "RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED";
5001 case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: return "RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED";
5002 case RIL_UNSOL_RESPONSE_NEW_SMS: return "RIL_UNSOL_RESPONSE_NEW_SMS";
5003 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: return "RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT";
5004 case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: return "RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM";
5005 case RIL_UNSOL_ON_USSD: return "RIL_UNSOL_ON_USSD";
5006 case RIL_UNSOL_ON_USSD_REQUEST: return "RIL_UNSOL_ON_USSD_REQUEST";
5007 case RIL_UNSOL_NITZ_TIME_RECEIVED: return "RIL_UNSOL_NITZ_TIME_RECEIVED";
5008 case RIL_UNSOL_SIGNAL_STRENGTH: return "RIL_UNSOL_SIGNAL_STRENGTH";
5009 case RIL_UNSOL_STK_SESSION_END: return "RIL_UNSOL_STK_SESSION_END";
5010 case RIL_UNSOL_STK_PROACTIVE_COMMAND: return "RIL_UNSOL_STK_PROACTIVE_COMMAND";
5011 case RIL_UNSOL_STK_EVENT_NOTIFY: return "RIL_UNSOL_STK_EVENT_NOTIFY";
5012 case RIL_UNSOL_STK_CALL_SETUP: return "RIL_UNSOL_STK_CALL_SETUP";
5013 case RIL_UNSOL_SIM_SMS_STORAGE_FULL: return "RIL_UNSOL_SIM_SMS_STORAGE_FULL";
5014 case RIL_UNSOL_SIM_REFRESH: return "RIL_UNSOL_SIM_REFRESH";
5015 case RIL_UNSOL_DATA_CALL_LIST_CHANGED: return "RIL_UNSOL_DATA_CALL_LIST_CHANGED";
5016 case RIL_UNSOL_CALL_RING: return "RIL_UNSOL_CALL_RING";
5017 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: return "RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED";
5018 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: return "RIL_UNSOL_RESPONSE_CDMA_NEW_SMS";
5019 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: return "RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS";
5020 case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: return "RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL";
5021 case RIL_UNSOL_RESTRICTED_STATE_CHANGED: return "RIL_UNSOL_RESTRICTED_STATE_CHANGED";
5022 case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: return "RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE";
5023 case RIL_UNSOL_CDMA_CALL_WAITING: return "RIL_UNSOL_CDMA_CALL_WAITING";
5024 case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: return "RIL_UNSOL_CDMA_OTA_PROVISION_STATUS";
5025 case RIL_UNSOL_CDMA_INFO_REC: return "RIL_UNSOL_CDMA_INFO_REC";
5026 case RIL_UNSOL_OEM_HOOK_RAW: return "RIL_UNSOL_OEM_HOOK_RAW";
5027 case RIL_UNSOL_RINGBACK_TONE: return "RIL_UNSOL_RINGBACK_TONE";
5028 case RIL_UNSOL_RESEND_INCALL_MUTE: return "RIL_UNSOL_RESEND_INCALL_MUTE";
5029 case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: return "RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED";
5030 case RIL_UNSOL_CDMA_PRL_CHANGED: return "RIL_UNSOL_CDMA_PRL_CHANGED";
5031 case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: return "RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE";
5032 case RIL_UNSOL_RIL_CONNECTED: return "RIL_UNSOL_RIL_CONNECTED";
5033 case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED: return "RIL_UNSOL_VOICE_RADIO_TECH_CHANGED";
5034 case RIL_UNSOL_CELL_INFO_LIST: return "RIL_UNSOL_CELL_INFO_LIST";
5035 case RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED: return "RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED";
5036 case RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED: return "RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED";
5037 case RIL_UNSOL_SRVCC_STATE_NOTIFY: return "RIL_UNSOL_SRVCC_STATE_NOTIFY";
5038 case RIL_UNSOL_HARDWARE_CONFIG_CHANGED: return "RIL_UNSOL_HARDWARE_CONFIG_CHANGED";
5039 case RIL_UNSOL_DC_RT_INFO_CHANGED: return "RIL_UNSOL_DC_RT_INFO_CHANGED";
5040 case RIL_REQUEST_SHUTDOWN: return "RIL_REQUEST_SHUTDOWN";
5041 case RIL_UNSOL_RADIO_CAPABILITY: return "RIL_UNSOL_RADIO_CAPABILITY";
5042 case RIL_REQUEST_SET_TRM: return "RIL_REQUEST_SET_TRM";
5043 case RIL_REQUEST_SET_IMS_ENABLE:return "RIL_REQUEST_SET_IMS_ENABLE";
5044 case RIL_REQUEST_SET_AUDIO_PATH: return "RIL_REQUEST_SET_AUDIO_PATH";
5045 case RIL_REQUEST_HANGUP_ALL: return "RIL_REQUEST_HANGUP_ALL";
5046 case RIL_REQUEST_FORCE_RELEASE_CALL: return "RIL_REQUEST_FORCE_RELEASE_CALL";
5047 case RIL_REQUEST_EMERGENCY_DIAL: return "RIL_REQUEST_EMERGENCY_DIAL";
5048 case RIL_REQUEST_SET_ECC_SERVICE_CATEGORY: return "RIL_REQUEST_SET_ECC_SERVICE_CATEGORY";
5049 case RIL_REQUEST_SET_ECC_LIST: return "RIL_REQUEST_SET_ECC_LIST";
5050 case RIL_REQUEST_AT_COMMAND_WITH_PROXY: return "RIL_REQUEST_AT_COMMAND_WITH_PROXY";
5051 case RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION: return "RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION";
5052 case RIL_REQUEST_SET_CLIP: return "RIL_REQUEST_SET_CLIP";
5053 case RIL_REQUEST_GET_COLP: return "RIL_REQUEST_GET_COLP";
5054 case RIL_REQUEST_SET_COLP: return "RIL_REQUEST_SET_COLP";
5055 case RIL_REQUEST_GET_COLR: return "RIL_REQUEST_GET_COLR";
5056 case RIL_REQUEST_ADD_IMS_CONFERENCE_CALL_MEMBER: return "RIL_REQUEST_ADD_IMS_CONFERENCE_CALL_MEMBER";
5057 case RIL_REQUEST_REMOVE_IMS_CONFERENCE_CALL_MEMBER: return "RIL_REQUEST_REMOVE_IMS_CONFERENCE_CALL_MEMBER";
5058 case RIL_REQUEST_CONFERENCE_DIAL: return "RIL_REQUEST_CONFERENCE_DIAL";
5059 case RIL_REQUEST_DIAL_WITH_SIP_URI: return "RIL_REQUEST_DIAL_WITH_SIP_URI";
5060 case RIL_REQUEST_HOLD_CALL: return "RIL_REQUEST_HOLD_CALL";
5061 case RIL_REQUEST_RESUME_CALL: return "RIL_REQUEST_RESUME_CALL";
5062 case RIL_UNSOL_ECONF_SRVCC_INDICATION : return "RIL_UNSOL_ECONF_SRVCC_INDICATION";
5063 case RIL_UNSOL_ECONF_RESULT_INDICATION : return "RIL_UNSOL_ECONF_RESULT_INDICATION";
5064 case RIL_UNSOL_MAL_AT_INFO : return "RIL_UNSOL_MAL_AT_INFO";
5065 case RIL_REQUEST_MODEM_POWEROFF: return "RIL_REQUEST_MODEM_POWEROFF";
5066 case RIL_REQUEST_MODEM_POWERON: return "RIL_REQUEST_MODEM_POWERON";
5067 case RIL_REQUEST_WRITE_SMS_TO_SIM: return "RIL_REQUEST_WRITE_SMS_TO_SIM";
5068 case RIL_REQUEST_QUERY_ICCID: return "RIL_REQUEST_QUERY_ICCID";
5069 case RIL_UNSOL_TX_POWER: return "RIL_UNSOL_TX_POWER";
5070 case RIL_UNSOL_NETWORK_INFO: return "RIL_UNSOL_NETWORK_INFO";
5071 case RIL_REQUEST_DELETE_SMS_ON_SIM: return "RIL_REQUEST_DELETE_SMS_ON_SIM";
5072 case RIL_REQUEST_SET_IMSCFG: return "RIL_REQUEST_SET_IMSCFG";
5073#ifdef ECALL_SUPPORT
5074 case RIL_REQUEST_ECALL_FAST_MAKE_ECALL: return "RIL_REQUEST_ECALL_FAST_MAKE_ECALL";
5075 case RIL_REQUEST_ECALL_SET_IVS: return "RIL_REQUEST_ECALL_SET_IVS";
5076 case RIL_REQUEST_ECALL_SET_PSAP: return "RIL_REQUEST_ECALL_SET_PSAP";
5077 case RIL_REQUEST_ECALL_MAKE_ECALL: return "RIL_REQUEST_ECALL_MAKE_ECALL";
5078 case RIL_REQUEST_ECALL_IVS_PUSH_MSD: return "RIL_REQUEST_ECALL_IVS_PUSH_MSD";
5079 case RIL_REQUEST_ECALL_PSAP_PULL_MSD: return "RIL_REQUEST_ECALL_PSAP_PULL_MSD";
5080 case RIL_UNSOL_ECALL_MSDHACK : return "RIL_UNSOL_ECALL_MSDHACK";
5081 case RIL_REQUEST_ECALL_SET_MSD: return "RIL_REQUEST_ECALL_SET_MSD";
5082 case RIL_REQUEST_ECALL_CTRL_SEQUENCE: return "RIL_REQUEST_ECALL_CTRL_SEQUENCE";
5083 case RIL_UNSOL_ECALL_INDICATIONS : return "RIL_UNSOL_ECALL_INDICATIONS";
5084 case RIL_REQUEST_ECALL_RESET_IVS: return "RIL_REQUEST_ECALL_RESET_IVS";
5085 case RIL_REQUEST_ECALL_SET_PRI: return "RIL_REQUEST_ECALL_SET_PRI";
5086 case RIL_REQUEST_ECALL_SET_TEST_NUM: return "RIL_REQUEST_ECALL_SET_TEST_NUM";
5087 case RIL_REQUEST_ECALL_SET_RECONF_NUM: return "RIL_REQUEST_ECALL_SET_RECONF_NUM";
5088 case RIL_REQUEST_SYNC_DATA_SETTINGS_TO_MD: return "RIL_REQUEST_SYNC_DATA_SETTINGS_TO_MD";
5089 case RIL_REQUEST_ECALL_SET_NAD_DEREGISTRATION_TIME: return "RIL_REQUEST_ECALL_SET_NAD_DEREGISTRATION_TIME";
5090 case RIL_REQUEST_ECALL_SET_REGISTRATION_STATE: return "RIL_REQUEST_ECALL_SET_REGISTRATION_STATE";
5091#endif /*ECALL_SUPPORT*/
5092#ifdef KEEP_ALIVE
5093 case RIL_REQUEST_START_KEEPALIVE_PRO: return "RIL_REQUEST_START_KEEPALIVE_PRO";
5094 case RIL_REQUEST_STOP_KEEPALIVE_PRO: return "RIL_REQUEST_STOP_KEEPALIVE_PRO";
5095 case RIL_UNSOL_KEEPALIVE_STATUS_PRO: return "RIL_UNSOL_KEEPALIVE_STATUS_PRO";
5096#endif /*KEEP_ALIVE*/
5097 case RIL_REQUEST_SEND_USSI: return "RIL_REQUEST_SEND_USSI";
5098 case RIL_REQUEST_CANCEL_USSI: return "RIL_REQUEST_CANCEL_USSI";
5099 case RIL_REQUEST_GET_SMS_SIM_MEM_STATUS: return "RIL_REQUEST_GET_SMS_SIM_MEM_STATUS";
5100 case RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR: return "RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR";
5101 case RIL_REQUEST_REPORT_AIRPLANE_MODE: return "RIL_REQUEST_REPORT_AIRPLANE_MODE";
5102 case RIL_REQUEST_SET_ECC_NUM: return "RIL_REQUEST_SET_ECC_NUM";
5103 case RIL_REQUEST_GET_ECC_NUM: return "RIL_REQUEST_GET_ECC_NUM";
5104 case RIL_UNSOL_ECC_NUM: return "RIL_UNSOL_ECC_NUM";
5105 case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS_WITH_ACT: return "RIL_REQUEST_QUERY_AVAILABLE_NETWORKS_WITH_ACT";
5106 case RIL_REQUEST_GSM_GET_BROADCAST_LANGUAGE: return "RIL_REQUEST_GSM_GET_BROADCAST_LANGUAGE";
5107 case RIL_REQUEST_GSM_SET_BROADCAST_LANGUAGE: return "RIL_REQUEST_GSM_SET_BROADCAST_LANGUAGE";
5108 case RIL_UNSOL_CALL_INFO_INDICATION: return "RIL_UNSOL_CALL_INFO_INDICATION";
rjw20006d12022-04-21 16:29:04 +08005109/*Typethree add for t800 RIL Service 2022/04/14 start*/
5110//#ifdef TARGET_PLATFORM_MT2731
lh7b0674a2022-01-10 00:34:35 -08005111 case RIL_REQUEST_MODIFY_APN: return "RIL_REQUEST_MODIFY_APN";
5112 case RIL_REQUEST_RESET_APN: return "RIL_REQUEST_RESET_APN";
rjw20006d12022-04-21 16:29:04 +08005113//#endif
5114/*Typethree add for t800 RIL Service 2022/04/14 end*/
lh7b0674a2022-01-10 00:34:35 -08005115 case RIL_REQUEST_QUERY_SIM_RETRY_COUNT: return "RIL_REQUEST_QUERY_SIM_RETRY_COUNT";
5116 case RIL_REQUEST_QUERY_EID: return "RIL_REQUEST_QUERY_EID";
5117 /*LYNQ CMD*/
5118 case LYNQ_AUTO_ANSWER_CALL: return "LYNQ_AUTO_ANSWER_CALL";
5119 case LYNQ_REQUEST_SET_DTMF_VOLUME: return "RIL_REQUEST_SET_DTMF_VOLUME";
q.huangec88da92022-03-29 04:17:32 -04005120 case LYNQ_REQUEST_SET_SPEECH_VOLUME: return "RIL_REQUEST_SET_SPEECH_VOLUME";
5121 case LYNQ_REQUEST_GET_SPEECH_VOLUME: return "RIL_REQUEST_GET_SPEECH_VOLUME";
5122 case LYNQ_REQUEST_RECORD: return "RIL_REQUEST_RECORD";
lhf6eea122022-01-20 19:32:14 -08005123 case LYNQ_REQUEST_WRITE_SMS_TO_MEMORY: return "LYNQ_REQUEST_WRITE_SMS_TO_MEMORY";
5124 case LYNQ_REQUEST_READ_SMS_FROM_MEMORY: return "LYNQ_REQUEST_READ_SMS_FROM_MEMORY";
5125 case LYNQ_REQUEST_DELETE_SMS_FROM_MEMORY: return "LYNQ_REQUEST_DELETE_SMS_FROM_MEMORY";
5126 case LYNQ_REQUEST_LIST_SMS_FROM_MEMORY: return "LYNQ_REQUEST_LIST_SMS_FROM_MEMORY";
rjw5d2a50e2022-02-28 15:01:49 +08005127 case LYNQ_REQUEST_SET_DEFAULT_SIM_ALL:return "SET_DEFAULT_SIM_ALL";
jb.qi96449342022-09-19 22:14:41 -07005128 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 +08005129 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 -07005130 /*warren add for t800 ril service 2022/1/22 end*/
lh7b0674a2022-01-10 00:34:35 -08005131 default: return "<unknown request>";
5132 }
5133}
5134
5135const char *
5136requestToString(int request) {
5137/*
5138 cat libs/telephony/ril_commands.h \
5139 | egrep "^ *{RIL_" \
5140 | sed -re 's/\{RIL_([^,]+),[^,]+,([^}]+).+/case RIL_\1: return "\1";/'
5141
5142
5143 cat libs/telephony/ril_unsol_commands.h \
5144 | egrep "^ *{RIL_" \
5145 | sed -re 's/\{RIL_([^,]+),([^}]+).+/case RIL_\1: return "\1";/'
5146
5147*/
5148 switch(request) {
5149 case RIL_REQUEST_GET_SIM_STATUS: return "GET_SIM_STATUS";
5150 case RIL_REQUEST_ENTER_SIM_PIN: return "ENTER_SIM_PIN";
5151 case RIL_REQUEST_ENTER_SIM_PUK: return "ENTER_SIM_PUK";
5152 case RIL_REQUEST_ENTER_SIM_PIN2: return "ENTER_SIM_PIN2";
5153 case RIL_REQUEST_ENTER_SIM_PUK2: return "ENTER_SIM_PUK2";
5154 case RIL_REQUEST_CHANGE_SIM_PIN: return "CHANGE_SIM_PIN";
5155 case RIL_REQUEST_CHANGE_SIM_PIN2: return "CHANGE_SIM_PIN2";
5156 case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: return "ENTER_NETWORK_DEPERSONALIZATION";
5157 case RIL_REQUEST_GET_CURRENT_CALLS: return "GET_CURRENT_CALLS";
5158 case RIL_REQUEST_DIAL: return "DIAL";
5159 case RIL_REQUEST_GET_IMSI: return "GET_IMSI";
5160 case RIL_REQUEST_HANGUP: return "HANGUP";
5161 case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: return "HANGUP_WAITING_OR_BACKGROUND";
5162 case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: return "HANGUP_FOREGROUND_RESUME_BACKGROUND";
5163 case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: return "SWITCH_WAITING_OR_HOLDING_AND_ACTIVE";
5164 case RIL_REQUEST_CONFERENCE: return "CONFERENCE";
5165 case RIL_REQUEST_UDUB: return "UDUB";
5166 case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: return "LAST_CALL_FAIL_CAUSE";
5167 case RIL_REQUEST_SIGNAL_STRENGTH: return "SIGNAL_STRENGTH";
5168 case RIL_REQUEST_VOICE_REGISTRATION_STATE: return "VOICE_REGISTRATION_STATE";
5169 case RIL_REQUEST_DATA_REGISTRATION_STATE: return "DATA_REGISTRATION_STATE";
5170 case RIL_REQUEST_OPERATOR: return "OPERATOR";
5171 case RIL_REQUEST_RADIO_POWER: return "RADIO_POWER";
5172 case RIL_REQUEST_DTMF: return "DTMF";
5173 case RIL_REQUEST_SEND_SMS: return "SEND_SMS";
5174 case RIL_REQUEST_SEND_SMS_EXPECT_MORE: return "SEND_SMS_EXPECT_MORE";
5175 case RIL_REQUEST_SETUP_DATA_CALL: return "SETUP_DATA_CALL";
5176 case RIL_REQUEST_SIM_IO: return "SIM_IO";
5177 case RIL_REQUEST_SEND_USSD: return "SEND_USSD";
5178 case RIL_REQUEST_CANCEL_USSD: return "CANCEL_USSD";
5179 case RIL_REQUEST_GET_CLIR: return "GET_CLIR";
5180 case RIL_REQUEST_SET_CLIR: return "SET_CLIR";
5181 case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: return "QUERY_CALL_FORWARD_STATUS";
5182 case RIL_REQUEST_SET_CALL_FORWARD: return "SET_CALL_FORWARD";
5183 case RIL_REQUEST_QUERY_CALL_WAITING: return "QUERY_CALL_WAITING";
5184 case RIL_REQUEST_SET_CALL_WAITING: return "SET_CALL_WAITING";
5185 case RIL_REQUEST_SMS_ACKNOWLEDGE: return "SMS_ACKNOWLEDGE";
5186 case RIL_REQUEST_GET_IMEI: return "GET_IMEI";
5187 case RIL_REQUEST_GET_IMEISV: return "GET_IMEISV";
5188 case RIL_REQUEST_ANSWER: return "ANSWER";
5189 case RIL_REQUEST_DEACTIVATE_DATA_CALL: return "DEACTIVATE_DATA_CALL";
5190 case RIL_REQUEST_QUERY_FACILITY_LOCK: return "QUERY_FACILITY_LOCK";
5191 case RIL_REQUEST_SET_FACILITY_LOCK: return "SET_FACILITY_LOCK";
5192 case RIL_REQUEST_CHANGE_BARRING_PASSWORD: return "CHANGE_BARRING_PASSWORD";
5193 case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: return "QUERY_NETWORK_SELECTION_MODE";
5194 case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: return "SET_NETWORK_SELECTION_AUTOMATIC";
5195 case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: return "SET_NETWORK_SELECTION_MANUAL";
5196 case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : return "QUERY_AVAILABLE_NETWORKS ";
5197 case RIL_REQUEST_DTMF_START: return "DTMF_START";
5198 case RIL_REQUEST_DTMF_STOP: return "DTMF_STOP";
5199 case RIL_REQUEST_BASEBAND_VERSION: return "BASEBAND_VERSION";
5200 case RIL_REQUEST_SEPARATE_CONNECTION: return "SEPARATE_CONNECTION";
5201 case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: return "SET_PREFERRED_NETWORK_TYPE";
5202 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: return "GET_PREFERRED_NETWORK_TYPE";
5203 case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: return "GET_NEIGHBORING_CELL_IDS";
5204 case RIL_REQUEST_SET_MUTE: return "SET_MUTE";
5205 case RIL_REQUEST_GET_MUTE: return "GET_MUTE";
5206 case RIL_REQUEST_QUERY_CLIP: return "QUERY_CLIP";
5207 case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: return "LAST_DATA_CALL_FAIL_CAUSE";
5208 case RIL_REQUEST_DATA_CALL_LIST: return "DATA_CALL_LIST";
5209 case RIL_REQUEST_RESET_RADIO: return "RESET_RADIO";
5210 case RIL_REQUEST_OEM_HOOK_RAW: return "OEM_HOOK_RAW";
5211 case RIL_REQUEST_OEM_HOOK_STRINGS: return "OEM_HOOK_STRINGS";
5212 case RIL_REQUEST_SET_BAND_MODE: return "SET_BAND_MODE";
5213 case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: return "QUERY_AVAILABLE_BAND_MODE";
5214 case RIL_REQUEST_STK_GET_PROFILE: return "STK_GET_PROFILE";
5215 case RIL_REQUEST_STK_SET_PROFILE: return "STK_SET_PROFILE";
5216 case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: return "STK_SEND_ENVELOPE_COMMAND";
5217 case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: return "STK_SEND_TERMINAL_RESPONSE";
5218 case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: return "STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM";
5219 case RIL_REQUEST_SCREEN_STATE: return "SCREEN_STATE";
5220 case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: return "EXPLICIT_CALL_TRANSFER";
5221 case RIL_REQUEST_SET_LOCATION_UPDATES: return "SET_LOCATION_UPDATES";
5222 case RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE:return"CDMA_SET_SUBSCRIPTION_SOURCE";
5223 case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE:return"CDMA_SET_ROAMING_PREFERENCE";
5224 case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE:return"CDMA_QUERY_ROAMING_PREFERENCE";
5225 case RIL_REQUEST_SET_TTY_MODE:return"SET_TTY_MODE";
5226 case RIL_REQUEST_QUERY_TTY_MODE:return"QUERY_TTY_MODE";
5227 case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE";
5228 case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE";
5229 case RIL_REQUEST_CDMA_FLASH:return"CDMA_FLASH";
5230 case RIL_REQUEST_CDMA_BURST_DTMF:return"CDMA_BURST_DTMF";
5231 case RIL_REQUEST_CDMA_SEND_SMS:return"CDMA_SEND_SMS";
5232 case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE:return"CDMA_SMS_ACKNOWLEDGE";
5233 case RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG:return"GSM_GET_BROADCAST_SMS_CONFIG";
5234 case RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG:return"GSM_SET_BROADCAST_SMS_CONFIG";
5235 case RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION:return "GSM_SMS_BROADCAST_ACTIVATION";
5236 case RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG:return "CDMA_GET_BROADCAST_SMS_CONFIG";
5237 case RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG:return "CDMA_SET_BROADCAST_SMS_CONFIG";
5238 case RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION:return "CDMA_SMS_BROADCAST_ACTIVATION";
5239 case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: return"CDMA_VALIDATE_AND_WRITE_AKEY";
5240 case RIL_REQUEST_CDMA_SUBSCRIPTION: return"CDMA_SUBSCRIPTION";
5241 case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: return "CDMA_WRITE_SMS_TO_RUIM";
5242 case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: return "CDMA_DELETE_SMS_ON_RUIM";
5243 case RIL_REQUEST_DEVICE_IDENTITY: return "DEVICE_IDENTITY";
5244 case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: return "EXIT_EMERGENCY_CALLBACK_MODE";
5245 case RIL_REQUEST_GET_SMSC_ADDRESS: return "GET_SMSC_ADDRESS";
5246 case RIL_REQUEST_SET_SMSC_ADDRESS: return "SET_SMSC_ADDRESS";
5247 case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: return "REPORT_SMS_MEMORY_STATUS";
5248 case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: return "REPORT_STK_SERVICE_IS_RUNNING";
5249 case RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE: return "CDMA_GET_SUBSCRIPTION_SOURCE";
5250 case RIL_REQUEST_ISIM_AUTHENTICATION: return "ISIM_AUTHENTICATION";
5251 case RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU: return "RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU";
5252 case RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS: return "RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS";
5253 case RIL_REQUEST_VOICE_RADIO_TECH: return "VOICE_RADIO_TECH";
5254 case RIL_REQUEST_GET_CELL_INFO_LIST: return"GET_CELL_INFO_LIST";
5255 case RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE: return"SET_UNSOL_CELL_INFO_LIST_RATE";
5256 case RIL_REQUEST_SET_INITIAL_ATTACH_APN: return "RIL_REQUEST_SET_INITIAL_ATTACH_APN";
5257 case RIL_REQUEST_IMS_REGISTRATION_STATE: return "IMS_REGISTRATION_STATE";
5258 case RIL_REQUEST_IMS_SEND_SMS: return "IMS_SEND_SMS";
5259 case RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC: return "SIM_TRANSMIT_APDU_BASIC";
5260 case RIL_REQUEST_SIM_OPEN_CHANNEL: return "SIM_OPEN_CHANNEL";
5261 case RIL_REQUEST_SIM_CLOSE_CHANNEL: return "SIM_CLOSE_CHANNEL";
5262 case RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL: return "SIM_TRANSMIT_APDU_CHANNEL";
5263 case RIL_REQUEST_GET_RADIO_CAPABILITY: return "RIL_REQUEST_GET_RADIO_CAPABILITY";
5264 case RIL_REQUEST_SET_RADIO_CAPABILITY: return "RIL_REQUEST_SET_RADIO_CAPABILITY";
5265 case RIL_REQUEST_SET_UICC_SUBSCRIPTION: return "SET_UICC_SUBSCRIPTION";
5266 case RIL_REQUEST_ALLOW_DATA: return "ALLOW_DATA";
5267 case RIL_REQUEST_GET_HARDWARE_CONFIG: return "GET_HARDWARE_CONFIG";
5268 case RIL_REQUEST_SIM_AUTHENTICATION: return "SIM_AUTHENTICATION";
5269 case RIL_REQUEST_GET_DC_RT_INFO: return "GET_DC_RT_INFO";
5270 case RIL_REQUEST_SET_DC_RT_INFO_RATE: return "SET_DC_RT_INFO_RATE";
5271 case RIL_REQUEST_SET_DATA_PROFILE: return "SET_DATA_PROFILE";
5272 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return "UNSOL_RESPONSE_RADIO_STATE_CHANGED";
5273 case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return "UNSOL_RESPONSE_CALL_STATE_CHANGED";
5274 case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: return "UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED";
q.huang036b6cf2023-01-10 14:29:20 +08005275 case RIL_UNSOL_RESPONSE_PS_NETWORK_STATE_CHANGED: return "UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED";
lh7b0674a2022-01-10 00:34:35 -08005276 case RIL_UNSOL_RESPONSE_NEW_SMS: return "UNSOL_RESPONSE_NEW_SMS";
5277 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: return "UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT";
5278 case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: return "UNSOL_RESPONSE_NEW_SMS_ON_SIM";
5279 case RIL_UNSOL_ON_USSD: return "UNSOL_ON_USSD";
5280 case RIL_UNSOL_ON_USSD_REQUEST: return "UNSOL_ON_USSD_REQUEST(obsolete)";
5281 case RIL_UNSOL_NITZ_TIME_RECEIVED: return "UNSOL_NITZ_TIME_RECEIVED";
5282 case RIL_UNSOL_SIGNAL_STRENGTH: return "UNSOL_SIGNAL_STRENGTH";
5283 case RIL_UNSOL_STK_SESSION_END: return "UNSOL_STK_SESSION_END";
5284 case RIL_UNSOL_STK_PROACTIVE_COMMAND: return "UNSOL_STK_PROACTIVE_COMMAND";
5285 case RIL_UNSOL_STK_EVENT_NOTIFY: return "UNSOL_STK_EVENT_NOTIFY";
5286 case RIL_UNSOL_STK_CALL_SETUP: return "UNSOL_STK_CALL_SETUP";
5287 case RIL_UNSOL_SIM_SMS_STORAGE_FULL: return "UNSOL_SIM_SMS_STORAGE_FUL";
5288 case RIL_UNSOL_SIM_REFRESH: return "UNSOL_SIM_REFRESH";
5289 case RIL_UNSOL_DATA_CALL_LIST_CHANGED: return "UNSOL_DATA_CALL_LIST_CHANGED";
5290 case RIL_UNSOL_CALL_RING: return "UNSOL_CALL_RING";
5291 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: return "UNSOL_RESPONSE_SIM_STATUS_CHANGED";
5292 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: return "UNSOL_NEW_CDMA_SMS";
5293 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: return "UNSOL_NEW_BROADCAST_SMS";
5294 case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: return "UNSOL_CDMA_RUIM_SMS_STORAGE_FULL";
5295 case RIL_UNSOL_RESTRICTED_STATE_CHANGED: return "UNSOL_RESTRICTED_STATE_CHANGED";
5296 case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: return "UNSOL_ENTER_EMERGENCY_CALLBACK_MODE";
5297 case RIL_UNSOL_CDMA_CALL_WAITING: return "UNSOL_CDMA_CALL_WAITING";
5298 case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: return "UNSOL_CDMA_OTA_PROVISION_STATUS";
5299 case RIL_UNSOL_CDMA_INFO_REC: return "UNSOL_CDMA_INFO_REC";
5300 case RIL_UNSOL_OEM_HOOK_RAW: return "UNSOL_OEM_HOOK_RAW";
5301 case RIL_UNSOL_RINGBACK_TONE: return "UNSOL_RINGBACK_TONE";
5302 case RIL_UNSOL_RESEND_INCALL_MUTE: return "UNSOL_RESEND_INCALL_MUTE";
5303 case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: return "UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED";
5304 case RIL_UNSOL_CDMA_PRL_CHANGED: return "UNSOL_CDMA_PRL_CHANGED";
5305 case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: return "UNSOL_EXIT_EMERGENCY_CALLBACK_MODE";
5306 case RIL_UNSOL_RIL_CONNECTED: return "UNSOL_RIL_CONNECTED";
5307 case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED: return "UNSOL_VOICE_RADIO_TECH_CHANGED";
5308 case RIL_UNSOL_CELL_INFO_LIST: return "UNSOL_CELL_INFO_LIST";
5309 case RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED: return "RESPONSE_IMS_NETWORK_STATE_CHANGED";
5310 case RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED: return "UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED";
5311 case RIL_UNSOL_SRVCC_STATE_NOTIFY: return "UNSOL_SRVCC_STATE_NOTIFY";
5312 case RIL_UNSOL_HARDWARE_CONFIG_CHANGED: return "HARDWARE_CONFIG_CHANGED";
5313 case RIL_UNSOL_DC_RT_INFO_CHANGED: return "UNSOL_DC_RT_INFO_CHANGED";
5314 case RIL_REQUEST_SHUTDOWN: return "SHUTDOWN";
5315 case RIL_UNSOL_RADIO_CAPABILITY: return "RIL_UNSOL_RADIO_CAPABILITY";
5316 case RIL_REQUEST_SET_TRM: return "RIL_REQUEST_SET_TRM";
5317 case RIL_REQUEST_SET_IMS_ENABLE:return "RIL_REQUEST_SET_IMS_ENABLE";
5318 case RIL_REQUEST_SET_AUDIO_PATH: return "SET_AUDIO_PATH";
5319 case RIL_REQUEST_HANGUP_ALL: return "HANGUP_ALL";
5320 case RIL_REQUEST_FORCE_RELEASE_CALL: return "FORCE_RELEASE_CALL";
5321 case RIL_REQUEST_EMERGENCY_DIAL: return "RIL_REQUEST_EMERGENCY_DIAL";
5322 case RIL_REQUEST_SET_ECC_SERVICE_CATEGORY: return "RIL_REQUEST_SET_ECC_SERVICE_CATEGORY";
5323 case RIL_REQUEST_SET_ECC_LIST: return "RIL_REQUEST_SET_ECC_LIST";
5324 case RIL_REQUEST_AT_COMMAND_WITH_PROXY: return "AT_COMMAND_WITH_PROXY";
5325 case RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION: return "RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION";
5326 case RIL_REQUEST_SET_CLIP: return "RIL_REQUEST_SET_CLIP";
5327 case RIL_REQUEST_GET_COLP: return "RIL_REQUEST_GET_COLP";
5328 case RIL_REQUEST_SET_COLP: return "RIL_REQUEST_SET_COLP";
5329 case RIL_REQUEST_GET_COLR: return "RIL_REQUEST_GET_COLR";
5330 case RIL_REQUEST_ADD_IMS_CONFERENCE_CALL_MEMBER: return "ADD_IMS_CONFERENCE_CALL_MEMBER";
5331 case RIL_REQUEST_REMOVE_IMS_CONFERENCE_CALL_MEMBER: return "REMOVE_IMS_CONFERENCE_CALL_MEMBER";
5332 case RIL_REQUEST_CONFERENCE_DIAL: return "CONFERENCE_DIAL";
5333 case RIL_REQUEST_DIAL_WITH_SIP_URI: return "DIAL_WITH_SIP_URI";
5334 case RIL_REQUEST_HOLD_CALL: return "HOLD_CALL";
5335 case RIL_REQUEST_RESUME_CALL: return "RESUME_CALL";
5336 case RIL_UNSOL_ECONF_SRVCC_INDICATION : return "ECONF_SRVCC_INDICATION";
5337 case RIL_UNSOL_ECONF_RESULT_INDICATION : return "ECONF_RESULT_INDICATION";
5338 case RIL_UNSOL_MAL_AT_INFO : return "UNSOL_MAL_AT_INFO";
5339 case RIL_REQUEST_MODEM_POWEROFF: return "MODEM_POWEROFF";
5340 case RIL_REQUEST_MODEM_POWERON: return "MODEM_POWERON";
5341 case RIL_REQUEST_WRITE_SMS_TO_SIM: return "WRITE_SMS_TO_SIM";
5342 case RIL_REQUEST_QUERY_ICCID: return "RIL_REQUEST_QUERY_ICCID";
5343 case RIL_UNSOL_TX_POWER: return "RIL_UNSOL_TX_POWER";
5344 case RIL_UNSOL_NETWORK_INFO: return "RIL_UNSOL_NETWORK_INFO";
5345 case RIL_REQUEST_DELETE_SMS_ON_SIM: return "DELETE_SMS_ON_SIM";
5346 case RIL_REQUEST_SET_IMSCFG: return "RIL_REQUEST_SET_IMSCFG";
5347#ifdef ECALL_SUPPORT
5348 case RIL_REQUEST_ECALL_FAST_MAKE_ECALL: return "ECALL_FAST_MAKE_ECALL";
5349 case RIL_REQUEST_ECALL_SET_IVS: return "RIL_REQUEST_ECALL_SET_IVS";
5350 case RIL_REQUEST_ECALL_SET_PSAP: return "RIL_REQUEST_ECALL_SET_PSAP";
5351 case RIL_REQUEST_ECALL_MAKE_ECALL: return "RIL_REQUEST_ECALL_MAKE_ECALL";
5352 case RIL_REQUEST_ECALL_IVS_PUSH_MSD: return "RIL_REQUEST_ECALL_IVS_PUSH_MSD";
5353 case RIL_REQUEST_ECALL_PSAP_PULL_MSD: return "RIL_REQUEST_ECALL_PSAP_PULL_MSD";
5354 case RIL_UNSOL_ECALL_MSDHACK : return "ECALL_MSDHACK";
5355 case RIL_REQUEST_ECALL_SET_MSD: return "RIL_REQUEST_ECALL_SET_MSD";
5356 case RIL_REQUEST_ECALL_CTRL_SEQUENCE: return "ECALL_SET_CTRL_SEQUENCE";
5357 case RIL_UNSOL_ECALL_INDICATIONS : return "ECALL_INDICATIONS";
5358 case RIL_REQUEST_ECALL_RESET_IVS: return "RIL_REQUEST_ECALL_RESET_IVS";
5359 case RIL_REQUEST_ECALL_SET_PRI: return "RIL_REQUEST_ECALL_SET_PRI";
5360 case RIL_REQUEST_ECALL_SET_TEST_NUM: return "RIL_REQUEST_ECALL_SET_TEST_NUM";
5361 case RIL_REQUEST_ECALL_SET_RECONF_NUM: return "RIL_REQUEST_ECALL_SET_RECONF_NUM";
5362 case RIL_REQUEST_SYNC_DATA_SETTINGS_TO_MD: return "RIL_REQUEST_SYNC_DATA_SETTINGS_TO_MD";
5363 case RIL_REQUEST_ECALL_SET_NAD_DEREGISTRATION_TIME: return "RIL_REQUEST_ECALL_SET_NAD_DEREGISTRATION_TIME";
5364 case RIL_REQUEST_ECALL_SET_REGISTRATION_STATE: return "RIL_REQUEST_ECALL_SET_REGISTRATION_STATE";
5365#endif /*ECALL_SUPPORT*/
5366#ifdef KEEP_ALIVE
5367 case RIL_REQUEST_START_KEEPALIVE_PRO: return "RIL_REQUEST_START_KEEPALIVE_PRO";
5368 case RIL_REQUEST_STOP_KEEPALIVE_PRO: return "RIL_REQUEST_STOP_KEEPALIVE_PRO";
5369 case RIL_UNSOL_KEEPALIVE_STATUS_PRO: return "RIL_UNSOL_KEEPALIVE_STATUS_PRO";
5370#endif /*KEEP_ALIVE*/
5371 case RIL_REQUEST_SEND_USSI: return "SEND_USSI";
5372 case RIL_REQUEST_CANCEL_USSI: return "CANCEL_USSI";
5373 case RIL_REQUEST_GET_SMS_SIM_MEM_STATUS: return "GET_SMS_SIM_MEM_STATUS";
5374 case RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR: return "RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR";
5375 case RIL_REQUEST_REPORT_AIRPLANE_MODE: return "RIL_REQUEST_REPORT_AIRPLANE_MODE";
5376 case RIL_REQUEST_SET_ECC_NUM: return "RIL_REQUEST_SET_ECC_NUM";
5377 case RIL_REQUEST_GET_ECC_NUM: return "RIL_REQUEST_GET_ECC_NUM";
5378 case RIL_UNSOL_ECC_NUM: return "RIL_UNSOL_ECC_NUM";
5379 case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS_WITH_ACT: return "RIL_REQUEST_QUERY_AVAILABLE_NETWORKS_WITH_ACT";
5380 case RIL_REQUEST_GSM_GET_BROADCAST_LANGUAGE: return "RIL_REQUEST_GSM_GET_BROADCAST_LANGUAGE";
5381 case RIL_REQUEST_GSM_SET_BROADCAST_LANGUAGE: return "RIL_REQUEST_GSM_SET_BROADCAST_LANGUAGE";
5382 case RIL_UNSOL_CALL_INFO_INDICATION: return "RIL_UNSOL_CALL_INFO_INDICATION";
5383 case RIL_REQUEST_MODIFY_APN: return "RIL_REQUEST_MODIFY_APN";
5384 case RIL_REQUEST_RESET_APN: return "RIL_REQUEST_RESET_APN";
5385 case RIL_REQUEST_QUERY_SIM_RETRY_COUNT: return "RIL_REQUEST_QUERY_SIM_RETRY_COUNT";
5386 case RIL_REQUEST_QUERY_EID: return "RIL_REQUEST_QUERY_EID";
5387 case LYNQ_REQUEST_SET_DTMF_VOLUME: return "RIL_REQUEST_SET_DTMF_VOLUME";
q.huangec88da92022-03-29 04:17:32 -04005388 case LYNQ_REQUEST_SET_SPEECH_VOLUME: return "RIL_REQUEST_SET_SPEECH_VOLUME";
5389 case LYNQ_REQUEST_GET_SPEECH_VOLUME: return "RIL_REQUEST_GET_SPEECH_VOLUME";
5390 case LYNQ_REQUEST_RECORD: return "RIL_REQUEST_RECORD";
lhf6eea122022-01-20 19:32:14 -08005391 /*warren add for t800 ril service 2022/1/22 start*/
5392 case LYNQ_REQUEST_WRITE_SMS_TO_MEMORY: return "LYNQ_REQUEST_WRITE_SMS_TO_MEMORY";
5393 case LYNQ_REQUEST_READ_SMS_FROM_MEMORY: return "LYNQ_REQUEST_READ_SMS_FROM_MEMORY";
5394 case LYNQ_REQUEST_DELETE_SMS_FROM_MEMORY: return "LYNQ_REQUEST_DELETE_SMS_FROM_MEMORY";
5395 case LYNQ_REQUEST_LIST_SMS_FROM_MEMORY: return "LYNQ_REQUEST_LIST_SMS_FROM_MEMORY";
rjw5d2a50e2022-02-28 15:01:49 +08005396 case LYNQ_REQUEST_SET_DEFAULT_SIM_ALL:return "SET_DEFAULT_SIM_ALL";
jb.qi96449342022-09-19 22:14:41 -07005397 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 +08005398 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 -08005399 /*warren add for t800 ril service 2022/1/22 end*/
lh7b0674a2022-01-10 00:34:35 -08005400 default: return "<unknown request>";
5401 }
5402}
5403
5404static int sendResponse (Parcel &p, RIL_SOCKET_ID socket_id) {
5405 printResponse;
5406 int type;
5407 if(enable_bt_resp){
5408 SendRespToClient(p.data(), p.dataSize());
5409 }
5410 p.setDataPosition(0);
5411 p.readInt32(&type);
5412 if(type == RESPONSE_UNSOLICITED){
5413 processUnsolicited(p,type);
5414 }else if (type == RESPONSE_SOLICITED){
5415 processSolicited(p,type);
5416 }
5417 return 0;
5418}
5419
5420static void speciaRequest_wait()
5421{
5422 struct timeval now;
5423 struct timespec timeout;
5424
5425 gettimeofday(&now,NULL);
5426 timeout.tv_sec = now.tv_sec+1200; //timeout is 2omin. maybe radio on/off need 10s to complete.
5427 timeout.tv_nsec = now.tv_usec*1000;
5428
5429 SPECIA_BLOCK_LOCK();
5430 while(!(requestOneByOne == 0)) {
5431 int ret = SPECIA_BLOCK_WAIT(&timeout);
5432 if(ret == ETIMEDOUT){
5433 RLOGD("special request wait timeout");
5434 break;
5435 }
5436 }
5437 requestOneByOne = 1;
5438 SPECIA_BLOCK_UNLOCK();
5439}
5440
5441static void speciaRequest_wakeup()
5442{
5443 SPECIA_BLOCK_LOCK();
5444 requestOneByOne = 0;
5445 SPECIA_BLOCK_WAKEUP();
5446 SPECIA_BLOCK_UNLOCK();
5447}
5448
5449static void updateIccCardState(RIL_SOCKET_ID soc_id)
5450{
5451 ARspRequest(RIL_REQUEST_GET_SIM_STATUS, soc_id);
5452}
5453
5454void sendRequestToMd(int request, int id) {
5455 RequestInfo* info = creatRILInfoAndInit(request, INIT, (RIL_SOCKET_ID) ((id)));
5456 switch(request){
5457 case RIL_REQUEST_DEVICE_IDENTITY:
5458 {
5459 getDeviceIdentity(1, NULL, (RIL_SOCKET_ID) ((id)), info);
5460 break;
5461 }
5462 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE:
5463 {
5464 getPreferredNetworkType(1, NULL, (RIL_SOCKET_ID) ((id)), info);
5465 break;
5466 }
5467 case RIL_REQUEST_GET_SIM_STATUS:
5468 {
5469 getIccCardStatus(1, NULL, (RIL_SOCKET_ID) (id), info);
5470 break;
5471 }
5472 case RIL_REQUEST_DATA_REGISTRATION_STATE:
5473 {
5474 getDataRegistrationState(1, NULL, (RIL_SOCKET_ID) (id), info);
5475 break;
5476 }
5477 case RIL_REQUEST_VOICE_REGISTRATION_STATE:
5478 {
5479 getVoiceRegistrationState(1, NULL, (RIL_SOCKET_ID) (id), info);
5480 break;
5481 }
5482 case RIL_REQUEST_VOICE_RADIO_TECH:
5483 {
5484 getVoiceRadioTechnology(1, NULL, (RIL_SOCKET_ID) (id), info);
5485 break;
5486 }
5487 case RIL_REQUEST_OEM_HOOK_RAW:
5488 {
5489 char* tmp[2] = {"RIL_REQUEST_OEM_HOOK_RAW", "AT+ECAL"};
5490 sendATCMD(2, tmp, (RIL_SOCKET_ID) (id), info);
5491 break;
5492 }
5493 case RIL_REQUEST_GET_RADIO_CAPABILITY:
5494 {
5495 getRadioCapability(1, NULL, (RIL_SOCKET_ID) ((id)), info);
5496 break;
5497 }
5498 default:
5499 RLOGE("don't support %d in init", id);
5500 if(info) {
5501 free(info);
5502 }
5503 }
5504}
5505
jb.qi96449342022-09-19 22:14:41 -07005506/**@brief pass the change screen state request to the executing function
5507*@param request type: [IN] requestID
5508*@param slot_id type: [IN] simID
5509*@param argv type: [IN] getScreenState's argv
5510*@author jb.qi
5511*@date 2022/09/19
5512*/
5513void lynq_sendRequestToMd(int request, int slot_id, char **argv, struct sockaddr_in lynqClient_addr, int utoken)
5514{
5515 RequestInfo* info = creatRILInfoAndInit(request, UDP, (RIL_SOCKET_ID) ((slot_id)));
5516 info->uToken = utoken;
5517 info->lynqEvent = 2;
5518 info->uClient_addr.sin_family = lynqClient_addr.sin_family;
5519 info->uClient_addr.sin_addr.s_addr = lynqClient_addr.sin_addr.s_addr;
5520 info->uClient_addr.sin_port = lynqClient_addr.sin_port;
5521 switch(request){
5522 case RIL_REQUEST_SCREEN_STATE:
5523 {
5524 int waittoken = info->token;
5525 RLOGD("getScreenState\n");
5526 getScreenState(2, argv, (RIL_SOCKET_ID) ((slot_id)), info);
5527 waitResponse(waittoken);
5528 break;
5529 }
ll71a113b2022-10-21 18:07:25 +08005530 case RIL_REQUEST_RADIO_POWER:
5531 {
5532 int waittoken = info->token;
5533 RLOGD("LYNQ_REQUEST_CHANGE_RADIO\n");
5534 setRadioPower(2, argv, (RIL_SOCKET_ID) ((slot_id)), info);
5535 waitResponse(waittoken);
5536 break;
5537 }
jb.qi96449342022-09-19 22:14:41 -07005538 default:
5539 RLOGD("dont support %d in init", slot_id);
jb.qi6b23ed42022-09-22 00:30:55 -07005540 if(info)
5541 {
jb.qi96449342022-09-19 22:14:41 -07005542 free(info);
5543 }
5544 }
5545}
5546
lh7b0674a2022-01-10 00:34:35 -08005547static void init(int id) {
5548 int waittoken;
5549 RIL_RadioState radioState = CALL_ONSTATEREQUEST((RIL_SOCKET_ID )id);
5550 while (radioState == RADIO_STATE_UNAVAILABLE) {
5551 sleep(1);
5552 radioState = CALL_ONSTATEREQUEST((RIL_SOCKET_ID )id);
5553 RLOGD("init socket id: %d, %s", id, radioStateToString(radioState));
5554 }
5555 RLOGD("init socket id: %d, %s", id, radioStateToString(radioState));
xja1c30b82022-01-25 16:13:48 +08005556 updataDataConnectState(id, false);
lh7b0674a2022-01-10 00:34:35 -08005557 sendRequestToMd(RIL_REQUEST_GET_SIM_STATUS, id);
5558
5559#if 0
5560 if (radioState != RADIO_STATE_ON) {
5561 RequestInfo* radio = creatRILInfoAndInit(RIL_REQUEST_RADIO_POWER, INIT, (RIL_SOCKET_ID) (id));
5562 waittoken = radio->token;
5563 RLOGD("[%s-%d]:token is %x", __FUNCTION__, __LINE__, radio->token);
5564 char* tmp[2] = { "RIL_REQUEST_RADIO_POWER", "1" };
5565 setRadioPower(2, tmp, (RIL_SOCKET_ID) (id), radio);
5566 waitResponse(waittoken);
5567 sleep(2);
5568 radioState = CALL_ONSTATEREQUEST((RIL_SOCKET_ID )id);
5569 RLOGD("NOW radio status %s", radioStateToString(radioState));
5570 }
5571# endif
5572 sendRequestToMd(RIL_REQUEST_DATA_REGISTRATION_STATE, id);
5573 sendRequestToMd(RIL_REQUEST_VOICE_REGISTRATION_STATE, id);
5574 sendRequestToMd(RIL_REQUEST_VOICE_RADIO_TECH, id);
5575 sendRequestToMd(RIL_REQUEST_DEVICE_IDENTITY,id);
5576 sendRequestToMd(RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE, id);
5577 sendRequestToMd(RIL_REQUEST_OEM_HOOK_RAW, id);
5578 sendRequestToMd(RIL_REQUEST_GET_RADIO_CAPABILITY,id);
5579}
5580
5581static void initCoditions()
5582{
5583 mixer_init();
5584 if(utils::is_support_dsds()) {
5585 for(int i = 0; i < 2 ; i++) {
5586 init(i);
5587 }
5588 }
5589
5590 if(utils::is_suppport_dsss()) {
5591 int id = Phone_utils::get_enable_sim_for_dsss();
5592 init(id);
q.huang036b6cf2023-01-10 14:29:20 +08005593 }
lh7b0674a2022-01-10 00:34:35 -08005594}
5595
5596
5597//For UDP sokcet send response to client
5598static int SendRespToClient(const void *data, size_t dataSize)
5599{
5600 const uint8_t *toWrite;
5601 size_t writeOffset = 0;
5602
5603 toWrite = (const uint8_t *)data;
5604
5605 if (toWrite == NULL) {
5606 //buf is invaild
5607 return -1;
5608 }
5609
5610 while (writeOffset < dataSize) {
5611 ssize_t written;
5612 do {
5613 //written = write (fd, toWrite + writeOffset,dataSize - writeOffset);
5614 written = sendto(server_socket_fd, toWrite + writeOffset, dataSize - writeOffset,
5615 0, (struct sockaddr *)&client_addr, sizeof(client_addr));
5616 } while (written < 0 && ((errno == EINTR) || (errno == EAGAIN)));
5617
5618 if (written >= 0) {
5619 writeOffset += written;
5620 } else { // written < 0
5621 RLOGE ("RIL Response: unexpected error on write errno:%d", errno);
5622 return -1;
5623 }
5624 }
5625
5626 return 0;
5627}
5628
5629static UnsolResponseInfo* find_mtk_unsol_command(int request)
5630{
5631 int i;
5632 for (i = 0; i < (int32_t)NUM_ELEMS(s_mtk_unsolResponses); i++)
5633 if (s_mtk_unsolResponses[i].requestNumber == request)
5634 return (&s_mtk_unsolResponses[i]);
5635 return ((UnsolResponseInfo *)NULL);
5636}
5637
5638static int
5639onSupports (int requestCode)
5640{
5641 switch(requestCode)
5642 {
5643 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return 1;
5644 case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return 1;
5645 case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: return 1;
q.huangcdcdf922022-10-20 13:40:51 +08005646 case RIL_UNSOL_RESPONSE_PS_NETWORK_STATE_CHANGED: return 1;
lh7b0674a2022-01-10 00:34:35 -08005647 case RIL_UNSOL_RESPONSE_NEW_SMS: return 1;
5648 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: return 1;
5649 case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: return 1;
5650 case RIL_UNSOL_ON_USSD: return 1;
5651 case RIL_UNSOL_ON_USSD_REQUEST: return 1;
5652 case RIL_UNSOL_NITZ_TIME_RECEIVED: return 1;
5653 case RIL_UNSOL_SIGNAL_STRENGTH: return 1;
5654 case RIL_UNSOL_DATA_CALL_LIST_CHANGED: return 1;
5655 case RIL_UNSOL_SUPP_SVC_NOTIFICATION: return 1;
5656 case RIL_UNSOL_STK_SESSION_END: return 1;
5657 case RIL_UNSOL_STK_PROACTIVE_COMMAND: return 1;
5658 case RIL_UNSOL_STK_EVENT_NOTIFY: return 1;
5659 case RIL_UNSOL_STK_CALL_SETUP: return 1;
5660 case RIL_UNSOL_SIM_SMS_STORAGE_FULL: return 1;
5661 case RIL_UNSOL_SIM_REFRESH: return 1;
5662 case RIL_UNSOL_CALL_RING: return 1;
5663 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: return 1;
5664 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: return 1;
5665 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: return 1;
5666 case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: return 0;
5667 case RIL_UNSOL_RESTRICTED_STATE_CHANGED: return 1;
5668 case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: return 1;
5669 case RIL_UNSOL_CDMA_CALL_WAITING: return 1;
5670 case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: return 0;
5671 case RIL_UNSOL_CDMA_INFO_REC: return 0;
5672 case RIL_UNSOL_OEM_HOOK_RAW: return 1;
5673 case RIL_UNSOL_RINGBACK_TONE: return 1;
5674 case RIL_UNSOL_RESEND_INCALL_MUTE: return 0;
5675 case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: return 0;
5676 case RIL_UNSOL_CDMA_PRL_CHANGED: return 0;
5677 case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: return 1;
5678 case RIL_UNSOL_RIL_CONNECTED: return 1;
5679 case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED: return 1;
5680 case RIL_UNSOL_CELL_INFO_LIST: return 1;
5681 case RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED: return 1;
5682 case RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED: return 1;
5683 case RIL_UNSOL_SRVCC_STATE_NOTIFY: return 1;
5684 case RIL_UNSOL_HARDWARE_CONFIG_CHANGED: return 0;
5685 case RIL_UNSOL_DC_RT_INFO_CHANGED: return 0;
5686 case RIL_UNSOL_RADIO_CAPABILITY : return 1;
5687 case RIL_UNSOL_MAL_RESTART : return 1;
5688 case RIL_UNSOL_CALL_INFO_INDICATION : return 1;
5689 case RIL_UNSOL_CRSS_NOTIFICATION : return 0;
5690 case RIL_UNSOL_ECONF_SRVCC_INDICATION : return 1;
5691 case RIL_UNSOL_ECONF_RESULT_INDICATION : return 1;
5692 case RIL_UNSOL_STK_BIP_PROACTIVE_COMMAND : return 0;
5693 case RIL_UNSOL_MAL_AT_INFO: return 1;
5694 case RIL_UNSOL_ECALL_MSDHACK: return 1;
5695 case RIL_UNSOL_TX_POWER: return 1;
5696 case RIL_UNSOL_NETWORK_INFO: return 1;
5697#ifdef ECALL_SUPPORT
5698 case RIL_UNSOL_ECALL_INDICATIONS: return 1;
5699#endif /*ECALL_SUPPORT*/
5700#ifdef KEEP_ALIVE
5701 case RIL_UNSOL_KEEPALIVE_STATUS_PRO: return 1;
5702#endif /*KEEP_ALIVE*/
5703 case RIL_UNSOL_ON_USSI: return 1;
5704 case RIL_UNSOL_ECC_NUM: return 1;
5705 case RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR: return 1;
5706 default: return 0;
5707 }
5708}
5709
5710int parse_param(char *cmd, char *argv[], int max_args)
5711{
5712 char *pos, *pos2;
5713 int argc = 0;
5714 printf("warren test cmd=%s\n",cmd);
5715 pos = cmd;
5716 while (1) {
5717 // Trim the space characters.
5718 while (*pos == ' ') {
5719 pos++;
5720 }
5721
5722 if (*pos == '\0') {
5723 break;
5724 }
5725
5726 // One token may start with '"' or other characters.
5727 if (*pos == '"' && (pos2 = strrchr(pos+1, '"'))) {
5728 argv[argc++] = pos + 1;
5729 *pos2 = '\0';
5730 pos = pos2 + 1;
5731 if(*pos == '\n'){
5732 *pos = '\0';
5733 pos = pos + 1;
5734 }
5735
5736 } else {
5737 argv[argc++] = pos;
5738 while (*pos != '\0' && *pos != ' '&& *pos != '\n') {
5739 pos++;
5740 }
5741 *pos++ = '\0';
5742
5743 if(argc == 1) {
5744 char* at_cmd = strstr(argv[0], "RIL_REQUEST_OEM_HOOK_RAW");
5745 if(at_cmd != NULL) {
5746 while (*pos == ' ') {
5747 pos++;
5748 }
5749 argv[argc++] = pos;
5750 while (*pos != '\0' && *pos != '\n') {
5751 pos++;
5752 }
5753 *pos++ = '\0';
5754 break;
5755 }
5756 }
5757
5758 }
5759
5760 // Check if the maximum of arguments is reached.
5761 if (argc == max_args) {
5762 break;
5763 }
5764 }
5765
5766 return argc;
5767}
5768
5769/* Look up NAME as the name of a command, and return a pointer to that
5770 command. Return a NULL pointer if NAME isn't a command name. */
5771COMMAND* find_command (char *name)
5772{
5773 register int i;
5774
5775 for (i = 0; commands[i].name; i++)
5776 if (strcmp (name, commands[i].name) == 0)
5777 return (&commands[i]);
5778
5779 return ((COMMAND *)NULL);
5780}
5781
5782CommandInfo* find_mtk_command (int request)
5783{
5784 int i;
5785 for (i = 0; i < (int32_t)NUM_ELEMS(mtk_s_command); i++)
5786 if (mtk_s_command[i].requestNumber == request)
5787 return (&mtk_s_command[i]);
5788 return ((CommandInfo *)NULL);
5789}
5790
5791/* The user wishes to quit using this program. Just set DONE non-zero. */
5792static int com_quit (int argc, char *argv[], RIL_SOCKET_ID socket_id, RequestInfo *pRI)
5793{
5794 exit(EXIT_SUCCESS);
5795 return (0);
5796}
5797
5798static int enableSyslog(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
5799{
5800 if(argc < 2)
5801 {
5802 RLOGE("[Error] enable syslog paramter is error\n");
5803 free(pRI);
5804 return -1;
5805 }
5806 enable_syslog = atoi(argv[1]);
5807 RLOGE("%s syslog\n",enable_syslog ? "enable" :"disable");
5808 free(pRI);
5809 return 0;
5810}
5811
5812static int enableBTResponse(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
5813{
5814 if(argc < 2)
5815 {
5816 RLOGE("[Error] enable BT response paramter is error\n");
5817 free(pRI);
5818 return -1;
5819 }
5820 enable_bt_resp = atoi(argv[1]);
5821 RLOGE("%s bt response!\n",enable_bt_resp ? "enable" :"disable");
5822 free(pRI);
5823 return 0;
5824
5825}
5826
5827char Time_buf[24];
5828void GetTimeString(char * buf)
5829{
5830 time_t timep;
5831 struct tm p;
5832
5833 if(buf == NULL){
5834 RLOGE("[Error] GetTimeString: buf is Null\n");
5835 return;
5836 }
5837 //memset(buf,0,sizeof(buf));
5838 time(&timep);
5839 localtime_r(&timep,&p);
5840 sprintf(buf,"%d_%d_%d %d:%d:%d",(1900+p.tm_year),(1+p.tm_mon),p.tm_mday,
5841 (p.tm_hour),p.tm_min,p.tm_sec);
5842// printf("data is %s\n",buf);
5843
5844 return;
5845}
5846/*Warren add for t800 RIL Service 2021/12/10 start*/
q.huangadbad2f2022-09-15 16:28:02 +08005847int lynqAssemblyParcelheader(Parcel &p,int slot,int utoken, int request,int respType,int error)
lh7b0674a2022-01-10 00:34:35 -08005848{
5849 p.writeInt32 (respType);
q.huangadbad2f2022-09-15 16:28:02 +08005850 p.writeInt32 (utoken);
lh7b0674a2022-01-10 00:34:35 -08005851 p.writeInt32 (request);
5852 /*warren add for t800 ril servie 2021/12/15 start*/
5853 p.writeInt32(slot);
5854 /*warren add for t800 ril servie 2021/12/15 end*/
5855 p.writeInt32 (error);
5856 return 0;
5857}
5858void LYNQ_RIL_urcClientInit()
5859{
5860 int len = 0;
5861 int on=1;
5862 int ret = 0;
5863 lynq_urc_socket_fd = socket(AF_INET,SOCK_DGRAM,0);
5864 if(lynq_urc_socket_fd < 0)
5865 {
5866 perror("creaet socket for udp fail");
5867 return;
5868 }
5869 /* 设置socket允许重复使用地址与端口,SO_REUSEADDR值为2 */
5870 //setsockopt(socket_fd,SOL_SOCKET,SO_REUSEADDR,&on,sizeof on);
5871 /* 使能广播功能,SO_BROADCAST值为6 */
5872 ret= setsockopt(lynq_urc_socket_fd,SOL_SOCKET,SO_BROADCAST,&on,sizeof(on));
5873 if(ret<0)
5874 {
5875 RLOGD("set broadcast fail!!!\n");
5876 exit(1);
5877 }
5878 urc_broadcast_addr.sin_family = AF_INET; //IPv4
5879 urc_broadcast_addr.sin_port = htons(LYNQ_BRODCAST_PORT);
5880 urc_broadcast_addr.sin_addr.s_addr = inet_addr("255.255.255.255" );//255.255.255.255 broadcast addrress.
5881 printf("LYNQ_RIL_urcClientInit success!!!\n");
5882 return;
5883 /*
5884 while(1)
5885 {
5886 len = sendto(lynq_urc_socket_fd,"hello world",11,0,(struct sockaddr *)&urc_broadcast_addr,sizeof(urc_broadcast_addr));
5887 if(len > 0)
5888 {
5889 printf("sendto success,len=%d\n",len);
5890 }
5891 else
5892 {
5893 printf("sendto fail\n");
5894 }
5895 sleep(1);
5896 }
5897 */
5898}
q.huang5bbadde2023-02-09 16:50:52 +08005899
5900//add by hq for bug 760 2023/02/09
5901static int setnonblocking(int sockfd) {
5902 int flag = fcntl(sockfd, F_GETFL, 0); //get current flag
5903 if (flag < 0) {
5904 RLOGE("fcntl F_GETFL fail");
5905 return -1;
5906 }
5907 if (fcntl(sockfd, F_SETFL, flag | O_NONBLOCK) < 0) { //add O_NONBLOCK
5908 RLOGE("fcntl F_SETFL fail");
5909 return -1;
5910 }
5911 return 0;
5912}
5913
lh7b0674a2022-01-10 00:34:35 -08005914void LYNQ_RIL_RecSocket()
5915{
5916 RLOGD("LYNQ_RIL_RecSocket start\n");
5917 char *argv[MAX_ARGS];
5918 int argc = 0;
5919 int ep_fd = 0;
5920 int en_fd = 0;
5921 struct epoll_event lynq_ev;
5922 struct epoll_event lynq_events[LYNQ_SOCKET_ENVNT_FD_MAX];
5923 //prctl(PR_SET_NAME,(unsigned long)"UDP_Thr");
5924
5925 /*listen UPD SOCKET port */
5926 struct sockaddr_in server_addr;
5927 struct sockaddr_in lynqClient_addr;
5928 bzero(&server_addr, sizeof(server_addr));
5929 server_addr.sin_family = AF_INET;
5930 server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
5931 server_addr.sin_port = htons(LYNQ_SERVICE_PORT);
5932 /* create socket */
5933 //int server_socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
5934 server_socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
5935 if(server_socket_fd == -1)
5936 {
5937 RLOGE("Create Socket Failed:");
5938 exit(1);
5939 }
5940
5941 /* bind socket port*/
5942 if(-1 == (bind(server_socket_fd,(struct sockaddr*)&server_addr,sizeof(server_addr))))
5943 {
5944 RLOGE("Server Bind Failed:");
5945 exit(1);
5946 }
q.huang5bbadde2023-02-09 16:50:52 +08005947
5948 if(setnonblocking(server_socket_fd)!=0)
5949 {
5950 RLOGE("setnonblocking Failed");
5951 exit(1);
5952 }
5953
lh7b0674a2022-01-10 00:34:35 -08005954 /* create epoll fd,add socket to epoll */
5955 ep_fd = epoll_create(LYNQ_SOCKET_ENVNT_FD_MAX);
5956 //int len = sizeof(struct sockaddr_in);
5957 lynq_ev.events = EPOLLIN | EPOLLET;
5958 lynq_ev.data.fd = server_socket_fd;
5959 if(epoll_ctl(ep_fd, EPOLL_CTL_ADD, server_socket_fd, &lynq_ev) < 0)
5960 {
5961 fprintf(stderr, "epoll set insertion error: fd=%d\n", server_socket_fd);
5962 return;
5963 }
5964 else
5965 {
5966 printf("monitor socket add epoll success!!!\n");
5967 }
5968 char buffer[LYNQ_SOCKET_BUFFER];
5969 lynq_client_t *client_tmp = NULL;
5970 /* tranlate data */
5971 while(true)
5972 {
5973 if(!s_registerCalled)
5974 {
5975 sleep(1);
5976 continue;
5977 }
5978 en_fd = epoll_wait(ep_fd, lynq_events, 10000, -1);//###Check valid
5979 if(en_fd <=0 )
5980 {
5981 continue;
5982 }
5983 for (int n = 0; n < en_fd; ++n)
5984 {
5985 if (lynq_events[n].data.fd == server_socket_fd)
5986 {
5987 /* define address to catch the client addreess*/
5988 //struct sockaddr_in client_addr;
5989 socklen_t client_addr_length = sizeof(lynqClient_addr);
5990 /* receive the data */
5991 bzero(buffer, LYNQ_SOCKET_BUFFER);
q.huang5bbadde2023-02-09 16:50:52 +08005992 while(recvfrom(server_socket_fd, buffer, LYNQ_SOCKET_BUFFER,0,(struct sockaddr*)&lynqClient_addr, &client_addr_length) != -1)//add while by hq for bug 760 2023/02/09
lh7b0674a2022-01-10 00:34:35 -08005993 {
q.huang5bbadde2023-02-09 16:50:52 +08005994 client_tmp = (lynq_client_t*)buffer;
5995 RLOGD("[LYNQ socketId] utoken=%d,request=%d,len=%d,param=%s",client_tmp->uToken,client_tmp->request,client_tmp->paramLen,client_tmp->param);
5996 //char test[36] = {};
5997 //sprintf(test,"test okay len = %d",client_tmp->paramLen);
5998 //sendto(server_socket_fd,test,strlen(test),0,(struct sockaddr*)&client_addr,client_addr_length);
5999 argv[0] = (char *)lynq_requset_to_string(client_tmp->request);
6000 argc = 0;
6001 if(client_tmp->paramLen > 0)
lh7b0674a2022-01-10 00:34:35 -08006002 {
q.huang5bbadde2023-02-09 16:50:52 +08006003 /*transfer struct*/
6004 argc = parse_param(client_tmp->param, argv+1, MAX_ARGS);
6005 if(argc < 1)
6006 {
6007 RLOGE("%s: error input.", buffer);
6008 continue;
6009 }
6010 }
6011 printf("argc =%d\n",argc);
6012 argc = argc+1;
6013 for(int t = 0;t<argc;t++)
6014 {
6015 RLOGD("warren test argv[%d]=%s\n",t,argv[t]);
6016 }
6017 COMMAND *command = find_command(argv[0]);
6018 if(!command)
6019 {
6020 RLOGE("%s: No such command for DemoApp", argv[0]);
lh7b0674a2022-01-10 00:34:35 -08006021 continue;
6022 }
q.huang5bbadde2023-02-09 16:50:52 +08006023 int32_t request;
6024 request = command->request;
6025 RIL_SOCKET_ID id = RIL_SOCKET_1;
6026 if(utils::is_support_dsds()) {
6027 id = (RIL_SOCKET_ID)get_default_sim_all_except_data();
6028 } else if(utils::is_suppport_dsss()) {
6029 id = (RIL_SOCKET_ID)Phone_utils::get_enable_sim_for_dsss();
ll71a113b2022-10-21 18:07:25 +08006030 }
q.huang5bbadde2023-02-09 16:50:52 +08006031 if(request == -1)
ll71a113b2022-10-21 18:07:25 +08006032 {
q.huang5bbadde2023-02-09 16:50:52 +08006033 (*(command->func)) (argc, argv, id, NULL);
6034 continue;
jb.qi96449342022-09-19 22:14:41 -07006035 }
q.huang5bbadde2023-02-09 16:50:52 +08006036 if (request < 1 || (request >= (int32_t)NUM_ELEMS(s_commands) && request < RIL_REQUEST_VENDOR_BASE)) {
6037 RLOGW("unsupported request code %d token %d", request);
6038 // FIXME this should perhaps return a response
6039 continue;
6040 }
6041 /*jb.qi add for two sim suspend 2022/9/19 start lei modify for factory test of sleep*/
6042 if(request == LYNQ_REQUEST_CHANGE_SCREEN_STATE || request == LYNQ_REQUEST_CHANGE_RADIO)
6043 {
6044 int i;
6045 RLOGD("lynq_request_change_screen_state");
6046 if(request == LYNQ_REQUEST_CHANGE_SCREEN_STATE)
6047 {
6048 for(i=0;i<2;i++) //suspend sim0 and sim1
6049 {
6050 lynq_sendRequestToMd(RIL_REQUEST_SCREEN_STATE, i, argv, lynqClient_addr, client_tmp->uToken);
6051 }
6052 }
6053 /*lei modify for factory test of sleep*/
6054 if(request == LYNQ_REQUEST_CHANGE_RADIO)
6055 {
6056 for(i=0;i<2;i++) //both radio on/off
6057 {
6058 lynq_sendRequestToMd(RIL_REQUEST_RADIO_POWER, i, argv, lynqClient_addr, client_tmp->uToken);
6059 }
6060 }
6061 continue;
6062 }
6063 /*jb.qi add for two sim suspend 2022/9/19 end*/
6064 RLOGD("REQUEST: %s ParamterNum:%d", requestToString(request), argc);
6065 RequestInfo *pRI = creatRILInfoAndInit(request, UDP, (RIL_SOCKET_ID)(id));
6066 pRI->uToken = client_tmp->uToken;
6067 pRI->lynqEvent = 2;
6068 pRI->uClient_addr.sin_family = lynqClient_addr.sin_family;
6069 pRI->uClient_addr.sin_addr.s_addr = lynqClient_addr.sin_addr.s_addr;
6070 pRI->uClient_addr.sin_port = lynqClient_addr.sin_port;
6071 //sendto(server_socket_fd,test,strlen(test),0,(struct sockaddr*)&pRI->uClient_addr,client_addr_length);
6072 //pRI->uClient_addr.sa_family = (struct sockaddr)client_addr.sa_family;
6073 //memcpy(pRI->uClient_addr.sa_data,&client_addr
6074 //Radio on/off only allow one thread operate.
6075 if(request == RIL_REQUEST_RADIO_POWER)
6076 {
6077 speciaRequest_wait();
6078 }
6079 #ifdef ECALL_SUPPORT
6080 else if(request == RIL_REQUEST_ECALL_FAST_MAKE_ECALL)
6081 {
6082 init_redial_flag();
6083 }
6084 #endif
6085 memset(Time_buf,0,sizeof(Time_buf));
6086 GetTimeString(Time_buf);
6087 //FUNCTION_CALLED(Time_buf,requestToString(request));
6088 int waittoken = pRI->token;
6089 (*(command->func)) (argc, argv, pRI->socket_id, pRI);
6090 FUNCTION_CALLED(Time_buf,requestToString(request));
6091 waitResponse(waittoken);
6092 memset(Time_buf,0,sizeof(Time_buf));
6093 GetTimeString(Time_buf);
6094 FUNCTION_RETURN(Time_buf,requestToString(request));
6095 bzero(buffer, LYNQ_SOCKET_BUFFER);
6096
jb.qi96449342022-09-19 22:14:41 -07006097 }
q.huang5bbadde2023-02-09 16:50:52 +08006098 RLOGE("process Receive Data end");
6099 // continue;
lh7b0674a2022-01-10 00:34:35 -08006100 }
6101 }
6102 }
6103 RLOGD("close socket fd");
6104 close(server_socket_fd);
6105 return ;
6106}
6107int LYNQ_RIL_respSocket(Parcel &p,RIL_Token t)
6108{
6109 RLOGD("LYNQ_RIL_respSocket send start");
lh7b0674a2022-01-10 00:34:35 -08006110 ssize_t sent = 0;
lh7b0674a2022-01-10 00:34:35 -08006111 RequestInfo *pRI = (RequestInfo *)t;
ll90a255c2022-04-07 09:09:55 +00006112 if(pRI->lynqEvent!=2)
lh7b0674a2022-01-10 00:34:35 -08006113 {
6114 RLOGD("this is internal event!!!");
6115 return -1;
6116 }
6117 int dataSize = p.dataSize();
6118 const uint8_t* data = p.data();
6119 RLOGD("lynqSocketSend RESPONSE!!!! ");
lh7b0674a2022-01-10 00:34:35 -08006120 sent = sendto(server_socket_fd, data, dataSize, 0, (struct sockaddr *)&pRI->uClient_addr, sizeof(pRI->uClient_addr));
6121 if( sent < 0 )
6122 {
6123 RLOGE("lynqSocketSend send datalen fail (sent=%d, sendFD=%d, dataSize=%d)",
6124 sent,server_socket_fd, dataSize);
lh7b0674a2022-01-10 00:34:35 -08006125 return -1;
6126 }
6127 return 0;
6128}
6129int LYNQ_RIL_respSocket_sp(Parcel &p,RequestInfo *pRI)
6130{
6131 RLOGD("LYNQ_RIL_respSocket send start");
6132 int ret =0;
6133 bool sendResult =false;
6134 ssize_t sent = 0;
6135 uint8_t dataLength[4];
6136 int verify = 0x55aa;
6137 int dataSize = p.dataSize();
6138 const uint8_t* data = p.data();
ll90a255c2022-04-07 09:09:55 +00006139 if(pRI->lynqEvent!=2)
lh7b0674a2022-01-10 00:34:35 -08006140 {
6141 RLOGD("this is internal event!!!");
6142 return -1;
6143 }
6144 RLOGD("lynqSocketSend RESPONSE!!!! ");
lh7b0674a2022-01-10 00:34:35 -08006145
6146 sent = sendto(server_socket_fd, data, dataSize, 0, (struct sockaddr *)&pRI->uClient_addr, sizeof(pRI->uClient_addr));
6147 if( sent < 0 )
6148 {
6149 RLOGE("lynqSocketSend send datalen fail (sent=%d, sendFD=%d, dataSize=%d)",
6150 sent,server_socket_fd, dataSize);
lh7b0674a2022-01-10 00:34:35 -08006151 return -1;
6152 }
6153 return 0;
6154}
6155
q.huang036b6cf2023-01-10 14:29:20 +08006156bool is_need_use_shm(int dataSize, int urc_id)
6157{
6158 switch(urc_id)
6159 {
6160 /*network*/
6161 case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED:
6162 case RIL_UNSOL_RESPONSE_PS_NETWORK_STATE_CHANGED:
6163 case RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED:
6164 case RIL_UNSOL_SIGNAL_STRENGTH:
llcce1a812023-01-19 15:49:25 +08006165 /*sms*/
6166 case RIL_UNSOL_RESPONSE_NEW_SMS:
6167 /*sim*/
6168 //case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: Not supported at present
q.huang036b6cf2023-01-10 14:29:20 +08006169 /*call*/
6170 case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED:
6171 case RIL_UNSOL_CALL_RING:
6172 case RIL_UNSOL_RINGBACK_TONE:
6173 case RIL_UNSOL_CALL_INFO_INDICATION:
6174#ifdef ECALL_SUPPORT
6175 case RIL_UNSOL_ECALL_INDICATIONS://9502
rjw7ee7bb42023-01-18 11:34:28 +08006176#endif
6177 /*Data*/
6178 case LYNQ_URC_DATA_CALL_STATUS_IND:
6179 case LYNQ_URC_MODIFY_APNDB:
6180 case LYNQ_URC_RESET_APNDB:
q.huang036b6cf2023-01-10 14:29:20 +08006181 break;
6182 default:
6183 return false;
6184 }
6185 if(dataSize>urc_broadcase_shm_size_limit && dataSize <= get_max_shem_buffer_size())
6186 {
6187 return true;
6188 }
6189 return false;
6190}
6191
6192int LYNQ_RIL_urcBroadcast(Parcel &p, int urc_id)
lh7b0674a2022-01-10 00:34:35 -08006193{
6194 RLOGD("LYNQ_RIL_urcBroadcast send start");
q.huang036b6cf2023-01-10 14:29:20 +08006195 int ret =0;
6196 ssize_t sent = 0;
6197 p.setDataPosition(0);
lh7b0674a2022-01-10 00:34:35 -08006198 int dataSize = p.dataSize();
6199 const uint8_t* data = p.data();
q.huang036b6cf2023-01-10 14:29:20 +08006200 RLOGD("LYNQ_RIL_urcBroadcast urc_id is %d, dataSize=%d, msg is %s", urc_id, dataSize, requestToString(urc_id));
6201 if(is_need_use_shm(dataSize,urc_id))
6202 {
6203 int index,level;
6204 if(get_cur_shem_buffer_index(dataSize,&level,&index))
6205 {
6206 char* p_shm_buffer=get_shem_buffer(level,index);
6207 memcpy(p_shm_buffer,data,dataSize);
6208 uint32_t* pFirstInt = (uint32_t*) const_cast<uint8_t*> (data);
6209 *pFirstInt=*pFirstInt+((index+1)<<SHM_BUFFER_INDEX_OFFSET)+((dataSize)<<SHM_BUFFER_SIZE_OFFSET);
6210 dataSize=sizeof(int32_t)*2;
6211 RLOGD("LYNQ_RIL_urcBroadcast use share mem level is %d, index is %d",level,index);
6212 }
6213 }
lh7b0674a2022-01-10 00:34:35 -08006214 sent = sendto(lynq_urc_socket_fd, data, dataSize, 0, (struct sockaddr *)&urc_broadcast_addr, sizeof(urc_broadcast_addr));
6215 if( sent < 0 )
6216 {
6217 RLOGE("LYNQ_RIL_urcBroadcast send datalen fail (sent=%d, sendFD=%d, dataSize=%d)",
6218 sent,lynq_urc_socket_fd, dataSize);
6219 return -1;
6220 }
q.huang036b6cf2023-01-10 14:29:20 +08006221
lh7b0674a2022-01-10 00:34:35 -08006222 return 0;
6223}
6224/*Warren add for t800 RIL Service 2021/12/10 end*/
6225
6226void
6227RIL_StartRevSocket()
6228{
6229 RLOGD("RIL_StartRevSocket start\n");
xja1c30b82022-01-25 16:13:48 +08006230 char *argv[MAX_ARGS] = {0};
lh7b0674a2022-01-10 00:34:35 -08006231 int argc = 0;
6232
6233 prctl(PR_SET_NAME,(unsigned long)"UDP_Thr");
6234
6235 /*listen UPD SOCKET port */
6236 struct sockaddr_in server_addr;
6237 bzero(&server_addr, sizeof(server_addr));
6238 server_addr.sin_family = AF_INET;
6239 server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
6240 server_addr.sin_port = htons(SERVER_PORT);
6241 /* create socket */
6242 //int server_socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
6243 server_socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
6244 if(server_socket_fd == -1)
6245 {
6246 RLOGE("Create Socket Failed:");
6247 exit(1);
6248 }
6249
6250 /* bind socket port*/
6251 if(-1 == (bind(server_socket_fd,(struct sockaddr*)&server_addr,sizeof(server_addr))))
6252 {
6253 RLOGE("Server Bind Failed:");
6254 exit(1);
6255 }
6256
6257 /* tranlate data */
6258 while(true)
6259 {
6260 if(!s_registerCalled)
6261 {
6262 sleep(1);
6263 continue;
6264 }
6265 /* define address to catch the client addreess*/
6266 //struct sockaddr_in client_addr;
6267 socklen_t client_addr_length = sizeof(client_addr);
6268
6269 /* receive the data */
6270 char buffer[BUFFER_SIZE];
6271 bzero(buffer, BUFFER_SIZE);
6272 if(recvfrom(server_socket_fd, buffer, BUFFER_SIZE,0,(struct sockaddr*)&client_addr, &client_addr_length) == -1)
6273 {
6274 RLOGE("Receive Data Failed:");
6275 continue;
6276 }
6277 RLOGD("DemoAPP:%s, receve: %s", inet_ntoa(client_addr.sin_addr), buffer);
6278 if(mtkItTest(buffer)) {
6279 RLOGD("mtkItTest() handle.");
6280 continue;
6281 }
6282 int argc = parse_param(buffer, argv, MAX_ARGS);
6283 if(argc < 1)
6284 {
6285 RLOGE("%s: error input.", buffer);
6286 continue;
6287 }
6288 COMMAND *command = find_command(argv[0]);
6289 if(!command)
6290 {
6291 RLOGE("%s: No such command for DemoApp", argv[0]);
6292 continue;
6293 }
6294
6295 int32_t request;
6296
6297 request = command->request;
6298
6299 RIL_SOCKET_ID id = RIL_SOCKET_1;
6300 if(utils::is_support_dsds()) {
6301 id = (RIL_SOCKET_ID)get_default_sim_all_except_data();
6302 } else if(utils::is_suppport_dsss()) {
6303 id = (RIL_SOCKET_ID)Phone_utils::get_enable_sim_for_dsss();
6304 }
lh7b0674a2022-01-10 00:34:35 -08006305 if(request == -1)
6306 {
6307 (*(command->func)) (argc, argv, id, NULL);
6308 continue;
6309 }
6310
6311 if (request < 1 || (request >= (int32_t)NUM_ELEMS(s_commands) && request < RIL_REQUEST_VENDOR_BASE)) {
6312 RLOGW("unsupported request code %d token %d", request);
6313 // FIXME this should perhaps return a response
6314 continue;
6315 }
6316
6317 RLOGD("REQUEST: %s ParamterNum:%d", requestToString(request), argc);
6318
6319
6320 RequestInfo *pRI = creatRILInfoAndInit(request, UDP, (RIL_SOCKET_ID)(id));
6321 //Radio on/off only allow one thread operate.
6322 if(request == RIL_REQUEST_RADIO_POWER)
6323 {
6324 speciaRequest_wait();
6325 }
6326 memset(Time_buf,0,sizeof(Time_buf));
6327 GetTimeString(Time_buf);
6328 //FUNCTION_CALLED(Time_buf,requestToString(request));
6329 int waittoken = pRI->token;
6330 (*(command->func)) (argc, argv, pRI->socket_id, pRI);
6331 FUNCTION_CALLED(Time_buf,requestToString(request));
6332 waitResponse(waittoken);
6333 memset(Time_buf,0,sizeof(Time_buf));
6334 GetTimeString(Time_buf);
6335 FUNCTION_RETURN(Time_buf,requestToString(request));
6336 }
6337
6338 RLOGD("close socket fd");
6339 close(server_socket_fd);
6340 return ;
6341}
6342
6343const int waitResponse(int token)
6344{
6345 int waitToken = token;
6346 struct timeval now;
6347 struct timespec timeout;
6348 if((token&BLOCK_MARK) != BLOCK_MARK){
6349 RLOGD("No need wait!,token is %x!",token);
6350 return 0;
6351 }
6352
6353 gettimeofday(&now,NULL);
6354 timeout.tv_sec = now.tv_sec+60; //timeout is 1min
6355 timeout.tv_nsec = now.tv_usec*1000;
6356
6357 RLOGD("Block Request, wait token is %x,",waitToken);
6358 BLOCK_LOCK();
6359 if(waitToken == wakeup_token)
6360 RLOGD("response early than return, wait token is %x, wakeup token is %x",waitToken, wakeup_token);
6361 while(!(waitToken == wakeup_token)) {
6362 RLOGD("Wait Response, wait token is %x, wakeup token is %x",waitToken, wakeup_token);
6363 int ret = BLOCK_WAIT(&timeout);
6364 if(ret == ETIMEDOUT){
6365 RLOGD("Wait Response timeout, wait token is %x, wakeup token is %x",waitToken, wakeup_token);
6366 goto out;
6367 }
6368 }
6369 RLOGD("Response wakeup,token is %x!",wakeup_token);
6370 wakeup_token = -1;
6371out:
6372 BLOCK_UNLOCK();
6373 return 0;
6374}
6375
lld164b022022-03-29 14:01:01 +08006376/**
6377 * @brief check at input in at_buffer
6378 * @param buf type:in at port input
6379 * @return int
6380 */
6381static int lynq_inside_at_buffer(char *buf)
6382{
6383 for(int i = 0; i < MAX_AT_CMD; i++)
6384 {
6385 if(at_buf_ext[i] == NULL)
6386 {
6387 break;
6388 }
6389 else
6390 {
llf4be54d2022-04-18 08:08:38 +00006391 if(strstr(buf, at_buf_ext[i]))
lld164b022022-03-29 14:01:01 +08006392 {
6393 return 1;
6394 }
6395 }
6396 }
6397 return 0;
6398}
6399
6400/**
6401 * @brief send input to client
6402 * @param buffer type:in buffer from at port
6403 * @param len_buf type:in strlen(buffer)
6404 * @param client type:in sockaddr client
6405 * @return int
6406 */
6407static int lynq_send_info(char *buffer, int len_buf, struct sockaddr* client)
6408{
6409 socklen_t len = sizeof(*client);
6410 int sent = sendto(sockfd,buffer,len_buf,0,client,len);
6411 if( sent < 0 )
6412 {
6413 RLOGE("lynq_send_info send fail (sent=%d, sendFD=%d, dataSize=%d)",
6414 sent,sockfd, len);
6415 return sent;
6416 }
6417 return 0;
6418}
6419
6420/**
6421 * @brief Fetch data from a one-dimensional array into a two-dimensional array
6422 *
6423 * @param cmd type:in buffer from client
6424 * @param argv type:in two-dimensional array
6425 * @param cnt type:in Two dimensional array subscript
6426 * @return int
6427 */
6428static int lynq_parse_at_cmd(char *cmd, char *argv[], int cnt)
6429{
6430 if(NULL == cmd || NULL == argv)
6431 {
6432 return -1;
6433 }
6434 if(cnt > MAX_AT_CMD)
6435 {
6436 return -1;
6437 }
6438 const char s[2] = ";";
6439 char *token;
6440 int argc = cnt;
6441 token = strtok(cmd, s);
6442 while( token != NULL ) {
6443 argv[argc++] = token;
6444 token = strtok(NULL, s);
6445 }
6446 return 0;
6447}
6448
6449/**
6450 * @brief count at cmd amount
6451 *
6452 * @param type:in buffer
6453 * @return int
6454 */
6455static int lynq_count_at(char *buffer)
6456{
6457 char *p = buffer;
6458 int count = 0;
6459 while(*p != '\0')
6460 {
6461 if(*p == ';')
6462 {
6463 count++;
6464 }
6465 *p++;
6466 }
6467 return count+1;
6468}
6469
6470/**
6471 * @brief receive registion and display on at port
6472 * @param parm type:in
6473 * @return void*
6474 */
6475void *receive_at(void *parm)
6476{
6477 RLOGE("receive_at thread start\n");
6478 struct sockaddr* cli = (struct sockaddr*)parm;
6479 socklen_t len;
6480 int recv = 0;
6481 char display[1024] = {0};
6482 /*For at extension to receive at buffer*/
llacba3662022-04-15 16:57:13 +08006483 bool flag = false;
lld164b022022-03-29 14:01:01 +08006484 int count_at_cmd = 0;
6485 len = sizeof(*cli);
6486 while(1)
6487 {
llacba3662022-04-15 16:57:13 +08006488 if(!flag)
lld164b022022-03-29 14:01:01 +08006489 {
6490 RLOGE("receive third at cmd\n");
6491 recv = recvfrom(sockfd, buffer_at, LYNQ_AT_SOCKET_BUFFER, 0, cli, &len);
6492 if(recv < 0)
6493 {
6494 RLOGE("recv fail\n");
6495 continue;
6496 }
6497 RLOGE("recvfrom from client\n");
6498 /*parse buffer for at command*/
6499 count_at_cmd = lynq_count_at(buffer_at);
6500 if(count_at_cmd > MAX_AT_CMD)
6501 {
6502 RLOGE("too many at cmd\n");
6503 continue;;
6504 }
6505 lynq_parse_at_cmd(buffer_at, at_buf_ext, 0);
llacba3662022-04-15 16:57:13 +08006506 flag = true;
lld164b022022-03-29 14:01:01 +08006507 }
6508 else
6509 {
6510 RLOGE("display output on at port\n");
6511 bzero(display, 1024);
6512 recv = recvfrom(sockfd, display, LYNQ_AT_SOCKET_BUFFER, 0, cli, &len);
6513 if(recv < 0)
6514 {
6515 RLOGE("recv fail\n");
6516 continue;
6517 }
6518 /*display on at port*/
6519 else
6520 {
6521 strcat(display, "\n");
6522 int n = write(ttyGS3_fd,display,strlen(display));
6523 if(n<0)
6524 {
6525 RLOGE("lynq resp write error");
6526 }
6527 }
6528 }
lld164b022022-03-29 14:01:01 +08006529 }
6530 return NULL;
6531}
6532
ll2f3fea22022-09-29 17:16:10 +08006533static void wait_reset_mipc_response(void)
6534{
6535 int outfd = open("/data/tp",O_RDONLY);
6536 if(outfd == -1){
6537 RLOGD("open error");
6538 return;
6539 }
6540 char rst[1024];
6541 char response[2048];
6542 int s;
6543 s = read(outfd,rst,sizeof(rst));
6544 if (s>0)
6545 {
6546 RLOGD("lei buf: %s \n", rst);
6547 /*respone ok or error*/
6548 if(rst[0] = '0')
6549 {
6550 sprintf(response,"%s%s","+LRSTMD:",rst);
6551 /*check fd can or can't write*/
6552 write(ttyGS3_fd,response,strlen(response));
6553 write(ttyGS3_fd,"\nOK\n",4);
6554 }
6555 else
6556 {
6557 sprintf(response,"%s%s","+CME ERROR:",rst);
6558 /*check fd can or can't write*/
6559 write(ttyGS3_fd,response,strlen(response));
6560 }
6561 }
6562 else
6563 {
6564 RLOGD("wait_reset_mipc_response unknow error\n");
6565 }
6566 usleep(1);
6567 close(outfd);
6568 return;
6569}
6570
llaaca09b2022-03-14 16:14:28 +08006571void startUsbLoop(void)
6572{
lld164b022022-03-29 14:01:01 +08006573 /*lei add*/
6574 //Create a network communication object
6575 struct sockaddr_in addr_serv;
6576 struct sockaddr_in addr_clie;
6577 //Creating a Socket object
6578 sockfd=socket(AF_INET,SOCK_DGRAM,0);
6579 memset(&addr_serv, 0, sizeof(addr_serv));
6580 addr_serv.sin_family =AF_INET;
6581 addr_serv.sin_port =htons(LYNQ_AT_SERVICE_PORT);
6582 addr_serv.sin_addr.s_addr=htonl(INADDR_ANY);
6583 bind(sockfd,(struct sockaddr*)&addr_serv,sizeof(addr_serv));
6584 //receive registion and display on at port
6585 pthread_t thid;
6586 if(pthread_create(&thid, NULL, receive_at, (struct sockaddr*)&addr_clie) != 0) {
6587 RLOGE("thread creation failed\n");
6588 exit(1);
6589 }
6590 RLOGE("thread creation\n");
6591 /*lei add*/
llaaca09b2022-03-14 16:14:28 +08006592 int nread=-1;
6593 int n = -1;
6594 int routeId = -1;
6595 char buffer[1024]={};
6596 char tempbuf[1024]={};
6597 char buf_parser[64] = {};
6598 int argc = 0;
6599 char *argv[MAX_ARGS];//argv[0]:at name,argv[1]:raw data,argv[2]:at type,argv[3]:paramter1,argv[4]:paramter2 ....
6600 char eBuf[1024];
lle71c13f2022-10-12 13:42:18 +08006601 if(ttyGS3_fd > 0)
6602 {
6603 close(ttyGS3_fd);
6604 RLOGE("reopen need close");
6605 }
llaaca09b2022-03-14 16:14:28 +08006606 ttyGS3_fd = open("/dev/ttyGS3",O_RDWR);
6607 if(ttyGS3_fd==-1)
6608 {
6609 RLOGE("open ttyGS3 failure!!!");
6610 printf("open ttyGS3 failure!!!\n");
6611 //printf("%s\n",strerr(errno));
6612 perror("--test--");
llf5512ed2022-09-15 19:04:43 +08006613 //kill(0, SIGKILL);
llaaca09b2022-03-14 16:14:28 +08006614 }
llf5512ed2022-09-15 19:04:43 +08006615 RLOGD("[%s]open %s successfully ttyGS3_d %d!!!\n",__FUNCTION__,ttyname(ttyGS3_fd), ttyGS3_fd);
llaaca09b2022-03-14 16:14:28 +08006616 while(1)
6617 {
6618 bzero(buffer, 1024);
6619 bzero(tempbuf, 1024);
6620 bzero(buf_parser, 64);
6621 if((nread=read(ttyGS3_fd,buffer,1024))>0)
6622 {
6623 if(nread<2)
6624 {
6625 //RLOGD("input is space!!!");
6626 continue;
6627 }
6628 buffer[nread-1] = '\0';
6629 //printf("buffer is %s\n",buffer);
6630 for(int i = 0 ; i < nread ; i++)
6631 {
6632 if(buffer[i]=='=')
6633 {
6634 break;
6635 }
6636 if(buffer[i]>='a'&&buffer[i]<='z')
6637 {
6638 buffer[i] = buffer[i]-32;
6639 }
6640 }
lld164b022022-03-29 14:01:01 +08006641 RLOGD("buffer is %s\n",buffer);
6642 /*lei add*/
6643 /*check third cmd in buffer*/
6644 if(lynq_inside_at_buffer(buffer))
llaaca09b2022-03-14 16:14:28 +08006645 {
lld164b022022-03-29 14:01:01 +08006646 lynq_send_info(buffer, nread, (struct sockaddr*)&addr_clie);
llaaca09b2022-03-14 16:14:28 +08006647 }
lld164b022022-03-29 14:01:01 +08006648 /*lei add*/
6649 else
llaaca09b2022-03-14 16:14:28 +08006650 {
lld164b022022-03-29 14:01:01 +08006651 argc = lynqParseUsbCommand(buffer,argv,tempbuf,buf_parser,MAX_ARGS);
6652 if(argc<0)
6653 {
6654 bzero(eBuf, 1024);
6655 sprintf(eBuf,"LYNQ:%s not support!!!\n",buffer);
6656 int n = write(ttyGS3_fd,eBuf,strlen(eBuf));
llaaca09b2022-03-14 16:14:28 +08006657 if(n<0)
6658 {
6659 perror("lynq resp write:");
6660 }
lld164b022022-03-29 14:01:01 +08006661 RLOGD("n = %d\n",n);
llaaca09b2022-03-14 16:14:28 +08006662 continue;
lld164b022022-03-29 14:01:01 +08006663 }
6664 usb_at_transfer_t *atCmd = lynqFindId(argv[0]);
6665 if(atCmd==NULL)
llaaca09b2022-03-14 16:14:28 +08006666 {
lld164b022022-03-29 14:01:01 +08006667 RLOGD("LYNQ send ATCMD:%s!!!",argv[1]);
llaaca09b2022-03-14 16:14:28 +08006668 lynqSendAt(argc,argv,1010);
ll2f3fea22022-09-29 17:16:10 +08006669 usleep(50*1000);
6670 if(!strcmp(buffer, "AT+LRSTMD"))
6671 {
6672 wait_reset_mipc_response();
6673 }
lld164b022022-03-29 14:01:01 +08006674 continue;
llaaca09b2022-03-14 16:14:28 +08006675 }
lld164b022022-03-29 14:01:01 +08006676 if(!((1<<atoi(argv[2])) & (atCmd->support)))
llaaca09b2022-03-14 16:14:28 +08006677 {
lld164b022022-03-29 14:01:01 +08006678 RLOGD("LYNQ %s not support!!!",atCmd->cmdName);
6679 int n = write(ttyGS3_fd,"\n+CME ERROR: 100\n",strlen("\n+CME ERROR: 100\n"));
6680 if(n<0)
llaaca09b2022-03-14 16:14:28 +08006681 {
lld164b022022-03-29 14:01:01 +08006682 perror("lynq resp write:");
llaaca09b2022-03-14 16:14:28 +08006683 }
lld164b022022-03-29 14:01:01 +08006684 continue;
llaaca09b2022-03-14 16:14:28 +08006685 }
lld164b022022-03-29 14:01:01 +08006686 routeId = routeCmd(atCmd->cmdId);
6687 //routeId = routeCmd(atcmd->cmdId);
6688 //routeId = LYNQ_GOTO_AT;
6689 switch(routeId)
llaaca09b2022-03-14 16:14:28 +08006690 {
lld164b022022-03-29 14:01:01 +08006691 case LYNQ_GOTO_AT:
llaaca09b2022-03-14 16:14:28 +08006692 {
lld164b022022-03-29 14:01:01 +08006693 lynqSendAt(argc,argv,1010);
6694 break;
llaaca09b2022-03-14 16:14:28 +08006695 }
lld164b022022-03-29 14:01:01 +08006696 case LYNQ_GOTO_TELE_REQ:
6697 {
6698 usb_cmd_t *atCmdEvn = lynqFindUsbEvent(argv[0]);
6699 if(!atCmdEvn)
6700 {
6701 RLOGD("can not find at cmd event!!!");
6702 continue;
6703 }
6704 atCmdEvn->fun(argc,argv,atCmdEvn->rilRequest,1011);
6705 break;
6706 }
6707 case LYNQ_GOTO_USER_REQ:
6708 {
6709 usb_cmd_t *atCmdEvn = lynqFindUsbEvent(argv[0]);
6710 if(!atCmdEvn)
6711 {
6712 RLOGD("can not find at cmd event!!!");
6713 continue;
6714 }
6715 atCmdEvn->ufun(argc,argv,1012);
6716 break;
6717 }
6718 case LYNQ_GOTO_LINFO_REQ:
6719 {
6720 lynqInfo(argv);
6721 break;
6722 }
6723 // case LYNQ_GOTO_PLAT_REQ:
6724 // {
6725 // lynq_deal_with_log_at(&argv[3]);
6726 // break;
6727 // }
6728 case LYNQ_GOTO_RNDIS_REQ:
6729 {
6730 lynq_get_rndis_data(buffer);
6731 break;
6732 }
6733 case LYNQ_GOTO_FACTORY:
6734 {
6735 lynq_get_factory_data(argc,argv);
6736 break;
6737 }
tao.liu68d6eeb2022-11-17 16:48:50 +08006738 case LYNQ_GOTO_FOTA:
6739 {
6740 lynq_atfota_test(argv);
6741 break;
6742 }
rita9c8cd862022-08-10 09:36:49 +08006743 /*rita add start*/
6744 case LYNQ_GOTO_TEMP:
6745 {
6746 //write(ttyGS3_fd,"\n+CME ERROR: 1\n",strlen("\n+CME ERROR: 1\n"));
6747 lynq_at_get_temp(argc, argv);
6748 break;
6749 }
lld164b022022-03-29 14:01:01 +08006750 default:
6751 break;
llaaca09b2022-03-14 16:14:28 +08006752 }
llaaca09b2022-03-14 16:14:28 +08006753 }
lld164b022022-03-29 14:01:01 +08006754
llaaca09b2022-03-14 16:14:28 +08006755 }
6756 }
6757 close(ttyGS3_fd);
6758 return;
6759}
6760
lh7b0674a2022-01-10 00:34:35 -08006761void *
6762eventLoop(void *param) {
6763 pthread_mutex_lock(&s_startupMutex);
6764 s_started = 1;
6765 pthread_cond_broadcast(&s_startupCond);
6766 pthread_mutex_unlock(&s_startupMutex);
6767 #ifdef ECALL_SUPPORT
6768 init_ecall_timer_all();
6769 #endif /**/ECALL_SUPPORT
6770 /*warren add for t800 ril service 2021/12/13 start*/
6771 //RIL_StartRevSocket();
6772 LYNQ_RIL_urcClientInit();
6773 LYNQ_RIL_RecSocket();
6774 /*warren add for t800 ril service 2021/12/13 end*/
6775 RLOGD("error in event_loop_base errno:%d", errno);
6776 // kill self to restart on error
6777 kill(0, SIGKILL);
6778
6779 return NULL;
6780}
6781
llaaca09b2022-03-14 16:14:28 +08006782
6783void *
6784eventLoop_at(void *param) {
6785 pthread_mutex_lock(&s_startupMutex);
6786 s_started = 1;
6787 pthread_cond_broadcast(&s_startupCond);
6788 pthread_mutex_unlock(&s_startupMutex);
6789 //RIL_StartRevSocket();
6790 startUsbLoop();
6791 //startUsbLoop_test();
6792 RLOGD("error in event_loop_base errno:%d", errno);
6793 // kill self to restart on error
6794 kill(0, SIGKILL);
6795
6796 return NULL;
6797}
6798
lld164b022022-03-29 14:01:01 +08006799
6800
lh7b0674a2022-01-10 00:34:35 -08006801const int RspDispFunction(int request,char* arg, RIL_SOCKET_ID socket_id)
6802{
6803 int waittoken;
6804 RequestInfo *pRI = creatRILInfoAndInit(request, RSPD, socket_id);
6805 if(pRI == NULL)
6806 return 0;
6807 waittoken = pRI->token;
6808 switch (request) {
6809 case RIL_REQUEST_GET_CURRENT_CALLS:
6810 {
6811 RLOGD("request Current list start!");
6812 Parcel p;
6813 pRI->pCI->dispatchFunction(p, pRI);
6814 waitResponse(waittoken);
6815 RLOGD("request Current list end!");
6816 }
6817 break;
6818
6819 case RIL_REQUEST_ANSWER:
6820 {
6821 RLOGD("request Answer a MT call start!");
6822 Parcel p;
6823 pRI->pCI->dispatchFunction(p, pRI);
6824 waitResponse(waittoken);
6825 RLOGD("request Answer a MT call end!");
6826 }
6827 break;
6828
6829 case RIL_REQUEST_GET_SIM_STATUS:
6830 {
6831 int ret=getIccCardStatus(1, NULL, socket_id, pRI);
6832 if(ret == 0)
6833 waitResponse(waittoken);
6834 }
6835 break;
6836
6837 case RIL_REQUEST_DATA_REGISTRATION_STATE:
6838 {
6839 int ret=getDataRegistrationState(1, NULL, socket_id,pRI);
6840 if(ret == 0)
6841 waitResponse(waittoken);
6842 }
6843 break;
6844
6845 case RIL_REQUEST_VOICE_REGISTRATION_STATE:
6846 {
6847 int ret=getVoiceRegistrationState(1, NULL, socket_id,pRI);
6848 if(ret == 0)
6849 waitResponse(waittoken);
6850 }
6851 break;
6852 case RIL_REQUEST_SMS_ACKNOWLEDGE:
6853 {
6854 char* tmp[3] = {"RIL_REQUEST_SMS_ACKNOWLEDGE", "1", "0"};
6855 acknowledgeIncomingGsmSmsWithPdu(3,tmp,socket_id,pRI);
6856 waitResponse(waittoken);
6857 RLOGD("acknowledge last Incoming Gsm Sms : RIL_REQUEST_SMS_ACKNOWLEDGE end!");
6858 }
6859 break;
6860 case RIL_REQUEST_OEM_HOOK_RAW:
6861 {
6862 if(arg != NULL)
6863 {
6864 RLOGD("request OEM HOOK RAW start!");
6865 pRI->token = pRI->token|BLOCK_MARK;
6866 int waittokenOEM = pRI->token;
6867 Parcel p;
6868
6869 size_t pos = p.dataPosition();
6870 int len = strlen(arg);
6871 p.writeInt32(len);
6872 p.write((const void*)arg,len);
6873
6874 p.setDataPosition(pos);
6875 RLOGD("emSendATCommand: %s %d\n",arg,strlen(arg));
6876 pRI->pCI->dispatchFunction(p, pRI);
6877 waitResponse(waittokenOEM);
6878 } else {
6879 if(pRI){
6880 free(pRI);
6881 }
6882 RLOGE("at command shouldn't null");
6883 }
6884 break;
6885 }
6886 case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM:
6887 {
6888 char* tmp[2] = {"RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM", "no"};
6889 handleCallSetupRequestFromSim(2, tmp, socket_id,pRI);
6890 waitResponse(waittoken);
6891 RLOGD("timeout 1 minutes, response no by RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM");
6892 break;
6893 }
6894 case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE:
6895 {
6896 char* tmp[2] ={"RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE", arg};
6897 RLOGD("tmp[0]=%s, tmp[1]=%s, arg=%s", tmp[0], tmp[1], arg);
6898 sendTerminalResponse(2, tmp, socket_id, pRI);
6899 waitResponse(waittoken);
6900 break;
6901 }
6902 case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE:
6903 {
6904 acknowledgeLastIncomingCdmaSms(1, NULL,socket_id,pRI);
6905 waitResponse(waittoken);
6906 break;
6907 }
6908 case RIL_REQUEST_RADIO_POWER:
6909 {
6910 RLOGD("response loop, RIL_REQUEST_RADIO_POWER: %s", (arg == NULL ? "nul": arg));
6911 if(arg != NULL) {
6912 char* tmp[2] = {"RIL_REQUEST_RADIO_POWER", arg};
6913 setRadioPower(2,tmp,socket_id,pRI);
6914 waitResponse(waittoken);
6915 } else {
6916 if(pRI){
6917 free(pRI);
6918 }
6919 RLOGE("response loop, RIL_REQUEST_RADIO_POWER fail");
6920 }
6921 break;
6922 }
6923 case RIL_REQUEST_ALLOW_DATA:
6924 {
6925 int default_id = get_default_sim_data();
6926 RLOGD("RspDispFunction: socket_id=%d switch_id=%d", socket_id, default_id);
6927 char* argv[2] = {"RIL_REQUEST_ALLOW_DATA","0"};
6928 if(socket_id == default_id) {
6929 utils::mtk_property_set(PROP_DEFAULT_DATA_SIM, std::to_string(socket_id + 1).c_str());
6930 argv[1] = "1";
6931 }
6932 while(!isRadioAvailable(socket_id)) {
6933 sleep(1);
6934 RLOGD("[SIM%d]RspDispFunction(RIL_REQUEST_ALLOW_DATA): wait radio available", socket_id);
6935 }
6936 setDataAllowed(2, argv, socket_id, pRI);
6937 waitResponse(waittoken);
6938 break;
6939 }
6940 case RIL_REQUEST_CDMA_FLASH:
6941 {
6942 sendCDMAFeatureCode(1, NULL, socket_id, pRI);
6943 waitResponse(waittoken);
6944 break;
6945 }
6946 default:
xja1c30b82022-01-25 16:13:48 +08006947 if(pRI) {
6948 free(pRI);
6949 pRI = NULL;
6950 }
lh7b0674a2022-01-10 00:34:35 -08006951 break;
6952 }
6953 return 0;
6954}
6955
6956void * responseLoop(void *param) {
6957 pthread_mutex_lock(&s_startupMutex);
6958 s_responseDispatch= 1;
6959 pthread_cond_broadcast(&s_startupCond);
6960 pthread_mutex_unlock(&s_startupMutex);
6961 responseDispatch();
6962 RLOGD("error in response_loop_base errno:%d", errno);
6963 // kill self to restart on error
6964 kill(0, SIGKILL);
6965
6966 return NULL;
6967}
6968
6969void ATCIRequest(int request,char* reqString, void* t,int argc,char**argv)
6970{
xja1c30b82022-01-25 16:13:48 +08006971 if(t == NULL) {
6972 RLOGE("ATCIRequest t is null");
6973 return;
6974 }
lh7b0674a2022-01-10 00:34:35 -08006975 RequestInfo *pRI = (RequestInfo *)t;
6976 int waittoken;
6977 if (request < RIL_REQUEST_VENDOR_BASE) {
6978 pRI->pCI = &(s_commands[request]);
6979 } else {
6980 pRI->pCI = find_mtk_command(request);
6981 }
ll6e73f202022-12-28 14:59:46 +08006982 /*lei modify for Some requests that are not in the ril_commands.h and mtk_ril_commands.h but in commands.h*/
6983 COMMAND *command = find_command(reqString);
xja1c30b82022-01-25 16:13:48 +08006984 if(pRI->pCI == NULL){
ll6e73f202022-12-28 14:59:46 +08006985 if(command == NULL)
6986 {
6987 RLOGE("pCI command & command not found!");
6988 if(pRI) {
6989 free(pRI);
6990 }
6991 return;
xja1c30b82022-01-25 16:13:48 +08006992 }
xja1c30b82022-01-25 16:13:48 +08006993 }
ll6e73f202022-12-28 14:59:46 +08006994 /*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 +08006995
lh7b0674a2022-01-10 00:34:35 -08006996 if(utils::is_suppport_dsss()){
6997 pRI->socket_id = (RIL_SOCKET_ID)Phone_utils::get_enable_sim_for_dsss();
6998 }
6999
7000 if(utils::is_support_dsds() && (request != RIL_REQUEST_RADIO_POWER)){
7001 pRI->socket_id = (RIL_SOCKET_ID)get_atci_sim();
7002 }
lh7b0674a2022-01-10 00:34:35 -08007003 pRI->p_next = NULL;
7004
ll6e73f202022-12-28 14:59:46 +08007005
7006 RLOGD("function %s line %d reqString %s", __FUNCTION__, __LINE__, reqString);
lh7b0674a2022-01-10 00:34:35 -08007007 if(command == NULL) {
7008 RLOGE("ATCI request command find error!");
xja1c30b82022-01-25 16:13:48 +08007009 if(pRI) {
7010 free(pRI);
7011 }
7012 return;
lh7b0674a2022-01-10 00:34:35 -08007013 } else {
7014 RLOGE("ATCI request name is %s!",command->name);
7015 }
7016
7017 pRI->token = GenerateToken(ATCI, request);
7018 waittoken = pRI->token;
7019 if(request == RIL_REQUEST_RADIO_POWER) {
7020 speciaRequest_wait();
7021 }
7022 (*(command->func)) (argc, argv, pRI->socket_id, pRI);
7023 //need wait Ril_onRequestComplete return.
7024 waitResponse(waittoken);
7025 return;
7026}
7027
7028void startWakupLoop(void)
7029{
7030 pthread_t WakeupReasonThread;
7031
7032 RLOGD("startWakupLoop()");
7033 pthread_mutex_lock(&s_startupMutex);
7034
7035 pthread_attr_t attr;
7036 pthread_attr_init(&attr);
7037 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
7038
7039 int result = pthread_create(&WakeupReasonThread, &attr, wakeup_reason_loop, NULL);
7040 if (result != 0) {
7041 RLOGW("Failed to create wakeup reason thread: %s", strerror(result));
7042 goto done;
7043 }
7044
7045done:
7046 pthread_mutex_unlock(&s_startupMutex);
7047}
llaaca09b2022-03-14 16:14:28 +08007048/*Warren add for FAW 2021/09/23 start
7049** use ttyGS0 port
7050*/
7051int lynqSendToRil(int argc,char *argv[],int uToken)
7052{
7053 if(argc < 1)
7054 {
7055 RLOGE("lynqSendToRil error input.");
7056 return 1;
7057 }
7058 for(int i =0;i<argc;i++)
7059 {
7060 printf("argv[%d]=%s\n",i,argv[i]);
7061 }
7062 COMMAND *command = find_command(argv[0]);
7063 if(!command)
7064 {
7065 RLOGE("%s: No such command for DemoApp", argv[0]);
7066 return 1;
7067 }
7068
7069 int32_t request;
7070
7071 request = command->request;
7072
7073 RIL_SOCKET_ID id = RIL_SOCKET_1;
7074 if(utils::is_support_dsds()) {
7075 id = (RIL_SOCKET_ID)get_default_sim_all_except_data();
7076 } else if(utils::is_suppport_dsss()) {
7077 id = (RIL_SOCKET_ID)Phone_utils::get_enable_sim_for_dsss();
7078 }
7079
7080 if(request == -1)
7081 {
7082 (*(command->func)) (argc, argv, id, NULL);
7083 return 1;
7084 }
7085
7086 if (request < 1 || (request >= (int32_t)NUM_ELEMS(s_commands) && request < RIL_REQUEST_VENDOR_BASE)) {
7087 RLOGW("unsupported request code %d token %d", request);
7088 // FIXME this should perhaps return a response
7089 return 1;
7090 }
7091
7092 RLOGD("REQUEST: %s ParamterNum:%d", requestToString(request), argc);
7093
7094
7095 RequestInfo *pRI = creatRILInfoAndInit(request, UDP, (RIL_SOCKET_ID)(id));
7096 pRI->lynqEvent = 1;
7097 //Radio on/off only allow one thread operate.
7098 if(request == RIL_REQUEST_RADIO_POWER)
7099 {
7100 speciaRequest_wait();
7101 }
7102 memset(Time_buf,0,sizeof(Time_buf));
7103 GetTimeString(Time_buf);
7104 //FUNCTION_CALLED(Time_buf,requestToString(request));
7105 int waittoken = pRI->token;
7106 (*(command->func)) (argc, argv, pRI->socket_id, pRI);
7107 FUNCTION_CALLED(Time_buf,requestToString(request));
7108 waitResponse(waittoken);
7109 memset(Time_buf,0,sizeof(Time_buf));
7110 GetTimeString(Time_buf);
7111 FUNCTION_RETURN(Time_buf,requestToString(request));
7112 return 0;
7113}
7114
7115int sendRespToUsb(char *cmd)
7116{
7117 return 0;
7118}
7119int sendUrcToUsb(char *cmd)
7120{
7121 return 0;
7122}
7123/*Warren add for FAW 2021/09/23 end*/
lh7b0674a2022-01-10 00:34:35 -08007124
7125void startPMLoop(void)
7126{
7127 pthread_t atciSocketThread;
7128
7129 RLOGD("startPMLoop()");
7130 pthread_mutex_lock(&s_startupMutex);
7131
7132 pthread_attr_t attr;
7133 pthread_attr_init(&attr);
7134 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
7135
7136 int result = pthread_create(&atciSocketThread, &attr, StartPMSocket, NULL);
7137 if (result != 0) {
7138 RLOGW("Failed to create PM thread: %s", strerror(result));
7139 goto done;
7140 }
7141
7142done:
7143 pthread_mutex_unlock(&s_startupMutex);
7144}
7145
7146void startGdbusLoop(void)
7147{
7148 pthread_t atciSocketThread;
7149
7150 RLOGD("startGdbusLoop()");
7151 pthread_mutex_lock(&s_startupMutex);
7152
7153 pthread_attr_t attr;
7154 pthread_attr_init(&attr);
7155 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
7156
7157 int result = pthread_create(&atciSocketThread, &attr, init_data_gdbus_cb, NULL);
7158 if (result != 0) {
7159 RLOGW("Failed to create gdbus thread: %s", strerror(result));
7160 goto done;
7161 }
7162
7163done:
7164 pthread_mutex_unlock(&s_startupMutex);
7165}
7166
7167void startATCILoop(void)
7168{
7169 pthread_t atciSocketThread;
7170
7171 RLOGD("startATCILoop()");
7172 pthread_mutex_lock(&s_startupMutex);
7173
7174 pthread_attr_t attr;
7175 pthread_attr_init(&attr);
7176 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
7177
7178 int result = pthread_create(&atciSocketThread, &attr, StartATCISocket, NULL);
7179 if (result != 0) {
7180 RLOGW("Failed to create ATCI thread: %s", strerror(result));
7181 goto done;
7182 }
7183
7184done:
7185 pthread_mutex_unlock(&s_startupMutex);
7186}
7187
7188void RIL_startEventLoop(void)
7189{
7190 RLOGD("RIL_startEventLoop()");
lhf6eea122022-01-20 19:32:14 -08007191 lynq_init_sms_manager();
lh7b0674a2022-01-10 00:34:35 -08007192 /* spin up eventLoop thread and wait for it to get started */
7193 s_started = 0;
7194 pthread_mutex_lock(&s_startupMutex);
7195
7196 pthread_attr_t attr;
7197 pthread_attr_init(&attr);
7198 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
7199
7200 int result = pthread_create(&s_tid_dispatch, &attr, eventLoop, NULL);
7201 if (result != 0) {
7202 RLOGW("Failed to create dispatch thread: %s", strerror(result));
7203 goto done;
7204 }
llaaca09b2022-03-14 16:14:28 +08007205
7206 while (s_started == 0) {
7207 pthread_cond_wait(&s_startupCond, &s_startupMutex);
7208 }
Hong_Liu2b7b17c2022-12-14 03:03:56 -08007209 //warren delete,beacuse of update at fwk.
7210 /*mobiletek add*
llaaca09b2022-03-14 16:14:28 +08007211 s_started = 0;
7212 result = pthread_create(&s_tid_dispatch, &attr, eventLoop_at, NULL);
7213 if (result != 0) {
7214 RLOGW("Failed to create dispatch thread: %s", strerror(result));
7215 goto done;
7216 }
lh7b0674a2022-01-10 00:34:35 -08007217
7218 while (s_started == 0) {
7219 pthread_cond_wait(&s_startupCond, &s_startupMutex);
7220 }
Hong_Liu2b7b17c2022-12-14 03:03:56 -08007221 *mobiletek add*/
lh7b0674a2022-01-10 00:34:35 -08007222 result = pthread_create(&s_tid_dispatch, &attr, responseLoop, NULL);
7223 if (result != 0) {
7224 RLOGW("Failed to create response dispatch thread: %s", strerror(result));
7225 goto done;
7226 }
7227
7228 while (s_responseDispatch == 0) {
7229 pthread_cond_wait(&s_startupCond, &s_startupMutex);
7230 }
7231done:
7232 pthread_mutex_unlock(&s_startupMutex);
7233}
7234
7235void printInputArgs(int argc, char** argv)
7236{
7237 int i=0;
7238
7239 for(i=0; i<argc; i++)
7240 {
7241 RLOGD("%s", argv[i]);
7242 }
7243}
7244
7245void initRequestInfo(RequestInfo *pRI, int request, int mode, RIL_SOCKET_ID soc_id)
7246{
7247 pRI->token = GenerateToken(mode, request);
7248 if (request < RIL_REQUEST_VENDOR_BASE) {
7249 pRI->pCI = &(s_commands[request]);
7250 } else {
7251 pRI->pCI = find_mtk_command(request);
7252 }
7253 pRI->socket_id = soc_id;
7254
7255 pRI->p_next = NULL;
7256}
7257
7258void getVoiceAndDataRegistrationState(RIL_SOCKET_ID soc_id)
7259{
7260 ARspRequest(RIL_REQUEST_DATA_REGISTRATION_STATE,soc_id);
7261 ARspRequest(RIL_REQUEST_VOICE_REGISTRATION_STATE,soc_id);
7262}
7263
7264void requestAnswer(RIL_SOCKET_ID soc_id)
7265{
7266 ARspRequest(RIL_REQUEST_ANSWER,soc_id);
7267 return;
7268}
7269void requestSMSACKNOWLEDGE(RIL_SOCKET_ID soc_id)
7270{
7271 ARspRequest(RIL_REQUEST_SMS_ACKNOWLEDGE,soc_id);
7272 return;
7273}
7274
7275#if EM_MODE_SUPPORT
7276void registerForNetworkInfo(netwokInfoNotify cb)
7277{
7278 networkCb = cb;
7279 return ;
7280}
7281void unregisterNetwork()
7282{
7283 networkCb = NULL;
7284 //AT+EINFO= flag & 0xFFFFFFF7
7285}
7286void registerForATcmdResponse(atCmdResponse cb)
7287{
7288 atResponseCb = cb;
7289 return ;
7290}
7291
7292void unregisterATcmd()
7293{
7294 atResponseCb = NULL;
7295}
7296
7297#endif
7298int emResultNotify(const char *str)
7299{
7300 RLOGD("emResultNotify %s",str);
7301 int len_s = sendto(server_socket_fd,str,strlen(str),0,(struct sockaddr *)&client_addr,sizeof(client_addr));
7302
7303 sendto(server_socket_fd,"stopemdone",strlen("stopemdone"),0,(struct sockaddr *)&client_addr,sizeof(client_addr));
7304 return len_s;
7305}
7306
7307void processUnsolicited (Parcel &p, int type)
7308{
xja1c30b82022-01-25 16:13:48 +08007309 int32_t response = -1;
lh7b0674a2022-01-10 00:34:35 -08007310 p.readInt32(&response);
7311 switch(response){
7312 case RIL_UNSOL_MAL_AT_INFO:
7313 {
7314#if EM_MODE_SUPPORT
7315 char *stringresponse = strdupReadString(p);
7316 if(strstr(stringresponse,"+ENWINFO") != NULL){
7317 RLOGD("processUnsolicited ENWINFO \n");
7318 char *start = strstr(stringresponse,":");
7319 char *end = strstr(stringresponse,",");
7320 if(start == NULL ||end == NULL ){
7321 break;
7322 }
7323 if(networkCb){
7324 //parse type & data, notify to registrants
7325 char ctype[5] = {0};
7326 int type = 0;
7327 memcpy(ctype,start+1, end - start -1);
7328 type = atoi(ctype);
7329 char *data = end+1;
7330 RLOGD("ctype %s type %d data %s\n",ctype,type,data);
7331 //parse response
7332 networkCb(type,data);
7333 }
7334 }
7335 if(stringresponse){
7336 free(stringresponse);
7337 }
7338#endif
7339 break;
7340 }
7341 default:
7342 break;
7343 }
7344}
7345void processSolicited(Parcel &p, int type) {
7346 int32_t serial, error;
xja1c30b82022-01-25 16:13:48 +08007347 serial = 0;
lh7b0674a2022-01-10 00:34:35 -08007348 p.readInt32(&serial); //telematic it is the same as ril request num
7349 p.readInt32(&error);
7350 RLOGD("processSolicited serial %d\n", serial);
7351 switch (serial) {
7352 case RIL_REQUEST_OEM_HOOK_RAW: {
7353 if (error != RIL_E_SUCCESS) {
7354 RLOGW("RIL_E_fail");
7355 if (atResponseCb) {
7356 atResponseCb(NULL, 0);
7357 }
7358 if(m_RfDesense){
7359 m_RfDesense->handle_request("", 0, 0, (RIL_Errno)error);
7360 }
7361 return;
7362 }
7363 int len;
7364 status_t status = 0;
7365 status = p.readInt32(&len);
7366 if (status != 0) {
7367 RLOGW("read int32 fail");
7368 return;
7369 }
7370 char *stringresponse = (char*) calloc(len, sizeof(char));
7371 status = p.read((void*) stringresponse, len);
7372 if (status != 0) {
7373 if (stringresponse) {
7374 free(stringresponse);
7375 }
7376 RLOGW("read int32 fail");
7377 return;
7378 }
7379 parseAtCmd(stringresponse);
7380 RLOGD("processSolicited AT string %s %d\n", stringresponse, len);
7381#if EM_MODE_SUPPORT
7382 if (atResponseCb) {
7383 if (stringresponse) {
7384
7385 atResponseCb(stringresponse, len);
7386 } else {
7387 atResponseCb(stringresponse, 0);
7388 }
7389 }
7390 if(m_RfDesense){
7391 if(stringresponse && (!isFinalResponseErrorEx(stringresponse))) {
7392 m_RfDesense->handle_request(stringresponse,len,0, (RIL_Errno)RIL_E_SUCCESS);
7393 } else {
7394 RLOGD("isFinalResponseErrorEx error or response is null");
7395 m_RfDesense->handle_request(stringresponse, 0, 0, (RIL_Errno)RIL_E_GENERIC_FAILURE);
7396 }
7397 }
7398#endif
7399 if (stringresponse) {
7400 free(stringresponse);
7401 }
7402 break;
7403 }
7404 case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: {
7405#if EM_MODE_SUPPORT
7406 if (atResponseCb) {
7407 if (error != RIL_E_SUCCESS) {
7408 atResponseCb(NULL, 0);
7409 } else {
7410 atResponseCb("OK", 2);
7411 }
7412 }
7413#endif
7414 break;
7415 }
7416 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: {
7417#if EM_MODE_SUPPORT
7418 int nums = 0;
7419 int prefertype = 0;
7420 p.readInt32(&nums);
7421 if (nums != 1) {
7422 RLOGD("getpreferrednetworktype nums > 1");
7423 }
7424 p.readInt32(&prefertype);
7425 char prefertype_str[3] = { 0 };
7426 sprintf(prefertype_str, "%d", prefertype);
7427 if (atResponseCb) {
7428 if (error != RIL_E_SUCCESS) {
7429 atResponseCb(NULL, 0);
7430 } else {
7431 atResponseCb(prefertype_str, strlen(prefertype_str));
7432 }
7433 }
7434#endif
7435 break;
7436 }
7437 case RIL_REQUEST_GET_IMSI: {
7438 if (error != RIL_E_SUCCESS) {
7439 RLOGD("RIL_REQUEST_GET_IMSI error %d\n", error);
7440 }
7441 break;
7442 }
7443 }
7444}
7445
7446#ifdef ECALL_SUPPORT
7447static int responseEcallStatus(Parcel &p, void *response, size_t responselen) {
7448 if (response == NULL || responselen != sizeof(RIL_Ecall_Unsol_Indications)) {
7449 if (response == NULL) {
7450 RLOGE("invalid response: NULL");
7451 }
7452 else {
7453 RLOGE("responseEcallStatus: invalid response length %d expecting len: %d",
7454 sizeof(RIL_Ecall_Unsol_Indications), responselen);
7455 }
7456 return RIL_ERRNO_INVALID_RESPONSE;
7457 }
7458
7459 RIL_Ecall_Unsol_Indications *p_cur = (RIL_Ecall_Unsol_Indications *)response;
7460 p.writeInt32(p_cur->ind);
7461 p.writeInt32(p_cur->call_id);
7462
7463 startResponse;
7464 appendPrintBuf("ECall Status: %d, call_id: %d",
7465 p_cur->ind, p_cur->call_id);
7466 closeResponse;
7467
7468 return 0;
7469}
7470
7471/**
7472 * Callee expects const RIL_ECallReqMsg *
7473 * Payload is:
7474 * RIL_ECall_Category ecall_cat
7475 * RIL_ECall_Variant ecall_variant
7476 * String address
7477 * String msd_data
7478 */
7479static void dispatchFastEcall (Parcel &p, RequestInfo *pRI) {
7480 RIL_ECallReqMsg eCallReqMsg;
7481
xja1c30b82022-01-25 16:13:48 +08007482 int32_t t = -1;
lh7b0674a2022-01-10 00:34:35 -08007483 int size;
7484 status_t status;
7485 int digitCount;
7486 int digitLimit;
7487 uint8_t uct;
7488
7489 memset(&eCallReqMsg, 0, sizeof(eCallReqMsg));
7490
7491 status = p.readInt32(&t);
7492 eCallReqMsg.ecall_cat= (RIL_ECall_Category)t;
7493
7494 status = p.readInt32(&t);
7495 eCallReqMsg.ecall_variant = (RIL_ECall_Variant)t;
7496
7497 eCallReqMsg.address = strdupReadString(p);
7498
7499 status = p.readInt32(&t);
7500 eCallReqMsg.length = (uint8_t) t;
7501
7502 digitLimit= MIN((eCallReqMsg.length), MSD_MAX_LENGTH);
7503 eCallReqMsg.msd_data = (unsigned char *)alloca(digitLimit);
7504
7505 for(digitCount = 0 ; digitCount < digitLimit; digitCount ++) {
7506 status = p.read(&uct, sizeof(uint8_t));
7507 eCallReqMsg.msd_data[digitCount] = (uint8_t) uct;
7508 }
7509
7510 startRequest;
7511 appendPrintBuf("%secall_cat=%d,ecall_variant=%d, address=%s", printBuf,
7512 eCallReqMsg.ecall_cat, eCallReqMsg.ecall_variant, (char*)eCallReqMsg.address);
7513 closeRequest;
7514 printRequest(pRI->token, pRI->pCI->requestNumber);
7515
7516 if (status != NO_ERROR) {
7517 goto invalid;
7518 }
7519
7520 size = sizeof(eCallReqMsg);
7521 CALL_ONREQUEST(pRI->pCI->requestNumber, &eCallReqMsg, size, pRI, pRI->socket_id);
7522
7523#ifdef MEMSET_FREED
7524 memsetString(eCallReqMsg.address);
lhb07f4e12022-02-17 22:08:54 -08007525 memset(eCallReqMsg.msd_data, 0, digitLimit);
lh7b0674a2022-01-10 00:34:35 -08007526#endif
7527
7528 free(eCallReqMsg.address);
7529
7530#ifdef MEMSET_FREED
7531 memset(&eCallReqMsg, 0, sizeof(eCallReqMsg));
7532#endif
7533
7534 return;
7535invalid:
7536 invalidCommandBlock(pRI);
7537 return;
7538}
7539
7540/**
7541 * Callee expects const RIL_ECallSetMSD *
7542 * Payload is:
7543 * int call_id
7544 * String msd_data
7545 */
7546static void dispatchSetMsd (Parcel &p, RequestInfo *pRI) {
7547 RIL_ECallSetMSD eCallSetMsd;
7548
xja1c30b82022-01-25 16:13:48 +08007549 int32_t t = -1;
lh7b0674a2022-01-10 00:34:35 -08007550 int size;
7551 status_t status;
7552 int digitCount;
7553 int digitLimit;
7554 uint8_t uct;
7555
7556 memset(&eCallSetMsd, 0, sizeof(eCallSetMsd));
7557
7558 status = p.readInt32(&t);
7559 eCallSetMsd.call_id = (int)t;
7560
7561 status = p.readInt32(&t);
7562 eCallSetMsd.length = (uint8_t) t;
7563
7564 digitLimit= MIN((eCallSetMsd.length), MSD_MAX_LENGTH);
7565 eCallSetMsd.msd_data = (unsigned char *)alloca(digitLimit);
7566
7567 for(digitCount = 0 ; digitCount < digitLimit; digitCount ++) {
7568 status = p.read(&uct, sizeof(uint8_t));
7569 eCallSetMsd.msd_data[digitCount] = (uint8_t) uct;
7570 }
7571
7572 startRequest;
7573 appendPrintBuf("%scall_id=%d,msd_data=%s", printBuf, eCallSetMsd.call_id, (char*)eCallSetMsd.msd_data);
7574 closeRequest;
7575 printRequest(pRI->token, pRI->pCI->requestNumber);
7576
7577 if (status != NO_ERROR) {
7578 goto invalid;
7579 }
7580
7581 size = sizeof(eCallSetMsd);
7582 CALL_ONREQUEST(pRI->pCI->requestNumber, &eCallSetMsd, size, pRI, pRI->socket_id);
7583
7584#ifdef MEMSET_FREED
7585 memset(eCallSetMsd.msd_data, 0, eCallSetMsd.length);
7586#endif
7587
7588#ifdef MEMSET_FREED
7589 memset(&eCallSetMsd, 0, sizeof(eCallSetMsd));
7590#endif
7591
7592 return;
7593invalid:
7594 invalidCommandBlock(pRI);
7595 return;
7596}
7597
7598/**
7599 * Callee expects const RIL_ECallSetNum *
7600 * Payload is:
7601 * int arg_num;
7602 * int type
7603 * char* address
7604 */
7605static void dispatchEcallRecord (Parcel &p, RequestInfo *pRI) {
7606 RIL_ECallSetNum args;
xja1c30b82022-01-25 16:13:48 +08007607 int32_t t = -1;
lh7b0674a2022-01-10 00:34:35 -08007608 status_t status;
7609
7610 RLOGD("dispatchSmsWrite");
7611 memset (&args, 0, sizeof(args));
7612
7613 status = p.readInt32(&t);
7614 args.arg_num = (int)t;
7615
7616 status = p.readInt32(&t);
7617 args.type = (int)t;
7618
7619 args.address = strdupReadString(p);
7620
7621 if (status != NO_ERROR || args.address == NULL) {
7622 goto invalid;
7623 }
7624
7625 startRequest;
7626 appendPrintBuf("%s%d,%s,%d", printBuf, args.type, args.address,args.arg_num);
7627 closeRequest;
7628 printRequest(pRI->token, pRI->pCI->requestNumber);
7629
7630 CALL_ONREQUEST(pRI->pCI->requestNumber, &args, sizeof(args), pRI, pRI->socket_id);
7631
7632#ifdef MEMSET_FREED
7633 memsetString (args.address);
7634#endif
7635
7636 free (args.address);
7637#ifdef MEMSET_FREED
7638 memset(&args, 0, sizeof(args));
7639#endif
7640 return;
7641invalid:
7642 invalidCommandBlock(pRI);
7643 return;
7644}
7645#endif /*ECALL_SUPPORT*/
7646
7647#ifdef KEEP_ALIVE
7648static void dispatchStartKeepalivePro(Parcel &p, RequestInfo *pRI){
7649 RIL_RequestKeepalive_Pro kp;
xja1c30b82022-01-25 16:13:48 +08007650 int32_t t = -1;
lh7b0674a2022-01-10 00:34:35 -08007651 status_t status;
7652 std::vector<uint8_t> sadr;
7653 std::vector<uint8_t> dadr;
7654
7655 memset (&kp, 0, sizeof(RIL_RequestKeepalive_Pro));
7656
7657 status = p.readInt32(&t);
7658 kp.type = (RIL_PacketType)t;
7659 if (status != NO_ERROR) {
7660 goto invalid;
7661 }
7662
7663
7664 status = p.readByteVector(&sadr);
7665 if (status != NO_ERROR) {
7666 goto invalid;
7667 } else {
7668 for(int i = 0; i < sadr.size(); i++) {
7669 kp.sourceAddress[i] = sadr[i];
7670 }
7671 }
7672
7673 status = p.readInt32(&t);
7674 kp.sourcePort= (int)t;
7675 if (status != NO_ERROR) {
7676 goto invalid;
7677 }
7678
7679 status = p.readByteVector(&dadr);
7680 if (status != NO_ERROR) {
7681 goto invalid;
7682 } else {
7683 for(int i = 0; i < dadr.size(); i++) {
7684 kp.destinationAddress[i] = dadr[i];
7685 }
7686 }
7687
7688 status = p.readInt32(&t);
7689 kp.destinationPort= (int)t;
7690 if (status != NO_ERROR) {
7691 goto invalid;
7692 }
7693
7694 status = p.readInt32(&t);
7695 kp.netif_id = (int)t;
7696 if (status != NO_ERROR) {
7697 goto invalid;
7698 }
7699
7700 status = p.readInt32(&t);
7701 kp.keepIdleTime = (int)t;
7702 if (status != NO_ERROR) {
7703 goto invalid;
7704 }
7705
7706 status = p.readInt32(&t);
7707 kp.keepIntervalTime = (int)t;
7708 if (status != NO_ERROR) {
7709 goto invalid;
7710 }
7711
7712 status = p.readInt32(&t);
7713 kp.retryCount = (int)t;
7714 if (status != NO_ERROR) {
7715 goto invalid;
7716 }
7717 startRequest;
7718 appendPrintBuf("%s [type:%d, sourceAddress:",printBuf, kp.type);
7719
7720 for(auto v: sadr) {
7721 appendPrintBuf("%s %d",printBuf,v);
7722 }
7723 appendPrintBuf("%s, sourcePort:%d, destinationAddress:",printBuf, kp.sourcePort);
7724
7725 for(auto v: dadr) {
7726 appendPrintBuf("%s %d",printBuf,v);
7727 }
7728 appendPrintBuf("%s, destinationPort:%d, netif_id:%d, keepIdleTime:%d,, keepIntervalTime:%d, retryCount:%d",
7729 printBuf, kp.destinationPort, kp.netif_id, kp.keepIdleTime, kp.keepIntervalTime, kp.retryCount);
7730
7731 closeRequest;
7732 printRequest(pRI->token, pRI->pCI->requestNumber);
7733
7734 CALL_ONREQUEST(pRI->pCI->requestNumber,&kp,sizeof(RIL_RequestKeepalive_Pro),pRI, pRI->socket_id);
7735 return;
7736invalid:
7737 invalidCommandBlock(pRI);
7738 return;
7739}
7740#endif /* KEEP_ALIVE*/
7741} /* namespace android */
7742
7743#if 0
7744void rilEventAddWakeup_helper(struct ril_event *ev) {
7745 android::rilEventAddWakeup(ev);
7746}
7747
7748void listenCallback_helper(int fd, short flags, void *param) {
7749 android::listenCallback(fd, flags, param);
7750}
7751
7752int blockingWrite_helper(int fd, void *buffer, size_t len) {
7753 return android::blockingWrite(fd, buffer, len);
7754}
7755#endif