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