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