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