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