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