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