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