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