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