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