blob: 915b39916c9b9123a8a11e96fed2d74d75ecfc93 [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: {
rjw62a60152022-06-09 17:43:01 +08003139 /*Typethree add for T800 earfcn 2022/06/09 start*/
rjwc5401bb2022-06-08 15:37:23 +08003140 appendPrintBuf("%s LTE id: mcc=%d,mnc=%d,ci=%d,pci=%d,tac=%d,earfcn=%d", printBuf,
lh7b0674a2022-01-10 00:34:35 -08003141 p_cur->CellInfo.lte.cellIdentityLte.mcc,
3142 p_cur->CellInfo.lte.cellIdentityLte.mnc,
3143 p_cur->CellInfo.lte.cellIdentityLte.ci,
3144 p_cur->CellInfo.lte.cellIdentityLte.pci,
rjwc5401bb2022-06-08 15:37:23 +08003145 p_cur->CellInfo.lte.cellIdentityLte.tac,
3146 p_cur->CellInfo.lte.cellIdentityLte.earfcn);
lh7b0674a2022-01-10 00:34:35 -08003147
3148 p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.mcc);
3149 p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.mnc);
3150 p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.ci);
3151 p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.pci);
3152 p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.tac);
rjwc5401bb2022-06-08 15:37:23 +08003153 p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.earfcn);
rjw62a60152022-06-09 17:43:01 +08003154 /*Typethree add for T800 earfcn 2022/06/09 end*/
lh7b0674a2022-01-10 00:34:35 -08003155 appendPrintBuf("%s lteSS: ss=%d,rsrp=%d,rsrq=%d,rssnr=%d,cqi=%d,ta=%d", printBuf,
3156 p_cur->CellInfo.lte.signalStrengthLte.signalStrength,
3157 p_cur->CellInfo.lte.signalStrengthLte.rsrp,
3158 p_cur->CellInfo.lte.signalStrengthLte.rsrq,
3159 p_cur->CellInfo.lte.signalStrengthLte.rssnr,
3160 p_cur->CellInfo.lte.signalStrengthLte.cqi,
3161 p_cur->CellInfo.lte.signalStrengthLte.timingAdvance);
3162 p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.signalStrength);
3163 p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.rsrp);
3164 p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.rsrq);
3165 p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.rssnr);
3166 p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.cqi);
3167 p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.timingAdvance);
3168 break;
3169 }
3170 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
3171 appendPrintBuf("%s TDSCDMA id: mcc=%d,mnc=%d,lac=%d,cid=%d,cpid=%d,", printBuf,
3172 p_cur->CellInfo.tdscdma.cellIdentityTdscdma.mcc,
3173 p_cur->CellInfo.tdscdma.cellIdentityTdscdma.mnc,
3174 p_cur->CellInfo.tdscdma.cellIdentityTdscdma.lac,
3175 p_cur->CellInfo.tdscdma.cellIdentityTdscdma.cid,
3176 p_cur->CellInfo.tdscdma.cellIdentityTdscdma.cpid);
3177 appendPrintBuf("%s tdscdmaSS: rscp=%d],", printBuf,
3178 p_cur->CellInfo.tdscdma.signalStrengthTdscdma.rscp);
3179
3180 p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
3181 p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
3182 p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.lac);
3183 p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.cid);
3184 p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.cpid);
3185 p.writeInt32(p_cur->CellInfo.tdscdma.signalStrengthTdscdma.rscp);
3186 break;
3187 }
3188#ifdef TELEMATIC_5G_SUPPORT
3189 case RIL_CELL_INFO_TYPE_NR: {
rjw62a60152022-06-09 17:43:01 +08003190 /*Typethree add for T800 5G cid 2022/06/09 start*/
3191 appendPrintBuf("%s NR id: mcc=%d,mnc=%d,nci=%llu,pci=%d,tac=%d", printBuf,
lh7b0674a2022-01-10 00:34:35 -08003192 p_cur->CellInfo.nr.cellidentity.mcc,
3193 p_cur->CellInfo.nr.cellidentity.mnc,
3194 p_cur->CellInfo.nr.cellidentity.nci,
3195 p_cur->CellInfo.nr.cellidentity.pci,
3196 p_cur->CellInfo.nr.cellidentity.tac,
3197 p_cur->CellInfo.nr.cellidentity.nrarfcn);
3198
3199 p.writeInt32(p_cur->CellInfo.nr.cellidentity.mcc);
3200 p.writeInt32(p_cur->CellInfo.nr.cellidentity.mnc);
rjw62a60152022-06-09 17:43:01 +08003201 p.writeUint64(p_cur->CellInfo.nr.cellidentity.nci);
lh7b0674a2022-01-10 00:34:35 -08003202 p.writeInt32(p_cur->CellInfo.nr.cellidentity.pci);
3203 p.writeInt32(p_cur->CellInfo.nr.cellidentity.tac);
3204 p.writeInt32(p_cur->CellInfo.nr.cellidentity.nrarfcn);
rjw62a60152022-06-09 17:43:01 +08003205 /*Typethree add for T800 5G cid 2022/06/09 end*/
lh7b0674a2022-01-10 00:34:35 -08003206 appendPrintBuf("%s NRSS: ssRsrp=%d,ssRsrq=%d,ssSinr=%d,csiRsrp=%d,csiRsrq=%d,csiSinr=%d", printBuf,
3207 p_cur->CellInfo.nr.signalStrength.ssRsrp,
3208 p_cur->CellInfo.nr.signalStrength.ssRsrq,
3209 p_cur->CellInfo.nr.signalStrength.ssSinr,
3210 p_cur->CellInfo.nr.signalStrength.csiRsrp,
3211 p_cur->CellInfo.nr.signalStrength.csiRsrq,
3212 p_cur->CellInfo.nr.signalStrength.csiSinr);
3213 p.writeInt32(p_cur->CellInfo.nr.signalStrength.ssRsrp);
3214 p.writeInt32(p_cur->CellInfo.nr.signalStrength.ssRsrq);
3215 p.writeInt32(p_cur->CellInfo.nr.signalStrength.ssSinr);
3216 p.writeInt32(p_cur->CellInfo.nr.signalStrength.csiRsrp);
3217 p.writeInt32(p_cur->CellInfo.nr.signalStrength.csiRsrq);
3218 p.writeInt32(p_cur->CellInfo.nr.signalStrength.csiSinr);
3219 break;
3220 }
3221#endif
3222 }
3223 p_cur += 1;
3224 }
3225 removeLastChar;
3226 closeResponse;
3227
3228 return 0;
3229}
3230
3231static int responseHardwareConfig(Parcel &p, void *response, size_t responselen)
3232{
3233 if (response == NULL && responselen != 0) {
3234 RLOGE("invalid response: NULL");
3235 return RIL_ERRNO_INVALID_RESPONSE;
3236 }
3237
3238 if (responselen % sizeof(RIL_HardwareConfig) != 0) {
3239 RLOGE("responseHardwareConfig: invalid response length %d expected multiple of %d",
3240 (int)responselen, (int)sizeof(RIL_HardwareConfig));
3241 return RIL_ERRNO_INVALID_RESPONSE;
3242 }
3243
3244 int num = responselen / sizeof(RIL_HardwareConfig);
3245 int i;
3246 RIL_HardwareConfig *p_cur = (RIL_HardwareConfig *) response;
3247
3248 p.writeInt32(num);
3249
3250 startResponse;
3251 for (i = 0; i < num; i++) {
3252 switch (p_cur[i].type) {
3253 case RIL_HARDWARE_CONFIG_MODEM: {
3254 writeStringToParcel(p, p_cur[i].uuid);
3255 p.writeInt32((int)p_cur[i].state);
3256 p.writeInt32(p_cur[i].cfg.modem.rat);
3257 p.writeInt32(p_cur[i].cfg.modem.maxVoice);
3258 p.writeInt32(p_cur[i].cfg.modem.maxData);
3259 p.writeInt32(p_cur[i].cfg.modem.maxStandby);
3260
3261 appendPrintBuf("%s modem: uuid=%s,state=%d,rat=%08x,maxV=%d,maxD=%d,maxS=%d", printBuf,
3262 p_cur[i].uuid, (int)p_cur[i].state, p_cur[i].cfg.modem.rat,
3263 p_cur[i].cfg.modem.maxVoice, p_cur[i].cfg.modem.maxData, p_cur[i].cfg.modem.maxStandby);
3264 break;
3265 }
3266 case RIL_HARDWARE_CONFIG_SIM: {
3267 writeStringToParcel(p, p_cur[i].uuid);
3268 p.writeInt32((int)p_cur[i].state);
3269 writeStringToParcel(p, p_cur[i].cfg.sim.modemUuid);
3270
3271 appendPrintBuf("%s sim: uuid=%s,state=%d,modem-uuid=%s", printBuf,
3272 p_cur[i].uuid, (int)p_cur[i].state, p_cur[i].cfg.sim.modemUuid);
3273 break;
3274 }
3275 }
3276 }
3277 removeLastChar;
3278 closeResponse;
3279 return 0;
3280}
3281
3282static int responseRadioCapability(Parcel &p, void *response, size_t responselen) {
3283 if (response == NULL) {
3284 RLOGE("invalid response: NULL");
3285 return RIL_ERRNO_INVALID_RESPONSE;
3286 }
3287
3288 if (responselen != sizeof (RIL_RadioCapability) ) {
3289 RLOGE("invalid response length was %d expected %d",
3290 (int)responselen, (int)sizeof (RIL_SIM_IO_Response));
3291 return RIL_ERRNO_INVALID_RESPONSE;
3292 }
3293
3294 RIL_RadioCapability *p_cur = (RIL_RadioCapability *) response;
3295 p.writeInt32(p_cur->version);
3296 p.writeInt32(p_cur->session);
3297 p.writeInt32(p_cur->phase);
3298 p.writeInt32(p_cur->rat);
3299 writeStringToParcel(p, p_cur->logicalModemUuid);
3300 p.writeInt32(p_cur->status);
3301
3302 startResponse;
3303 appendPrintBuf("%s[version=%d,session=%d,phase=%d,\
3304 rat=%d,logicalModemUuid=%s,status=%d]",
3305 printBuf,
3306 p_cur->version,
3307 p_cur->session,
3308 p_cur->phase,
3309 p_cur->rat,
3310 p_cur->logicalModemUuid,
3311 p_cur->status);
3312 closeResponse;
3313 return 0;
3314}
3315
3316static int responseSSData(Parcel &p, void *response, size_t responselen) {
3317 RLOGD("In responseSSData");
3318 int num;
3319
3320 if (response == NULL && responselen != 0) {
3321 RLOGE("invalid response length was %d expected %d",
3322 (int)responselen, (int)sizeof (RIL_SIM_IO_Response));
3323 return RIL_ERRNO_INVALID_RESPONSE;
3324 }
3325
3326 if (responselen != sizeof(RIL_StkCcUnsolSsResponse)) {
3327 RLOGE("invalid response length %d, expected %d",
3328 (int)responselen, (int)sizeof(RIL_StkCcUnsolSsResponse));
3329 return RIL_ERRNO_INVALID_RESPONSE;
3330 }
3331
3332 startResponse;
3333 RIL_StkCcUnsolSsResponse *p_cur = (RIL_StkCcUnsolSsResponse *) response;
3334 p.writeInt32(p_cur->serviceType);
3335 p.writeInt32(p_cur->requestType);
3336 p.writeInt32(p_cur->teleserviceType);
3337 p.writeInt32(p_cur->serviceClass);
3338 p.writeInt32(p_cur->result);
3339
3340 if (isServiceTypeCfQuery(p_cur->serviceType, p_cur->requestType)) {
3341 RLOGD("responseSSData CF type, num of Cf elements %d", p_cur->cfData.numValidIndexes);
3342 if (p_cur->cfData.numValidIndexes > NUM_SERVICE_CLASSES) {
3343 RLOGE("numValidIndexes is greater than max value %d, "
3344 "truncating it to max value", NUM_SERVICE_CLASSES);
3345 p_cur->cfData.numValidIndexes = NUM_SERVICE_CLASSES;
3346 }
3347 /* number of call info's */
3348 p.writeInt32(p_cur->cfData.numValidIndexes);
3349
3350 for (int i = 0; i < p_cur->cfData.numValidIndexes; i++) {
3351 RIL_CallForwardInfo cf = p_cur->cfData.cfInfo[i];
3352
3353 p.writeInt32(cf.status);
3354 p.writeInt32(cf.reason);
3355 p.writeInt32(cf.serviceClass);
3356 p.writeInt32(cf.toa);
3357 writeStringToParcel(p, cf.number);
3358 p.writeInt32(cf.timeSeconds);
3359 appendPrintBuf("%s[%s,reason=%d,cls=%d,toa=%d,%s,tout=%d],", printBuf,
3360 (cf.status==1)?"enable":"disable", cf.reason, cf.serviceClass, cf.toa,
3361 (char*)cf.number, cf.timeSeconds);
3362 RLOGD("Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status,
3363 cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds);
3364 }
3365 } else {
3366 p.writeInt32 (SS_INFO_MAX);
3367
3368 /* each int*/
3369 for (int i = 0; i < SS_INFO_MAX; i++) {
3370 appendPrintBuf("%s%d,", printBuf, p_cur->ssInfo[i]);
3371 RLOGD("Data: %d",p_cur->ssInfo[i]);
3372 p.writeInt32(p_cur->ssInfo[i]);
3373 }
3374 }
3375 removeLastChar;
3376 closeResponse;
3377
3378 return 0;
3379}
3380
3381static bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) {
3382 if ((reqType == SS_INTERROGATION) &&
3383 (serType == SS_CFU ||
3384 serType == SS_CF_BUSY ||
3385 serType == SS_CF_NO_REPLY ||
3386 serType == SS_CF_NOT_REACHABLE ||
3387 serType == SS_CF_ALL ||
3388 serType == SS_CF_ALL_CONDITIONAL)) {
3389 return true;
3390 }
3391 return false;
3392}
3393
3394static void sendSimStatusAppInfo(Parcel &p, int num_apps, RIL_AppStatus appStatus[]) {
3395 p.writeInt32(num_apps);
3396 startResponse;
3397 for (int i = 0; i < num_apps; i++) {
3398 p.writeInt32(appStatus[i].app_type);
3399 p.writeInt32(appStatus[i].app_state);
3400 p.writeInt32(appStatus[i].perso_substate);
3401 writeStringToParcel(p, (const char*)(appStatus[i].aid_ptr));
3402 writeStringToParcel(p, (const char*)
3403 (appStatus[i].app_label_ptr));
3404 p.writeInt32(appStatus[i].pin1_replaced);
3405 p.writeInt32(appStatus[i].pin1);
3406 p.writeInt32(appStatus[i].pin2);
3407 appendPrintBuf("%s[app_type=%d,app_state=%d,perso_substate=%d,\
3408 aid_ptr=%s,app_label_ptr=%s,pin1_replaced=%d,pin1=%d,pin2=%d],",
3409 printBuf,
3410 appStatus[i].app_type,
3411 appStatus[i].app_state,
3412 appStatus[i].perso_substate,
3413 appStatus[i].aid_ptr,
3414 appStatus[i].app_label_ptr,
3415 appStatus[i].pin1_replaced,
3416 appStatus[i].pin1,
3417 appStatus[i].pin2);
3418 }
3419 closeResponse;
3420}
3421
3422static int responseSimStatus(Parcel &p, void *response, size_t responselen) {
3423 int i;
3424
3425 if (response == NULL && responselen != 0) {
3426 RLOGE("invalid response: NULL");
3427 return RIL_ERRNO_INVALID_RESPONSE;
3428 }
3429
3430 RLOGD("responselen: %d, v6: %d, v5: %d", responselen, sizeof (RIL_CardStatus_v6),sizeof (RIL_CardStatus_v5));
3431 if (responselen == sizeof (RIL_CardStatus_v6)) {
3432 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
3433 p.writeInt32(p_cur->card_state);
3434 p.writeInt32(p_cur->universal_pin_state);
3435 p.writeInt32(p_cur->gsm_umts_subscription_app_index);
3436 p.writeInt32(p_cur->cdma_subscription_app_index);
3437 p.writeInt32(p_cur->ims_subscription_app_index);
3438
3439 sendSimStatusAppInfo(p, p_cur->num_applications, p_cur->applications);
3440 } else if (responselen == sizeof (RIL_CardStatus_v5)) {
3441 RIL_CardStatus_v5 *p_cur = ((RIL_CardStatus_v5 *) response);
3442
3443 p.writeInt32(p_cur->card_state);
3444 p.writeInt32(p_cur->universal_pin_state);
3445 p.writeInt32(p_cur->gsm_umts_subscription_app_index);
3446 p.writeInt32(p_cur->cdma_subscription_app_index);
3447 p.writeInt32(-1);
3448
3449 sendSimStatusAppInfo(p, p_cur->num_applications, p_cur->applications);
3450 } else {
3451 RLOGE("responseSimStatus: A RilCardStatus_v6 or _v5 expected\n");
3452 return RIL_ERRNO_INVALID_RESPONSE;
3453 }
3454
3455 return 0;
3456}
3457
3458static int responseGsmBrSmsCnf(Parcel &p, void *response, size_t responselen) {
3459 int num = responselen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
3460 p.writeInt32(num);
3461
3462 startResponse;
3463 RIL_GSM_BroadcastSmsConfigInfo **p_cur =
3464 (RIL_GSM_BroadcastSmsConfigInfo **) response;
3465 for (int i = 0; i < num; i++) {
3466 p.writeInt32(p_cur[i]->fromServiceId);
3467 p.writeInt32(p_cur[i]->toServiceId);
3468 p.writeInt32(p_cur[i]->fromCodeScheme);
3469 p.writeInt32(p_cur[i]->toCodeScheme);
3470 p.writeInt32(p_cur[i]->selected);
3471
3472 appendPrintBuf("%s [%d: fromServiceId=%d, toServiceId=%d, \
3473 fromCodeScheme=%d, toCodeScheme=%d, selected =%d]",
3474 printBuf, i, p_cur[i]->fromServiceId, p_cur[i]->toServiceId,
3475 p_cur[i]->fromCodeScheme, p_cur[i]->toCodeScheme,
3476 p_cur[i]->selected);
3477 }
3478 closeResponse;
3479
3480 return 0;
3481}
3482
3483static int responseCdmaBrSmsCnf(Parcel &p, void *response, size_t responselen) {
3484 RIL_CDMA_BroadcastSmsConfigInfo **p_cur =
3485 (RIL_CDMA_BroadcastSmsConfigInfo **) response;
3486
3487 int num = responselen / sizeof (RIL_CDMA_BroadcastSmsConfigInfo *);
3488 p.writeInt32(num);
3489
3490 startResponse;
3491 for (int i = 0 ; i < num ; i++ ) {
3492 p.writeInt32(p_cur[i]->service_category);
3493 p.writeInt32(p_cur[i]->language);
3494 p.writeInt32(p_cur[i]->selected);
3495
3496 appendPrintBuf("%s [%d: srvice_category=%d, language =%d, \
3497 selected =%d], ",
3498 printBuf, i, p_cur[i]->service_category, p_cur[i]->language,
3499 p_cur[i]->selected);
3500 }
3501 closeResponse;
3502
3503 return 0;
3504}
3505
3506static int responseCdmaSms(Parcel &p, void *response, size_t responselen) {
3507 int num;
3508 int digitCount;
3509 int digitLimit;
3510 uint8_t uct;
3511 void* dest;
3512
3513 RLOGD("Inside responseCdmaSms");
3514
3515 if (response == NULL && responselen != 0) {
3516 RLOGE("invalid response: NULL");
3517 return RIL_ERRNO_INVALID_RESPONSE;
3518 }
3519
3520 if (responselen != sizeof(RIL_CDMA_SMS_Message)) {
3521 RLOGE("invalid response length was %d expected %d",
3522 (int)responselen, (int)sizeof(RIL_CDMA_SMS_Message));
3523 return RIL_ERRNO_INVALID_RESPONSE;
3524 }
3525
3526 RIL_CDMA_SMS_Message *p_cur = (RIL_CDMA_SMS_Message *) response;
3527 p.writeInt32(p_cur->uTeleserviceID);
3528 p.write(&(p_cur->bIsServicePresent),sizeof(uct));
3529 p.writeInt32(p_cur->uServicecategory);
3530 p.writeInt32(p_cur->sAddress.digit_mode);
3531 p.writeInt32(p_cur->sAddress.number_mode);
3532 p.writeInt32(p_cur->sAddress.number_type);
3533 p.writeInt32(p_cur->sAddress.number_plan);
3534 RLOGD("MT CDMA SMS: sAddress.number_plan = %d", p_cur->sAddress.number_plan);
3535 p.write(&(p_cur->sAddress.number_of_digits), sizeof(uct));
3536 RLOGD("MT CDMA SMS: sAddress.number_of_digits = %d", p_cur->sAddress.number_of_digits);
3537 digitLimit= MIN((p_cur->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
3538 String8 str(""), temp;
3539 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
3540 p.write(&(p_cur->sAddress.digits[digitCount]),sizeof(uct));
3541 temp = String8::format("%d,", p_cur->sAddress.digits[digitCount]);
3542 str.append(temp);
3543 }
3544 RLOGD("MT CDMA SMS: sAddress.digits: {%s}", str.isEmpty()? "" : str.string());
3545
3546 p.writeInt32(p_cur->sSubAddress.subaddressType);
3547 RLOGD("MT CDMA SMS: sSubAddress.subaddressType = %d", p_cur->sSubAddress.subaddressType);
3548 p.write(&(p_cur->sSubAddress.odd),sizeof(uct));
3549 RLOGD("MT CDMA SMS: sSubAddress.odd = %d", p_cur->sSubAddress.odd);
3550 p.write(&(p_cur->sSubAddress.number_of_digits),sizeof(uct));
3551 RLOGD("MT CDMA SMS: sSubAddress.number_of_digits = %d", p_cur->sSubAddress.number_of_digits);
3552 digitLimit= MIN((p_cur->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
3553 str.clear();
3554 temp.clear();
3555 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
3556 p.write(&(p_cur->sSubAddress.digits[digitCount]),sizeof(uct));
3557 temp = String8::format("%d,", p_cur->sSubAddress.digits[digitCount]);
3558 str.append(temp);
3559 }
3560 RLOGD("MT CDMA SMS: sSubAddress.digits: {%s}", str.isEmpty() ? "" : str.string());
3561
3562 digitLimit= MIN((p_cur->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
3563 RLOGD("MT CDMA SMS: uBearerDataLen = %d", p_cur->uBearerDataLen);
3564 p.writeInt32(p_cur->uBearerDataLen);
3565 str.clear();
3566 temp.clear();
3567 for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
3568 p.write(&(p_cur->aBearerData[digitCount]), sizeof(uct));
3569 temp = String8::format("%d,", p_cur->aBearerData[digitCount]);
3570 str.append(temp);
3571 }
3572 RLOGD("MT CDMA SMS: aBearerData: {%s}", str.isEmpty() ? "" : str.string());
3573
3574 startResponse;
3575 appendPrintBuf("%suTeleserviceID=%d, bIsServicePresent=%d, uServicecategory=%d, \
3576 sAddress.digit_mode=%d, sAddress.number_mode=%d, sAddress.number_type=%d, ",
3577 printBuf, p_cur->uTeleserviceID,p_cur->bIsServicePresent,p_cur->uServicecategory,
3578 p_cur->sAddress.digit_mode, p_cur->sAddress.number_mode,p_cur->sAddress.number_type);
3579 closeResponse;
3580 resposeCdmaSms(p_cur);
3581 return 0;
3582}
3583
3584static int responseDcRtInfo(Parcel &p, void *response, size_t responselen)
3585{
3586 int num = responselen / sizeof(RIL_DcRtInfo);
3587 if ((responselen % sizeof(RIL_DcRtInfo) != 0) || (num != 1)) {
3588 RLOGE("responseDcRtInfo: invalid response length %d expected multiple of %d",
3589 (int)responselen, (int)sizeof(RIL_DcRtInfo));
3590 return RIL_ERRNO_INVALID_RESPONSE;
3591 }
3592
3593 startResponse;
3594 RIL_DcRtInfo *pDcRtInfo = (RIL_DcRtInfo *)response;
3595 p.writeInt64(pDcRtInfo->time);
3596 p.writeInt32(pDcRtInfo->powerState);
3597 appendPrintBuf("%s[time=%d,powerState=%d]", printBuf,
3598 pDcRtInfo->time,
3599 pDcRtInfo->powerState);
3600 closeResponse;
3601
3602 return 0;
3603}
3604
3605static int responseLceStatus(Parcel &p, void *response, size_t responselen) {
3606 if (response == NULL || responselen != sizeof(RIL_LceStatusInfo)) {
3607 if (response == NULL) {
3608 RLOGE("invalid response: NULL");
3609 }
3610 else {
3611 RLOGE("responseLceStatus: invalid response length %d expecting len: %d",
3612 sizeof(RIL_LceStatusInfo), responselen);
3613 }
3614 return RIL_ERRNO_INVALID_RESPONSE;
3615 }
3616
3617 RIL_LceStatusInfo *p_cur = (RIL_LceStatusInfo *)response;
3618 p.write((void *)p_cur, 1); // p_cur->lce_status takes one byte.
3619 p.writeInt32(p_cur->actual_interval_ms);
3620
3621 startResponse;
3622 appendPrintBuf("LCE Status: %d, actual_interval_ms: %d",
3623 p_cur->lce_status, p_cur->actual_interval_ms);
3624 closeResponse;
3625
3626 return 0;
3627}
3628
3629static int responseLceData(Parcel &p, void *response, size_t responselen) {
3630 if (response == NULL || responselen != sizeof(RIL_LceDataInfo)) {
3631 if (response == NULL) {
3632 RLOGE("invalid response: NULL");
3633 }
3634 else {
3635 RLOGE("responseLceData: invalid response length %d expecting len: %d",
3636 sizeof(RIL_LceDataInfo), responselen);
3637 }
3638 return RIL_ERRNO_INVALID_RESPONSE;
3639 }
3640
3641 RIL_LceDataInfo *p_cur = (RIL_LceDataInfo *)response;
3642 p.writeInt32(p_cur->last_hop_capacity_kbps);
3643
3644 /* p_cur->confidence_level and p_cur->lce_suspended take 1 byte each.*/
3645 p.write((void *)&(p_cur->confidence_level), 1);
3646 p.write((void *)&(p_cur->lce_suspended), 1);
3647
3648 startResponse;
3649 appendPrintBuf("LCE info received: capacity %d confidence level %d and suspended %d",
3650 p_cur->last_hop_capacity_kbps, p_cur->confidence_level,
3651 p_cur->lce_suspended);
3652 closeResponse;
3653
3654 return 0;
3655}
3656
3657static int responseActivityData(Parcel &p, void *response, size_t responselen) {
3658 if (response == NULL || responselen != sizeof(RIL_ActivityStatsInfo)) {
3659 if (response == NULL) {
3660 RLOGE("invalid response: NULL");
3661 }
3662 else {
3663 RLOGE("responseActivityData: invalid response length %d expecting len: %d",
3664 sizeof(RIL_ActivityStatsInfo), responselen);
3665 }
3666 return RIL_ERRNO_INVALID_RESPONSE;
3667 }
3668
3669 RIL_ActivityStatsInfo *p_cur = (RIL_ActivityStatsInfo *)response;
3670 p.writeInt32(p_cur->sleep_mode_time_ms);
3671 p.writeInt32(p_cur->idle_mode_time_ms);
3672 for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) {
3673 p.writeInt32(p_cur->tx_mode_time_ms[i]);
3674 }
3675 p.writeInt32(p_cur->rx_mode_time_ms);
3676
3677 startResponse;
3678 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",
3679 p_cur->sleep_mode_time_ms, p_cur->idle_mode_time_ms, p_cur->tx_mode_time_ms[0],
3680 p_cur->tx_mode_time_ms[1], p_cur->tx_mode_time_ms[2], p_cur->tx_mode_time_ms[3],
3681 p_cur->tx_mode_time_ms[4], p_cur->rx_mode_time_ms);
3682 closeResponse;
3683
3684 return 0;
3685}
3686
3687static int responseSmsSimMemStatus(Parcel &p, void *response, size_t responselen) {
3688 printf("=============%s\n", __FUNCTION__);
3689 if (response == NULL) {
3690 RLOGE("invalid response: NULL");
3691 return RIL_ERRNO_INVALID_RESPONSE;
3692 }
3693
3694 if (responselen != sizeof (RIL_SMS_Memory_Status) ) {
3695 RLOGE("invalid response length %d expected %d",
3696 (int)responselen, (int)sizeof (RIL_SMS_Memory_Status));
3697 return RIL_ERRNO_INVALID_RESPONSE;
3698 }
3699
3700 RIL_SMS_Memory_Status *p_cur = (RIL_SMS_Memory_Status *) response;
3701
3702 p.writeInt32(p_cur->used);
3703 p.writeInt32(p_cur->total);
3704
3705 startResponse;
3706 appendPrintBuf("%s%d,%d", printBuf, p_cur->used, p_cur->total);
3707 closeResponse;
3708
3709 printf("%s%d,%d\n", printBuf, p_cur->used, p_cur->total);
3710 RLOGE("===========================%s%d,%d", printBuf, p_cur->used, p_cur->total);
3711 return 0;
3712}
3713
3714void RIL_startEventLoop(void);
3715extern "C" void
3716RIL_register (const RIL_RadioFunctions *callbacks) {
3717 if (callbacks == NULL) {
3718 RLOGE("RIL_register: RIL_RadioFunctions * null");
3719 return;
3720 }
3721#if 0
3722 if (callbacks->version < RIL_VERSION_MIN) {
3723 RLOGE("RIL_register: version %d is to old, min version is %d",
3724 callbacks->version, RIL_VERSION_MIN);
3725 return;
3726 }
3727 if (callbacks->version > RIL_VERSION) {
3728 RLOGE("RIL_register: version %d is too new, max version is %d",
3729 callbacks->version, RIL_VERSION);
3730 return;
3731 }
3732#endif
3733 RLOGE("RIL_register: RIL version %d", callbacks->version);
3734
3735 if (s_registerCalled > 0) {
3736 RLOGE("RIL_register has been called more than once. "
3737 "Subsequent call ignored");
3738 return;
3739 }
3740
3741 memcpy(&s_callbacks, callbacks, sizeof (RIL_RadioFunctions));
3742
3743 s_registerCalled = 1;
3744
3745 pthread_mutex_lock(&s_InitMutex);
3746 if(utils::is_support_dsds()) {
3747 while (s_isConnected[0] == 0 || s_isConnected[1] == 0) {
3748 pthread_cond_wait(&s_InitCond, &s_InitMutex);
3749 }
3750 } else {
3751 while (s_isConnected[0] == 0 && s_isConnected[1] == 0) {
3752 pthread_cond_wait(&s_InitCond, &s_InitMutex);
3753 }
3754 }
3755 pthread_mutex_unlock(&s_InitMutex);
3756 initCoditions();
3757 // New rild impl calls RIL_startEventLoop() first
3758 // old standalone impl wants it here.
3759
3760 if (s_started == 0) {
3761 RIL_startEventLoop();
3762 }
3763
3764}
3765
3766#if 0
3767static int
3768checkAndDequeueRequestInfo(struct RequestInfo *pRI) {
3769 int ret = 0;
3770 /* Hook for current context
3771 pendingRequestsMutextHook refer to &s_pendingRequestsMutex */
3772 pthread_mutex_t* pendingRequestsMutexHook = &s_pendingRequestsMutex;
3773 /* pendingRequestsHook refer to &s_pendingRequests */
3774 RequestInfo ** pendingRequestsHook = &s_pendingRequests;
3775
3776 if (pRI == NULL) {
3777 return 0;
3778 }
3779
3780#if (SIM_COUNT >= 2)
3781 if (pRI->socket_id == RIL_SOCKET_2) {
3782 pendingRequestsMutexHook = &s_pendingRequestsMutex_socket2;
3783 pendingRequestsHook = &s_pendingRequests_socket2;
3784 }
3785#if (SIM_COUNT >= 3)
3786 if (pRI->socket_id == RIL_SOCKET_3) {
3787 pendingRequestsMutexHook = &s_pendingRequestsMutex_socket3;
3788 pendingRequestsHook = &s_pendingRequests_socket3;
3789 }
3790#endif
3791#if (SIM_COUNT >= 4)
3792 if (pRI->socket_id == RIL_SOCKET_4) {
3793 pendingRequestsMutexHook = &s_pendingRequestsMutex_socket4;
3794 pendingRequestsHook = &s_pendingRequests_socket4;
3795 }
3796#endif
3797#endif
3798 pthread_mutex_lock(pendingRequestsMutexHook);
3799
3800 for(RequestInfo **ppCur = pendingRequestsHook
3801 ; *ppCur != NULL
3802 ; ppCur = &((*ppCur)->p_next)
3803 ) {
3804 if (pRI == *ppCur) {
3805 ret = 1;
3806
3807 *ppCur = (*ppCur)->p_next;
3808 break;
3809 }
3810 }
3811
3812 pthread_mutex_unlock(pendingRequestsMutexHook);
3813
3814 return ret;
3815}
3816
3817#endif
3818
llaaca09b2022-03-14 16:14:28 +08003819static void parse_version_buf(char *buf){
3820 char *p = buf;
3821 int flag = 0;
3822 int recv = 0;
3823 int tmp = -1;
3824 while (*p != '\0')
3825 {
3826 recv++;
3827 if(*p == '"'){
3828 tmp = recv;
3829 }
3830 if(tmp >= 0){
3831 buf[flag++] = buf[tmp++];
3832 if(buf[flag-1] == '\"'){
3833 buf[flag-1] = '\0';
3834 }
3835 }
3836 *p++;
3837 }
3838 return;
3839}
3840
3841static int lynq_get_version(){
3842 FILE *fp;
3843 char buf[128] = {0};
3844 char cgmr[128] = {0};
3845 sprintf(buf, "uci get lynq_uci_ro.lynq_version.LYNQ_SW_VERSION 2>&1");
3846 fp=popen(buf, "r");
3847 int n;
llacba3662022-04-15 16:57:13 +08003848 while(fgets(buf, sizeof(buf), fp) != NULL)
3849 {
llaaca09b2022-03-14 16:14:28 +08003850 }
3851 //parse_version_buf(buf);
llacba3662022-04-15 16:57:13 +08003852 sprintf(cgmr, "%s %s", "+CGMR:", buf);
llaaca09b2022-03-14 16:14:28 +08003853 n = write(ttyGS3_fd,cgmr,strlen(cgmr));
3854 if(n<0)
3855 {
3856 perror("lynq resp write:");
3857 }
3858 pclose(fp);
3859 return 0;
3860}
3861
ll2d5dbd12022-05-19 14:48:44 +08003862static int lynq_get_inside_version(){
3863 FILE *fp;
3864 char buf[128] = {0};
3865 char cgmr[128] = {0};
3866 sprintf(buf, "uci get lynq_uci_ro.lynq_version.LYNQ_SW_INSIDE_VERSION 2>&1");
3867 fp=popen(buf, "r");
3868 int n;
3869 while(fgets(buf, sizeof(buf), fp) != NULL)
3870 {
3871 }
3872 //parse_version_buf(buf);
3873 sprintf(cgmr, "%s %s", "+CGIR:", buf);
3874 n = write(ttyGS3_fd,cgmr,strlen(cgmr));
3875 if(n<0)
3876 {
3877 perror("lynq resp write:");
3878 }
3879 pclose(fp);
3880 return 0;
3881}
3882
3883/**
3884 * @brief cgmr ---> cgir
3885 *
3886 * @param response
3887 */
3888static void parse_inside_version(void *response)
3889{
3890 char *p = (char *)response;
3891 while (*p != 0)
3892 {
3893 if(*p == 'M')
3894 {
3895 *p = 'I';
3896 break;
3897 }
3898 else
3899 {
3900 *p ++;
3901 }
3902 }
3903 return;
3904}
3905
lh7b0674a2022-01-10 00:34:35 -08003906extern "C" void
3907RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responselen) {
3908 RequestInfo *pRI;
3909 int ret;
3910 //int fd = s_ril_param_socket.fdCommand;
3911 size_t errorOffset;
3912 RIL_SOCKET_ID socket_id = RIL_SOCKET_1;
3913
3914 pRI = (RequestInfo *)t;
3915#if 0
3916 if (!checkAndDequeueRequestInfo(pRI)) {
3917 RLOGE ("RIL_onRequestComplete: invalid RIL_Token");
3918 return;
3919 }
3920#endif
3921
3922 socket_id = pRI->socket_id;
3923#if 0
3924#if (SIM_COUNT >= 2)
3925 if (socket_id == RIL_SOCKET_2) {
3926 fd = s_ril_param_socket2.fdCommand;
3927 }
3928#if (SIM_COUNT >= 3)
3929 if (socket_id == RIL_SOCKET_3) {
3930 fd = s_ril_param_socket3.fdCommand;
3931 }
3932#endif
3933#if (SIM_COUNT >= 4)
3934 if (socket_id == RIL_SOCKET_4) {
3935 fd = s_ril_param_socket4.fdCommand;
3936 }
3937#endif
3938#endif
3939#endif
3940#if VDBG
3941 RLOGD("RequestComplete, %s", rilSocketIdToString(socket_id));
3942#endif
3943
3944 if (pRI->local > 0) {
3945 // Locally issued command...void only!
3946 // response does not go back up the command socket
3947 RLOGD("C[locl]< %s", requestToString(pRI->pCI->requestNumber));
3948
3949 goto done;
3950 }
3951
3952 appendPrintBuf("[%x][SIM%d]< %s", pRI->token,socket_id,requestToString(pRI->pCI->requestNumber));
3953
3954 if (pRI->cancelled == 0) {
3955 Parcel p;
3956
3957 p.writeInt32 (RESPONSE_SOLICITED);
3958 p.writeInt32 (pRI->pCI->requestNumber);
3959 /*warren add for t800 ril servie 2021/12/15 start*/
3960 p.writeInt32(socket_id);
3961 /*warren add for t800 ril servie 2021/12/15 end*/
3962 errorOffset = p.dataPosition();
3963
3964 p.writeInt32 (e);
3965
3966 if (response != NULL) {
3967 // there is a response payload, no matter success or not.
3968 ret = pRI->pCI->responseFunction(p, response, responselen);
3969
3970 /* if an error occurred, rewind and mark it */
3971 if (ret != 0) {
3972 RLOGE ("responseFunction error, ret %d", ret);
3973 p.setDataPosition(errorOffset);
3974 p.writeInt32 (ret);
3975 }
3976 switch (pRI->pCI->requestNumber) {
3977 case RIL_REQUEST_QUERY_FACILITY_LOCK:
3978 {
3979 int numInts = responselen / sizeof(int);
3980 if(numInts > 0) {
3981 int *p_int = (int *) response;
3982 RLOGD("RIL_REQUEST_QUERY_FACILITY_LOCK: %s", (p_int[0] != 0 ? "PIN enable" : "PIN1 disable"));
3983 } else {
3984 RLOGD("RIL_REQUEST_QUERY_FACILITY_LOCK response numInts: %d", numInts);
3985 }
3986 break;
3987 }
3988 case RIL_REQUEST_IMS_REGISTRATION_STATE:
3989 {
3990 int numInts = responselen / sizeof(int);
3991 if(numInts > 0) {
3992 int *p_int = (int *) response;
3993 printf("[SIM%d][QUERY][REG_STATUS] IMS is %s\n", socket_id, (p_int[0] == 0 ? "Not registered" : "Registered"));
3994 } else {
3995 RLOGD("RIL_REQUEST_IMS_REGISTRATION_STATE response numInts: %d", numInts);
3996 }
3997 break;
3998 }
3999 case RIL_REQUEST_VOICE_REGISTRATION_STATE:
4000 {
4001 char **p_cur = (char **) response;
4002 int numStrings = responselen / sizeof(char *);
4003 update_reg_voice_service_state(RIL_REQUEST_VOICE_REGISTRATION_STATE, (char *)p_cur[0], socket_id, pRI->token);
4004 int tempVal=0;
4005 memset(respStr,0,sizeof(respStr));
4006 tempVal = atoi((char *)p_cur[0]);
4007 if(tempVal == 1 || tempVal==5){
4008 sprintf(respStr,"[SIM%d]%s register is in service!",socket_id +1, respStr);
4009 }else{
4010 sprintf(respStr,"[SIM%d]%s register is not in service!",socket_id +1, respStr);
4011 }
4012 if(numStrings >=4 && p_cur[3] != NULL)
4013 {
4014 update_reg_voice_radio_tech(RIL_REQUEST_VOICE_REGISTRATION_STATE, atoi((char *)p_cur[3]), socket_id, pRI->token);
4015 tempVal = atoi((char *)p_cur[3]);
4016 if(tempVal == RADIO_TECH_LTE){//4G
4017 sprintf(respStr,"%s radioTech is 4G!",respStr);
4018 } else if( tempVal == RADIO_TECH_GSM ||
4019 tempVal == RADIO_TECH_GPRS ||
4020 tempVal == RADIO_TECH_EDGE ||
4021 tempVal == RADIO_TECH_IS95A ||
4022 tempVal == RADIO_TECH_IS95B ||
4023 tempVal == RADIO_TECH_1xRTT) { //2G
4024 sprintf(respStr,"%s radioTech is 2G!",respStr);
4025 } else if( tempVal == RADIO_TECH_UMTS ||
4026 tempVal == RADIO_TECH_HSDPA ||
4027 tempVal == RADIO_TECH_HSUPA ||
4028 tempVal == RADIO_TECH_HSPA ||
4029 tempVal == RADIO_TECH_EHRPD ||
4030 tempVal == RADIO_TECH_HSPAP ||
4031 tempVal == RADIO_TECH_TD_SCDMA ||
4032 tempVal == RADIO_TECH_EVDO_0 ||
4033 tempVal == RADIO_TECH_EVDO_A ||
4034 tempVal == RADIO_TECH_EVDO_B) { //3G
4035 sprintf(respStr,"%s radioTech is 3G!",respStr);
4036#ifdef TELEMATIC_5G_SUPPORT
4037 } else if(tempVal == RADIO_TECH_NR) { //5G
4038 sprintf(respStr,"%s radioTech is 5G!",respStr);
4039#endif
4040 } else { //unknown
4041 sprintf(respStr,"%s radioTech is unkown!",respStr);
4042 }
4043 }
4044 sprintf(respStr,"%s\n",respStr);
4045 break;
4046 }
4047 case RIL_REQUEST_DATA_REGISTRATION_STATE:
4048 {
4049 char **p_cur = (char **) response;
4050 int numStrings = responselen / sizeof(char *);
4051 update_reg_data_service_state(RIL_REQUEST_DATA_REGISTRATION_STATE, (char *)p_cur[0], socket_id, pRI->token);
4052 if(numStrings >=4 && p_cur[3] != NULL)
4053 {
4054 update_reg_data_radio_tech(RIL_REQUEST_DATA_REGISTRATION_STATE, atoi((char *)p_cur[3]), socket_id, pRI->token);
4055 }
llaaca09b2022-03-14 16:14:28 +08004056 /*Warren add for SZZT 2021/11/14 start*/
4057 lynqAtRespWatingEvent();
4058 /*Warren add for SZZT 2021/11/14 end*/
lh7b0674a2022-01-10 00:34:35 -08004059 break;
4060 }
4061 case RIL_REQUEST_GET_CURRENT_CALLS:
4062 {
4063 update_call_state(response,responselen, socket_id);
4064 int num = responselen / sizeof(RIL_Call *);
4065 speechonoff(num);
4066 printf("%s\n", printBuf);
4067 break;
4068 }
4069 case RIL_REQUEST_SETUP_DATA_CALL:
4070 {
4071 int num = responselen / sizeof(RIL_Data_Call_Response_v6);
4072 RIL_Data_Call_Response_v6 *p_cur = (RIL_Data_Call_Response_v6 *) response;
4073 updateRILDataCallResponsev6(num,p_cur);
4074 break;
4075 }
q.huang3c4b3252022-04-28 18:24:48 +08004076 case RIL_REQUEST_ANSWER:
4077 {
4078 if(e==RIL_E_SUCCESS)
4079 {
4080 resetMute();
4081 }
4082 break;
4083 }
lh7b0674a2022-01-10 00:34:35 -08004084 case RIL_REQUEST_GET_SIM_STATUS:
4085 {
4086 if (responselen == sizeof (RIL_CardStatus_v6)) {
4087 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
4088 updateCardStatusV6(p_cur, socket_id);
4089 }
4090 break;
4091 }
4092 case RIL_REQUEST_VOICE_RADIO_TECH:
4093 {
4094 update_voice_radio_tech(((int *) response)[0], socket_id);
4095 break;
4096 }
4097 case RIL_REQUEST_GET_RADIO_CAPABILITY:
4098 {
4099 update_radio_capa((RIL_RadioCapability *) response, socket_id);
4100 break;
4101 }
4102 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE:
4103 {
4104 update_preferred_network_type(((int *) response)[0], socket_id);
4105 break;
4106 }
4107 case RIL_REQUEST_DELETE_SMS_ON_SIM:
4108 {
4109 setSimSmsStorageFullFlag(false);
4110 break;
4111 }
4112 case RIL_REQUEST_SEND_SMS:
4113 case RIL_REQUEST_SEND_SMS_EXPECT_MORE:
4114 case RIL_REQUEST_IMS_SEND_SMS:
4115 {
4116 //for auto save sms to sim
4117 sendStatusWriteSmsToSim(socket_id);
4118 break;
4119 }
4120 case RIL_REQUEST_ECALL_SET_REGISTRATION_STATE:
4121 {
4122 int numInts = responselen / sizeof(int);
4123 if(numInts > 0) {
4124 int *p_int = (int *) response;
4125 RLOGD("RIL_REQUEST_ECALL_SET_REGISTRATION_STATE: %d", p_int[0]);
4126 if(p_int[0] == ECALL_DEREGISTRATION)
4127 {
4128 gostSetInNeedRegister(true);
4129 }
4130
4131 } else {
4132 RLOGD("RIL_REQUEST_ECALL_SET_REGISTRATION_STATE response numInts: %d", numInts);
4133 }
4134 break;
4135 }
llaaca09b2022-03-14 16:14:28 +08004136 case RIL_REQUEST_OEM_HOOK_RAW:
4137 {
4138 if(pRI->lynqEvent==1)
4139 {
4140 /*lei add for at+cgmr*/
4141 if(strstr((const char*)response,"+CGMR")){
4142 lynq_get_version();
4143 }
4144 /*lei add for at+cgmr*/
4145 int n = write(ttyGS3_fd,response,responselen);
4146 if(n<0)
4147 {
4148 perror("lynq resp write:");
4149 }
4150 printf("n = %d\n",n);
4151 }
ll2d5dbd12022-05-19 14:48:44 +08004152 /*lei add only for factory test 2022/5/19*/
4153 if(pRI->lynqEvent==3)
4154 {
4155 /*lei add for at+cgir*/
4156 if(strstr((const char*)response,"+CGMR")){
4157 lynq_get_inside_version();
4158 }
4159 /*lei add for at+cgir*/
4160 parse_inside_version(response);
4161 int n = write(ttyGS3_fd,response,responselen);
4162 if(n<0)
4163 {
4164 perror("lynq resp write:");
4165 }
4166 printf("n = %d\n",n);
4167 }
llaaca09b2022-03-14 16:14:28 +08004168 }
lh7b0674a2022-01-10 00:34:35 -08004169 default:
4170 break;
4171 }
4172 }
llaaca09b2022-03-14 16:14:28 +08004173 /*Warren add for FAW platform 2021/10/8 start*/
4174 else
4175 {
4176 if(pRI->lynqEvent==1)
4177 {
4178 char eBuf[64] = {0};
4179 bzero(eBuf, 64);
4180 if(e==RIL_E_SUCCESS)
4181 {
4182 sprintf(eBuf,"\nOK\n\0");
4183 }
4184 else
4185 {
4186 sprintf(eBuf,"\nCME ERROR: %d\n\0",e);
4187 }
4188 int n = write(ttyGS3_fd,eBuf,strlen(eBuf));
4189 if(n<0)
4190 {
4191 perror("lynq resp write:");
4192 }
4193 //printf("n = %d\n",n);
4194 }
4195 }
4196 /*Warren add for FAW platform 2021/10/8 start*/
lh7b0674a2022-01-10 00:34:35 -08004197 if (e != RIL_E_SUCCESS) {
4198 appendPrintBuf("%s fails by %s", printBuf, failCauseToString(e));
4199 }
4200
4201 if ((pRI->token & RIL_TOKEN_MARK) == RIL_TOKEN_MARK) {
4202 printf("%s\n", printBuf ? printBuf : "unkonwn");
4203 } else if (((pRI->pCI->requestNumber == RIL_REQUEST_DEVICE_IDENTITY)
4204 || (pRI->pCI->requestNumber == RIL_REQUEST_OEM_HOOK_RAW))
4205 && (pRI->token & INIT_TOKEN_MARK) == INIT_TOKEN_MARK) {
4206 printf("%s\n", printBuf ? printBuf : "unkonwn");
4207 if (pRI->pCI->requestNumber == RIL_REQUEST_DEVICE_IDENTITY) {
4208 if (e != RIL_E_SUCCESS) {
4209 printf(
4210 "*******************************************\n*** NOTICE: IMEI don't wirite in slot%d ***\n*******************************************\n",
4211 socket_id);
4212 }
4213 }
4214 }
4215
4216#if 0
4217 if (fd < 0) {
4218 RLOGD ("RIL onRequestComplete: Command channel closed");
4219 }
4220#endif
4221 LYNQ_RIL_respSocket(p,t);
4222 sendResponse(p, socket_id);
4223 }
4224#if ATCI_ENABLE_RESPONSE
4225 if((pRI->token & ATCI_TOKEN_MARK) == ATCI_TOKEN_MARK) //ATCI_Rsp
4226 {
4227 int error;
4228 memset(Respose_buf, 0, sizeof(Respose_buf));
4229 if(e != RIL_E_SUCCESS)
4230 error = 1; //fail
4231 else
4232 error = 0; //ok
4233 ATCIResponse(pRI->token,error,Respose_buf, pRI->pCI->requestNumber);
4234 }
4235#endif
4236 if(pRI->pCI->requestNumber == RIL_REQUEST_VOICE_REGISTRATION_STATE && (pRI->token & RIL_TOKEN_MARK) == RIL_TOKEN_MARK){
4237 int len_s = sendto(server_socket_fd,respStr,strlen(respStr),0,(struct sockaddr *)&client_addr,sizeof(client_addr));
4238 }
4239 RLOGW("RIL_onRequestComplete %s end!",requestToString(pRI->pCI->requestNumber));
4240 if((pRI->token&BLOCK_MARK) == BLOCK_MARK) {
4241 //need wakeup dispatch function
4242 BLOCK_LOCK();
4243 wakeup_token = pRI->token;
4244 RLOGW("RIL_onRequestComplete wakeup, token is %x!",wakeup_token);
4245 BLOCK_WAKEUP();
4246 BLOCK_UNLOCK();
4247 }
4248 switch (pRI->pCI->requestNumber) {
4249 case RIL_REQUEST_RADIO_POWER:
4250 speciaRequest_wakeup();
4251 break;
4252 case RIL_REQUEST_SET_RADIO_CAPABILITY:
4253 {
4254 if(utils::is_support_dsds()) {
4255 for (int id = 0; id < SIM_COUNT; id++) {
4256 ARspRequest(RIL_REQUEST_ALLOW_DATA, (RIL_SOCKET_ID)id);
4257 }
4258 }
4259 break;
4260 }
4261 case RIL_REQUEST_ALLOW_DATA:
4262 {
4263 if(utils::is_support_dsds() && isNeedConnect() && get_default_sim_data() == socket_id) {
xja1c30b82022-01-25 16:13:48 +08004264 RLOGD("wait and recreate PDN with sim switch");
lh7b0674a2022-01-10 00:34:35 -08004265 resetConnect();
xja1c30b82022-01-25 16:13:48 +08004266 sleep(WAIT_TIME_FOR_SIM_SWITCH);
lh7b0674a2022-01-10 00:34:35 -08004267 setupDataCall(0, NULL, (RIL_SOCKET_ID)0, NULL);
4268 }
4269 break;
4270 }
4271#ifdef KEEP_ALIVE
4272 case RIL_REQUEST_START_KEEPALIVE_PRO:
4273 case RIL_REQUEST_STOP_KEEPALIVE_PRO:
4274 {
4275 handleKeepAliveResponse(pRI->pCI->requestNumber, response, responselen, socket_id, (e != RIL_E_SUCCESS));
4276 break;
4277 }
4278#endif /*KEEP_ALIVE*/
4279 case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC:
4280 {
4281 if(e == RIL_E_SUCCESS)
4282 {
4283 gostSetInNeedRegister(false);
4284 gostFastEcallFlgSet(false);
4285 }
4286 else
4287 {
4288 gostNetworkSelectionSet(socket_id);
4289 }
4290 break;
4291 }
4292 default:
4293 break;
4294 }
4295done:
4296 free(pRI);
4297}
4298
4299
4300static void
4301grabPartialWakeLock() {
4302 acquire_wake_lock(PARTIAL_WAKE_LOCK, ANDROID_WAKE_LOCK_NAME);
4303}
4304
4305static void
4306releaseWakeLock() {
4307 release_wake_lock(ANDROID_WAKE_LOCK_NAME);
4308}
4309
4310
4311static int
4312decodeVoiceRadioTechnology (RIL_RadioState radioState) {
4313 switch (radioState) {
4314 case RADIO_STATE_SIM_NOT_READY:
4315 case RADIO_STATE_SIM_LOCKED_OR_ABSENT:
4316 case RADIO_STATE_SIM_READY:
4317 return RADIO_TECH_UMTS;
4318
4319 case RADIO_STATE_RUIM_NOT_READY:
4320 case RADIO_STATE_RUIM_READY:
4321 case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:
4322 case RADIO_STATE_NV_NOT_READY:
4323 case RADIO_STATE_NV_READY:
4324 return RADIO_TECH_1xRTT;
4325
4326 default:
4327 RLOGD("decodeVoiceRadioTechnology: Invoked with incorrect RadioState");
4328 return -1;
4329 }
4330}
4331
4332static int
4333decodeCdmaSubscriptionSource (RIL_RadioState radioState) {
4334 switch (radioState) {
4335 case RADIO_STATE_SIM_NOT_READY:
4336 case RADIO_STATE_SIM_LOCKED_OR_ABSENT:
4337 case RADIO_STATE_SIM_READY:
4338 case RADIO_STATE_RUIM_NOT_READY:
4339 case RADIO_STATE_RUIM_READY:
4340 case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:
4341 return CDMA_SUBSCRIPTION_SOURCE_RUIM_SIM;
4342
4343 case RADIO_STATE_NV_NOT_READY:
4344 case RADIO_STATE_NV_READY:
4345 return CDMA_SUBSCRIPTION_SOURCE_NV;
4346
4347 default:
4348 RLOGD("decodeCdmaSubscriptionSource: Invoked with incorrect RadioState");
4349 return -1;
4350 }
4351}
4352
4353static int
4354decodeSimStatus (RIL_RadioState radioState) {
4355 switch (radioState) {
4356 case RADIO_STATE_SIM_NOT_READY:
4357 case RADIO_STATE_RUIM_NOT_READY:
4358 case RADIO_STATE_NV_NOT_READY:
4359 case RADIO_STATE_NV_READY:
4360 return -1;
4361 case RADIO_STATE_SIM_LOCKED_OR_ABSENT:
4362 case RADIO_STATE_SIM_READY:
4363 case RADIO_STATE_RUIM_READY:
4364 case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:
4365 return radioState;
4366 default:
4367 RLOGD("decodeSimStatus: Invoked with incorrect RadioState");
4368 return -1;
4369 }
4370}
4371
4372static bool is3gpp2(int radioTech) {
4373 switch (radioTech) {
4374 case RADIO_TECH_IS95A:
4375 case RADIO_TECH_IS95B:
4376 case RADIO_TECH_1xRTT:
4377 case RADIO_TECH_EVDO_0:
4378 case RADIO_TECH_EVDO_A:
4379 case RADIO_TECH_EVDO_B:
4380 case RADIO_TECH_EHRPD:
4381 return true;
4382 default:
4383 return false;
4384 }
4385}
4386
4387/* If RIL sends SIM states or RUIM states, store the voice radio
4388 * technology and subscription source information so that they can be
4389 * returned when telephony framework requests them
4390 */
4391static RIL_RadioState
4392processRadioState(RIL_RadioState newRadioState, RIL_SOCKET_ID socket_id) {
4393
4394 if((newRadioState > RADIO_STATE_UNAVAILABLE) && (newRadioState < RADIO_STATE_ON)) {
4395 int newVoiceRadioTech;
4396 int newCdmaSubscriptionSource;
4397 int newSimStatus;
4398
4399 /* This is old RIL. Decode Subscription source and Voice Radio Technology
4400 from Radio State and send change notifications if there has been a change */
4401 newVoiceRadioTech = decodeVoiceRadioTechnology(newRadioState);
4402 if(newVoiceRadioTech != voiceRadioTech) {
4403 voiceRadioTech = newVoiceRadioTech;
4404 RIL_UNSOL_RESPONSE(RIL_UNSOL_VOICE_RADIO_TECH_CHANGED,
4405 &voiceRadioTech, sizeof(voiceRadioTech), socket_id);
4406 }
4407 if(is3gpp2(newVoiceRadioTech)) {
4408 newCdmaSubscriptionSource = decodeCdmaSubscriptionSource(newRadioState);
4409 if(newCdmaSubscriptionSource != cdmaSubscriptionSource) {
4410 cdmaSubscriptionSource = newCdmaSubscriptionSource;
4411 RIL_UNSOL_RESPONSE(RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED,
4412 &cdmaSubscriptionSource, sizeof(cdmaSubscriptionSource), socket_id);
4413 }
4414 }
4415 newSimStatus = decodeSimStatus(newRadioState);
4416 if(newSimStatus != simRuimStatus) {
4417 simRuimStatus = newSimStatus;
4418 RIL_UNSOL_RESPONSE(RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, NULL, 0, socket_id);
4419 }
4420
4421 /* Send RADIO_ON to telephony */
4422 newRadioState = RADIO_STATE_ON;
4423 }
4424
4425 return newRadioState;
4426}
4427
4428
4429#if defined(ANDROID_MULTI_SIM)
4430extern "C"
4431void RIL_onUnsolicitedResponse(int unsolResponse, const void *data,
4432 size_t datalen, RIL_SOCKET_ID socket_id)
4433#else
4434extern "C"
4435void RIL_onUnsolicitedResponse(int unsolResponse, const void *data,
4436 size_t datalen)
4437#endif
4438{
4439 int unsolResponseIndex;
4440 int ret;
4441 int64_t timeReceived = 0;
4442 bool shouldScheduleTimeout = false;
4443 RIL_RadioState newState;
lhf6eea122022-01-20 19:32:14 -08004444 int temp = 0;
4445 char *tempChar=NULL;
lh7b0674a2022-01-10 00:34:35 -08004446 RIL_SOCKET_ID soc_id = (RIL_SOCKET_ID)Phone_utils::get_enable_sim_for_dsss();
4447
4448#if defined(ANDROID_MULTI_SIM)
4449 soc_id = socket_id;
4450#endif
4451
4452 handle_wakeup_reason(unsolResponse);
4453
4454 if (s_registerCalled == 0) {
4455 // Ignore RIL_onUnsolicitedResponse before RIL_register
4456 RLOGW("RIL_onUnsolicitedResponse called before RIL_register");
4457 return;
4458 }
4459 if(onSupports(unsolResponse) == 0)
4460 {
4461 RLOGE("unsupported unsolicited response code %d", unsolResponse);
4462 return;
4463 }
4464
4465#ifdef TARGET_PLATFORM_MT2635
4466 //Reset modem, exit DemoApp.
4467 if(unsolResponse==RIL_UNSOL_MAL_RESTART ) {
4468 RLOGD("Modem Reset, Exit DemoApp!");
4469 printf("Modem Reset, Exit DemoApp!\n");
4470 speechonoff(0);
4471 mixer_reset_set(1);
4472 com_quit(0,NULL,soc_id,NULL);
4473 }
4474#endif
4475 if (unsolResponse < RIL_UNSOL_VENDOR_BASE) {
4476 unsolResponseIndex = unsolResponse - RIL_UNSOL_RESPONSE_BASE;
4477 }
4478#if 0
4479 WakeType wakeType;
4480 if (unsolResponse >= RIL_UNSOL_VENDOR_BASE) {
4481 //unsolResponseIndex = unsolResponse - RIL_UNSOL_VENDOR_BASE;
4482 wakeType = WAKE_PARTIAL;
4483 } else {
4484 unsolResponseIndex = unsolResponse - RIL_UNSOL_RESPONSE_BASE;
4485 wakeType = s_unsolResponses[unsolResponseIndex].wakeType;
4486 }
4487
4488 // Grab a wake lock if needed for this reponse,
4489 // as we exit we'll either release it immediately
4490 // or set a timer to release it later.
4491 switch (wakeType) {
4492 case WAKE_PARTIAL:
4493 grabPartialWakeLock();
4494 shouldScheduleTimeout = false;
4495 break;
4496
4497 case DONT_WAKE:
4498 default:
4499 // No wake lock is grabed so don't set timeout
4500 shouldScheduleTimeout = false;
4501 break;
4502 }
4503
4504 // Mark the time this was received, doing this
4505 // after grabing the wakelock incase getting
4506 // the elapsedRealTime might cause us to goto
4507 // sleep.
4508 if (unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) {
4509 timeReceived = elapsedRealtime();
4510 }
4511#endif
4512 appendPrintBuf("[UNSL][SIM%d]< %s", soc_id, requestToString(unsolResponse));
4513
4514 Parcel p;
lh7b0674a2022-01-10 00:34:35 -08004515 p.writeInt32 (RESPONSE_UNSOLICITED);
4516 p.writeInt32 (unsolResponse);
4517 /*Warren add for t800 ril service 2021/12/16 start*/
4518 p.writeInt32 (soc_id);
4519 /*Warren add for t800 ril service 2021/12/16 end*/
4520 if (unsolResponse >= RIL_UNSOL_VENDOR_BASE) {
4521 UnsolResponseInfo* unsolRspInof = find_mtk_unsol_command(unsolResponse);
4522 if(unsolRspInof == NULL){
4523 RLOGE("no unsolicited response function -- %d", unsolResponse);
4524 return;
4525 } else {
4526 ret = unsolRspInof->responseFunction(p,const_cast<void*>(data),datalen);
4527 }
4528 } else {
4529 ret = s_unsolResponses[unsolResponseIndex].responseFunction(p, const_cast<void*>(data), datalen);
4530 }
4531 if (ret != 0) {
4532 // Problem with the response. Don't continue;
4533 goto error_exit;
4534 }
4535
4536 // some things get more payload
4537 switch(unsolResponse) {
4538 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED:
4539 newState = CALL_ONSTATEREQUEST(soc_id);
4540 p.writeInt32(newState);
4541 appendPrintBuf("%s {%s}", printBuf,
4542 radioStateToString(CALL_ONSTATEREQUEST(soc_id)));
4543 break;
4544
4545#if 0
4546 case RIL_UNSOL_NITZ_TIME_RECEIVED:
4547 // Store the time that this was received so the
4548 // handler of this message can account for
4549 // the time it takes to arrive and process. In
4550 // particular the system has been known to sleep
4551 // before this message can be processed.
4552 p.writeInt64(timeReceived);
4553 break;
4554#endif
4555 }
4556
4557#if VDBG
4558 RLOGI("%s UNSOLICITED: %s length:%d", rilSocketIdToString(soc_id), requestToString(unsolResponse), p.dataSize());
4559#endif
lhf6eea122022-01-20 19:32:14 -08004560 //ret = sendResponse(p, soc_id);
lh7b0674a2022-01-10 00:34:35 -08004561
4562//unsol trigger other things.
4563 switch(unsolResponse) {
4564 //case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED:
4565 //ARspRequest(RIL_REQUEST_GET_CURRENT_CALLS, soc_id);
4566 //break;
4567 case RIL_UNSOL_CALL_RING:
4568 callRing(soc_id);
4569 break;
4570 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED:
4571 updateIccCardState(soc_id);
4572 break;
4573 case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED:
4574 getVoiceAndDataRegistrationState(soc_id);
4575 break;
4576 case RIL_UNSOL_RESPONSE_NEW_SMS:
lhf6eea122022-01-20 19:32:14 -08004577 responseNewSMS((const char*)data, datalen,soc_id,unsolResponse,p);
lh7b0674a2022-01-10 00:34:35 -08004578 unreadStatusWriteSMSToSim((const char*)data, datalen, soc_id);
4579 sendSMSACK(soc_id);
4580 break;
4581 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS:
4582 {
4583 RLOGD("Receive RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS data: %s, length: %d", (char*)data, datalen);
4584 break;
4585 }
4586 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT:
4587 sendSMSACK(soc_id);
4588 break;
4589 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED:
4590 updateRadioStatus(newState,soc_id);
4591 break;
4592 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS:
4593 {
4594 ARspRequest(RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE, soc_id);
4595 break;
4596 }
4597 case RIL_UNSOL_STK_PROACTIVE_COMMAND:
4598 {
4599 RLOGD("STk proactive command raw date: %s, length: %d", (char*)data, datalen);
4600 handleStkCommand((char*)data, datalen,soc_id);
4601 break;
4602 }
4603 case RIL_UNSOL_RIL_CONNECTED:
4604 {
4605 RLOGD("vendor-ril socket(%d) connect start", soc_id);
4606 pthread_mutex_lock(&s_InitMutex);
4607 s_isConnected[soc_id] = 1;
4608 if(utils::is_support_dsds()) {
4609 if (s_isConnected[0] == 1 && s_isConnected[1] == 1) {
4610 pthread_cond_broadcast(&s_InitCond);
4611 }
4612 } else {
4613 if (s_isConnected[0] == 1 || s_isConnected[1] == 1) {
4614 pthread_cond_broadcast(&s_InitCond);
4615 }
4616 }
4617 pthread_mutex_unlock(&s_InitMutex);
4618 RLOGD("vendor-ril socket(%d) connect end", soc_id);
4619 break;
4620 }
4621 case RIL_UNSOL_TX_POWER: {
4622 int *p_int = (int *) data;
4623 int numInts = datalen / sizeof(int);
4624 if (numInts > 1) {
4625 m_RfDesense->emOemHookRaw(p_int[1],soc_id);
4626 } else {
4627 m_RfDesense->emOemHookRaw(0, soc_id);
4628 }
4629 break;
4630 }
4631 case RIL_UNSOL_NETWORK_INFO: {
4632 if(networkCb){
4633 //TBD
4634 char **p_cur = (char **) data;
4635 char *ctype = (char*)p_cur[0];
4636 int type = atoi(ctype);
4637 char *data = (char*)p_cur[1];
4638 RLOGD("ctype %s type %d data %s\n",ctype,type,data);
4639 networkCb(type,data);
4640 }
4641 break;
4642 }
4643 case RIL_UNSOL_DATA_CALL_LIST_CHANGED:
4644 {
4645 int num = datalen / sizeof(RIL_Data_Call_Response_v6);
4646 RIL_Data_Call_Response_v6 *p_cur = (RIL_Data_Call_Response_v6 *) data;
4647 handleUnsolDataCalllistChange(num,p_cur);
4648 break;
4649 }
4650 case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED:
4651 {
4652 update_voice_radio_tech(((int *) data)[0], soc_id);
4653 break;
4654 }
4655 case RIL_UNSOL_RADIO_CAPABILITY:
4656 {
4657 update_radio_capa((RIL_RadioCapability *) data, soc_id);
4658 //Proxy_controller::getInstance()->handle_message_notify((RIL_RadioCapability *) data, soc_id);
4659 break;
4660 }
4661 case RIL_UNSOL_CDMA_CALL_WAITING:
4662 {
4663 autoAnswerForCdma(soc_id);
4664 break;
4665 }
4666 case RIL_UNSOL_NITZ_TIME_RECEIVED:
4667 {
4668 updateSystemTime(data, datalen);
4669 break;
4670 }
4671 case RIL_UNSOL_ECALL_INDICATIONS:
4672 {
4673 handleEcallIndication(data, datalen, soc_id);
4674 break;
4675 }
4676#ifdef KEEP_ALIVE
4677 case RIL_UNSOL_KEEPALIVE_STATUS_PRO:
4678 {
4679 handleKeepAliveResponse(unsolResponse, data, datalen, soc_id, false);
4680 break;
4681 }
4682#endif /*KEEP_ALIVE*/
4683 case RIL_UNSOL_SIM_SMS_STORAGE_FULL:
4684 {
4685 setSimSmsStorageFullFlag(true);
4686 break;
4687 }
4688 case RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR:
4689 {
4690 handleUnsolSipCallProgressInd(data, datalen);
4691 break;
4692 }
4693 case RIL_UNSOL_ECC_NUM:
4694 {
4695 handleECCNumResponse(data, datalen,soc_id);
4696 break;
4697 }
4698 case RIL_UNSOL_CALL_INFO_INDICATION:
4699 {
4700 handleUnsolCallInfoInd(data, datalen, soc_id);
4701 break;
4702 }
4703 case RIL_UNSOL_RINGBACK_TONE:
4704 {
4705 handleRingbackTone(data, datalen, soc_id);
4706 break;
4707 }
4708 default:
4709 break;
4710 }
lhf6eea122022-01-20 19:32:14 -08004711 /*Warren add for t800 ril service 2021/12/16 start*/
4712 ret = LYNQ_RIL_urcBroadcast(p);
4713 /*Warren add for t800 ril service 2021/12/16 end*/
lh7b0674a2022-01-10 00:34:35 -08004714#if 0
4715 if (ret != 0 && unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) {
4716
4717 // Unfortunately, NITZ time is not poll/update like everything
4718 // else in the system. So, if the upstream client isn't connected,
4719 // keep a copy of the last NITZ response (with receive time noted
4720 // above) around so we can deliver it when it is connected
4721
4722 if (s_lastNITZTimeData != NULL) {
4723 free (s_lastNITZTimeData);
4724 s_lastNITZTimeData = NULL;
4725 }
4726
4727 s_lastNITZTimeData = malloc(p.dataSize());
4728 s_lastNITZTimeDataSize = p.dataSize();
4729 memcpy(s_lastNITZTimeData, p.data(), p.dataSize());
4730 }
4731
4732#endif
4733 // Normal exit
4734 return;
4735
4736error_exit:
4737 RLOGD("unsol handle fail");
4738#if 0
4739 if (shouldScheduleTimeout) {
4740 releaseWakeLock();
4741 }
4742#endif
4743}
4744
4745extern "C" void
4746RIL_requestTimedCallback (RIL_TimedCallback callback, void *param,
4747 const struct timeval *relativeTime) {
4748}
4749
4750const char *
4751failCauseToString(RIL_Errno e) {
4752 switch(e) {
4753 case RIL_E_SUCCESS: return "E_SUCCESS";
4754 case RIL_E_RADIO_NOT_AVAILABLE: return "E_RADIO_NOT_AVAILABLE";
4755 case RIL_E_GENERIC_FAILURE: return "E_GENERIC_FAILURE";
4756 case RIL_E_PASSWORD_INCORRECT: return "E_PASSWORD_INCORRECT";
4757 case RIL_E_SIM_PIN2: return "E_SIM_PIN2";
4758 case RIL_E_SIM_PUK2: return "E_SIM_PUK2";
4759 case RIL_E_REQUEST_NOT_SUPPORTED: return "E_REQUEST_NOT_SUPPORTED";
4760 case RIL_E_CANCELLED: return "E_CANCELLED";
4761 case RIL_E_OP_NOT_ALLOWED_DURING_VOICE_CALL: return "E_OP_NOT_ALLOWED_DURING_VOICE_CALL";
4762 case RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW: return "E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW";
4763 case RIL_E_SMS_SEND_FAIL_RETRY: return "E_SMS_SEND_FAIL_RETRY";
4764 case RIL_E_SIM_ABSENT:return "E_SIM_ABSENT";
4765 case RIL_E_ILLEGAL_SIM_OR_ME:return "E_ILLEGAL_SIM_OR_ME";
4766#ifdef FEATURE_MULTIMODE_ANDROID
4767 case RIL_E_SUBSCRIPTION_NOT_AVAILABLE:return "E_SUBSCRIPTION_NOT_AVAILABLE";
4768 case RIL_E_MODE_NOT_SUPPORTED:return "E_MODE_NOT_SUPPORTED";
4769#endif
4770 case RIL_E_SIM_MEM_FULL: return "E_SIM_MEM_FULL";
4771 default: return "<unknown error>";
4772 }
4773}
4774
4775const char *
4776callStateToString(RIL_CallState s) {
4777 switch(s) {
4778 case RIL_CALL_ACTIVE : return "ACTIVE";
4779 case RIL_CALL_HOLDING: return "HOLDING";
4780 case RIL_CALL_DIALING: return "DIALING";
4781 case RIL_CALL_ALERTING: return "ALERTING";
4782 case RIL_CALL_INCOMING: return "INCOMING";
4783 case RIL_CALL_WAITING: return "WAITING";
4784 default: return "<unknown state>";
4785 }
4786}
4787const char *lynq_requset_to_string(int request)
4788{
4789 switch(request) {
4790 case RIL_REQUEST_GET_SIM_STATUS: return "RIL_REQUEST_GET_SIM_STATUS";
4791 case RIL_REQUEST_ENTER_SIM_PIN: return "RIL_REQUEST_ENTER_SIM_PIN";
4792 case RIL_REQUEST_ENTER_SIM_PUK: return "RIL_REQUEST_ENTER_SIM_PUK";
4793 case RIL_REQUEST_ENTER_SIM_PIN2: return "RIL_REQUEST_ENTER_SIM_PIN2";
4794 case RIL_REQUEST_ENTER_SIM_PUK2: return "RIL_REQUEST_ENTER_SIM_PUK2";
4795 case RIL_REQUEST_CHANGE_SIM_PIN: return "RIL_REQUEST_CHANGE_SIM_PIN";
4796 case RIL_REQUEST_CHANGE_SIM_PIN2: return "RIL_REQUEST_CHANGE_SIM_PIN2";
4797 case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: return "RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION";
4798 case RIL_REQUEST_GET_CURRENT_CALLS: return "RIL_REQUEST_GET_CURRENT_CALLS";
4799 case RIL_REQUEST_DIAL: return "RIL_REQUEST_DIAL";
4800 case RIL_REQUEST_GET_IMSI: return "RIL_REQUEST_GET_IMSI";
4801 case RIL_REQUEST_HANGUP: return "RIL_REQUEST_HANGUP";
4802 case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: return "RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND";
4803 case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: return "RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND";
4804 case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: return "RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE";
4805 case RIL_REQUEST_CONFERENCE: return "RIL_REQUEST_CONFERENCE";
4806 case RIL_REQUEST_UDUB: return "RIL_REQUEST_UDUB";
4807 case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: return "RIL_REQUEST_LAST_CALL_FAIL_CAUSE";
4808 case RIL_REQUEST_SIGNAL_STRENGTH: return "RIL_REQUEST_SIGNAL_STRENGTH";
4809 case RIL_REQUEST_VOICE_REGISTRATION_STATE: return "RIL_REQUEST_VOICE_REGISTRATION_STATE";
4810 case RIL_REQUEST_DATA_REGISTRATION_STATE: return "RIL_REQUEST_DATA_REGISTRATION_STATE";
4811 case RIL_REQUEST_OPERATOR: return "RIL_REQUEST_OPERATOR";
4812 case RIL_REQUEST_RADIO_POWER: return "RIL_REQUEST_RADIO_POWER";
4813 case RIL_REQUEST_DTMF: return "RIL_REQUEST_DTMF";
4814 case RIL_REQUEST_SEND_SMS: return "RIL_REQUEST_SEND_SMS";
4815 case RIL_REQUEST_SEND_SMS_EXPECT_MORE: return "RIL_REQUEST_SEND_SMS_EXPECT_MORE";
4816 case RIL_REQUEST_SETUP_DATA_CALL: return "RIL_REQUEST_SETUP_DATA_CALL";
4817 case RIL_REQUEST_SIM_IO: return "RIL_REQUEST_SIM_IO";
4818 case RIL_REQUEST_SEND_USSD: return "RIL_REQUEST_SEND_USSD";
4819 case RIL_REQUEST_CANCEL_USSD: return "RIL_REQUEST_CANCEL_USSD";
4820 case RIL_REQUEST_GET_CLIR: return "RIL_REQUEST_GET_CLIR";
4821 case RIL_REQUEST_SET_CLIR: return "RIL_REQUEST_SET_CLIR";
4822 case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: return "RIL_REQUEST_QUERY_CALL_FORWARD_STATUS";
4823 case RIL_REQUEST_SET_CALL_FORWARD: return "RIL_REQUEST_SET_CALL_FORWARD";
4824 case RIL_REQUEST_QUERY_CALL_WAITING: return "RIL_REQUEST_QUERY_CALL_WAITING";
4825 case RIL_REQUEST_SET_CALL_WAITING: return "RIL_REQUEST_SET_CALL_WAITING";
4826 case RIL_REQUEST_SMS_ACKNOWLEDGE: return "RIL_REQUEST_SMS_ACKNOWLEDGE";
4827 case RIL_REQUEST_GET_IMEI: return "RIL_REQUEST_GET_IMEI";
4828 case RIL_REQUEST_GET_IMEISV: return "RIL_REQUEST_GET_IMEISV";
4829 case RIL_REQUEST_ANSWER: return "RIL_REQUEST_ANSWER";
4830 case RIL_REQUEST_DEACTIVATE_DATA_CALL: return "RIL_REQUEST_DEACTIVATE_DATA_CALL";
4831 case RIL_REQUEST_QUERY_FACILITY_LOCK: return "RIL_REQUEST_QUERY_FACILITY_LOCK";
4832 case RIL_REQUEST_SET_FACILITY_LOCK: return "RIL_REQUEST_SET_FACILITY_LOCK";
4833 case RIL_REQUEST_CHANGE_BARRING_PASSWORD: return "RIL_REQUEST_CHANGE_BARRING_PASSWORD";
4834 case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: return "RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE";
4835 case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: return "RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC";
4836 case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: return "RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL";
4837 case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : return "RIL_REQUEST_QUERY_AVAILABLE_NETWORKS";
4838 case RIL_REQUEST_DTMF_START: return "RIL_REQUEST_DTMF_START";
4839 case RIL_REQUEST_DTMF_STOP: return "RIL_REQUEST_DTMF_STOP";
4840 case RIL_REQUEST_BASEBAND_VERSION: return "RIL_REQUEST_BASEBAND_VERSION";
4841 case RIL_REQUEST_SEPARATE_CONNECTION: return "RIL_REQUEST_SEPARATE_CONNECTION";
4842 case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: return "RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE";
4843 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: return "RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE";
4844 case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: return "RIL_REQUEST_GET_NEIGHBORING_CELL_IDS";
4845 case RIL_REQUEST_SET_MUTE: return "RIL_REQUEST_SET_MUTE";
4846 case RIL_REQUEST_GET_MUTE: return "RIL_REQUEST_GET_MUTE";
4847 case RIL_REQUEST_QUERY_CLIP: return "RIL_REQUEST_QUERY_CLIP";
4848 case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: return "RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE";
4849 case RIL_REQUEST_DATA_CALL_LIST: return "RIL_REQUEST_DATA_CALL_LIST";
4850 case RIL_REQUEST_RESET_RADIO: return "RIL_REQUEST_RESET_RADIO";
4851 case RIL_REQUEST_OEM_HOOK_RAW: return "RIL_REQUEST_OEM_HOOK_RAW";
4852 case RIL_REQUEST_OEM_HOOK_STRINGS: return "RIL_REQUEST_OEM_HOOK_STRINGS";
4853 case RIL_REQUEST_SET_BAND_MODE: return "RIL_REQUEST_SET_BAND_MODE";
4854 case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: return "RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE";
4855 case RIL_REQUEST_STK_GET_PROFILE: return "RIL_REQUEST_STK_GET_PROFILE";
4856 case RIL_REQUEST_STK_SET_PROFILE: return "RIL_REQUEST_STK_SET_PROFILE";
4857 case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: return "RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND";
4858 case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: return "RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE";
4859 case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: return "RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM";
4860 case RIL_REQUEST_SCREEN_STATE: return "RIL_REQUEST_SCREEN_STATE";
4861 case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: return "RIL_REQUEST_EXPLICIT_CALL_TRANSFER";
4862 case RIL_REQUEST_SET_LOCATION_UPDATES: return "RIL_REQUEST_SET_LOCATION_UPDATES";
4863 case RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE:return"RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE";
4864 case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE:return"RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE";
4865 case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE:return"RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE";
4866 case RIL_REQUEST_SET_TTY_MODE:return"RIL_REQUEST_SET_TTY_MODE";
4867 case RIL_REQUEST_QUERY_TTY_MODE:return"RIL_REQUEST_QUERY_TTY_MODE";
4868 case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE:return"RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE";
4869 case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE:return"RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE";
4870 case RIL_REQUEST_CDMA_FLASH:return"RIL_REQUEST_CDMA_FLASH";
4871 case RIL_REQUEST_CDMA_BURST_DTMF:return"RIL_REQUEST_CDMA_BURST_DTMF";
4872 case RIL_REQUEST_CDMA_SEND_SMS:return"RIL_REQUEST_CDMA_SEND_SMS";
4873 case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE:return"RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE";
4874 case RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG:return"RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG";
4875 case RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG:return"RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG";
4876 case RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION:return "RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION";
4877 case RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG:return "RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG";
4878 case RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG:return "RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG";
4879 case RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION:return "RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION";
4880 case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: return"RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY";
4881 case RIL_REQUEST_CDMA_SUBSCRIPTION: return"RIL_REQUEST_CDMA_SUBSCRIPTION";
4882 case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: return "RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM";
4883 case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: return "RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM";
4884 case RIL_REQUEST_DEVICE_IDENTITY: return "RIL_REQUEST_DEVICE_IDENTITY";
4885 case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: return "RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE";
4886 case RIL_REQUEST_GET_SMSC_ADDRESS: return "RIL_REQUEST_GET_SMSC_ADDRESS";
4887 case RIL_REQUEST_SET_SMSC_ADDRESS: return "RIL_REQUEST_SET_SMSC_ADDRESS";
4888 case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: return "RIL_REQUEST_REPORT_SMS_MEMORY_STATUS";
4889 case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: return "RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING";
4890 case RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE: return "RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE";
4891 case RIL_REQUEST_ISIM_AUTHENTICATION: return "RIL_REQUEST_ISIM_AUTHENTICATION";
4892 case RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU: return "RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU";
4893 case RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS: return "RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS";
4894 case RIL_REQUEST_VOICE_RADIO_TECH: return "RIL_REQUEST_VOICE_RADIO_TECH";
4895 case RIL_REQUEST_GET_CELL_INFO_LIST: return"RIL_REQUEST_GET_CELL_INFO_LIST";
4896 case RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE: return"RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE";
4897 case RIL_REQUEST_SET_INITIAL_ATTACH_APN: return "RIL_REQUEST_SET_INITIAL_ATTACH_APN";
4898 case RIL_REQUEST_IMS_REGISTRATION_STATE: return "RIL_REQUEST_IMS_REGISTRATION_STATE";
4899 case RIL_REQUEST_IMS_SEND_SMS: return "RIL_REQUEST_IMS_SEND_SMS";
4900 case RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC: return "RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC";
4901 case RIL_REQUEST_SIM_OPEN_CHANNEL: return "RIL_REQUEST_SIM_OPEN_CHANNEL";
4902 case RIL_REQUEST_SIM_CLOSE_CHANNEL: return "RIL_REQUEST_SIM_CLOSE_CHANNEL";
4903 case RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL: return "RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL";
4904 case RIL_REQUEST_GET_RADIO_CAPABILITY: return "RIL_REQUEST_GET_RADIO_CAPABILITY";
4905 case RIL_REQUEST_SET_RADIO_CAPABILITY: return "RIL_REQUEST_SET_RADIO_CAPABILITY";
4906 case RIL_REQUEST_SET_UICC_SUBSCRIPTION: return "RIL_REQUEST_SET_UICC_SUBSCRIPTION";
4907 case RIL_REQUEST_ALLOW_DATA: return "RIL_REQUEST_ALLOW_DATA";
4908 case RIL_REQUEST_GET_HARDWARE_CONFIG: return "RIL_REQUEST_GET_HARDWARE_CONFIG";
4909 case RIL_REQUEST_SIM_AUTHENTICATION: return "RIL_REQUEST_SIM_AUTHENTICATION";
4910 case RIL_REQUEST_GET_DC_RT_INFO: return "RIL_REQUEST_GET_DC_RT_INFO";
4911 case RIL_REQUEST_SET_DC_RT_INFO_RATE: return "RIL_REQUEST_SET_DC_RT_INFO_RATE";
4912 case RIL_REQUEST_SET_DATA_PROFILE: return "RIL_REQUEST_SET_DATA_PROFILE";
4913 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return "RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED";
4914 case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return "RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED";
4915 case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: return "RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED";
4916 case RIL_UNSOL_RESPONSE_NEW_SMS: return "RIL_UNSOL_RESPONSE_NEW_SMS";
4917 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: return "RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT";
4918 case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: return "RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM";
4919 case RIL_UNSOL_ON_USSD: return "RIL_UNSOL_ON_USSD";
4920 case RIL_UNSOL_ON_USSD_REQUEST: return "RIL_UNSOL_ON_USSD_REQUEST";
4921 case RIL_UNSOL_NITZ_TIME_RECEIVED: return "RIL_UNSOL_NITZ_TIME_RECEIVED";
4922 case RIL_UNSOL_SIGNAL_STRENGTH: return "RIL_UNSOL_SIGNAL_STRENGTH";
4923 case RIL_UNSOL_STK_SESSION_END: return "RIL_UNSOL_STK_SESSION_END";
4924 case RIL_UNSOL_STK_PROACTIVE_COMMAND: return "RIL_UNSOL_STK_PROACTIVE_COMMAND";
4925 case RIL_UNSOL_STK_EVENT_NOTIFY: return "RIL_UNSOL_STK_EVENT_NOTIFY";
4926 case RIL_UNSOL_STK_CALL_SETUP: return "RIL_UNSOL_STK_CALL_SETUP";
4927 case RIL_UNSOL_SIM_SMS_STORAGE_FULL: return "RIL_UNSOL_SIM_SMS_STORAGE_FULL";
4928 case RIL_UNSOL_SIM_REFRESH: return "RIL_UNSOL_SIM_REFRESH";
4929 case RIL_UNSOL_DATA_CALL_LIST_CHANGED: return "RIL_UNSOL_DATA_CALL_LIST_CHANGED";
4930 case RIL_UNSOL_CALL_RING: return "RIL_UNSOL_CALL_RING";
4931 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: return "RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED";
4932 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: return "RIL_UNSOL_RESPONSE_CDMA_NEW_SMS";
4933 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: return "RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS";
4934 case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: return "RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL";
4935 case RIL_UNSOL_RESTRICTED_STATE_CHANGED: return "RIL_UNSOL_RESTRICTED_STATE_CHANGED";
4936 case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: return "RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE";
4937 case RIL_UNSOL_CDMA_CALL_WAITING: return "RIL_UNSOL_CDMA_CALL_WAITING";
4938 case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: return "RIL_UNSOL_CDMA_OTA_PROVISION_STATUS";
4939 case RIL_UNSOL_CDMA_INFO_REC: return "RIL_UNSOL_CDMA_INFO_REC";
4940 case RIL_UNSOL_OEM_HOOK_RAW: return "RIL_UNSOL_OEM_HOOK_RAW";
4941 case RIL_UNSOL_RINGBACK_TONE: return "RIL_UNSOL_RINGBACK_TONE";
4942 case RIL_UNSOL_RESEND_INCALL_MUTE: return "RIL_UNSOL_RESEND_INCALL_MUTE";
4943 case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: return "RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED";
4944 case RIL_UNSOL_CDMA_PRL_CHANGED: return "RIL_UNSOL_CDMA_PRL_CHANGED";
4945 case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: return "RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE";
4946 case RIL_UNSOL_RIL_CONNECTED: return "RIL_UNSOL_RIL_CONNECTED";
4947 case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED: return "RIL_UNSOL_VOICE_RADIO_TECH_CHANGED";
4948 case RIL_UNSOL_CELL_INFO_LIST: return "RIL_UNSOL_CELL_INFO_LIST";
4949 case RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED: return "RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED";
4950 case RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED: return "RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED";
4951 case RIL_UNSOL_SRVCC_STATE_NOTIFY: return "RIL_UNSOL_SRVCC_STATE_NOTIFY";
4952 case RIL_UNSOL_HARDWARE_CONFIG_CHANGED: return "RIL_UNSOL_HARDWARE_CONFIG_CHANGED";
4953 case RIL_UNSOL_DC_RT_INFO_CHANGED: return "RIL_UNSOL_DC_RT_INFO_CHANGED";
4954 case RIL_REQUEST_SHUTDOWN: return "RIL_REQUEST_SHUTDOWN";
4955 case RIL_UNSOL_RADIO_CAPABILITY: return "RIL_UNSOL_RADIO_CAPABILITY";
4956 case RIL_REQUEST_SET_TRM: return "RIL_REQUEST_SET_TRM";
4957 case RIL_REQUEST_SET_IMS_ENABLE:return "RIL_REQUEST_SET_IMS_ENABLE";
4958 case RIL_REQUEST_SET_AUDIO_PATH: return "RIL_REQUEST_SET_AUDIO_PATH";
4959 case RIL_REQUEST_HANGUP_ALL: return "RIL_REQUEST_HANGUP_ALL";
4960 case RIL_REQUEST_FORCE_RELEASE_CALL: return "RIL_REQUEST_FORCE_RELEASE_CALL";
4961 case RIL_REQUEST_EMERGENCY_DIAL: return "RIL_REQUEST_EMERGENCY_DIAL";
4962 case RIL_REQUEST_SET_ECC_SERVICE_CATEGORY: return "RIL_REQUEST_SET_ECC_SERVICE_CATEGORY";
4963 case RIL_REQUEST_SET_ECC_LIST: return "RIL_REQUEST_SET_ECC_LIST";
4964 case RIL_REQUEST_AT_COMMAND_WITH_PROXY: return "RIL_REQUEST_AT_COMMAND_WITH_PROXY";
4965 case RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION: return "RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION";
4966 case RIL_REQUEST_SET_CLIP: return "RIL_REQUEST_SET_CLIP";
4967 case RIL_REQUEST_GET_COLP: return "RIL_REQUEST_GET_COLP";
4968 case RIL_REQUEST_SET_COLP: return "RIL_REQUEST_SET_COLP";
4969 case RIL_REQUEST_GET_COLR: return "RIL_REQUEST_GET_COLR";
4970 case RIL_REQUEST_ADD_IMS_CONFERENCE_CALL_MEMBER: return "RIL_REQUEST_ADD_IMS_CONFERENCE_CALL_MEMBER";
4971 case RIL_REQUEST_REMOVE_IMS_CONFERENCE_CALL_MEMBER: return "RIL_REQUEST_REMOVE_IMS_CONFERENCE_CALL_MEMBER";
4972 case RIL_REQUEST_CONFERENCE_DIAL: return "RIL_REQUEST_CONFERENCE_DIAL";
4973 case RIL_REQUEST_DIAL_WITH_SIP_URI: return "RIL_REQUEST_DIAL_WITH_SIP_URI";
4974 case RIL_REQUEST_HOLD_CALL: return "RIL_REQUEST_HOLD_CALL";
4975 case RIL_REQUEST_RESUME_CALL: return "RIL_REQUEST_RESUME_CALL";
4976 case RIL_UNSOL_ECONF_SRVCC_INDICATION : return "RIL_UNSOL_ECONF_SRVCC_INDICATION";
4977 case RIL_UNSOL_ECONF_RESULT_INDICATION : return "RIL_UNSOL_ECONF_RESULT_INDICATION";
4978 case RIL_UNSOL_MAL_AT_INFO : return "RIL_UNSOL_MAL_AT_INFO";
4979 case RIL_REQUEST_MODEM_POWEROFF: return "RIL_REQUEST_MODEM_POWEROFF";
4980 case RIL_REQUEST_MODEM_POWERON: return "RIL_REQUEST_MODEM_POWERON";
4981 case RIL_REQUEST_WRITE_SMS_TO_SIM: return "RIL_REQUEST_WRITE_SMS_TO_SIM";
4982 case RIL_REQUEST_QUERY_ICCID: return "RIL_REQUEST_QUERY_ICCID";
4983 case RIL_UNSOL_TX_POWER: return "RIL_UNSOL_TX_POWER";
4984 case RIL_UNSOL_NETWORK_INFO: return "RIL_UNSOL_NETWORK_INFO";
4985 case RIL_REQUEST_DELETE_SMS_ON_SIM: return "RIL_REQUEST_DELETE_SMS_ON_SIM";
4986 case RIL_REQUEST_SET_IMSCFG: return "RIL_REQUEST_SET_IMSCFG";
4987#ifdef ECALL_SUPPORT
4988 case RIL_REQUEST_ECALL_FAST_MAKE_ECALL: return "RIL_REQUEST_ECALL_FAST_MAKE_ECALL";
4989 case RIL_REQUEST_ECALL_SET_IVS: return "RIL_REQUEST_ECALL_SET_IVS";
4990 case RIL_REQUEST_ECALL_SET_PSAP: return "RIL_REQUEST_ECALL_SET_PSAP";
4991 case RIL_REQUEST_ECALL_MAKE_ECALL: return "RIL_REQUEST_ECALL_MAKE_ECALL";
4992 case RIL_REQUEST_ECALL_IVS_PUSH_MSD: return "RIL_REQUEST_ECALL_IVS_PUSH_MSD";
4993 case RIL_REQUEST_ECALL_PSAP_PULL_MSD: return "RIL_REQUEST_ECALL_PSAP_PULL_MSD";
4994 case RIL_UNSOL_ECALL_MSDHACK : return "RIL_UNSOL_ECALL_MSDHACK";
4995 case RIL_REQUEST_ECALL_SET_MSD: return "RIL_REQUEST_ECALL_SET_MSD";
4996 case RIL_REQUEST_ECALL_CTRL_SEQUENCE: return "RIL_REQUEST_ECALL_CTRL_SEQUENCE";
4997 case RIL_UNSOL_ECALL_INDICATIONS : return "RIL_UNSOL_ECALL_INDICATIONS";
4998 case RIL_REQUEST_ECALL_RESET_IVS: return "RIL_REQUEST_ECALL_RESET_IVS";
4999 case RIL_REQUEST_ECALL_SET_PRI: return "RIL_REQUEST_ECALL_SET_PRI";
5000 case RIL_REQUEST_ECALL_SET_TEST_NUM: return "RIL_REQUEST_ECALL_SET_TEST_NUM";
5001 case RIL_REQUEST_ECALL_SET_RECONF_NUM: return "RIL_REQUEST_ECALL_SET_RECONF_NUM";
5002 case RIL_REQUEST_SYNC_DATA_SETTINGS_TO_MD: return "RIL_REQUEST_SYNC_DATA_SETTINGS_TO_MD";
5003 case RIL_REQUEST_ECALL_SET_NAD_DEREGISTRATION_TIME: return "RIL_REQUEST_ECALL_SET_NAD_DEREGISTRATION_TIME";
5004 case RIL_REQUEST_ECALL_SET_REGISTRATION_STATE: return "RIL_REQUEST_ECALL_SET_REGISTRATION_STATE";
5005#endif /*ECALL_SUPPORT*/
5006#ifdef KEEP_ALIVE
5007 case RIL_REQUEST_START_KEEPALIVE_PRO: return "RIL_REQUEST_START_KEEPALIVE_PRO";
5008 case RIL_REQUEST_STOP_KEEPALIVE_PRO: return "RIL_REQUEST_STOP_KEEPALIVE_PRO";
5009 case RIL_UNSOL_KEEPALIVE_STATUS_PRO: return "RIL_UNSOL_KEEPALIVE_STATUS_PRO";
5010#endif /*KEEP_ALIVE*/
5011 case RIL_REQUEST_SEND_USSI: return "RIL_REQUEST_SEND_USSI";
5012 case RIL_REQUEST_CANCEL_USSI: return "RIL_REQUEST_CANCEL_USSI";
5013 case RIL_REQUEST_GET_SMS_SIM_MEM_STATUS: return "RIL_REQUEST_GET_SMS_SIM_MEM_STATUS";
5014 case RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR: return "RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR";
5015 case RIL_REQUEST_REPORT_AIRPLANE_MODE: return "RIL_REQUEST_REPORT_AIRPLANE_MODE";
5016 case RIL_REQUEST_SET_ECC_NUM: return "RIL_REQUEST_SET_ECC_NUM";
5017 case RIL_REQUEST_GET_ECC_NUM: return "RIL_REQUEST_GET_ECC_NUM";
5018 case RIL_UNSOL_ECC_NUM: return "RIL_UNSOL_ECC_NUM";
5019 case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS_WITH_ACT: return "RIL_REQUEST_QUERY_AVAILABLE_NETWORKS_WITH_ACT";
5020 case RIL_REQUEST_GSM_GET_BROADCAST_LANGUAGE: return "RIL_REQUEST_GSM_GET_BROADCAST_LANGUAGE";
5021 case RIL_REQUEST_GSM_SET_BROADCAST_LANGUAGE: return "RIL_REQUEST_GSM_SET_BROADCAST_LANGUAGE";
5022 case RIL_UNSOL_CALL_INFO_INDICATION: return "RIL_UNSOL_CALL_INFO_INDICATION";
rjw20006d12022-04-21 16:29:04 +08005023/*Typethree add for t800 RIL Service 2022/04/14 start*/
5024//#ifdef TARGET_PLATFORM_MT2731
lh7b0674a2022-01-10 00:34:35 -08005025 case RIL_REQUEST_MODIFY_APN: return "RIL_REQUEST_MODIFY_APN";
5026 case RIL_REQUEST_RESET_APN: return "RIL_REQUEST_RESET_APN";
rjw20006d12022-04-21 16:29:04 +08005027//#endif
5028/*Typethree add for t800 RIL Service 2022/04/14 end*/
lh7b0674a2022-01-10 00:34:35 -08005029 case RIL_REQUEST_QUERY_SIM_RETRY_COUNT: return "RIL_REQUEST_QUERY_SIM_RETRY_COUNT";
5030 case RIL_REQUEST_QUERY_EID: return "RIL_REQUEST_QUERY_EID";
5031 /*LYNQ CMD*/
5032 case LYNQ_AUTO_ANSWER_CALL: return "LYNQ_AUTO_ANSWER_CALL";
5033 case LYNQ_REQUEST_SET_DTMF_VOLUME: return "RIL_REQUEST_SET_DTMF_VOLUME";
q.huangec88da92022-03-29 04:17:32 -04005034 case LYNQ_REQUEST_SET_SPEECH_VOLUME: return "RIL_REQUEST_SET_SPEECH_VOLUME";
5035 case LYNQ_REQUEST_GET_SPEECH_VOLUME: return "RIL_REQUEST_GET_SPEECH_VOLUME";
5036 case LYNQ_REQUEST_RECORD: return "RIL_REQUEST_RECORD";
lhf6eea122022-01-20 19:32:14 -08005037 case LYNQ_REQUEST_WRITE_SMS_TO_MEMORY: return "LYNQ_REQUEST_WRITE_SMS_TO_MEMORY";
5038 case LYNQ_REQUEST_READ_SMS_FROM_MEMORY: return "LYNQ_REQUEST_READ_SMS_FROM_MEMORY";
5039 case LYNQ_REQUEST_DELETE_SMS_FROM_MEMORY: return "LYNQ_REQUEST_DELETE_SMS_FROM_MEMORY";
5040 case LYNQ_REQUEST_LIST_SMS_FROM_MEMORY: return "LYNQ_REQUEST_LIST_SMS_FROM_MEMORY";
rjw5d2a50e2022-02-28 15:01:49 +08005041 case LYNQ_REQUEST_SET_DEFAULT_SIM_ALL:return "SET_DEFAULT_SIM_ALL";
lh7b0674a2022-01-10 00:34:35 -08005042 default: return "<unknown request>";
5043 }
5044}
5045
5046const char *
5047requestToString(int request) {
5048/*
5049 cat libs/telephony/ril_commands.h \
5050 | egrep "^ *{RIL_" \
5051 | sed -re 's/\{RIL_([^,]+),[^,]+,([^}]+).+/case RIL_\1: return "\1";/'
5052
5053
5054 cat libs/telephony/ril_unsol_commands.h \
5055 | egrep "^ *{RIL_" \
5056 | sed -re 's/\{RIL_([^,]+),([^}]+).+/case RIL_\1: return "\1";/'
5057
5058*/
5059 switch(request) {
5060 case RIL_REQUEST_GET_SIM_STATUS: return "GET_SIM_STATUS";
5061 case RIL_REQUEST_ENTER_SIM_PIN: return "ENTER_SIM_PIN";
5062 case RIL_REQUEST_ENTER_SIM_PUK: return "ENTER_SIM_PUK";
5063 case RIL_REQUEST_ENTER_SIM_PIN2: return "ENTER_SIM_PIN2";
5064 case RIL_REQUEST_ENTER_SIM_PUK2: return "ENTER_SIM_PUK2";
5065 case RIL_REQUEST_CHANGE_SIM_PIN: return "CHANGE_SIM_PIN";
5066 case RIL_REQUEST_CHANGE_SIM_PIN2: return "CHANGE_SIM_PIN2";
5067 case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: return "ENTER_NETWORK_DEPERSONALIZATION";
5068 case RIL_REQUEST_GET_CURRENT_CALLS: return "GET_CURRENT_CALLS";
5069 case RIL_REQUEST_DIAL: return "DIAL";
5070 case RIL_REQUEST_GET_IMSI: return "GET_IMSI";
5071 case RIL_REQUEST_HANGUP: return "HANGUP";
5072 case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: return "HANGUP_WAITING_OR_BACKGROUND";
5073 case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: return "HANGUP_FOREGROUND_RESUME_BACKGROUND";
5074 case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: return "SWITCH_WAITING_OR_HOLDING_AND_ACTIVE";
5075 case RIL_REQUEST_CONFERENCE: return "CONFERENCE";
5076 case RIL_REQUEST_UDUB: return "UDUB";
5077 case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: return "LAST_CALL_FAIL_CAUSE";
5078 case RIL_REQUEST_SIGNAL_STRENGTH: return "SIGNAL_STRENGTH";
5079 case RIL_REQUEST_VOICE_REGISTRATION_STATE: return "VOICE_REGISTRATION_STATE";
5080 case RIL_REQUEST_DATA_REGISTRATION_STATE: return "DATA_REGISTRATION_STATE";
5081 case RIL_REQUEST_OPERATOR: return "OPERATOR";
5082 case RIL_REQUEST_RADIO_POWER: return "RADIO_POWER";
5083 case RIL_REQUEST_DTMF: return "DTMF";
5084 case RIL_REQUEST_SEND_SMS: return "SEND_SMS";
5085 case RIL_REQUEST_SEND_SMS_EXPECT_MORE: return "SEND_SMS_EXPECT_MORE";
5086 case RIL_REQUEST_SETUP_DATA_CALL: return "SETUP_DATA_CALL";
5087 case RIL_REQUEST_SIM_IO: return "SIM_IO";
5088 case RIL_REQUEST_SEND_USSD: return "SEND_USSD";
5089 case RIL_REQUEST_CANCEL_USSD: return "CANCEL_USSD";
5090 case RIL_REQUEST_GET_CLIR: return "GET_CLIR";
5091 case RIL_REQUEST_SET_CLIR: return "SET_CLIR";
5092 case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: return "QUERY_CALL_FORWARD_STATUS";
5093 case RIL_REQUEST_SET_CALL_FORWARD: return "SET_CALL_FORWARD";
5094 case RIL_REQUEST_QUERY_CALL_WAITING: return "QUERY_CALL_WAITING";
5095 case RIL_REQUEST_SET_CALL_WAITING: return "SET_CALL_WAITING";
5096 case RIL_REQUEST_SMS_ACKNOWLEDGE: return "SMS_ACKNOWLEDGE";
5097 case RIL_REQUEST_GET_IMEI: return "GET_IMEI";
5098 case RIL_REQUEST_GET_IMEISV: return "GET_IMEISV";
5099 case RIL_REQUEST_ANSWER: return "ANSWER";
5100 case RIL_REQUEST_DEACTIVATE_DATA_CALL: return "DEACTIVATE_DATA_CALL";
5101 case RIL_REQUEST_QUERY_FACILITY_LOCK: return "QUERY_FACILITY_LOCK";
5102 case RIL_REQUEST_SET_FACILITY_LOCK: return "SET_FACILITY_LOCK";
5103 case RIL_REQUEST_CHANGE_BARRING_PASSWORD: return "CHANGE_BARRING_PASSWORD";
5104 case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: return "QUERY_NETWORK_SELECTION_MODE";
5105 case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: return "SET_NETWORK_SELECTION_AUTOMATIC";
5106 case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: return "SET_NETWORK_SELECTION_MANUAL";
5107 case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : return "QUERY_AVAILABLE_NETWORKS ";
5108 case RIL_REQUEST_DTMF_START: return "DTMF_START";
5109 case RIL_REQUEST_DTMF_STOP: return "DTMF_STOP";
5110 case RIL_REQUEST_BASEBAND_VERSION: return "BASEBAND_VERSION";
5111 case RIL_REQUEST_SEPARATE_CONNECTION: return "SEPARATE_CONNECTION";
5112 case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: return "SET_PREFERRED_NETWORK_TYPE";
5113 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: return "GET_PREFERRED_NETWORK_TYPE";
5114 case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: return "GET_NEIGHBORING_CELL_IDS";
5115 case RIL_REQUEST_SET_MUTE: return "SET_MUTE";
5116 case RIL_REQUEST_GET_MUTE: return "GET_MUTE";
5117 case RIL_REQUEST_QUERY_CLIP: return "QUERY_CLIP";
5118 case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: return "LAST_DATA_CALL_FAIL_CAUSE";
5119 case RIL_REQUEST_DATA_CALL_LIST: return "DATA_CALL_LIST";
5120 case RIL_REQUEST_RESET_RADIO: return "RESET_RADIO";
5121 case RIL_REQUEST_OEM_HOOK_RAW: return "OEM_HOOK_RAW";
5122 case RIL_REQUEST_OEM_HOOK_STRINGS: return "OEM_HOOK_STRINGS";
5123 case RIL_REQUEST_SET_BAND_MODE: return "SET_BAND_MODE";
5124 case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: return "QUERY_AVAILABLE_BAND_MODE";
5125 case RIL_REQUEST_STK_GET_PROFILE: return "STK_GET_PROFILE";
5126 case RIL_REQUEST_STK_SET_PROFILE: return "STK_SET_PROFILE";
5127 case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: return "STK_SEND_ENVELOPE_COMMAND";
5128 case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: return "STK_SEND_TERMINAL_RESPONSE";
5129 case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: return "STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM";
5130 case RIL_REQUEST_SCREEN_STATE: return "SCREEN_STATE";
5131 case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: return "EXPLICIT_CALL_TRANSFER";
5132 case RIL_REQUEST_SET_LOCATION_UPDATES: return "SET_LOCATION_UPDATES";
5133 case RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE:return"CDMA_SET_SUBSCRIPTION_SOURCE";
5134 case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE:return"CDMA_SET_ROAMING_PREFERENCE";
5135 case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE:return"CDMA_QUERY_ROAMING_PREFERENCE";
5136 case RIL_REQUEST_SET_TTY_MODE:return"SET_TTY_MODE";
5137 case RIL_REQUEST_QUERY_TTY_MODE:return"QUERY_TTY_MODE";
5138 case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE";
5139 case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE";
5140 case RIL_REQUEST_CDMA_FLASH:return"CDMA_FLASH";
5141 case RIL_REQUEST_CDMA_BURST_DTMF:return"CDMA_BURST_DTMF";
5142 case RIL_REQUEST_CDMA_SEND_SMS:return"CDMA_SEND_SMS";
5143 case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE:return"CDMA_SMS_ACKNOWLEDGE";
5144 case RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG:return"GSM_GET_BROADCAST_SMS_CONFIG";
5145 case RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG:return"GSM_SET_BROADCAST_SMS_CONFIG";
5146 case RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION:return "GSM_SMS_BROADCAST_ACTIVATION";
5147 case RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG:return "CDMA_GET_BROADCAST_SMS_CONFIG";
5148 case RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG:return "CDMA_SET_BROADCAST_SMS_CONFIG";
5149 case RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION:return "CDMA_SMS_BROADCAST_ACTIVATION";
5150 case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: return"CDMA_VALIDATE_AND_WRITE_AKEY";
5151 case RIL_REQUEST_CDMA_SUBSCRIPTION: return"CDMA_SUBSCRIPTION";
5152 case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: return "CDMA_WRITE_SMS_TO_RUIM";
5153 case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: return "CDMA_DELETE_SMS_ON_RUIM";
5154 case RIL_REQUEST_DEVICE_IDENTITY: return "DEVICE_IDENTITY";
5155 case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: return "EXIT_EMERGENCY_CALLBACK_MODE";
5156 case RIL_REQUEST_GET_SMSC_ADDRESS: return "GET_SMSC_ADDRESS";
5157 case RIL_REQUEST_SET_SMSC_ADDRESS: return "SET_SMSC_ADDRESS";
5158 case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: return "REPORT_SMS_MEMORY_STATUS";
5159 case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: return "REPORT_STK_SERVICE_IS_RUNNING";
5160 case RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE: return "CDMA_GET_SUBSCRIPTION_SOURCE";
5161 case RIL_REQUEST_ISIM_AUTHENTICATION: return "ISIM_AUTHENTICATION";
5162 case RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU: return "RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU";
5163 case RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS: return "RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS";
5164 case RIL_REQUEST_VOICE_RADIO_TECH: return "VOICE_RADIO_TECH";
5165 case RIL_REQUEST_GET_CELL_INFO_LIST: return"GET_CELL_INFO_LIST";
5166 case RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE: return"SET_UNSOL_CELL_INFO_LIST_RATE";
5167 case RIL_REQUEST_SET_INITIAL_ATTACH_APN: return "RIL_REQUEST_SET_INITIAL_ATTACH_APN";
5168 case RIL_REQUEST_IMS_REGISTRATION_STATE: return "IMS_REGISTRATION_STATE";
5169 case RIL_REQUEST_IMS_SEND_SMS: return "IMS_SEND_SMS";
5170 case RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC: return "SIM_TRANSMIT_APDU_BASIC";
5171 case RIL_REQUEST_SIM_OPEN_CHANNEL: return "SIM_OPEN_CHANNEL";
5172 case RIL_REQUEST_SIM_CLOSE_CHANNEL: return "SIM_CLOSE_CHANNEL";
5173 case RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL: return "SIM_TRANSMIT_APDU_CHANNEL";
5174 case RIL_REQUEST_GET_RADIO_CAPABILITY: return "RIL_REQUEST_GET_RADIO_CAPABILITY";
5175 case RIL_REQUEST_SET_RADIO_CAPABILITY: return "RIL_REQUEST_SET_RADIO_CAPABILITY";
5176 case RIL_REQUEST_SET_UICC_SUBSCRIPTION: return "SET_UICC_SUBSCRIPTION";
5177 case RIL_REQUEST_ALLOW_DATA: return "ALLOW_DATA";
5178 case RIL_REQUEST_GET_HARDWARE_CONFIG: return "GET_HARDWARE_CONFIG";
5179 case RIL_REQUEST_SIM_AUTHENTICATION: return "SIM_AUTHENTICATION";
5180 case RIL_REQUEST_GET_DC_RT_INFO: return "GET_DC_RT_INFO";
5181 case RIL_REQUEST_SET_DC_RT_INFO_RATE: return "SET_DC_RT_INFO_RATE";
5182 case RIL_REQUEST_SET_DATA_PROFILE: return "SET_DATA_PROFILE";
5183 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return "UNSOL_RESPONSE_RADIO_STATE_CHANGED";
5184 case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return "UNSOL_RESPONSE_CALL_STATE_CHANGED";
5185 case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: return "UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED";
5186 case RIL_UNSOL_RESPONSE_NEW_SMS: return "UNSOL_RESPONSE_NEW_SMS";
5187 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: return "UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT";
5188 case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: return "UNSOL_RESPONSE_NEW_SMS_ON_SIM";
5189 case RIL_UNSOL_ON_USSD: return "UNSOL_ON_USSD";
5190 case RIL_UNSOL_ON_USSD_REQUEST: return "UNSOL_ON_USSD_REQUEST(obsolete)";
5191 case RIL_UNSOL_NITZ_TIME_RECEIVED: return "UNSOL_NITZ_TIME_RECEIVED";
5192 case RIL_UNSOL_SIGNAL_STRENGTH: return "UNSOL_SIGNAL_STRENGTH";
5193 case RIL_UNSOL_STK_SESSION_END: return "UNSOL_STK_SESSION_END";
5194 case RIL_UNSOL_STK_PROACTIVE_COMMAND: return "UNSOL_STK_PROACTIVE_COMMAND";
5195 case RIL_UNSOL_STK_EVENT_NOTIFY: return "UNSOL_STK_EVENT_NOTIFY";
5196 case RIL_UNSOL_STK_CALL_SETUP: return "UNSOL_STK_CALL_SETUP";
5197 case RIL_UNSOL_SIM_SMS_STORAGE_FULL: return "UNSOL_SIM_SMS_STORAGE_FUL";
5198 case RIL_UNSOL_SIM_REFRESH: return "UNSOL_SIM_REFRESH";
5199 case RIL_UNSOL_DATA_CALL_LIST_CHANGED: return "UNSOL_DATA_CALL_LIST_CHANGED";
5200 case RIL_UNSOL_CALL_RING: return "UNSOL_CALL_RING";
5201 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: return "UNSOL_RESPONSE_SIM_STATUS_CHANGED";
5202 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: return "UNSOL_NEW_CDMA_SMS";
5203 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: return "UNSOL_NEW_BROADCAST_SMS";
5204 case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: return "UNSOL_CDMA_RUIM_SMS_STORAGE_FULL";
5205 case RIL_UNSOL_RESTRICTED_STATE_CHANGED: return "UNSOL_RESTRICTED_STATE_CHANGED";
5206 case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: return "UNSOL_ENTER_EMERGENCY_CALLBACK_MODE";
5207 case RIL_UNSOL_CDMA_CALL_WAITING: return "UNSOL_CDMA_CALL_WAITING";
5208 case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: return "UNSOL_CDMA_OTA_PROVISION_STATUS";
5209 case RIL_UNSOL_CDMA_INFO_REC: return "UNSOL_CDMA_INFO_REC";
5210 case RIL_UNSOL_OEM_HOOK_RAW: return "UNSOL_OEM_HOOK_RAW";
5211 case RIL_UNSOL_RINGBACK_TONE: return "UNSOL_RINGBACK_TONE";
5212 case RIL_UNSOL_RESEND_INCALL_MUTE: return "UNSOL_RESEND_INCALL_MUTE";
5213 case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: return "UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED";
5214 case RIL_UNSOL_CDMA_PRL_CHANGED: return "UNSOL_CDMA_PRL_CHANGED";
5215 case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: return "UNSOL_EXIT_EMERGENCY_CALLBACK_MODE";
5216 case RIL_UNSOL_RIL_CONNECTED: return "UNSOL_RIL_CONNECTED";
5217 case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED: return "UNSOL_VOICE_RADIO_TECH_CHANGED";
5218 case RIL_UNSOL_CELL_INFO_LIST: return "UNSOL_CELL_INFO_LIST";
5219 case RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED: return "RESPONSE_IMS_NETWORK_STATE_CHANGED";
5220 case RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED: return "UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED";
5221 case RIL_UNSOL_SRVCC_STATE_NOTIFY: return "UNSOL_SRVCC_STATE_NOTIFY";
5222 case RIL_UNSOL_HARDWARE_CONFIG_CHANGED: return "HARDWARE_CONFIG_CHANGED";
5223 case RIL_UNSOL_DC_RT_INFO_CHANGED: return "UNSOL_DC_RT_INFO_CHANGED";
5224 case RIL_REQUEST_SHUTDOWN: return "SHUTDOWN";
5225 case RIL_UNSOL_RADIO_CAPABILITY: return "RIL_UNSOL_RADIO_CAPABILITY";
5226 case RIL_REQUEST_SET_TRM: return "RIL_REQUEST_SET_TRM";
5227 case RIL_REQUEST_SET_IMS_ENABLE:return "RIL_REQUEST_SET_IMS_ENABLE";
5228 case RIL_REQUEST_SET_AUDIO_PATH: return "SET_AUDIO_PATH";
5229 case RIL_REQUEST_HANGUP_ALL: return "HANGUP_ALL";
5230 case RIL_REQUEST_FORCE_RELEASE_CALL: return "FORCE_RELEASE_CALL";
5231 case RIL_REQUEST_EMERGENCY_DIAL: return "RIL_REQUEST_EMERGENCY_DIAL";
5232 case RIL_REQUEST_SET_ECC_SERVICE_CATEGORY: return "RIL_REQUEST_SET_ECC_SERVICE_CATEGORY";
5233 case RIL_REQUEST_SET_ECC_LIST: return "RIL_REQUEST_SET_ECC_LIST";
5234 case RIL_REQUEST_AT_COMMAND_WITH_PROXY: return "AT_COMMAND_WITH_PROXY";
5235 case RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION: return "RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION";
5236 case RIL_REQUEST_SET_CLIP: return "RIL_REQUEST_SET_CLIP";
5237 case RIL_REQUEST_GET_COLP: return "RIL_REQUEST_GET_COLP";
5238 case RIL_REQUEST_SET_COLP: return "RIL_REQUEST_SET_COLP";
5239 case RIL_REQUEST_GET_COLR: return "RIL_REQUEST_GET_COLR";
5240 case RIL_REQUEST_ADD_IMS_CONFERENCE_CALL_MEMBER: return "ADD_IMS_CONFERENCE_CALL_MEMBER";
5241 case RIL_REQUEST_REMOVE_IMS_CONFERENCE_CALL_MEMBER: return "REMOVE_IMS_CONFERENCE_CALL_MEMBER";
5242 case RIL_REQUEST_CONFERENCE_DIAL: return "CONFERENCE_DIAL";
5243 case RIL_REQUEST_DIAL_WITH_SIP_URI: return "DIAL_WITH_SIP_URI";
5244 case RIL_REQUEST_HOLD_CALL: return "HOLD_CALL";
5245 case RIL_REQUEST_RESUME_CALL: return "RESUME_CALL";
5246 case RIL_UNSOL_ECONF_SRVCC_INDICATION : return "ECONF_SRVCC_INDICATION";
5247 case RIL_UNSOL_ECONF_RESULT_INDICATION : return "ECONF_RESULT_INDICATION";
5248 case RIL_UNSOL_MAL_AT_INFO : return "UNSOL_MAL_AT_INFO";
5249 case RIL_REQUEST_MODEM_POWEROFF: return "MODEM_POWEROFF";
5250 case RIL_REQUEST_MODEM_POWERON: return "MODEM_POWERON";
5251 case RIL_REQUEST_WRITE_SMS_TO_SIM: return "WRITE_SMS_TO_SIM";
5252 case RIL_REQUEST_QUERY_ICCID: return "RIL_REQUEST_QUERY_ICCID";
5253 case RIL_UNSOL_TX_POWER: return "RIL_UNSOL_TX_POWER";
5254 case RIL_UNSOL_NETWORK_INFO: return "RIL_UNSOL_NETWORK_INFO";
5255 case RIL_REQUEST_DELETE_SMS_ON_SIM: return "DELETE_SMS_ON_SIM";
5256 case RIL_REQUEST_SET_IMSCFG: return "RIL_REQUEST_SET_IMSCFG";
5257#ifdef ECALL_SUPPORT
5258 case RIL_REQUEST_ECALL_FAST_MAKE_ECALL: return "ECALL_FAST_MAKE_ECALL";
5259 case RIL_REQUEST_ECALL_SET_IVS: return "RIL_REQUEST_ECALL_SET_IVS";
5260 case RIL_REQUEST_ECALL_SET_PSAP: return "RIL_REQUEST_ECALL_SET_PSAP";
5261 case RIL_REQUEST_ECALL_MAKE_ECALL: return "RIL_REQUEST_ECALL_MAKE_ECALL";
5262 case RIL_REQUEST_ECALL_IVS_PUSH_MSD: return "RIL_REQUEST_ECALL_IVS_PUSH_MSD";
5263 case RIL_REQUEST_ECALL_PSAP_PULL_MSD: return "RIL_REQUEST_ECALL_PSAP_PULL_MSD";
5264 case RIL_UNSOL_ECALL_MSDHACK : return "ECALL_MSDHACK";
5265 case RIL_REQUEST_ECALL_SET_MSD: return "RIL_REQUEST_ECALL_SET_MSD";
5266 case RIL_REQUEST_ECALL_CTRL_SEQUENCE: return "ECALL_SET_CTRL_SEQUENCE";
5267 case RIL_UNSOL_ECALL_INDICATIONS : return "ECALL_INDICATIONS";
5268 case RIL_REQUEST_ECALL_RESET_IVS: return "RIL_REQUEST_ECALL_RESET_IVS";
5269 case RIL_REQUEST_ECALL_SET_PRI: return "RIL_REQUEST_ECALL_SET_PRI";
5270 case RIL_REQUEST_ECALL_SET_TEST_NUM: return "RIL_REQUEST_ECALL_SET_TEST_NUM";
5271 case RIL_REQUEST_ECALL_SET_RECONF_NUM: return "RIL_REQUEST_ECALL_SET_RECONF_NUM";
5272 case RIL_REQUEST_SYNC_DATA_SETTINGS_TO_MD: return "RIL_REQUEST_SYNC_DATA_SETTINGS_TO_MD";
5273 case RIL_REQUEST_ECALL_SET_NAD_DEREGISTRATION_TIME: return "RIL_REQUEST_ECALL_SET_NAD_DEREGISTRATION_TIME";
5274 case RIL_REQUEST_ECALL_SET_REGISTRATION_STATE: return "RIL_REQUEST_ECALL_SET_REGISTRATION_STATE";
5275#endif /*ECALL_SUPPORT*/
5276#ifdef KEEP_ALIVE
5277 case RIL_REQUEST_START_KEEPALIVE_PRO: return "RIL_REQUEST_START_KEEPALIVE_PRO";
5278 case RIL_REQUEST_STOP_KEEPALIVE_PRO: return "RIL_REQUEST_STOP_KEEPALIVE_PRO";
5279 case RIL_UNSOL_KEEPALIVE_STATUS_PRO: return "RIL_UNSOL_KEEPALIVE_STATUS_PRO";
5280#endif /*KEEP_ALIVE*/
5281 case RIL_REQUEST_SEND_USSI: return "SEND_USSI";
5282 case RIL_REQUEST_CANCEL_USSI: return "CANCEL_USSI";
5283 case RIL_REQUEST_GET_SMS_SIM_MEM_STATUS: return "GET_SMS_SIM_MEM_STATUS";
5284 case RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR: return "RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR";
5285 case RIL_REQUEST_REPORT_AIRPLANE_MODE: return "RIL_REQUEST_REPORT_AIRPLANE_MODE";
5286 case RIL_REQUEST_SET_ECC_NUM: return "RIL_REQUEST_SET_ECC_NUM";
5287 case RIL_REQUEST_GET_ECC_NUM: return "RIL_REQUEST_GET_ECC_NUM";
5288 case RIL_UNSOL_ECC_NUM: return "RIL_UNSOL_ECC_NUM";
5289 case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS_WITH_ACT: return "RIL_REQUEST_QUERY_AVAILABLE_NETWORKS_WITH_ACT";
5290 case RIL_REQUEST_GSM_GET_BROADCAST_LANGUAGE: return "RIL_REQUEST_GSM_GET_BROADCAST_LANGUAGE";
5291 case RIL_REQUEST_GSM_SET_BROADCAST_LANGUAGE: return "RIL_REQUEST_GSM_SET_BROADCAST_LANGUAGE";
5292 case RIL_UNSOL_CALL_INFO_INDICATION: return "RIL_UNSOL_CALL_INFO_INDICATION";
5293 case RIL_REQUEST_MODIFY_APN: return "RIL_REQUEST_MODIFY_APN";
5294 case RIL_REQUEST_RESET_APN: return "RIL_REQUEST_RESET_APN";
5295 case RIL_REQUEST_QUERY_SIM_RETRY_COUNT: return "RIL_REQUEST_QUERY_SIM_RETRY_COUNT";
5296 case RIL_REQUEST_QUERY_EID: return "RIL_REQUEST_QUERY_EID";
5297 case LYNQ_REQUEST_SET_DTMF_VOLUME: return "RIL_REQUEST_SET_DTMF_VOLUME";
q.huangec88da92022-03-29 04:17:32 -04005298 case LYNQ_REQUEST_SET_SPEECH_VOLUME: return "RIL_REQUEST_SET_SPEECH_VOLUME";
5299 case LYNQ_REQUEST_GET_SPEECH_VOLUME: return "RIL_REQUEST_GET_SPEECH_VOLUME";
5300 case LYNQ_REQUEST_RECORD: return "RIL_REQUEST_RECORD";
lhf6eea122022-01-20 19:32:14 -08005301 /*warren add for t800 ril service 2022/1/22 start*/
5302 case LYNQ_REQUEST_WRITE_SMS_TO_MEMORY: return "LYNQ_REQUEST_WRITE_SMS_TO_MEMORY";
5303 case LYNQ_REQUEST_READ_SMS_FROM_MEMORY: return "LYNQ_REQUEST_READ_SMS_FROM_MEMORY";
5304 case LYNQ_REQUEST_DELETE_SMS_FROM_MEMORY: return "LYNQ_REQUEST_DELETE_SMS_FROM_MEMORY";
5305 case LYNQ_REQUEST_LIST_SMS_FROM_MEMORY: return "LYNQ_REQUEST_LIST_SMS_FROM_MEMORY";
rjw5d2a50e2022-02-28 15:01:49 +08005306 case LYNQ_REQUEST_SET_DEFAULT_SIM_ALL:return "SET_DEFAULT_SIM_ALL";
lhf6eea122022-01-20 19:32:14 -08005307 /*warren add for t800 ril service 2022/1/22 end*/
lh7b0674a2022-01-10 00:34:35 -08005308 default: return "<unknown request>";
5309 }
5310}
5311
5312static int sendResponse (Parcel &p, RIL_SOCKET_ID socket_id) {
5313 printResponse;
5314 int type;
5315 if(enable_bt_resp){
5316 SendRespToClient(p.data(), p.dataSize());
5317 }
5318 p.setDataPosition(0);
5319 p.readInt32(&type);
5320 if(type == RESPONSE_UNSOLICITED){
5321 processUnsolicited(p,type);
5322 }else if (type == RESPONSE_SOLICITED){
5323 processSolicited(p,type);
5324 }
5325 return 0;
5326}
5327
5328static void speciaRequest_wait()
5329{
5330 struct timeval now;
5331 struct timespec timeout;
5332
5333 gettimeofday(&now,NULL);
5334 timeout.tv_sec = now.tv_sec+1200; //timeout is 2omin. maybe radio on/off need 10s to complete.
5335 timeout.tv_nsec = now.tv_usec*1000;
5336
5337 SPECIA_BLOCK_LOCK();
5338 while(!(requestOneByOne == 0)) {
5339 int ret = SPECIA_BLOCK_WAIT(&timeout);
5340 if(ret == ETIMEDOUT){
5341 RLOGD("special request wait timeout");
5342 break;
5343 }
5344 }
5345 requestOneByOne = 1;
5346 SPECIA_BLOCK_UNLOCK();
5347}
5348
5349static void speciaRequest_wakeup()
5350{
5351 SPECIA_BLOCK_LOCK();
5352 requestOneByOne = 0;
5353 SPECIA_BLOCK_WAKEUP();
5354 SPECIA_BLOCK_UNLOCK();
5355}
5356
5357static void updateIccCardState(RIL_SOCKET_ID soc_id)
5358{
5359 ARspRequest(RIL_REQUEST_GET_SIM_STATUS, soc_id);
5360}
5361
5362void sendRequestToMd(int request, int id) {
5363 RequestInfo* info = creatRILInfoAndInit(request, INIT, (RIL_SOCKET_ID) ((id)));
5364 switch(request){
5365 case RIL_REQUEST_DEVICE_IDENTITY:
5366 {
5367 getDeviceIdentity(1, NULL, (RIL_SOCKET_ID) ((id)), info);
5368 break;
5369 }
5370 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE:
5371 {
5372 getPreferredNetworkType(1, NULL, (RIL_SOCKET_ID) ((id)), info);
5373 break;
5374 }
5375 case RIL_REQUEST_GET_SIM_STATUS:
5376 {
5377 getIccCardStatus(1, NULL, (RIL_SOCKET_ID) (id), info);
5378 break;
5379 }
5380 case RIL_REQUEST_DATA_REGISTRATION_STATE:
5381 {
5382 getDataRegistrationState(1, NULL, (RIL_SOCKET_ID) (id), info);
5383 break;
5384 }
5385 case RIL_REQUEST_VOICE_REGISTRATION_STATE:
5386 {
5387 getVoiceRegistrationState(1, NULL, (RIL_SOCKET_ID) (id), info);
5388 break;
5389 }
5390 case RIL_REQUEST_VOICE_RADIO_TECH:
5391 {
5392 getVoiceRadioTechnology(1, NULL, (RIL_SOCKET_ID) (id), info);
5393 break;
5394 }
5395 case RIL_REQUEST_OEM_HOOK_RAW:
5396 {
5397 char* tmp[2] = {"RIL_REQUEST_OEM_HOOK_RAW", "AT+ECAL"};
5398 sendATCMD(2, tmp, (RIL_SOCKET_ID) (id), info);
5399 break;
5400 }
5401 case RIL_REQUEST_GET_RADIO_CAPABILITY:
5402 {
5403 getRadioCapability(1, NULL, (RIL_SOCKET_ID) ((id)), info);
5404 break;
5405 }
5406 default:
5407 RLOGE("don't support %d in init", id);
5408 if(info) {
5409 free(info);
5410 }
5411 }
5412}
5413
5414static void init(int id) {
5415 int waittoken;
5416 RIL_RadioState radioState = CALL_ONSTATEREQUEST((RIL_SOCKET_ID )id);
5417 while (radioState == RADIO_STATE_UNAVAILABLE) {
5418 sleep(1);
5419 radioState = CALL_ONSTATEREQUEST((RIL_SOCKET_ID )id);
5420 RLOGD("init socket id: %d, %s", id, radioStateToString(radioState));
5421 }
5422 RLOGD("init socket id: %d, %s", id, radioStateToString(radioState));
xja1c30b82022-01-25 16:13:48 +08005423 updataDataConnectState(id, false);
lh7b0674a2022-01-10 00:34:35 -08005424 sendRequestToMd(RIL_REQUEST_GET_SIM_STATUS, id);
5425
5426#if 0
5427 if (radioState != RADIO_STATE_ON) {
5428 RequestInfo* radio = creatRILInfoAndInit(RIL_REQUEST_RADIO_POWER, INIT, (RIL_SOCKET_ID) (id));
5429 waittoken = radio->token;
5430 RLOGD("[%s-%d]:token is %x", __FUNCTION__, __LINE__, radio->token);
5431 char* tmp[2] = { "RIL_REQUEST_RADIO_POWER", "1" };
5432 setRadioPower(2, tmp, (RIL_SOCKET_ID) (id), radio);
5433 waitResponse(waittoken);
5434 sleep(2);
5435 radioState = CALL_ONSTATEREQUEST((RIL_SOCKET_ID )id);
5436 RLOGD("NOW radio status %s", radioStateToString(radioState));
5437 }
5438# endif
5439 sendRequestToMd(RIL_REQUEST_DATA_REGISTRATION_STATE, id);
5440 sendRequestToMd(RIL_REQUEST_VOICE_REGISTRATION_STATE, id);
5441 sendRequestToMd(RIL_REQUEST_VOICE_RADIO_TECH, id);
5442 sendRequestToMd(RIL_REQUEST_DEVICE_IDENTITY,id);
5443 sendRequestToMd(RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE, id);
5444 sendRequestToMd(RIL_REQUEST_OEM_HOOK_RAW, id);
5445 sendRequestToMd(RIL_REQUEST_GET_RADIO_CAPABILITY,id);
5446}
5447
5448static void initCoditions()
5449{
5450 mixer_init();
5451 if(utils::is_support_dsds()) {
5452 for(int i = 0; i < 2 ; i++) {
5453 init(i);
5454 }
5455 }
5456
5457 if(utils::is_suppport_dsss()) {
5458 int id = Phone_utils::get_enable_sim_for_dsss();
5459 init(id);
5460 }
5461}
5462
5463
5464//For UDP sokcet send response to client
5465static int SendRespToClient(const void *data, size_t dataSize)
5466{
5467 const uint8_t *toWrite;
5468 size_t writeOffset = 0;
5469
5470 toWrite = (const uint8_t *)data;
5471
5472 if (toWrite == NULL) {
5473 //buf is invaild
5474 return -1;
5475 }
5476
5477 while (writeOffset < dataSize) {
5478 ssize_t written;
5479 do {
5480 //written = write (fd, toWrite + writeOffset,dataSize - writeOffset);
5481 written = sendto(server_socket_fd, toWrite + writeOffset, dataSize - writeOffset,
5482 0, (struct sockaddr *)&client_addr, sizeof(client_addr));
5483 } while (written < 0 && ((errno == EINTR) || (errno == EAGAIN)));
5484
5485 if (written >= 0) {
5486 writeOffset += written;
5487 } else { // written < 0
5488 RLOGE ("RIL Response: unexpected error on write errno:%d", errno);
5489 return -1;
5490 }
5491 }
5492
5493 return 0;
5494}
5495
5496static UnsolResponseInfo* find_mtk_unsol_command(int request)
5497{
5498 int i;
5499 for (i = 0; i < (int32_t)NUM_ELEMS(s_mtk_unsolResponses); i++)
5500 if (s_mtk_unsolResponses[i].requestNumber == request)
5501 return (&s_mtk_unsolResponses[i]);
5502 return ((UnsolResponseInfo *)NULL);
5503}
5504
5505static int
5506onSupports (int requestCode)
5507{
5508 switch(requestCode)
5509 {
5510 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return 1;
5511 case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return 1;
5512 case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: return 1;
5513 case RIL_UNSOL_RESPONSE_NEW_SMS: return 1;
5514 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: return 1;
5515 case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: return 1;
5516 case RIL_UNSOL_ON_USSD: return 1;
5517 case RIL_UNSOL_ON_USSD_REQUEST: return 1;
5518 case RIL_UNSOL_NITZ_TIME_RECEIVED: return 1;
5519 case RIL_UNSOL_SIGNAL_STRENGTH: return 1;
5520 case RIL_UNSOL_DATA_CALL_LIST_CHANGED: return 1;
5521 case RIL_UNSOL_SUPP_SVC_NOTIFICATION: return 1;
5522 case RIL_UNSOL_STK_SESSION_END: return 1;
5523 case RIL_UNSOL_STK_PROACTIVE_COMMAND: return 1;
5524 case RIL_UNSOL_STK_EVENT_NOTIFY: return 1;
5525 case RIL_UNSOL_STK_CALL_SETUP: return 1;
5526 case RIL_UNSOL_SIM_SMS_STORAGE_FULL: return 1;
5527 case RIL_UNSOL_SIM_REFRESH: return 1;
5528 case RIL_UNSOL_CALL_RING: return 1;
5529 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: return 1;
5530 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: return 1;
5531 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: return 1;
5532 case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: return 0;
5533 case RIL_UNSOL_RESTRICTED_STATE_CHANGED: return 1;
5534 case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: return 1;
5535 case RIL_UNSOL_CDMA_CALL_WAITING: return 1;
5536 case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: return 0;
5537 case RIL_UNSOL_CDMA_INFO_REC: return 0;
5538 case RIL_UNSOL_OEM_HOOK_RAW: return 1;
5539 case RIL_UNSOL_RINGBACK_TONE: return 1;
5540 case RIL_UNSOL_RESEND_INCALL_MUTE: return 0;
5541 case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: return 0;
5542 case RIL_UNSOL_CDMA_PRL_CHANGED: return 0;
5543 case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: return 1;
5544 case RIL_UNSOL_RIL_CONNECTED: return 1;
5545 case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED: return 1;
5546 case RIL_UNSOL_CELL_INFO_LIST: return 1;
5547 case RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED: return 1;
5548 case RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED: return 1;
5549 case RIL_UNSOL_SRVCC_STATE_NOTIFY: return 1;
5550 case RIL_UNSOL_HARDWARE_CONFIG_CHANGED: return 0;
5551 case RIL_UNSOL_DC_RT_INFO_CHANGED: return 0;
5552 case RIL_UNSOL_RADIO_CAPABILITY : return 1;
5553 case RIL_UNSOL_MAL_RESTART : return 1;
5554 case RIL_UNSOL_CALL_INFO_INDICATION : return 1;
5555 case RIL_UNSOL_CRSS_NOTIFICATION : return 0;
5556 case RIL_UNSOL_ECONF_SRVCC_INDICATION : return 1;
5557 case RIL_UNSOL_ECONF_RESULT_INDICATION : return 1;
5558 case RIL_UNSOL_STK_BIP_PROACTIVE_COMMAND : return 0;
5559 case RIL_UNSOL_MAL_AT_INFO: return 1;
5560 case RIL_UNSOL_ECALL_MSDHACK: return 1;
5561 case RIL_UNSOL_TX_POWER: return 1;
5562 case RIL_UNSOL_NETWORK_INFO: return 1;
5563#ifdef ECALL_SUPPORT
5564 case RIL_UNSOL_ECALL_INDICATIONS: return 1;
5565#endif /*ECALL_SUPPORT*/
5566#ifdef KEEP_ALIVE
5567 case RIL_UNSOL_KEEPALIVE_STATUS_PRO: return 1;
5568#endif /*KEEP_ALIVE*/
5569 case RIL_UNSOL_ON_USSI: return 1;
5570 case RIL_UNSOL_ECC_NUM: return 1;
5571 case RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR: return 1;
5572 default: return 0;
5573 }
5574}
5575
5576int parse_param(char *cmd, char *argv[], int max_args)
5577{
5578 char *pos, *pos2;
5579 int argc = 0;
5580 printf("warren test cmd=%s\n",cmd);
5581 pos = cmd;
5582 while (1) {
5583 // Trim the space characters.
5584 while (*pos == ' ') {
5585 pos++;
5586 }
5587
5588 if (*pos == '\0') {
5589 break;
5590 }
5591
5592 // One token may start with '"' or other characters.
5593 if (*pos == '"' && (pos2 = strrchr(pos+1, '"'))) {
5594 argv[argc++] = pos + 1;
5595 *pos2 = '\0';
5596 pos = pos2 + 1;
5597 if(*pos == '\n'){
5598 *pos = '\0';
5599 pos = pos + 1;
5600 }
5601
5602 } else {
5603 argv[argc++] = pos;
5604 while (*pos != '\0' && *pos != ' '&& *pos != '\n') {
5605 pos++;
5606 }
5607 *pos++ = '\0';
5608
5609 if(argc == 1) {
5610 char* at_cmd = strstr(argv[0], "RIL_REQUEST_OEM_HOOK_RAW");
5611 if(at_cmd != NULL) {
5612 while (*pos == ' ') {
5613 pos++;
5614 }
5615 argv[argc++] = pos;
5616 while (*pos != '\0' && *pos != '\n') {
5617 pos++;
5618 }
5619 *pos++ = '\0';
5620 break;
5621 }
5622 }
5623
5624 }
5625
5626 // Check if the maximum of arguments is reached.
5627 if (argc == max_args) {
5628 break;
5629 }
5630 }
5631
5632 return argc;
5633}
5634
5635/* Look up NAME as the name of a command, and return a pointer to that
5636 command. Return a NULL pointer if NAME isn't a command name. */
5637COMMAND* find_command (char *name)
5638{
5639 register int i;
5640
5641 for (i = 0; commands[i].name; i++)
5642 if (strcmp (name, commands[i].name) == 0)
5643 return (&commands[i]);
5644
5645 return ((COMMAND *)NULL);
5646}
5647
5648CommandInfo* find_mtk_command (int request)
5649{
5650 int i;
5651 for (i = 0; i < (int32_t)NUM_ELEMS(mtk_s_command); i++)
5652 if (mtk_s_command[i].requestNumber == request)
5653 return (&mtk_s_command[i]);
5654 return ((CommandInfo *)NULL);
5655}
5656
5657/* The user wishes to quit using this program. Just set DONE non-zero. */
5658static int com_quit (int argc, char *argv[], RIL_SOCKET_ID socket_id, RequestInfo *pRI)
5659{
5660 exit(EXIT_SUCCESS);
5661 return (0);
5662}
5663
5664static int enableSyslog(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
5665{
5666 if(argc < 2)
5667 {
5668 RLOGE("[Error] enable syslog paramter is error\n");
5669 free(pRI);
5670 return -1;
5671 }
5672 enable_syslog = atoi(argv[1]);
5673 RLOGE("%s syslog\n",enable_syslog ? "enable" :"disable");
5674 free(pRI);
5675 return 0;
5676}
5677
5678static int enableBTResponse(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
5679{
5680 if(argc < 2)
5681 {
5682 RLOGE("[Error] enable BT response paramter is error\n");
5683 free(pRI);
5684 return -1;
5685 }
5686 enable_bt_resp = atoi(argv[1]);
5687 RLOGE("%s bt response!\n",enable_bt_resp ? "enable" :"disable");
5688 free(pRI);
5689 return 0;
5690
5691}
5692
5693char Time_buf[24];
5694void GetTimeString(char * buf)
5695{
5696 time_t timep;
5697 struct tm p;
5698
5699 if(buf == NULL){
5700 RLOGE("[Error] GetTimeString: buf is Null\n");
5701 return;
5702 }
5703 //memset(buf,0,sizeof(buf));
5704 time(&timep);
5705 localtime_r(&timep,&p);
5706 sprintf(buf,"%d_%d_%d %d:%d:%d",(1900+p.tm_year),(1+p.tm_mon),p.tm_mday,
5707 (p.tm_hour),p.tm_min,p.tm_sec);
5708// printf("data is %s\n",buf);
5709
5710 return;
5711}
5712/*Warren add for t800 RIL Service 2021/12/10 start*/
5713int lynqAssemblyParcelheader(Parcel &p,int slot,int request,int respType,int error)
5714{
5715 p.writeInt32 (respType);
5716 p.writeInt32 (request);
5717 /*warren add for t800 ril servie 2021/12/15 start*/
5718 p.writeInt32(slot);
5719 /*warren add for t800 ril servie 2021/12/15 end*/
5720 p.writeInt32 (error);
5721 return 0;
5722}
5723void LYNQ_RIL_urcClientInit()
5724{
5725 int len = 0;
5726 int on=1;
5727 int ret = 0;
5728 lynq_urc_socket_fd = socket(AF_INET,SOCK_DGRAM,0);
5729 if(lynq_urc_socket_fd < 0)
5730 {
5731 perror("creaet socket for udp fail");
5732 return;
5733 }
5734 /* 设置socket允许重复使用地址与端口,SO_REUSEADDR值为2 */
5735 //setsockopt(socket_fd,SOL_SOCKET,SO_REUSEADDR,&on,sizeof on);
5736 /* 使能广播功能,SO_BROADCAST值为6 */
5737 ret= setsockopt(lynq_urc_socket_fd,SOL_SOCKET,SO_BROADCAST,&on,sizeof(on));
5738 if(ret<0)
5739 {
5740 RLOGD("set broadcast fail!!!\n");
5741 exit(1);
5742 }
5743 urc_broadcast_addr.sin_family = AF_INET; //IPv4
5744 urc_broadcast_addr.sin_port = htons(LYNQ_BRODCAST_PORT);
5745 urc_broadcast_addr.sin_addr.s_addr = inet_addr("255.255.255.255" );//255.255.255.255 broadcast addrress.
5746 printf("LYNQ_RIL_urcClientInit success!!!\n");
5747 return;
5748 /*
5749 while(1)
5750 {
5751 len = sendto(lynq_urc_socket_fd,"hello world",11,0,(struct sockaddr *)&urc_broadcast_addr,sizeof(urc_broadcast_addr));
5752 if(len > 0)
5753 {
5754 printf("sendto success,len=%d\n",len);
5755 }
5756 else
5757 {
5758 printf("sendto fail\n");
5759 }
5760 sleep(1);
5761 }
5762 */
5763}
5764void LYNQ_RIL_RecSocket()
5765{
5766 RLOGD("LYNQ_RIL_RecSocket start\n");
5767 char *argv[MAX_ARGS];
5768 int argc = 0;
5769 int ep_fd = 0;
5770 int en_fd = 0;
5771 struct epoll_event lynq_ev;
5772 struct epoll_event lynq_events[LYNQ_SOCKET_ENVNT_FD_MAX];
5773 //prctl(PR_SET_NAME,(unsigned long)"UDP_Thr");
5774
5775 /*listen UPD SOCKET port */
5776 struct sockaddr_in server_addr;
5777 struct sockaddr_in lynqClient_addr;
5778 bzero(&server_addr, sizeof(server_addr));
5779 server_addr.sin_family = AF_INET;
5780 server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
5781 server_addr.sin_port = htons(LYNQ_SERVICE_PORT);
5782 /* create socket */
5783 //int server_socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
5784 server_socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
5785 if(server_socket_fd == -1)
5786 {
5787 RLOGE("Create Socket Failed:");
5788 exit(1);
5789 }
5790
5791 /* bind socket port*/
5792 if(-1 == (bind(server_socket_fd,(struct sockaddr*)&server_addr,sizeof(server_addr))))
5793 {
5794 RLOGE("Server Bind Failed:");
5795 exit(1);
5796 }
5797 /* create epoll fd,add socket to epoll */
5798 ep_fd = epoll_create(LYNQ_SOCKET_ENVNT_FD_MAX);
5799 //int len = sizeof(struct sockaddr_in);
5800 lynq_ev.events = EPOLLIN | EPOLLET;
5801 lynq_ev.data.fd = server_socket_fd;
5802 if(epoll_ctl(ep_fd, EPOLL_CTL_ADD, server_socket_fd, &lynq_ev) < 0)
5803 {
5804 fprintf(stderr, "epoll set insertion error: fd=%d\n", server_socket_fd);
5805 return;
5806 }
5807 else
5808 {
5809 printf("monitor socket add epoll success!!!\n");
5810 }
5811 char buffer[LYNQ_SOCKET_BUFFER];
5812 lynq_client_t *client_tmp = NULL;
5813 /* tranlate data */
5814 while(true)
5815 {
5816 if(!s_registerCalled)
5817 {
5818 sleep(1);
5819 continue;
5820 }
5821 en_fd = epoll_wait(ep_fd, lynq_events, 10000, -1);//###Check valid
5822 if(en_fd <=0 )
5823 {
5824 continue;
5825 }
5826 for (int n = 0; n < en_fd; ++n)
5827 {
5828 if (lynq_events[n].data.fd == server_socket_fd)
5829 {
5830 /* define address to catch the client addreess*/
5831 //struct sockaddr_in client_addr;
5832 socklen_t client_addr_length = sizeof(lynqClient_addr);
5833 /* receive the data */
5834 bzero(buffer, LYNQ_SOCKET_BUFFER);
5835 if(recvfrom(server_socket_fd, buffer, LYNQ_SOCKET_BUFFER,0,(struct sockaddr*)&lynqClient_addr, &client_addr_length) == -1)
5836 {
5837 RLOGE("Receive Data Failed:");
5838 continue;
5839 }
5840 client_tmp = (lynq_client_t*)buffer;
5841 RLOGD("[LYNQ socketId] utoken=%d,request=%d,len=%d,param=%s",client_tmp->uToken,client_tmp->request,client_tmp->paramLen,client_tmp->param);
5842 //char test[36] = {};
5843 //sprintf(test,"test okay len = %d",client_tmp->paramLen);
5844 //sendto(server_socket_fd,test,strlen(test),0,(struct sockaddr*)&client_addr,client_addr_length);
5845 argv[0] = (char *)lynq_requset_to_string(client_tmp->request);
5846 argc = 0;
5847 if(client_tmp->paramLen > 0)
5848 {
5849 /*transfer struct*/
5850 argc = parse_param(client_tmp->param, argv+1, MAX_ARGS);
5851 if(argc < 1)
5852 {
5853 RLOGE("%s: error input.", buffer);
5854 continue;
5855 }
5856 }
5857 printf("argc =%d\n",argc);
5858 argc = argc+1;
5859 for(int t = 0;t<argc;t++)
5860 {
5861 RLOGD("warren test argv[%d]=%s\n",t,argv[t]);
5862 }
5863 COMMAND *command = find_command(argv[0]);
5864 if(!command)
5865 {
5866 RLOGE("%s: No such command for DemoApp", argv[0]);
5867 continue;
5868 }
5869 int32_t request;
5870 request = command->request;
5871 RIL_SOCKET_ID id = RIL_SOCKET_1;
5872 if(utils::is_support_dsds()) {
5873 id = (RIL_SOCKET_ID)get_default_sim_all_except_data();
5874 } else if(utils::is_suppport_dsss()) {
5875 id = (RIL_SOCKET_ID)Phone_utils::get_enable_sim_for_dsss();
5876 }
5877 if(request == -1)
5878 {
5879 (*(command->func)) (argc, argv, id, NULL);
5880 continue;
5881 }
5882 if (request < 1 || (request >= (int32_t)NUM_ELEMS(s_commands) && request < RIL_REQUEST_VENDOR_BASE)) {
5883 RLOGW("unsupported request code %d token %d", request);
5884 // FIXME this should perhaps return a response
5885 continue;
5886 }
5887 RLOGD("REQUEST: %s ParamterNum:%d", requestToString(request), argc);
5888 RequestInfo *pRI = creatRILInfoAndInit(request, UDP, (RIL_SOCKET_ID)(id));
5889 pRI->uToken = client_tmp->uToken;
ll90a255c2022-04-07 09:09:55 +00005890 pRI->lynqEvent = 2;
lh7b0674a2022-01-10 00:34:35 -08005891 pRI->uClient_addr.sin_family = lynqClient_addr.sin_family;
5892 pRI->uClient_addr.sin_addr.s_addr = lynqClient_addr.sin_addr.s_addr;
5893 pRI->uClient_addr.sin_port = lynqClient_addr.sin_port;
5894 //sendto(server_socket_fd,test,strlen(test),0,(struct sockaddr*)&pRI->uClient_addr,client_addr_length);
5895 //pRI->uClient_addr.sa_family = (struct sockaddr)client_addr.sa_family;
5896 //memcpy(pRI->uClient_addr.sa_data,&client_addr
5897 //Radio on/off only allow one thread operate.
5898 if(request == RIL_REQUEST_RADIO_POWER)
5899 {
5900 speciaRequest_wait();
5901 }
q.huang70b76492022-06-02 14:49:02 +08005902#ifdef ECALL_SUPPORT
5903 else if(request == RIL_REQUEST_ECALL_FAST_MAKE_ECALL)
5904 {
5905 init_redial_flag();
5906 }
5907#endif
lh7b0674a2022-01-10 00:34:35 -08005908 memset(Time_buf,0,sizeof(Time_buf));
5909 GetTimeString(Time_buf);
5910 //FUNCTION_CALLED(Time_buf,requestToString(request));
5911 int waittoken = pRI->token;
5912 (*(command->func)) (argc, argv, pRI->socket_id, pRI);
5913 FUNCTION_CALLED(Time_buf,requestToString(request));
5914 waitResponse(waittoken);
5915 memset(Time_buf,0,sizeof(Time_buf));
5916 GetTimeString(Time_buf);
5917 FUNCTION_RETURN(Time_buf,requestToString(request));
5918 }
5919 }
5920 }
5921 RLOGD("close socket fd");
5922 close(server_socket_fd);
5923 return ;
5924}
5925int LYNQ_RIL_respSocket(Parcel &p,RIL_Token t)
5926{
5927 RLOGD("LYNQ_RIL_respSocket send start");
lh7b0674a2022-01-10 00:34:35 -08005928 ssize_t sent = 0;
lh7b0674a2022-01-10 00:34:35 -08005929 RequestInfo *pRI = (RequestInfo *)t;
ll90a255c2022-04-07 09:09:55 +00005930 if(pRI->lynqEvent!=2)
lh7b0674a2022-01-10 00:34:35 -08005931 {
5932 RLOGD("this is internal event!!!");
5933 return -1;
5934 }
5935 int dataSize = p.dataSize();
5936 const uint8_t* data = p.data();
5937 RLOGD("lynqSocketSend RESPONSE!!!! ");
lh7b0674a2022-01-10 00:34:35 -08005938 sent = sendto(server_socket_fd, data, dataSize, 0, (struct sockaddr *)&pRI->uClient_addr, sizeof(pRI->uClient_addr));
5939 if( sent < 0 )
5940 {
5941 RLOGE("lynqSocketSend send datalen fail (sent=%d, sendFD=%d, dataSize=%d)",
5942 sent,server_socket_fd, dataSize);
lh7b0674a2022-01-10 00:34:35 -08005943 return -1;
5944 }
5945 return 0;
5946}
5947int LYNQ_RIL_respSocket_sp(Parcel &p,RequestInfo *pRI)
5948{
5949 RLOGD("LYNQ_RIL_respSocket send start");
5950 int ret =0;
5951 bool sendResult =false;
5952 ssize_t sent = 0;
5953 uint8_t dataLength[4];
5954 int verify = 0x55aa;
5955 int dataSize = p.dataSize();
5956 const uint8_t* data = p.data();
ll90a255c2022-04-07 09:09:55 +00005957 if(pRI->lynqEvent!=2)
lh7b0674a2022-01-10 00:34:35 -08005958 {
5959 RLOGD("this is internal event!!!");
5960 return -1;
5961 }
5962 RLOGD("lynqSocketSend RESPONSE!!!! ");
lh7b0674a2022-01-10 00:34:35 -08005963
5964 sent = sendto(server_socket_fd, data, dataSize, 0, (struct sockaddr *)&pRI->uClient_addr, sizeof(pRI->uClient_addr));
5965 if( sent < 0 )
5966 {
5967 RLOGE("lynqSocketSend send datalen fail (sent=%d, sendFD=%d, dataSize=%d)",
5968 sent,server_socket_fd, dataSize);
lh7b0674a2022-01-10 00:34:35 -08005969 return -1;
5970 }
5971 return 0;
5972}
5973
5974int LYNQ_RIL_urcBroadcast(Parcel &p)
5975{
5976 RLOGD("LYNQ_RIL_urcBroadcast send start");
5977 int ret =0;
5978 bool sendResult =false;
5979 ssize_t sent = 0;
5980 uint8_t dataLength[4];
5981 int verify = 0x55aa;
lhf6eea122022-01-20 19:32:14 -08005982 p.setDataPosition(0);
lh7b0674a2022-01-10 00:34:35 -08005983 int dataSize = p.dataSize();
5984 const uint8_t* data = p.data();
5985 sent = sendto(lynq_urc_socket_fd, data, dataSize, 0, (struct sockaddr *)&urc_broadcast_addr, sizeof(urc_broadcast_addr));
5986 if( sent < 0 )
5987 {
5988 RLOGE("LYNQ_RIL_urcBroadcast send datalen fail (sent=%d, sendFD=%d, dataSize=%d)",
5989 sent,lynq_urc_socket_fd, dataSize);
5990 return -1;
5991 }
5992 return 0;
5993}
5994/*Warren add for t800 RIL Service 2021/12/10 end*/
5995
5996void
5997RIL_StartRevSocket()
5998{
5999 RLOGD("RIL_StartRevSocket start\n");
xja1c30b82022-01-25 16:13:48 +08006000 char *argv[MAX_ARGS] = {0};
lh7b0674a2022-01-10 00:34:35 -08006001 int argc = 0;
6002
6003 prctl(PR_SET_NAME,(unsigned long)"UDP_Thr");
6004
6005 /*listen UPD SOCKET port */
6006 struct sockaddr_in server_addr;
6007 bzero(&server_addr, sizeof(server_addr));
6008 server_addr.sin_family = AF_INET;
6009 server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
6010 server_addr.sin_port = htons(SERVER_PORT);
6011 /* create socket */
6012 //int server_socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
6013 server_socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
6014 if(server_socket_fd == -1)
6015 {
6016 RLOGE("Create Socket Failed:");
6017 exit(1);
6018 }
6019
6020 /* bind socket port*/
6021 if(-1 == (bind(server_socket_fd,(struct sockaddr*)&server_addr,sizeof(server_addr))))
6022 {
6023 RLOGE("Server Bind Failed:");
6024 exit(1);
6025 }
6026
6027 /* tranlate data */
6028 while(true)
6029 {
6030 if(!s_registerCalled)
6031 {
6032 sleep(1);
6033 continue;
6034 }
6035 /* define address to catch the client addreess*/
6036 //struct sockaddr_in client_addr;
6037 socklen_t client_addr_length = sizeof(client_addr);
6038
6039 /* receive the data */
6040 char buffer[BUFFER_SIZE];
6041 bzero(buffer, BUFFER_SIZE);
6042 if(recvfrom(server_socket_fd, buffer, BUFFER_SIZE,0,(struct sockaddr*)&client_addr, &client_addr_length) == -1)
6043 {
6044 RLOGE("Receive Data Failed:");
6045 continue;
6046 }
6047 RLOGD("DemoAPP:%s, receve: %s", inet_ntoa(client_addr.sin_addr), buffer);
6048 if(mtkItTest(buffer)) {
6049 RLOGD("mtkItTest() handle.");
6050 continue;
6051 }
6052 int argc = parse_param(buffer, argv, MAX_ARGS);
6053 if(argc < 1)
6054 {
6055 RLOGE("%s: error input.", buffer);
6056 continue;
6057 }
6058 COMMAND *command = find_command(argv[0]);
6059 if(!command)
6060 {
6061 RLOGE("%s: No such command for DemoApp", argv[0]);
6062 continue;
6063 }
6064
6065 int32_t request;
6066
6067 request = command->request;
6068
6069 RIL_SOCKET_ID id = RIL_SOCKET_1;
6070 if(utils::is_support_dsds()) {
6071 id = (RIL_SOCKET_ID)get_default_sim_all_except_data();
6072 } else if(utils::is_suppport_dsss()) {
6073 id = (RIL_SOCKET_ID)Phone_utils::get_enable_sim_for_dsss();
6074 }
6075
6076 if(request == -1)
6077 {
6078 (*(command->func)) (argc, argv, id, NULL);
6079 continue;
6080 }
6081
6082 if (request < 1 || (request >= (int32_t)NUM_ELEMS(s_commands) && request < RIL_REQUEST_VENDOR_BASE)) {
6083 RLOGW("unsupported request code %d token %d", request);
6084 // FIXME this should perhaps return a response
6085 continue;
6086 }
6087
6088 RLOGD("REQUEST: %s ParamterNum:%d", requestToString(request), argc);
6089
6090
6091 RequestInfo *pRI = creatRILInfoAndInit(request, UDP, (RIL_SOCKET_ID)(id));
6092 //Radio on/off only allow one thread operate.
6093 if(request == RIL_REQUEST_RADIO_POWER)
6094 {
6095 speciaRequest_wait();
6096 }
6097 memset(Time_buf,0,sizeof(Time_buf));
6098 GetTimeString(Time_buf);
6099 //FUNCTION_CALLED(Time_buf,requestToString(request));
6100 int waittoken = pRI->token;
6101 (*(command->func)) (argc, argv, pRI->socket_id, pRI);
6102 FUNCTION_CALLED(Time_buf,requestToString(request));
6103 waitResponse(waittoken);
6104 memset(Time_buf,0,sizeof(Time_buf));
6105 GetTimeString(Time_buf);
6106 FUNCTION_RETURN(Time_buf,requestToString(request));
6107 }
6108
6109 RLOGD("close socket fd");
6110 close(server_socket_fd);
6111 return ;
6112}
6113
6114const int waitResponse(int token)
6115{
6116 int waitToken = token;
6117 struct timeval now;
6118 struct timespec timeout;
6119 if((token&BLOCK_MARK) != BLOCK_MARK){
6120 RLOGD("No need wait!,token is %x!",token);
6121 return 0;
6122 }
6123
6124 gettimeofday(&now,NULL);
6125 timeout.tv_sec = now.tv_sec+60; //timeout is 1min
6126 timeout.tv_nsec = now.tv_usec*1000;
6127
6128 RLOGD("Block Request, wait token is %x,",waitToken);
6129 BLOCK_LOCK();
6130 if(waitToken == wakeup_token)
6131 RLOGD("response early than return, wait token is %x, wakeup token is %x",waitToken, wakeup_token);
6132 while(!(waitToken == wakeup_token)) {
6133 RLOGD("Wait Response, wait token is %x, wakeup token is %x",waitToken, wakeup_token);
6134 int ret = BLOCK_WAIT(&timeout);
6135 if(ret == ETIMEDOUT){
6136 RLOGD("Wait Response timeout, wait token is %x, wakeup token is %x",waitToken, wakeup_token);
6137 goto out;
6138 }
6139 }
6140 RLOGD("Response wakeup,token is %x!",wakeup_token);
6141 wakeup_token = -1;
6142out:
6143 BLOCK_UNLOCK();
6144 return 0;
6145}
6146
lld164b022022-03-29 14:01:01 +08006147/**
6148 * @brief check at input in at_buffer
6149 * @param buf type:in at port input
6150 * @return int
6151 */
6152static int lynq_inside_at_buffer(char *buf)
6153{
6154 for(int i = 0; i < MAX_AT_CMD; i++)
6155 {
6156 if(at_buf_ext[i] == NULL)
6157 {
6158 break;
6159 }
6160 else
6161 {
llf4be54d2022-04-18 08:08:38 +00006162 if(strstr(buf, at_buf_ext[i]))
lld164b022022-03-29 14:01:01 +08006163 {
6164 return 1;
6165 }
6166 }
6167 }
6168 return 0;
6169}
6170
6171/**
6172 * @brief send input to client
6173 * @param buffer type:in buffer from at port
6174 * @param len_buf type:in strlen(buffer)
6175 * @param client type:in sockaddr client
6176 * @return int
6177 */
6178static int lynq_send_info(char *buffer, int len_buf, struct sockaddr* client)
6179{
6180 socklen_t len = sizeof(*client);
6181 int sent = sendto(sockfd,buffer,len_buf,0,client,len);
6182 if( sent < 0 )
6183 {
6184 RLOGE("lynq_send_info send fail (sent=%d, sendFD=%d, dataSize=%d)",
6185 sent,sockfd, len);
6186 return sent;
6187 }
6188 return 0;
6189}
6190
6191/**
6192 * @brief Fetch data from a one-dimensional array into a two-dimensional array
6193 *
6194 * @param cmd type:in buffer from client
6195 * @param argv type:in two-dimensional array
6196 * @param cnt type:in Two dimensional array subscript
6197 * @return int
6198 */
6199static int lynq_parse_at_cmd(char *cmd, char *argv[], int cnt)
6200{
6201 if(NULL == cmd || NULL == argv)
6202 {
6203 return -1;
6204 }
6205 if(cnt > MAX_AT_CMD)
6206 {
6207 return -1;
6208 }
6209 const char s[2] = ";";
6210 char *token;
6211 int argc = cnt;
6212 token = strtok(cmd, s);
6213 while( token != NULL ) {
6214 argv[argc++] = token;
6215 token = strtok(NULL, s);
6216 }
6217 return 0;
6218}
6219
6220/**
6221 * @brief count at cmd amount
6222 *
6223 * @param type:in buffer
6224 * @return int
6225 */
6226static int lynq_count_at(char *buffer)
6227{
6228 char *p = buffer;
6229 int count = 0;
6230 while(*p != '\0')
6231 {
6232 if(*p == ';')
6233 {
6234 count++;
6235 }
6236 *p++;
6237 }
6238 return count+1;
6239}
6240
6241/**
6242 * @brief receive registion and display on at port
6243 * @param parm type:in
6244 * @return void*
6245 */
6246void *receive_at(void *parm)
6247{
6248 RLOGE("receive_at thread start\n");
6249 struct sockaddr* cli = (struct sockaddr*)parm;
6250 socklen_t len;
6251 int recv = 0;
6252 char display[1024] = {0};
6253 /*For at extension to receive at buffer*/
llacba3662022-04-15 16:57:13 +08006254 bool flag = false;
lld164b022022-03-29 14:01:01 +08006255 int count_at_cmd = 0;
6256 len = sizeof(*cli);
6257 while(1)
6258 {
llacba3662022-04-15 16:57:13 +08006259 if(!flag)
lld164b022022-03-29 14:01:01 +08006260 {
6261 RLOGE("receive third at cmd\n");
6262 recv = recvfrom(sockfd, buffer_at, LYNQ_AT_SOCKET_BUFFER, 0, cli, &len);
6263 if(recv < 0)
6264 {
6265 RLOGE("recv fail\n");
6266 continue;
6267 }
6268 RLOGE("recvfrom from client\n");
6269 /*parse buffer for at command*/
6270 count_at_cmd = lynq_count_at(buffer_at);
6271 if(count_at_cmd > MAX_AT_CMD)
6272 {
6273 RLOGE("too many at cmd\n");
6274 continue;;
6275 }
6276 lynq_parse_at_cmd(buffer_at, at_buf_ext, 0);
llacba3662022-04-15 16:57:13 +08006277 flag = true;
lld164b022022-03-29 14:01:01 +08006278 }
6279 else
6280 {
6281 RLOGE("display output on at port\n");
6282 bzero(display, 1024);
6283 recv = recvfrom(sockfd, display, LYNQ_AT_SOCKET_BUFFER, 0, cli, &len);
6284 if(recv < 0)
6285 {
6286 RLOGE("recv fail\n");
6287 continue;
6288 }
6289 /*display on at port*/
6290 else
6291 {
6292 strcat(display, "\n");
6293 int n = write(ttyGS3_fd,display,strlen(display));
6294 if(n<0)
6295 {
6296 RLOGE("lynq resp write error");
6297 }
6298 }
6299 }
lld164b022022-03-29 14:01:01 +08006300 }
6301 return NULL;
6302}
6303
llaaca09b2022-03-14 16:14:28 +08006304void startUsbLoop(void)
6305{
lld164b022022-03-29 14:01:01 +08006306 /*lei add*/
6307 //Create a network communication object
6308 struct sockaddr_in addr_serv;
6309 struct sockaddr_in addr_clie;
6310 //Creating a Socket object
6311 sockfd=socket(AF_INET,SOCK_DGRAM,0);
6312 memset(&addr_serv, 0, sizeof(addr_serv));
6313 addr_serv.sin_family =AF_INET;
6314 addr_serv.sin_port =htons(LYNQ_AT_SERVICE_PORT);
6315 addr_serv.sin_addr.s_addr=htonl(INADDR_ANY);
6316 bind(sockfd,(struct sockaddr*)&addr_serv,sizeof(addr_serv));
6317 //receive registion and display on at port
6318 pthread_t thid;
6319 if(pthread_create(&thid, NULL, receive_at, (struct sockaddr*)&addr_clie) != 0) {
6320 RLOGE("thread creation failed\n");
6321 exit(1);
6322 }
6323 RLOGE("thread creation\n");
6324 /*lei add*/
llaaca09b2022-03-14 16:14:28 +08006325 int nread=-1;
6326 int n = -1;
6327 int routeId = -1;
6328 char buffer[1024]={};
6329 char tempbuf[1024]={};
6330 char buf_parser[64] = {};
6331 int argc = 0;
6332 char *argv[MAX_ARGS];//argv[0]:at name,argv[1]:raw data,argv[2]:at type,argv[3]:paramter1,argv[4]:paramter2 ....
6333 char eBuf[1024];
6334 ttyGS3_fd = open("/dev/ttyGS3",O_RDWR);
6335 if(ttyGS3_fd==-1)
6336 {
6337 RLOGE("open ttyGS3 failure!!!");
6338 printf("open ttyGS3 failure!!!\n");
6339 //printf("%s\n",strerr(errno));
6340 perror("--test--");
6341 kill(0, SIGKILL);
6342 }
lld164b022022-03-29 14:01:01 +08006343 RLOGD("[%s]open %s successfully!!!\n",__FUNCTION__,ttyname(ttyGS3_fd));
llaaca09b2022-03-14 16:14:28 +08006344 while(1)
6345 {
6346 bzero(buffer, 1024);
6347 bzero(tempbuf, 1024);
6348 bzero(buf_parser, 64);
6349 if((nread=read(ttyGS3_fd,buffer,1024))>0)
6350 {
6351 if(nread<2)
6352 {
6353 //RLOGD("input is space!!!");
6354 continue;
6355 }
6356 buffer[nread-1] = '\0';
6357 //printf("buffer is %s\n",buffer);
6358 for(int i = 0 ; i < nread ; i++)
6359 {
6360 if(buffer[i]=='=')
6361 {
6362 break;
6363 }
6364 if(buffer[i]>='a'&&buffer[i]<='z')
6365 {
6366 buffer[i] = buffer[i]-32;
6367 }
6368 }
lld164b022022-03-29 14:01:01 +08006369 RLOGD("buffer is %s\n",buffer);
6370 /*lei add*/
6371 /*check third cmd in buffer*/
6372 if(lynq_inside_at_buffer(buffer))
llaaca09b2022-03-14 16:14:28 +08006373 {
lld164b022022-03-29 14:01:01 +08006374 lynq_send_info(buffer, nread, (struct sockaddr*)&addr_clie);
llaaca09b2022-03-14 16:14:28 +08006375 }
lld164b022022-03-29 14:01:01 +08006376 /*lei add*/
6377 else
llaaca09b2022-03-14 16:14:28 +08006378 {
lld164b022022-03-29 14:01:01 +08006379 argc = lynqParseUsbCommand(buffer,argv,tempbuf,buf_parser,MAX_ARGS);
6380 if(argc<0)
6381 {
6382 bzero(eBuf, 1024);
6383 sprintf(eBuf,"LYNQ:%s not support!!!\n",buffer);
6384 int n = write(ttyGS3_fd,eBuf,strlen(eBuf));
llaaca09b2022-03-14 16:14:28 +08006385 if(n<0)
6386 {
6387 perror("lynq resp write:");
6388 }
lld164b022022-03-29 14:01:01 +08006389 RLOGD("n = %d\n",n);
llaaca09b2022-03-14 16:14:28 +08006390 continue;
lld164b022022-03-29 14:01:01 +08006391 }
6392 usb_at_transfer_t *atCmd = lynqFindId(argv[0]);
6393 if(atCmd==NULL)
llaaca09b2022-03-14 16:14:28 +08006394 {
lld164b022022-03-29 14:01:01 +08006395 RLOGD("LYNQ send ATCMD:%s!!!",argv[1]);
llaaca09b2022-03-14 16:14:28 +08006396 lynqSendAt(argc,argv,1010);
lld164b022022-03-29 14:01:01 +08006397 continue;
llaaca09b2022-03-14 16:14:28 +08006398 }
lld164b022022-03-29 14:01:01 +08006399 if(!((1<<atoi(argv[2])) & (atCmd->support)))
llaaca09b2022-03-14 16:14:28 +08006400 {
lld164b022022-03-29 14:01:01 +08006401 RLOGD("LYNQ %s not support!!!",atCmd->cmdName);
6402 int n = write(ttyGS3_fd,"\n+CME ERROR: 100\n",strlen("\n+CME ERROR: 100\n"));
6403 if(n<0)
llaaca09b2022-03-14 16:14:28 +08006404 {
lld164b022022-03-29 14:01:01 +08006405 perror("lynq resp write:");
llaaca09b2022-03-14 16:14:28 +08006406 }
lld164b022022-03-29 14:01:01 +08006407 continue;
llaaca09b2022-03-14 16:14:28 +08006408 }
lld164b022022-03-29 14:01:01 +08006409 routeId = routeCmd(atCmd->cmdId);
6410 //routeId = routeCmd(atcmd->cmdId);
6411 //routeId = LYNQ_GOTO_AT;
6412 switch(routeId)
llaaca09b2022-03-14 16:14:28 +08006413 {
lld164b022022-03-29 14:01:01 +08006414 case LYNQ_GOTO_AT:
llaaca09b2022-03-14 16:14:28 +08006415 {
lld164b022022-03-29 14:01:01 +08006416 lynqSendAt(argc,argv,1010);
6417 break;
llaaca09b2022-03-14 16:14:28 +08006418 }
lld164b022022-03-29 14:01:01 +08006419 case LYNQ_GOTO_TELE_REQ:
6420 {
6421 usb_cmd_t *atCmdEvn = lynqFindUsbEvent(argv[0]);
6422 if(!atCmdEvn)
6423 {
6424 RLOGD("can not find at cmd event!!!");
6425 continue;
6426 }
6427 atCmdEvn->fun(argc,argv,atCmdEvn->rilRequest,1011);
6428 break;
6429 }
6430 case LYNQ_GOTO_USER_REQ:
6431 {
6432 usb_cmd_t *atCmdEvn = lynqFindUsbEvent(argv[0]);
6433 if(!atCmdEvn)
6434 {
6435 RLOGD("can not find at cmd event!!!");
6436 continue;
6437 }
6438 atCmdEvn->ufun(argc,argv,1012);
6439 break;
6440 }
6441 case LYNQ_GOTO_LINFO_REQ:
6442 {
6443 lynqInfo(argv);
6444 break;
6445 }
6446 // case LYNQ_GOTO_PLAT_REQ:
6447 // {
6448 // lynq_deal_with_log_at(&argv[3]);
6449 // break;
6450 // }
6451 case LYNQ_GOTO_RNDIS_REQ:
6452 {
6453 lynq_get_rndis_data(buffer);
6454 break;
6455 }
6456 case LYNQ_GOTO_FACTORY:
6457 {
6458 lynq_get_factory_data(argc,argv);
6459 break;
6460 }
6461 // case LYNQ_GOTO_FOTA:
6462 // {
6463 // lynq_atfota_test(argv);
6464 // break;
6465 // }
6466 default:
6467 break;
llaaca09b2022-03-14 16:14:28 +08006468 }
llaaca09b2022-03-14 16:14:28 +08006469 }
lld164b022022-03-29 14:01:01 +08006470
llaaca09b2022-03-14 16:14:28 +08006471 }
6472 }
6473 close(ttyGS3_fd);
6474 return;
6475}
6476
lh7b0674a2022-01-10 00:34:35 -08006477void *
6478eventLoop(void *param) {
6479 pthread_mutex_lock(&s_startupMutex);
6480 s_started = 1;
6481 pthread_cond_broadcast(&s_startupCond);
6482 pthread_mutex_unlock(&s_startupMutex);
6483 #ifdef ECALL_SUPPORT
6484 init_ecall_timer_all();
6485 #endif /**/ECALL_SUPPORT
6486 /*warren add for t800 ril service 2021/12/13 start*/
6487 //RIL_StartRevSocket();
6488 LYNQ_RIL_urcClientInit();
6489 LYNQ_RIL_RecSocket();
6490 /*warren add for t800 ril service 2021/12/13 end*/
6491 RLOGD("error in event_loop_base errno:%d", errno);
6492 // kill self to restart on error
6493 kill(0, SIGKILL);
6494
6495 return NULL;
6496}
6497
llaaca09b2022-03-14 16:14:28 +08006498
6499void *
6500eventLoop_at(void *param) {
6501 pthread_mutex_lock(&s_startupMutex);
6502 s_started = 1;
6503 pthread_cond_broadcast(&s_startupCond);
6504 pthread_mutex_unlock(&s_startupMutex);
6505 //RIL_StartRevSocket();
6506 startUsbLoop();
6507 //startUsbLoop_test();
6508 RLOGD("error in event_loop_base errno:%d", errno);
6509 // kill self to restart on error
6510 kill(0, SIGKILL);
6511
6512 return NULL;
6513}
6514
lld164b022022-03-29 14:01:01 +08006515
6516
lh7b0674a2022-01-10 00:34:35 -08006517const int RspDispFunction(int request,char* arg, RIL_SOCKET_ID socket_id)
6518{
6519 int waittoken;
6520 RequestInfo *pRI = creatRILInfoAndInit(request, RSPD, socket_id);
6521 if(pRI == NULL)
6522 return 0;
6523 waittoken = pRI->token;
6524 switch (request) {
6525 case RIL_REQUEST_GET_CURRENT_CALLS:
6526 {
6527 RLOGD("request Current list start!");
6528 Parcel p;
6529 pRI->pCI->dispatchFunction(p, pRI);
6530 waitResponse(waittoken);
6531 RLOGD("request Current list end!");
6532 }
6533 break;
6534
6535 case RIL_REQUEST_ANSWER:
6536 {
6537 RLOGD("request Answer a MT call start!");
6538 Parcel p;
6539 pRI->pCI->dispatchFunction(p, pRI);
6540 waitResponse(waittoken);
6541 RLOGD("request Answer a MT call end!");
6542 }
6543 break;
6544
6545 case RIL_REQUEST_GET_SIM_STATUS:
6546 {
6547 int ret=getIccCardStatus(1, NULL, socket_id, pRI);
6548 if(ret == 0)
6549 waitResponse(waittoken);
6550 }
6551 break;
6552
6553 case RIL_REQUEST_DATA_REGISTRATION_STATE:
6554 {
6555 int ret=getDataRegistrationState(1, NULL, socket_id,pRI);
6556 if(ret == 0)
6557 waitResponse(waittoken);
6558 }
6559 break;
6560
6561 case RIL_REQUEST_VOICE_REGISTRATION_STATE:
6562 {
6563 int ret=getVoiceRegistrationState(1, NULL, socket_id,pRI);
6564 if(ret == 0)
6565 waitResponse(waittoken);
6566 }
6567 break;
6568 case RIL_REQUEST_SMS_ACKNOWLEDGE:
6569 {
6570 char* tmp[3] = {"RIL_REQUEST_SMS_ACKNOWLEDGE", "1", "0"};
6571 acknowledgeIncomingGsmSmsWithPdu(3,tmp,socket_id,pRI);
6572 waitResponse(waittoken);
6573 RLOGD("acknowledge last Incoming Gsm Sms : RIL_REQUEST_SMS_ACKNOWLEDGE end!");
6574 }
6575 break;
6576 case RIL_REQUEST_OEM_HOOK_RAW:
6577 {
6578 if(arg != NULL)
6579 {
6580 RLOGD("request OEM HOOK RAW start!");
6581 pRI->token = pRI->token|BLOCK_MARK;
6582 int waittokenOEM = pRI->token;
6583 Parcel p;
6584
6585 size_t pos = p.dataPosition();
6586 int len = strlen(arg);
6587 p.writeInt32(len);
6588 p.write((const void*)arg,len);
6589
6590 p.setDataPosition(pos);
6591 RLOGD("emSendATCommand: %s %d\n",arg,strlen(arg));
6592 pRI->pCI->dispatchFunction(p, pRI);
6593 waitResponse(waittokenOEM);
6594 } else {
6595 if(pRI){
6596 free(pRI);
6597 }
6598 RLOGE("at command shouldn't null");
6599 }
6600 break;
6601 }
6602 case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM:
6603 {
6604 char* tmp[2] = {"RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM", "no"};
6605 handleCallSetupRequestFromSim(2, tmp, socket_id,pRI);
6606 waitResponse(waittoken);
6607 RLOGD("timeout 1 minutes, response no by RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM");
6608 break;
6609 }
6610 case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE:
6611 {
6612 char* tmp[2] ={"RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE", arg};
6613 RLOGD("tmp[0]=%s, tmp[1]=%s, arg=%s", tmp[0], tmp[1], arg);
6614 sendTerminalResponse(2, tmp, socket_id, pRI);
6615 waitResponse(waittoken);
6616 break;
6617 }
6618 case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE:
6619 {
6620 acknowledgeLastIncomingCdmaSms(1, NULL,socket_id,pRI);
6621 waitResponse(waittoken);
6622 break;
6623 }
6624 case RIL_REQUEST_RADIO_POWER:
6625 {
6626 RLOGD("response loop, RIL_REQUEST_RADIO_POWER: %s", (arg == NULL ? "nul": arg));
6627 if(arg != NULL) {
6628 char* tmp[2] = {"RIL_REQUEST_RADIO_POWER", arg};
6629 setRadioPower(2,tmp,socket_id,pRI);
6630 waitResponse(waittoken);
6631 } else {
6632 if(pRI){
6633 free(pRI);
6634 }
6635 RLOGE("response loop, RIL_REQUEST_RADIO_POWER fail");
6636 }
6637 break;
6638 }
6639 case RIL_REQUEST_ALLOW_DATA:
6640 {
6641 int default_id = get_default_sim_data();
6642 RLOGD("RspDispFunction: socket_id=%d switch_id=%d", socket_id, default_id);
6643 char* argv[2] = {"RIL_REQUEST_ALLOW_DATA","0"};
6644 if(socket_id == default_id) {
6645 utils::mtk_property_set(PROP_DEFAULT_DATA_SIM, std::to_string(socket_id + 1).c_str());
6646 argv[1] = "1";
6647 }
6648 while(!isRadioAvailable(socket_id)) {
6649 sleep(1);
6650 RLOGD("[SIM%d]RspDispFunction(RIL_REQUEST_ALLOW_DATA): wait radio available", socket_id);
6651 }
6652 setDataAllowed(2, argv, socket_id, pRI);
6653 waitResponse(waittoken);
6654 break;
6655 }
6656 case RIL_REQUEST_CDMA_FLASH:
6657 {
6658 sendCDMAFeatureCode(1, NULL, socket_id, pRI);
6659 waitResponse(waittoken);
6660 break;
6661 }
6662 default:
xja1c30b82022-01-25 16:13:48 +08006663 if(pRI) {
6664 free(pRI);
6665 pRI = NULL;
6666 }
lh7b0674a2022-01-10 00:34:35 -08006667 break;
6668 }
6669 return 0;
6670}
6671
6672void * responseLoop(void *param) {
6673 pthread_mutex_lock(&s_startupMutex);
6674 s_responseDispatch= 1;
6675 pthread_cond_broadcast(&s_startupCond);
6676 pthread_mutex_unlock(&s_startupMutex);
6677 responseDispatch();
6678 RLOGD("error in response_loop_base errno:%d", errno);
6679 // kill self to restart on error
6680 kill(0, SIGKILL);
6681
6682 return NULL;
6683}
6684
6685void ATCIRequest(int request,char* reqString, void* t,int argc,char**argv)
6686{
xja1c30b82022-01-25 16:13:48 +08006687 if(t == NULL) {
6688 RLOGE("ATCIRequest t is null");
6689 return;
6690 }
lh7b0674a2022-01-10 00:34:35 -08006691 RequestInfo *pRI = (RequestInfo *)t;
6692 int waittoken;
6693 if (request < RIL_REQUEST_VENDOR_BASE) {
6694 pRI->pCI = &(s_commands[request]);
6695 } else {
6696 pRI->pCI = find_mtk_command(request);
6697 }
xja1c30b82022-01-25 16:13:48 +08006698 if(pRI->pCI == NULL){
lh7b0674a2022-01-10 00:34:35 -08006699 RLOGE("pCI command not found!");
xja1c30b82022-01-25 16:13:48 +08006700 if(pRI) {
6701 free(pRI);
6702 }
6703 return;
6704 }
lh7b0674a2022-01-10 00:34:35 -08006705
6706 if(utils::is_suppport_dsss()){
6707 pRI->socket_id = (RIL_SOCKET_ID)Phone_utils::get_enable_sim_for_dsss();
6708 }
6709
6710 if(utils::is_support_dsds() && (request != RIL_REQUEST_RADIO_POWER)){
6711 pRI->socket_id = (RIL_SOCKET_ID)get_atci_sim();
6712 }
6713
6714 pRI->p_next = NULL;
6715
6716 COMMAND *command = find_command(reqString);
6717
6718 if(command == NULL) {
6719 RLOGE("ATCI request command find error!");
xja1c30b82022-01-25 16:13:48 +08006720 if(pRI) {
6721 free(pRI);
6722 }
6723 return;
lh7b0674a2022-01-10 00:34:35 -08006724 } else {
6725 RLOGE("ATCI request name is %s!",command->name);
6726 }
6727
6728 pRI->token = GenerateToken(ATCI, request);
6729 waittoken = pRI->token;
6730 if(request == RIL_REQUEST_RADIO_POWER) {
6731 speciaRequest_wait();
6732 }
6733 (*(command->func)) (argc, argv, pRI->socket_id, pRI);
6734 //need wait Ril_onRequestComplete return.
6735 waitResponse(waittoken);
6736 return;
6737}
6738
6739void startWakupLoop(void)
6740{
6741 pthread_t WakeupReasonThread;
6742
6743 RLOGD("startWakupLoop()");
6744 pthread_mutex_lock(&s_startupMutex);
6745
6746 pthread_attr_t attr;
6747 pthread_attr_init(&attr);
6748 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
6749
6750 int result = pthread_create(&WakeupReasonThread, &attr, wakeup_reason_loop, NULL);
6751 if (result != 0) {
6752 RLOGW("Failed to create wakeup reason thread: %s", strerror(result));
6753 goto done;
6754 }
6755
6756done:
6757 pthread_mutex_unlock(&s_startupMutex);
6758}
llaaca09b2022-03-14 16:14:28 +08006759/*Warren add for FAW 2021/09/23 start
6760** use ttyGS0 port
6761*/
6762int lynqSendToRil(int argc,char *argv[],int uToken)
6763{
6764 if(argc < 1)
6765 {
6766 RLOGE("lynqSendToRil error input.");
6767 return 1;
6768 }
6769 for(int i =0;i<argc;i++)
6770 {
6771 printf("argv[%d]=%s\n",i,argv[i]);
6772 }
6773 COMMAND *command = find_command(argv[0]);
6774 if(!command)
6775 {
6776 RLOGE("%s: No such command for DemoApp", argv[0]);
6777 return 1;
6778 }
6779
6780 int32_t request;
6781
6782 request = command->request;
6783
6784 RIL_SOCKET_ID id = RIL_SOCKET_1;
6785 if(utils::is_support_dsds()) {
6786 id = (RIL_SOCKET_ID)get_default_sim_all_except_data();
6787 } else if(utils::is_suppport_dsss()) {
6788 id = (RIL_SOCKET_ID)Phone_utils::get_enable_sim_for_dsss();
6789 }
6790
6791 if(request == -1)
6792 {
6793 (*(command->func)) (argc, argv, id, NULL);
6794 return 1;
6795 }
6796
6797 if (request < 1 || (request >= (int32_t)NUM_ELEMS(s_commands) && request < RIL_REQUEST_VENDOR_BASE)) {
6798 RLOGW("unsupported request code %d token %d", request);
6799 // FIXME this should perhaps return a response
6800 return 1;
6801 }
6802
6803 RLOGD("REQUEST: %s ParamterNum:%d", requestToString(request), argc);
6804
6805
6806 RequestInfo *pRI = creatRILInfoAndInit(request, UDP, (RIL_SOCKET_ID)(id));
6807 pRI->lynqEvent = 1;
6808 //Radio on/off only allow one thread operate.
6809 if(request == RIL_REQUEST_RADIO_POWER)
6810 {
6811 speciaRequest_wait();
6812 }
6813 memset(Time_buf,0,sizeof(Time_buf));
6814 GetTimeString(Time_buf);
6815 //FUNCTION_CALLED(Time_buf,requestToString(request));
6816 int waittoken = pRI->token;
6817 (*(command->func)) (argc, argv, pRI->socket_id, pRI);
6818 FUNCTION_CALLED(Time_buf,requestToString(request));
6819 waitResponse(waittoken);
6820 memset(Time_buf,0,sizeof(Time_buf));
6821 GetTimeString(Time_buf);
6822 FUNCTION_RETURN(Time_buf,requestToString(request));
6823 return 0;
6824}
6825
6826int sendRespToUsb(char *cmd)
6827{
6828 return 0;
6829}
6830int sendUrcToUsb(char *cmd)
6831{
6832 return 0;
6833}
6834/*Warren add for FAW 2021/09/23 end*/
lh7b0674a2022-01-10 00:34:35 -08006835
6836void startPMLoop(void)
6837{
6838 pthread_t atciSocketThread;
6839
6840 RLOGD("startPMLoop()");
6841 pthread_mutex_lock(&s_startupMutex);
6842
6843 pthread_attr_t attr;
6844 pthread_attr_init(&attr);
6845 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
6846
6847 int result = pthread_create(&atciSocketThread, &attr, StartPMSocket, NULL);
6848 if (result != 0) {
6849 RLOGW("Failed to create PM thread: %s", strerror(result));
6850 goto done;
6851 }
6852
6853done:
6854 pthread_mutex_unlock(&s_startupMutex);
6855}
6856
6857void startGdbusLoop(void)
6858{
6859 pthread_t atciSocketThread;
6860
6861 RLOGD("startGdbusLoop()");
6862 pthread_mutex_lock(&s_startupMutex);
6863
6864 pthread_attr_t attr;
6865 pthread_attr_init(&attr);
6866 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
6867
6868 int result = pthread_create(&atciSocketThread, &attr, init_data_gdbus_cb, NULL);
6869 if (result != 0) {
6870 RLOGW("Failed to create gdbus thread: %s", strerror(result));
6871 goto done;
6872 }
6873
6874done:
6875 pthread_mutex_unlock(&s_startupMutex);
6876}
6877
6878void startATCILoop(void)
6879{
6880 pthread_t atciSocketThread;
6881
6882 RLOGD("startATCILoop()");
6883 pthread_mutex_lock(&s_startupMutex);
6884
6885 pthread_attr_t attr;
6886 pthread_attr_init(&attr);
6887 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
6888
6889 int result = pthread_create(&atciSocketThread, &attr, StartATCISocket, NULL);
6890 if (result != 0) {
6891 RLOGW("Failed to create ATCI thread: %s", strerror(result));
6892 goto done;
6893 }
6894
6895done:
6896 pthread_mutex_unlock(&s_startupMutex);
6897}
6898
6899void RIL_startEventLoop(void)
6900{
6901 RLOGD("RIL_startEventLoop()");
lhf6eea122022-01-20 19:32:14 -08006902 lynq_init_sms_manager();
lh7b0674a2022-01-10 00:34:35 -08006903 /* spin up eventLoop thread and wait for it to get started */
6904 s_started = 0;
6905 pthread_mutex_lock(&s_startupMutex);
6906
6907 pthread_attr_t attr;
6908 pthread_attr_init(&attr);
6909 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
6910
6911 int result = pthread_create(&s_tid_dispatch, &attr, eventLoop, NULL);
6912 if (result != 0) {
6913 RLOGW("Failed to create dispatch thread: %s", strerror(result));
6914 goto done;
6915 }
llaaca09b2022-03-14 16:14:28 +08006916
6917 while (s_started == 0) {
6918 pthread_cond_wait(&s_startupCond, &s_startupMutex);
6919 }
6920 /*mobiletek add*/
6921 s_started = 0;
6922 result = pthread_create(&s_tid_dispatch, &attr, eventLoop_at, NULL);
6923 if (result != 0) {
6924 RLOGW("Failed to create dispatch thread: %s", strerror(result));
6925 goto done;
6926 }
lh7b0674a2022-01-10 00:34:35 -08006927
6928 while (s_started == 0) {
6929 pthread_cond_wait(&s_startupCond, &s_startupMutex);
6930 }
llaaca09b2022-03-14 16:14:28 +08006931 /*mobiletek add*/
lh7b0674a2022-01-10 00:34:35 -08006932 result = pthread_create(&s_tid_dispatch, &attr, responseLoop, NULL);
6933 if (result != 0) {
6934 RLOGW("Failed to create response dispatch thread: %s", strerror(result));
6935 goto done;
6936 }
6937
6938 while (s_responseDispatch == 0) {
6939 pthread_cond_wait(&s_startupCond, &s_startupMutex);
6940 }
6941done:
6942 pthread_mutex_unlock(&s_startupMutex);
6943}
6944
6945void printInputArgs(int argc, char** argv)
6946{
6947 int i=0;
6948
6949 for(i=0; i<argc; i++)
6950 {
6951 RLOGD("%s", argv[i]);
6952 }
6953}
6954
6955void initRequestInfo(RequestInfo *pRI, int request, int mode, RIL_SOCKET_ID soc_id)
6956{
6957 pRI->token = GenerateToken(mode, request);
6958 if (request < RIL_REQUEST_VENDOR_BASE) {
6959 pRI->pCI = &(s_commands[request]);
6960 } else {
6961 pRI->pCI = find_mtk_command(request);
6962 }
6963 pRI->socket_id = soc_id;
6964
6965 pRI->p_next = NULL;
6966}
6967
6968void getVoiceAndDataRegistrationState(RIL_SOCKET_ID soc_id)
6969{
6970 ARspRequest(RIL_REQUEST_DATA_REGISTRATION_STATE,soc_id);
6971 ARspRequest(RIL_REQUEST_VOICE_REGISTRATION_STATE,soc_id);
6972}
6973
6974void requestAnswer(RIL_SOCKET_ID soc_id)
6975{
6976 ARspRequest(RIL_REQUEST_ANSWER,soc_id);
6977 return;
6978}
6979void requestSMSACKNOWLEDGE(RIL_SOCKET_ID soc_id)
6980{
6981 ARspRequest(RIL_REQUEST_SMS_ACKNOWLEDGE,soc_id);
6982 return;
6983}
6984
6985#if EM_MODE_SUPPORT
6986void registerForNetworkInfo(netwokInfoNotify cb)
6987{
6988 networkCb = cb;
6989 return ;
6990}
6991void unregisterNetwork()
6992{
6993 networkCb = NULL;
6994 //AT+EINFO= flag & 0xFFFFFFF7
6995}
6996void registerForATcmdResponse(atCmdResponse cb)
6997{
6998 atResponseCb = cb;
6999 return ;
7000}
7001
7002void unregisterATcmd()
7003{
7004 atResponseCb = NULL;
7005}
7006
7007#endif
7008int emResultNotify(const char *str)
7009{
7010 RLOGD("emResultNotify %s",str);
7011 int len_s = sendto(server_socket_fd,str,strlen(str),0,(struct sockaddr *)&client_addr,sizeof(client_addr));
7012
7013 sendto(server_socket_fd,"stopemdone",strlen("stopemdone"),0,(struct sockaddr *)&client_addr,sizeof(client_addr));
7014 return len_s;
7015}
7016
7017void processUnsolicited (Parcel &p, int type)
7018{
xja1c30b82022-01-25 16:13:48 +08007019 int32_t response = -1;
lh7b0674a2022-01-10 00:34:35 -08007020 p.readInt32(&response);
7021 switch(response){
7022 case RIL_UNSOL_MAL_AT_INFO:
7023 {
7024#if EM_MODE_SUPPORT
7025 char *stringresponse = strdupReadString(p);
7026 if(strstr(stringresponse,"+ENWINFO") != NULL){
7027 RLOGD("processUnsolicited ENWINFO \n");
7028 char *start = strstr(stringresponse,":");
7029 char *end = strstr(stringresponse,",");
7030 if(start == NULL ||end == NULL ){
7031 break;
7032 }
7033 if(networkCb){
7034 //parse type & data, notify to registrants
7035 char ctype[5] = {0};
7036 int type = 0;
7037 memcpy(ctype,start+1, end - start -1);
7038 type = atoi(ctype);
7039 char *data = end+1;
7040 RLOGD("ctype %s type %d data %s\n",ctype,type,data);
7041 //parse response
7042 networkCb(type,data);
7043 }
7044 }
7045 if(stringresponse){
7046 free(stringresponse);
7047 }
7048#endif
7049 break;
7050 }
7051 default:
7052 break;
7053 }
7054}
7055void processSolicited(Parcel &p, int type) {
7056 int32_t serial, error;
xja1c30b82022-01-25 16:13:48 +08007057 serial = 0;
lh7b0674a2022-01-10 00:34:35 -08007058 p.readInt32(&serial); //telematic it is the same as ril request num
7059 p.readInt32(&error);
7060 RLOGD("processSolicited serial %d\n", serial);
7061 switch (serial) {
7062 case RIL_REQUEST_OEM_HOOK_RAW: {
7063 if (error != RIL_E_SUCCESS) {
7064 RLOGW("RIL_E_fail");
7065 if (atResponseCb) {
7066 atResponseCb(NULL, 0);
7067 }
7068 if(m_RfDesense){
7069 m_RfDesense->handle_request("", 0, 0, (RIL_Errno)error);
7070 }
7071 return;
7072 }
7073 int len;
7074 status_t status = 0;
7075 status = p.readInt32(&len);
7076 if (status != 0) {
7077 RLOGW("read int32 fail");
7078 return;
7079 }
7080 char *stringresponse = (char*) calloc(len, sizeof(char));
7081 status = p.read((void*) stringresponse, len);
7082 if (status != 0) {
7083 if (stringresponse) {
7084 free(stringresponse);
7085 }
7086 RLOGW("read int32 fail");
7087 return;
7088 }
7089 parseAtCmd(stringresponse);
7090 RLOGD("processSolicited AT string %s %d\n", stringresponse, len);
7091#if EM_MODE_SUPPORT
7092 if (atResponseCb) {
7093 if (stringresponse) {
7094
7095 atResponseCb(stringresponse, len);
7096 } else {
7097 atResponseCb(stringresponse, 0);
7098 }
7099 }
7100 if(m_RfDesense){
7101 if(stringresponse && (!isFinalResponseErrorEx(stringresponse))) {
7102 m_RfDesense->handle_request(stringresponse,len,0, (RIL_Errno)RIL_E_SUCCESS);
7103 } else {
7104 RLOGD("isFinalResponseErrorEx error or response is null");
7105 m_RfDesense->handle_request(stringresponse, 0, 0, (RIL_Errno)RIL_E_GENERIC_FAILURE);
7106 }
7107 }
7108#endif
7109 if (stringresponse) {
7110 free(stringresponse);
7111 }
7112 break;
7113 }
7114 case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: {
7115#if EM_MODE_SUPPORT
7116 if (atResponseCb) {
7117 if (error != RIL_E_SUCCESS) {
7118 atResponseCb(NULL, 0);
7119 } else {
7120 atResponseCb("OK", 2);
7121 }
7122 }
7123#endif
7124 break;
7125 }
7126 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: {
7127#if EM_MODE_SUPPORT
7128 int nums = 0;
7129 int prefertype = 0;
7130 p.readInt32(&nums);
7131 if (nums != 1) {
7132 RLOGD("getpreferrednetworktype nums > 1");
7133 }
7134 p.readInt32(&prefertype);
7135 char prefertype_str[3] = { 0 };
7136 sprintf(prefertype_str, "%d", prefertype);
7137 if (atResponseCb) {
7138 if (error != RIL_E_SUCCESS) {
7139 atResponseCb(NULL, 0);
7140 } else {
7141 atResponseCb(prefertype_str, strlen(prefertype_str));
7142 }
7143 }
7144#endif
7145 break;
7146 }
7147 case RIL_REQUEST_GET_IMSI: {
7148 if (error != RIL_E_SUCCESS) {
7149 RLOGD("RIL_REQUEST_GET_IMSI error %d\n", error);
7150 }
7151 break;
7152 }
7153 }
7154}
7155
7156#ifdef ECALL_SUPPORT
7157static int responseEcallStatus(Parcel &p, void *response, size_t responselen) {
7158 if (response == NULL || responselen != sizeof(RIL_Ecall_Unsol_Indications)) {
7159 if (response == NULL) {
7160 RLOGE("invalid response: NULL");
7161 }
7162 else {
7163 RLOGE("responseEcallStatus: invalid response length %d expecting len: %d",
7164 sizeof(RIL_Ecall_Unsol_Indications), responselen);
7165 }
7166 return RIL_ERRNO_INVALID_RESPONSE;
7167 }
7168
7169 RIL_Ecall_Unsol_Indications *p_cur = (RIL_Ecall_Unsol_Indications *)response;
7170 p.writeInt32(p_cur->ind);
7171 p.writeInt32(p_cur->call_id);
7172
7173 startResponse;
7174 appendPrintBuf("ECall Status: %d, call_id: %d",
7175 p_cur->ind, p_cur->call_id);
7176 closeResponse;
7177
7178 return 0;
7179}
7180
7181/**
7182 * Callee expects const RIL_ECallReqMsg *
7183 * Payload is:
7184 * RIL_ECall_Category ecall_cat
7185 * RIL_ECall_Variant ecall_variant
7186 * String address
7187 * String msd_data
7188 */
7189static void dispatchFastEcall (Parcel &p, RequestInfo *pRI) {
7190 RIL_ECallReqMsg eCallReqMsg;
7191
xja1c30b82022-01-25 16:13:48 +08007192 int32_t t = -1;
lh7b0674a2022-01-10 00:34:35 -08007193 int size;
7194 status_t status;
7195 int digitCount;
7196 int digitLimit;
7197 uint8_t uct;
7198
7199 memset(&eCallReqMsg, 0, sizeof(eCallReqMsg));
7200
7201 status = p.readInt32(&t);
7202 eCallReqMsg.ecall_cat= (RIL_ECall_Category)t;
7203
7204 status = p.readInt32(&t);
7205 eCallReqMsg.ecall_variant = (RIL_ECall_Variant)t;
7206
7207 eCallReqMsg.address = strdupReadString(p);
7208
7209 status = p.readInt32(&t);
7210 eCallReqMsg.length = (uint8_t) t;
7211
7212 digitLimit= MIN((eCallReqMsg.length), MSD_MAX_LENGTH);
7213 eCallReqMsg.msd_data = (unsigned char *)alloca(digitLimit);
7214
7215 for(digitCount = 0 ; digitCount < digitLimit; digitCount ++) {
7216 status = p.read(&uct, sizeof(uint8_t));
7217 eCallReqMsg.msd_data[digitCount] = (uint8_t) uct;
7218 }
7219
7220 startRequest;
7221 appendPrintBuf("%secall_cat=%d,ecall_variant=%d, address=%s", printBuf,
7222 eCallReqMsg.ecall_cat, eCallReqMsg.ecall_variant, (char*)eCallReqMsg.address);
7223 closeRequest;
7224 printRequest(pRI->token, pRI->pCI->requestNumber);
7225
7226 if (status != NO_ERROR) {
7227 goto invalid;
7228 }
7229
7230 size = sizeof(eCallReqMsg);
7231 CALL_ONREQUEST(pRI->pCI->requestNumber, &eCallReqMsg, size, pRI, pRI->socket_id);
7232
7233#ifdef MEMSET_FREED
7234 memsetString(eCallReqMsg.address);
lhb07f4e12022-02-17 22:08:54 -08007235 memset(eCallReqMsg.msd_data, 0, digitLimit);
lh7b0674a2022-01-10 00:34:35 -08007236#endif
7237
7238 free(eCallReqMsg.address);
7239
7240#ifdef MEMSET_FREED
7241 memset(&eCallReqMsg, 0, sizeof(eCallReqMsg));
7242#endif
7243
7244 return;
7245invalid:
7246 invalidCommandBlock(pRI);
7247 return;
7248}
7249
7250/**
7251 * Callee expects const RIL_ECallSetMSD *
7252 * Payload is:
7253 * int call_id
7254 * String msd_data
7255 */
7256static void dispatchSetMsd (Parcel &p, RequestInfo *pRI) {
7257 RIL_ECallSetMSD eCallSetMsd;
7258
xja1c30b82022-01-25 16:13:48 +08007259 int32_t t = -1;
lh7b0674a2022-01-10 00:34:35 -08007260 int size;
7261 status_t status;
7262 int digitCount;
7263 int digitLimit;
7264 uint8_t uct;
7265
7266 memset(&eCallSetMsd, 0, sizeof(eCallSetMsd));
7267
7268 status = p.readInt32(&t);
7269 eCallSetMsd.call_id = (int)t;
7270
7271 status = p.readInt32(&t);
7272 eCallSetMsd.length = (uint8_t) t;
7273
7274 digitLimit= MIN((eCallSetMsd.length), MSD_MAX_LENGTH);
7275 eCallSetMsd.msd_data = (unsigned char *)alloca(digitLimit);
7276
7277 for(digitCount = 0 ; digitCount < digitLimit; digitCount ++) {
7278 status = p.read(&uct, sizeof(uint8_t));
7279 eCallSetMsd.msd_data[digitCount] = (uint8_t) uct;
7280 }
7281
7282 startRequest;
7283 appendPrintBuf("%scall_id=%d,msd_data=%s", printBuf, eCallSetMsd.call_id, (char*)eCallSetMsd.msd_data);
7284 closeRequest;
7285 printRequest(pRI->token, pRI->pCI->requestNumber);
7286
7287 if (status != NO_ERROR) {
7288 goto invalid;
7289 }
7290
7291 size = sizeof(eCallSetMsd);
7292 CALL_ONREQUEST(pRI->pCI->requestNumber, &eCallSetMsd, size, pRI, pRI->socket_id);
7293
7294#ifdef MEMSET_FREED
7295 memset(eCallSetMsd.msd_data, 0, eCallSetMsd.length);
7296#endif
7297
7298#ifdef MEMSET_FREED
7299 memset(&eCallSetMsd, 0, sizeof(eCallSetMsd));
7300#endif
7301
7302 return;
7303invalid:
7304 invalidCommandBlock(pRI);
7305 return;
7306}
7307
7308/**
7309 * Callee expects const RIL_ECallSetNum *
7310 * Payload is:
7311 * int arg_num;
7312 * int type
7313 * char* address
7314 */
7315static void dispatchEcallRecord (Parcel &p, RequestInfo *pRI) {
7316 RIL_ECallSetNum args;
xja1c30b82022-01-25 16:13:48 +08007317 int32_t t = -1;
lh7b0674a2022-01-10 00:34:35 -08007318 status_t status;
7319
7320 RLOGD("dispatchSmsWrite");
7321 memset (&args, 0, sizeof(args));
7322
7323 status = p.readInt32(&t);
7324 args.arg_num = (int)t;
7325
7326 status = p.readInt32(&t);
7327 args.type = (int)t;
7328
7329 args.address = strdupReadString(p);
7330
7331 if (status != NO_ERROR || args.address == NULL) {
7332 goto invalid;
7333 }
7334
7335 startRequest;
7336 appendPrintBuf("%s%d,%s,%d", printBuf, args.type, args.address,args.arg_num);
7337 closeRequest;
7338 printRequest(pRI->token, pRI->pCI->requestNumber);
7339
7340 CALL_ONREQUEST(pRI->pCI->requestNumber, &args, sizeof(args), pRI, pRI->socket_id);
7341
7342#ifdef MEMSET_FREED
7343 memsetString (args.address);
7344#endif
7345
7346 free (args.address);
7347#ifdef MEMSET_FREED
7348 memset(&args, 0, sizeof(args));
7349#endif
7350 return;
7351invalid:
7352 invalidCommandBlock(pRI);
7353 return;
7354}
7355#endif /*ECALL_SUPPORT*/
7356
7357#ifdef KEEP_ALIVE
7358static void dispatchStartKeepalivePro(Parcel &p, RequestInfo *pRI){
7359 RIL_RequestKeepalive_Pro kp;
xja1c30b82022-01-25 16:13:48 +08007360 int32_t t = -1;
lh7b0674a2022-01-10 00:34:35 -08007361 status_t status;
7362 std::vector<uint8_t> sadr;
7363 std::vector<uint8_t> dadr;
7364
7365 memset (&kp, 0, sizeof(RIL_RequestKeepalive_Pro));
7366
7367 status = p.readInt32(&t);
7368 kp.type = (RIL_PacketType)t;
7369 if (status != NO_ERROR) {
7370 goto invalid;
7371 }
7372
7373
7374 status = p.readByteVector(&sadr);
7375 if (status != NO_ERROR) {
7376 goto invalid;
7377 } else {
7378 for(int i = 0; i < sadr.size(); i++) {
7379 kp.sourceAddress[i] = sadr[i];
7380 }
7381 }
7382
7383 status = p.readInt32(&t);
7384 kp.sourcePort= (int)t;
7385 if (status != NO_ERROR) {
7386 goto invalid;
7387 }
7388
7389 status = p.readByteVector(&dadr);
7390 if (status != NO_ERROR) {
7391 goto invalid;
7392 } else {
7393 for(int i = 0; i < dadr.size(); i++) {
7394 kp.destinationAddress[i] = dadr[i];
7395 }
7396 }
7397
7398 status = p.readInt32(&t);
7399 kp.destinationPort= (int)t;
7400 if (status != NO_ERROR) {
7401 goto invalid;
7402 }
7403
7404 status = p.readInt32(&t);
7405 kp.netif_id = (int)t;
7406 if (status != NO_ERROR) {
7407 goto invalid;
7408 }
7409
7410 status = p.readInt32(&t);
7411 kp.keepIdleTime = (int)t;
7412 if (status != NO_ERROR) {
7413 goto invalid;
7414 }
7415
7416 status = p.readInt32(&t);
7417 kp.keepIntervalTime = (int)t;
7418 if (status != NO_ERROR) {
7419 goto invalid;
7420 }
7421
7422 status = p.readInt32(&t);
7423 kp.retryCount = (int)t;
7424 if (status != NO_ERROR) {
7425 goto invalid;
7426 }
7427 startRequest;
7428 appendPrintBuf("%s [type:%d, sourceAddress:",printBuf, kp.type);
7429
7430 for(auto v: sadr) {
7431 appendPrintBuf("%s %d",printBuf,v);
7432 }
7433 appendPrintBuf("%s, sourcePort:%d, destinationAddress:",printBuf, kp.sourcePort);
7434
7435 for(auto v: dadr) {
7436 appendPrintBuf("%s %d",printBuf,v);
7437 }
7438 appendPrintBuf("%s, destinationPort:%d, netif_id:%d, keepIdleTime:%d,, keepIntervalTime:%d, retryCount:%d",
7439 printBuf, kp.destinationPort, kp.netif_id, kp.keepIdleTime, kp.keepIntervalTime, kp.retryCount);
7440
7441 closeRequest;
7442 printRequest(pRI->token, pRI->pCI->requestNumber);
7443
7444 CALL_ONREQUEST(pRI->pCI->requestNumber,&kp,sizeof(RIL_RequestKeepalive_Pro),pRI, pRI->socket_id);
7445 return;
7446invalid:
7447 invalidCommandBlock(pRI);
7448 return;
7449}
7450#endif /* KEEP_ALIVE*/
7451} /* namespace android */
7452
7453#if 0
7454void rilEventAddWakeup_helper(struct ril_event *ev) {
7455 android::rilEventAddWakeup(ev);
7456}
7457
7458void listenCallback_helper(int fd, short flags, void *param) {
7459 android::listenCallback(fd, flags, param);
7460}
7461
7462int blockingWrite_helper(int fd, void *buffer, size_t len) {
7463 return android::blockingWrite(fd, buffer, len);
7464}
7465#endif