Daniel Hillenbrand | 601dc85 | 2013-07-07 10:06:59 +0200 | [diff] [blame] | 1 | /* //device/libs/telephony/ril.cpp |
| 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 | |
| 18 | #define LOG_TAG "RILC" |
| 19 | |
| 20 | #include <hardware_legacy/power.h> |
| 21 | |
| 22 | #include <telephony/ril.h> |
| 23 | #include <telephony/ril_cdma_sms.h> |
| 24 | #include <cutils/sockets.h> |
| 25 | #include <cutils/jstring.h> |
| 26 | #include <cutils/record_stream.h> |
| 27 | #include <utils/Log.h> |
| 28 | #include <utils/SystemClock.h> |
| 29 | #include <pthread.h> |
| 30 | #include <binder/Parcel.h> |
| 31 | #include <cutils/jstring.h> |
| 32 | |
| 33 | #include <sys/types.h> |
| 34 | #include <pwd.h> |
| 35 | |
| 36 | #include <stdio.h> |
| 37 | #include <stdlib.h> |
| 38 | #include <stdarg.h> |
| 39 | #include <string.h> |
| 40 | #include <unistd.h> |
| 41 | #include <fcntl.h> |
| 42 | #include <time.h> |
| 43 | #include <errno.h> |
| 44 | #include <assert.h> |
| 45 | #include <ctype.h> |
| 46 | #include <alloca.h> |
| 47 | #include <sys/un.h> |
| 48 | #include <assert.h> |
| 49 | #include <netinet/in.h> |
| 50 | #include <cutils/properties.h> |
| 51 | |
| 52 | #include <ril_event.h> |
| 53 | |
| 54 | namespace android { |
| 55 | |
| 56 | #define PHONE_PROCESS "radio" |
| 57 | |
| 58 | #define SOCKET_NAME_RIL "rild" |
| 59 | #define SOCKET_NAME_RIL_DEBUG "rild-debug" |
| 60 | |
| 61 | #define ANDROID_WAKE_LOCK_NAME "radio-interface" |
| 62 | |
| 63 | |
| 64 | #define PROPERTY_RIL_IMPL "gsm.version.ril-impl" |
| 65 | |
| 66 | // match with constant in RIL.java |
| 67 | #define MAX_COMMAND_BYTES (8 * 1024) |
| 68 | |
| 69 | // Basically: memset buffers that the client library |
| 70 | // shouldn't be using anymore in an attempt to find |
| 71 | // memory usage issues sooner. |
| 72 | #define MEMSET_FREED 1 |
| 73 | |
| 74 | #define NUM_ELEMS(a) (sizeof (a) / sizeof (a)[0]) |
| 75 | |
| 76 | #define MIN(a,b) ((a)<(b) ? (a) : (b)) |
| 77 | |
| 78 | /* Constants for response types */ |
| 79 | #define RESPONSE_SOLICITED 0 |
| 80 | #define RESPONSE_UNSOLICITED 1 |
| 81 | |
| 82 | /* Negative values for private RIL errno's */ |
| 83 | #define RIL_ERRNO_INVALID_RESPONSE -1 |
| 84 | |
| 85 | // request, response, and unsolicited msg print macro |
| 86 | #define PRINTBUF_SIZE 8096 |
| 87 | |
| 88 | // Enable RILC log |
| 89 | #define RILC_LOG 0 |
| 90 | |
| 91 | #if RILC_LOG |
| 92 | #define startRequest sprintf(printBuf, "(") |
| 93 | #define closeRequest sprintf(printBuf, "%s)", printBuf) |
| 94 | #define printRequest(token, req) \ |
| 95 | ALOGD("[%04d]> %s %s", token, requestToString(req), printBuf) |
| 96 | |
| 97 | #define startResponse sprintf(printBuf, "%s {", printBuf) |
| 98 | #define closeResponse sprintf(printBuf, "%s}", printBuf) |
| 99 | #define printResponse ALOGD("%s", printBuf) |
| 100 | |
| 101 | #define clearPrintBuf printBuf[0] = 0 |
| 102 | #define removeLastChar printBuf[strlen(printBuf)-1] = 0 |
| 103 | #define appendPrintBuf(x...) sprintf(printBuf, x) |
| 104 | #else |
| 105 | #define startRequest |
| 106 | #define closeRequest |
| 107 | #define printRequest(token, req) |
| 108 | #define startResponse |
| 109 | #define closeResponse |
| 110 | #define printResponse |
| 111 | #define clearPrintBuf |
| 112 | #define removeLastChar |
| 113 | #define appendPrintBuf(x...) |
| 114 | #endif |
| 115 | |
| 116 | enum WakeType {DONT_WAKE, WAKE_PARTIAL}; |
| 117 | |
| 118 | typedef struct { |
| 119 | int requestNumber; |
| 120 | void (*dispatchFunction) (Parcel &p, struct RequestInfo *pRI); |
| 121 | int(*responseFunction) (Parcel &p, void *response, size_t responselen); |
| 122 | } CommandInfo; |
| 123 | |
| 124 | typedef struct { |
| 125 | int requestNumber; |
| 126 | int (*responseFunction) (Parcel &p, void *response, size_t responselen); |
| 127 | WakeType wakeType; |
| 128 | } UnsolResponseInfo; |
| 129 | |
| 130 | typedef struct RequestInfo { |
| 131 | int32_t token; //this is not RIL_Token |
| 132 | CommandInfo *pCI; |
| 133 | struct RequestInfo *p_next; |
| 134 | char cancelled; |
| 135 | char local; // responses to local commands do not go back to command process |
| 136 | } RequestInfo; |
| 137 | |
| 138 | typedef struct UserCallbackInfo { |
| 139 | RIL_TimedCallback p_callback; |
| 140 | void *userParam; |
| 141 | struct ril_event event; |
| 142 | struct UserCallbackInfo *p_next; |
| 143 | } UserCallbackInfo; |
| 144 | |
| 145 | |
| 146 | /*******************************************************************/ |
| 147 | |
| 148 | RIL_RadioFunctions s_callbacks = {0, NULL, NULL, NULL, NULL, NULL}; |
| 149 | static int s_registerCalled = 0; |
| 150 | |
| 151 | static pthread_t s_tid_dispatch; |
| 152 | static pthread_t s_tid_reader; |
| 153 | static int s_started = 0; |
| 154 | |
| 155 | static int s_fdListen = -1; |
| 156 | static int s_fdCommand = -1; |
| 157 | static int s_fdDebug = -1; |
| 158 | |
| 159 | static int s_fdWakeupRead; |
| 160 | static int s_fdWakeupWrite; |
| 161 | |
| 162 | static struct ril_event s_commands_event; |
| 163 | static struct ril_event s_wakeupfd_event; |
| 164 | static struct ril_event s_listen_event; |
| 165 | static struct ril_event s_wake_timeout_event; |
| 166 | static struct ril_event s_debug_event; |
| 167 | |
| 168 | |
| 169 | static const struct timeval TIMEVAL_WAKE_TIMEOUT = {1,0}; |
| 170 | |
| 171 | static pthread_mutex_t s_pendingRequestsMutex = PTHREAD_MUTEX_INITIALIZER; |
| 172 | static pthread_mutex_t s_writeMutex = PTHREAD_MUTEX_INITIALIZER; |
| 173 | static pthread_mutex_t s_startupMutex = PTHREAD_MUTEX_INITIALIZER; |
| 174 | static pthread_cond_t s_startupCond = PTHREAD_COND_INITIALIZER; |
| 175 | |
| 176 | static pthread_mutex_t s_dispatchMutex = PTHREAD_MUTEX_INITIALIZER; |
| 177 | static pthread_cond_t s_dispatchCond = PTHREAD_COND_INITIALIZER; |
| 178 | |
| 179 | static RequestInfo *s_pendingRequests = NULL; |
| 180 | |
| 181 | static RequestInfo *s_toDispatchHead = NULL; |
| 182 | static RequestInfo *s_toDispatchTail = NULL; |
| 183 | |
| 184 | static UserCallbackInfo *s_last_wake_timeout_info = NULL; |
| 185 | |
| 186 | static void *s_lastNITZTimeData = NULL; |
| 187 | static size_t s_lastNITZTimeDataSize; |
| 188 | |
| 189 | #if RILC_LOG |
| 190 | static char printBuf[PRINTBUF_SIZE]; |
| 191 | #endif |
| 192 | |
| 193 | /*******************************************************************/ |
| 194 | |
| 195 | static void dispatchVoid (Parcel& p, RequestInfo *pRI); |
| 196 | static void dispatchString (Parcel& p, RequestInfo *pRI); |
| 197 | static void dispatchStrings (Parcel& p, RequestInfo *pRI); |
| 198 | static void dispatchInts (Parcel& p, RequestInfo *pRI); |
| 199 | static void dispatchDial (Parcel& p, RequestInfo *pRI); |
| 200 | static void dispatchSIM_IO (Parcel& p, RequestInfo *pRI); |
| 201 | static void dispatchCallForward(Parcel& p, RequestInfo *pRI); |
| 202 | static void dispatchRaw(Parcel& p, RequestInfo *pRI); |
| 203 | static void dispatchSmsWrite (Parcel &p, RequestInfo *pRI); |
| 204 | |
| 205 | static void dispatchCdmaSms(Parcel &p, RequestInfo *pRI); |
| 206 | static void dispatchCdmaSmsAck(Parcel &p, RequestInfo *pRI); |
| 207 | static void dispatchGsmBrSmsCnf(Parcel &p, RequestInfo *pRI); |
| 208 | static void dispatchCdmaBrSmsCnf(Parcel &p, RequestInfo *pRI); |
| 209 | static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI); |
| 210 | static int responseInts(Parcel &p, void *response, size_t responselen); |
| 211 | static int responseIntsGetPreferredNetworkType(Parcel &p, void *response, size_t responselen); |
| 212 | static int responseStrings(Parcel &p, void *response, size_t responselen); |
| 213 | static int responseStringsNetworks(Parcel &p, void *response, size_t responselen); |
| 214 | static int responseStrings(Parcel &p, void *response, size_t responselen, bool network_search); |
| 215 | static int responseString(Parcel &p, void *response, size_t responselen); |
| 216 | static int responseVoid(Parcel &p, void *response, size_t responselen); |
| 217 | static int responseCallList(Parcel &p, void *response, size_t responselen); |
| 218 | static int responseSMS(Parcel &p, void *response, size_t responselen); |
| 219 | static int responseSIM_IO(Parcel &p, void *response, size_t responselen); |
| 220 | static int responseCallForwards(Parcel &p, void *response, size_t responselen); |
| 221 | static int responseDataCallList(Parcel &p, void *response, size_t responselen); |
| 222 | static int responseRaw(Parcel &p, void *response, size_t responselen); |
| 223 | static int responseSsn(Parcel &p, void *response, size_t responselen); |
| 224 | static int responseSimStatus(Parcel &p, void *response, size_t responselen); |
| 225 | static int responseGsmBrSmsCnf(Parcel &p, void *response, size_t responselen); |
| 226 | static int responseCdmaBrSmsCnf(Parcel &p, void *response, size_t responselen); |
| 227 | static int responseCdmaSms(Parcel &p, void *response, size_t responselen); |
| 228 | static int responseCellList(Parcel &p, void *response, size_t responselen); |
| 229 | static int responseCdmaInformationRecords(Parcel &p,void *response, size_t responselen); |
| 230 | static int responseRilSignalStrength(Parcel &p,void *response, size_t responselen); |
| 231 | static int responseCallRing(Parcel &p, void *response, size_t responselen); |
| 232 | static int responseCdmaSignalInfoRecord(Parcel &p,void *response, size_t responselen); |
| 233 | static int responseCdmaCallWaiting(Parcel &p,void *response, size_t responselen); |
| 234 | static int responseSimRefresh(Parcel &p, void *response, size_t responselen); |
| 235 | |
| 236 | static int decodeVoiceRadioTechnology (RIL_RadioState radioState); |
| 237 | static int decodeCdmaSubscriptionSource (RIL_RadioState radioState); |
| 238 | static RIL_RadioState processRadioState(RIL_RadioState newRadioState); |
| 239 | |
| 240 | extern "C" const char * requestToString(int request); |
| 241 | extern "C" const char * failCauseToString(RIL_Errno); |
| 242 | extern "C" const char * callStateToString(RIL_CallState); |
| 243 | extern "C" const char * radioStateToString(RIL_RadioState); |
| 244 | |
| 245 | #ifdef RIL_SHLIB |
| 246 | extern "C" void RIL_onUnsolicitedResponse(int unsolResponse, void *data, |
| 247 | size_t datalen); |
| 248 | #endif |
| 249 | |
| 250 | static UserCallbackInfo * internalRequestTimedCallback |
| 251 | (RIL_TimedCallback callback, void *param, |
| 252 | const struct timeval *relativeTime); |
| 253 | |
| 254 | /** Index == requestNumber */ |
| 255 | static CommandInfo s_commands[] = { |
| 256 | #include "ril_commands.h" |
| 257 | }; |
| 258 | |
| 259 | static UnsolResponseInfo s_unsolResponses[] = { |
| 260 | #include "ril_unsol_commands.h" |
| 261 | }; |
| 262 | |
| 263 | /* For older RILs that do not support new commands RIL_REQUEST_VOICE_RADIO_TECH and |
| 264 | RIL_UNSOL_VOICE_RADIO_TECH_CHANGED messages, decode the voice radio tech from |
| 265 | radio state message and store it. Every time there is a change in Radio State |
| 266 | check to see if voice radio tech changes and notify telephony |
| 267 | */ |
| 268 | int voiceRadioTech = -1; |
| 269 | |
| 270 | /* For older RILs that do not support new commands RIL_REQUEST_GET_CDMA_SUBSCRIPTION_SOURCE |
| 271 | and RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED messages, decode the subscription |
| 272 | source from radio state and store it. Every time there is a change in Radio State |
| 273 | check to see if subscription source changed and notify telephony |
| 274 | */ |
| 275 | int cdmaSubscriptionSource = -1; |
| 276 | |
| 277 | /* For older RILs that do not send RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, decode the |
| 278 | SIM/RUIM state from radio state and store it. Every time there is a change in Radio State, |
| 279 | check to see if SIM/RUIM status changed and notify telephony |
| 280 | */ |
| 281 | int simRuimStatus = -1; |
| 282 | |
| 283 | static char * |
| 284 | strdupReadString(Parcel &p) { |
| 285 | size_t stringlen; |
| 286 | const char16_t *s16; |
| 287 | |
| 288 | s16 = p.readString16Inplace(&stringlen); |
| 289 | |
| 290 | return strndup16to8(s16, stringlen); |
| 291 | } |
| 292 | |
| 293 | static void writeStringToParcel(Parcel &p, const char *s) { |
| 294 | char16_t *s16; |
| 295 | size_t s16_len; |
| 296 | s16 = strdup8to16(s, &s16_len); |
| 297 | p.writeString16(s16, s16_len); |
| 298 | free(s16); |
| 299 | } |
| 300 | |
| 301 | |
| 302 | static void |
| 303 | memsetString (char *s) { |
| 304 | if (s != NULL) { |
| 305 | memset (s, 0, strlen(s)); |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | void nullParcelReleaseFunction (const uint8_t* data, size_t dataSize, |
| 310 | const size_t* objects, size_t objectsSize, |
| 311 | void* cookie) { |
| 312 | // do nothing -- the data reference lives longer than the Parcel object |
| 313 | } |
| 314 | |
| 315 | /** |
| 316 | * To be called from dispatch thread |
| 317 | * Issue a single local request, ensuring that the response |
| 318 | * is not sent back up to the command process |
| 319 | */ |
| 320 | static void |
| 321 | issueLocalRequest(int request, void *data, int len) { |
| 322 | RequestInfo *pRI; |
| 323 | int index; |
| 324 | int ret; |
| 325 | |
| 326 | pRI = (RequestInfo *)calloc(1, sizeof(RequestInfo)); |
| 327 | |
| 328 | pRI->local = 1; |
| 329 | pRI->token = 0xffffffff; // token is not used in this context |
| 330 | |
| 331 | /* Hack to include Samsung requests */ |
| 332 | if (request > 10000) { |
| 333 | index = request - 10000 + RIL_REQUEST_VOICE_RADIO_TECH; |
| 334 | ALOGE("SAMSUNG: request=%d, index=%d", request, index); |
| 335 | pRI->pCI = &(s_commands[index]); |
| 336 | } else { |
| 337 | pRI->pCI = &(s_commands[request]); |
| 338 | } |
| 339 | |
| 340 | ret = pthread_mutex_lock(&s_pendingRequestsMutex); |
| 341 | assert (ret == 0); |
| 342 | |
| 343 | pRI->p_next = s_pendingRequests; |
| 344 | s_pendingRequests = pRI; |
| 345 | |
| 346 | ret = pthread_mutex_unlock(&s_pendingRequestsMutex); |
| 347 | assert (ret == 0); |
| 348 | |
| 349 | ALOGD("C[locl]> %s", requestToString(request)); |
| 350 | |
| 351 | s_callbacks.onRequest(request, data, len, pRI); |
| 352 | } |
| 353 | |
| 354 | static int |
| 355 | processCommandBuffer(void *buffer, size_t buflen) { |
| 356 | Parcel p; |
| 357 | status_t status; |
| 358 | int32_t request; |
| 359 | int32_t token; |
| 360 | RequestInfo *pRI; |
| 361 | int index; |
| 362 | int ret; |
| 363 | |
Daniel Hillenbrand | 601dc85 | 2013-07-07 10:06:59 +0200 | [diff] [blame] | 364 | p.setData((uint8_t *) buffer, buflen); |
| 365 | |
| 366 | // status checked at end |
| 367 | status = p.readInt32(&request); |
| 368 | status = p.readInt32 (&token); |
| 369 | |
| 370 | if (status != NO_ERROR) { |
| 371 | ALOGE("invalid request block"); |
| 372 | return 0; |
| 373 | } |
| 374 | |
| 375 | /* Hack to include Samsung requests */ |
| 376 | //if (request < 1 || request >= (int32_t)NUM_ELEMS(s_commands)) { |
| 377 | if (request < 1 || ((request > RIL_REQUEST_VOICE_RADIO_TECH) && (request < RIL_REQUEST_GET_CELL_BROADCAST_CONFIG)) || request > RIL_REQUEST_HANGUP_VT) { |
| 378 | ALOGE("unsupported request code %d token %d", request, token); |
| 379 | // FIXME this should perhaps return a response |
| 380 | return 0; |
| 381 | } |
| 382 | |
| 383 | pRI = (RequestInfo *)calloc(1, sizeof(RequestInfo)); |
| 384 | |
| 385 | pRI->token = token; |
| 386 | |
| 387 | /* Hack to include Samsung requests */ |
| 388 | if (request > 10000) { |
| 389 | index = request - 10000 + RIL_REQUEST_VOICE_RADIO_TECH; |
| 390 | ALOGE("processCommandBuffer: samsung request=%d, index=%d", request, index); |
| 391 | pRI->pCI = &(s_commands[index]); |
| 392 | } else { |
| 393 | pRI->pCI = &(s_commands[request]); |
| 394 | } |
| 395 | |
| 396 | ret = pthread_mutex_lock(&s_pendingRequestsMutex); |
| 397 | assert (ret == 0); |
| 398 | |
| 399 | pRI->p_next = s_pendingRequests; |
| 400 | s_pendingRequests = pRI; |
| 401 | |
| 402 | ret = pthread_mutex_unlock(&s_pendingRequestsMutex); |
| 403 | assert (ret == 0); |
| 404 | |
| 405 | /* sLastDispatchedToken = token; */ |
| 406 | |
Daniel Hillenbrand | 601dc85 | 2013-07-07 10:06:59 +0200 | [diff] [blame] | 407 | pRI->pCI->dispatchFunction(p, pRI); |
| 408 | |
Daniel Hillenbrand | 601dc85 | 2013-07-07 10:06:59 +0200 | [diff] [blame] | 409 | return 0; |
| 410 | } |
| 411 | |
| 412 | static void |
| 413 | invalidCommandBlock (RequestInfo *pRI) { |
| 414 | ALOGE("invalid command block for token %d request %s", |
| 415 | pRI->token, requestToString(pRI->pCI->requestNumber)); |
| 416 | } |
| 417 | |
| 418 | /** Callee expects NULL */ |
| 419 | static void |
| 420 | dispatchVoid (Parcel& p, RequestInfo *pRI) { |
| 421 | clearPrintBuf; |
| 422 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 423 | s_callbacks.onRequest(pRI->pCI->requestNumber, NULL, 0, pRI); |
| 424 | } |
| 425 | |
| 426 | /** Callee expects const char * */ |
| 427 | static void |
| 428 | dispatchString (Parcel& p, RequestInfo *pRI) { |
| 429 | status_t status; |
| 430 | size_t datalen; |
| 431 | size_t stringlen; |
| 432 | char *string8 = NULL; |
| 433 | |
| 434 | string8 = strdupReadString(p); |
| 435 | |
| 436 | startRequest; |
| 437 | appendPrintBuf("%s%s", printBuf, string8); |
| 438 | closeRequest; |
| 439 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 440 | |
| 441 | s_callbacks.onRequest(pRI->pCI->requestNumber, string8, |
| 442 | sizeof(char *), pRI); |
| 443 | |
| 444 | #ifdef MEMSET_FREED |
| 445 | memsetString(string8); |
| 446 | #endif |
| 447 | |
| 448 | free(string8); |
| 449 | return; |
| 450 | invalid: |
| 451 | invalidCommandBlock(pRI); |
| 452 | return; |
| 453 | } |
| 454 | |
| 455 | /** Callee expects const char ** */ |
| 456 | static void |
| 457 | dispatchStrings (Parcel &p, RequestInfo *pRI) { |
| 458 | int32_t countStrings; |
| 459 | status_t status; |
| 460 | size_t datalen; |
| 461 | char **pStrings; |
| 462 | |
| 463 | status = p.readInt32 (&countStrings); |
| 464 | |
| 465 | if (status != NO_ERROR) { |
| 466 | goto invalid; |
| 467 | } |
| 468 | |
| 469 | startRequest; |
| 470 | if (countStrings == 0) { |
| 471 | // just some non-null pointer |
| 472 | pStrings = (char **)alloca(sizeof(char *)); |
| 473 | datalen = 0; |
| 474 | } else if (((int)countStrings) == -1) { |
| 475 | pStrings = NULL; |
| 476 | datalen = 0; |
| 477 | } else { |
| 478 | datalen = sizeof(char *) * countStrings; |
| 479 | |
| 480 | pStrings = (char **)alloca(datalen); |
| 481 | |
| 482 | for (int i = 0 ; i < countStrings ; i++) { |
| 483 | pStrings[i] = strdupReadString(p); |
| 484 | appendPrintBuf("%s%s,", printBuf, pStrings[i]); |
| 485 | } |
| 486 | } |
| 487 | removeLastChar; |
| 488 | closeRequest; |
| 489 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 490 | |
| 491 | s_callbacks.onRequest(pRI->pCI->requestNumber, pStrings, datalen, pRI); |
| 492 | |
| 493 | if (pStrings != NULL) { |
| 494 | for (int i = 0 ; i < countStrings ; i++) { |
| 495 | #ifdef MEMSET_FREED |
| 496 | memsetString (pStrings[i]); |
| 497 | #endif |
| 498 | free(pStrings[i]); |
| 499 | } |
| 500 | |
| 501 | #ifdef MEMSET_FREED |
| 502 | memset(pStrings, 0, datalen); |
| 503 | #endif |
| 504 | } |
| 505 | |
| 506 | return; |
| 507 | invalid: |
| 508 | invalidCommandBlock(pRI); |
| 509 | return; |
| 510 | } |
| 511 | |
| 512 | /** Callee expects const int * */ |
| 513 | static void |
| 514 | dispatchInts (Parcel &p, RequestInfo *pRI) { |
| 515 | int32_t count; |
| 516 | status_t status; |
| 517 | size_t datalen; |
| 518 | int *pInts; |
| 519 | |
| 520 | status = p.readInt32 (&count); |
| 521 | |
| 522 | if (status != NO_ERROR || count == 0) { |
| 523 | goto invalid; |
| 524 | } |
| 525 | |
| 526 | datalen = sizeof(int) * count; |
| 527 | pInts = (int *)alloca(datalen); |
| 528 | |
| 529 | startRequest; |
| 530 | for (int i = 0 ; i < count ; i++) { |
| 531 | int32_t t; |
| 532 | |
| 533 | status = p.readInt32(&t); |
| 534 | pInts[i] = (int)t; |
| 535 | appendPrintBuf("%s%d,", printBuf, t); |
| 536 | |
| 537 | if (status != NO_ERROR) { |
| 538 | goto invalid; |
| 539 | } |
| 540 | } |
| 541 | removeLastChar; |
| 542 | closeRequest; |
| 543 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 544 | |
| 545 | s_callbacks.onRequest(pRI->pCI->requestNumber, const_cast<int *>(pInts), |
| 546 | datalen, pRI); |
| 547 | |
| 548 | #ifdef MEMSET_FREED |
| 549 | memset(pInts, 0, datalen); |
| 550 | #endif |
| 551 | |
| 552 | return; |
| 553 | invalid: |
| 554 | invalidCommandBlock(pRI); |
| 555 | return; |
| 556 | } |
| 557 | |
| 558 | |
| 559 | /** |
| 560 | * Callee expects const RIL_SMS_WriteArgs * |
| 561 | * Payload is: |
| 562 | * int32_t status |
| 563 | * String pdu |
| 564 | */ |
| 565 | static void |
| 566 | dispatchSmsWrite (Parcel &p, RequestInfo *pRI) { |
| 567 | RIL_SMS_WriteArgs args; |
| 568 | int32_t t; |
| 569 | status_t status; |
| 570 | |
| 571 | memset (&args, 0, sizeof(args)); |
| 572 | |
| 573 | status = p.readInt32(&t); |
| 574 | args.status = (int)t; |
| 575 | |
| 576 | args.pdu = strdupReadString(p); |
| 577 | |
| 578 | if (status != NO_ERROR || args.pdu == NULL) { |
| 579 | goto invalid; |
| 580 | } |
| 581 | |
| 582 | args.smsc = strdupReadString(p); |
| 583 | |
| 584 | startRequest; |
| 585 | appendPrintBuf("%s%d,%s,smsc=%s", printBuf, args.status, |
| 586 | (char*)args.pdu, (char*)args.smsc); |
| 587 | closeRequest; |
| 588 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 589 | |
| 590 | s_callbacks.onRequest(pRI->pCI->requestNumber, &args, sizeof(args), pRI); |
| 591 | |
| 592 | #ifdef MEMSET_FREED |
| 593 | memsetString (args.pdu); |
| 594 | #endif |
| 595 | |
| 596 | free (args.pdu); |
| 597 | |
| 598 | #ifdef MEMSET_FREED |
| 599 | memset(&args, 0, sizeof(args)); |
| 600 | #endif |
| 601 | |
| 602 | return; |
| 603 | invalid: |
| 604 | invalidCommandBlock(pRI); |
| 605 | return; |
| 606 | } |
| 607 | |
| 608 | /** |
| 609 | * Callee expects const RIL_Dial * |
| 610 | * Payload is: |
| 611 | * String address |
| 612 | * int32_t clir |
| 613 | */ |
| 614 | static void |
| 615 | dispatchDial (Parcel &p, RequestInfo *pRI) { |
| 616 | RIL_Dial dial; |
| 617 | RIL_UUS_Info uusInfo; |
| 618 | int32_t sizeOfDial; |
| 619 | int32_t t; |
| 620 | int32_t uusPresent; |
| 621 | status_t status; |
| 622 | |
| 623 | memset (&dial, 0, sizeof(dial)); |
| 624 | |
| 625 | dial.address = strdupReadString(p); |
| 626 | |
| 627 | status = p.readInt32(&t); |
| 628 | dial.clir = (int)t; |
| 629 | |
| 630 | if (status != NO_ERROR || dial.address == NULL) { |
| 631 | goto invalid; |
| 632 | } |
| 633 | |
| 634 | if (s_callbacks.version < 3) { // Remove when partners upgrade to version 3 |
Daniel Hillenbrand | 601dc85 | 2013-07-07 10:06:59 +0200 | [diff] [blame] | 635 | uusPresent = 0; |
| 636 | sizeOfDial = sizeof(dial) - sizeof(RIL_UUS_Info *); |
| 637 | } else { |
| 638 | status = p.readInt32(&uusPresent); |
| 639 | |
| 640 | if (status != NO_ERROR) { |
| 641 | goto invalid; |
| 642 | } |
| 643 | |
| 644 | if (uusPresent == 0) { |
| 645 | /* Samsung hack */ |
| 646 | memset(&uusInfo, 0, sizeof(RIL_UUS_Info)); |
| 647 | uusInfo.uusType = (RIL_UUS_Type) 0; |
| 648 | uusInfo.uusDcs = (RIL_UUS_DCS) 0; |
| 649 | uusInfo.uusData = NULL; |
| 650 | uusInfo.uusLength = 0; |
| 651 | dial.uusInfo = &uusInfo; |
| 652 | } else { |
| 653 | int32_t len; |
| 654 | |
| 655 | memset(&uusInfo, 0, sizeof(RIL_UUS_Info)); |
| 656 | |
| 657 | status = p.readInt32(&t); |
| 658 | uusInfo.uusType = (RIL_UUS_Type) t; |
| 659 | |
| 660 | status = p.readInt32(&t); |
| 661 | uusInfo.uusDcs = (RIL_UUS_DCS) t; |
| 662 | |
| 663 | status = p.readInt32(&len); |
| 664 | if (status != NO_ERROR) { |
| 665 | goto invalid; |
| 666 | } |
| 667 | |
| 668 | // The java code writes -1 for null arrays |
| 669 | if (((int) len) == -1) { |
| 670 | uusInfo.uusData = NULL; |
| 671 | len = 0; |
| 672 | } else { |
| 673 | uusInfo.uusData = (char*) p.readInplace(len); |
| 674 | } |
| 675 | |
| 676 | uusInfo.uusLength = len; |
| 677 | dial.uusInfo = &uusInfo; |
| 678 | } |
| 679 | sizeOfDial = sizeof(dial); |
| 680 | } |
| 681 | |
| 682 | startRequest; |
| 683 | appendPrintBuf("%snum=%s,clir=%d", printBuf, dial.address, dial.clir); |
| 684 | if (uusPresent) { |
| 685 | appendPrintBuf("%s,uusType=%d,uusDcs=%d,uusLen=%d", printBuf, |
| 686 | dial.uusInfo->uusType, dial.uusInfo->uusDcs, |
| 687 | dial.uusInfo->uusLength); |
| 688 | } |
| 689 | closeRequest; |
| 690 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 691 | |
| 692 | s_callbacks.onRequest(pRI->pCI->requestNumber, &dial, sizeOfDial, pRI); |
| 693 | |
| 694 | #ifdef MEMSET_FREED |
| 695 | memsetString (dial.address); |
| 696 | #endif |
| 697 | |
| 698 | free (dial.address); |
| 699 | |
| 700 | #ifdef MEMSET_FREED |
| 701 | memset(&uusInfo, 0, sizeof(RIL_UUS_Info)); |
| 702 | memset(&dial, 0, sizeof(dial)); |
| 703 | #endif |
| 704 | |
| 705 | return; |
| 706 | invalid: |
| 707 | invalidCommandBlock(pRI); |
| 708 | return; |
| 709 | } |
| 710 | |
| 711 | /** |
| 712 | * Callee expects const RIL_SIM_IO * |
| 713 | * Payload is: |
| 714 | * int32_t command |
| 715 | * int32_t fileid |
| 716 | * String path |
| 717 | * int32_t p1, p2, p3 |
| 718 | * String data |
| 719 | * String pin2 |
| 720 | * String aidPtr |
| 721 | */ |
| 722 | static void |
| 723 | dispatchSIM_IO (Parcel &p, RequestInfo *pRI) { |
| 724 | RIL_SIM_IO_v6 simIO; |
| 725 | int32_t t; |
| 726 | status_t status; |
| 727 | |
| 728 | memset (&simIO, 0, sizeof(simIO)); |
| 729 | |
| 730 | // note we only check status at the end |
| 731 | |
| 732 | status = p.readInt32(&t); |
| 733 | simIO.command = (int)t; |
| 734 | |
| 735 | status = p.readInt32(&t); |
| 736 | simIO.fileid = (int)t; |
| 737 | |
| 738 | simIO.path = strdupReadString(p); |
| 739 | |
| 740 | status = p.readInt32(&t); |
| 741 | simIO.p1 = (int)t; |
| 742 | |
| 743 | status = p.readInt32(&t); |
| 744 | simIO.p2 = (int)t; |
| 745 | |
| 746 | status = p.readInt32(&t); |
| 747 | simIO.p3 = (int)t; |
| 748 | |
| 749 | simIO.data = strdupReadString(p); |
| 750 | simIO.pin2 = strdupReadString(p); |
| 751 | simIO.aidPtr = strdupReadString(p); |
| 752 | |
| 753 | startRequest; |
| 754 | appendPrintBuf("%scmd=0x%X,efid=0x%X,path=%s,%d,%d,%d,%s,pin2=%s,aid=%s", printBuf, |
| 755 | simIO.command, simIO.fileid, (char*)simIO.path, |
| 756 | simIO.p1, simIO.p2, simIO.p3, |
| 757 | (char*)simIO.data, (char*)simIO.pin2, simIO.aidPtr); |
| 758 | closeRequest; |
| 759 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 760 | |
| 761 | if (status != NO_ERROR) { |
| 762 | goto invalid; |
| 763 | } |
| 764 | |
| 765 | s_callbacks.onRequest(pRI->pCI->requestNumber, &simIO, sizeof(simIO), pRI); |
| 766 | |
| 767 | #ifdef MEMSET_FREED |
| 768 | memsetString (simIO.path); |
| 769 | memsetString (simIO.data); |
| 770 | memsetString (simIO.pin2); |
| 771 | memsetString (simIO.aidPtr); |
| 772 | #endif |
| 773 | |
| 774 | free (simIO.path); |
| 775 | free (simIO.data); |
| 776 | free (simIO.pin2); |
| 777 | free (simIO.aidPtr); |
| 778 | |
| 779 | #ifdef MEMSET_FREED |
| 780 | memset(&simIO, 0, sizeof(simIO)); |
| 781 | #endif |
| 782 | |
| 783 | return; |
| 784 | invalid: |
| 785 | invalidCommandBlock(pRI); |
| 786 | return; |
| 787 | } |
| 788 | |
| 789 | /** |
| 790 | * Callee expects const RIL_CallForwardInfo * |
| 791 | * Payload is: |
| 792 | * int32_t status/action |
| 793 | * int32_t reason |
| 794 | * int32_t serviceCode |
| 795 | * int32_t toa |
| 796 | * String number (0 length -> null) |
| 797 | * int32_t timeSeconds |
| 798 | */ |
| 799 | static void |
| 800 | dispatchCallForward(Parcel &p, RequestInfo *pRI) { |
| 801 | RIL_CallForwardInfo cff; |
| 802 | int32_t t; |
| 803 | status_t status; |
| 804 | |
| 805 | memset (&cff, 0, sizeof(cff)); |
| 806 | |
| 807 | // note we only check status at the end |
| 808 | |
| 809 | status = p.readInt32(&t); |
| 810 | cff.status = (int)t; |
| 811 | |
| 812 | status = p.readInt32(&t); |
| 813 | cff.reason = (int)t; |
| 814 | |
| 815 | status = p.readInt32(&t); |
| 816 | cff.serviceClass = (int)t; |
| 817 | |
| 818 | status = p.readInt32(&t); |
| 819 | cff.toa = (int)t; |
| 820 | |
| 821 | cff.number = strdupReadString(p); |
| 822 | |
| 823 | status = p.readInt32(&t); |
| 824 | cff.timeSeconds = (int)t; |
| 825 | |
| 826 | if (status != NO_ERROR) { |
| 827 | goto invalid; |
| 828 | } |
| 829 | |
| 830 | // special case: number 0-length fields is null |
| 831 | |
| 832 | if (cff.number != NULL && strlen (cff.number) == 0) { |
| 833 | cff.number = NULL; |
| 834 | } |
| 835 | |
| 836 | startRequest; |
| 837 | appendPrintBuf("%sstat=%d,reason=%d,serv=%d,toa=%d,%s,tout=%d", printBuf, |
| 838 | cff.status, cff.reason, cff.serviceClass, cff.toa, |
| 839 | (char*)cff.number, cff.timeSeconds); |
| 840 | closeRequest; |
| 841 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 842 | |
| 843 | s_callbacks.onRequest(pRI->pCI->requestNumber, &cff, sizeof(cff), pRI); |
| 844 | |
| 845 | #ifdef MEMSET_FREED |
| 846 | memsetString(cff.number); |
| 847 | #endif |
| 848 | |
| 849 | free (cff.number); |
| 850 | |
| 851 | #ifdef MEMSET_FREED |
| 852 | memset(&cff, 0, sizeof(cff)); |
| 853 | #endif |
| 854 | |
| 855 | return; |
| 856 | invalid: |
| 857 | invalidCommandBlock(pRI); |
| 858 | return; |
| 859 | } |
| 860 | |
| 861 | |
| 862 | static void |
| 863 | dispatchRaw(Parcel &p, RequestInfo *pRI) { |
| 864 | int32_t len; |
| 865 | status_t status; |
| 866 | const void *data; |
| 867 | |
| 868 | status = p.readInt32(&len); |
| 869 | |
| 870 | if (status != NO_ERROR) { |
| 871 | goto invalid; |
| 872 | } |
| 873 | |
| 874 | // The java code writes -1 for null arrays |
| 875 | if (((int)len) == -1) { |
| 876 | data = NULL; |
| 877 | len = 0; |
| 878 | } |
| 879 | |
| 880 | data = p.readInplace(len); |
| 881 | |
| 882 | startRequest; |
| 883 | appendPrintBuf("%sraw_size=%d", printBuf, len); |
| 884 | closeRequest; |
| 885 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 886 | |
| 887 | s_callbacks.onRequest(pRI->pCI->requestNumber, const_cast<void *>(data), len, pRI); |
| 888 | |
| 889 | return; |
| 890 | invalid: |
| 891 | invalidCommandBlock(pRI); |
| 892 | return; |
| 893 | } |
| 894 | |
| 895 | static void |
| 896 | dispatchCdmaSms(Parcel &p, RequestInfo *pRI) { |
| 897 | RIL_CDMA_SMS_Message rcsm; |
| 898 | int32_t t; |
| 899 | uint8_t ut; |
| 900 | status_t status; |
| 901 | int32_t digitCount; |
| 902 | int digitLimit; |
| 903 | |
| 904 | memset(&rcsm, 0, sizeof(rcsm)); |
| 905 | |
| 906 | status = p.readInt32(&t); |
| 907 | rcsm.uTeleserviceID = (int) t; |
| 908 | |
| 909 | status = p.read(&ut,sizeof(ut)); |
| 910 | rcsm.bIsServicePresent = (uint8_t) ut; |
| 911 | |
| 912 | status = p.readInt32(&t); |
| 913 | rcsm.uServicecategory = (int) t; |
| 914 | |
| 915 | status = p.readInt32(&t); |
| 916 | rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) t; |
| 917 | |
| 918 | status = p.readInt32(&t); |
| 919 | rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) t; |
| 920 | |
| 921 | status = p.readInt32(&t); |
| 922 | rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) t; |
| 923 | |
| 924 | status = p.readInt32(&t); |
| 925 | rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) t; |
| 926 | |
| 927 | status = p.read(&ut,sizeof(ut)); |
| 928 | rcsm.sAddress.number_of_digits= (uint8_t) ut; |
| 929 | |
| 930 | digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX); |
| 931 | for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { |
| 932 | status = p.read(&ut,sizeof(ut)); |
| 933 | rcsm.sAddress.digits[digitCount] = (uint8_t) ut; |
| 934 | } |
| 935 | |
| 936 | status = p.readInt32(&t); |
| 937 | rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) t; |
| 938 | |
| 939 | status = p.read(&ut,sizeof(ut)); |
| 940 | rcsm.sSubAddress.odd = (uint8_t) ut; |
| 941 | |
| 942 | status = p.read(&ut,sizeof(ut)); |
| 943 | rcsm.sSubAddress.number_of_digits = (uint8_t) ut; |
| 944 | |
| 945 | digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX); |
| 946 | for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { |
| 947 | status = p.read(&ut,sizeof(ut)); |
| 948 | rcsm.sSubAddress.digits[digitCount] = (uint8_t) ut; |
| 949 | } |
| 950 | |
| 951 | status = p.readInt32(&t); |
| 952 | rcsm.uBearerDataLen = (int) t; |
| 953 | |
| 954 | digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX); |
| 955 | for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { |
| 956 | status = p.read(&ut, sizeof(ut)); |
| 957 | rcsm.aBearerData[digitCount] = (uint8_t) ut; |
| 958 | } |
| 959 | |
| 960 | if (status != NO_ERROR) { |
| 961 | goto invalid; |
| 962 | } |
| 963 | |
| 964 | startRequest; |
| 965 | appendPrintBuf("%suTeleserviceID=%d, bIsServicePresent=%d, uServicecategory=%d, \ |
| 966 | sAddress.digit_mode=%d, sAddress.Number_mode=%d, sAddress.number_type=%d, ", |
| 967 | printBuf, rcsm.uTeleserviceID,rcsm.bIsServicePresent,rcsm.uServicecategory, |
| 968 | rcsm.sAddress.digit_mode, rcsm.sAddress.number_mode,rcsm.sAddress.number_type); |
| 969 | closeRequest; |
| 970 | |
| 971 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 972 | |
| 973 | s_callbacks.onRequest(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm),pRI); |
| 974 | |
| 975 | #ifdef MEMSET_FREED |
| 976 | memset(&rcsm, 0, sizeof(rcsm)); |
| 977 | #endif |
| 978 | |
| 979 | return; |
| 980 | |
| 981 | invalid: |
| 982 | invalidCommandBlock(pRI); |
| 983 | return; |
| 984 | } |
| 985 | |
| 986 | static void |
| 987 | dispatchCdmaSmsAck(Parcel &p, RequestInfo *pRI) { |
| 988 | RIL_CDMA_SMS_Ack rcsa; |
| 989 | int32_t t; |
| 990 | status_t status; |
| 991 | int32_t digitCount; |
| 992 | |
| 993 | memset(&rcsa, 0, sizeof(rcsa)); |
| 994 | |
| 995 | status = p.readInt32(&t); |
| 996 | rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) t; |
| 997 | |
| 998 | status = p.readInt32(&t); |
| 999 | rcsa.uSMSCauseCode = (int) t; |
| 1000 | |
| 1001 | if (status != NO_ERROR) { |
| 1002 | goto invalid; |
| 1003 | } |
| 1004 | |
| 1005 | startRequest; |
| 1006 | appendPrintBuf("%suErrorClass=%d, uTLStatus=%d, ", |
| 1007 | printBuf, rcsa.uErrorClass, rcsa.uSMSCauseCode); |
| 1008 | closeRequest; |
| 1009 | |
| 1010 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 1011 | |
| 1012 | s_callbacks.onRequest(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa),pRI); |
| 1013 | |
| 1014 | #ifdef MEMSET_FREED |
| 1015 | memset(&rcsa, 0, sizeof(rcsa)); |
| 1016 | #endif |
| 1017 | |
| 1018 | return; |
| 1019 | |
| 1020 | invalid: |
| 1021 | invalidCommandBlock(pRI); |
| 1022 | return; |
| 1023 | } |
| 1024 | |
| 1025 | static void |
| 1026 | dispatchGsmBrSmsCnf(Parcel &p, RequestInfo *pRI) { |
| 1027 | int32_t t; |
| 1028 | status_t status; |
| 1029 | int32_t num; |
| 1030 | |
| 1031 | status = p.readInt32(&num); |
| 1032 | if (status != NO_ERROR) { |
| 1033 | goto invalid; |
| 1034 | } |
| 1035 | |
| 1036 | RIL_GSM_BroadcastSmsConfigInfo gsmBci[num]; |
| 1037 | RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num]; |
| 1038 | |
| 1039 | startRequest; |
| 1040 | for (int i = 0 ; i < num ; i++ ) { |
| 1041 | gsmBciPtrs[i] = &gsmBci[i]; |
| 1042 | |
| 1043 | status = p.readInt32(&t); |
| 1044 | gsmBci[i].fromServiceId = (int) t; |
| 1045 | |
| 1046 | status = p.readInt32(&t); |
| 1047 | gsmBci[i].toServiceId = (int) t; |
| 1048 | |
| 1049 | status = p.readInt32(&t); |
| 1050 | gsmBci[i].fromCodeScheme = (int) t; |
| 1051 | |
| 1052 | status = p.readInt32(&t); |
| 1053 | gsmBci[i].toCodeScheme = (int) t; |
| 1054 | |
| 1055 | status = p.readInt32(&t); |
| 1056 | gsmBci[i].selected = (uint8_t) t; |
| 1057 | |
| 1058 | appendPrintBuf("%s [%d: fromServiceId=%d, toServiceId =%d, \ |
| 1059 | fromCodeScheme=%d, toCodeScheme=%d, selected =%d]", printBuf, i, |
| 1060 | gsmBci[i].fromServiceId, gsmBci[i].toServiceId, |
| 1061 | gsmBci[i].fromCodeScheme, gsmBci[i].toCodeScheme, |
| 1062 | gsmBci[i].selected); |
| 1063 | } |
| 1064 | closeRequest; |
| 1065 | |
| 1066 | if (status != NO_ERROR) { |
| 1067 | goto invalid; |
| 1068 | } |
| 1069 | |
| 1070 | s_callbacks.onRequest(pRI->pCI->requestNumber, |
| 1071 | gsmBciPtrs, |
| 1072 | num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), |
| 1073 | pRI); |
| 1074 | |
| 1075 | #ifdef MEMSET_FREED |
| 1076 | memset(gsmBci, 0, num * sizeof(RIL_GSM_BroadcastSmsConfigInfo)); |
| 1077 | memset(gsmBciPtrs, 0, num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *)); |
| 1078 | #endif |
| 1079 | |
| 1080 | return; |
| 1081 | |
| 1082 | invalid: |
| 1083 | invalidCommandBlock(pRI); |
| 1084 | return; |
| 1085 | } |
| 1086 | |
| 1087 | static void |
| 1088 | dispatchCdmaBrSmsCnf(Parcel &p, RequestInfo *pRI) { |
| 1089 | int32_t t; |
| 1090 | status_t status; |
| 1091 | int32_t num; |
| 1092 | |
| 1093 | status = p.readInt32(&num); |
| 1094 | if (status != NO_ERROR) { |
| 1095 | goto invalid; |
| 1096 | } |
| 1097 | |
| 1098 | RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num]; |
| 1099 | RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num]; |
| 1100 | |
| 1101 | startRequest; |
| 1102 | for (int i = 0 ; i < num ; i++ ) { |
| 1103 | cdmaBciPtrs[i] = &cdmaBci[i]; |
| 1104 | |
| 1105 | status = p.readInt32(&t); |
| 1106 | cdmaBci[i].service_category = (int) t; |
| 1107 | |
| 1108 | status = p.readInt32(&t); |
| 1109 | cdmaBci[i].language = (int) t; |
| 1110 | |
| 1111 | status = p.readInt32(&t); |
| 1112 | cdmaBci[i].selected = (uint8_t) t; |
| 1113 | |
| 1114 | appendPrintBuf("%s [%d: service_category=%d, language =%d, \ |
| 1115 | entries.bSelected =%d]", printBuf, i, cdmaBci[i].service_category, |
| 1116 | cdmaBci[i].language, cdmaBci[i].selected); |
| 1117 | } |
| 1118 | closeRequest; |
| 1119 | |
| 1120 | if (status != NO_ERROR) { |
| 1121 | goto invalid; |
| 1122 | } |
| 1123 | |
| 1124 | s_callbacks.onRequest(pRI->pCI->requestNumber, |
| 1125 | cdmaBciPtrs, |
| 1126 | num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), |
| 1127 | pRI); |
| 1128 | |
| 1129 | #ifdef MEMSET_FREED |
| 1130 | memset(cdmaBci, 0, num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo)); |
| 1131 | memset(cdmaBciPtrs, 0, num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *)); |
| 1132 | #endif |
| 1133 | |
| 1134 | return; |
| 1135 | |
| 1136 | invalid: |
| 1137 | invalidCommandBlock(pRI); |
| 1138 | return; |
| 1139 | } |
| 1140 | |
| 1141 | static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI) { |
| 1142 | RIL_CDMA_SMS_WriteArgs rcsw; |
| 1143 | int32_t t; |
| 1144 | uint32_t ut; |
| 1145 | uint8_t uct; |
| 1146 | status_t status; |
| 1147 | int32_t digitCount; |
| 1148 | |
| 1149 | memset(&rcsw, 0, sizeof(rcsw)); |
| 1150 | |
| 1151 | status = p.readInt32(&t); |
| 1152 | rcsw.status = t; |
| 1153 | |
| 1154 | status = p.readInt32(&t); |
| 1155 | rcsw.message.uTeleserviceID = (int) t; |
| 1156 | |
| 1157 | status = p.read(&uct,sizeof(uct)); |
| 1158 | rcsw.message.bIsServicePresent = (uint8_t) uct; |
| 1159 | |
| 1160 | status = p.readInt32(&t); |
| 1161 | rcsw.message.uServicecategory = (int) t; |
| 1162 | |
| 1163 | status = p.readInt32(&t); |
| 1164 | rcsw.message.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) t; |
| 1165 | |
| 1166 | status = p.readInt32(&t); |
| 1167 | rcsw.message.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) t; |
| 1168 | |
| 1169 | status = p.readInt32(&t); |
| 1170 | rcsw.message.sAddress.number_type = (RIL_CDMA_SMS_NumberType) t; |
| 1171 | |
| 1172 | status = p.readInt32(&t); |
| 1173 | rcsw.message.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) t; |
| 1174 | |
| 1175 | status = p.read(&uct,sizeof(uct)); |
| 1176 | rcsw.message.sAddress.number_of_digits = (uint8_t) uct; |
| 1177 | |
| 1178 | for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_ADDRESS_MAX; digitCount ++) { |
| 1179 | status = p.read(&uct,sizeof(uct)); |
| 1180 | rcsw.message.sAddress.digits[digitCount] = (uint8_t) uct; |
| 1181 | } |
| 1182 | |
| 1183 | status = p.readInt32(&t); |
| 1184 | rcsw.message.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) t; |
| 1185 | |
| 1186 | status = p.read(&uct,sizeof(uct)); |
| 1187 | rcsw.message.sSubAddress.odd = (uint8_t) uct; |
| 1188 | |
| 1189 | status = p.read(&uct,sizeof(uct)); |
| 1190 | rcsw.message.sSubAddress.number_of_digits = (uint8_t) uct; |
| 1191 | |
| 1192 | for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_SUBADDRESS_MAX; digitCount ++) { |
| 1193 | status = p.read(&uct,sizeof(uct)); |
| 1194 | rcsw.message.sSubAddress.digits[digitCount] = (uint8_t) uct; |
| 1195 | } |
| 1196 | |
| 1197 | status = p.readInt32(&t); |
| 1198 | rcsw.message.uBearerDataLen = (int) t; |
| 1199 | |
| 1200 | for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_BEARER_DATA_MAX; digitCount ++) { |
| 1201 | status = p.read(&uct, sizeof(uct)); |
| 1202 | rcsw.message.aBearerData[digitCount] = (uint8_t) uct; |
| 1203 | } |
| 1204 | |
| 1205 | if (status != NO_ERROR) { |
| 1206 | goto invalid; |
| 1207 | } |
| 1208 | |
| 1209 | startRequest; |
| 1210 | appendPrintBuf("%sstatus=%d, message.uTeleserviceID=%d, message.bIsServicePresent=%d, \ |
| 1211 | message.uServicecategory=%d, message.sAddress.digit_mode=%d, \ |
| 1212 | message.sAddress.number_mode=%d, \ |
| 1213 | message.sAddress.number_type=%d, ", |
| 1214 | printBuf, rcsw.status, rcsw.message.uTeleserviceID, rcsw.message.bIsServicePresent, |
| 1215 | rcsw.message.uServicecategory, rcsw.message.sAddress.digit_mode, |
| 1216 | rcsw.message.sAddress.number_mode, |
| 1217 | rcsw.message.sAddress.number_type); |
| 1218 | closeRequest; |
| 1219 | |
| 1220 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 1221 | |
| 1222 | s_callbacks.onRequest(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw),pRI); |
| 1223 | |
| 1224 | #ifdef MEMSET_FREED |
| 1225 | memset(&rcsw, 0, sizeof(rcsw)); |
| 1226 | #endif |
| 1227 | |
| 1228 | return; |
| 1229 | |
| 1230 | invalid: |
| 1231 | invalidCommandBlock(pRI); |
| 1232 | return; |
| 1233 | |
| 1234 | } |
| 1235 | |
| 1236 | static int |
| 1237 | blockingWrite(int fd, const void *buffer, size_t len) { |
| 1238 | size_t writeOffset = 0; |
| 1239 | const uint8_t *toWrite; |
| 1240 | |
| 1241 | toWrite = (const uint8_t *)buffer; |
| 1242 | |
| 1243 | while (writeOffset < len) { |
| 1244 | ssize_t written; |
| 1245 | do { |
| 1246 | written = write (fd, toWrite + writeOffset, |
| 1247 | len - writeOffset); |
| 1248 | } while (written < 0 && errno == EINTR); |
| 1249 | |
| 1250 | if (written >= 0) { |
| 1251 | writeOffset += written; |
| 1252 | } else { // written < 0 |
| 1253 | ALOGE ("RIL Response: unexpected error on write errno:%d", errno); |
| 1254 | close(fd); |
| 1255 | return -1; |
| 1256 | } |
| 1257 | } |
| 1258 | |
| 1259 | return 0; |
| 1260 | } |
| 1261 | |
| 1262 | static int |
| 1263 | sendResponseRaw (const void *data, size_t dataSize) { |
| 1264 | int fd = s_fdCommand; |
| 1265 | int ret; |
| 1266 | uint32_t header; |
| 1267 | |
| 1268 | if (s_fdCommand < 0) { |
| 1269 | return -1; |
| 1270 | } |
| 1271 | |
| 1272 | if (dataSize > MAX_COMMAND_BYTES) { |
| 1273 | ALOGE("RIL: packet larger than %u (%u)", |
| 1274 | MAX_COMMAND_BYTES, (unsigned int )dataSize); |
| 1275 | |
| 1276 | return -1; |
| 1277 | } |
| 1278 | |
| 1279 | pthread_mutex_lock(&s_writeMutex); |
| 1280 | |
| 1281 | header = htonl(dataSize); |
| 1282 | |
| 1283 | ret = blockingWrite(fd, (void *)&header, sizeof(header)); |
| 1284 | |
| 1285 | if (ret < 0) { |
| 1286 | pthread_mutex_unlock(&s_writeMutex); |
| 1287 | return ret; |
| 1288 | } |
| 1289 | |
| 1290 | ret = blockingWrite(fd, data, dataSize); |
| 1291 | |
| 1292 | if (ret < 0) { |
| 1293 | pthread_mutex_unlock(&s_writeMutex); |
| 1294 | return ret; |
| 1295 | } |
| 1296 | |
| 1297 | pthread_mutex_unlock(&s_writeMutex); |
| 1298 | |
| 1299 | return 0; |
| 1300 | } |
| 1301 | |
| 1302 | static int |
| 1303 | sendResponse (Parcel &p) { |
| 1304 | printResponse; |
| 1305 | return sendResponseRaw(p.data(), p.dataSize()); |
| 1306 | } |
| 1307 | |
| 1308 | /** response is an int* pointing to an array of ints*/ |
| 1309 | |
| 1310 | static int |
| 1311 | responseInts(Parcel &p, void *response, size_t responselen) { |
| 1312 | int numInts; |
| 1313 | |
| 1314 | if (response == NULL && responselen != 0) { |
| 1315 | ALOGE("invalid response: NULL"); |
| 1316 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1317 | } |
| 1318 | if (responselen % sizeof(int) != 0) { |
| 1319 | ALOGE("invalid response length %d expected multiple of %d\n", |
| 1320 | (int)responselen, (int)sizeof(int)); |
| 1321 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1322 | } |
| 1323 | |
| 1324 | int *p_int = (int *) response; |
| 1325 | |
| 1326 | numInts = responselen / sizeof(int *); |
| 1327 | p.writeInt32 (numInts); |
| 1328 | |
| 1329 | /* each int*/ |
| 1330 | startResponse; |
| 1331 | for (int i = 0 ; i < numInts ; i++) { |
| 1332 | appendPrintBuf("%s%d,", printBuf, p_int[i]); |
| 1333 | p.writeInt32(p_int[i]); |
| 1334 | } |
| 1335 | removeLastChar; |
| 1336 | closeResponse; |
| 1337 | |
| 1338 | return 0; |
| 1339 | } |
| 1340 | |
| 1341 | static int |
| 1342 | responseIntsGetPreferredNetworkType(Parcel &p, void *response, size_t responselen) { |
| 1343 | int numInts; |
| 1344 | |
| 1345 | if (response == NULL && responselen != 0) { |
| 1346 | ALOGE("invalid response: NULL"); |
| 1347 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1348 | } |
| 1349 | if (responselen % sizeof(int) != 0) { |
| 1350 | ALOGE("invalid response length %d expected multiple of %d\n", |
| 1351 | (int)responselen, (int)sizeof(int)); |
| 1352 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1353 | } |
| 1354 | |
| 1355 | int *p_int = (int *) response; |
| 1356 | |
| 1357 | numInts = responselen / sizeof(int *); |
| 1358 | p.writeInt32 (numInts); |
| 1359 | |
| 1360 | /* each int*/ |
| 1361 | startResponse; |
| 1362 | for (int i = 0 ; i < numInts ; i++) { |
| 1363 | if (i == 0 && p_int[0] == 7) { |
| 1364 | ALOGE("REQUEST_GET_PREFERRED_NETWORK_TYPE: NETWORK_MODE_GLOBAL => NETWORK_MODE_WCDMA_PREF"); |
| 1365 | p_int[0] = 0; |
| 1366 | } |
| 1367 | appendPrintBuf("%s%d,", printBuf, p_int[i]); |
| 1368 | p.writeInt32(p_int[i]); |
| 1369 | } |
| 1370 | removeLastChar; |
| 1371 | closeResponse; |
| 1372 | |
| 1373 | return 0; |
| 1374 | } |
| 1375 | |
| 1376 | /** response is a char **, pointing to an array of char *'s |
| 1377 | The parcel will begin with the version */ |
| 1378 | static int responseStringsWithVersion(int version, Parcel &p, void *response, size_t responselen) { |
| 1379 | p.writeInt32(version); |
| 1380 | return responseStrings(p, response, responselen); |
| 1381 | } |
| 1382 | |
| 1383 | /** response is a char **, pointing to an array of char *'s */ |
| 1384 | static int responseStrings(Parcel &p, void *response, size_t responselen) { |
| 1385 | return responseStrings(p, response, responselen, false); |
| 1386 | } |
| 1387 | |
| 1388 | static int responseStringsNetworks(Parcel &p, void *response, size_t responselen) { |
| 1389 | int numStrings; |
| 1390 | int inQANElements = 5; |
| 1391 | int outQANElements = 4; |
| 1392 | |
| 1393 | if (response == NULL && responselen != 0) { |
| 1394 | ALOGE("invalid response: NULL"); |
| 1395 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1396 | } |
| 1397 | if (responselen % sizeof(char *) != 0) { |
| 1398 | ALOGE("invalid response length %d expected multiple of %d\n", |
| 1399 | (int)responselen, (int)sizeof(char *)); |
| 1400 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1401 | } |
| 1402 | |
| 1403 | if (response == NULL) { |
| 1404 | p.writeInt32 (0); |
| 1405 | } else { |
| 1406 | char **p_cur = (char **) response; |
| 1407 | |
| 1408 | numStrings = responselen / sizeof(char *); |
| 1409 | p.writeInt32 ((numStrings / inQANElements) * outQANElements); |
| 1410 | |
| 1411 | /* each string*/ |
| 1412 | startResponse; |
| 1413 | int j=0; |
| 1414 | for (int i = 0 ; i < numStrings ; i++) { |
| 1415 | /* Samsung is sending 5 elements, upper layer expects 4. |
| 1416 | Drop every 5th element here */ |
| 1417 | if (j == outQANElements) { |
| 1418 | j=0; |
| 1419 | } else { |
| 1420 | appendPrintBuf("%s%s,", printBuf, (char*)p_cur[i]); |
| 1421 | writeStringToParcel (p, p_cur[i]); |
| 1422 | j++; |
| 1423 | } |
| 1424 | } |
| 1425 | removeLastChar; |
| 1426 | closeResponse; |
| 1427 | } |
| 1428 | return 0; |
| 1429 | } |
| 1430 | |
| 1431 | /** response is a char **, pointing to an array of char *'s */ |
| 1432 | static int responseStrings(Parcel &p, void *response, size_t responselen, bool network_search) { |
| 1433 | int numStrings; |
| 1434 | |
| 1435 | if (response == NULL && responselen != 0) { |
| 1436 | ALOGE("invalid response: NULL"); |
| 1437 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1438 | } |
| 1439 | if (responselen % sizeof(char *) != 0) { |
| 1440 | ALOGE("invalid response length %d expected multiple of %d\n", |
| 1441 | (int)responselen, (int)sizeof(char *)); |
| 1442 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1443 | } |
| 1444 | |
| 1445 | if (response == NULL) { |
| 1446 | p.writeInt32 (0); |
| 1447 | } else { |
| 1448 | char **p_cur = (char **) response; |
| 1449 | |
| 1450 | numStrings = responselen / sizeof(char *); |
| 1451 | p.writeInt32 (numStrings); |
| 1452 | |
| 1453 | /* each string*/ |
| 1454 | startResponse; |
| 1455 | for (int i = 0 ; i < numStrings ; i++) { |
| 1456 | appendPrintBuf("%s%s,", printBuf, (char*)p_cur[i]); |
| 1457 | writeStringToParcel (p, p_cur[i]); |
| 1458 | } |
| 1459 | removeLastChar; |
| 1460 | closeResponse; |
| 1461 | } |
| 1462 | return 0; |
| 1463 | } |
| 1464 | |
| 1465 | /** |
| 1466 | * NULL strings are accepted |
| 1467 | * FIXME currently ignores responselen |
| 1468 | */ |
| 1469 | static int responseString(Parcel &p, void *response, size_t responselen) { |
| 1470 | /* one string only */ |
| 1471 | startResponse; |
| 1472 | appendPrintBuf("%s%s", printBuf, (char*)response); |
| 1473 | closeResponse; |
| 1474 | |
| 1475 | writeStringToParcel(p, (const char *)response); |
| 1476 | |
| 1477 | return 0; |
| 1478 | } |
| 1479 | |
| 1480 | static int responseVoid(Parcel &p, void *response, size_t responselen) { |
| 1481 | startResponse; |
| 1482 | removeLastChar; |
| 1483 | return 0; |
| 1484 | } |
| 1485 | |
| 1486 | static int responseCallList(Parcel &p, void *response, size_t responselen) { |
| 1487 | int num; |
| 1488 | |
| 1489 | if (response == NULL && responselen != 0) { |
| 1490 | ALOGE("invalid response: NULL"); |
| 1491 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1492 | } |
| 1493 | |
| 1494 | if (responselen % sizeof (RIL_Call *) != 0) { |
| 1495 | ALOGE("invalid response length %d expected multiple of %d\n", |
| 1496 | (int)responselen, (int)sizeof (RIL_Call *)); |
| 1497 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1498 | } |
| 1499 | |
| 1500 | startResponse; |
| 1501 | /* number of call info's */ |
| 1502 | num = responselen / sizeof(RIL_Call *); |
| 1503 | p.writeInt32(num); |
| 1504 | |
| 1505 | for (int i = 0 ; i < num ; i++) { |
| 1506 | RIL_Call *p_cur = ((RIL_Call **) response)[i]; |
| 1507 | /* each call info */ |
| 1508 | p.writeInt32(p_cur->state); |
| 1509 | p.writeInt32(p_cur->index); |
| 1510 | p.writeInt32(p_cur->toa); |
| 1511 | p.writeInt32(p_cur->isMpty); |
| 1512 | p.writeInt32(p_cur->isMT); |
| 1513 | p.writeInt32(p_cur->als); |
| 1514 | p.writeInt32(p_cur->isVoice); |
| 1515 | p.writeInt32(p_cur->isVoicePrivacy); |
| 1516 | writeStringToParcel(p, p_cur->number); |
| 1517 | p.writeInt32(p_cur->numberPresentation); |
| 1518 | writeStringToParcel(p, p_cur->name); |
| 1519 | p.writeInt32(p_cur->namePresentation); |
Daniel Hillenbrand | ea4af61 | 2013-07-09 18:47:06 +0200 | [diff] [blame^] | 1520 | // Remove when partners upgrade to version 3 |
| 1521 | if ((s_callbacks.version < 3) || (p_cur->uusInfo == NULL || p_cur->uusInfo->uusData == NULL)) { |
| 1522 | p.writeInt32(0); /* UUS Information is absent */ |
| 1523 | } else { |
| 1524 | RIL_UUS_Info *uusInfo = p_cur->uusInfo; |
| 1525 | p.writeInt32(1); /* UUS Information is present */ |
| 1526 | p.writeInt32(uusInfo->uusType); |
| 1527 | p.writeInt32(uusInfo->uusDcs); |
| 1528 | p.writeInt32(uusInfo->uusLength); |
| 1529 | p.write(uusInfo->uusData, uusInfo->uusLength); |
| 1530 | } |
Daniel Hillenbrand | 601dc85 | 2013-07-07 10:06:59 +0200 | [diff] [blame] | 1531 | appendPrintBuf("%s[id=%d,%s,toa=%d,", |
| 1532 | printBuf, |
| 1533 | p_cur->index, |
| 1534 | callStateToString(p_cur->state), |
| 1535 | p_cur->toa); |
| 1536 | appendPrintBuf("%s%s,%s,als=%d,%s,%s,", |
| 1537 | printBuf, |
| 1538 | (p_cur->isMpty)?"conf":"norm", |
| 1539 | (p_cur->isMT)?"mt":"mo", |
| 1540 | p_cur->als, |
| 1541 | (p_cur->isVoice)?"voc":"nonvoc", |
| 1542 | (p_cur->isVoicePrivacy)?"evp":"noevp"); |
| 1543 | appendPrintBuf("%s%s,cli=%d,name='%s',%d]", |
| 1544 | printBuf, |
| 1545 | p_cur->number, |
| 1546 | p_cur->numberPresentation, |
| 1547 | p_cur->name, |
| 1548 | p_cur->namePresentation); |
| 1549 | } |
| 1550 | removeLastChar; |
| 1551 | closeResponse; |
| 1552 | |
| 1553 | return 0; |
| 1554 | } |
| 1555 | |
| 1556 | static int responseSMS(Parcel &p, void *response, size_t responselen) { |
| 1557 | if (response == NULL) { |
| 1558 | ALOGE("invalid response: NULL"); |
| 1559 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1560 | } |
| 1561 | |
| 1562 | if (responselen != sizeof (RIL_SMS_Response) ) { |
| 1563 | ALOGE("invalid response length %d expected %d", |
| 1564 | (int)responselen, (int)sizeof (RIL_SMS_Response)); |
| 1565 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1566 | } |
| 1567 | |
| 1568 | RIL_SMS_Response *p_cur = (RIL_SMS_Response *) response; |
| 1569 | |
| 1570 | p.writeInt32(p_cur->messageRef); |
| 1571 | writeStringToParcel(p, p_cur->ackPDU); |
| 1572 | p.writeInt32(p_cur->errorCode); |
| 1573 | |
| 1574 | startResponse; |
| 1575 | appendPrintBuf("%s%d,%s,%d", printBuf, p_cur->messageRef, |
| 1576 | (char*)p_cur->ackPDU, p_cur->errorCode); |
| 1577 | closeResponse; |
| 1578 | |
| 1579 | return 0; |
| 1580 | } |
| 1581 | |
| 1582 | static int responseDataCallList(Parcel &p, void *response, size_t responselen) |
| 1583 | { |
| 1584 | // Write version |
| 1585 | p.writeInt32(s_callbacks.version); |
| 1586 | |
| 1587 | if (response == NULL && responselen != 0) { |
| 1588 | ALOGE("invalid response: NULL"); |
| 1589 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1590 | } |
| 1591 | |
| 1592 | if (responselen % sizeof(RIL_Data_Call_Response_v6) != 0) { |
| 1593 | ALOGE("invalid response length %d expected multiple of %d", |
| 1594 | (int)responselen, (int)sizeof(RIL_Data_Call_Response_v6)); |
| 1595 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1596 | } |
| 1597 | |
| 1598 | int num = responselen / sizeof(RIL_Data_Call_Response_v6); |
| 1599 | p.writeInt32(num); |
| 1600 | |
| 1601 | RIL_Data_Call_Response_v6 *p_cur = (RIL_Data_Call_Response_v6 *) response; |
| 1602 | startResponse; |
| 1603 | |
| 1604 | for (int i = 0; i < num; i++) { |
| 1605 | p.writeInt32((int)p_cur[i].status); |
| 1606 | p.writeInt32(p_cur[i].suggestedRetryTime); |
| 1607 | p.writeInt32(p_cur[i].cid); |
| 1608 | p.writeInt32(p_cur[i].active); |
| 1609 | writeStringToParcel(p, p_cur[i].type); |
| 1610 | writeStringToParcel(p, p_cur[i].ifname); |
| 1611 | writeStringToParcel(p, p_cur[i].addresses); |
| 1612 | writeStringToParcel(p, p_cur[i].dnses); |
| 1613 | writeStringToParcel(p, p_cur[i].gateways); |
| 1614 | appendPrintBuf("%s[status=%d,retry=%d,cid=%d,%s,%s,%s,%s,%s,%s],", printBuf, |
| 1615 | p_cur[i].status, |
| 1616 | p_cur[i].suggestedRetryTime, |
| 1617 | p_cur[i].cid, |
| 1618 | (p_cur[i].active==0)?"down":"up", |
| 1619 | (char*)p_cur[i].type, |
| 1620 | (char*)p_cur[i].ifname, |
| 1621 | (char*)p_cur[i].addresses, |
| 1622 | (char*)p_cur[i].dnses, |
| 1623 | (char*)p_cur[i].gateways); |
| 1624 | } |
| 1625 | removeLastChar; |
| 1626 | closeResponse; |
| 1627 | |
| 1628 | return 0; |
| 1629 | } |
| 1630 | |
| 1631 | static int responseRaw(Parcel &p, void *response, size_t responselen) { |
| 1632 | if (response == NULL && responselen != 0) { |
| 1633 | ALOGE("invalid response: NULL with responselen != 0"); |
| 1634 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1635 | } |
| 1636 | |
| 1637 | // The java code reads -1 size as null byte array |
| 1638 | if (response == NULL) { |
| 1639 | p.writeInt32(-1); |
| 1640 | } else { |
| 1641 | p.writeInt32(responselen); |
| 1642 | p.write(response, responselen); |
| 1643 | } |
| 1644 | |
| 1645 | return 0; |
| 1646 | } |
| 1647 | |
| 1648 | |
| 1649 | static int responseSIM_IO(Parcel &p, void *response, size_t responselen) { |
| 1650 | if (response == NULL) { |
| 1651 | ALOGE("invalid response: NULL"); |
| 1652 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1653 | } |
| 1654 | |
| 1655 | if (responselen != sizeof (RIL_SIM_IO_Response) ) { |
| 1656 | ALOGE("invalid response length was %d expected %d", |
| 1657 | (int)responselen, (int)sizeof (RIL_SIM_IO_Response)); |
| 1658 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1659 | } |
| 1660 | |
| 1661 | RIL_SIM_IO_Response *p_cur = (RIL_SIM_IO_Response *) response; |
| 1662 | p.writeInt32(p_cur->sw1); |
| 1663 | p.writeInt32(p_cur->sw2); |
| 1664 | writeStringToParcel(p, p_cur->simResponse); |
| 1665 | |
| 1666 | startResponse; |
| 1667 | appendPrintBuf("%ssw1=0x%X,sw2=0x%X,%s", printBuf, p_cur->sw1, p_cur->sw2, |
| 1668 | (char*)p_cur->simResponse); |
| 1669 | closeResponse; |
| 1670 | |
| 1671 | |
| 1672 | return 0; |
| 1673 | } |
| 1674 | |
| 1675 | static int responseCallForwards(Parcel &p, void *response, size_t responselen) { |
| 1676 | int num; |
| 1677 | |
| 1678 | if (response == NULL && responselen != 0) { |
| 1679 | ALOGE("invalid response: NULL"); |
| 1680 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1681 | } |
| 1682 | |
| 1683 | if (responselen % sizeof(RIL_CallForwardInfo *) != 0) { |
| 1684 | ALOGE("invalid response length %d expected multiple of %d", |
| 1685 | (int)responselen, (int)sizeof(RIL_CallForwardInfo *)); |
| 1686 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1687 | } |
| 1688 | |
| 1689 | /* number of call info's */ |
| 1690 | num = responselen / sizeof(RIL_CallForwardInfo *); |
| 1691 | p.writeInt32(num); |
| 1692 | |
| 1693 | startResponse; |
| 1694 | for (int i = 0 ; i < num ; i++) { |
| 1695 | RIL_CallForwardInfo *p_cur = ((RIL_CallForwardInfo **) response)[i]; |
| 1696 | |
| 1697 | p.writeInt32(p_cur->status); |
| 1698 | p.writeInt32(p_cur->reason); |
| 1699 | p.writeInt32(p_cur->serviceClass); |
| 1700 | p.writeInt32(p_cur->toa); |
| 1701 | writeStringToParcel(p, p_cur->number); |
| 1702 | p.writeInt32(p_cur->timeSeconds); |
| 1703 | appendPrintBuf("%s[%s,reason=%d,cls=%d,toa=%d,%s,tout=%d],", printBuf, |
| 1704 | (p_cur->status==1)?"enable":"disable", |
| 1705 | p_cur->reason, p_cur->serviceClass, p_cur->toa, |
| 1706 | (char*)p_cur->number, |
| 1707 | p_cur->timeSeconds); |
| 1708 | } |
| 1709 | removeLastChar; |
| 1710 | closeResponse; |
| 1711 | |
| 1712 | return 0; |
| 1713 | } |
| 1714 | |
| 1715 | static int responseSsn(Parcel &p, void *response, size_t responselen) { |
| 1716 | if (response == NULL) { |
| 1717 | ALOGE("invalid response: NULL"); |
| 1718 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1719 | } |
| 1720 | |
| 1721 | if (responselen != sizeof(RIL_SuppSvcNotification)) { |
| 1722 | ALOGE("invalid response length was %d expected %d", |
| 1723 | (int)responselen, (int)sizeof (RIL_SuppSvcNotification)); |
| 1724 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1725 | } |
| 1726 | |
| 1727 | RIL_SuppSvcNotification *p_cur = (RIL_SuppSvcNotification *) response; |
| 1728 | p.writeInt32(p_cur->notificationType); |
| 1729 | p.writeInt32(p_cur->code); |
| 1730 | p.writeInt32(p_cur->index); |
| 1731 | p.writeInt32(p_cur->type); |
| 1732 | writeStringToParcel(p, p_cur->number); |
| 1733 | |
| 1734 | startResponse; |
| 1735 | appendPrintBuf("%s%s,code=%d,id=%d,type=%d,%s", printBuf, |
| 1736 | (p_cur->notificationType==0)?"mo":"mt", |
| 1737 | p_cur->code, p_cur->index, p_cur->type, |
| 1738 | (char*)p_cur->number); |
| 1739 | closeResponse; |
| 1740 | |
| 1741 | return 0; |
| 1742 | } |
| 1743 | |
| 1744 | static int responseCellList(Parcel &p, void *response, size_t responselen) { |
| 1745 | int num; |
| 1746 | |
| 1747 | if (response == NULL && responselen != 0) { |
| 1748 | ALOGE("invalid response: NULL"); |
| 1749 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1750 | } |
| 1751 | |
| 1752 | if (responselen % sizeof (RIL_NeighboringCell *) != 0) { |
| 1753 | ALOGE("invalid response length %d expected multiple of %d\n", |
| 1754 | (int)responselen, (int)sizeof (RIL_NeighboringCell *)); |
| 1755 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1756 | } |
| 1757 | |
| 1758 | startResponse; |
| 1759 | /* number of records */ |
| 1760 | num = responselen / sizeof(RIL_NeighboringCell *); |
| 1761 | p.writeInt32(num); |
| 1762 | |
| 1763 | for (int i = 0 ; i < num ; i++) { |
| 1764 | RIL_NeighboringCell *p_cur = ((RIL_NeighboringCell **) response)[i]; |
| 1765 | |
| 1766 | p.writeInt32(p_cur->rssi); |
| 1767 | writeStringToParcel (p, p_cur->cid); |
| 1768 | |
| 1769 | appendPrintBuf("%s[cid=%s,rssi=%d],", printBuf, |
| 1770 | p_cur->cid, p_cur->rssi); |
| 1771 | } |
| 1772 | removeLastChar; |
| 1773 | closeResponse; |
| 1774 | |
| 1775 | return 0; |
| 1776 | } |
| 1777 | |
| 1778 | /** |
| 1779 | * Marshall the signalInfoRecord into the parcel if it exists. |
| 1780 | */ |
| 1781 | static void marshallSignalInfoRecord(Parcel &p, |
| 1782 | RIL_CDMA_SignalInfoRecord &p_signalInfoRecord) { |
| 1783 | p.writeInt32(p_signalInfoRecord.isPresent); |
| 1784 | p.writeInt32(p_signalInfoRecord.signalType); |
| 1785 | p.writeInt32(p_signalInfoRecord.alertPitch); |
| 1786 | p.writeInt32(p_signalInfoRecord.signal); |
| 1787 | } |
| 1788 | |
| 1789 | static int responseCdmaInformationRecords(Parcel &p, |
| 1790 | void *response, size_t responselen) { |
| 1791 | int num; |
| 1792 | char* string8 = NULL; |
| 1793 | int buffer_lenght; |
| 1794 | RIL_CDMA_InformationRecord *infoRec; |
| 1795 | |
| 1796 | if (response == NULL && responselen != 0) { |
| 1797 | ALOGE("invalid response: NULL"); |
| 1798 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1799 | } |
| 1800 | |
| 1801 | if (responselen != sizeof (RIL_CDMA_InformationRecords)) { |
| 1802 | ALOGE("invalid response length %d expected multiple of %d\n", |
| 1803 | (int)responselen, (int)sizeof (RIL_CDMA_InformationRecords *)); |
| 1804 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1805 | } |
| 1806 | |
| 1807 | RIL_CDMA_InformationRecords *p_cur = |
| 1808 | (RIL_CDMA_InformationRecords *) response; |
| 1809 | num = MIN(p_cur->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS); |
| 1810 | |
| 1811 | startResponse; |
| 1812 | p.writeInt32(num); |
| 1813 | |
| 1814 | for (int i = 0 ; i < num ; i++) { |
| 1815 | infoRec = &p_cur->infoRec[i]; |
| 1816 | p.writeInt32(infoRec->name); |
| 1817 | switch (infoRec->name) { |
| 1818 | case RIL_CDMA_DISPLAY_INFO_REC: |
| 1819 | case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: |
| 1820 | if (infoRec->rec.display.alpha_len > |
| 1821 | CDMA_ALPHA_INFO_BUFFER_LENGTH) { |
| 1822 | ALOGE("invalid display info response length %d \ |
| 1823 | expected not more than %d\n", |
| 1824 | (int)infoRec->rec.display.alpha_len, |
| 1825 | CDMA_ALPHA_INFO_BUFFER_LENGTH); |
| 1826 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1827 | } |
| 1828 | string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) |
| 1829 | * sizeof(char) ); |
| 1830 | for (int i = 0 ; i < infoRec->rec.display.alpha_len ; i++) { |
| 1831 | string8[i] = infoRec->rec.display.alpha_buf[i]; |
| 1832 | } |
| 1833 | string8[(int)infoRec->rec.display.alpha_len] = '\0'; |
| 1834 | writeStringToParcel(p, (const char*)string8); |
| 1835 | free(string8); |
| 1836 | string8 = NULL; |
| 1837 | break; |
| 1838 | case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC: |
| 1839 | case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC: |
| 1840 | case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: |
| 1841 | if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) { |
| 1842 | ALOGE("invalid display info response length %d \ |
| 1843 | expected not more than %d\n", |
| 1844 | (int)infoRec->rec.number.len, |
| 1845 | CDMA_NUMBER_INFO_BUFFER_LENGTH); |
| 1846 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1847 | } |
| 1848 | string8 = (char*) malloc((infoRec->rec.number.len + 1) |
| 1849 | * sizeof(char) ); |
| 1850 | for (int i = 0 ; i < infoRec->rec.number.len; i++) { |
| 1851 | string8[i] = infoRec->rec.number.buf[i]; |
| 1852 | } |
| 1853 | string8[(int)infoRec->rec.number.len] = '\0'; |
| 1854 | writeStringToParcel(p, (const char*)string8); |
| 1855 | free(string8); |
| 1856 | string8 = NULL; |
| 1857 | p.writeInt32(infoRec->rec.number.number_type); |
| 1858 | p.writeInt32(infoRec->rec.number.number_plan); |
| 1859 | p.writeInt32(infoRec->rec.number.pi); |
| 1860 | p.writeInt32(infoRec->rec.number.si); |
| 1861 | break; |
| 1862 | case RIL_CDMA_SIGNAL_INFO_REC: |
| 1863 | p.writeInt32(infoRec->rec.signal.isPresent); |
| 1864 | p.writeInt32(infoRec->rec.signal.signalType); |
| 1865 | p.writeInt32(infoRec->rec.signal.alertPitch); |
| 1866 | p.writeInt32(infoRec->rec.signal.signal); |
| 1867 | |
| 1868 | appendPrintBuf("%sisPresent=%X, signalType=%X, \ |
| 1869 | alertPitch=%X, signal=%X, ", |
| 1870 | printBuf, (int)infoRec->rec.signal.isPresent, |
| 1871 | (int)infoRec->rec.signal.signalType, |
| 1872 | (int)infoRec->rec.signal.alertPitch, |
| 1873 | (int)infoRec->rec.signal.signal); |
| 1874 | removeLastChar; |
| 1875 | break; |
| 1876 | case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: |
| 1877 | if (infoRec->rec.redir.redirectingNumber.len > |
| 1878 | CDMA_NUMBER_INFO_BUFFER_LENGTH) { |
| 1879 | ALOGE("invalid display info response length %d \ |
| 1880 | expected not more than %d\n", |
| 1881 | (int)infoRec->rec.redir.redirectingNumber.len, |
| 1882 | CDMA_NUMBER_INFO_BUFFER_LENGTH); |
| 1883 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1884 | } |
| 1885 | string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber |
| 1886 | .len + 1) * sizeof(char) ); |
| 1887 | for (int i = 0; |
| 1888 | i < infoRec->rec.redir.redirectingNumber.len; |
| 1889 | i++) { |
| 1890 | string8[i] = infoRec->rec.redir.redirectingNumber.buf[i]; |
| 1891 | } |
| 1892 | string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0'; |
| 1893 | writeStringToParcel(p, (const char*)string8); |
| 1894 | free(string8); |
| 1895 | string8 = NULL; |
| 1896 | p.writeInt32(infoRec->rec.redir.redirectingNumber.number_type); |
| 1897 | p.writeInt32(infoRec->rec.redir.redirectingNumber.number_plan); |
| 1898 | p.writeInt32(infoRec->rec.redir.redirectingNumber.pi); |
| 1899 | p.writeInt32(infoRec->rec.redir.redirectingNumber.si); |
| 1900 | p.writeInt32(infoRec->rec.redir.redirectingReason); |
| 1901 | break; |
| 1902 | case RIL_CDMA_LINE_CONTROL_INFO_REC: |
| 1903 | p.writeInt32(infoRec->rec.lineCtrl.lineCtrlPolarityIncluded); |
| 1904 | p.writeInt32(infoRec->rec.lineCtrl.lineCtrlToggle); |
| 1905 | p.writeInt32(infoRec->rec.lineCtrl.lineCtrlReverse); |
| 1906 | p.writeInt32(infoRec->rec.lineCtrl.lineCtrlPowerDenial); |
| 1907 | |
| 1908 | appendPrintBuf("%slineCtrlPolarityIncluded=%d, \ |
| 1909 | lineCtrlToggle=%d, lineCtrlReverse=%d, \ |
| 1910 | lineCtrlPowerDenial=%d, ", printBuf, |
| 1911 | (int)infoRec->rec.lineCtrl.lineCtrlPolarityIncluded, |
| 1912 | (int)infoRec->rec.lineCtrl.lineCtrlToggle, |
| 1913 | (int)infoRec->rec.lineCtrl.lineCtrlReverse, |
| 1914 | (int)infoRec->rec.lineCtrl.lineCtrlPowerDenial); |
| 1915 | removeLastChar; |
| 1916 | break; |
| 1917 | case RIL_CDMA_T53_CLIR_INFO_REC: |
| 1918 | p.writeInt32((int)(infoRec->rec.clir.cause)); |
| 1919 | |
| 1920 | appendPrintBuf("%scause%d", printBuf, infoRec->rec.clir.cause); |
| 1921 | removeLastChar; |
| 1922 | break; |
| 1923 | case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: |
| 1924 | p.writeInt32(infoRec->rec.audioCtrl.upLink); |
| 1925 | p.writeInt32(infoRec->rec.audioCtrl.downLink); |
| 1926 | |
| 1927 | appendPrintBuf("%supLink=%d, downLink=%d, ", printBuf, |
| 1928 | infoRec->rec.audioCtrl.upLink, |
| 1929 | infoRec->rec.audioCtrl.downLink); |
| 1930 | removeLastChar; |
| 1931 | break; |
| 1932 | case RIL_CDMA_T53_RELEASE_INFO_REC: |
| 1933 | // TODO(Moto): See David Krause, he has the answer:) |
| 1934 | ALOGE("RIL_CDMA_T53_RELEASE_INFO_REC: return INVALID_RESPONSE"); |
| 1935 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1936 | default: |
| 1937 | ALOGE("Incorrect name value"); |
| 1938 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1939 | } |
| 1940 | } |
| 1941 | closeResponse; |
| 1942 | |
| 1943 | return 0; |
| 1944 | } |
| 1945 | |
| 1946 | static int responseRilSignalStrength(Parcel &p, |
| 1947 | void *response, size_t responselen) { |
| 1948 | |
| 1949 | int gsmSignalStrength; |
| 1950 | |
| 1951 | if (response == NULL && responselen != 0) { |
| 1952 | ALOGE("invalid response: NULL"); |
| 1953 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1954 | } |
| 1955 | |
| 1956 | ALOGE("responseRilSignalStrength()"); |
| 1957 | |
| 1958 | if (responselen >= sizeof (RIL_SignalStrength_v5)) { |
| 1959 | RIL_SignalStrength_v6 *p_cur = ((RIL_SignalStrength_v6 *) response); |
| 1960 | |
| 1961 | /* gsmSignalStrength */ |
| 1962 | ALOGD("gsmSignalStrength (raw)=%d", p_cur->GW_SignalStrength.signalStrength); |
| 1963 | gsmSignalStrength = p_cur->GW_SignalStrength.signalStrength & 0xFF; |
| 1964 | ALOGD("gsmSignalStrength (corrected)=%d", gsmSignalStrength); |
| 1965 | |
| 1966 | /* |
| 1967 | * if gsmSignalStrength isn't a valid value, use cdmaDbm as fallback. |
| 1968 | * This is needed for old modem firmwares. |
| 1969 | */ |
| 1970 | if (gsmSignalStrength < 0 || (gsmSignalStrength > 31 && p_cur->GW_SignalStrength.signalStrength != 99)) { |
| 1971 | ALOGD("gsmSignalStrength-fallback (raw)=%d", p_cur->CDMA_SignalStrength.dbm); |
| 1972 | gsmSignalStrength = p_cur->CDMA_SignalStrength.dbm; |
| 1973 | if (gsmSignalStrength < 0) { |
| 1974 | gsmSignalStrength = 99; |
| 1975 | } else if (gsmSignalStrength > 31 && gsmSignalStrength != 99) { |
| 1976 | gsmSignalStrength = 31; |
| 1977 | } |
| 1978 | ALOGD("gsmSignalStrength-fallback (corrected)=%d", gsmSignalStrength); |
| 1979 | } |
| 1980 | p.writeInt32(gsmSignalStrength); |
| 1981 | |
| 1982 | /* gsmBitErrorRate */ |
| 1983 | p.writeInt32(p_cur->GW_SignalStrength.bitErrorRate); |
| 1984 | /* cdmaDbm */ |
| 1985 | p.writeInt32(p_cur->CDMA_SignalStrength.dbm); |
| 1986 | /* cdmaEcio */ |
| 1987 | p.writeInt32(p_cur->CDMA_SignalStrength.ecio); |
| 1988 | /* evdoDbm */ |
| 1989 | p.writeInt32(p_cur->EVDO_SignalStrength.dbm); |
| 1990 | /* evdoEcio */ |
| 1991 | p.writeInt32(p_cur->EVDO_SignalStrength.ecio); |
| 1992 | /* evdoSnr */ |
| 1993 | p.writeInt32(p_cur->EVDO_SignalStrength.signalNoiseRatio); |
| 1994 | |
| 1995 | if (responselen >= sizeof (RIL_SignalStrength_v6)) { |
| 1996 | /* lteSignalStrength */ |
| 1997 | p.writeInt32(p_cur->LTE_SignalStrength.signalStrength); |
| 1998 | |
| 1999 | /* |
| 2000 | * ril version <=6 receives negative values for rsrp |
| 2001 | * workaround for backward compatibility |
| 2002 | */ |
| 2003 | p_cur->LTE_SignalStrength.rsrp = |
| 2004 | ((s_callbacks.version <= 6) && (p_cur->LTE_SignalStrength.rsrp < 0 )) ? |
| 2005 | -(p_cur->LTE_SignalStrength.rsrp) : p_cur->LTE_SignalStrength.rsrp; |
| 2006 | |
| 2007 | /* lteRsrp */ |
| 2008 | p.writeInt32(p_cur->LTE_SignalStrength.rsrp); |
| 2009 | /* lteRsrq */ |
| 2010 | p.writeInt32(p_cur->LTE_SignalStrength.rsrq); |
| 2011 | /* lteRssnr */ |
| 2012 | p.writeInt32(p_cur->LTE_SignalStrength.rssnr); |
| 2013 | /* lteCqi */ |
| 2014 | p.writeInt32(p_cur->LTE_SignalStrength.cqi); |
| 2015 | |
| 2016 | } else { |
| 2017 | memset(&p_cur->LTE_SignalStrength, sizeof (RIL_LTE_SignalStrength), 0); |
| 2018 | } |
| 2019 | |
| 2020 | startResponse; |
| 2021 | appendPrintBuf("%s[signalStrength=%d,bitErrorRate=%d,\ |
| 2022 | CDMA_SS.dbm=%d,CDMA_SSecio=%d,\ |
| 2023 | EVDO_SS.dbm=%d,EVDO_SS.ecio=%d,\ |
| 2024 | EVDO_SS.signalNoiseRatio=%d,\ |
| 2025 | LTE_SS.signalStrength=%d,LTE_SS.rsrp=%d,LTE_SS.rsrq=%d,\ |
| 2026 | LTE_SS.rssnr=%d,LTE_SS.cqi=%d]", |
| 2027 | printBuf, |
| 2028 | gsmSignalStrength, |
| 2029 | p_cur->GW_SignalStrength.bitErrorRate, |
| 2030 | p_cur->CDMA_SignalStrength.dbm, |
| 2031 | p_cur->CDMA_SignalStrength.ecio, |
| 2032 | p_cur->EVDO_SignalStrength.dbm, |
| 2033 | p_cur->EVDO_SignalStrength.ecio, |
| 2034 | p_cur->EVDO_SignalStrength.signalNoiseRatio, |
| 2035 | p_cur->LTE_SignalStrength.signalStrength, |
| 2036 | p_cur->LTE_SignalStrength.rsrp, |
| 2037 | p_cur->LTE_SignalStrength.rsrq, |
| 2038 | p_cur->LTE_SignalStrength.rssnr, |
| 2039 | p_cur->LTE_SignalStrength.cqi); |
| 2040 | closeResponse; |
| 2041 | |
| 2042 | } else { |
| 2043 | ALOGE("invalid response length"); |
| 2044 | return RIL_ERRNO_INVALID_RESPONSE; |
| 2045 | } |
| 2046 | |
| 2047 | return 0; |
| 2048 | } |
| 2049 | |
| 2050 | static int responseCallRing(Parcel &p, void *response, size_t responselen) { |
| 2051 | if ((response == NULL) || (responselen == 0)) { |
| 2052 | return responseVoid(p, response, responselen); |
| 2053 | } else { |
| 2054 | return responseCdmaSignalInfoRecord(p, response, responselen); |
| 2055 | } |
| 2056 | } |
| 2057 | |
| 2058 | static int responseCdmaSignalInfoRecord(Parcel &p, void *response, size_t responselen) { |
| 2059 | if (response == NULL || responselen == 0) { |
| 2060 | ALOGE("invalid response: NULL"); |
| 2061 | return RIL_ERRNO_INVALID_RESPONSE; |
| 2062 | } |
| 2063 | |
| 2064 | if (responselen != sizeof (RIL_CDMA_SignalInfoRecord)) { |
| 2065 | ALOGE("invalid response length %d expected sizeof (RIL_CDMA_SignalInfoRecord) of %d\n", |
| 2066 | (int)responselen, (int)sizeof (RIL_CDMA_SignalInfoRecord)); |
| 2067 | return RIL_ERRNO_INVALID_RESPONSE; |
| 2068 | } |
| 2069 | |
| 2070 | startResponse; |
| 2071 | |
| 2072 | RIL_CDMA_SignalInfoRecord *p_cur = ((RIL_CDMA_SignalInfoRecord *) response); |
| 2073 | marshallSignalInfoRecord(p, *p_cur); |
| 2074 | |
| 2075 | appendPrintBuf("%s[isPresent=%d,signalType=%d,alertPitch=%d\ |
| 2076 | signal=%d]", |
| 2077 | printBuf, |
| 2078 | p_cur->isPresent, |
| 2079 | p_cur->signalType, |
| 2080 | p_cur->alertPitch, |
| 2081 | p_cur->signal); |
| 2082 | |
| 2083 | closeResponse; |
| 2084 | return 0; |
| 2085 | } |
| 2086 | |
| 2087 | static int responseCdmaCallWaiting(Parcel &p, void *response, |
| 2088 | size_t responselen) { |
| 2089 | if (response == NULL && responselen != 0) { |
| 2090 | ALOGE("invalid response: NULL"); |
| 2091 | return RIL_ERRNO_INVALID_RESPONSE; |
| 2092 | } |
| 2093 | |
| 2094 | if (responselen < sizeof(RIL_CDMA_CallWaiting_v6)) { |
| 2095 | ALOGW("Upgrade to ril version %d\n", RIL_VERSION); |
| 2096 | } |
| 2097 | |
| 2098 | RIL_CDMA_CallWaiting_v6 *p_cur = ((RIL_CDMA_CallWaiting_v6 *) response); |
| 2099 | |
| 2100 | writeStringToParcel(p, p_cur->number); |
| 2101 | p.writeInt32(p_cur->numberPresentation); |
| 2102 | writeStringToParcel(p, p_cur->name); |
| 2103 | marshallSignalInfoRecord(p, p_cur->signalInfoRecord); |
| 2104 | |
| 2105 | if (responselen >= sizeof(RIL_CDMA_CallWaiting_v6)) { |
| 2106 | p.writeInt32(p_cur->number_type); |
| 2107 | p.writeInt32(p_cur->number_plan); |
| 2108 | } else { |
| 2109 | p.writeInt32(0); |
| 2110 | p.writeInt32(0); |
| 2111 | } |
| 2112 | |
| 2113 | startResponse; |
| 2114 | appendPrintBuf("%snumber=%s,numberPresentation=%d, name=%s,\ |
| 2115 | signalInfoRecord[isPresent=%d,signalType=%d,alertPitch=%d\ |
| 2116 | signal=%d,number_type=%d,number_plan=%d]", |
| 2117 | printBuf, |
| 2118 | p_cur->number, |
| 2119 | p_cur->numberPresentation, |
| 2120 | p_cur->name, |
| 2121 | p_cur->signalInfoRecord.isPresent, |
| 2122 | p_cur->signalInfoRecord.signalType, |
| 2123 | p_cur->signalInfoRecord.alertPitch, |
| 2124 | p_cur->signalInfoRecord.signal, |
| 2125 | p_cur->number_type, |
| 2126 | p_cur->number_plan); |
| 2127 | closeResponse; |
| 2128 | |
| 2129 | return 0; |
| 2130 | } |
| 2131 | |
| 2132 | static int responseSimRefresh(Parcel &p, void *response, size_t responselen) { |
| 2133 | if (response == NULL && responselen != 0) { |
| 2134 | ALOGE("responseSimRefresh: invalid response: NULL"); |
| 2135 | return RIL_ERRNO_INVALID_RESPONSE; |
| 2136 | } |
| 2137 | |
| 2138 | startResponse; |
| 2139 | if (s_callbacks.version == 7) { |
| 2140 | RIL_SimRefreshResponse_v7 *p_cur = ((RIL_SimRefreshResponse_v7 *) response); |
| 2141 | p.writeInt32(p_cur->result); |
| 2142 | p.writeInt32(p_cur->ef_id); |
| 2143 | writeStringToParcel(p, p_cur->aid); |
| 2144 | |
| 2145 | appendPrintBuf("%sresult=%d, ef_id=%d, aid=%s", |
| 2146 | printBuf, |
| 2147 | p_cur->result, |
| 2148 | p_cur->ef_id, |
| 2149 | p_cur->aid); |
| 2150 | } else { |
| 2151 | int *p_cur = ((int *) response); |
| 2152 | p.writeInt32(p_cur[0]); |
| 2153 | p.writeInt32(p_cur[1]); |
| 2154 | writeStringToParcel(p, NULL); |
| 2155 | |
| 2156 | appendPrintBuf("%sresult=%d, ef_id=%d", |
| 2157 | printBuf, |
| 2158 | p_cur[0], |
| 2159 | p_cur[1]); |
| 2160 | } |
| 2161 | closeResponse; |
| 2162 | |
| 2163 | return 0; |
| 2164 | } |
| 2165 | |
| 2166 | static void triggerEvLoop() { |
| 2167 | int ret; |
| 2168 | if (!pthread_equal(pthread_self(), s_tid_dispatch)) { |
| 2169 | /* trigger event loop to wakeup. No reason to do this, |
| 2170 | * if we're in the event loop thread */ |
| 2171 | do { |
| 2172 | ret = write (s_fdWakeupWrite, " ", 1); |
| 2173 | } while (ret < 0 && errno == EINTR); |
| 2174 | } |
| 2175 | } |
| 2176 | |
| 2177 | static void rilEventAddWakeup(struct ril_event *ev) { |
| 2178 | ril_event_add(ev); |
| 2179 | triggerEvLoop(); |
| 2180 | } |
| 2181 | |
| 2182 | static void sendSimStatusAppInfo(Parcel &p, int num_apps, RIL_AppStatus appStatus[]) { |
| 2183 | p.writeInt32(num_apps); |
| 2184 | startResponse; |
| 2185 | for (int i = 0; i < num_apps; i++) { |
| 2186 | p.writeInt32(appStatus[i].app_type); |
| 2187 | p.writeInt32(appStatus[i].app_state); |
| 2188 | p.writeInt32(appStatus[i].perso_substate); |
| 2189 | writeStringToParcel(p, (const char*)(appStatus[i].aid_ptr)); |
| 2190 | writeStringToParcel(p, (const char*) |
| 2191 | (appStatus[i].app_label_ptr)); |
| 2192 | p.writeInt32(appStatus[i].pin1_replaced); |
| 2193 | p.writeInt32(appStatus[i].pin1); |
| 2194 | p.writeInt32(appStatus[i].pin2); |
| 2195 | appendPrintBuf("%s[app_type=%d,app_state=%d,perso_substate=%d,\ |
| 2196 | aid_ptr=%s,app_label_ptr=%s,pin1_replaced=%d,pin1=%d,pin2=%d],", |
| 2197 | printBuf, |
| 2198 | appStatus[i].app_type, |
| 2199 | appStatus[i].app_state, |
| 2200 | appStatus[i].perso_substate, |
| 2201 | appStatus[i].aid_ptr, |
| 2202 | appStatus[i].app_label_ptr, |
| 2203 | appStatus[i].pin1_replaced, |
| 2204 | appStatus[i].pin1, |
| 2205 | appStatus[i].pin2); |
| 2206 | } |
| 2207 | closeResponse; |
| 2208 | } |
| 2209 | |
| 2210 | static int responseSimStatus(Parcel &p, void *response, size_t responselen) { |
| 2211 | if (response == NULL && responselen != 0) { |
| 2212 | ALOGE("invalid response: NULL"); |
| 2213 | return RIL_ERRNO_INVALID_RESPONSE; |
| 2214 | } |
| 2215 | |
| 2216 | if (responselen == sizeof (RIL_CardStatus_v6)) { |
| 2217 | ALOGE("RIL_CardStatus_v6"); |
| 2218 | RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response); |
| 2219 | |
| 2220 | p.writeInt32(p_cur->card_state); |
| 2221 | p.writeInt32(p_cur->universal_pin_state); |
| 2222 | p.writeInt32(p_cur->gsm_umts_subscription_app_index); |
| 2223 | p.writeInt32(p_cur->cdma_subscription_app_index); |
| 2224 | p.writeInt32(p_cur->ims_subscription_app_index); |
| 2225 | |
| 2226 | sendSimStatusAppInfo(p, p_cur->num_applications, p_cur->applications); |
| 2227 | } else if (responselen == sizeof (RIL_CardStatus_v5)) { |
| 2228 | ALOGE("RIL_CardStatus_v5"); |
| 2229 | RIL_CardStatus_v5 *p_cur = ((RIL_CardStatus_v5 *) response); |
| 2230 | |
| 2231 | p.writeInt32(p_cur->card_state); |
| 2232 | p.writeInt32(p_cur->universal_pin_state); |
| 2233 | p.writeInt32(p_cur->gsm_umts_subscription_app_index); |
| 2234 | p.writeInt32(p_cur->cdma_subscription_app_index); |
| 2235 | p.writeInt32(-1); |
| 2236 | |
| 2237 | sendSimStatusAppInfo(p, p_cur->num_applications, p_cur->applications); |
| 2238 | } else { |
| 2239 | ALOGE("responseSimStatus: A RilCardStatus_v6 or _v5 expected\n"); |
| 2240 | ALOGE("responselen=%d", responselen); |
| 2241 | ALOGE("RIL_CardStatus_v5=%d", sizeof (RIL_CardStatus_v5)); |
| 2242 | ALOGE("RIL_CardStatus_v6=%d", sizeof (RIL_CardStatus_v6)); |
| 2243 | return RIL_ERRNO_INVALID_RESPONSE; |
| 2244 | } |
| 2245 | |
| 2246 | return 0; |
| 2247 | } |
| 2248 | |
| 2249 | static int responseGsmBrSmsCnf(Parcel &p, void *response, size_t responselen) { |
| 2250 | int num = responselen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *); |
| 2251 | p.writeInt32(num); |
| 2252 | |
| 2253 | startResponse; |
| 2254 | RIL_GSM_BroadcastSmsConfigInfo **p_cur = |
| 2255 | (RIL_GSM_BroadcastSmsConfigInfo **) response; |
| 2256 | for (int i = 0; i < num; i++) { |
| 2257 | p.writeInt32(p_cur[i]->fromServiceId); |
| 2258 | p.writeInt32(p_cur[i]->toServiceId); |
| 2259 | p.writeInt32(p_cur[i]->fromCodeScheme); |
| 2260 | p.writeInt32(p_cur[i]->toCodeScheme); |
| 2261 | p.writeInt32(p_cur[i]->selected); |
| 2262 | |
| 2263 | appendPrintBuf("%s [%d: fromServiceId=%d, toServiceId=%d, \ |
| 2264 | fromCodeScheme=%d, toCodeScheme=%d, selected =%d]", |
| 2265 | printBuf, i, p_cur[i]->fromServiceId, p_cur[i]->toServiceId, |
| 2266 | p_cur[i]->fromCodeScheme, p_cur[i]->toCodeScheme, |
| 2267 | p_cur[i]->selected); |
| 2268 | } |
| 2269 | closeResponse; |
| 2270 | |
| 2271 | return 0; |
| 2272 | } |
| 2273 | |
| 2274 | static int responseCdmaBrSmsCnf(Parcel &p, void *response, size_t responselen) { |
| 2275 | RIL_CDMA_BroadcastSmsConfigInfo **p_cur = |
| 2276 | (RIL_CDMA_BroadcastSmsConfigInfo **) response; |
| 2277 | |
| 2278 | int num = responselen / sizeof (RIL_CDMA_BroadcastSmsConfigInfo *); |
| 2279 | p.writeInt32(num); |
| 2280 | |
| 2281 | startResponse; |
| 2282 | for (int i = 0 ; i < num ; i++ ) { |
| 2283 | p.writeInt32(p_cur[i]->service_category); |
| 2284 | p.writeInt32(p_cur[i]->language); |
| 2285 | p.writeInt32(p_cur[i]->selected); |
| 2286 | |
| 2287 | appendPrintBuf("%s [%d: srvice_category=%d, language =%d, \ |
| 2288 | selected =%d], ", |
| 2289 | printBuf, i, p_cur[i]->service_category, p_cur[i]->language, |
| 2290 | p_cur[i]->selected); |
| 2291 | } |
| 2292 | closeResponse; |
| 2293 | |
| 2294 | return 0; |
| 2295 | } |
| 2296 | |
| 2297 | static int responseCdmaSms(Parcel &p, void *response, size_t responselen) { |
| 2298 | int num; |
| 2299 | int digitCount; |
| 2300 | int digitLimit; |
| 2301 | uint8_t uct; |
| 2302 | void* dest; |
| 2303 | |
| 2304 | ALOGD("Inside responseCdmaSms"); |
| 2305 | |
| 2306 | if (response == NULL && responselen != 0) { |
| 2307 | ALOGE("invalid response: NULL"); |
| 2308 | return RIL_ERRNO_INVALID_RESPONSE; |
| 2309 | } |
| 2310 | |
| 2311 | if (responselen != sizeof(RIL_CDMA_SMS_Message)) { |
| 2312 | ALOGE("invalid response length was %d expected %d", |
| 2313 | (int)responselen, (int)sizeof(RIL_CDMA_SMS_Message)); |
| 2314 | return RIL_ERRNO_INVALID_RESPONSE; |
| 2315 | } |
| 2316 | |
| 2317 | RIL_CDMA_SMS_Message *p_cur = (RIL_CDMA_SMS_Message *) response; |
| 2318 | p.writeInt32(p_cur->uTeleserviceID); |
| 2319 | p.write(&(p_cur->bIsServicePresent),sizeof(uct)); |
| 2320 | p.writeInt32(p_cur->uServicecategory); |
| 2321 | p.writeInt32(p_cur->sAddress.digit_mode); |
| 2322 | p.writeInt32(p_cur->sAddress.number_mode); |
| 2323 | p.writeInt32(p_cur->sAddress.number_type); |
| 2324 | p.writeInt32(p_cur->sAddress.number_plan); |
| 2325 | p.write(&(p_cur->sAddress.number_of_digits), sizeof(uct)); |
| 2326 | digitLimit= MIN((p_cur->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX); |
| 2327 | for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { |
| 2328 | p.write(&(p_cur->sAddress.digits[digitCount]),sizeof(uct)); |
| 2329 | } |
| 2330 | |
| 2331 | p.writeInt32(p_cur->sSubAddress.subaddressType); |
| 2332 | p.write(&(p_cur->sSubAddress.odd),sizeof(uct)); |
| 2333 | p.write(&(p_cur->sSubAddress.number_of_digits),sizeof(uct)); |
| 2334 | digitLimit= MIN((p_cur->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX); |
| 2335 | for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { |
| 2336 | p.write(&(p_cur->sSubAddress.digits[digitCount]),sizeof(uct)); |
| 2337 | } |
| 2338 | |
| 2339 | digitLimit= MIN((p_cur->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX); |
| 2340 | p.writeInt32(p_cur->uBearerDataLen); |
| 2341 | for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { |
| 2342 | p.write(&(p_cur->aBearerData[digitCount]), sizeof(uct)); |
| 2343 | } |
| 2344 | |
| 2345 | startResponse; |
| 2346 | appendPrintBuf("%suTeleserviceID=%d, bIsServicePresent=%d, uServicecategory=%d, \ |
| 2347 | sAddress.digit_mode=%d, sAddress.number_mode=%d, sAddress.number_type=%d, ", |
| 2348 | printBuf, p_cur->uTeleserviceID,p_cur->bIsServicePresent,p_cur->uServicecategory, |
| 2349 | p_cur->sAddress.digit_mode, p_cur->sAddress.number_mode,p_cur->sAddress.number_type); |
| 2350 | closeResponse; |
| 2351 | |
| 2352 | return 0; |
| 2353 | } |
| 2354 | |
| 2355 | /** |
| 2356 | * A write on the wakeup fd is done just to pop us out of select() |
| 2357 | * We empty the buffer here and then ril_event will reset the timers on the |
| 2358 | * way back down |
| 2359 | */ |
| 2360 | static void processWakeupCallback(int fd, short flags, void *param) { |
| 2361 | char buff[16]; |
| 2362 | int ret; |
| 2363 | |
| 2364 | ALOGV("processWakeupCallback"); |
| 2365 | |
| 2366 | /* empty our wakeup socket out */ |
| 2367 | do { |
| 2368 | ret = read(s_fdWakeupRead, &buff, sizeof(buff)); |
| 2369 | } while (ret > 0 || (ret < 0 && errno == EINTR)); |
| 2370 | } |
| 2371 | |
| 2372 | static void onCommandsSocketClosed() { |
| 2373 | int ret; |
| 2374 | RequestInfo *p_cur; |
| 2375 | |
| 2376 | /* mark pending requests as "cancelled" so we dont report responses */ |
| 2377 | |
| 2378 | ret = pthread_mutex_lock(&s_pendingRequestsMutex); |
| 2379 | assert (ret == 0); |
| 2380 | |
| 2381 | p_cur = s_pendingRequests; |
| 2382 | |
| 2383 | for (p_cur = s_pendingRequests |
| 2384 | ; p_cur != NULL |
| 2385 | ; p_cur = p_cur->p_next |
| 2386 | ) { |
| 2387 | p_cur->cancelled = 1; |
| 2388 | } |
| 2389 | |
| 2390 | ret = pthread_mutex_unlock(&s_pendingRequestsMutex); |
| 2391 | assert (ret == 0); |
| 2392 | } |
| 2393 | |
| 2394 | static void processCommandsCallback(int fd, short flags, void *param) { |
| 2395 | RecordStream *p_rs; |
| 2396 | void *p_record; |
| 2397 | size_t recordlen; |
| 2398 | int ret; |
| 2399 | |
| 2400 | assert(fd == s_fdCommand); |
| 2401 | |
| 2402 | p_rs = (RecordStream *)param; |
| 2403 | |
| 2404 | for (;;) { |
| 2405 | /* loop until EAGAIN/EINTR, end of stream, or other error */ |
| 2406 | ret = record_stream_get_next(p_rs, &p_record, &recordlen); |
| 2407 | |
| 2408 | if (ret == 0 && p_record == NULL) { |
| 2409 | /* end-of-stream */ |
| 2410 | break; |
| 2411 | } else if (ret < 0) { |
| 2412 | break; |
| 2413 | } else if (ret == 0) { /* && p_record != NULL */ |
| 2414 | processCommandBuffer(p_record, recordlen); |
| 2415 | } |
| 2416 | } |
| 2417 | |
| 2418 | if (ret == 0 || !(errno == EAGAIN || errno == EINTR)) { |
| 2419 | /* fatal error or end-of-stream */ |
| 2420 | if (ret != 0) { |
| 2421 | ALOGE("error on reading command socket errno:%d\n", errno); |
| 2422 | } else { |
| 2423 | ALOGW("EOS. Closing command socket."); |
| 2424 | } |
| 2425 | |
| 2426 | close(s_fdCommand); |
| 2427 | s_fdCommand = -1; |
| 2428 | |
| 2429 | ril_event_del(&s_commands_event); |
| 2430 | |
| 2431 | record_stream_free(p_rs); |
| 2432 | |
| 2433 | /* start listening for new connections again */ |
| 2434 | rilEventAddWakeup(&s_listen_event); |
| 2435 | |
| 2436 | onCommandsSocketClosed(); |
| 2437 | } |
| 2438 | } |
| 2439 | |
| 2440 | |
| 2441 | static void onNewCommandConnect() { |
| 2442 | // Inform we are connected and the ril version |
| 2443 | int rilVer = s_callbacks.version; |
| 2444 | RIL_onUnsolicitedResponse(RIL_UNSOL_RIL_CONNECTED, |
| 2445 | &rilVer, sizeof(rilVer)); |
| 2446 | |
| 2447 | // implicit radio state changed |
| 2448 | RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, |
| 2449 | NULL, 0); |
| 2450 | |
| 2451 | // Send last NITZ time data, in case it was missed |
| 2452 | if (s_lastNITZTimeData != NULL) { |
| 2453 | sendResponseRaw(s_lastNITZTimeData, s_lastNITZTimeDataSize); |
| 2454 | |
| 2455 | free(s_lastNITZTimeData); |
| 2456 | s_lastNITZTimeData = NULL; |
| 2457 | } |
| 2458 | |
| 2459 | // Get version string |
| 2460 | if (s_callbacks.getVersion != NULL) { |
| 2461 | const char *version; |
| 2462 | version = s_callbacks.getVersion(); |
| 2463 | ALOGI("RIL Daemon version: %s\n", version); |
| 2464 | |
| 2465 | property_set(PROPERTY_RIL_IMPL, version); |
| 2466 | } else { |
| 2467 | ALOGI("RIL Daemon version: unavailable\n"); |
| 2468 | property_set(PROPERTY_RIL_IMPL, "unavailable"); |
| 2469 | } |
| 2470 | |
| 2471 | } |
| 2472 | |
| 2473 | static void listenCallback (int fd, short flags, void *param) { |
| 2474 | int ret; |
| 2475 | int err; |
| 2476 | int is_phone_socket; |
| 2477 | RecordStream *p_rs; |
| 2478 | |
| 2479 | struct sockaddr_un peeraddr; |
| 2480 | socklen_t socklen = sizeof (peeraddr); |
| 2481 | |
| 2482 | struct ucred creds; |
| 2483 | socklen_t szCreds = sizeof(creds); |
| 2484 | |
| 2485 | struct passwd *pwd = NULL; |
| 2486 | |
| 2487 | assert (s_fdCommand < 0); |
| 2488 | assert (fd == s_fdListen); |
| 2489 | |
| 2490 | s_fdCommand = accept(s_fdListen, (sockaddr *) &peeraddr, &socklen); |
| 2491 | |
| 2492 | if (s_fdCommand < 0 ) { |
| 2493 | ALOGE("Error on accept() errno:%d", errno); |
| 2494 | /* start listening for new connections again */ |
| 2495 | rilEventAddWakeup(&s_listen_event); |
| 2496 | return; |
| 2497 | } |
| 2498 | |
| 2499 | /* check the credential of the other side and only accept socket from |
| 2500 | * phone process |
| 2501 | */ |
| 2502 | errno = 0; |
| 2503 | is_phone_socket = 0; |
| 2504 | |
| 2505 | err = getsockopt(s_fdCommand, SOL_SOCKET, SO_PEERCRED, &creds, &szCreds); |
| 2506 | |
| 2507 | if (err == 0 && szCreds > 0) { |
| 2508 | errno = 0; |
| 2509 | pwd = getpwuid(creds.uid); |
| 2510 | if (pwd != NULL) { |
| 2511 | if (strcmp(pwd->pw_name, PHONE_PROCESS) == 0) { |
| 2512 | is_phone_socket = 1; |
| 2513 | } else { |
| 2514 | ALOGE("RILD can't accept socket from process %s", pwd->pw_name); |
| 2515 | } |
| 2516 | } else { |
| 2517 | ALOGE("Error on getpwuid() errno: %d", errno); |
| 2518 | } |
| 2519 | } else { |
| 2520 | ALOGD("Error on getsockopt() errno: %d", errno); |
| 2521 | } |
| 2522 | |
| 2523 | if ( !is_phone_socket ) { |
| 2524 | ALOGE("RILD must accept socket from %s", PHONE_PROCESS); |
| 2525 | |
| 2526 | close(s_fdCommand); |
| 2527 | s_fdCommand = -1; |
| 2528 | |
| 2529 | onCommandsSocketClosed(); |
| 2530 | |
| 2531 | /* start listening for new connections again */ |
| 2532 | rilEventAddWakeup(&s_listen_event); |
| 2533 | |
| 2534 | return; |
| 2535 | } |
| 2536 | |
| 2537 | ret = fcntl(s_fdCommand, F_SETFL, O_NONBLOCK); |
| 2538 | |
| 2539 | if (ret < 0) { |
| 2540 | ALOGE ("Error setting O_NONBLOCK errno:%d", errno); |
| 2541 | } |
| 2542 | |
| 2543 | ALOGI("libril: new connection"); |
| 2544 | |
| 2545 | p_rs = record_stream_new(s_fdCommand, MAX_COMMAND_BYTES); |
| 2546 | |
| 2547 | ril_event_set (&s_commands_event, s_fdCommand, 1, |
| 2548 | processCommandsCallback, p_rs); |
| 2549 | |
| 2550 | rilEventAddWakeup (&s_commands_event); |
| 2551 | |
| 2552 | onNewCommandConnect(); |
| 2553 | } |
| 2554 | |
| 2555 | static void freeDebugCallbackArgs(int number, char **args) { |
| 2556 | for (int i = 0; i < number; i++) { |
| 2557 | if (args[i] != NULL) { |
| 2558 | free(args[i]); |
| 2559 | } |
| 2560 | } |
| 2561 | free(args); |
| 2562 | } |
| 2563 | |
| 2564 | static void debugCallback (int fd, short flags, void *param) { |
| 2565 | int acceptFD, option; |
| 2566 | struct sockaddr_un peeraddr; |
| 2567 | socklen_t socklen = sizeof (peeraddr); |
| 2568 | int data; |
| 2569 | unsigned int qxdm_data[6]; |
| 2570 | const char *deactData[1] = {"1"}; |
| 2571 | char *actData[1]; |
| 2572 | RIL_Dial dialData; |
| 2573 | int hangupData[1] = {1}; |
| 2574 | int number; |
| 2575 | char **args; |
| 2576 | |
| 2577 | acceptFD = accept (fd, (sockaddr *) &peeraddr, &socklen); |
| 2578 | |
| 2579 | if (acceptFD < 0) { |
| 2580 | ALOGE ("error accepting on debug port: %d\n", errno); |
| 2581 | return; |
| 2582 | } |
| 2583 | |
| 2584 | if (recv(acceptFD, &number, sizeof(int), 0) != sizeof(int)) { |
| 2585 | ALOGE ("error reading on socket: number of Args: \n"); |
| 2586 | return; |
| 2587 | } |
| 2588 | args = (char **) malloc(sizeof(char*) * number); |
| 2589 | |
| 2590 | for (int i = 0; i < number; i++) { |
| 2591 | int len; |
| 2592 | if (recv(acceptFD, &len, sizeof(int), 0) != sizeof(int)) { |
| 2593 | ALOGE ("error reading on socket: Len of Args: \n"); |
| 2594 | freeDebugCallbackArgs(i, args); |
| 2595 | return; |
| 2596 | } |
| 2597 | // +1 for null-term |
| 2598 | args[i] = (char *) malloc((sizeof(char) * len) + 1); |
| 2599 | if (recv(acceptFD, args[i], sizeof(char) * len, 0) |
| 2600 | != (int)sizeof(char) * len) { |
| 2601 | ALOGE ("error reading on socket: Args[%d] \n", i); |
| 2602 | freeDebugCallbackArgs(i, args); |
| 2603 | return; |
| 2604 | } |
| 2605 | char * buf = args[i]; |
| 2606 | buf[len] = 0; |
| 2607 | } |
| 2608 | |
| 2609 | switch (atoi(args[0])) { |
| 2610 | case 0: |
| 2611 | ALOGI ("Connection on debug port: issuing reset."); |
| 2612 | issueLocalRequest(RIL_REQUEST_RESET_RADIO, NULL, 0); |
| 2613 | break; |
| 2614 | case 1: |
| 2615 | ALOGI ("Connection on debug port: issuing radio power off."); |
| 2616 | data = 0; |
| 2617 | issueLocalRequest(RIL_REQUEST_RADIO_POWER, &data, sizeof(int)); |
| 2618 | // Close the socket |
| 2619 | close(s_fdCommand); |
| 2620 | s_fdCommand = -1; |
| 2621 | break; |
| 2622 | case 2: |
| 2623 | ALOGI ("Debug port: issuing unsolicited voice network change."); |
| 2624 | RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED, |
| 2625 | NULL, 0); |
| 2626 | break; |
| 2627 | case 3: |
| 2628 | ALOGI ("Debug port: QXDM log enable."); |
| 2629 | qxdm_data[0] = 65536; // head.func_tag |
| 2630 | qxdm_data[1] = 16; // head.len |
| 2631 | qxdm_data[2] = 1; // mode: 1 for 'start logging' |
| 2632 | qxdm_data[3] = 32; // log_file_size: 32megabytes |
| 2633 | qxdm_data[4] = 0; // log_mask |
| 2634 | qxdm_data[5] = 8; // log_max_fileindex |
| 2635 | issueLocalRequest(RIL_REQUEST_OEM_HOOK_RAW, qxdm_data, |
| 2636 | 6 * sizeof(int)); |
| 2637 | break; |
| 2638 | case 4: |
| 2639 | ALOGI ("Debug port: QXDM log disable."); |
| 2640 | qxdm_data[0] = 65536; |
| 2641 | qxdm_data[1] = 16; |
| 2642 | qxdm_data[2] = 0; // mode: 0 for 'stop logging' |
| 2643 | qxdm_data[3] = 32; |
| 2644 | qxdm_data[4] = 0; |
| 2645 | qxdm_data[5] = 8; |
| 2646 | issueLocalRequest(RIL_REQUEST_OEM_HOOK_RAW, qxdm_data, |
| 2647 | 6 * sizeof(int)); |
| 2648 | break; |
| 2649 | case 5: |
| 2650 | ALOGI("Debug port: Radio On"); |
| 2651 | data = 1; |
| 2652 | issueLocalRequest(RIL_REQUEST_RADIO_POWER, &data, sizeof(int)); |
| 2653 | sleep(2); |
| 2654 | // Set network selection automatic. |
| 2655 | issueLocalRequest(RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC, NULL, 0); |
| 2656 | break; |
| 2657 | case 6: |
| 2658 | ALOGI("Debug port: Setup Data Call, Apn :%s\n", args[1]); |
| 2659 | actData[0] = args[1]; |
| 2660 | issueLocalRequest(RIL_REQUEST_SETUP_DATA_CALL, &actData, |
| 2661 | sizeof(actData)); |
| 2662 | break; |
| 2663 | case 7: |
| 2664 | ALOGI("Debug port: Deactivate Data Call"); |
| 2665 | issueLocalRequest(RIL_REQUEST_DEACTIVATE_DATA_CALL, &deactData, |
| 2666 | sizeof(deactData)); |
| 2667 | break; |
| 2668 | case 8: |
| 2669 | ALOGI("Debug port: Dial Call"); |
| 2670 | dialData.clir = 0; |
| 2671 | dialData.address = args[1]; |
| 2672 | issueLocalRequest(RIL_REQUEST_DIAL, &dialData, sizeof(dialData)); |
| 2673 | break; |
| 2674 | case 9: |
| 2675 | ALOGI("Debug port: Answer Call"); |
| 2676 | issueLocalRequest(RIL_REQUEST_ANSWER, NULL, 0); |
| 2677 | break; |
| 2678 | case 10: |
| 2679 | ALOGI("Debug port: End Call"); |
| 2680 | issueLocalRequest(RIL_REQUEST_HANGUP, &hangupData, |
| 2681 | sizeof(hangupData)); |
| 2682 | break; |
| 2683 | default: |
| 2684 | ALOGE ("Invalid request"); |
| 2685 | break; |
| 2686 | } |
| 2687 | freeDebugCallbackArgs(number, args); |
| 2688 | close(acceptFD); |
| 2689 | } |
| 2690 | |
| 2691 | |
| 2692 | static void userTimerCallback (int fd, short flags, void *param) { |
| 2693 | UserCallbackInfo *p_info; |
| 2694 | |
| 2695 | p_info = (UserCallbackInfo *)param; |
| 2696 | |
| 2697 | p_info->p_callback(p_info->userParam); |
| 2698 | |
| 2699 | |
| 2700 | // FIXME generalize this...there should be a cancel mechanism |
| 2701 | if (s_last_wake_timeout_info != NULL && s_last_wake_timeout_info == p_info) { |
| 2702 | s_last_wake_timeout_info = NULL; |
| 2703 | } |
| 2704 | |
| 2705 | free(p_info); |
| 2706 | } |
| 2707 | |
| 2708 | |
| 2709 | static void * |
| 2710 | eventLoop(void *param) { |
| 2711 | int ret; |
| 2712 | int filedes[2]; |
| 2713 | |
| 2714 | ril_event_init(); |
| 2715 | |
| 2716 | pthread_mutex_lock(&s_startupMutex); |
| 2717 | |
| 2718 | s_started = 1; |
| 2719 | pthread_cond_broadcast(&s_startupCond); |
| 2720 | |
| 2721 | pthread_mutex_unlock(&s_startupMutex); |
| 2722 | |
| 2723 | ret = pipe(filedes); |
| 2724 | |
| 2725 | if (ret < 0) { |
| 2726 | ALOGE("Error in pipe() errno:%d", errno); |
| 2727 | return NULL; |
| 2728 | } |
| 2729 | |
| 2730 | s_fdWakeupRead = filedes[0]; |
| 2731 | s_fdWakeupWrite = filedes[1]; |
| 2732 | |
| 2733 | fcntl(s_fdWakeupRead, F_SETFL, O_NONBLOCK); |
| 2734 | |
| 2735 | ril_event_set (&s_wakeupfd_event, s_fdWakeupRead, true, |
| 2736 | processWakeupCallback, NULL); |
| 2737 | |
| 2738 | rilEventAddWakeup (&s_wakeupfd_event); |
| 2739 | |
| 2740 | // Only returns on error |
| 2741 | ril_event_loop(); |
| 2742 | ALOGE ("error in event_loop_base errno:%d", errno); |
| 2743 | // kill self to restart on error |
| 2744 | kill(0, SIGKILL); |
| 2745 | |
| 2746 | return NULL; |
| 2747 | } |
| 2748 | |
| 2749 | extern "C" void |
| 2750 | RIL_startEventLoop(void) { |
| 2751 | int ret; |
| 2752 | pthread_attr_t attr; |
| 2753 | |
| 2754 | /* spin up eventLoop thread and wait for it to get started */ |
| 2755 | s_started = 0; |
| 2756 | pthread_mutex_lock(&s_startupMutex); |
| 2757 | |
| 2758 | pthread_attr_init (&attr); |
| 2759 | pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); |
| 2760 | ret = pthread_create(&s_tid_dispatch, &attr, eventLoop, NULL); |
| 2761 | |
| 2762 | while (s_started == 0) { |
| 2763 | pthread_cond_wait(&s_startupCond, &s_startupMutex); |
| 2764 | } |
| 2765 | |
| 2766 | pthread_mutex_unlock(&s_startupMutex); |
| 2767 | |
| 2768 | if (ret < 0) { |
| 2769 | ALOGE("Failed to create dispatch thread errno:%d", errno); |
| 2770 | return; |
| 2771 | } |
| 2772 | } |
| 2773 | |
| 2774 | // Used for testing purpose only. |
| 2775 | extern "C" void RIL_setcallbacks (const RIL_RadioFunctions *callbacks) { |
| 2776 | memcpy(&s_callbacks, callbacks, sizeof (RIL_RadioFunctions)); |
| 2777 | } |
| 2778 | |
| 2779 | extern "C" void |
| 2780 | RIL_register (const RIL_RadioFunctions *callbacks) { |
| 2781 | int ret; |
| 2782 | int flags; |
| 2783 | |
| 2784 | if (callbacks == NULL) { |
| 2785 | ALOGE("RIL_register: RIL_RadioFunctions * null"); |
| 2786 | return; |
| 2787 | } |
| 2788 | if (callbacks->version < RIL_VERSION_MIN) { |
| 2789 | ALOGE("RIL_register: version %d is to old, min version is %d", |
| 2790 | callbacks->version, RIL_VERSION_MIN); |
| 2791 | return; |
| 2792 | } |
| 2793 | if (callbacks->version > RIL_VERSION) { |
| 2794 | ALOGE("RIL_register: version %d is too new, max version is %d", |
| 2795 | callbacks->version, RIL_VERSION); |
| 2796 | return; |
| 2797 | } |
| 2798 | ALOGE("RIL_register: RIL version %d", callbacks->version); |
| 2799 | |
| 2800 | if (s_registerCalled > 0) { |
| 2801 | ALOGE("RIL_register has been called more than once. " |
| 2802 | "Subsequent call ignored"); |
| 2803 | return; |
| 2804 | } |
| 2805 | |
| 2806 | memcpy(&s_callbacks, callbacks, sizeof (RIL_RadioFunctions)); |
| 2807 | |
| 2808 | s_registerCalled = 1; |
| 2809 | |
| 2810 | // Little self-check |
| 2811 | |
| 2812 | for (int i = 0; i < (int)NUM_ELEMS(s_commands); i++) { |
| 2813 | assert(i == s_commands[i].requestNumber); |
| 2814 | } |
| 2815 | |
| 2816 | for (int i = 0; i < (int)NUM_ELEMS(s_unsolResponses); i++) { |
| 2817 | assert(i + RIL_UNSOL_RESPONSE_BASE |
| 2818 | == s_unsolResponses[i].requestNumber); |
| 2819 | } |
| 2820 | |
| 2821 | // New rild impl calls RIL_startEventLoop() first |
| 2822 | // old standalone impl wants it here. |
| 2823 | |
| 2824 | if (s_started == 0) { |
| 2825 | RIL_startEventLoop(); |
| 2826 | } |
| 2827 | |
| 2828 | // start listen socket |
| 2829 | |
| 2830 | #if 0 |
| 2831 | ret = socket_local_server (SOCKET_NAME_RIL, |
| 2832 | ANDROID_SOCKET_NAMESPACE_ABSTRACT, SOCK_STREAM); |
| 2833 | |
| 2834 | if (ret < 0) { |
| 2835 | ALOGE("Unable to bind socket errno:%d", errno); |
| 2836 | exit (-1); |
| 2837 | } |
| 2838 | s_fdListen = ret; |
| 2839 | |
| 2840 | #else |
| 2841 | s_fdListen = android_get_control_socket(SOCKET_NAME_RIL); |
| 2842 | if (s_fdListen < 0) { |
| 2843 | ALOGE("Failed to get socket '" SOCKET_NAME_RIL "'"); |
| 2844 | exit(-1); |
| 2845 | } |
| 2846 | |
| 2847 | ret = listen(s_fdListen, 4); |
| 2848 | |
| 2849 | if (ret < 0) { |
| 2850 | ALOGE("Failed to listen on control socket '%d': %s", |
| 2851 | s_fdListen, strerror(errno)); |
| 2852 | exit(-1); |
| 2853 | } |
| 2854 | #endif |
| 2855 | |
| 2856 | |
| 2857 | /* note: non-persistent so we can accept only one connection at a time */ |
| 2858 | ril_event_set (&s_listen_event, s_fdListen, false, |
| 2859 | listenCallback, NULL); |
| 2860 | |
| 2861 | rilEventAddWakeup (&s_listen_event); |
| 2862 | |
| 2863 | #if 1 |
| 2864 | // start debug interface socket |
| 2865 | |
| 2866 | s_fdDebug = android_get_control_socket(SOCKET_NAME_RIL_DEBUG); |
| 2867 | if (s_fdDebug < 0) { |
| 2868 | ALOGE("Failed to get socket '" SOCKET_NAME_RIL_DEBUG "' errno:%d", errno); |
| 2869 | exit(-1); |
| 2870 | } |
| 2871 | |
| 2872 | ret = listen(s_fdDebug, 4); |
| 2873 | |
| 2874 | if (ret < 0) { |
| 2875 | ALOGE("Failed to listen on ril debug socket '%d': %s", |
| 2876 | s_fdDebug, strerror(errno)); |
| 2877 | exit(-1); |
| 2878 | } |
| 2879 | |
| 2880 | ril_event_set (&s_debug_event, s_fdDebug, true, |
| 2881 | debugCallback, NULL); |
| 2882 | |
| 2883 | rilEventAddWakeup (&s_debug_event); |
| 2884 | #endif |
| 2885 | |
| 2886 | } |
| 2887 | |
| 2888 | static int |
| 2889 | checkAndDequeueRequestInfo(struct RequestInfo *pRI) { |
| 2890 | int ret = 0; |
| 2891 | |
| 2892 | if (pRI == NULL) { |
| 2893 | return 0; |
| 2894 | } |
| 2895 | |
| 2896 | pthread_mutex_lock(&s_pendingRequestsMutex); |
| 2897 | |
| 2898 | for(RequestInfo **ppCur = &s_pendingRequests |
| 2899 | ; *ppCur != NULL |
| 2900 | ; ppCur = &((*ppCur)->p_next) |
| 2901 | ) { |
| 2902 | if (pRI == *ppCur) { |
| 2903 | ret = 1; |
| 2904 | |
| 2905 | *ppCur = (*ppCur)->p_next; |
| 2906 | break; |
| 2907 | } |
| 2908 | } |
| 2909 | |
| 2910 | pthread_mutex_unlock(&s_pendingRequestsMutex); |
| 2911 | |
| 2912 | return ret; |
| 2913 | } |
| 2914 | |
| 2915 | |
| 2916 | extern "C" void |
| 2917 | RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responselen) { |
| 2918 | RequestInfo *pRI; |
| 2919 | int ret; |
| 2920 | size_t errorOffset; |
| 2921 | |
| 2922 | pRI = (RequestInfo *)t; |
| 2923 | |
| 2924 | if (!checkAndDequeueRequestInfo(pRI)) { |
| 2925 | ALOGE ("RIL_onRequestComplete: invalid RIL_Token"); |
| 2926 | return; |
| 2927 | } |
| 2928 | |
| 2929 | if (pRI->local > 0) { |
| 2930 | // Locally issued command...void only! |
| 2931 | // response does not go back up the command socket |
| 2932 | ALOGD("C[locl]< %s", requestToString(pRI->pCI->requestNumber)); |
| 2933 | |
| 2934 | goto done; |
| 2935 | } |
| 2936 | |
| 2937 | appendPrintBuf("[%04d]< %s", |
| 2938 | pRI->token, requestToString(pRI->pCI->requestNumber)); |
| 2939 | |
| 2940 | if (pRI->cancelled == 0) { |
| 2941 | Parcel p; |
| 2942 | |
| 2943 | p.writeInt32 (RESPONSE_SOLICITED); |
| 2944 | p.writeInt32 (pRI->token); |
| 2945 | errorOffset = p.dataPosition(); |
| 2946 | |
| 2947 | p.writeInt32 (e); |
| 2948 | |
| 2949 | if (response != NULL) { |
| 2950 | // there is a response payload, no matter success or not. |
| 2951 | ret = pRI->pCI->responseFunction(p, response, responselen); |
| 2952 | |
| 2953 | /* if an error occurred, rewind and mark it */ |
| 2954 | if (ret != 0) { |
| 2955 | p.setDataPosition(errorOffset); |
| 2956 | p.writeInt32 (ret); |
| 2957 | } |
| 2958 | } |
| 2959 | |
| 2960 | if (e != RIL_E_SUCCESS) { |
| 2961 | appendPrintBuf("%s fails by %s", printBuf, failCauseToString(e)); |
| 2962 | } |
| 2963 | |
| 2964 | if (s_fdCommand < 0) { |
| 2965 | ALOGD ("RIL onRequestComplete: Command channel closed"); |
| 2966 | } |
| 2967 | sendResponse(p); |
| 2968 | } |
| 2969 | |
| 2970 | done: |
| 2971 | free(pRI); |
| 2972 | } |
| 2973 | |
| 2974 | |
| 2975 | static void |
| 2976 | grabPartialWakeLock() { |
| 2977 | acquire_wake_lock(PARTIAL_WAKE_LOCK, ANDROID_WAKE_LOCK_NAME); |
| 2978 | } |
| 2979 | |
| 2980 | static void |
| 2981 | releaseWakeLock() { |
| 2982 | release_wake_lock(ANDROID_WAKE_LOCK_NAME); |
| 2983 | } |
| 2984 | |
| 2985 | /** |
| 2986 | * Timer callback to put us back to sleep before the default timeout |
| 2987 | */ |
| 2988 | static void |
| 2989 | wakeTimeoutCallback (void *param) { |
| 2990 | // We're using "param != NULL" as a cancellation mechanism |
| 2991 | if (param == NULL) { |
| 2992 | //ALOGD("wakeTimeout: releasing wake lock"); |
| 2993 | |
| 2994 | releaseWakeLock(); |
| 2995 | } else { |
| 2996 | //ALOGD("wakeTimeout: releasing wake lock CANCELLED"); |
| 2997 | } |
| 2998 | } |
| 2999 | |
| 3000 | static int |
| 3001 | decodeVoiceRadioTechnology (RIL_RadioState radioState) { |
| 3002 | switch (radioState) { |
| 3003 | case RADIO_STATE_SIM_NOT_READY: |
| 3004 | case RADIO_STATE_SIM_LOCKED_OR_ABSENT: |
| 3005 | case RADIO_STATE_SIM_READY: |
| 3006 | return RADIO_TECH_UMTS; |
| 3007 | |
| 3008 | case RADIO_STATE_RUIM_NOT_READY: |
| 3009 | case RADIO_STATE_RUIM_READY: |
| 3010 | case RADIO_STATE_RUIM_LOCKED_OR_ABSENT: |
| 3011 | case RADIO_STATE_NV_NOT_READY: |
| 3012 | case RADIO_STATE_NV_READY: |
| 3013 | return RADIO_TECH_1xRTT; |
| 3014 | |
| 3015 | default: |
| 3016 | ALOGD("decodeVoiceRadioTechnology: Invoked with incorrect RadioState"); |
| 3017 | return -1; |
| 3018 | } |
| 3019 | } |
| 3020 | |
| 3021 | static int |
| 3022 | decodeCdmaSubscriptionSource (RIL_RadioState radioState) { |
| 3023 | switch (radioState) { |
| 3024 | case RADIO_STATE_SIM_NOT_READY: |
| 3025 | case RADIO_STATE_SIM_LOCKED_OR_ABSENT: |
| 3026 | case RADIO_STATE_SIM_READY: |
| 3027 | case RADIO_STATE_RUIM_NOT_READY: |
| 3028 | case RADIO_STATE_RUIM_READY: |
| 3029 | case RADIO_STATE_RUIM_LOCKED_OR_ABSENT: |
| 3030 | return CDMA_SUBSCRIPTION_SOURCE_RUIM_SIM; |
| 3031 | |
| 3032 | case RADIO_STATE_NV_NOT_READY: |
| 3033 | case RADIO_STATE_NV_READY: |
| 3034 | return CDMA_SUBSCRIPTION_SOURCE_NV; |
| 3035 | |
| 3036 | default: |
| 3037 | ALOGD("decodeCdmaSubscriptionSource: Invoked with incorrect RadioState"); |
| 3038 | return -1; |
| 3039 | } |
| 3040 | } |
| 3041 | |
| 3042 | static int |
| 3043 | decodeSimStatus (RIL_RadioState radioState) { |
| 3044 | switch (radioState) { |
| 3045 | case RADIO_STATE_SIM_NOT_READY: |
| 3046 | case RADIO_STATE_RUIM_NOT_READY: |
| 3047 | case RADIO_STATE_NV_NOT_READY: |
| 3048 | case RADIO_STATE_NV_READY: |
| 3049 | return -1; |
| 3050 | case RADIO_STATE_SIM_LOCKED_OR_ABSENT: |
| 3051 | case RADIO_STATE_SIM_READY: |
| 3052 | case RADIO_STATE_RUIM_READY: |
| 3053 | case RADIO_STATE_RUIM_LOCKED_OR_ABSENT: |
| 3054 | return radioState; |
| 3055 | default: |
| 3056 | ALOGD("decodeSimStatus: Invoked with incorrect RadioState"); |
| 3057 | return -1; |
| 3058 | } |
| 3059 | } |
| 3060 | |
| 3061 | static bool is3gpp2(int radioTech) { |
| 3062 | switch (radioTech) { |
| 3063 | case RADIO_TECH_IS95A: |
| 3064 | case RADIO_TECH_IS95B: |
| 3065 | case RADIO_TECH_1xRTT: |
| 3066 | case RADIO_TECH_EVDO_0: |
| 3067 | case RADIO_TECH_EVDO_A: |
| 3068 | case RADIO_TECH_EVDO_B: |
| 3069 | case RADIO_TECH_EHRPD: |
| 3070 | return true; |
| 3071 | default: |
| 3072 | return false; |
| 3073 | } |
| 3074 | } |
| 3075 | |
| 3076 | /* If RIL sends SIM states or RUIM states, store the voice radio |
| 3077 | * technology and subscription source information so that they can be |
| 3078 | * returned when telephony framework requests them |
| 3079 | */ |
| 3080 | static RIL_RadioState |
| 3081 | processRadioState(RIL_RadioState newRadioState) { |
| 3082 | |
| 3083 | if((newRadioState > RADIO_STATE_UNAVAILABLE) && (newRadioState < RADIO_STATE_ON)) { |
| 3084 | int newVoiceRadioTech; |
| 3085 | int newCdmaSubscriptionSource; |
| 3086 | int newSimStatus; |
| 3087 | |
| 3088 | /* This is old RIL. Decode Subscription source and Voice Radio Technology |
| 3089 | from Radio State and send change notifications if there has been a change */ |
| 3090 | newVoiceRadioTech = decodeVoiceRadioTechnology(newRadioState); |
| 3091 | if(newVoiceRadioTech != voiceRadioTech) { |
| 3092 | voiceRadioTech = newVoiceRadioTech; |
| 3093 | RIL_onUnsolicitedResponse (RIL_UNSOL_VOICE_RADIO_TECH_CHANGED, |
| 3094 | &voiceRadioTech, sizeof(voiceRadioTech)); |
| 3095 | } |
| 3096 | if(is3gpp2(newVoiceRadioTech)) { |
| 3097 | newCdmaSubscriptionSource = decodeCdmaSubscriptionSource(newRadioState); |
| 3098 | if(newCdmaSubscriptionSource != cdmaSubscriptionSource) { |
| 3099 | cdmaSubscriptionSource = newCdmaSubscriptionSource; |
| 3100 | RIL_onUnsolicitedResponse (RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED, |
| 3101 | &cdmaSubscriptionSource, sizeof(cdmaSubscriptionSource)); |
| 3102 | } |
| 3103 | } |
| 3104 | newSimStatus = decodeSimStatus(newRadioState); |
| 3105 | if(newSimStatus != simRuimStatus) { |
| 3106 | simRuimStatus = newSimStatus; |
| 3107 | RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, NULL, 0); |
| 3108 | } |
| 3109 | |
| 3110 | /* Send RADIO_ON to telephony */ |
| 3111 | newRadioState = RADIO_STATE_ON; |
| 3112 | } |
| 3113 | |
| 3114 | return newRadioState; |
| 3115 | } |
| 3116 | |
| 3117 | extern "C" |
| 3118 | void RIL_onUnsolicitedResponse(int unsolResponse, void *data, |
| 3119 | size_t datalen) |
| 3120 | { |
| 3121 | int unsolResponseIndex; |
| 3122 | int ret; |
| 3123 | int64_t timeReceived = 0; |
| 3124 | bool shouldScheduleTimeout = false; |
| 3125 | RIL_RadioState newState; |
| 3126 | |
| 3127 | if (s_registerCalled == 0) { |
| 3128 | // Ignore RIL_onUnsolicitedResponse before RIL_register |
| 3129 | ALOGW("RIL_onUnsolicitedResponse called before RIL_register"); |
| 3130 | return; |
| 3131 | } |
| 3132 | |
| 3133 | unsolResponseIndex = unsolResponse - RIL_UNSOL_RESPONSE_BASE; |
| 3134 | |
| 3135 | if ((unsolResponseIndex < 0) |
| 3136 | || (unsolResponseIndex >= (int32_t)NUM_ELEMS(s_unsolResponses))) { |
| 3137 | ALOGE("unsupported unsolicited response code %d", unsolResponse); |
| 3138 | return; |
| 3139 | } |
| 3140 | |
| 3141 | // Grab a wake lock if needed for this reponse, |
| 3142 | // as we exit we'll either release it immediately |
| 3143 | // or set a timer to release it later. |
| 3144 | switch (s_unsolResponses[unsolResponseIndex].wakeType) { |
| 3145 | case WAKE_PARTIAL: |
| 3146 | grabPartialWakeLock(); |
| 3147 | shouldScheduleTimeout = true; |
| 3148 | break; |
| 3149 | |
| 3150 | case DONT_WAKE: |
| 3151 | default: |
| 3152 | // No wake lock is grabed so don't set timeout |
| 3153 | shouldScheduleTimeout = false; |
| 3154 | break; |
| 3155 | } |
| 3156 | |
| 3157 | // Mark the time this was received, doing this |
| 3158 | // after grabing the wakelock incase getting |
| 3159 | // the elapsedRealTime might cause us to goto |
| 3160 | // sleep. |
| 3161 | if (unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) { |
| 3162 | timeReceived = elapsedRealtime(); |
| 3163 | } |
| 3164 | |
| 3165 | appendPrintBuf("[UNSL]< %s", requestToString(unsolResponse)); |
| 3166 | |
| 3167 | Parcel p; |
| 3168 | |
| 3169 | p.writeInt32 (RESPONSE_UNSOLICITED); |
| 3170 | p.writeInt32 (unsolResponse); |
| 3171 | |
| 3172 | ret = s_unsolResponses[unsolResponseIndex] |
| 3173 | .responseFunction(p, data, datalen); |
| 3174 | if (ret != 0) { |
| 3175 | // Problem with the response. Don't continue; |
| 3176 | goto error_exit; |
| 3177 | } |
| 3178 | |
| 3179 | // some things get more payload |
| 3180 | switch(unsolResponse) { |
| 3181 | case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: |
| 3182 | newState = processRadioState(s_callbacks.onStateRequest()); |
| 3183 | p.writeInt32(newState); |
| 3184 | appendPrintBuf("%s {%s}", printBuf, |
| 3185 | radioStateToString(s_callbacks.onStateRequest())); |
| 3186 | break; |
| 3187 | |
| 3188 | |
| 3189 | case RIL_UNSOL_NITZ_TIME_RECEIVED: |
| 3190 | // Store the time that this was received so the |
| 3191 | // handler of this message can account for |
| 3192 | // the time it takes to arrive and process. In |
| 3193 | // particular the system has been known to sleep |
| 3194 | // before this message can be processed. |
| 3195 | p.writeInt64(timeReceived); |
| 3196 | break; |
| 3197 | } |
| 3198 | |
| 3199 | ret = sendResponse(p); |
| 3200 | if (ret != 0 && unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) { |
| 3201 | |
| 3202 | // Unfortunately, NITZ time is not poll/update like everything |
| 3203 | // else in the system. So, if the upstream client isn't connected, |
| 3204 | // keep a copy of the last NITZ response (with receive time noted |
| 3205 | // above) around so we can deliver it when it is connected |
| 3206 | |
| 3207 | if (s_lastNITZTimeData != NULL) { |
| 3208 | free (s_lastNITZTimeData); |
| 3209 | s_lastNITZTimeData = NULL; |
| 3210 | } |
| 3211 | |
| 3212 | s_lastNITZTimeData = malloc(p.dataSize()); |
| 3213 | s_lastNITZTimeDataSize = p.dataSize(); |
| 3214 | memcpy(s_lastNITZTimeData, p.data(), p.dataSize()); |
| 3215 | } |
| 3216 | |
| 3217 | // For now, we automatically go back to sleep after TIMEVAL_WAKE_TIMEOUT |
| 3218 | // FIXME The java code should handshake here to release wake lock |
| 3219 | |
| 3220 | if (shouldScheduleTimeout) { |
| 3221 | // Cancel the previous request |
| 3222 | if (s_last_wake_timeout_info != NULL) { |
| 3223 | s_last_wake_timeout_info->userParam = (void *)1; |
| 3224 | } |
| 3225 | |
| 3226 | s_last_wake_timeout_info |
| 3227 | = internalRequestTimedCallback(wakeTimeoutCallback, NULL, |
| 3228 | &TIMEVAL_WAKE_TIMEOUT); |
| 3229 | } |
| 3230 | |
| 3231 | // Normal exit |
| 3232 | return; |
| 3233 | |
| 3234 | error_exit: |
| 3235 | if (shouldScheduleTimeout) { |
| 3236 | releaseWakeLock(); |
| 3237 | } |
| 3238 | } |
| 3239 | |
| 3240 | /** FIXME generalize this if you track UserCAllbackInfo, clear it |
| 3241 | when the callback occurs |
| 3242 | */ |
| 3243 | static UserCallbackInfo * |
| 3244 | internalRequestTimedCallback (RIL_TimedCallback callback, void *param, |
| 3245 | const struct timeval *relativeTime) |
| 3246 | { |
| 3247 | struct timeval myRelativeTime; |
| 3248 | UserCallbackInfo *p_info; |
| 3249 | |
| 3250 | p_info = (UserCallbackInfo *) malloc (sizeof(UserCallbackInfo)); |
| 3251 | |
| 3252 | p_info->p_callback = callback; |
| 3253 | p_info->userParam = param; |
| 3254 | |
| 3255 | if (relativeTime == NULL) { |
| 3256 | /* treat null parameter as a 0 relative time */ |
| 3257 | memset (&myRelativeTime, 0, sizeof(myRelativeTime)); |
| 3258 | } else { |
| 3259 | /* FIXME I think event_add's tv param is really const anyway */ |
| 3260 | memcpy (&myRelativeTime, relativeTime, sizeof(myRelativeTime)); |
| 3261 | } |
| 3262 | |
| 3263 | ril_event_set(&(p_info->event), -1, false, userTimerCallback, p_info); |
| 3264 | |
| 3265 | ril_timer_add(&(p_info->event), &myRelativeTime); |
| 3266 | |
| 3267 | triggerEvLoop(); |
| 3268 | return p_info; |
| 3269 | } |
| 3270 | |
| 3271 | |
| 3272 | extern "C" void |
| 3273 | RIL_requestTimedCallback (RIL_TimedCallback callback, void *param, |
| 3274 | const struct timeval *relativeTime) { |
| 3275 | internalRequestTimedCallback (callback, param, relativeTime); |
| 3276 | } |
| 3277 | |
| 3278 | const char * |
| 3279 | failCauseToString(RIL_Errno e) { |
| 3280 | switch(e) { |
| 3281 | case RIL_E_SUCCESS: return "E_SUCCESS"; |
| 3282 | case RIL_E_RADIO_NOT_AVAILABLE: return "E_RAIDO_NOT_AVAILABLE"; |
| 3283 | case RIL_E_GENERIC_FAILURE: return "E_GENERIC_FAILURE"; |
| 3284 | case RIL_E_PASSWORD_INCORRECT: return "E_PASSWORD_INCORRECT"; |
| 3285 | case RIL_E_SIM_PIN2: return "E_SIM_PIN2"; |
| 3286 | case RIL_E_SIM_PUK2: return "E_SIM_PUK2"; |
| 3287 | case RIL_E_REQUEST_NOT_SUPPORTED: return "E_REQUEST_NOT_SUPPORTED"; |
| 3288 | case RIL_E_CANCELLED: return "E_CANCELLED"; |
| 3289 | case RIL_E_OP_NOT_ALLOWED_DURING_VOICE_CALL: return "E_OP_NOT_ALLOWED_DURING_VOICE_CALL"; |
| 3290 | case RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW: return "E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW"; |
| 3291 | case RIL_E_SMS_SEND_FAIL_RETRY: return "E_SMS_SEND_FAIL_RETRY"; |
| 3292 | case RIL_E_SIM_ABSENT:return "E_SIM_ABSENT"; |
| 3293 | case RIL_E_ILLEGAL_SIM_OR_ME:return "E_ILLEGAL_SIM_OR_ME"; |
| 3294 | #ifdef FEATURE_MULTIMODE_ANDROID |
| 3295 | case RIL_E_SUBSCRIPTION_NOT_AVAILABLE:return "E_SUBSCRIPTION_NOT_AVAILABLE"; |
| 3296 | case RIL_E_MODE_NOT_SUPPORTED:return "E_MODE_NOT_SUPPORTED"; |
| 3297 | #endif |
| 3298 | default: return "<unknown error>"; |
| 3299 | } |
| 3300 | } |
| 3301 | |
| 3302 | const char * |
| 3303 | radioStateToString(RIL_RadioState s) { |
| 3304 | switch(s) { |
| 3305 | case RADIO_STATE_OFF: return "RADIO_OFF"; |
| 3306 | case RADIO_STATE_UNAVAILABLE: return "RADIO_UNAVAILABLE"; |
| 3307 | case RADIO_STATE_SIM_NOT_READY: return "RADIO_SIM_NOT_READY"; |
| 3308 | case RADIO_STATE_SIM_LOCKED_OR_ABSENT: return "RADIO_SIM_LOCKED_OR_ABSENT"; |
| 3309 | case RADIO_STATE_SIM_READY: return "RADIO_SIM_READY"; |
| 3310 | case RADIO_STATE_RUIM_NOT_READY:return"RADIO_RUIM_NOT_READY"; |
| 3311 | case RADIO_STATE_RUIM_READY:return"RADIO_RUIM_READY"; |
| 3312 | case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:return"RADIO_RUIM_LOCKED_OR_ABSENT"; |
| 3313 | case RADIO_STATE_NV_NOT_READY:return"RADIO_NV_NOT_READY"; |
| 3314 | case RADIO_STATE_NV_READY:return"RADIO_NV_READY"; |
| 3315 | case RADIO_STATE_ON:return"RADIO_ON"; |
| 3316 | default: return "<unknown state>"; |
| 3317 | } |
| 3318 | } |
| 3319 | |
| 3320 | const char * |
| 3321 | callStateToString(RIL_CallState s) { |
| 3322 | switch(s) { |
| 3323 | case RIL_CALL_ACTIVE : return "ACTIVE"; |
| 3324 | case RIL_CALL_HOLDING: return "HOLDING"; |
| 3325 | case RIL_CALL_DIALING: return "DIALING"; |
| 3326 | case RIL_CALL_ALERTING: return "ALERTING"; |
| 3327 | case RIL_CALL_INCOMING: return "INCOMING"; |
| 3328 | case RIL_CALL_WAITING: return "WAITING"; |
| 3329 | default: return "<unknown state>"; |
| 3330 | } |
| 3331 | } |
| 3332 | |
| 3333 | const char * |
| 3334 | requestToString(int request) { |
| 3335 | /* |
| 3336 | cat libs/telephony/ril_commands.h \ |
| 3337 | | egrep "^ *{RIL_" \ |
| 3338 | | sed -re 's/\{RIL_([^,]+),[^,]+,([^}]+).+/case RIL_\1: return "\1";/' |
| 3339 | |
| 3340 | |
| 3341 | cat libs/telephony/ril_unsol_commands.h \ |
| 3342 | | egrep "^ *{RIL_" \ |
| 3343 | | sed -re 's/\{RIL_([^,]+),([^}]+).+/case RIL_\1: return "\1";/' |
| 3344 | |
| 3345 | */ |
| 3346 | switch(request) { |
| 3347 | case RIL_REQUEST_GET_SIM_STATUS: return "GET_SIM_STATUS"; |
| 3348 | case RIL_REQUEST_ENTER_SIM_PIN: return "ENTER_SIM_PIN"; |
| 3349 | case RIL_REQUEST_ENTER_SIM_PUK: return "ENTER_SIM_PUK"; |
| 3350 | case RIL_REQUEST_ENTER_SIM_PIN2: return "ENTER_SIM_PIN2"; |
| 3351 | case RIL_REQUEST_ENTER_SIM_PUK2: return "ENTER_SIM_PUK2"; |
| 3352 | case RIL_REQUEST_CHANGE_SIM_PIN: return "CHANGE_SIM_PIN"; |
| 3353 | case RIL_REQUEST_CHANGE_SIM_PIN2: return "CHANGE_SIM_PIN2"; |
| 3354 | case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: return "ENTER_NETWORK_DEPERSONALIZATION"; |
| 3355 | case RIL_REQUEST_GET_CURRENT_CALLS: return "GET_CURRENT_CALLS"; |
| 3356 | case RIL_REQUEST_DIAL: return "DIAL"; |
| 3357 | case RIL_REQUEST_DIAL_EMERGENCY: return "DIAL"; |
| 3358 | case RIL_REQUEST_GET_IMSI: return "GET_IMSI"; |
| 3359 | case RIL_REQUEST_HANGUP: return "HANGUP"; |
| 3360 | case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: return "HANGUP_WAITING_OR_BACKGROUND"; |
| 3361 | case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: return "HANGUP_FOREGROUND_RESUME_BACKGROUND"; |
| 3362 | case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: return "SWITCH_WAITING_OR_HOLDING_AND_ACTIVE"; |
| 3363 | case RIL_REQUEST_CONFERENCE: return "CONFERENCE"; |
| 3364 | case RIL_REQUEST_UDUB: return "UDUB"; |
| 3365 | case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: return "LAST_CALL_FAIL_CAUSE"; |
| 3366 | case RIL_REQUEST_SIGNAL_STRENGTH: return "SIGNAL_STRENGTH"; |
| 3367 | case RIL_REQUEST_VOICE_REGISTRATION_STATE: return "VOICE_REGISTRATION_STATE"; |
| 3368 | case RIL_REQUEST_DATA_REGISTRATION_STATE: return "DATA_REGISTRATION_STATE"; |
| 3369 | case RIL_REQUEST_OPERATOR: return "OPERATOR"; |
| 3370 | case RIL_REQUEST_RADIO_POWER: return "RADIO_POWER"; |
| 3371 | case RIL_REQUEST_DTMF: return "DTMF"; |
| 3372 | case RIL_REQUEST_SEND_SMS: return "SEND_SMS"; |
| 3373 | case RIL_REQUEST_SEND_SMS_EXPECT_MORE: return "SEND_SMS_EXPECT_MORE"; |
| 3374 | case RIL_REQUEST_SETUP_DATA_CALL: return "SETUP_DATA_CALL"; |
| 3375 | case RIL_REQUEST_SIM_IO: return "SIM_IO"; |
| 3376 | case RIL_REQUEST_SEND_USSD: return "SEND_USSD"; |
| 3377 | case RIL_REQUEST_CANCEL_USSD: return "CANCEL_USSD"; |
| 3378 | case RIL_REQUEST_GET_CLIR: return "GET_CLIR"; |
| 3379 | case RIL_REQUEST_SET_CLIR: return "SET_CLIR"; |
| 3380 | case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: return "QUERY_CALL_FORWARD_STATUS"; |
| 3381 | case RIL_REQUEST_SET_CALL_FORWARD: return "SET_CALL_FORWARD"; |
| 3382 | case RIL_REQUEST_QUERY_CALL_WAITING: return "QUERY_CALL_WAITING"; |
| 3383 | case RIL_REQUEST_SET_CALL_WAITING: return "SET_CALL_WAITING"; |
| 3384 | case RIL_REQUEST_SMS_ACKNOWLEDGE: return "SMS_ACKNOWLEDGE"; |
| 3385 | case RIL_REQUEST_GET_IMEI: return "GET_IMEI"; |
| 3386 | case RIL_REQUEST_GET_IMEISV: return "GET_IMEISV"; |
| 3387 | case RIL_REQUEST_ANSWER: return "ANSWER"; |
| 3388 | case RIL_REQUEST_DEACTIVATE_DATA_CALL: return "DEACTIVATE_DATA_CALL"; |
| 3389 | case RIL_REQUEST_QUERY_FACILITY_LOCK: return "QUERY_FACILITY_LOCK"; |
| 3390 | case RIL_REQUEST_SET_FACILITY_LOCK: return "SET_FACILITY_LOCK"; |
| 3391 | case RIL_REQUEST_CHANGE_BARRING_PASSWORD: return "CHANGE_BARRING_PASSWORD"; |
| 3392 | case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: return "QUERY_NETWORK_SELECTION_MODE"; |
| 3393 | case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: return "SET_NETWORK_SELECTION_AUTOMATIC"; |
| 3394 | case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: return "SET_NETWORK_SELECTION_MANUAL"; |
| 3395 | case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : return "QUERY_AVAILABLE_NETWORKS "; |
| 3396 | case RIL_REQUEST_DTMF_START: return "DTMF_START"; |
| 3397 | case RIL_REQUEST_DTMF_STOP: return "DTMF_STOP"; |
| 3398 | case RIL_REQUEST_BASEBAND_VERSION: return "BASEBAND_VERSION"; |
| 3399 | case RIL_REQUEST_SEPARATE_CONNECTION: return "SEPARATE_CONNECTION"; |
| 3400 | case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: return "SET_PREFERRED_NETWORK_TYPE"; |
| 3401 | case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: return "GET_PREFERRED_NETWORK_TYPE"; |
| 3402 | case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: return "GET_NEIGHBORING_CELL_IDS"; |
| 3403 | case RIL_REQUEST_SET_MUTE: return "SET_MUTE"; |
| 3404 | case RIL_REQUEST_GET_MUTE: return "GET_MUTE"; |
| 3405 | case RIL_REQUEST_QUERY_CLIP: return "QUERY_CLIP"; |
| 3406 | case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: return "LAST_DATA_CALL_FAIL_CAUSE"; |
| 3407 | case RIL_REQUEST_DATA_CALL_LIST: return "DATA_CALL_LIST"; |
| 3408 | case RIL_REQUEST_RESET_RADIO: return "RESET_RADIO"; |
| 3409 | case RIL_REQUEST_OEM_HOOK_RAW: return "OEM_HOOK_RAW"; |
| 3410 | case RIL_REQUEST_OEM_HOOK_STRINGS: return "OEM_HOOK_STRINGS"; |
| 3411 | case RIL_REQUEST_SET_BAND_MODE: return "SET_BAND_MODE"; |
| 3412 | case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: return "QUERY_AVAILABLE_BAND_MODE"; |
| 3413 | case RIL_REQUEST_STK_GET_PROFILE: return "STK_GET_PROFILE"; |
| 3414 | case RIL_REQUEST_STK_SET_PROFILE: return "STK_SET_PROFILE"; |
| 3415 | case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: return "STK_SEND_ENVELOPE_COMMAND"; |
| 3416 | case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: return "STK_SEND_TERMINAL_RESPONSE"; |
| 3417 | case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: return "STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM"; |
| 3418 | case RIL_REQUEST_SCREEN_STATE: return "SCREEN_STATE"; |
| 3419 | case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: return "EXPLICIT_CALL_TRANSFER"; |
| 3420 | case RIL_REQUEST_SET_LOCATION_UPDATES: return "SET_LOCATION_UPDATES"; |
| 3421 | case RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE: return "CDMA_SET_SUBSCRIPTION_SOURCE"; |
| 3422 | case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE:return"CDMA_SET_ROAMING_PREFERENCE"; |
| 3423 | case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE:return"CDMA_QUERY_ROAMING_PREFERENCE"; |
| 3424 | case RIL_REQUEST_SET_TTY_MODE:return"SET_TTY_MODE"; |
| 3425 | case RIL_REQUEST_QUERY_TTY_MODE:return"QUERY_TTY_MODE"; |
| 3426 | case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE"; |
| 3427 | case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE"; |
| 3428 | case RIL_REQUEST_CDMA_FLASH:return"CDMA_FLASH"; |
| 3429 | case RIL_REQUEST_CDMA_BURST_DTMF:return"CDMA_BURST_DTMF"; |
| 3430 | case RIL_REQUEST_CDMA_SEND_SMS:return"CDMA_SEND_SMS"; |
| 3431 | case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE:return"CDMA_SMS_ACKNOWLEDGE"; |
| 3432 | case RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG:return"GSM_GET_BROADCAST_SMS_CONFIG"; |
| 3433 | case RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG:return"GSM_SET_BROADCAST_SMS_CONFIG"; |
| 3434 | case RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG:return "CDMA_GET_BROADCAST_SMS_CONFIG"; |
| 3435 | case RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG:return "CDMA_SET_BROADCAST_SMS_CONFIG"; |
| 3436 | case RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION:return "CDMA_SMS_BROADCAST_ACTIVATION"; |
| 3437 | case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: return "CDMA_VALIDATE_AND_WRITE_AKEY"; |
| 3438 | case RIL_REQUEST_CDMA_SUBSCRIPTION: return"CDMA_SUBSCRIPTION"; |
| 3439 | case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: return "CDMA_WRITE_SMS_TO_RUIM"; |
| 3440 | case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: return "CDMA_DELETE_SMS_ON_RUIM"; |
| 3441 | case RIL_REQUEST_DEVICE_IDENTITY: return "DEVICE_IDENTITY"; |
| 3442 | case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: return "EXIT_EMERGENCY_CALLBACK_MODE"; |
| 3443 | case RIL_REQUEST_GET_SMSC_ADDRESS: return "GET_SMSC_ADDRESS"; |
| 3444 | case RIL_REQUEST_SET_SMSC_ADDRESS: return "SET_SMSC_ADDRESS"; |
| 3445 | case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: return "REPORT_SMS_MEMORY_STATUS"; |
| 3446 | case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: return "REPORT_STK_SERVICE_IS_RUNNING"; |
| 3447 | case RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE: return "CDMA_GET_SUBSCRIPTION_SOURCE"; |
| 3448 | case RIL_REQUEST_ISIM_AUTHENTICATION: return "ISIM_AUTHENTICATION"; |
| 3449 | case RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU: return "RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU"; |
| 3450 | case RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS: return "RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS"; |
| 3451 | case RIL_REQUEST_VOICE_RADIO_TECH: return "VOICE_RADIO_TECH"; |
| 3452 | case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return "UNSOL_RESPONSE_RADIO_STATE_CHANGED"; |
| 3453 | case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return "UNSOL_RESPONSE_CALL_STATE_CHANGED"; |
| 3454 | case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: return "UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED"; |
| 3455 | case RIL_UNSOL_RESPONSE_NEW_SMS: return "UNSOL_RESPONSE_NEW_SMS"; |
| 3456 | case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: return "UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT"; |
| 3457 | case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: return "UNSOL_RESPONSE_NEW_SMS_ON_SIM"; |
| 3458 | case RIL_UNSOL_ON_USSD: return "UNSOL_ON_USSD"; |
| 3459 | case RIL_UNSOL_ON_USSD_REQUEST: return "UNSOL_ON_USSD_REQUEST(obsolete)"; |
| 3460 | case RIL_UNSOL_NITZ_TIME_RECEIVED: return "UNSOL_NITZ_TIME_RECEIVED"; |
| 3461 | case RIL_UNSOL_SIGNAL_STRENGTH: return "UNSOL_SIGNAL_STRENGTH"; |
| 3462 | case RIL_UNSOL_STK_SESSION_END: return "UNSOL_STK_SESSION_END"; |
| 3463 | case RIL_UNSOL_STK_PROACTIVE_COMMAND: return "UNSOL_STK_PROACTIVE_COMMAND"; |
| 3464 | case RIL_UNSOL_STK_EVENT_NOTIFY: return "UNSOL_STK_EVENT_NOTIFY"; |
| 3465 | case RIL_UNSOL_STK_CALL_SETUP: return "UNSOL_STK_CALL_SETUP"; |
| 3466 | case RIL_UNSOL_SIM_SMS_STORAGE_FULL: return "UNSOL_SIM_SMS_STORAGE_FUL"; |
| 3467 | case RIL_UNSOL_SIM_REFRESH: return "UNSOL_SIM_REFRESH"; |
| 3468 | case RIL_UNSOL_DATA_CALL_LIST_CHANGED: return "UNSOL_DATA_CALL_LIST_CHANGED"; |
| 3469 | case RIL_UNSOL_CALL_RING: return "UNSOL_CALL_RING"; |
| 3470 | case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: return "UNSOL_RESPONSE_SIM_STATUS_CHANGED"; |
| 3471 | case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: return "UNSOL_NEW_CDMA_SMS"; |
| 3472 | case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: return "UNSOL_NEW_BROADCAST_SMS"; |
| 3473 | case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: return "UNSOL_CDMA_RUIM_SMS_STORAGE_FULL"; |
| 3474 | case RIL_UNSOL_RESTRICTED_STATE_CHANGED: return "UNSOL_RESTRICTED_STATE_CHANGED"; |
| 3475 | case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: return "UNSOL_ENTER_EMERGENCY_CALLBACK_MODE"; |
| 3476 | case RIL_UNSOL_CDMA_CALL_WAITING: return "UNSOL_CDMA_CALL_WAITING"; |
| 3477 | case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: return "UNSOL_CDMA_OTA_PROVISION_STATUS"; |
| 3478 | case RIL_UNSOL_CDMA_INFO_REC: return "UNSOL_CDMA_INFO_REC"; |
| 3479 | case RIL_UNSOL_OEM_HOOK_RAW: return "UNSOL_OEM_HOOK_RAW"; |
| 3480 | case RIL_UNSOL_RINGBACK_TONE: return "UNSOL_RINGBACK_TONE"; |
| 3481 | case RIL_UNSOL_RESEND_INCALL_MUTE: return "UNSOL_RESEND_INCALL_MUTE"; |
| 3482 | case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: return "UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED"; |
| 3483 | case RIL_UNSOL_CDMA_PRL_CHANGED: return "UNSOL_CDMA_PRL_CHANGED"; |
| 3484 | case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: return "UNSOL_EXIT_EMERGENCY_CALLBACK_MODE"; |
| 3485 | case RIL_UNSOL_RIL_CONNECTED: return "UNSOL_RIL_CONNECTED"; |
| 3486 | case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED: return "UNSOL_VOICE_RADIO_TECH_CHANGED"; |
| 3487 | default: return "<unknown request>"; |
| 3488 | } |
| 3489 | } |
| 3490 | |
| 3491 | } /* namespace android */ |