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