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