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