blob: 12801dd29bffa639e3c9bd684397528b255ca0a2 [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
ll2d5dbd12022-05-19 14:48:44 +08003858static int lynq_get_inside_version(){
3859 FILE *fp;
3860 char buf[128] = {0};
3861 char cgmr[128] = {0};
3862 sprintf(buf, "uci get lynq_uci_ro.lynq_version.LYNQ_SW_INSIDE_VERSION 2>&1");
3863 fp=popen(buf, "r");
3864 int n;
3865 while(fgets(buf, sizeof(buf), fp) != NULL)
3866 {
3867 }
3868 //parse_version_buf(buf);
3869 sprintf(cgmr, "%s %s", "+CGIR:", buf);
3870 n = write(ttyGS3_fd,cgmr,strlen(cgmr));
3871 if(n<0)
3872 {
3873 perror("lynq resp write:");
3874 }
3875 pclose(fp);
3876 return 0;
3877}
3878
3879/**
3880 * @brief cgmr ---> cgir
3881 *
3882 * @param response
3883 */
3884static void parse_inside_version(void *response)
3885{
3886 char *p = (char *)response;
3887 while (*p != 0)
3888 {
3889 if(*p == 'M')
3890 {
3891 *p = 'I';
3892 break;
3893 }
3894 else
3895 {
3896 *p ++;
3897 }
3898 }
3899 return;
3900}
3901
lh7b0674a2022-01-10 00:34:35 -08003902extern "C" void
3903RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responselen) {
3904 RequestInfo *pRI;
3905 int ret;
3906 //int fd = s_ril_param_socket.fdCommand;
3907 size_t errorOffset;
3908 RIL_SOCKET_ID socket_id = RIL_SOCKET_1;
3909
3910 pRI = (RequestInfo *)t;
3911#if 0
3912 if (!checkAndDequeueRequestInfo(pRI)) {
3913 RLOGE ("RIL_onRequestComplete: invalid RIL_Token");
3914 return;
3915 }
3916#endif
3917
3918 socket_id = pRI->socket_id;
3919#if 0
3920#if (SIM_COUNT >= 2)
3921 if (socket_id == RIL_SOCKET_2) {
3922 fd = s_ril_param_socket2.fdCommand;
3923 }
3924#if (SIM_COUNT >= 3)
3925 if (socket_id == RIL_SOCKET_3) {
3926 fd = s_ril_param_socket3.fdCommand;
3927 }
3928#endif
3929#if (SIM_COUNT >= 4)
3930 if (socket_id == RIL_SOCKET_4) {
3931 fd = s_ril_param_socket4.fdCommand;
3932 }
3933#endif
3934#endif
3935#endif
3936#if VDBG
3937 RLOGD("RequestComplete, %s", rilSocketIdToString(socket_id));
3938#endif
3939
3940 if (pRI->local > 0) {
3941 // Locally issued command...void only!
3942 // response does not go back up the command socket
3943 RLOGD("C[locl]< %s", requestToString(pRI->pCI->requestNumber));
3944
3945 goto done;
3946 }
3947
3948 appendPrintBuf("[%x][SIM%d]< %s", pRI->token,socket_id,requestToString(pRI->pCI->requestNumber));
3949
3950 if (pRI->cancelled == 0) {
3951 Parcel p;
3952
3953 p.writeInt32 (RESPONSE_SOLICITED);
3954 p.writeInt32 (pRI->pCI->requestNumber);
3955 /*warren add for t800 ril servie 2021/12/15 start*/
3956 p.writeInt32(socket_id);
3957 /*warren add for t800 ril servie 2021/12/15 end*/
3958 errorOffset = p.dataPosition();
3959
3960 p.writeInt32 (e);
3961
3962 if (response != NULL) {
3963 // there is a response payload, no matter success or not.
3964 ret = pRI->pCI->responseFunction(p, response, responselen);
3965
3966 /* if an error occurred, rewind and mark it */
3967 if (ret != 0) {
3968 RLOGE ("responseFunction error, ret %d", ret);
3969 p.setDataPosition(errorOffset);
3970 p.writeInt32 (ret);
3971 }
3972 switch (pRI->pCI->requestNumber) {
3973 case RIL_REQUEST_QUERY_FACILITY_LOCK:
3974 {
3975 int numInts = responselen / sizeof(int);
3976 if(numInts > 0) {
3977 int *p_int = (int *) response;
3978 RLOGD("RIL_REQUEST_QUERY_FACILITY_LOCK: %s", (p_int[0] != 0 ? "PIN enable" : "PIN1 disable"));
3979 } else {
3980 RLOGD("RIL_REQUEST_QUERY_FACILITY_LOCK response numInts: %d", numInts);
3981 }
3982 break;
3983 }
3984 case RIL_REQUEST_IMS_REGISTRATION_STATE:
3985 {
3986 int numInts = responselen / sizeof(int);
3987 if(numInts > 0) {
3988 int *p_int = (int *) response;
3989 printf("[SIM%d][QUERY][REG_STATUS] IMS is %s\n", socket_id, (p_int[0] == 0 ? "Not registered" : "Registered"));
3990 } else {
3991 RLOGD("RIL_REQUEST_IMS_REGISTRATION_STATE response numInts: %d", numInts);
3992 }
3993 break;
3994 }
3995 case RIL_REQUEST_VOICE_REGISTRATION_STATE:
3996 {
3997 char **p_cur = (char **) response;
3998 int numStrings = responselen / sizeof(char *);
3999 update_reg_voice_service_state(RIL_REQUEST_VOICE_REGISTRATION_STATE, (char *)p_cur[0], socket_id, pRI->token);
4000 int tempVal=0;
4001 memset(respStr,0,sizeof(respStr));
4002 tempVal = atoi((char *)p_cur[0]);
4003 if(tempVal == 1 || tempVal==5){
4004 sprintf(respStr,"[SIM%d]%s register is in service!",socket_id +1, respStr);
4005 }else{
4006 sprintf(respStr,"[SIM%d]%s register is not in service!",socket_id +1, respStr);
4007 }
4008 if(numStrings >=4 && p_cur[3] != NULL)
4009 {
4010 update_reg_voice_radio_tech(RIL_REQUEST_VOICE_REGISTRATION_STATE, atoi((char *)p_cur[3]), socket_id, pRI->token);
4011 tempVal = atoi((char *)p_cur[3]);
4012 if(tempVal == RADIO_TECH_LTE){//4G
4013 sprintf(respStr,"%s radioTech is 4G!",respStr);
4014 } else if( tempVal == RADIO_TECH_GSM ||
4015 tempVal == RADIO_TECH_GPRS ||
4016 tempVal == RADIO_TECH_EDGE ||
4017 tempVal == RADIO_TECH_IS95A ||
4018 tempVal == RADIO_TECH_IS95B ||
4019 tempVal == RADIO_TECH_1xRTT) { //2G
4020 sprintf(respStr,"%s radioTech is 2G!",respStr);
4021 } else if( tempVal == RADIO_TECH_UMTS ||
4022 tempVal == RADIO_TECH_HSDPA ||
4023 tempVal == RADIO_TECH_HSUPA ||
4024 tempVal == RADIO_TECH_HSPA ||
4025 tempVal == RADIO_TECH_EHRPD ||
4026 tempVal == RADIO_TECH_HSPAP ||
4027 tempVal == RADIO_TECH_TD_SCDMA ||
4028 tempVal == RADIO_TECH_EVDO_0 ||
4029 tempVal == RADIO_TECH_EVDO_A ||
4030 tempVal == RADIO_TECH_EVDO_B) { //3G
4031 sprintf(respStr,"%s radioTech is 3G!",respStr);
4032#ifdef TELEMATIC_5G_SUPPORT
4033 } else if(tempVal == RADIO_TECH_NR) { //5G
4034 sprintf(respStr,"%s radioTech is 5G!",respStr);
4035#endif
4036 } else { //unknown
4037 sprintf(respStr,"%s radioTech is unkown!",respStr);
4038 }
4039 }
4040 sprintf(respStr,"%s\n",respStr);
4041 break;
4042 }
4043 case RIL_REQUEST_DATA_REGISTRATION_STATE:
4044 {
4045 char **p_cur = (char **) response;
4046 int numStrings = responselen / sizeof(char *);
4047 update_reg_data_service_state(RIL_REQUEST_DATA_REGISTRATION_STATE, (char *)p_cur[0], socket_id, pRI->token);
4048 if(numStrings >=4 && p_cur[3] != NULL)
4049 {
4050 update_reg_data_radio_tech(RIL_REQUEST_DATA_REGISTRATION_STATE, atoi((char *)p_cur[3]), socket_id, pRI->token);
4051 }
llaaca09b2022-03-14 16:14:28 +08004052 /*Warren add for SZZT 2021/11/14 start*/
4053 lynqAtRespWatingEvent();
4054 /*Warren add for SZZT 2021/11/14 end*/
lh7b0674a2022-01-10 00:34:35 -08004055 break;
4056 }
4057 case RIL_REQUEST_GET_CURRENT_CALLS:
4058 {
4059 update_call_state(response,responselen, socket_id);
4060 int num = responselen / sizeof(RIL_Call *);
4061 speechonoff(num);
4062 printf("%s\n", printBuf);
4063 break;
4064 }
4065 case RIL_REQUEST_SETUP_DATA_CALL:
4066 {
4067 int num = responselen / sizeof(RIL_Data_Call_Response_v6);
4068 RIL_Data_Call_Response_v6 *p_cur = (RIL_Data_Call_Response_v6 *) response;
4069 updateRILDataCallResponsev6(num,p_cur);
4070 break;
4071 }
q.huang3c4b3252022-04-28 18:24:48 +08004072 case RIL_REQUEST_ANSWER:
4073 {
4074 if(e==RIL_E_SUCCESS)
4075 {
4076 resetMute();
4077 }
4078 break;
4079 }
lh7b0674a2022-01-10 00:34:35 -08004080 case RIL_REQUEST_GET_SIM_STATUS:
4081 {
4082 if (responselen == sizeof (RIL_CardStatus_v6)) {
4083 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
4084 updateCardStatusV6(p_cur, socket_id);
4085 }
4086 break;
4087 }
4088 case RIL_REQUEST_VOICE_RADIO_TECH:
4089 {
4090 update_voice_radio_tech(((int *) response)[0], socket_id);
4091 break;
4092 }
4093 case RIL_REQUEST_GET_RADIO_CAPABILITY:
4094 {
4095 update_radio_capa((RIL_RadioCapability *) response, socket_id);
4096 break;
4097 }
4098 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE:
4099 {
4100 update_preferred_network_type(((int *) response)[0], socket_id);
4101 break;
4102 }
4103 case RIL_REQUEST_DELETE_SMS_ON_SIM:
4104 {
4105 setSimSmsStorageFullFlag(false);
4106 break;
4107 }
4108 case RIL_REQUEST_SEND_SMS:
4109 case RIL_REQUEST_SEND_SMS_EXPECT_MORE:
4110 case RIL_REQUEST_IMS_SEND_SMS:
4111 {
4112 //for auto save sms to sim
4113 sendStatusWriteSmsToSim(socket_id);
4114 break;
4115 }
4116 case RIL_REQUEST_ECALL_SET_REGISTRATION_STATE:
4117 {
4118 int numInts = responselen / sizeof(int);
4119 if(numInts > 0) {
4120 int *p_int = (int *) response;
4121 RLOGD("RIL_REQUEST_ECALL_SET_REGISTRATION_STATE: %d", p_int[0]);
4122 if(p_int[0] == ECALL_DEREGISTRATION)
4123 {
4124 gostSetInNeedRegister(true);
4125 }
4126
4127 } else {
4128 RLOGD("RIL_REQUEST_ECALL_SET_REGISTRATION_STATE response numInts: %d", numInts);
4129 }
4130 break;
4131 }
llaaca09b2022-03-14 16:14:28 +08004132 case RIL_REQUEST_OEM_HOOK_RAW:
4133 {
4134 if(pRI->lynqEvent==1)
4135 {
4136 /*lei add for at+cgmr*/
4137 if(strstr((const char*)response,"+CGMR")){
4138 lynq_get_version();
4139 }
4140 /*lei add for at+cgmr*/
4141 int n = write(ttyGS3_fd,response,responselen);
4142 if(n<0)
4143 {
4144 perror("lynq resp write:");
4145 }
4146 printf("n = %d\n",n);
4147 }
ll2d5dbd12022-05-19 14:48:44 +08004148 /*lei add only for factory test 2022/5/19*/
4149 if(pRI->lynqEvent==3)
4150 {
4151 /*lei add for at+cgir*/
4152 if(strstr((const char*)response,"+CGMR")){
4153 lynq_get_inside_version();
4154 }
4155 /*lei add for at+cgir*/
4156 parse_inside_version(response);
4157 int n = write(ttyGS3_fd,response,responselen);
4158 if(n<0)
4159 {
4160 perror("lynq resp write:");
4161 }
4162 printf("n = %d\n",n);
4163 }
llaaca09b2022-03-14 16:14:28 +08004164 }
lh7b0674a2022-01-10 00:34:35 -08004165 default:
4166 break;
4167 }
4168 }
llaaca09b2022-03-14 16:14:28 +08004169 /*Warren add for FAW platform 2021/10/8 start*/
4170 else
4171 {
4172 if(pRI->lynqEvent==1)
4173 {
4174 char eBuf[64] = {0};
4175 bzero(eBuf, 64);
4176 if(e==RIL_E_SUCCESS)
4177 {
4178 sprintf(eBuf,"\nOK\n\0");
4179 }
4180 else
4181 {
4182 sprintf(eBuf,"\nCME ERROR: %d\n\0",e);
4183 }
4184 int n = write(ttyGS3_fd,eBuf,strlen(eBuf));
4185 if(n<0)
4186 {
4187 perror("lynq resp write:");
4188 }
4189 //printf("n = %d\n",n);
4190 }
4191 }
4192 /*Warren add for FAW platform 2021/10/8 start*/
lh7b0674a2022-01-10 00:34:35 -08004193 if (e != RIL_E_SUCCESS) {
4194 appendPrintBuf("%s fails by %s", printBuf, failCauseToString(e));
4195 }
4196
4197 if ((pRI->token & RIL_TOKEN_MARK) == RIL_TOKEN_MARK) {
4198 printf("%s\n", printBuf ? printBuf : "unkonwn");
4199 } else if (((pRI->pCI->requestNumber == RIL_REQUEST_DEVICE_IDENTITY)
4200 || (pRI->pCI->requestNumber == RIL_REQUEST_OEM_HOOK_RAW))
4201 && (pRI->token & INIT_TOKEN_MARK) == INIT_TOKEN_MARK) {
4202 printf("%s\n", printBuf ? printBuf : "unkonwn");
4203 if (pRI->pCI->requestNumber == RIL_REQUEST_DEVICE_IDENTITY) {
4204 if (e != RIL_E_SUCCESS) {
4205 printf(
4206 "*******************************************\n*** NOTICE: IMEI don't wirite in slot%d ***\n*******************************************\n",
4207 socket_id);
4208 }
4209 }
4210 }
4211
4212#if 0
4213 if (fd < 0) {
4214 RLOGD ("RIL onRequestComplete: Command channel closed");
4215 }
4216#endif
4217 LYNQ_RIL_respSocket(p,t);
4218 sendResponse(p, socket_id);
4219 }
4220#if ATCI_ENABLE_RESPONSE
4221 if((pRI->token & ATCI_TOKEN_MARK) == ATCI_TOKEN_MARK) //ATCI_Rsp
4222 {
4223 int error;
4224 memset(Respose_buf, 0, sizeof(Respose_buf));
4225 if(e != RIL_E_SUCCESS)
4226 error = 1; //fail
4227 else
4228 error = 0; //ok
4229 ATCIResponse(pRI->token,error,Respose_buf, pRI->pCI->requestNumber);
4230 }
4231#endif
4232 if(pRI->pCI->requestNumber == RIL_REQUEST_VOICE_REGISTRATION_STATE && (pRI->token & RIL_TOKEN_MARK) == RIL_TOKEN_MARK){
4233 int len_s = sendto(server_socket_fd,respStr,strlen(respStr),0,(struct sockaddr *)&client_addr,sizeof(client_addr));
4234 }
4235 RLOGW("RIL_onRequestComplete %s end!",requestToString(pRI->pCI->requestNumber));
4236 if((pRI->token&BLOCK_MARK) == BLOCK_MARK) {
4237 //need wakeup dispatch function
4238 BLOCK_LOCK();
4239 wakeup_token = pRI->token;
4240 RLOGW("RIL_onRequestComplete wakeup, token is %x!",wakeup_token);
4241 BLOCK_WAKEUP();
4242 BLOCK_UNLOCK();
4243 }
4244 switch (pRI->pCI->requestNumber) {
4245 case RIL_REQUEST_RADIO_POWER:
4246 speciaRequest_wakeup();
4247 break;
4248 case RIL_REQUEST_SET_RADIO_CAPABILITY:
4249 {
4250 if(utils::is_support_dsds()) {
4251 for (int id = 0; id < SIM_COUNT; id++) {
4252 ARspRequest(RIL_REQUEST_ALLOW_DATA, (RIL_SOCKET_ID)id);
4253 }
4254 }
4255 break;
4256 }
4257 case RIL_REQUEST_ALLOW_DATA:
4258 {
4259 if(utils::is_support_dsds() && isNeedConnect() && get_default_sim_data() == socket_id) {
xja1c30b82022-01-25 16:13:48 +08004260 RLOGD("wait and recreate PDN with sim switch");
lh7b0674a2022-01-10 00:34:35 -08004261 resetConnect();
xja1c30b82022-01-25 16:13:48 +08004262 sleep(WAIT_TIME_FOR_SIM_SWITCH);
lh7b0674a2022-01-10 00:34:35 -08004263 setupDataCall(0, NULL, (RIL_SOCKET_ID)0, NULL);
4264 }
4265 break;
4266 }
4267#ifdef KEEP_ALIVE
4268 case RIL_REQUEST_START_KEEPALIVE_PRO:
4269 case RIL_REQUEST_STOP_KEEPALIVE_PRO:
4270 {
4271 handleKeepAliveResponse(pRI->pCI->requestNumber, response, responselen, socket_id, (e != RIL_E_SUCCESS));
4272 break;
4273 }
4274#endif /*KEEP_ALIVE*/
4275 case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC:
4276 {
4277 if(e == RIL_E_SUCCESS)
4278 {
4279 gostSetInNeedRegister(false);
4280 gostFastEcallFlgSet(false);
4281 }
4282 else
4283 {
4284 gostNetworkSelectionSet(socket_id);
4285 }
4286 break;
4287 }
4288 default:
4289 break;
4290 }
4291done:
4292 free(pRI);
4293}
4294
4295
4296static void
4297grabPartialWakeLock() {
4298 acquire_wake_lock(PARTIAL_WAKE_LOCK, ANDROID_WAKE_LOCK_NAME);
4299}
4300
4301static void
4302releaseWakeLock() {
4303 release_wake_lock(ANDROID_WAKE_LOCK_NAME);
4304}
4305
4306
4307static int
4308decodeVoiceRadioTechnology (RIL_RadioState radioState) {
4309 switch (radioState) {
4310 case RADIO_STATE_SIM_NOT_READY:
4311 case RADIO_STATE_SIM_LOCKED_OR_ABSENT:
4312 case RADIO_STATE_SIM_READY:
4313 return RADIO_TECH_UMTS;
4314
4315 case RADIO_STATE_RUIM_NOT_READY:
4316 case RADIO_STATE_RUIM_READY:
4317 case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:
4318 case RADIO_STATE_NV_NOT_READY:
4319 case RADIO_STATE_NV_READY:
4320 return RADIO_TECH_1xRTT;
4321
4322 default:
4323 RLOGD("decodeVoiceRadioTechnology: Invoked with incorrect RadioState");
4324 return -1;
4325 }
4326}
4327
4328static int
4329decodeCdmaSubscriptionSource (RIL_RadioState radioState) {
4330 switch (radioState) {
4331 case RADIO_STATE_SIM_NOT_READY:
4332 case RADIO_STATE_SIM_LOCKED_OR_ABSENT:
4333 case RADIO_STATE_SIM_READY:
4334 case RADIO_STATE_RUIM_NOT_READY:
4335 case RADIO_STATE_RUIM_READY:
4336 case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:
4337 return CDMA_SUBSCRIPTION_SOURCE_RUIM_SIM;
4338
4339 case RADIO_STATE_NV_NOT_READY:
4340 case RADIO_STATE_NV_READY:
4341 return CDMA_SUBSCRIPTION_SOURCE_NV;
4342
4343 default:
4344 RLOGD("decodeCdmaSubscriptionSource: Invoked with incorrect RadioState");
4345 return -1;
4346 }
4347}
4348
4349static int
4350decodeSimStatus (RIL_RadioState radioState) {
4351 switch (radioState) {
4352 case RADIO_STATE_SIM_NOT_READY:
4353 case RADIO_STATE_RUIM_NOT_READY:
4354 case RADIO_STATE_NV_NOT_READY:
4355 case RADIO_STATE_NV_READY:
4356 return -1;
4357 case RADIO_STATE_SIM_LOCKED_OR_ABSENT:
4358 case RADIO_STATE_SIM_READY:
4359 case RADIO_STATE_RUIM_READY:
4360 case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:
4361 return radioState;
4362 default:
4363 RLOGD("decodeSimStatus: Invoked with incorrect RadioState");
4364 return -1;
4365 }
4366}
4367
4368static bool is3gpp2(int radioTech) {
4369 switch (radioTech) {
4370 case RADIO_TECH_IS95A:
4371 case RADIO_TECH_IS95B:
4372 case RADIO_TECH_1xRTT:
4373 case RADIO_TECH_EVDO_0:
4374 case RADIO_TECH_EVDO_A:
4375 case RADIO_TECH_EVDO_B:
4376 case RADIO_TECH_EHRPD:
4377 return true;
4378 default:
4379 return false;
4380 }
4381}
4382
4383/* If RIL sends SIM states or RUIM states, store the voice radio
4384 * technology and subscription source information so that they can be
4385 * returned when telephony framework requests them
4386 */
4387static RIL_RadioState
4388processRadioState(RIL_RadioState newRadioState, RIL_SOCKET_ID socket_id) {
4389
4390 if((newRadioState > RADIO_STATE_UNAVAILABLE) && (newRadioState < RADIO_STATE_ON)) {
4391 int newVoiceRadioTech;
4392 int newCdmaSubscriptionSource;
4393 int newSimStatus;
4394
4395 /* This is old RIL. Decode Subscription source and Voice Radio Technology
4396 from Radio State and send change notifications if there has been a change */
4397 newVoiceRadioTech = decodeVoiceRadioTechnology(newRadioState);
4398 if(newVoiceRadioTech != voiceRadioTech) {
4399 voiceRadioTech = newVoiceRadioTech;
4400 RIL_UNSOL_RESPONSE(RIL_UNSOL_VOICE_RADIO_TECH_CHANGED,
4401 &voiceRadioTech, sizeof(voiceRadioTech), socket_id);
4402 }
4403 if(is3gpp2(newVoiceRadioTech)) {
4404 newCdmaSubscriptionSource = decodeCdmaSubscriptionSource(newRadioState);
4405 if(newCdmaSubscriptionSource != cdmaSubscriptionSource) {
4406 cdmaSubscriptionSource = newCdmaSubscriptionSource;
4407 RIL_UNSOL_RESPONSE(RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED,
4408 &cdmaSubscriptionSource, sizeof(cdmaSubscriptionSource), socket_id);
4409 }
4410 }
4411 newSimStatus = decodeSimStatus(newRadioState);
4412 if(newSimStatus != simRuimStatus) {
4413 simRuimStatus = newSimStatus;
4414 RIL_UNSOL_RESPONSE(RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, NULL, 0, socket_id);
4415 }
4416
4417 /* Send RADIO_ON to telephony */
4418 newRadioState = RADIO_STATE_ON;
4419 }
4420
4421 return newRadioState;
4422}
4423
4424
4425#if defined(ANDROID_MULTI_SIM)
4426extern "C"
4427void RIL_onUnsolicitedResponse(int unsolResponse, const void *data,
4428 size_t datalen, RIL_SOCKET_ID socket_id)
4429#else
4430extern "C"
4431void RIL_onUnsolicitedResponse(int unsolResponse, const void *data,
4432 size_t datalen)
4433#endif
4434{
4435 int unsolResponseIndex;
4436 int ret;
4437 int64_t timeReceived = 0;
4438 bool shouldScheduleTimeout = false;
4439 RIL_RadioState newState;
lhf6eea122022-01-20 19:32:14 -08004440 int temp = 0;
4441 char *tempChar=NULL;
lh7b0674a2022-01-10 00:34:35 -08004442 RIL_SOCKET_ID soc_id = (RIL_SOCKET_ID)Phone_utils::get_enable_sim_for_dsss();
4443
4444#if defined(ANDROID_MULTI_SIM)
4445 soc_id = socket_id;
4446#endif
4447
4448 handle_wakeup_reason(unsolResponse);
4449
4450 if (s_registerCalled == 0) {
4451 // Ignore RIL_onUnsolicitedResponse before RIL_register
4452 RLOGW("RIL_onUnsolicitedResponse called before RIL_register");
4453 return;
4454 }
4455 if(onSupports(unsolResponse) == 0)
4456 {
4457 RLOGE("unsupported unsolicited response code %d", unsolResponse);
4458 return;
4459 }
4460
4461#ifdef TARGET_PLATFORM_MT2635
4462 //Reset modem, exit DemoApp.
4463 if(unsolResponse==RIL_UNSOL_MAL_RESTART ) {
4464 RLOGD("Modem Reset, Exit DemoApp!");
4465 printf("Modem Reset, Exit DemoApp!\n");
4466 speechonoff(0);
4467 mixer_reset_set(1);
4468 com_quit(0,NULL,soc_id,NULL);
4469 }
4470#endif
4471 if (unsolResponse < RIL_UNSOL_VENDOR_BASE) {
4472 unsolResponseIndex = unsolResponse - RIL_UNSOL_RESPONSE_BASE;
4473 }
4474#if 0
4475 WakeType wakeType;
4476 if (unsolResponse >= RIL_UNSOL_VENDOR_BASE) {
4477 //unsolResponseIndex = unsolResponse - RIL_UNSOL_VENDOR_BASE;
4478 wakeType = WAKE_PARTIAL;
4479 } else {
4480 unsolResponseIndex = unsolResponse - RIL_UNSOL_RESPONSE_BASE;
4481 wakeType = s_unsolResponses[unsolResponseIndex].wakeType;
4482 }
4483
4484 // Grab a wake lock if needed for this reponse,
4485 // as we exit we'll either release it immediately
4486 // or set a timer to release it later.
4487 switch (wakeType) {
4488 case WAKE_PARTIAL:
4489 grabPartialWakeLock();
4490 shouldScheduleTimeout = false;
4491 break;
4492
4493 case DONT_WAKE:
4494 default:
4495 // No wake lock is grabed so don't set timeout
4496 shouldScheduleTimeout = false;
4497 break;
4498 }
4499
4500 // Mark the time this was received, doing this
4501 // after grabing the wakelock incase getting
4502 // the elapsedRealTime might cause us to goto
4503 // sleep.
4504 if (unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) {
4505 timeReceived = elapsedRealtime();
4506 }
4507#endif
4508 appendPrintBuf("[UNSL][SIM%d]< %s", soc_id, requestToString(unsolResponse));
4509
4510 Parcel p;
lh7b0674a2022-01-10 00:34:35 -08004511 p.writeInt32 (RESPONSE_UNSOLICITED);
4512 p.writeInt32 (unsolResponse);
4513 /*Warren add for t800 ril service 2021/12/16 start*/
4514 p.writeInt32 (soc_id);
4515 /*Warren add for t800 ril service 2021/12/16 end*/
4516 if (unsolResponse >= RIL_UNSOL_VENDOR_BASE) {
4517 UnsolResponseInfo* unsolRspInof = find_mtk_unsol_command(unsolResponse);
4518 if(unsolRspInof == NULL){
4519 RLOGE("no unsolicited response function -- %d", unsolResponse);
4520 return;
4521 } else {
4522 ret = unsolRspInof->responseFunction(p,const_cast<void*>(data),datalen);
4523 }
4524 } else {
4525 ret = s_unsolResponses[unsolResponseIndex].responseFunction(p, const_cast<void*>(data), datalen);
4526 }
4527 if (ret != 0) {
4528 // Problem with the response. Don't continue;
4529 goto error_exit;
4530 }
4531
4532 // some things get more payload
4533 switch(unsolResponse) {
4534 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED:
4535 newState = CALL_ONSTATEREQUEST(soc_id);
4536 p.writeInt32(newState);
4537 appendPrintBuf("%s {%s}", printBuf,
4538 radioStateToString(CALL_ONSTATEREQUEST(soc_id)));
4539 break;
4540
4541#if 0
4542 case RIL_UNSOL_NITZ_TIME_RECEIVED:
4543 // Store the time that this was received so the
4544 // handler of this message can account for
4545 // the time it takes to arrive and process. In
4546 // particular the system has been known to sleep
4547 // before this message can be processed.
4548 p.writeInt64(timeReceived);
4549 break;
4550#endif
4551 }
4552
4553#if VDBG
4554 RLOGI("%s UNSOLICITED: %s length:%d", rilSocketIdToString(soc_id), requestToString(unsolResponse), p.dataSize());
4555#endif
lhf6eea122022-01-20 19:32:14 -08004556 //ret = sendResponse(p, soc_id);
lh7b0674a2022-01-10 00:34:35 -08004557
4558//unsol trigger other things.
4559 switch(unsolResponse) {
4560 //case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED:
4561 //ARspRequest(RIL_REQUEST_GET_CURRENT_CALLS, soc_id);
4562 //break;
4563 case RIL_UNSOL_CALL_RING:
4564 callRing(soc_id);
4565 break;
4566 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED:
4567 updateIccCardState(soc_id);
4568 break;
4569 case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED:
4570 getVoiceAndDataRegistrationState(soc_id);
4571 break;
4572 case RIL_UNSOL_RESPONSE_NEW_SMS:
lhf6eea122022-01-20 19:32:14 -08004573 responseNewSMS((const char*)data, datalen,soc_id,unsolResponse,p);
lh7b0674a2022-01-10 00:34:35 -08004574 unreadStatusWriteSMSToSim((const char*)data, datalen, soc_id);
4575 sendSMSACK(soc_id);
4576 break;
4577 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS:
4578 {
4579 RLOGD("Receive RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS data: %s, length: %d", (char*)data, datalen);
4580 break;
4581 }
4582 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT:
4583 sendSMSACK(soc_id);
4584 break;
4585 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED:
4586 updateRadioStatus(newState,soc_id);
4587 break;
4588 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS:
4589 {
4590 ARspRequest(RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE, soc_id);
4591 break;
4592 }
4593 case RIL_UNSOL_STK_PROACTIVE_COMMAND:
4594 {
4595 RLOGD("STk proactive command raw date: %s, length: %d", (char*)data, datalen);
4596 handleStkCommand((char*)data, datalen,soc_id);
4597 break;
4598 }
4599 case RIL_UNSOL_RIL_CONNECTED:
4600 {
4601 RLOGD("vendor-ril socket(%d) connect start", soc_id);
4602 pthread_mutex_lock(&s_InitMutex);
4603 s_isConnected[soc_id] = 1;
4604 if(utils::is_support_dsds()) {
4605 if (s_isConnected[0] == 1 && s_isConnected[1] == 1) {
4606 pthread_cond_broadcast(&s_InitCond);
4607 }
4608 } else {
4609 if (s_isConnected[0] == 1 || s_isConnected[1] == 1) {
4610 pthread_cond_broadcast(&s_InitCond);
4611 }
4612 }
4613 pthread_mutex_unlock(&s_InitMutex);
4614 RLOGD("vendor-ril socket(%d) connect end", soc_id);
4615 break;
4616 }
4617 case RIL_UNSOL_TX_POWER: {
4618 int *p_int = (int *) data;
4619 int numInts = datalen / sizeof(int);
4620 if (numInts > 1) {
4621 m_RfDesense->emOemHookRaw(p_int[1],soc_id);
4622 } else {
4623 m_RfDesense->emOemHookRaw(0, soc_id);
4624 }
4625 break;
4626 }
4627 case RIL_UNSOL_NETWORK_INFO: {
4628 if(networkCb){
4629 //TBD
4630 char **p_cur = (char **) data;
4631 char *ctype = (char*)p_cur[0];
4632 int type = atoi(ctype);
4633 char *data = (char*)p_cur[1];
4634 RLOGD("ctype %s type %d data %s\n",ctype,type,data);
4635 networkCb(type,data);
4636 }
4637 break;
4638 }
4639 case RIL_UNSOL_DATA_CALL_LIST_CHANGED:
4640 {
4641 int num = datalen / sizeof(RIL_Data_Call_Response_v6);
4642 RIL_Data_Call_Response_v6 *p_cur = (RIL_Data_Call_Response_v6 *) data;
4643 handleUnsolDataCalllistChange(num,p_cur);
4644 break;
4645 }
4646 case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED:
4647 {
4648 update_voice_radio_tech(((int *) data)[0], soc_id);
4649 break;
4650 }
4651 case RIL_UNSOL_RADIO_CAPABILITY:
4652 {
4653 update_radio_capa((RIL_RadioCapability *) data, soc_id);
4654 //Proxy_controller::getInstance()->handle_message_notify((RIL_RadioCapability *) data, soc_id);
4655 break;
4656 }
4657 case RIL_UNSOL_CDMA_CALL_WAITING:
4658 {
4659 autoAnswerForCdma(soc_id);
4660 break;
4661 }
4662 case RIL_UNSOL_NITZ_TIME_RECEIVED:
4663 {
4664 updateSystemTime(data, datalen);
4665 break;
4666 }
4667 case RIL_UNSOL_ECALL_INDICATIONS:
4668 {
4669 handleEcallIndication(data, datalen, soc_id);
4670 break;
4671 }
4672#ifdef KEEP_ALIVE
4673 case RIL_UNSOL_KEEPALIVE_STATUS_PRO:
4674 {
4675 handleKeepAliveResponse(unsolResponse, data, datalen, soc_id, false);
4676 break;
4677 }
4678#endif /*KEEP_ALIVE*/
4679 case RIL_UNSOL_SIM_SMS_STORAGE_FULL:
4680 {
4681 setSimSmsStorageFullFlag(true);
4682 break;
4683 }
4684 case RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR:
4685 {
4686 handleUnsolSipCallProgressInd(data, datalen);
4687 break;
4688 }
4689 case RIL_UNSOL_ECC_NUM:
4690 {
4691 handleECCNumResponse(data, datalen,soc_id);
4692 break;
4693 }
4694 case RIL_UNSOL_CALL_INFO_INDICATION:
4695 {
4696 handleUnsolCallInfoInd(data, datalen, soc_id);
4697 break;
4698 }
4699 case RIL_UNSOL_RINGBACK_TONE:
4700 {
4701 handleRingbackTone(data, datalen, soc_id);
4702 break;
4703 }
4704 default:
4705 break;
4706 }
lhf6eea122022-01-20 19:32:14 -08004707 /*Warren add for t800 ril service 2021/12/16 start*/
4708 ret = LYNQ_RIL_urcBroadcast(p);
4709 /*Warren add for t800 ril service 2021/12/16 end*/
lh7b0674a2022-01-10 00:34:35 -08004710#if 0
4711 if (ret != 0 && unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) {
4712
4713 // Unfortunately, NITZ time is not poll/update like everything
4714 // else in the system. So, if the upstream client isn't connected,
4715 // keep a copy of the last NITZ response (with receive time noted
4716 // above) around so we can deliver it when it is connected
4717
4718 if (s_lastNITZTimeData != NULL) {
4719 free (s_lastNITZTimeData);
4720 s_lastNITZTimeData = NULL;
4721 }
4722
4723 s_lastNITZTimeData = malloc(p.dataSize());
4724 s_lastNITZTimeDataSize = p.dataSize();
4725 memcpy(s_lastNITZTimeData, p.data(), p.dataSize());
4726 }
4727
4728#endif
4729 // Normal exit
4730 return;
4731
4732error_exit:
4733 RLOGD("unsol handle fail");
4734#if 0
4735 if (shouldScheduleTimeout) {
4736 releaseWakeLock();
4737 }
4738#endif
4739}
4740
4741extern "C" void
4742RIL_requestTimedCallback (RIL_TimedCallback callback, void *param,
4743 const struct timeval *relativeTime) {
4744}
4745
4746const char *
4747failCauseToString(RIL_Errno e) {
4748 switch(e) {
4749 case RIL_E_SUCCESS: return "E_SUCCESS";
4750 case RIL_E_RADIO_NOT_AVAILABLE: return "E_RADIO_NOT_AVAILABLE";
4751 case RIL_E_GENERIC_FAILURE: return "E_GENERIC_FAILURE";
4752 case RIL_E_PASSWORD_INCORRECT: return "E_PASSWORD_INCORRECT";
4753 case RIL_E_SIM_PIN2: return "E_SIM_PIN2";
4754 case RIL_E_SIM_PUK2: return "E_SIM_PUK2";
4755 case RIL_E_REQUEST_NOT_SUPPORTED: return "E_REQUEST_NOT_SUPPORTED";
4756 case RIL_E_CANCELLED: return "E_CANCELLED";
4757 case RIL_E_OP_NOT_ALLOWED_DURING_VOICE_CALL: return "E_OP_NOT_ALLOWED_DURING_VOICE_CALL";
4758 case RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW: return "E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW";
4759 case RIL_E_SMS_SEND_FAIL_RETRY: return "E_SMS_SEND_FAIL_RETRY";
4760 case RIL_E_SIM_ABSENT:return "E_SIM_ABSENT";
4761 case RIL_E_ILLEGAL_SIM_OR_ME:return "E_ILLEGAL_SIM_OR_ME";
4762#ifdef FEATURE_MULTIMODE_ANDROID
4763 case RIL_E_SUBSCRIPTION_NOT_AVAILABLE:return "E_SUBSCRIPTION_NOT_AVAILABLE";
4764 case RIL_E_MODE_NOT_SUPPORTED:return "E_MODE_NOT_SUPPORTED";
4765#endif
4766 case RIL_E_SIM_MEM_FULL: return "E_SIM_MEM_FULL";
4767 default: return "<unknown error>";
4768 }
4769}
4770
4771const char *
4772callStateToString(RIL_CallState s) {
4773 switch(s) {
4774 case RIL_CALL_ACTIVE : return "ACTIVE";
4775 case RIL_CALL_HOLDING: return "HOLDING";
4776 case RIL_CALL_DIALING: return "DIALING";
4777 case RIL_CALL_ALERTING: return "ALERTING";
4778 case RIL_CALL_INCOMING: return "INCOMING";
4779 case RIL_CALL_WAITING: return "WAITING";
4780 default: return "<unknown state>";
4781 }
4782}
4783const char *lynq_requset_to_string(int request)
4784{
4785 switch(request) {
4786 case RIL_REQUEST_GET_SIM_STATUS: return "RIL_REQUEST_GET_SIM_STATUS";
4787 case RIL_REQUEST_ENTER_SIM_PIN: return "RIL_REQUEST_ENTER_SIM_PIN";
4788 case RIL_REQUEST_ENTER_SIM_PUK: return "RIL_REQUEST_ENTER_SIM_PUK";
4789 case RIL_REQUEST_ENTER_SIM_PIN2: return "RIL_REQUEST_ENTER_SIM_PIN2";
4790 case RIL_REQUEST_ENTER_SIM_PUK2: return "RIL_REQUEST_ENTER_SIM_PUK2";
4791 case RIL_REQUEST_CHANGE_SIM_PIN: return "RIL_REQUEST_CHANGE_SIM_PIN";
4792 case RIL_REQUEST_CHANGE_SIM_PIN2: return "RIL_REQUEST_CHANGE_SIM_PIN2";
4793 case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: return "RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION";
4794 case RIL_REQUEST_GET_CURRENT_CALLS: return "RIL_REQUEST_GET_CURRENT_CALLS";
4795 case RIL_REQUEST_DIAL: return "RIL_REQUEST_DIAL";
4796 case RIL_REQUEST_GET_IMSI: return "RIL_REQUEST_GET_IMSI";
4797 case RIL_REQUEST_HANGUP: return "RIL_REQUEST_HANGUP";
4798 case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: return "RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND";
4799 case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: return "RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND";
4800 case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: return "RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE";
4801 case RIL_REQUEST_CONFERENCE: return "RIL_REQUEST_CONFERENCE";
4802 case RIL_REQUEST_UDUB: return "RIL_REQUEST_UDUB";
4803 case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: return "RIL_REQUEST_LAST_CALL_FAIL_CAUSE";
4804 case RIL_REQUEST_SIGNAL_STRENGTH: return "RIL_REQUEST_SIGNAL_STRENGTH";
4805 case RIL_REQUEST_VOICE_REGISTRATION_STATE: return "RIL_REQUEST_VOICE_REGISTRATION_STATE";
4806 case RIL_REQUEST_DATA_REGISTRATION_STATE: return "RIL_REQUEST_DATA_REGISTRATION_STATE";
4807 case RIL_REQUEST_OPERATOR: return "RIL_REQUEST_OPERATOR";
4808 case RIL_REQUEST_RADIO_POWER: return "RIL_REQUEST_RADIO_POWER";
4809 case RIL_REQUEST_DTMF: return "RIL_REQUEST_DTMF";
4810 case RIL_REQUEST_SEND_SMS: return "RIL_REQUEST_SEND_SMS";
4811 case RIL_REQUEST_SEND_SMS_EXPECT_MORE: return "RIL_REQUEST_SEND_SMS_EXPECT_MORE";
4812 case RIL_REQUEST_SETUP_DATA_CALL: return "RIL_REQUEST_SETUP_DATA_CALL";
4813 case RIL_REQUEST_SIM_IO: return "RIL_REQUEST_SIM_IO";
4814 case RIL_REQUEST_SEND_USSD: return "RIL_REQUEST_SEND_USSD";
4815 case RIL_REQUEST_CANCEL_USSD: return "RIL_REQUEST_CANCEL_USSD";
4816 case RIL_REQUEST_GET_CLIR: return "RIL_REQUEST_GET_CLIR";
4817 case RIL_REQUEST_SET_CLIR: return "RIL_REQUEST_SET_CLIR";
4818 case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: return "RIL_REQUEST_QUERY_CALL_FORWARD_STATUS";
4819 case RIL_REQUEST_SET_CALL_FORWARD: return "RIL_REQUEST_SET_CALL_FORWARD";
4820 case RIL_REQUEST_QUERY_CALL_WAITING: return "RIL_REQUEST_QUERY_CALL_WAITING";
4821 case RIL_REQUEST_SET_CALL_WAITING: return "RIL_REQUEST_SET_CALL_WAITING";
4822 case RIL_REQUEST_SMS_ACKNOWLEDGE: return "RIL_REQUEST_SMS_ACKNOWLEDGE";
4823 case RIL_REQUEST_GET_IMEI: return "RIL_REQUEST_GET_IMEI";
4824 case RIL_REQUEST_GET_IMEISV: return "RIL_REQUEST_GET_IMEISV";
4825 case RIL_REQUEST_ANSWER: return "RIL_REQUEST_ANSWER";
4826 case RIL_REQUEST_DEACTIVATE_DATA_CALL: return "RIL_REQUEST_DEACTIVATE_DATA_CALL";
4827 case RIL_REQUEST_QUERY_FACILITY_LOCK: return "RIL_REQUEST_QUERY_FACILITY_LOCK";
4828 case RIL_REQUEST_SET_FACILITY_LOCK: return "RIL_REQUEST_SET_FACILITY_LOCK";
4829 case RIL_REQUEST_CHANGE_BARRING_PASSWORD: return "RIL_REQUEST_CHANGE_BARRING_PASSWORD";
4830 case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: return "RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE";
4831 case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: return "RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC";
4832 case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: return "RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL";
4833 case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : return "RIL_REQUEST_QUERY_AVAILABLE_NETWORKS";
4834 case RIL_REQUEST_DTMF_START: return "RIL_REQUEST_DTMF_START";
4835 case RIL_REQUEST_DTMF_STOP: return "RIL_REQUEST_DTMF_STOP";
4836 case RIL_REQUEST_BASEBAND_VERSION: return "RIL_REQUEST_BASEBAND_VERSION";
4837 case RIL_REQUEST_SEPARATE_CONNECTION: return "RIL_REQUEST_SEPARATE_CONNECTION";
4838 case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: return "RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE";
4839 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: return "RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE";
4840 case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: return "RIL_REQUEST_GET_NEIGHBORING_CELL_IDS";
4841 case RIL_REQUEST_SET_MUTE: return "RIL_REQUEST_SET_MUTE";
4842 case RIL_REQUEST_GET_MUTE: return "RIL_REQUEST_GET_MUTE";
4843 case RIL_REQUEST_QUERY_CLIP: return "RIL_REQUEST_QUERY_CLIP";
4844 case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: return "RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE";
4845 case RIL_REQUEST_DATA_CALL_LIST: return "RIL_REQUEST_DATA_CALL_LIST";
4846 case RIL_REQUEST_RESET_RADIO: return "RIL_REQUEST_RESET_RADIO";
4847 case RIL_REQUEST_OEM_HOOK_RAW: return "RIL_REQUEST_OEM_HOOK_RAW";
4848 case RIL_REQUEST_OEM_HOOK_STRINGS: return "RIL_REQUEST_OEM_HOOK_STRINGS";
4849 case RIL_REQUEST_SET_BAND_MODE: return "RIL_REQUEST_SET_BAND_MODE";
4850 case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: return "RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE";
4851 case RIL_REQUEST_STK_GET_PROFILE: return "RIL_REQUEST_STK_GET_PROFILE";
4852 case RIL_REQUEST_STK_SET_PROFILE: return "RIL_REQUEST_STK_SET_PROFILE";
4853 case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: return "RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND";
4854 case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: return "RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE";
4855 case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: return "RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM";
4856 case RIL_REQUEST_SCREEN_STATE: return "RIL_REQUEST_SCREEN_STATE";
4857 case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: return "RIL_REQUEST_EXPLICIT_CALL_TRANSFER";
4858 case RIL_REQUEST_SET_LOCATION_UPDATES: return "RIL_REQUEST_SET_LOCATION_UPDATES";
4859 case RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE:return"RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE";
4860 case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE:return"RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE";
4861 case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE:return"RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE";
4862 case RIL_REQUEST_SET_TTY_MODE:return"RIL_REQUEST_SET_TTY_MODE";
4863 case RIL_REQUEST_QUERY_TTY_MODE:return"RIL_REQUEST_QUERY_TTY_MODE";
4864 case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE:return"RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE";
4865 case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE:return"RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE";
4866 case RIL_REQUEST_CDMA_FLASH:return"RIL_REQUEST_CDMA_FLASH";
4867 case RIL_REQUEST_CDMA_BURST_DTMF:return"RIL_REQUEST_CDMA_BURST_DTMF";
4868 case RIL_REQUEST_CDMA_SEND_SMS:return"RIL_REQUEST_CDMA_SEND_SMS";
4869 case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE:return"RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE";
4870 case RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG:return"RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG";
4871 case RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG:return"RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG";
4872 case RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION:return "RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION";
4873 case RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG:return "RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG";
4874 case RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG:return "RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG";
4875 case RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION:return "RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION";
4876 case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: return"RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY";
4877 case RIL_REQUEST_CDMA_SUBSCRIPTION: return"RIL_REQUEST_CDMA_SUBSCRIPTION";
4878 case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: return "RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM";
4879 case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: return "RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM";
4880 case RIL_REQUEST_DEVICE_IDENTITY: return "RIL_REQUEST_DEVICE_IDENTITY";
4881 case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: return "RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE";
4882 case RIL_REQUEST_GET_SMSC_ADDRESS: return "RIL_REQUEST_GET_SMSC_ADDRESS";
4883 case RIL_REQUEST_SET_SMSC_ADDRESS: return "RIL_REQUEST_SET_SMSC_ADDRESS";
4884 case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: return "RIL_REQUEST_REPORT_SMS_MEMORY_STATUS";
4885 case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: return "RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING";
4886 case RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE: return "RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE";
4887 case RIL_REQUEST_ISIM_AUTHENTICATION: return "RIL_REQUEST_ISIM_AUTHENTICATION";
4888 case RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU: return "RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU";
4889 case RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS: return "RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS";
4890 case RIL_REQUEST_VOICE_RADIO_TECH: return "RIL_REQUEST_VOICE_RADIO_TECH";
4891 case RIL_REQUEST_GET_CELL_INFO_LIST: return"RIL_REQUEST_GET_CELL_INFO_LIST";
4892 case RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE: return"RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE";
4893 case RIL_REQUEST_SET_INITIAL_ATTACH_APN: return "RIL_REQUEST_SET_INITIAL_ATTACH_APN";
4894 case RIL_REQUEST_IMS_REGISTRATION_STATE: return "RIL_REQUEST_IMS_REGISTRATION_STATE";
4895 case RIL_REQUEST_IMS_SEND_SMS: return "RIL_REQUEST_IMS_SEND_SMS";
4896 case RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC: return "RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC";
4897 case RIL_REQUEST_SIM_OPEN_CHANNEL: return "RIL_REQUEST_SIM_OPEN_CHANNEL";
4898 case RIL_REQUEST_SIM_CLOSE_CHANNEL: return "RIL_REQUEST_SIM_CLOSE_CHANNEL";
4899 case RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL: return "RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL";
4900 case RIL_REQUEST_GET_RADIO_CAPABILITY: return "RIL_REQUEST_GET_RADIO_CAPABILITY";
4901 case RIL_REQUEST_SET_RADIO_CAPABILITY: return "RIL_REQUEST_SET_RADIO_CAPABILITY";
4902 case RIL_REQUEST_SET_UICC_SUBSCRIPTION: return "RIL_REQUEST_SET_UICC_SUBSCRIPTION";
4903 case RIL_REQUEST_ALLOW_DATA: return "RIL_REQUEST_ALLOW_DATA";
4904 case RIL_REQUEST_GET_HARDWARE_CONFIG: return "RIL_REQUEST_GET_HARDWARE_CONFIG";
4905 case RIL_REQUEST_SIM_AUTHENTICATION: return "RIL_REQUEST_SIM_AUTHENTICATION";
4906 case RIL_REQUEST_GET_DC_RT_INFO: return "RIL_REQUEST_GET_DC_RT_INFO";
4907 case RIL_REQUEST_SET_DC_RT_INFO_RATE: return "RIL_REQUEST_SET_DC_RT_INFO_RATE";
4908 case RIL_REQUEST_SET_DATA_PROFILE: return "RIL_REQUEST_SET_DATA_PROFILE";
4909 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return "RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED";
4910 case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return "RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED";
4911 case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: return "RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED";
4912 case RIL_UNSOL_RESPONSE_NEW_SMS: return "RIL_UNSOL_RESPONSE_NEW_SMS";
4913 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: return "RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT";
4914 case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: return "RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM";
4915 case RIL_UNSOL_ON_USSD: return "RIL_UNSOL_ON_USSD";
4916 case RIL_UNSOL_ON_USSD_REQUEST: return "RIL_UNSOL_ON_USSD_REQUEST";
4917 case RIL_UNSOL_NITZ_TIME_RECEIVED: return "RIL_UNSOL_NITZ_TIME_RECEIVED";
4918 case RIL_UNSOL_SIGNAL_STRENGTH: return "RIL_UNSOL_SIGNAL_STRENGTH";
4919 case RIL_UNSOL_STK_SESSION_END: return "RIL_UNSOL_STK_SESSION_END";
4920 case RIL_UNSOL_STK_PROACTIVE_COMMAND: return "RIL_UNSOL_STK_PROACTIVE_COMMAND";
4921 case RIL_UNSOL_STK_EVENT_NOTIFY: return "RIL_UNSOL_STK_EVENT_NOTIFY";
4922 case RIL_UNSOL_STK_CALL_SETUP: return "RIL_UNSOL_STK_CALL_SETUP";
4923 case RIL_UNSOL_SIM_SMS_STORAGE_FULL: return "RIL_UNSOL_SIM_SMS_STORAGE_FULL";
4924 case RIL_UNSOL_SIM_REFRESH: return "RIL_UNSOL_SIM_REFRESH";
4925 case RIL_UNSOL_DATA_CALL_LIST_CHANGED: return "RIL_UNSOL_DATA_CALL_LIST_CHANGED";
4926 case RIL_UNSOL_CALL_RING: return "RIL_UNSOL_CALL_RING";
4927 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: return "RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED";
4928 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: return "RIL_UNSOL_RESPONSE_CDMA_NEW_SMS";
4929 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: return "RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS";
4930 case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: return "RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL";
4931 case RIL_UNSOL_RESTRICTED_STATE_CHANGED: return "RIL_UNSOL_RESTRICTED_STATE_CHANGED";
4932 case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: return "RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE";
4933 case RIL_UNSOL_CDMA_CALL_WAITING: return "RIL_UNSOL_CDMA_CALL_WAITING";
4934 case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: return "RIL_UNSOL_CDMA_OTA_PROVISION_STATUS";
4935 case RIL_UNSOL_CDMA_INFO_REC: return "RIL_UNSOL_CDMA_INFO_REC";
4936 case RIL_UNSOL_OEM_HOOK_RAW: return "RIL_UNSOL_OEM_HOOK_RAW";
4937 case RIL_UNSOL_RINGBACK_TONE: return "RIL_UNSOL_RINGBACK_TONE";
4938 case RIL_UNSOL_RESEND_INCALL_MUTE: return "RIL_UNSOL_RESEND_INCALL_MUTE";
4939 case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: return "RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED";
4940 case RIL_UNSOL_CDMA_PRL_CHANGED: return "RIL_UNSOL_CDMA_PRL_CHANGED";
4941 case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: return "RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE";
4942 case RIL_UNSOL_RIL_CONNECTED: return "RIL_UNSOL_RIL_CONNECTED";
4943 case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED: return "RIL_UNSOL_VOICE_RADIO_TECH_CHANGED";
4944 case RIL_UNSOL_CELL_INFO_LIST: return "RIL_UNSOL_CELL_INFO_LIST";
4945 case RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED: return "RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED";
4946 case RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED: return "RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED";
4947 case RIL_UNSOL_SRVCC_STATE_NOTIFY: return "RIL_UNSOL_SRVCC_STATE_NOTIFY";
4948 case RIL_UNSOL_HARDWARE_CONFIG_CHANGED: return "RIL_UNSOL_HARDWARE_CONFIG_CHANGED";
4949 case RIL_UNSOL_DC_RT_INFO_CHANGED: return "RIL_UNSOL_DC_RT_INFO_CHANGED";
4950 case RIL_REQUEST_SHUTDOWN: return "RIL_REQUEST_SHUTDOWN";
4951 case RIL_UNSOL_RADIO_CAPABILITY: return "RIL_UNSOL_RADIO_CAPABILITY";
4952 case RIL_REQUEST_SET_TRM: return "RIL_REQUEST_SET_TRM";
4953 case RIL_REQUEST_SET_IMS_ENABLE:return "RIL_REQUEST_SET_IMS_ENABLE";
4954 case RIL_REQUEST_SET_AUDIO_PATH: return "RIL_REQUEST_SET_AUDIO_PATH";
4955 case RIL_REQUEST_HANGUP_ALL: return "RIL_REQUEST_HANGUP_ALL";
4956 case RIL_REQUEST_FORCE_RELEASE_CALL: return "RIL_REQUEST_FORCE_RELEASE_CALL";
4957 case RIL_REQUEST_EMERGENCY_DIAL: return "RIL_REQUEST_EMERGENCY_DIAL";
4958 case RIL_REQUEST_SET_ECC_SERVICE_CATEGORY: return "RIL_REQUEST_SET_ECC_SERVICE_CATEGORY";
4959 case RIL_REQUEST_SET_ECC_LIST: return "RIL_REQUEST_SET_ECC_LIST";
4960 case RIL_REQUEST_AT_COMMAND_WITH_PROXY: return "RIL_REQUEST_AT_COMMAND_WITH_PROXY";
4961 case RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION: return "RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION";
4962 case RIL_REQUEST_SET_CLIP: return "RIL_REQUEST_SET_CLIP";
4963 case RIL_REQUEST_GET_COLP: return "RIL_REQUEST_GET_COLP";
4964 case RIL_REQUEST_SET_COLP: return "RIL_REQUEST_SET_COLP";
4965 case RIL_REQUEST_GET_COLR: return "RIL_REQUEST_GET_COLR";
4966 case RIL_REQUEST_ADD_IMS_CONFERENCE_CALL_MEMBER: return "RIL_REQUEST_ADD_IMS_CONFERENCE_CALL_MEMBER";
4967 case RIL_REQUEST_REMOVE_IMS_CONFERENCE_CALL_MEMBER: return "RIL_REQUEST_REMOVE_IMS_CONFERENCE_CALL_MEMBER";
4968 case RIL_REQUEST_CONFERENCE_DIAL: return "RIL_REQUEST_CONFERENCE_DIAL";
4969 case RIL_REQUEST_DIAL_WITH_SIP_URI: return "RIL_REQUEST_DIAL_WITH_SIP_URI";
4970 case RIL_REQUEST_HOLD_CALL: return "RIL_REQUEST_HOLD_CALL";
4971 case RIL_REQUEST_RESUME_CALL: return "RIL_REQUEST_RESUME_CALL";
4972 case RIL_UNSOL_ECONF_SRVCC_INDICATION : return "RIL_UNSOL_ECONF_SRVCC_INDICATION";
4973 case RIL_UNSOL_ECONF_RESULT_INDICATION : return "RIL_UNSOL_ECONF_RESULT_INDICATION";
4974 case RIL_UNSOL_MAL_AT_INFO : return "RIL_UNSOL_MAL_AT_INFO";
4975 case RIL_REQUEST_MODEM_POWEROFF: return "RIL_REQUEST_MODEM_POWEROFF";
4976 case RIL_REQUEST_MODEM_POWERON: return "RIL_REQUEST_MODEM_POWERON";
4977 case RIL_REQUEST_WRITE_SMS_TO_SIM: return "RIL_REQUEST_WRITE_SMS_TO_SIM";
4978 case RIL_REQUEST_QUERY_ICCID: return "RIL_REQUEST_QUERY_ICCID";
4979 case RIL_UNSOL_TX_POWER: return "RIL_UNSOL_TX_POWER";
4980 case RIL_UNSOL_NETWORK_INFO: return "RIL_UNSOL_NETWORK_INFO";
4981 case RIL_REQUEST_DELETE_SMS_ON_SIM: return "RIL_REQUEST_DELETE_SMS_ON_SIM";
4982 case RIL_REQUEST_SET_IMSCFG: return "RIL_REQUEST_SET_IMSCFG";
4983#ifdef ECALL_SUPPORT
4984 case RIL_REQUEST_ECALL_FAST_MAKE_ECALL: return "RIL_REQUEST_ECALL_FAST_MAKE_ECALL";
4985 case RIL_REQUEST_ECALL_SET_IVS: return "RIL_REQUEST_ECALL_SET_IVS";
4986 case RIL_REQUEST_ECALL_SET_PSAP: return "RIL_REQUEST_ECALL_SET_PSAP";
4987 case RIL_REQUEST_ECALL_MAKE_ECALL: return "RIL_REQUEST_ECALL_MAKE_ECALL";
4988 case RIL_REQUEST_ECALL_IVS_PUSH_MSD: return "RIL_REQUEST_ECALL_IVS_PUSH_MSD";
4989 case RIL_REQUEST_ECALL_PSAP_PULL_MSD: return "RIL_REQUEST_ECALL_PSAP_PULL_MSD";
4990 case RIL_UNSOL_ECALL_MSDHACK : return "RIL_UNSOL_ECALL_MSDHACK";
4991 case RIL_REQUEST_ECALL_SET_MSD: return "RIL_REQUEST_ECALL_SET_MSD";
4992 case RIL_REQUEST_ECALL_CTRL_SEQUENCE: return "RIL_REQUEST_ECALL_CTRL_SEQUENCE";
4993 case RIL_UNSOL_ECALL_INDICATIONS : return "RIL_UNSOL_ECALL_INDICATIONS";
4994 case RIL_REQUEST_ECALL_RESET_IVS: return "RIL_REQUEST_ECALL_RESET_IVS";
4995 case RIL_REQUEST_ECALL_SET_PRI: return "RIL_REQUEST_ECALL_SET_PRI";
4996 case RIL_REQUEST_ECALL_SET_TEST_NUM: return "RIL_REQUEST_ECALL_SET_TEST_NUM";
4997 case RIL_REQUEST_ECALL_SET_RECONF_NUM: return "RIL_REQUEST_ECALL_SET_RECONF_NUM";
4998 case RIL_REQUEST_SYNC_DATA_SETTINGS_TO_MD: return "RIL_REQUEST_SYNC_DATA_SETTINGS_TO_MD";
4999 case RIL_REQUEST_ECALL_SET_NAD_DEREGISTRATION_TIME: return "RIL_REQUEST_ECALL_SET_NAD_DEREGISTRATION_TIME";
5000 case RIL_REQUEST_ECALL_SET_REGISTRATION_STATE: return "RIL_REQUEST_ECALL_SET_REGISTRATION_STATE";
5001#endif /*ECALL_SUPPORT*/
5002#ifdef KEEP_ALIVE
5003 case RIL_REQUEST_START_KEEPALIVE_PRO: return "RIL_REQUEST_START_KEEPALIVE_PRO";
5004 case RIL_REQUEST_STOP_KEEPALIVE_PRO: return "RIL_REQUEST_STOP_KEEPALIVE_PRO";
5005 case RIL_UNSOL_KEEPALIVE_STATUS_PRO: return "RIL_UNSOL_KEEPALIVE_STATUS_PRO";
5006#endif /*KEEP_ALIVE*/
5007 case RIL_REQUEST_SEND_USSI: return "RIL_REQUEST_SEND_USSI";
5008 case RIL_REQUEST_CANCEL_USSI: return "RIL_REQUEST_CANCEL_USSI";
5009 case RIL_REQUEST_GET_SMS_SIM_MEM_STATUS: return "RIL_REQUEST_GET_SMS_SIM_MEM_STATUS";
5010 case RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR: return "RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR";
5011 case RIL_REQUEST_REPORT_AIRPLANE_MODE: return "RIL_REQUEST_REPORT_AIRPLANE_MODE";
5012 case RIL_REQUEST_SET_ECC_NUM: return "RIL_REQUEST_SET_ECC_NUM";
5013 case RIL_REQUEST_GET_ECC_NUM: return "RIL_REQUEST_GET_ECC_NUM";
5014 case RIL_UNSOL_ECC_NUM: return "RIL_UNSOL_ECC_NUM";
5015 case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS_WITH_ACT: return "RIL_REQUEST_QUERY_AVAILABLE_NETWORKS_WITH_ACT";
5016 case RIL_REQUEST_GSM_GET_BROADCAST_LANGUAGE: return "RIL_REQUEST_GSM_GET_BROADCAST_LANGUAGE";
5017 case RIL_REQUEST_GSM_SET_BROADCAST_LANGUAGE: return "RIL_REQUEST_GSM_SET_BROADCAST_LANGUAGE";
5018 case RIL_UNSOL_CALL_INFO_INDICATION: return "RIL_UNSOL_CALL_INFO_INDICATION";
rjw20006d12022-04-21 16:29:04 +08005019/*Typethree add for t800 RIL Service 2022/04/14 start*/
5020//#ifdef TARGET_PLATFORM_MT2731
lh7b0674a2022-01-10 00:34:35 -08005021 case RIL_REQUEST_MODIFY_APN: return "RIL_REQUEST_MODIFY_APN";
5022 case RIL_REQUEST_RESET_APN: return "RIL_REQUEST_RESET_APN";
rjw20006d12022-04-21 16:29:04 +08005023//#endif
5024/*Typethree add for t800 RIL Service 2022/04/14 end*/
lh7b0674a2022-01-10 00:34:35 -08005025 case RIL_REQUEST_QUERY_SIM_RETRY_COUNT: return "RIL_REQUEST_QUERY_SIM_RETRY_COUNT";
5026 case RIL_REQUEST_QUERY_EID: return "RIL_REQUEST_QUERY_EID";
5027 /*LYNQ CMD*/
5028 case LYNQ_AUTO_ANSWER_CALL: return "LYNQ_AUTO_ANSWER_CALL";
5029 case LYNQ_REQUEST_SET_DTMF_VOLUME: return "RIL_REQUEST_SET_DTMF_VOLUME";
q.huangec88da92022-03-29 04:17:32 -04005030 case LYNQ_REQUEST_SET_SPEECH_VOLUME: return "RIL_REQUEST_SET_SPEECH_VOLUME";
5031 case LYNQ_REQUEST_GET_SPEECH_VOLUME: return "RIL_REQUEST_GET_SPEECH_VOLUME";
5032 case LYNQ_REQUEST_RECORD: return "RIL_REQUEST_RECORD";
lhf6eea122022-01-20 19:32:14 -08005033 case LYNQ_REQUEST_WRITE_SMS_TO_MEMORY: return "LYNQ_REQUEST_WRITE_SMS_TO_MEMORY";
5034 case LYNQ_REQUEST_READ_SMS_FROM_MEMORY: return "LYNQ_REQUEST_READ_SMS_FROM_MEMORY";
5035 case LYNQ_REQUEST_DELETE_SMS_FROM_MEMORY: return "LYNQ_REQUEST_DELETE_SMS_FROM_MEMORY";
5036 case LYNQ_REQUEST_LIST_SMS_FROM_MEMORY: return "LYNQ_REQUEST_LIST_SMS_FROM_MEMORY";
rjw5d2a50e2022-02-28 15:01:49 +08005037 case LYNQ_REQUEST_SET_DEFAULT_SIM_ALL:return "SET_DEFAULT_SIM_ALL";
lh7b0674a2022-01-10 00:34:35 -08005038 default: return "<unknown request>";
5039 }
5040}
5041
5042const char *
5043requestToString(int request) {
5044/*
5045 cat libs/telephony/ril_commands.h \
5046 | egrep "^ *{RIL_" \
5047 | sed -re 's/\{RIL_([^,]+),[^,]+,([^}]+).+/case RIL_\1: return "\1";/'
5048
5049
5050 cat libs/telephony/ril_unsol_commands.h \
5051 | egrep "^ *{RIL_" \
5052 | sed -re 's/\{RIL_([^,]+),([^}]+).+/case RIL_\1: return "\1";/'
5053
5054*/
5055 switch(request) {
5056 case RIL_REQUEST_GET_SIM_STATUS: return "GET_SIM_STATUS";
5057 case RIL_REQUEST_ENTER_SIM_PIN: return "ENTER_SIM_PIN";
5058 case RIL_REQUEST_ENTER_SIM_PUK: return "ENTER_SIM_PUK";
5059 case RIL_REQUEST_ENTER_SIM_PIN2: return "ENTER_SIM_PIN2";
5060 case RIL_REQUEST_ENTER_SIM_PUK2: return "ENTER_SIM_PUK2";
5061 case RIL_REQUEST_CHANGE_SIM_PIN: return "CHANGE_SIM_PIN";
5062 case RIL_REQUEST_CHANGE_SIM_PIN2: return "CHANGE_SIM_PIN2";
5063 case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: return "ENTER_NETWORK_DEPERSONALIZATION";
5064 case RIL_REQUEST_GET_CURRENT_CALLS: return "GET_CURRENT_CALLS";
5065 case RIL_REQUEST_DIAL: return "DIAL";
5066 case RIL_REQUEST_GET_IMSI: return "GET_IMSI";
5067 case RIL_REQUEST_HANGUP: return "HANGUP";
5068 case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: return "HANGUP_WAITING_OR_BACKGROUND";
5069 case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: return "HANGUP_FOREGROUND_RESUME_BACKGROUND";
5070 case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: return "SWITCH_WAITING_OR_HOLDING_AND_ACTIVE";
5071 case RIL_REQUEST_CONFERENCE: return "CONFERENCE";
5072 case RIL_REQUEST_UDUB: return "UDUB";
5073 case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: return "LAST_CALL_FAIL_CAUSE";
5074 case RIL_REQUEST_SIGNAL_STRENGTH: return "SIGNAL_STRENGTH";
5075 case RIL_REQUEST_VOICE_REGISTRATION_STATE: return "VOICE_REGISTRATION_STATE";
5076 case RIL_REQUEST_DATA_REGISTRATION_STATE: return "DATA_REGISTRATION_STATE";
5077 case RIL_REQUEST_OPERATOR: return "OPERATOR";
5078 case RIL_REQUEST_RADIO_POWER: return "RADIO_POWER";
5079 case RIL_REQUEST_DTMF: return "DTMF";
5080 case RIL_REQUEST_SEND_SMS: return "SEND_SMS";
5081 case RIL_REQUEST_SEND_SMS_EXPECT_MORE: return "SEND_SMS_EXPECT_MORE";
5082 case RIL_REQUEST_SETUP_DATA_CALL: return "SETUP_DATA_CALL";
5083 case RIL_REQUEST_SIM_IO: return "SIM_IO";
5084 case RIL_REQUEST_SEND_USSD: return "SEND_USSD";
5085 case RIL_REQUEST_CANCEL_USSD: return "CANCEL_USSD";
5086 case RIL_REQUEST_GET_CLIR: return "GET_CLIR";
5087 case RIL_REQUEST_SET_CLIR: return "SET_CLIR";
5088 case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: return "QUERY_CALL_FORWARD_STATUS";
5089 case RIL_REQUEST_SET_CALL_FORWARD: return "SET_CALL_FORWARD";
5090 case RIL_REQUEST_QUERY_CALL_WAITING: return "QUERY_CALL_WAITING";
5091 case RIL_REQUEST_SET_CALL_WAITING: return "SET_CALL_WAITING";
5092 case RIL_REQUEST_SMS_ACKNOWLEDGE: return "SMS_ACKNOWLEDGE";
5093 case RIL_REQUEST_GET_IMEI: return "GET_IMEI";
5094 case RIL_REQUEST_GET_IMEISV: return "GET_IMEISV";
5095 case RIL_REQUEST_ANSWER: return "ANSWER";
5096 case RIL_REQUEST_DEACTIVATE_DATA_CALL: return "DEACTIVATE_DATA_CALL";
5097 case RIL_REQUEST_QUERY_FACILITY_LOCK: return "QUERY_FACILITY_LOCK";
5098 case RIL_REQUEST_SET_FACILITY_LOCK: return "SET_FACILITY_LOCK";
5099 case RIL_REQUEST_CHANGE_BARRING_PASSWORD: return "CHANGE_BARRING_PASSWORD";
5100 case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: return "QUERY_NETWORK_SELECTION_MODE";
5101 case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: return "SET_NETWORK_SELECTION_AUTOMATIC";
5102 case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: return "SET_NETWORK_SELECTION_MANUAL";
5103 case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : return "QUERY_AVAILABLE_NETWORKS ";
5104 case RIL_REQUEST_DTMF_START: return "DTMF_START";
5105 case RIL_REQUEST_DTMF_STOP: return "DTMF_STOP";
5106 case RIL_REQUEST_BASEBAND_VERSION: return "BASEBAND_VERSION";
5107 case RIL_REQUEST_SEPARATE_CONNECTION: return "SEPARATE_CONNECTION";
5108 case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: return "SET_PREFERRED_NETWORK_TYPE";
5109 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: return "GET_PREFERRED_NETWORK_TYPE";
5110 case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: return "GET_NEIGHBORING_CELL_IDS";
5111 case RIL_REQUEST_SET_MUTE: return "SET_MUTE";
5112 case RIL_REQUEST_GET_MUTE: return "GET_MUTE";
5113 case RIL_REQUEST_QUERY_CLIP: return "QUERY_CLIP";
5114 case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: return "LAST_DATA_CALL_FAIL_CAUSE";
5115 case RIL_REQUEST_DATA_CALL_LIST: return "DATA_CALL_LIST";
5116 case RIL_REQUEST_RESET_RADIO: return "RESET_RADIO";
5117 case RIL_REQUEST_OEM_HOOK_RAW: return "OEM_HOOK_RAW";
5118 case RIL_REQUEST_OEM_HOOK_STRINGS: return "OEM_HOOK_STRINGS";
5119 case RIL_REQUEST_SET_BAND_MODE: return "SET_BAND_MODE";
5120 case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: return "QUERY_AVAILABLE_BAND_MODE";
5121 case RIL_REQUEST_STK_GET_PROFILE: return "STK_GET_PROFILE";
5122 case RIL_REQUEST_STK_SET_PROFILE: return "STK_SET_PROFILE";
5123 case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: return "STK_SEND_ENVELOPE_COMMAND";
5124 case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: return "STK_SEND_TERMINAL_RESPONSE";
5125 case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: return "STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM";
5126 case RIL_REQUEST_SCREEN_STATE: return "SCREEN_STATE";
5127 case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: return "EXPLICIT_CALL_TRANSFER";
5128 case RIL_REQUEST_SET_LOCATION_UPDATES: return "SET_LOCATION_UPDATES";
5129 case RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE:return"CDMA_SET_SUBSCRIPTION_SOURCE";
5130 case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE:return"CDMA_SET_ROAMING_PREFERENCE";
5131 case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE:return"CDMA_QUERY_ROAMING_PREFERENCE";
5132 case RIL_REQUEST_SET_TTY_MODE:return"SET_TTY_MODE";
5133 case RIL_REQUEST_QUERY_TTY_MODE:return"QUERY_TTY_MODE";
5134 case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE";
5135 case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE";
5136 case RIL_REQUEST_CDMA_FLASH:return"CDMA_FLASH";
5137 case RIL_REQUEST_CDMA_BURST_DTMF:return"CDMA_BURST_DTMF";
5138 case RIL_REQUEST_CDMA_SEND_SMS:return"CDMA_SEND_SMS";
5139 case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE:return"CDMA_SMS_ACKNOWLEDGE";
5140 case RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG:return"GSM_GET_BROADCAST_SMS_CONFIG";
5141 case RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG:return"GSM_SET_BROADCAST_SMS_CONFIG";
5142 case RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION:return "GSM_SMS_BROADCAST_ACTIVATION";
5143 case RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG:return "CDMA_GET_BROADCAST_SMS_CONFIG";
5144 case RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG:return "CDMA_SET_BROADCAST_SMS_CONFIG";
5145 case RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION:return "CDMA_SMS_BROADCAST_ACTIVATION";
5146 case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: return"CDMA_VALIDATE_AND_WRITE_AKEY";
5147 case RIL_REQUEST_CDMA_SUBSCRIPTION: return"CDMA_SUBSCRIPTION";
5148 case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: return "CDMA_WRITE_SMS_TO_RUIM";
5149 case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: return "CDMA_DELETE_SMS_ON_RUIM";
5150 case RIL_REQUEST_DEVICE_IDENTITY: return "DEVICE_IDENTITY";
5151 case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: return "EXIT_EMERGENCY_CALLBACK_MODE";
5152 case RIL_REQUEST_GET_SMSC_ADDRESS: return "GET_SMSC_ADDRESS";
5153 case RIL_REQUEST_SET_SMSC_ADDRESS: return "SET_SMSC_ADDRESS";
5154 case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: return "REPORT_SMS_MEMORY_STATUS";
5155 case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: return "REPORT_STK_SERVICE_IS_RUNNING";
5156 case RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE: return "CDMA_GET_SUBSCRIPTION_SOURCE";
5157 case RIL_REQUEST_ISIM_AUTHENTICATION: return "ISIM_AUTHENTICATION";
5158 case RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU: return "RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU";
5159 case RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS: return "RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS";
5160 case RIL_REQUEST_VOICE_RADIO_TECH: return "VOICE_RADIO_TECH";
5161 case RIL_REQUEST_GET_CELL_INFO_LIST: return"GET_CELL_INFO_LIST";
5162 case RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE: return"SET_UNSOL_CELL_INFO_LIST_RATE";
5163 case RIL_REQUEST_SET_INITIAL_ATTACH_APN: return "RIL_REQUEST_SET_INITIAL_ATTACH_APN";
5164 case RIL_REQUEST_IMS_REGISTRATION_STATE: return "IMS_REGISTRATION_STATE";
5165 case RIL_REQUEST_IMS_SEND_SMS: return "IMS_SEND_SMS";
5166 case RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC: return "SIM_TRANSMIT_APDU_BASIC";
5167 case RIL_REQUEST_SIM_OPEN_CHANNEL: return "SIM_OPEN_CHANNEL";
5168 case RIL_REQUEST_SIM_CLOSE_CHANNEL: return "SIM_CLOSE_CHANNEL";
5169 case RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL: return "SIM_TRANSMIT_APDU_CHANNEL";
5170 case RIL_REQUEST_GET_RADIO_CAPABILITY: return "RIL_REQUEST_GET_RADIO_CAPABILITY";
5171 case RIL_REQUEST_SET_RADIO_CAPABILITY: return "RIL_REQUEST_SET_RADIO_CAPABILITY";
5172 case RIL_REQUEST_SET_UICC_SUBSCRIPTION: return "SET_UICC_SUBSCRIPTION";
5173 case RIL_REQUEST_ALLOW_DATA: return "ALLOW_DATA";
5174 case RIL_REQUEST_GET_HARDWARE_CONFIG: return "GET_HARDWARE_CONFIG";
5175 case RIL_REQUEST_SIM_AUTHENTICATION: return "SIM_AUTHENTICATION";
5176 case RIL_REQUEST_GET_DC_RT_INFO: return "GET_DC_RT_INFO";
5177 case RIL_REQUEST_SET_DC_RT_INFO_RATE: return "SET_DC_RT_INFO_RATE";
5178 case RIL_REQUEST_SET_DATA_PROFILE: return "SET_DATA_PROFILE";
5179 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return "UNSOL_RESPONSE_RADIO_STATE_CHANGED";
5180 case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return "UNSOL_RESPONSE_CALL_STATE_CHANGED";
5181 case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: return "UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED";
5182 case RIL_UNSOL_RESPONSE_NEW_SMS: return "UNSOL_RESPONSE_NEW_SMS";
5183 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: return "UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT";
5184 case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: return "UNSOL_RESPONSE_NEW_SMS_ON_SIM";
5185 case RIL_UNSOL_ON_USSD: return "UNSOL_ON_USSD";
5186 case RIL_UNSOL_ON_USSD_REQUEST: return "UNSOL_ON_USSD_REQUEST(obsolete)";
5187 case RIL_UNSOL_NITZ_TIME_RECEIVED: return "UNSOL_NITZ_TIME_RECEIVED";
5188 case RIL_UNSOL_SIGNAL_STRENGTH: return "UNSOL_SIGNAL_STRENGTH";
5189 case RIL_UNSOL_STK_SESSION_END: return "UNSOL_STK_SESSION_END";
5190 case RIL_UNSOL_STK_PROACTIVE_COMMAND: return "UNSOL_STK_PROACTIVE_COMMAND";
5191 case RIL_UNSOL_STK_EVENT_NOTIFY: return "UNSOL_STK_EVENT_NOTIFY";
5192 case RIL_UNSOL_STK_CALL_SETUP: return "UNSOL_STK_CALL_SETUP";
5193 case RIL_UNSOL_SIM_SMS_STORAGE_FULL: return "UNSOL_SIM_SMS_STORAGE_FUL";
5194 case RIL_UNSOL_SIM_REFRESH: return "UNSOL_SIM_REFRESH";
5195 case RIL_UNSOL_DATA_CALL_LIST_CHANGED: return "UNSOL_DATA_CALL_LIST_CHANGED";
5196 case RIL_UNSOL_CALL_RING: return "UNSOL_CALL_RING";
5197 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: return "UNSOL_RESPONSE_SIM_STATUS_CHANGED";
5198 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: return "UNSOL_NEW_CDMA_SMS";
5199 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: return "UNSOL_NEW_BROADCAST_SMS";
5200 case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: return "UNSOL_CDMA_RUIM_SMS_STORAGE_FULL";
5201 case RIL_UNSOL_RESTRICTED_STATE_CHANGED: return "UNSOL_RESTRICTED_STATE_CHANGED";
5202 case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: return "UNSOL_ENTER_EMERGENCY_CALLBACK_MODE";
5203 case RIL_UNSOL_CDMA_CALL_WAITING: return "UNSOL_CDMA_CALL_WAITING";
5204 case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: return "UNSOL_CDMA_OTA_PROVISION_STATUS";
5205 case RIL_UNSOL_CDMA_INFO_REC: return "UNSOL_CDMA_INFO_REC";
5206 case RIL_UNSOL_OEM_HOOK_RAW: return "UNSOL_OEM_HOOK_RAW";
5207 case RIL_UNSOL_RINGBACK_TONE: return "UNSOL_RINGBACK_TONE";
5208 case RIL_UNSOL_RESEND_INCALL_MUTE: return "UNSOL_RESEND_INCALL_MUTE";
5209 case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: return "UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED";
5210 case RIL_UNSOL_CDMA_PRL_CHANGED: return "UNSOL_CDMA_PRL_CHANGED";
5211 case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: return "UNSOL_EXIT_EMERGENCY_CALLBACK_MODE";
5212 case RIL_UNSOL_RIL_CONNECTED: return "UNSOL_RIL_CONNECTED";
5213 case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED: return "UNSOL_VOICE_RADIO_TECH_CHANGED";
5214 case RIL_UNSOL_CELL_INFO_LIST: return "UNSOL_CELL_INFO_LIST";
5215 case RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED: return "RESPONSE_IMS_NETWORK_STATE_CHANGED";
5216 case RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED: return "UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED";
5217 case RIL_UNSOL_SRVCC_STATE_NOTIFY: return "UNSOL_SRVCC_STATE_NOTIFY";
5218 case RIL_UNSOL_HARDWARE_CONFIG_CHANGED: return "HARDWARE_CONFIG_CHANGED";
5219 case RIL_UNSOL_DC_RT_INFO_CHANGED: return "UNSOL_DC_RT_INFO_CHANGED";
5220 case RIL_REQUEST_SHUTDOWN: return "SHUTDOWN";
5221 case RIL_UNSOL_RADIO_CAPABILITY: return "RIL_UNSOL_RADIO_CAPABILITY";
5222 case RIL_REQUEST_SET_TRM: return "RIL_REQUEST_SET_TRM";
5223 case RIL_REQUEST_SET_IMS_ENABLE:return "RIL_REQUEST_SET_IMS_ENABLE";
5224 case RIL_REQUEST_SET_AUDIO_PATH: return "SET_AUDIO_PATH";
5225 case RIL_REQUEST_HANGUP_ALL: return "HANGUP_ALL";
5226 case RIL_REQUEST_FORCE_RELEASE_CALL: return "FORCE_RELEASE_CALL";
5227 case RIL_REQUEST_EMERGENCY_DIAL: return "RIL_REQUEST_EMERGENCY_DIAL";
5228 case RIL_REQUEST_SET_ECC_SERVICE_CATEGORY: return "RIL_REQUEST_SET_ECC_SERVICE_CATEGORY";
5229 case RIL_REQUEST_SET_ECC_LIST: return "RIL_REQUEST_SET_ECC_LIST";
5230 case RIL_REQUEST_AT_COMMAND_WITH_PROXY: return "AT_COMMAND_WITH_PROXY";
5231 case RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION: return "RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION";
5232 case RIL_REQUEST_SET_CLIP: return "RIL_REQUEST_SET_CLIP";
5233 case RIL_REQUEST_GET_COLP: return "RIL_REQUEST_GET_COLP";
5234 case RIL_REQUEST_SET_COLP: return "RIL_REQUEST_SET_COLP";
5235 case RIL_REQUEST_GET_COLR: return "RIL_REQUEST_GET_COLR";
5236 case RIL_REQUEST_ADD_IMS_CONFERENCE_CALL_MEMBER: return "ADD_IMS_CONFERENCE_CALL_MEMBER";
5237 case RIL_REQUEST_REMOVE_IMS_CONFERENCE_CALL_MEMBER: return "REMOVE_IMS_CONFERENCE_CALL_MEMBER";
5238 case RIL_REQUEST_CONFERENCE_DIAL: return "CONFERENCE_DIAL";
5239 case RIL_REQUEST_DIAL_WITH_SIP_URI: return "DIAL_WITH_SIP_URI";
5240 case RIL_REQUEST_HOLD_CALL: return "HOLD_CALL";
5241 case RIL_REQUEST_RESUME_CALL: return "RESUME_CALL";
5242 case RIL_UNSOL_ECONF_SRVCC_INDICATION : return "ECONF_SRVCC_INDICATION";
5243 case RIL_UNSOL_ECONF_RESULT_INDICATION : return "ECONF_RESULT_INDICATION";
5244 case RIL_UNSOL_MAL_AT_INFO : return "UNSOL_MAL_AT_INFO";
5245 case RIL_REQUEST_MODEM_POWEROFF: return "MODEM_POWEROFF";
5246 case RIL_REQUEST_MODEM_POWERON: return "MODEM_POWERON";
5247 case RIL_REQUEST_WRITE_SMS_TO_SIM: return "WRITE_SMS_TO_SIM";
5248 case RIL_REQUEST_QUERY_ICCID: return "RIL_REQUEST_QUERY_ICCID";
5249 case RIL_UNSOL_TX_POWER: return "RIL_UNSOL_TX_POWER";
5250 case RIL_UNSOL_NETWORK_INFO: return "RIL_UNSOL_NETWORK_INFO";
5251 case RIL_REQUEST_DELETE_SMS_ON_SIM: return "DELETE_SMS_ON_SIM";
5252 case RIL_REQUEST_SET_IMSCFG: return "RIL_REQUEST_SET_IMSCFG";
5253#ifdef ECALL_SUPPORT
5254 case RIL_REQUEST_ECALL_FAST_MAKE_ECALL: return "ECALL_FAST_MAKE_ECALL";
5255 case RIL_REQUEST_ECALL_SET_IVS: return "RIL_REQUEST_ECALL_SET_IVS";
5256 case RIL_REQUEST_ECALL_SET_PSAP: return "RIL_REQUEST_ECALL_SET_PSAP";
5257 case RIL_REQUEST_ECALL_MAKE_ECALL: return "RIL_REQUEST_ECALL_MAKE_ECALL";
5258 case RIL_REQUEST_ECALL_IVS_PUSH_MSD: return "RIL_REQUEST_ECALL_IVS_PUSH_MSD";
5259 case RIL_REQUEST_ECALL_PSAP_PULL_MSD: return "RIL_REQUEST_ECALL_PSAP_PULL_MSD";
5260 case RIL_UNSOL_ECALL_MSDHACK : return "ECALL_MSDHACK";
5261 case RIL_REQUEST_ECALL_SET_MSD: return "RIL_REQUEST_ECALL_SET_MSD";
5262 case RIL_REQUEST_ECALL_CTRL_SEQUENCE: return "ECALL_SET_CTRL_SEQUENCE";
5263 case RIL_UNSOL_ECALL_INDICATIONS : return "ECALL_INDICATIONS";
5264 case RIL_REQUEST_ECALL_RESET_IVS: return "RIL_REQUEST_ECALL_RESET_IVS";
5265 case RIL_REQUEST_ECALL_SET_PRI: return "RIL_REQUEST_ECALL_SET_PRI";
5266 case RIL_REQUEST_ECALL_SET_TEST_NUM: return "RIL_REQUEST_ECALL_SET_TEST_NUM";
5267 case RIL_REQUEST_ECALL_SET_RECONF_NUM: return "RIL_REQUEST_ECALL_SET_RECONF_NUM";
5268 case RIL_REQUEST_SYNC_DATA_SETTINGS_TO_MD: return "RIL_REQUEST_SYNC_DATA_SETTINGS_TO_MD";
5269 case RIL_REQUEST_ECALL_SET_NAD_DEREGISTRATION_TIME: return "RIL_REQUEST_ECALL_SET_NAD_DEREGISTRATION_TIME";
5270 case RIL_REQUEST_ECALL_SET_REGISTRATION_STATE: return "RIL_REQUEST_ECALL_SET_REGISTRATION_STATE";
5271#endif /*ECALL_SUPPORT*/
5272#ifdef KEEP_ALIVE
5273 case RIL_REQUEST_START_KEEPALIVE_PRO: return "RIL_REQUEST_START_KEEPALIVE_PRO";
5274 case RIL_REQUEST_STOP_KEEPALIVE_PRO: return "RIL_REQUEST_STOP_KEEPALIVE_PRO";
5275 case RIL_UNSOL_KEEPALIVE_STATUS_PRO: return "RIL_UNSOL_KEEPALIVE_STATUS_PRO";
5276#endif /*KEEP_ALIVE*/
5277 case RIL_REQUEST_SEND_USSI: return "SEND_USSI";
5278 case RIL_REQUEST_CANCEL_USSI: return "CANCEL_USSI";
5279 case RIL_REQUEST_GET_SMS_SIM_MEM_STATUS: return "GET_SMS_SIM_MEM_STATUS";
5280 case RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR: return "RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR";
5281 case RIL_REQUEST_REPORT_AIRPLANE_MODE: return "RIL_REQUEST_REPORT_AIRPLANE_MODE";
5282 case RIL_REQUEST_SET_ECC_NUM: return "RIL_REQUEST_SET_ECC_NUM";
5283 case RIL_REQUEST_GET_ECC_NUM: return "RIL_REQUEST_GET_ECC_NUM";
5284 case RIL_UNSOL_ECC_NUM: return "RIL_UNSOL_ECC_NUM";
5285 case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS_WITH_ACT: return "RIL_REQUEST_QUERY_AVAILABLE_NETWORKS_WITH_ACT";
5286 case RIL_REQUEST_GSM_GET_BROADCAST_LANGUAGE: return "RIL_REQUEST_GSM_GET_BROADCAST_LANGUAGE";
5287 case RIL_REQUEST_GSM_SET_BROADCAST_LANGUAGE: return "RIL_REQUEST_GSM_SET_BROADCAST_LANGUAGE";
5288 case RIL_UNSOL_CALL_INFO_INDICATION: return "RIL_UNSOL_CALL_INFO_INDICATION";
5289 case RIL_REQUEST_MODIFY_APN: return "RIL_REQUEST_MODIFY_APN";
5290 case RIL_REQUEST_RESET_APN: return "RIL_REQUEST_RESET_APN";
5291 case RIL_REQUEST_QUERY_SIM_RETRY_COUNT: return "RIL_REQUEST_QUERY_SIM_RETRY_COUNT";
5292 case RIL_REQUEST_QUERY_EID: return "RIL_REQUEST_QUERY_EID";
5293 case LYNQ_REQUEST_SET_DTMF_VOLUME: return "RIL_REQUEST_SET_DTMF_VOLUME";
q.huangec88da92022-03-29 04:17:32 -04005294 case LYNQ_REQUEST_SET_SPEECH_VOLUME: return "RIL_REQUEST_SET_SPEECH_VOLUME";
5295 case LYNQ_REQUEST_GET_SPEECH_VOLUME: return "RIL_REQUEST_GET_SPEECH_VOLUME";
5296 case LYNQ_REQUEST_RECORD: return "RIL_REQUEST_RECORD";
lhf6eea122022-01-20 19:32:14 -08005297 /*warren add for t800 ril service 2022/1/22 start*/
5298 case LYNQ_REQUEST_WRITE_SMS_TO_MEMORY: return "LYNQ_REQUEST_WRITE_SMS_TO_MEMORY";
5299 case LYNQ_REQUEST_READ_SMS_FROM_MEMORY: return "LYNQ_REQUEST_READ_SMS_FROM_MEMORY";
5300 case LYNQ_REQUEST_DELETE_SMS_FROM_MEMORY: return "LYNQ_REQUEST_DELETE_SMS_FROM_MEMORY";
5301 case LYNQ_REQUEST_LIST_SMS_FROM_MEMORY: return "LYNQ_REQUEST_LIST_SMS_FROM_MEMORY";
rjw5d2a50e2022-02-28 15:01:49 +08005302 case LYNQ_REQUEST_SET_DEFAULT_SIM_ALL:return "SET_DEFAULT_SIM_ALL";
lhf6eea122022-01-20 19:32:14 -08005303 /*warren add for t800 ril service 2022/1/22 end*/
lh7b0674a2022-01-10 00:34:35 -08005304 default: return "<unknown request>";
5305 }
5306}
5307
5308static int sendResponse (Parcel &p, RIL_SOCKET_ID socket_id) {
5309 printResponse;
5310 int type;
5311 if(enable_bt_resp){
5312 SendRespToClient(p.data(), p.dataSize());
5313 }
5314 p.setDataPosition(0);
5315 p.readInt32(&type);
5316 if(type == RESPONSE_UNSOLICITED){
5317 processUnsolicited(p,type);
5318 }else if (type == RESPONSE_SOLICITED){
5319 processSolicited(p,type);
5320 }
5321 return 0;
5322}
5323
5324static void speciaRequest_wait()
5325{
5326 struct timeval now;
5327 struct timespec timeout;
5328
5329 gettimeofday(&now,NULL);
5330 timeout.tv_sec = now.tv_sec+1200; //timeout is 2omin. maybe radio on/off need 10s to complete.
5331 timeout.tv_nsec = now.tv_usec*1000;
5332
5333 SPECIA_BLOCK_LOCK();
5334 while(!(requestOneByOne == 0)) {
5335 int ret = SPECIA_BLOCK_WAIT(&timeout);
5336 if(ret == ETIMEDOUT){
5337 RLOGD("special request wait timeout");
5338 break;
5339 }
5340 }
5341 requestOneByOne = 1;
5342 SPECIA_BLOCK_UNLOCK();
5343}
5344
5345static void speciaRequest_wakeup()
5346{
5347 SPECIA_BLOCK_LOCK();
5348 requestOneByOne = 0;
5349 SPECIA_BLOCK_WAKEUP();
5350 SPECIA_BLOCK_UNLOCK();
5351}
5352
5353static void updateIccCardState(RIL_SOCKET_ID soc_id)
5354{
5355 ARspRequest(RIL_REQUEST_GET_SIM_STATUS, soc_id);
5356}
5357
5358void sendRequestToMd(int request, int id) {
5359 RequestInfo* info = creatRILInfoAndInit(request, INIT, (RIL_SOCKET_ID) ((id)));
5360 switch(request){
5361 case RIL_REQUEST_DEVICE_IDENTITY:
5362 {
5363 getDeviceIdentity(1, NULL, (RIL_SOCKET_ID) ((id)), info);
5364 break;
5365 }
5366 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE:
5367 {
5368 getPreferredNetworkType(1, NULL, (RIL_SOCKET_ID) ((id)), info);
5369 break;
5370 }
5371 case RIL_REQUEST_GET_SIM_STATUS:
5372 {
5373 getIccCardStatus(1, NULL, (RIL_SOCKET_ID) (id), info);
5374 break;
5375 }
5376 case RIL_REQUEST_DATA_REGISTRATION_STATE:
5377 {
5378 getDataRegistrationState(1, NULL, (RIL_SOCKET_ID) (id), info);
5379 break;
5380 }
5381 case RIL_REQUEST_VOICE_REGISTRATION_STATE:
5382 {
5383 getVoiceRegistrationState(1, NULL, (RIL_SOCKET_ID) (id), info);
5384 break;
5385 }
5386 case RIL_REQUEST_VOICE_RADIO_TECH:
5387 {
5388 getVoiceRadioTechnology(1, NULL, (RIL_SOCKET_ID) (id), info);
5389 break;
5390 }
5391 case RIL_REQUEST_OEM_HOOK_RAW:
5392 {
5393 char* tmp[2] = {"RIL_REQUEST_OEM_HOOK_RAW", "AT+ECAL"};
5394 sendATCMD(2, tmp, (RIL_SOCKET_ID) (id), info);
5395 break;
5396 }
5397 case RIL_REQUEST_GET_RADIO_CAPABILITY:
5398 {
5399 getRadioCapability(1, NULL, (RIL_SOCKET_ID) ((id)), info);
5400 break;
5401 }
5402 default:
5403 RLOGE("don't support %d in init", id);
5404 if(info) {
5405 free(info);
5406 }
5407 }
5408}
5409
5410static void init(int id) {
5411 int waittoken;
5412 RIL_RadioState radioState = CALL_ONSTATEREQUEST((RIL_SOCKET_ID )id);
5413 while (radioState == RADIO_STATE_UNAVAILABLE) {
5414 sleep(1);
5415 radioState = CALL_ONSTATEREQUEST((RIL_SOCKET_ID )id);
5416 RLOGD("init socket id: %d, %s", id, radioStateToString(radioState));
5417 }
5418 RLOGD("init socket id: %d, %s", id, radioStateToString(radioState));
xja1c30b82022-01-25 16:13:48 +08005419 updataDataConnectState(id, false);
lh7b0674a2022-01-10 00:34:35 -08005420 sendRequestToMd(RIL_REQUEST_GET_SIM_STATUS, id);
5421
5422#if 0
5423 if (radioState != RADIO_STATE_ON) {
5424 RequestInfo* radio = creatRILInfoAndInit(RIL_REQUEST_RADIO_POWER, INIT, (RIL_SOCKET_ID) (id));
5425 waittoken = radio->token;
5426 RLOGD("[%s-%d]:token is %x", __FUNCTION__, __LINE__, radio->token);
5427 char* tmp[2] = { "RIL_REQUEST_RADIO_POWER", "1" };
5428 setRadioPower(2, tmp, (RIL_SOCKET_ID) (id), radio);
5429 waitResponse(waittoken);
5430 sleep(2);
5431 radioState = CALL_ONSTATEREQUEST((RIL_SOCKET_ID )id);
5432 RLOGD("NOW radio status %s", radioStateToString(radioState));
5433 }
5434# endif
5435 sendRequestToMd(RIL_REQUEST_DATA_REGISTRATION_STATE, id);
5436 sendRequestToMd(RIL_REQUEST_VOICE_REGISTRATION_STATE, id);
5437 sendRequestToMd(RIL_REQUEST_VOICE_RADIO_TECH, id);
5438 sendRequestToMd(RIL_REQUEST_DEVICE_IDENTITY,id);
5439 sendRequestToMd(RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE, id);
5440 sendRequestToMd(RIL_REQUEST_OEM_HOOK_RAW, id);
5441 sendRequestToMd(RIL_REQUEST_GET_RADIO_CAPABILITY,id);
5442}
5443
5444static void initCoditions()
5445{
5446 mixer_init();
5447 if(utils::is_support_dsds()) {
5448 for(int i = 0; i < 2 ; i++) {
5449 init(i);
5450 }
5451 }
5452
5453 if(utils::is_suppport_dsss()) {
5454 int id = Phone_utils::get_enable_sim_for_dsss();
5455 init(id);
5456 }
5457}
5458
5459
5460//For UDP sokcet send response to client
5461static int SendRespToClient(const void *data, size_t dataSize)
5462{
5463 const uint8_t *toWrite;
5464 size_t writeOffset = 0;
5465
5466 toWrite = (const uint8_t *)data;
5467
5468 if (toWrite == NULL) {
5469 //buf is invaild
5470 return -1;
5471 }
5472
5473 while (writeOffset < dataSize) {
5474 ssize_t written;
5475 do {
5476 //written = write (fd, toWrite + writeOffset,dataSize - writeOffset);
5477 written = sendto(server_socket_fd, toWrite + writeOffset, dataSize - writeOffset,
5478 0, (struct sockaddr *)&client_addr, sizeof(client_addr));
5479 } while (written < 0 && ((errno == EINTR) || (errno == EAGAIN)));
5480
5481 if (written >= 0) {
5482 writeOffset += written;
5483 } else { // written < 0
5484 RLOGE ("RIL Response: unexpected error on write errno:%d", errno);
5485 return -1;
5486 }
5487 }
5488
5489 return 0;
5490}
5491
5492static UnsolResponseInfo* find_mtk_unsol_command(int request)
5493{
5494 int i;
5495 for (i = 0; i < (int32_t)NUM_ELEMS(s_mtk_unsolResponses); i++)
5496 if (s_mtk_unsolResponses[i].requestNumber == request)
5497 return (&s_mtk_unsolResponses[i]);
5498 return ((UnsolResponseInfo *)NULL);
5499}
5500
5501static int
5502onSupports (int requestCode)
5503{
5504 switch(requestCode)
5505 {
5506 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return 1;
5507 case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return 1;
5508 case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: return 1;
5509 case RIL_UNSOL_RESPONSE_NEW_SMS: return 1;
5510 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: return 1;
5511 case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: return 1;
5512 case RIL_UNSOL_ON_USSD: return 1;
5513 case RIL_UNSOL_ON_USSD_REQUEST: return 1;
5514 case RIL_UNSOL_NITZ_TIME_RECEIVED: return 1;
5515 case RIL_UNSOL_SIGNAL_STRENGTH: return 1;
5516 case RIL_UNSOL_DATA_CALL_LIST_CHANGED: return 1;
5517 case RIL_UNSOL_SUPP_SVC_NOTIFICATION: return 1;
5518 case RIL_UNSOL_STK_SESSION_END: return 1;
5519 case RIL_UNSOL_STK_PROACTIVE_COMMAND: return 1;
5520 case RIL_UNSOL_STK_EVENT_NOTIFY: return 1;
5521 case RIL_UNSOL_STK_CALL_SETUP: return 1;
5522 case RIL_UNSOL_SIM_SMS_STORAGE_FULL: return 1;
5523 case RIL_UNSOL_SIM_REFRESH: return 1;
5524 case RIL_UNSOL_CALL_RING: return 1;
5525 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: return 1;
5526 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: return 1;
5527 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: return 1;
5528 case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: return 0;
5529 case RIL_UNSOL_RESTRICTED_STATE_CHANGED: return 1;
5530 case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: return 1;
5531 case RIL_UNSOL_CDMA_CALL_WAITING: return 1;
5532 case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: return 0;
5533 case RIL_UNSOL_CDMA_INFO_REC: return 0;
5534 case RIL_UNSOL_OEM_HOOK_RAW: return 1;
5535 case RIL_UNSOL_RINGBACK_TONE: return 1;
5536 case RIL_UNSOL_RESEND_INCALL_MUTE: return 0;
5537 case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: return 0;
5538 case RIL_UNSOL_CDMA_PRL_CHANGED: return 0;
5539 case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: return 1;
5540 case RIL_UNSOL_RIL_CONNECTED: return 1;
5541 case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED: return 1;
5542 case RIL_UNSOL_CELL_INFO_LIST: return 1;
5543 case RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED: return 1;
5544 case RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED: return 1;
5545 case RIL_UNSOL_SRVCC_STATE_NOTIFY: return 1;
5546 case RIL_UNSOL_HARDWARE_CONFIG_CHANGED: return 0;
5547 case RIL_UNSOL_DC_RT_INFO_CHANGED: return 0;
5548 case RIL_UNSOL_RADIO_CAPABILITY : return 1;
5549 case RIL_UNSOL_MAL_RESTART : return 1;
5550 case RIL_UNSOL_CALL_INFO_INDICATION : return 1;
5551 case RIL_UNSOL_CRSS_NOTIFICATION : return 0;
5552 case RIL_UNSOL_ECONF_SRVCC_INDICATION : return 1;
5553 case RIL_UNSOL_ECONF_RESULT_INDICATION : return 1;
5554 case RIL_UNSOL_STK_BIP_PROACTIVE_COMMAND : return 0;
5555 case RIL_UNSOL_MAL_AT_INFO: return 1;
5556 case RIL_UNSOL_ECALL_MSDHACK: return 1;
5557 case RIL_UNSOL_TX_POWER: return 1;
5558 case RIL_UNSOL_NETWORK_INFO: return 1;
5559#ifdef ECALL_SUPPORT
5560 case RIL_UNSOL_ECALL_INDICATIONS: return 1;
5561#endif /*ECALL_SUPPORT*/
5562#ifdef KEEP_ALIVE
5563 case RIL_UNSOL_KEEPALIVE_STATUS_PRO: return 1;
5564#endif /*KEEP_ALIVE*/
5565 case RIL_UNSOL_ON_USSI: return 1;
5566 case RIL_UNSOL_ECC_NUM: return 1;
5567 case RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR: return 1;
5568 default: return 0;
5569 }
5570}
5571
5572int parse_param(char *cmd, char *argv[], int max_args)
5573{
5574 char *pos, *pos2;
5575 int argc = 0;
5576 printf("warren test cmd=%s\n",cmd);
5577 pos = cmd;
5578 while (1) {
5579 // Trim the space characters.
5580 while (*pos == ' ') {
5581 pos++;
5582 }
5583
5584 if (*pos == '\0') {
5585 break;
5586 }
5587
5588 // One token may start with '"' or other characters.
5589 if (*pos == '"' && (pos2 = strrchr(pos+1, '"'))) {
5590 argv[argc++] = pos + 1;
5591 *pos2 = '\0';
5592 pos = pos2 + 1;
5593 if(*pos == '\n'){
5594 *pos = '\0';
5595 pos = pos + 1;
5596 }
5597
5598 } else {
5599 argv[argc++] = pos;
5600 while (*pos != '\0' && *pos != ' '&& *pos != '\n') {
5601 pos++;
5602 }
5603 *pos++ = '\0';
5604
5605 if(argc == 1) {
5606 char* at_cmd = strstr(argv[0], "RIL_REQUEST_OEM_HOOK_RAW");
5607 if(at_cmd != NULL) {
5608 while (*pos == ' ') {
5609 pos++;
5610 }
5611 argv[argc++] = pos;
5612 while (*pos != '\0' && *pos != '\n') {
5613 pos++;
5614 }
5615 *pos++ = '\0';
5616 break;
5617 }
5618 }
5619
5620 }
5621
5622 // Check if the maximum of arguments is reached.
5623 if (argc == max_args) {
5624 break;
5625 }
5626 }
5627
5628 return argc;
5629}
5630
5631/* Look up NAME as the name of a command, and return a pointer to that
5632 command. Return a NULL pointer if NAME isn't a command name. */
5633COMMAND* find_command (char *name)
5634{
5635 register int i;
5636
5637 for (i = 0; commands[i].name; i++)
5638 if (strcmp (name, commands[i].name) == 0)
5639 return (&commands[i]);
5640
5641 return ((COMMAND *)NULL);
5642}
5643
5644CommandInfo* find_mtk_command (int request)
5645{
5646 int i;
5647 for (i = 0; i < (int32_t)NUM_ELEMS(mtk_s_command); i++)
5648 if (mtk_s_command[i].requestNumber == request)
5649 return (&mtk_s_command[i]);
5650 return ((CommandInfo *)NULL);
5651}
5652
5653/* The user wishes to quit using this program. Just set DONE non-zero. */
5654static int com_quit (int argc, char *argv[], RIL_SOCKET_ID socket_id, RequestInfo *pRI)
5655{
5656 exit(EXIT_SUCCESS);
5657 return (0);
5658}
5659
5660static int enableSyslog(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
5661{
5662 if(argc < 2)
5663 {
5664 RLOGE("[Error] enable syslog paramter is error\n");
5665 free(pRI);
5666 return -1;
5667 }
5668 enable_syslog = atoi(argv[1]);
5669 RLOGE("%s syslog\n",enable_syslog ? "enable" :"disable");
5670 free(pRI);
5671 return 0;
5672}
5673
5674static int enableBTResponse(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
5675{
5676 if(argc < 2)
5677 {
5678 RLOGE("[Error] enable BT response paramter is error\n");
5679 free(pRI);
5680 return -1;
5681 }
5682 enable_bt_resp = atoi(argv[1]);
5683 RLOGE("%s bt response!\n",enable_bt_resp ? "enable" :"disable");
5684 free(pRI);
5685 return 0;
5686
5687}
5688
5689char Time_buf[24];
5690void GetTimeString(char * buf)
5691{
5692 time_t timep;
5693 struct tm p;
5694
5695 if(buf == NULL){
5696 RLOGE("[Error] GetTimeString: buf is Null\n");
5697 return;
5698 }
5699 //memset(buf,0,sizeof(buf));
5700 time(&timep);
5701 localtime_r(&timep,&p);
5702 sprintf(buf,"%d_%d_%d %d:%d:%d",(1900+p.tm_year),(1+p.tm_mon),p.tm_mday,
5703 (p.tm_hour),p.tm_min,p.tm_sec);
5704// printf("data is %s\n",buf);
5705
5706 return;
5707}
5708/*Warren add for t800 RIL Service 2021/12/10 start*/
5709int lynqAssemblyParcelheader(Parcel &p,int slot,int request,int respType,int error)
5710{
5711 p.writeInt32 (respType);
5712 p.writeInt32 (request);
5713 /*warren add for t800 ril servie 2021/12/15 start*/
5714 p.writeInt32(slot);
5715 /*warren add for t800 ril servie 2021/12/15 end*/
5716 p.writeInt32 (error);
5717 return 0;
5718}
5719void LYNQ_RIL_urcClientInit()
5720{
5721 int len = 0;
5722 int on=1;
5723 int ret = 0;
5724 lynq_urc_socket_fd = socket(AF_INET,SOCK_DGRAM,0);
5725 if(lynq_urc_socket_fd < 0)
5726 {
5727 perror("creaet socket for udp fail");
5728 return;
5729 }
5730 /* 设置socket允许重复使用地址与端口,SO_REUSEADDR值为2 */
5731 //setsockopt(socket_fd,SOL_SOCKET,SO_REUSEADDR,&on,sizeof on);
5732 /* 使能广播功能,SO_BROADCAST值为6 */
5733 ret= setsockopt(lynq_urc_socket_fd,SOL_SOCKET,SO_BROADCAST,&on,sizeof(on));
5734 if(ret<0)
5735 {
5736 RLOGD("set broadcast fail!!!\n");
5737 exit(1);
5738 }
5739 urc_broadcast_addr.sin_family = AF_INET; //IPv4
5740 urc_broadcast_addr.sin_port = htons(LYNQ_BRODCAST_PORT);
5741 urc_broadcast_addr.sin_addr.s_addr = inet_addr("255.255.255.255" );//255.255.255.255 broadcast addrress.
5742 printf("LYNQ_RIL_urcClientInit success!!!\n");
5743 return;
5744 /*
5745 while(1)
5746 {
5747 len = sendto(lynq_urc_socket_fd,"hello world",11,0,(struct sockaddr *)&urc_broadcast_addr,sizeof(urc_broadcast_addr));
5748 if(len > 0)
5749 {
5750 printf("sendto success,len=%d\n",len);
5751 }
5752 else
5753 {
5754 printf("sendto fail\n");
5755 }
5756 sleep(1);
5757 }
5758 */
5759}
5760void LYNQ_RIL_RecSocket()
5761{
5762 RLOGD("LYNQ_RIL_RecSocket start\n");
5763 char *argv[MAX_ARGS];
5764 int argc = 0;
5765 int ep_fd = 0;
5766 int en_fd = 0;
5767 struct epoll_event lynq_ev;
5768 struct epoll_event lynq_events[LYNQ_SOCKET_ENVNT_FD_MAX];
5769 //prctl(PR_SET_NAME,(unsigned long)"UDP_Thr");
5770
5771 /*listen UPD SOCKET port */
5772 struct sockaddr_in server_addr;
5773 struct sockaddr_in lynqClient_addr;
5774 bzero(&server_addr, sizeof(server_addr));
5775 server_addr.sin_family = AF_INET;
5776 server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
5777 server_addr.sin_port = htons(LYNQ_SERVICE_PORT);
5778 /* create socket */
5779 //int server_socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
5780 server_socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
5781 if(server_socket_fd == -1)
5782 {
5783 RLOGE("Create Socket Failed:");
5784 exit(1);
5785 }
5786
5787 /* bind socket port*/
5788 if(-1 == (bind(server_socket_fd,(struct sockaddr*)&server_addr,sizeof(server_addr))))
5789 {
5790 RLOGE("Server Bind Failed:");
5791 exit(1);
5792 }
5793 /* create epoll fd,add socket to epoll */
5794 ep_fd = epoll_create(LYNQ_SOCKET_ENVNT_FD_MAX);
5795 //int len = sizeof(struct sockaddr_in);
5796 lynq_ev.events = EPOLLIN | EPOLLET;
5797 lynq_ev.data.fd = server_socket_fd;
5798 if(epoll_ctl(ep_fd, EPOLL_CTL_ADD, server_socket_fd, &lynq_ev) < 0)
5799 {
5800 fprintf(stderr, "epoll set insertion error: fd=%d\n", server_socket_fd);
5801 return;
5802 }
5803 else
5804 {
5805 printf("monitor socket add epoll success!!!\n");
5806 }
5807 char buffer[LYNQ_SOCKET_BUFFER];
5808 lynq_client_t *client_tmp = NULL;
5809 /* tranlate data */
5810 while(true)
5811 {
5812 if(!s_registerCalled)
5813 {
5814 sleep(1);
5815 continue;
5816 }
5817 en_fd = epoll_wait(ep_fd, lynq_events, 10000, -1);//###Check valid
5818 if(en_fd <=0 )
5819 {
5820 continue;
5821 }
5822 for (int n = 0; n < en_fd; ++n)
5823 {
5824 if (lynq_events[n].data.fd == server_socket_fd)
5825 {
5826 /* define address to catch the client addreess*/
5827 //struct sockaddr_in client_addr;
5828 socklen_t client_addr_length = sizeof(lynqClient_addr);
5829 /* receive the data */
5830 bzero(buffer, LYNQ_SOCKET_BUFFER);
5831 if(recvfrom(server_socket_fd, buffer, LYNQ_SOCKET_BUFFER,0,(struct sockaddr*)&lynqClient_addr, &client_addr_length) == -1)
5832 {
5833 RLOGE("Receive Data Failed:");
5834 continue;
5835 }
5836 client_tmp = (lynq_client_t*)buffer;
5837 RLOGD("[LYNQ socketId] utoken=%d,request=%d,len=%d,param=%s",client_tmp->uToken,client_tmp->request,client_tmp->paramLen,client_tmp->param);
5838 //char test[36] = {};
5839 //sprintf(test,"test okay len = %d",client_tmp->paramLen);
5840 //sendto(server_socket_fd,test,strlen(test),0,(struct sockaddr*)&client_addr,client_addr_length);
5841 argv[0] = (char *)lynq_requset_to_string(client_tmp->request);
5842 argc = 0;
5843 if(client_tmp->paramLen > 0)
5844 {
5845 /*transfer struct*/
5846 argc = parse_param(client_tmp->param, argv+1, MAX_ARGS);
5847 if(argc < 1)
5848 {
5849 RLOGE("%s: error input.", buffer);
5850 continue;
5851 }
5852 }
5853 printf("argc =%d\n",argc);
5854 argc = argc+1;
5855 for(int t = 0;t<argc;t++)
5856 {
5857 RLOGD("warren test argv[%d]=%s\n",t,argv[t]);
5858 }
5859 COMMAND *command = find_command(argv[0]);
5860 if(!command)
5861 {
5862 RLOGE("%s: No such command for DemoApp", argv[0]);
5863 continue;
5864 }
5865 int32_t request;
5866 request = command->request;
5867 RIL_SOCKET_ID id = RIL_SOCKET_1;
5868 if(utils::is_support_dsds()) {
5869 id = (RIL_SOCKET_ID)get_default_sim_all_except_data();
5870 } else if(utils::is_suppport_dsss()) {
5871 id = (RIL_SOCKET_ID)Phone_utils::get_enable_sim_for_dsss();
5872 }
5873 if(request == -1)
5874 {
5875 (*(command->func)) (argc, argv, id, NULL);
5876 continue;
5877 }
5878 if (request < 1 || (request >= (int32_t)NUM_ELEMS(s_commands) && request < RIL_REQUEST_VENDOR_BASE)) {
5879 RLOGW("unsupported request code %d token %d", request);
5880 // FIXME this should perhaps return a response
5881 continue;
5882 }
5883 RLOGD("REQUEST: %s ParamterNum:%d", requestToString(request), argc);
5884 RequestInfo *pRI = creatRILInfoAndInit(request, UDP, (RIL_SOCKET_ID)(id));
5885 pRI->uToken = client_tmp->uToken;
ll90a255c2022-04-07 09:09:55 +00005886 pRI->lynqEvent = 2;
lh7b0674a2022-01-10 00:34:35 -08005887 pRI->uClient_addr.sin_family = lynqClient_addr.sin_family;
5888 pRI->uClient_addr.sin_addr.s_addr = lynqClient_addr.sin_addr.s_addr;
5889 pRI->uClient_addr.sin_port = lynqClient_addr.sin_port;
5890 //sendto(server_socket_fd,test,strlen(test),0,(struct sockaddr*)&pRI->uClient_addr,client_addr_length);
5891 //pRI->uClient_addr.sa_family = (struct sockaddr)client_addr.sa_family;
5892 //memcpy(pRI->uClient_addr.sa_data,&client_addr
5893 //Radio on/off only allow one thread operate.
5894 if(request == RIL_REQUEST_RADIO_POWER)
5895 {
5896 speciaRequest_wait();
5897 }
5898 memset(Time_buf,0,sizeof(Time_buf));
5899 GetTimeString(Time_buf);
5900 //FUNCTION_CALLED(Time_buf,requestToString(request));
5901 int waittoken = pRI->token;
5902 (*(command->func)) (argc, argv, pRI->socket_id, pRI);
5903 FUNCTION_CALLED(Time_buf,requestToString(request));
5904 waitResponse(waittoken);
5905 memset(Time_buf,0,sizeof(Time_buf));
5906 GetTimeString(Time_buf);
5907 FUNCTION_RETURN(Time_buf,requestToString(request));
5908 }
5909 }
5910 }
5911 RLOGD("close socket fd");
5912 close(server_socket_fd);
5913 return ;
5914}
5915int LYNQ_RIL_respSocket(Parcel &p,RIL_Token t)
5916{
5917 RLOGD("LYNQ_RIL_respSocket send start");
lh7b0674a2022-01-10 00:34:35 -08005918 ssize_t sent = 0;
lh7b0674a2022-01-10 00:34:35 -08005919 RequestInfo *pRI = (RequestInfo *)t;
ll90a255c2022-04-07 09:09:55 +00005920 if(pRI->lynqEvent!=2)
lh7b0674a2022-01-10 00:34:35 -08005921 {
5922 RLOGD("this is internal event!!!");
5923 return -1;
5924 }
5925 int dataSize = p.dataSize();
5926 const uint8_t* data = p.data();
5927 RLOGD("lynqSocketSend RESPONSE!!!! ");
lh7b0674a2022-01-10 00:34:35 -08005928 sent = sendto(server_socket_fd, data, dataSize, 0, (struct sockaddr *)&pRI->uClient_addr, sizeof(pRI->uClient_addr));
5929 if( sent < 0 )
5930 {
5931 RLOGE("lynqSocketSend send datalen fail (sent=%d, sendFD=%d, dataSize=%d)",
5932 sent,server_socket_fd, dataSize);
lh7b0674a2022-01-10 00:34:35 -08005933 return -1;
5934 }
5935 return 0;
5936}
5937int LYNQ_RIL_respSocket_sp(Parcel &p,RequestInfo *pRI)
5938{
5939 RLOGD("LYNQ_RIL_respSocket send start");
5940 int ret =0;
5941 bool sendResult =false;
5942 ssize_t sent = 0;
5943 uint8_t dataLength[4];
5944 int verify = 0x55aa;
5945 int dataSize = p.dataSize();
5946 const uint8_t* data = p.data();
ll90a255c2022-04-07 09:09:55 +00005947 if(pRI->lynqEvent!=2)
lh7b0674a2022-01-10 00:34:35 -08005948 {
5949 RLOGD("this is internal event!!!");
5950 return -1;
5951 }
5952 RLOGD("lynqSocketSend RESPONSE!!!! ");
lh7b0674a2022-01-10 00:34:35 -08005953
5954 sent = sendto(server_socket_fd, data, dataSize, 0, (struct sockaddr *)&pRI->uClient_addr, sizeof(pRI->uClient_addr));
5955 if( sent < 0 )
5956 {
5957 RLOGE("lynqSocketSend send datalen fail (sent=%d, sendFD=%d, dataSize=%d)",
5958 sent,server_socket_fd, dataSize);
lh7b0674a2022-01-10 00:34:35 -08005959 return -1;
5960 }
5961 return 0;
5962}
5963
5964int LYNQ_RIL_urcBroadcast(Parcel &p)
5965{
5966 RLOGD("LYNQ_RIL_urcBroadcast send start");
5967 int ret =0;
5968 bool sendResult =false;
5969 ssize_t sent = 0;
5970 uint8_t dataLength[4];
5971 int verify = 0x55aa;
lhf6eea122022-01-20 19:32:14 -08005972 p.setDataPosition(0);
lh7b0674a2022-01-10 00:34:35 -08005973 int dataSize = p.dataSize();
5974 const uint8_t* data = p.data();
5975 sent = sendto(lynq_urc_socket_fd, data, dataSize, 0, (struct sockaddr *)&urc_broadcast_addr, sizeof(urc_broadcast_addr));
5976 if( sent < 0 )
5977 {
5978 RLOGE("LYNQ_RIL_urcBroadcast send datalen fail (sent=%d, sendFD=%d, dataSize=%d)",
5979 sent,lynq_urc_socket_fd, dataSize);
5980 return -1;
5981 }
5982 return 0;
5983}
5984/*Warren add for t800 RIL Service 2021/12/10 end*/
5985
5986void
5987RIL_StartRevSocket()
5988{
5989 RLOGD("RIL_StartRevSocket start\n");
xja1c30b82022-01-25 16:13:48 +08005990 char *argv[MAX_ARGS] = {0};
lh7b0674a2022-01-10 00:34:35 -08005991 int argc = 0;
5992
5993 prctl(PR_SET_NAME,(unsigned long)"UDP_Thr");
5994
5995 /*listen UPD SOCKET port */
5996 struct sockaddr_in server_addr;
5997 bzero(&server_addr, sizeof(server_addr));
5998 server_addr.sin_family = AF_INET;
5999 server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
6000 server_addr.sin_port = htons(SERVER_PORT);
6001 /* create socket */
6002 //int server_socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
6003 server_socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
6004 if(server_socket_fd == -1)
6005 {
6006 RLOGE("Create Socket Failed:");
6007 exit(1);
6008 }
6009
6010 /* bind socket port*/
6011 if(-1 == (bind(server_socket_fd,(struct sockaddr*)&server_addr,sizeof(server_addr))))
6012 {
6013 RLOGE("Server Bind Failed:");
6014 exit(1);
6015 }
6016
6017 /* tranlate data */
6018 while(true)
6019 {
6020 if(!s_registerCalled)
6021 {
6022 sleep(1);
6023 continue;
6024 }
6025 /* define address to catch the client addreess*/
6026 //struct sockaddr_in client_addr;
6027 socklen_t client_addr_length = sizeof(client_addr);
6028
6029 /* receive the data */
6030 char buffer[BUFFER_SIZE];
6031 bzero(buffer, BUFFER_SIZE);
6032 if(recvfrom(server_socket_fd, buffer, BUFFER_SIZE,0,(struct sockaddr*)&client_addr, &client_addr_length) == -1)
6033 {
6034 RLOGE("Receive Data Failed:");
6035 continue;
6036 }
6037 RLOGD("DemoAPP:%s, receve: %s", inet_ntoa(client_addr.sin_addr), buffer);
6038 if(mtkItTest(buffer)) {
6039 RLOGD("mtkItTest() handle.");
6040 continue;
6041 }
6042 int argc = parse_param(buffer, argv, MAX_ARGS);
6043 if(argc < 1)
6044 {
6045 RLOGE("%s: error input.", buffer);
6046 continue;
6047 }
6048 COMMAND *command = find_command(argv[0]);
6049 if(!command)
6050 {
6051 RLOGE("%s: No such command for DemoApp", argv[0]);
6052 continue;
6053 }
6054
6055 int32_t request;
6056
6057 request = command->request;
6058
6059 RIL_SOCKET_ID id = RIL_SOCKET_1;
6060 if(utils::is_support_dsds()) {
6061 id = (RIL_SOCKET_ID)get_default_sim_all_except_data();
6062 } else if(utils::is_suppport_dsss()) {
6063 id = (RIL_SOCKET_ID)Phone_utils::get_enable_sim_for_dsss();
6064 }
6065
6066 if(request == -1)
6067 {
6068 (*(command->func)) (argc, argv, id, NULL);
6069 continue;
6070 }
6071
6072 if (request < 1 || (request >= (int32_t)NUM_ELEMS(s_commands) && request < RIL_REQUEST_VENDOR_BASE)) {
6073 RLOGW("unsupported request code %d token %d", request);
6074 // FIXME this should perhaps return a response
6075 continue;
6076 }
6077
6078 RLOGD("REQUEST: %s ParamterNum:%d", requestToString(request), argc);
6079
6080
6081 RequestInfo *pRI = creatRILInfoAndInit(request, UDP, (RIL_SOCKET_ID)(id));
6082 //Radio on/off only allow one thread operate.
6083 if(request == RIL_REQUEST_RADIO_POWER)
6084 {
6085 speciaRequest_wait();
6086 }
6087 memset(Time_buf,0,sizeof(Time_buf));
6088 GetTimeString(Time_buf);
6089 //FUNCTION_CALLED(Time_buf,requestToString(request));
6090 int waittoken = pRI->token;
6091 (*(command->func)) (argc, argv, pRI->socket_id, pRI);
6092 FUNCTION_CALLED(Time_buf,requestToString(request));
6093 waitResponse(waittoken);
6094 memset(Time_buf,0,sizeof(Time_buf));
6095 GetTimeString(Time_buf);
6096 FUNCTION_RETURN(Time_buf,requestToString(request));
6097 }
6098
6099 RLOGD("close socket fd");
6100 close(server_socket_fd);
6101 return ;
6102}
6103
6104const int waitResponse(int token)
6105{
6106 int waitToken = token;
6107 struct timeval now;
6108 struct timespec timeout;
6109 if((token&BLOCK_MARK) != BLOCK_MARK){
6110 RLOGD("No need wait!,token is %x!",token);
6111 return 0;
6112 }
6113
6114 gettimeofday(&now,NULL);
6115 timeout.tv_sec = now.tv_sec+60; //timeout is 1min
6116 timeout.tv_nsec = now.tv_usec*1000;
6117
6118 RLOGD("Block Request, wait token is %x,",waitToken);
6119 BLOCK_LOCK();
6120 if(waitToken == wakeup_token)
6121 RLOGD("response early than return, wait token is %x, wakeup token is %x",waitToken, wakeup_token);
6122 while(!(waitToken == wakeup_token)) {
6123 RLOGD("Wait Response, wait token is %x, wakeup token is %x",waitToken, wakeup_token);
6124 int ret = BLOCK_WAIT(&timeout);
6125 if(ret == ETIMEDOUT){
6126 RLOGD("Wait Response timeout, wait token is %x, wakeup token is %x",waitToken, wakeup_token);
6127 goto out;
6128 }
6129 }
6130 RLOGD("Response wakeup,token is %x!",wakeup_token);
6131 wakeup_token = -1;
6132out:
6133 BLOCK_UNLOCK();
6134 return 0;
6135}
6136
lld164b022022-03-29 14:01:01 +08006137/**
6138 * @brief check at input in at_buffer
6139 * @param buf type:in at port input
6140 * @return int
6141 */
6142static int lynq_inside_at_buffer(char *buf)
6143{
6144 for(int i = 0; i < MAX_AT_CMD; i++)
6145 {
6146 if(at_buf_ext[i] == NULL)
6147 {
6148 break;
6149 }
6150 else
6151 {
llf4be54d2022-04-18 08:08:38 +00006152 if(strstr(buf, at_buf_ext[i]))
lld164b022022-03-29 14:01:01 +08006153 {
6154 return 1;
6155 }
6156 }
6157 }
6158 return 0;
6159}
6160
6161/**
6162 * @brief send input to client
6163 * @param buffer type:in buffer from at port
6164 * @param len_buf type:in strlen(buffer)
6165 * @param client type:in sockaddr client
6166 * @return int
6167 */
6168static int lynq_send_info(char *buffer, int len_buf, struct sockaddr* client)
6169{
6170 socklen_t len = sizeof(*client);
6171 int sent = sendto(sockfd,buffer,len_buf,0,client,len);
6172 if( sent < 0 )
6173 {
6174 RLOGE("lynq_send_info send fail (sent=%d, sendFD=%d, dataSize=%d)",
6175 sent,sockfd, len);
6176 return sent;
6177 }
6178 return 0;
6179}
6180
6181/**
6182 * @brief Fetch data from a one-dimensional array into a two-dimensional array
6183 *
6184 * @param cmd type:in buffer from client
6185 * @param argv type:in two-dimensional array
6186 * @param cnt type:in Two dimensional array subscript
6187 * @return int
6188 */
6189static int lynq_parse_at_cmd(char *cmd, char *argv[], int cnt)
6190{
6191 if(NULL == cmd || NULL == argv)
6192 {
6193 return -1;
6194 }
6195 if(cnt > MAX_AT_CMD)
6196 {
6197 return -1;
6198 }
6199 const char s[2] = ";";
6200 char *token;
6201 int argc = cnt;
6202 token = strtok(cmd, s);
6203 while( token != NULL ) {
6204 argv[argc++] = token;
6205 token = strtok(NULL, s);
6206 }
6207 return 0;
6208}
6209
6210/**
6211 * @brief count at cmd amount
6212 *
6213 * @param type:in buffer
6214 * @return int
6215 */
6216static int lynq_count_at(char *buffer)
6217{
6218 char *p = buffer;
6219 int count = 0;
6220 while(*p != '\0')
6221 {
6222 if(*p == ';')
6223 {
6224 count++;
6225 }
6226 *p++;
6227 }
6228 return count+1;
6229}
6230
6231/**
6232 * @brief receive registion and display on at port
6233 * @param parm type:in
6234 * @return void*
6235 */
6236void *receive_at(void *parm)
6237{
6238 RLOGE("receive_at thread start\n");
6239 struct sockaddr* cli = (struct sockaddr*)parm;
6240 socklen_t len;
6241 int recv = 0;
6242 char display[1024] = {0};
6243 /*For at extension to receive at buffer*/
llacba3662022-04-15 16:57:13 +08006244 bool flag = false;
lld164b022022-03-29 14:01:01 +08006245 int count_at_cmd = 0;
6246 len = sizeof(*cli);
6247 while(1)
6248 {
llacba3662022-04-15 16:57:13 +08006249 if(!flag)
lld164b022022-03-29 14:01:01 +08006250 {
6251 RLOGE("receive third at cmd\n");
6252 recv = recvfrom(sockfd, buffer_at, LYNQ_AT_SOCKET_BUFFER, 0, cli, &len);
6253 if(recv < 0)
6254 {
6255 RLOGE("recv fail\n");
6256 continue;
6257 }
6258 RLOGE("recvfrom from client\n");
6259 /*parse buffer for at command*/
6260 count_at_cmd = lynq_count_at(buffer_at);
6261 if(count_at_cmd > MAX_AT_CMD)
6262 {
6263 RLOGE("too many at cmd\n");
6264 continue;;
6265 }
6266 lynq_parse_at_cmd(buffer_at, at_buf_ext, 0);
llacba3662022-04-15 16:57:13 +08006267 flag = true;
lld164b022022-03-29 14:01:01 +08006268 }
6269 else
6270 {
6271 RLOGE("display output on at port\n");
6272 bzero(display, 1024);
6273 recv = recvfrom(sockfd, display, LYNQ_AT_SOCKET_BUFFER, 0, cli, &len);
6274 if(recv < 0)
6275 {
6276 RLOGE("recv fail\n");
6277 continue;
6278 }
6279 /*display on at port*/
6280 else
6281 {
6282 strcat(display, "\n");
6283 int n = write(ttyGS3_fd,display,strlen(display));
6284 if(n<0)
6285 {
6286 RLOGE("lynq resp write error");
6287 }
6288 }
6289 }
lld164b022022-03-29 14:01:01 +08006290 }
6291 return NULL;
6292}
6293
llaaca09b2022-03-14 16:14:28 +08006294void startUsbLoop(void)
6295{
lld164b022022-03-29 14:01:01 +08006296 /*lei add*/
6297 //Create a network communication object
6298 struct sockaddr_in addr_serv;
6299 struct sockaddr_in addr_clie;
6300 //Creating a Socket object
6301 sockfd=socket(AF_INET,SOCK_DGRAM,0);
6302 memset(&addr_serv, 0, sizeof(addr_serv));
6303 addr_serv.sin_family =AF_INET;
6304 addr_serv.sin_port =htons(LYNQ_AT_SERVICE_PORT);
6305 addr_serv.sin_addr.s_addr=htonl(INADDR_ANY);
6306 bind(sockfd,(struct sockaddr*)&addr_serv,sizeof(addr_serv));
6307 //receive registion and display on at port
6308 pthread_t thid;
6309 if(pthread_create(&thid, NULL, receive_at, (struct sockaddr*)&addr_clie) != 0) {
6310 RLOGE("thread creation failed\n");
6311 exit(1);
6312 }
6313 RLOGE("thread creation\n");
6314 /*lei add*/
llaaca09b2022-03-14 16:14:28 +08006315 int nread=-1;
6316 int n = -1;
6317 int routeId = -1;
6318 char buffer[1024]={};
6319 char tempbuf[1024]={};
6320 char buf_parser[64] = {};
6321 int argc = 0;
6322 char *argv[MAX_ARGS];//argv[0]:at name,argv[1]:raw data,argv[2]:at type,argv[3]:paramter1,argv[4]:paramter2 ....
6323 char eBuf[1024];
6324 ttyGS3_fd = open("/dev/ttyGS3",O_RDWR);
6325 if(ttyGS3_fd==-1)
6326 {
6327 RLOGE("open ttyGS3 failure!!!");
6328 printf("open ttyGS3 failure!!!\n");
6329 //printf("%s\n",strerr(errno));
6330 perror("--test--");
6331 kill(0, SIGKILL);
6332 }
lld164b022022-03-29 14:01:01 +08006333 RLOGD("[%s]open %s successfully!!!\n",__FUNCTION__,ttyname(ttyGS3_fd));
llaaca09b2022-03-14 16:14:28 +08006334 while(1)
6335 {
6336 bzero(buffer, 1024);
6337 bzero(tempbuf, 1024);
6338 bzero(buf_parser, 64);
6339 if((nread=read(ttyGS3_fd,buffer,1024))>0)
6340 {
6341 if(nread<2)
6342 {
6343 //RLOGD("input is space!!!");
6344 continue;
6345 }
6346 buffer[nread-1] = '\0';
6347 //printf("buffer is %s\n",buffer);
6348 for(int i = 0 ; i < nread ; i++)
6349 {
6350 if(buffer[i]=='=')
6351 {
6352 break;
6353 }
6354 if(buffer[i]>='a'&&buffer[i]<='z')
6355 {
6356 buffer[i] = buffer[i]-32;
6357 }
6358 }
lld164b022022-03-29 14:01:01 +08006359 RLOGD("buffer is %s\n",buffer);
6360 /*lei add*/
6361 /*check third cmd in buffer*/
6362 if(lynq_inside_at_buffer(buffer))
llaaca09b2022-03-14 16:14:28 +08006363 {
lld164b022022-03-29 14:01:01 +08006364 lynq_send_info(buffer, nread, (struct sockaddr*)&addr_clie);
llaaca09b2022-03-14 16:14:28 +08006365 }
lld164b022022-03-29 14:01:01 +08006366 /*lei add*/
6367 else
llaaca09b2022-03-14 16:14:28 +08006368 {
lld164b022022-03-29 14:01:01 +08006369 argc = lynqParseUsbCommand(buffer,argv,tempbuf,buf_parser,MAX_ARGS);
6370 if(argc<0)
6371 {
6372 bzero(eBuf, 1024);
6373 sprintf(eBuf,"LYNQ:%s not support!!!\n",buffer);
6374 int n = write(ttyGS3_fd,eBuf,strlen(eBuf));
llaaca09b2022-03-14 16:14:28 +08006375 if(n<0)
6376 {
6377 perror("lynq resp write:");
6378 }
lld164b022022-03-29 14:01:01 +08006379 RLOGD("n = %d\n",n);
llaaca09b2022-03-14 16:14:28 +08006380 continue;
lld164b022022-03-29 14:01:01 +08006381 }
6382 usb_at_transfer_t *atCmd = lynqFindId(argv[0]);
6383 if(atCmd==NULL)
llaaca09b2022-03-14 16:14:28 +08006384 {
lld164b022022-03-29 14:01:01 +08006385 RLOGD("LYNQ send ATCMD:%s!!!",argv[1]);
llaaca09b2022-03-14 16:14:28 +08006386 lynqSendAt(argc,argv,1010);
lld164b022022-03-29 14:01:01 +08006387 continue;
llaaca09b2022-03-14 16:14:28 +08006388 }
lld164b022022-03-29 14:01:01 +08006389 if(!((1<<atoi(argv[2])) & (atCmd->support)))
llaaca09b2022-03-14 16:14:28 +08006390 {
lld164b022022-03-29 14:01:01 +08006391 RLOGD("LYNQ %s not support!!!",atCmd->cmdName);
6392 int n = write(ttyGS3_fd,"\n+CME ERROR: 100\n",strlen("\n+CME ERROR: 100\n"));
6393 if(n<0)
llaaca09b2022-03-14 16:14:28 +08006394 {
lld164b022022-03-29 14:01:01 +08006395 perror("lynq resp write:");
llaaca09b2022-03-14 16:14:28 +08006396 }
lld164b022022-03-29 14:01:01 +08006397 continue;
llaaca09b2022-03-14 16:14:28 +08006398 }
lld164b022022-03-29 14:01:01 +08006399 routeId = routeCmd(atCmd->cmdId);
6400 //routeId = routeCmd(atcmd->cmdId);
6401 //routeId = LYNQ_GOTO_AT;
6402 switch(routeId)
llaaca09b2022-03-14 16:14:28 +08006403 {
lld164b022022-03-29 14:01:01 +08006404 case LYNQ_GOTO_AT:
llaaca09b2022-03-14 16:14:28 +08006405 {
lld164b022022-03-29 14:01:01 +08006406 lynqSendAt(argc,argv,1010);
6407 break;
llaaca09b2022-03-14 16:14:28 +08006408 }
lld164b022022-03-29 14:01:01 +08006409 case LYNQ_GOTO_TELE_REQ:
6410 {
6411 usb_cmd_t *atCmdEvn = lynqFindUsbEvent(argv[0]);
6412 if(!atCmdEvn)
6413 {
6414 RLOGD("can not find at cmd event!!!");
6415 continue;
6416 }
6417 atCmdEvn->fun(argc,argv,atCmdEvn->rilRequest,1011);
6418 break;
6419 }
6420 case LYNQ_GOTO_USER_REQ:
6421 {
6422 usb_cmd_t *atCmdEvn = lynqFindUsbEvent(argv[0]);
6423 if(!atCmdEvn)
6424 {
6425 RLOGD("can not find at cmd event!!!");
6426 continue;
6427 }
6428 atCmdEvn->ufun(argc,argv,1012);
6429 break;
6430 }
6431 case LYNQ_GOTO_LINFO_REQ:
6432 {
6433 lynqInfo(argv);
6434 break;
6435 }
6436 // case LYNQ_GOTO_PLAT_REQ:
6437 // {
6438 // lynq_deal_with_log_at(&argv[3]);
6439 // break;
6440 // }
6441 case LYNQ_GOTO_RNDIS_REQ:
6442 {
6443 lynq_get_rndis_data(buffer);
6444 break;
6445 }
6446 case LYNQ_GOTO_FACTORY:
6447 {
6448 lynq_get_factory_data(argc,argv);
6449 break;
6450 }
6451 // case LYNQ_GOTO_FOTA:
6452 // {
6453 // lynq_atfota_test(argv);
6454 // break;
6455 // }
6456 default:
6457 break;
llaaca09b2022-03-14 16:14:28 +08006458 }
llaaca09b2022-03-14 16:14:28 +08006459 }
lld164b022022-03-29 14:01:01 +08006460
llaaca09b2022-03-14 16:14:28 +08006461 }
6462 }
6463 close(ttyGS3_fd);
6464 return;
6465}
6466
lh7b0674a2022-01-10 00:34:35 -08006467void *
6468eventLoop(void *param) {
6469 pthread_mutex_lock(&s_startupMutex);
6470 s_started = 1;
6471 pthread_cond_broadcast(&s_startupCond);
6472 pthread_mutex_unlock(&s_startupMutex);
6473 #ifdef ECALL_SUPPORT
6474 init_ecall_timer_all();
6475 #endif /**/ECALL_SUPPORT
6476 /*warren add for t800 ril service 2021/12/13 start*/
6477 //RIL_StartRevSocket();
6478 LYNQ_RIL_urcClientInit();
6479 LYNQ_RIL_RecSocket();
6480 /*warren add for t800 ril service 2021/12/13 end*/
6481 RLOGD("error in event_loop_base errno:%d", errno);
6482 // kill self to restart on error
6483 kill(0, SIGKILL);
6484
6485 return NULL;
6486}
6487
llaaca09b2022-03-14 16:14:28 +08006488
6489void *
6490eventLoop_at(void *param) {
6491 pthread_mutex_lock(&s_startupMutex);
6492 s_started = 1;
6493 pthread_cond_broadcast(&s_startupCond);
6494 pthread_mutex_unlock(&s_startupMutex);
6495 //RIL_StartRevSocket();
6496 startUsbLoop();
6497 //startUsbLoop_test();
6498 RLOGD("error in event_loop_base errno:%d", errno);
6499 // kill self to restart on error
6500 kill(0, SIGKILL);
6501
6502 return NULL;
6503}
6504
lld164b022022-03-29 14:01:01 +08006505
6506
lh7b0674a2022-01-10 00:34:35 -08006507const int RspDispFunction(int request,char* arg, RIL_SOCKET_ID socket_id)
6508{
6509 int waittoken;
6510 RequestInfo *pRI = creatRILInfoAndInit(request, RSPD, socket_id);
6511 if(pRI == NULL)
6512 return 0;
6513 waittoken = pRI->token;
6514 switch (request) {
6515 case RIL_REQUEST_GET_CURRENT_CALLS:
6516 {
6517 RLOGD("request Current list start!");
6518 Parcel p;
6519 pRI->pCI->dispatchFunction(p, pRI);
6520 waitResponse(waittoken);
6521 RLOGD("request Current list end!");
6522 }
6523 break;
6524
6525 case RIL_REQUEST_ANSWER:
6526 {
6527 RLOGD("request Answer a MT call start!");
6528 Parcel p;
6529 pRI->pCI->dispatchFunction(p, pRI);
6530 waitResponse(waittoken);
6531 RLOGD("request Answer a MT call end!");
6532 }
6533 break;
6534
6535 case RIL_REQUEST_GET_SIM_STATUS:
6536 {
6537 int ret=getIccCardStatus(1, NULL, socket_id, pRI);
6538 if(ret == 0)
6539 waitResponse(waittoken);
6540 }
6541 break;
6542
6543 case RIL_REQUEST_DATA_REGISTRATION_STATE:
6544 {
6545 int ret=getDataRegistrationState(1, NULL, socket_id,pRI);
6546 if(ret == 0)
6547 waitResponse(waittoken);
6548 }
6549 break;
6550
6551 case RIL_REQUEST_VOICE_REGISTRATION_STATE:
6552 {
6553 int ret=getVoiceRegistrationState(1, NULL, socket_id,pRI);
6554 if(ret == 0)
6555 waitResponse(waittoken);
6556 }
6557 break;
6558 case RIL_REQUEST_SMS_ACKNOWLEDGE:
6559 {
6560 char* tmp[3] = {"RIL_REQUEST_SMS_ACKNOWLEDGE", "1", "0"};
6561 acknowledgeIncomingGsmSmsWithPdu(3,tmp,socket_id,pRI);
6562 waitResponse(waittoken);
6563 RLOGD("acknowledge last Incoming Gsm Sms : RIL_REQUEST_SMS_ACKNOWLEDGE end!");
6564 }
6565 break;
6566 case RIL_REQUEST_OEM_HOOK_RAW:
6567 {
6568 if(arg != NULL)
6569 {
6570 RLOGD("request OEM HOOK RAW start!");
6571 pRI->token = pRI->token|BLOCK_MARK;
6572 int waittokenOEM = pRI->token;
6573 Parcel p;
6574
6575 size_t pos = p.dataPosition();
6576 int len = strlen(arg);
6577 p.writeInt32(len);
6578 p.write((const void*)arg,len);
6579
6580 p.setDataPosition(pos);
6581 RLOGD("emSendATCommand: %s %d\n",arg,strlen(arg));
6582 pRI->pCI->dispatchFunction(p, pRI);
6583 waitResponse(waittokenOEM);
6584 } else {
6585 if(pRI){
6586 free(pRI);
6587 }
6588 RLOGE("at command shouldn't null");
6589 }
6590 break;
6591 }
6592 case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM:
6593 {
6594 char* tmp[2] = {"RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM", "no"};
6595 handleCallSetupRequestFromSim(2, tmp, socket_id,pRI);
6596 waitResponse(waittoken);
6597 RLOGD("timeout 1 minutes, response no by RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM");
6598 break;
6599 }
6600 case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE:
6601 {
6602 char* tmp[2] ={"RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE", arg};
6603 RLOGD("tmp[0]=%s, tmp[1]=%s, arg=%s", tmp[0], tmp[1], arg);
6604 sendTerminalResponse(2, tmp, socket_id, pRI);
6605 waitResponse(waittoken);
6606 break;
6607 }
6608 case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE:
6609 {
6610 acknowledgeLastIncomingCdmaSms(1, NULL,socket_id,pRI);
6611 waitResponse(waittoken);
6612 break;
6613 }
6614 case RIL_REQUEST_RADIO_POWER:
6615 {
6616 RLOGD("response loop, RIL_REQUEST_RADIO_POWER: %s", (arg == NULL ? "nul": arg));
6617 if(arg != NULL) {
6618 char* tmp[2] = {"RIL_REQUEST_RADIO_POWER", arg};
6619 setRadioPower(2,tmp,socket_id,pRI);
6620 waitResponse(waittoken);
6621 } else {
6622 if(pRI){
6623 free(pRI);
6624 }
6625 RLOGE("response loop, RIL_REQUEST_RADIO_POWER fail");
6626 }
6627 break;
6628 }
6629 case RIL_REQUEST_ALLOW_DATA:
6630 {
6631 int default_id = get_default_sim_data();
6632 RLOGD("RspDispFunction: socket_id=%d switch_id=%d", socket_id, default_id);
6633 char* argv[2] = {"RIL_REQUEST_ALLOW_DATA","0"};
6634 if(socket_id == default_id) {
6635 utils::mtk_property_set(PROP_DEFAULT_DATA_SIM, std::to_string(socket_id + 1).c_str());
6636 argv[1] = "1";
6637 }
6638 while(!isRadioAvailable(socket_id)) {
6639 sleep(1);
6640 RLOGD("[SIM%d]RspDispFunction(RIL_REQUEST_ALLOW_DATA): wait radio available", socket_id);
6641 }
6642 setDataAllowed(2, argv, socket_id, pRI);
6643 waitResponse(waittoken);
6644 break;
6645 }
6646 case RIL_REQUEST_CDMA_FLASH:
6647 {
6648 sendCDMAFeatureCode(1, NULL, socket_id, pRI);
6649 waitResponse(waittoken);
6650 break;
6651 }
6652 default:
xja1c30b82022-01-25 16:13:48 +08006653 if(pRI) {
6654 free(pRI);
6655 pRI = NULL;
6656 }
lh7b0674a2022-01-10 00:34:35 -08006657 break;
6658 }
6659 return 0;
6660}
6661
6662void * responseLoop(void *param) {
6663 pthread_mutex_lock(&s_startupMutex);
6664 s_responseDispatch= 1;
6665 pthread_cond_broadcast(&s_startupCond);
6666 pthread_mutex_unlock(&s_startupMutex);
6667 responseDispatch();
6668 RLOGD("error in response_loop_base errno:%d", errno);
6669 // kill self to restart on error
6670 kill(0, SIGKILL);
6671
6672 return NULL;
6673}
6674
6675void ATCIRequest(int request,char* reqString, void* t,int argc,char**argv)
6676{
xja1c30b82022-01-25 16:13:48 +08006677 if(t == NULL) {
6678 RLOGE("ATCIRequest t is null");
6679 return;
6680 }
lh7b0674a2022-01-10 00:34:35 -08006681 RequestInfo *pRI = (RequestInfo *)t;
6682 int waittoken;
6683 if (request < RIL_REQUEST_VENDOR_BASE) {
6684 pRI->pCI = &(s_commands[request]);
6685 } else {
6686 pRI->pCI = find_mtk_command(request);
6687 }
xja1c30b82022-01-25 16:13:48 +08006688 if(pRI->pCI == NULL){
lh7b0674a2022-01-10 00:34:35 -08006689 RLOGE("pCI command not found!");
xja1c30b82022-01-25 16:13:48 +08006690 if(pRI) {
6691 free(pRI);
6692 }
6693 return;
6694 }
lh7b0674a2022-01-10 00:34:35 -08006695
6696 if(utils::is_suppport_dsss()){
6697 pRI->socket_id = (RIL_SOCKET_ID)Phone_utils::get_enable_sim_for_dsss();
6698 }
6699
6700 if(utils::is_support_dsds() && (request != RIL_REQUEST_RADIO_POWER)){
6701 pRI->socket_id = (RIL_SOCKET_ID)get_atci_sim();
6702 }
6703
6704 pRI->p_next = NULL;
6705
6706 COMMAND *command = find_command(reqString);
6707
6708 if(command == NULL) {
6709 RLOGE("ATCI request command find error!");
xja1c30b82022-01-25 16:13:48 +08006710 if(pRI) {
6711 free(pRI);
6712 }
6713 return;
lh7b0674a2022-01-10 00:34:35 -08006714 } else {
6715 RLOGE("ATCI request name is %s!",command->name);
6716 }
6717
6718 pRI->token = GenerateToken(ATCI, request);
6719 waittoken = pRI->token;
6720 if(request == RIL_REQUEST_RADIO_POWER) {
6721 speciaRequest_wait();
6722 }
6723 (*(command->func)) (argc, argv, pRI->socket_id, pRI);
6724 //need wait Ril_onRequestComplete return.
6725 waitResponse(waittoken);
6726 return;
6727}
6728
6729void startWakupLoop(void)
6730{
6731 pthread_t WakeupReasonThread;
6732
6733 RLOGD("startWakupLoop()");
6734 pthread_mutex_lock(&s_startupMutex);
6735
6736 pthread_attr_t attr;
6737 pthread_attr_init(&attr);
6738 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
6739
6740 int result = pthread_create(&WakeupReasonThread, &attr, wakeup_reason_loop, NULL);
6741 if (result != 0) {
6742 RLOGW("Failed to create wakeup reason thread: %s", strerror(result));
6743 goto done;
6744 }
6745
6746done:
6747 pthread_mutex_unlock(&s_startupMutex);
6748}
llaaca09b2022-03-14 16:14:28 +08006749/*Warren add for FAW 2021/09/23 start
6750** use ttyGS0 port
6751*/
6752int lynqSendToRil(int argc,char *argv[],int uToken)
6753{
6754 if(argc < 1)
6755 {
6756 RLOGE("lynqSendToRil error input.");
6757 return 1;
6758 }
6759 for(int i =0;i<argc;i++)
6760 {
6761 printf("argv[%d]=%s\n",i,argv[i]);
6762 }
6763 COMMAND *command = find_command(argv[0]);
6764 if(!command)
6765 {
6766 RLOGE("%s: No such command for DemoApp", argv[0]);
6767 return 1;
6768 }
6769
6770 int32_t request;
6771
6772 request = command->request;
6773
6774 RIL_SOCKET_ID id = RIL_SOCKET_1;
6775 if(utils::is_support_dsds()) {
6776 id = (RIL_SOCKET_ID)get_default_sim_all_except_data();
6777 } else if(utils::is_suppport_dsss()) {
6778 id = (RIL_SOCKET_ID)Phone_utils::get_enable_sim_for_dsss();
6779 }
6780
6781 if(request == -1)
6782 {
6783 (*(command->func)) (argc, argv, id, NULL);
6784 return 1;
6785 }
6786
6787 if (request < 1 || (request >= (int32_t)NUM_ELEMS(s_commands) && request < RIL_REQUEST_VENDOR_BASE)) {
6788 RLOGW("unsupported request code %d token %d", request);
6789 // FIXME this should perhaps return a response
6790 return 1;
6791 }
6792
6793 RLOGD("REQUEST: %s ParamterNum:%d", requestToString(request), argc);
6794
6795
6796 RequestInfo *pRI = creatRILInfoAndInit(request, UDP, (RIL_SOCKET_ID)(id));
6797 pRI->lynqEvent = 1;
6798 //Radio on/off only allow one thread operate.
6799 if(request == RIL_REQUEST_RADIO_POWER)
6800 {
6801 speciaRequest_wait();
6802 }
6803 memset(Time_buf,0,sizeof(Time_buf));
6804 GetTimeString(Time_buf);
6805 //FUNCTION_CALLED(Time_buf,requestToString(request));
6806 int waittoken = pRI->token;
6807 (*(command->func)) (argc, argv, pRI->socket_id, pRI);
6808 FUNCTION_CALLED(Time_buf,requestToString(request));
6809 waitResponse(waittoken);
6810 memset(Time_buf,0,sizeof(Time_buf));
6811 GetTimeString(Time_buf);
6812 FUNCTION_RETURN(Time_buf,requestToString(request));
6813 return 0;
6814}
6815
6816int sendRespToUsb(char *cmd)
6817{
6818 return 0;
6819}
6820int sendUrcToUsb(char *cmd)
6821{
6822 return 0;
6823}
6824/*Warren add for FAW 2021/09/23 end*/
lh7b0674a2022-01-10 00:34:35 -08006825
6826void startPMLoop(void)
6827{
6828 pthread_t atciSocketThread;
6829
6830 RLOGD("startPMLoop()");
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(&atciSocketThread, &attr, StartPMSocket, NULL);
6838 if (result != 0) {
6839 RLOGW("Failed to create PM thread: %s", strerror(result));
6840 goto done;
6841 }
6842
6843done:
6844 pthread_mutex_unlock(&s_startupMutex);
6845}
6846
6847void startGdbusLoop(void)
6848{
6849 pthread_t atciSocketThread;
6850
6851 RLOGD("startGdbusLoop()");
6852 pthread_mutex_lock(&s_startupMutex);
6853
6854 pthread_attr_t attr;
6855 pthread_attr_init(&attr);
6856 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
6857
6858 int result = pthread_create(&atciSocketThread, &attr, init_data_gdbus_cb, NULL);
6859 if (result != 0) {
6860 RLOGW("Failed to create gdbus thread: %s", strerror(result));
6861 goto done;
6862 }
6863
6864done:
6865 pthread_mutex_unlock(&s_startupMutex);
6866}
6867
6868void startATCILoop(void)
6869{
6870 pthread_t atciSocketThread;
6871
6872 RLOGD("startATCILoop()");
6873 pthread_mutex_lock(&s_startupMutex);
6874
6875 pthread_attr_t attr;
6876 pthread_attr_init(&attr);
6877 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
6878
6879 int result = pthread_create(&atciSocketThread, &attr, StartATCISocket, NULL);
6880 if (result != 0) {
6881 RLOGW("Failed to create ATCI thread: %s", strerror(result));
6882 goto done;
6883 }
6884
6885done:
6886 pthread_mutex_unlock(&s_startupMutex);
6887}
6888
6889void RIL_startEventLoop(void)
6890{
6891 RLOGD("RIL_startEventLoop()");
lhf6eea122022-01-20 19:32:14 -08006892 lynq_init_sms_manager();
lh7b0674a2022-01-10 00:34:35 -08006893 /* spin up eventLoop thread and wait for it to get started */
6894 s_started = 0;
6895 pthread_mutex_lock(&s_startupMutex);
6896
6897 pthread_attr_t attr;
6898 pthread_attr_init(&attr);
6899 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
6900
6901 int result = pthread_create(&s_tid_dispatch, &attr, eventLoop, NULL);
6902 if (result != 0) {
6903 RLOGW("Failed to create dispatch thread: %s", strerror(result));
6904 goto done;
6905 }
llaaca09b2022-03-14 16:14:28 +08006906
6907 while (s_started == 0) {
6908 pthread_cond_wait(&s_startupCond, &s_startupMutex);
6909 }
6910 /*mobiletek add*/
6911 s_started = 0;
6912 result = pthread_create(&s_tid_dispatch, &attr, eventLoop_at, NULL);
6913 if (result != 0) {
6914 RLOGW("Failed to create dispatch thread: %s", strerror(result));
6915 goto done;
6916 }
lh7b0674a2022-01-10 00:34:35 -08006917
6918 while (s_started == 0) {
6919 pthread_cond_wait(&s_startupCond, &s_startupMutex);
6920 }
llaaca09b2022-03-14 16:14:28 +08006921 /*mobiletek add*/
lh7b0674a2022-01-10 00:34:35 -08006922 result = pthread_create(&s_tid_dispatch, &attr, responseLoop, NULL);
6923 if (result != 0) {
6924 RLOGW("Failed to create response dispatch thread: %s", strerror(result));
6925 goto done;
6926 }
6927
6928 while (s_responseDispatch == 0) {
6929 pthread_cond_wait(&s_startupCond, &s_startupMutex);
6930 }
6931done:
6932 pthread_mutex_unlock(&s_startupMutex);
6933}
6934
6935void printInputArgs(int argc, char** argv)
6936{
6937 int i=0;
6938
6939 for(i=0; i<argc; i++)
6940 {
6941 RLOGD("%s", argv[i]);
6942 }
6943}
6944
6945void initRequestInfo(RequestInfo *pRI, int request, int mode, RIL_SOCKET_ID soc_id)
6946{
6947 pRI->token = GenerateToken(mode, request);
6948 if (request < RIL_REQUEST_VENDOR_BASE) {
6949 pRI->pCI = &(s_commands[request]);
6950 } else {
6951 pRI->pCI = find_mtk_command(request);
6952 }
6953 pRI->socket_id = soc_id;
6954
6955 pRI->p_next = NULL;
6956}
6957
6958void getVoiceAndDataRegistrationState(RIL_SOCKET_ID soc_id)
6959{
6960 ARspRequest(RIL_REQUEST_DATA_REGISTRATION_STATE,soc_id);
6961 ARspRequest(RIL_REQUEST_VOICE_REGISTRATION_STATE,soc_id);
6962}
6963
6964void requestAnswer(RIL_SOCKET_ID soc_id)
6965{
6966 ARspRequest(RIL_REQUEST_ANSWER,soc_id);
6967 return;
6968}
6969void requestSMSACKNOWLEDGE(RIL_SOCKET_ID soc_id)
6970{
6971 ARspRequest(RIL_REQUEST_SMS_ACKNOWLEDGE,soc_id);
6972 return;
6973}
6974
6975#if EM_MODE_SUPPORT
6976void registerForNetworkInfo(netwokInfoNotify cb)
6977{
6978 networkCb = cb;
6979 return ;
6980}
6981void unregisterNetwork()
6982{
6983 networkCb = NULL;
6984 //AT+EINFO= flag & 0xFFFFFFF7
6985}
6986void registerForATcmdResponse(atCmdResponse cb)
6987{
6988 atResponseCb = cb;
6989 return ;
6990}
6991
6992void unregisterATcmd()
6993{
6994 atResponseCb = NULL;
6995}
6996
6997#endif
6998int emResultNotify(const char *str)
6999{
7000 RLOGD("emResultNotify %s",str);
7001 int len_s = sendto(server_socket_fd,str,strlen(str),0,(struct sockaddr *)&client_addr,sizeof(client_addr));
7002
7003 sendto(server_socket_fd,"stopemdone",strlen("stopemdone"),0,(struct sockaddr *)&client_addr,sizeof(client_addr));
7004 return len_s;
7005}
7006
7007void processUnsolicited (Parcel &p, int type)
7008{
xja1c30b82022-01-25 16:13:48 +08007009 int32_t response = -1;
lh7b0674a2022-01-10 00:34:35 -08007010 p.readInt32(&response);
7011 switch(response){
7012 case RIL_UNSOL_MAL_AT_INFO:
7013 {
7014#if EM_MODE_SUPPORT
7015 char *stringresponse = strdupReadString(p);
7016 if(strstr(stringresponse,"+ENWINFO") != NULL){
7017 RLOGD("processUnsolicited ENWINFO \n");
7018 char *start = strstr(stringresponse,":");
7019 char *end = strstr(stringresponse,",");
7020 if(start == NULL ||end == NULL ){
7021 break;
7022 }
7023 if(networkCb){
7024 //parse type & data, notify to registrants
7025 char ctype[5] = {0};
7026 int type = 0;
7027 memcpy(ctype,start+1, end - start -1);
7028 type = atoi(ctype);
7029 char *data = end+1;
7030 RLOGD("ctype %s type %d data %s\n",ctype,type,data);
7031 //parse response
7032 networkCb(type,data);
7033 }
7034 }
7035 if(stringresponse){
7036 free(stringresponse);
7037 }
7038#endif
7039 break;
7040 }
7041 default:
7042 break;
7043 }
7044}
7045void processSolicited(Parcel &p, int type) {
7046 int32_t serial, error;
xja1c30b82022-01-25 16:13:48 +08007047 serial = 0;
lh7b0674a2022-01-10 00:34:35 -08007048 p.readInt32(&serial); //telematic it is the same as ril request num
7049 p.readInt32(&error);
7050 RLOGD("processSolicited serial %d\n", serial);
7051 switch (serial) {
7052 case RIL_REQUEST_OEM_HOOK_RAW: {
7053 if (error != RIL_E_SUCCESS) {
7054 RLOGW("RIL_E_fail");
7055 if (atResponseCb) {
7056 atResponseCb(NULL, 0);
7057 }
7058 if(m_RfDesense){
7059 m_RfDesense->handle_request("", 0, 0, (RIL_Errno)error);
7060 }
7061 return;
7062 }
7063 int len;
7064 status_t status = 0;
7065 status = p.readInt32(&len);
7066 if (status != 0) {
7067 RLOGW("read int32 fail");
7068 return;
7069 }
7070 char *stringresponse = (char*) calloc(len, sizeof(char));
7071 status = p.read((void*) stringresponse, len);
7072 if (status != 0) {
7073 if (stringresponse) {
7074 free(stringresponse);
7075 }
7076 RLOGW("read int32 fail");
7077 return;
7078 }
7079 parseAtCmd(stringresponse);
7080 RLOGD("processSolicited AT string %s %d\n", stringresponse, len);
7081#if EM_MODE_SUPPORT
7082 if (atResponseCb) {
7083 if (stringresponse) {
7084
7085 atResponseCb(stringresponse, len);
7086 } else {
7087 atResponseCb(stringresponse, 0);
7088 }
7089 }
7090 if(m_RfDesense){
7091 if(stringresponse && (!isFinalResponseErrorEx(stringresponse))) {
7092 m_RfDesense->handle_request(stringresponse,len,0, (RIL_Errno)RIL_E_SUCCESS);
7093 } else {
7094 RLOGD("isFinalResponseErrorEx error or response is null");
7095 m_RfDesense->handle_request(stringresponse, 0, 0, (RIL_Errno)RIL_E_GENERIC_FAILURE);
7096 }
7097 }
7098#endif
7099 if (stringresponse) {
7100 free(stringresponse);
7101 }
7102 break;
7103 }
7104 case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: {
7105#if EM_MODE_SUPPORT
7106 if (atResponseCb) {
7107 if (error != RIL_E_SUCCESS) {
7108 atResponseCb(NULL, 0);
7109 } else {
7110 atResponseCb("OK", 2);
7111 }
7112 }
7113#endif
7114 break;
7115 }
7116 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: {
7117#if EM_MODE_SUPPORT
7118 int nums = 0;
7119 int prefertype = 0;
7120 p.readInt32(&nums);
7121 if (nums != 1) {
7122 RLOGD("getpreferrednetworktype nums > 1");
7123 }
7124 p.readInt32(&prefertype);
7125 char prefertype_str[3] = { 0 };
7126 sprintf(prefertype_str, "%d", prefertype);
7127 if (atResponseCb) {
7128 if (error != RIL_E_SUCCESS) {
7129 atResponseCb(NULL, 0);
7130 } else {
7131 atResponseCb(prefertype_str, strlen(prefertype_str));
7132 }
7133 }
7134#endif
7135 break;
7136 }
7137 case RIL_REQUEST_GET_IMSI: {
7138 if (error != RIL_E_SUCCESS) {
7139 RLOGD("RIL_REQUEST_GET_IMSI error %d\n", error);
7140 }
7141 break;
7142 }
7143 }
7144}
7145
7146#ifdef ECALL_SUPPORT
7147static int responseEcallStatus(Parcel &p, void *response, size_t responselen) {
7148 if (response == NULL || responselen != sizeof(RIL_Ecall_Unsol_Indications)) {
7149 if (response == NULL) {
7150 RLOGE("invalid response: NULL");
7151 }
7152 else {
7153 RLOGE("responseEcallStatus: invalid response length %d expecting len: %d",
7154 sizeof(RIL_Ecall_Unsol_Indications), responselen);
7155 }
7156 return RIL_ERRNO_INVALID_RESPONSE;
7157 }
7158
7159 RIL_Ecall_Unsol_Indications *p_cur = (RIL_Ecall_Unsol_Indications *)response;
7160 p.writeInt32(p_cur->ind);
7161 p.writeInt32(p_cur->call_id);
7162
7163 startResponse;
7164 appendPrintBuf("ECall Status: %d, call_id: %d",
7165 p_cur->ind, p_cur->call_id);
7166 closeResponse;
7167
7168 return 0;
7169}
7170
7171/**
7172 * Callee expects const RIL_ECallReqMsg *
7173 * Payload is:
7174 * RIL_ECall_Category ecall_cat
7175 * RIL_ECall_Variant ecall_variant
7176 * String address
7177 * String msd_data
7178 */
7179static void dispatchFastEcall (Parcel &p, RequestInfo *pRI) {
7180 RIL_ECallReqMsg eCallReqMsg;
7181
xja1c30b82022-01-25 16:13:48 +08007182 int32_t t = -1;
lh7b0674a2022-01-10 00:34:35 -08007183 int size;
7184 status_t status;
7185 int digitCount;
7186 int digitLimit;
7187 uint8_t uct;
7188
7189 memset(&eCallReqMsg, 0, sizeof(eCallReqMsg));
7190
7191 status = p.readInt32(&t);
7192 eCallReqMsg.ecall_cat= (RIL_ECall_Category)t;
7193
7194 status = p.readInt32(&t);
7195 eCallReqMsg.ecall_variant = (RIL_ECall_Variant)t;
7196
7197 eCallReqMsg.address = strdupReadString(p);
7198
7199 status = p.readInt32(&t);
7200 eCallReqMsg.length = (uint8_t) t;
7201
7202 digitLimit= MIN((eCallReqMsg.length), MSD_MAX_LENGTH);
7203 eCallReqMsg.msd_data = (unsigned char *)alloca(digitLimit);
7204
7205 for(digitCount = 0 ; digitCount < digitLimit; digitCount ++) {
7206 status = p.read(&uct, sizeof(uint8_t));
7207 eCallReqMsg.msd_data[digitCount] = (uint8_t) uct;
7208 }
7209
7210 startRequest;
7211 appendPrintBuf("%secall_cat=%d,ecall_variant=%d, address=%s", printBuf,
7212 eCallReqMsg.ecall_cat, eCallReqMsg.ecall_variant, (char*)eCallReqMsg.address);
7213 closeRequest;
7214 printRequest(pRI->token, pRI->pCI->requestNumber);
7215
7216 if (status != NO_ERROR) {
7217 goto invalid;
7218 }
7219
7220 size = sizeof(eCallReqMsg);
7221 CALL_ONREQUEST(pRI->pCI->requestNumber, &eCallReqMsg, size, pRI, pRI->socket_id);
7222
7223#ifdef MEMSET_FREED
7224 memsetString(eCallReqMsg.address);
lhb07f4e12022-02-17 22:08:54 -08007225 memset(eCallReqMsg.msd_data, 0, digitLimit);
lh7b0674a2022-01-10 00:34:35 -08007226#endif
7227
7228 free(eCallReqMsg.address);
7229
7230#ifdef MEMSET_FREED
7231 memset(&eCallReqMsg, 0, sizeof(eCallReqMsg));
7232#endif
7233
7234 return;
7235invalid:
7236 invalidCommandBlock(pRI);
7237 return;
7238}
7239
7240/**
7241 * Callee expects const RIL_ECallSetMSD *
7242 * Payload is:
7243 * int call_id
7244 * String msd_data
7245 */
7246static void dispatchSetMsd (Parcel &p, RequestInfo *pRI) {
7247 RIL_ECallSetMSD eCallSetMsd;
7248
xja1c30b82022-01-25 16:13:48 +08007249 int32_t t = -1;
lh7b0674a2022-01-10 00:34:35 -08007250 int size;
7251 status_t status;
7252 int digitCount;
7253 int digitLimit;
7254 uint8_t uct;
7255
7256 memset(&eCallSetMsd, 0, sizeof(eCallSetMsd));
7257
7258 status = p.readInt32(&t);
7259 eCallSetMsd.call_id = (int)t;
7260
7261 status = p.readInt32(&t);
7262 eCallSetMsd.length = (uint8_t) t;
7263
7264 digitLimit= MIN((eCallSetMsd.length), MSD_MAX_LENGTH);
7265 eCallSetMsd.msd_data = (unsigned char *)alloca(digitLimit);
7266
7267 for(digitCount = 0 ; digitCount < digitLimit; digitCount ++) {
7268 status = p.read(&uct, sizeof(uint8_t));
7269 eCallSetMsd.msd_data[digitCount] = (uint8_t) uct;
7270 }
7271
7272 startRequest;
7273 appendPrintBuf("%scall_id=%d,msd_data=%s", printBuf, eCallSetMsd.call_id, (char*)eCallSetMsd.msd_data);
7274 closeRequest;
7275 printRequest(pRI->token, pRI->pCI->requestNumber);
7276
7277 if (status != NO_ERROR) {
7278 goto invalid;
7279 }
7280
7281 size = sizeof(eCallSetMsd);
7282 CALL_ONREQUEST(pRI->pCI->requestNumber, &eCallSetMsd, size, pRI, pRI->socket_id);
7283
7284#ifdef MEMSET_FREED
7285 memset(eCallSetMsd.msd_data, 0, eCallSetMsd.length);
7286#endif
7287
7288#ifdef MEMSET_FREED
7289 memset(&eCallSetMsd, 0, sizeof(eCallSetMsd));
7290#endif
7291
7292 return;
7293invalid:
7294 invalidCommandBlock(pRI);
7295 return;
7296}
7297
7298/**
7299 * Callee expects const RIL_ECallSetNum *
7300 * Payload is:
7301 * int arg_num;
7302 * int type
7303 * char* address
7304 */
7305static void dispatchEcallRecord (Parcel &p, RequestInfo *pRI) {
7306 RIL_ECallSetNum args;
xja1c30b82022-01-25 16:13:48 +08007307 int32_t t = -1;
lh7b0674a2022-01-10 00:34:35 -08007308 status_t status;
7309
7310 RLOGD("dispatchSmsWrite");
7311 memset (&args, 0, sizeof(args));
7312
7313 status = p.readInt32(&t);
7314 args.arg_num = (int)t;
7315
7316 status = p.readInt32(&t);
7317 args.type = (int)t;
7318
7319 args.address = strdupReadString(p);
7320
7321 if (status != NO_ERROR || args.address == NULL) {
7322 goto invalid;
7323 }
7324
7325 startRequest;
7326 appendPrintBuf("%s%d,%s,%d", printBuf, args.type, args.address,args.arg_num);
7327 closeRequest;
7328 printRequest(pRI->token, pRI->pCI->requestNumber);
7329
7330 CALL_ONREQUEST(pRI->pCI->requestNumber, &args, sizeof(args), pRI, pRI->socket_id);
7331
7332#ifdef MEMSET_FREED
7333 memsetString (args.address);
7334#endif
7335
7336 free (args.address);
7337#ifdef MEMSET_FREED
7338 memset(&args, 0, sizeof(args));
7339#endif
7340 return;
7341invalid:
7342 invalidCommandBlock(pRI);
7343 return;
7344}
7345#endif /*ECALL_SUPPORT*/
7346
7347#ifdef KEEP_ALIVE
7348static void dispatchStartKeepalivePro(Parcel &p, RequestInfo *pRI){
7349 RIL_RequestKeepalive_Pro kp;
xja1c30b82022-01-25 16:13:48 +08007350 int32_t t = -1;
lh7b0674a2022-01-10 00:34:35 -08007351 status_t status;
7352 std::vector<uint8_t> sadr;
7353 std::vector<uint8_t> dadr;
7354
7355 memset (&kp, 0, sizeof(RIL_RequestKeepalive_Pro));
7356
7357 status = p.readInt32(&t);
7358 kp.type = (RIL_PacketType)t;
7359 if (status != NO_ERROR) {
7360 goto invalid;
7361 }
7362
7363
7364 status = p.readByteVector(&sadr);
7365 if (status != NO_ERROR) {
7366 goto invalid;
7367 } else {
7368 for(int i = 0; i < sadr.size(); i++) {
7369 kp.sourceAddress[i] = sadr[i];
7370 }
7371 }
7372
7373 status = p.readInt32(&t);
7374 kp.sourcePort= (int)t;
7375 if (status != NO_ERROR) {
7376 goto invalid;
7377 }
7378
7379 status = p.readByteVector(&dadr);
7380 if (status != NO_ERROR) {
7381 goto invalid;
7382 } else {
7383 for(int i = 0; i < dadr.size(); i++) {
7384 kp.destinationAddress[i] = dadr[i];
7385 }
7386 }
7387
7388 status = p.readInt32(&t);
7389 kp.destinationPort= (int)t;
7390 if (status != NO_ERROR) {
7391 goto invalid;
7392 }
7393
7394 status = p.readInt32(&t);
7395 kp.netif_id = (int)t;
7396 if (status != NO_ERROR) {
7397 goto invalid;
7398 }
7399
7400 status = p.readInt32(&t);
7401 kp.keepIdleTime = (int)t;
7402 if (status != NO_ERROR) {
7403 goto invalid;
7404 }
7405
7406 status = p.readInt32(&t);
7407 kp.keepIntervalTime = (int)t;
7408 if (status != NO_ERROR) {
7409 goto invalid;
7410 }
7411
7412 status = p.readInt32(&t);
7413 kp.retryCount = (int)t;
7414 if (status != NO_ERROR) {
7415 goto invalid;
7416 }
7417 startRequest;
7418 appendPrintBuf("%s [type:%d, sourceAddress:",printBuf, kp.type);
7419
7420 for(auto v: sadr) {
7421 appendPrintBuf("%s %d",printBuf,v);
7422 }
7423 appendPrintBuf("%s, sourcePort:%d, destinationAddress:",printBuf, kp.sourcePort);
7424
7425 for(auto v: dadr) {
7426 appendPrintBuf("%s %d",printBuf,v);
7427 }
7428 appendPrintBuf("%s, destinationPort:%d, netif_id:%d, keepIdleTime:%d,, keepIntervalTime:%d, retryCount:%d",
7429 printBuf, kp.destinationPort, kp.netif_id, kp.keepIdleTime, kp.keepIntervalTime, kp.retryCount);
7430
7431 closeRequest;
7432 printRequest(pRI->token, pRI->pCI->requestNumber);
7433
7434 CALL_ONREQUEST(pRI->pCI->requestNumber,&kp,sizeof(RIL_RequestKeepalive_Pro),pRI, pRI->socket_id);
7435 return;
7436invalid:
7437 invalidCommandBlock(pRI);
7438 return;
7439}
7440#endif /* KEEP_ALIVE*/
7441} /* namespace android */
7442
7443#if 0
7444void rilEventAddWakeup_helper(struct ril_event *ev) {
7445 android::rilEventAddWakeup(ev);
7446}
7447
7448void listenCallback_helper(int fd, short flags, void *param) {
7449 android::listenCallback(fd, flags, param);
7450}
7451
7452int blockingWrite_helper(int fd, void *buffer, size_t len) {
7453 return android::blockingWrite(fd, buffer, len);
7454}
7455#endif