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