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