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