The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [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> |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 23 | #include <telephony/ril_cdma_sms.h> |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 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 <utils/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 | |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 76 | #define MIN(a,b) ((a)<(b) ? (a) : (b)) |
| 77 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 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 | LOGD("[%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 LOGD("%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 | |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 205 | static void dispatchCdmaSms(Parcel &p, RequestInfo *pRI); |
| 206 | static void dispatchCdmaSmsAck(Parcel &p, RequestInfo *pRI); |
| 207 | static void dispatchBrSmsCnf(Parcel &p, RequestInfo *pRI); |
| 208 | static void dispatchCdmaBrSmsCnf(Parcel &p, RequestInfo *pRI); |
| 209 | static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 210 | static int responseInts(Parcel &p, void *response, size_t responselen); |
| 211 | static int responseStrings(Parcel &p, void *response, size_t responselen); |
| 212 | static int responseString(Parcel &p, void *response, size_t responselen); |
| 213 | static int responseVoid(Parcel &p, void *response, size_t responselen); |
| 214 | static int responseCallList(Parcel &p, void *response, size_t responselen); |
| 215 | static int responseSMS(Parcel &p, void *response, size_t responselen); |
| 216 | static int responseSIM_IO(Parcel &p, void *response, size_t responselen); |
| 217 | static int responseCallForwards(Parcel &p, void *response, size_t responselen); |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 218 | static int responseDataCallList(Parcel &p, void *response, size_t responselen); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 219 | static int responseRaw(Parcel &p, void *response, size_t responselen); |
| 220 | static int responseSsn(Parcel &p, void *response, size_t responselen); |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 221 | static int responseSimStatus(Parcel &p, void *response, size_t responselen); |
| 222 | static int responseBrSmsCnf(Parcel &p, void *response, size_t responselen); |
| 223 | static int responseCdmaBrCnf(Parcel &p, void *response, size_t responselen); |
| 224 | static int responseCdmaSms(Parcel &p, void *response, size_t responselen); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 225 | static int responseCellList(Parcel &p, void *response, size_t responselen); |
| 226 | |
| 227 | extern "C" const char * requestToString(int request); |
| 228 | extern "C" const char * failCauseToString(RIL_Errno); |
| 229 | extern "C" const char * callStateToString(RIL_CallState); |
| 230 | extern "C" const char * radioStateToString(RIL_RadioState); |
| 231 | |
| 232 | #ifdef RIL_SHLIB |
| 233 | extern "C" void RIL_onUnsolicitedResponse(int unsolResponse, void *data, |
| 234 | size_t datalen); |
| 235 | #endif |
| 236 | |
| 237 | static UserCallbackInfo * internalRequestTimedCallback |
| 238 | (RIL_TimedCallback callback, void *param, |
| 239 | const struct timeval *relativeTime); |
| 240 | |
| 241 | /** Index == requestNumber */ |
| 242 | static CommandInfo s_commands[] = { |
| 243 | #include "ril_commands.h" |
| 244 | }; |
| 245 | |
| 246 | static UnsolResponseInfo s_unsolResponses[] = { |
| 247 | #include "ril_unsol_commands.h" |
| 248 | }; |
| 249 | |
| 250 | |
| 251 | static char * |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 252 | strdupReadString(Parcel &p) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 253 | size_t stringlen; |
| 254 | const char16_t *s16; |
| 255 | |
| 256 | s16 = p.readString16Inplace(&stringlen); |
| 257 | |
| 258 | return strndup16to8(s16, stringlen); |
| 259 | } |
| 260 | |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 261 | static void writeStringToParcel(Parcel &p, const char *s) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 262 | char16_t *s16; |
| 263 | size_t s16_len; |
| 264 | s16 = strdup8to16(s, &s16_len); |
| 265 | p.writeString16(s16, s16_len); |
| 266 | free(s16); |
| 267 | } |
| 268 | |
| 269 | |
| 270 | static void |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 271 | memsetString (char *s) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 272 | if (s != NULL) { |
| 273 | memset (s, 0, strlen(s)); |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | void nullParcelReleaseFunction (const uint8_t* data, size_t dataSize, |
| 278 | const size_t* objects, size_t objectsSize, |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 279 | void* cookie) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 280 | // do nothing -- the data reference lives longer than the Parcel object |
| 281 | } |
| 282 | |
| 283 | /** |
| 284 | * To be called from dispatch thread |
| 285 | * Issue a single local request, ensuring that the response |
| 286 | * is not sent back up to the command process |
| 287 | */ |
| 288 | static void |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 289 | issueLocalRequest(int request, void *data, int len) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 290 | RequestInfo *pRI; |
| 291 | int ret; |
| 292 | |
| 293 | pRI = (RequestInfo *)calloc(1, sizeof(RequestInfo)); |
| 294 | |
| 295 | pRI->local = 1; |
| 296 | pRI->token = 0xffffffff; // token is not used in this context |
| 297 | pRI->pCI = &(s_commands[request]); |
| 298 | |
| 299 | ret = pthread_mutex_lock(&s_pendingRequestsMutex); |
| 300 | assert (ret == 0); |
| 301 | |
| 302 | pRI->p_next = s_pendingRequests; |
| 303 | s_pendingRequests = pRI; |
| 304 | |
| 305 | ret = pthread_mutex_unlock(&s_pendingRequestsMutex); |
| 306 | assert (ret == 0); |
| 307 | |
| 308 | LOGD("C[locl]> %s", requestToString(request)); |
| 309 | |
| 310 | s_callbacks.onRequest(request, data, len, pRI); |
| 311 | } |
| 312 | |
| 313 | |
| 314 | |
| 315 | static int |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 316 | processCommandBuffer(void *buffer, size_t buflen) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 317 | Parcel p; |
| 318 | status_t status; |
| 319 | int32_t request; |
| 320 | int32_t token; |
| 321 | RequestInfo *pRI; |
| 322 | int ret; |
| 323 | |
| 324 | p.setData((uint8_t *) buffer, buflen); |
| 325 | |
| 326 | // status checked at end |
| 327 | status = p.readInt32(&request); |
| 328 | status = p.readInt32 (&token); |
| 329 | |
| 330 | if (status != NO_ERROR) { |
| 331 | LOGE("invalid request block"); |
| 332 | return 0; |
| 333 | } |
| 334 | |
| 335 | if (request < 1 || request >= (int32_t)NUM_ELEMS(s_commands)) { |
| 336 | LOGE("unsupported request code %d token %d", request, token); |
| 337 | // FIXME this should perhaps return a response |
| 338 | return 0; |
| 339 | } |
| 340 | |
| 341 | |
| 342 | pRI = (RequestInfo *)calloc(1, sizeof(RequestInfo)); |
| 343 | |
| 344 | pRI->token = token; |
| 345 | pRI->pCI = &(s_commands[request]); |
| 346 | |
| 347 | ret = pthread_mutex_lock(&s_pendingRequestsMutex); |
| 348 | assert (ret == 0); |
| 349 | |
| 350 | pRI->p_next = s_pendingRequests; |
| 351 | s_pendingRequests = pRI; |
| 352 | |
| 353 | ret = pthread_mutex_unlock(&s_pendingRequestsMutex); |
| 354 | assert (ret == 0); |
| 355 | |
| 356 | /* sLastDispatchedToken = token; */ |
| 357 | |
| 358 | pRI->pCI->dispatchFunction(p, pRI); |
| 359 | |
| 360 | return 0; |
| 361 | } |
| 362 | |
| 363 | static void |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 364 | invalidCommandBlock (RequestInfo *pRI) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 365 | LOGE("invalid command block for token %d request %s", |
| 366 | pRI->token, requestToString(pRI->pCI->requestNumber)); |
| 367 | } |
| 368 | |
| 369 | /** Callee expects NULL */ |
| 370 | static void |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 371 | dispatchVoid (Parcel& p, RequestInfo *pRI) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 372 | clearPrintBuf; |
| 373 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 374 | s_callbacks.onRequest(pRI->pCI->requestNumber, NULL, 0, pRI); |
| 375 | } |
| 376 | |
| 377 | /** Callee expects const char * */ |
| 378 | static void |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 379 | dispatchString (Parcel& p, RequestInfo *pRI) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 380 | status_t status; |
| 381 | size_t datalen; |
| 382 | size_t stringlen; |
| 383 | char *string8 = NULL; |
| 384 | |
| 385 | string8 = strdupReadString(p); |
| 386 | |
| 387 | startRequest; |
| 388 | appendPrintBuf("%s%s", printBuf, string8); |
| 389 | closeRequest; |
| 390 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 391 | |
| 392 | s_callbacks.onRequest(pRI->pCI->requestNumber, string8, |
| 393 | sizeof(char *), pRI); |
| 394 | |
| 395 | #ifdef MEMSET_FREED |
| 396 | memsetString(string8); |
| 397 | #endif |
| 398 | |
| 399 | free(string8); |
| 400 | return; |
| 401 | invalid: |
| 402 | invalidCommandBlock(pRI); |
| 403 | return; |
| 404 | } |
| 405 | |
| 406 | /** Callee expects const char ** */ |
| 407 | static void |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 408 | dispatchStrings (Parcel &p, RequestInfo *pRI) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 409 | int32_t countStrings; |
| 410 | status_t status; |
| 411 | size_t datalen; |
| 412 | char **pStrings; |
| 413 | |
| 414 | status = p.readInt32 (&countStrings); |
| 415 | |
| 416 | if (status != NO_ERROR) { |
| 417 | goto invalid; |
| 418 | } |
| 419 | |
| 420 | startRequest; |
| 421 | if (countStrings == 0) { |
| 422 | // just some non-null pointer |
| 423 | pStrings = (char **)alloca(sizeof(char *)); |
| 424 | datalen = 0; |
| 425 | } else if (((int)countStrings) == -1) { |
| 426 | pStrings = NULL; |
| 427 | datalen = 0; |
| 428 | } else { |
| 429 | datalen = sizeof(char *) * countStrings; |
| 430 | |
| 431 | pStrings = (char **)alloca(datalen); |
| 432 | |
| 433 | for (int i = 0 ; i < countStrings ; i++) { |
| 434 | pStrings[i] = strdupReadString(p); |
| 435 | appendPrintBuf("%s%s,", printBuf, pStrings[i]); |
| 436 | } |
| 437 | } |
| 438 | removeLastChar; |
| 439 | closeRequest; |
| 440 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 441 | |
| 442 | s_callbacks.onRequest(pRI->pCI->requestNumber, pStrings, datalen, pRI); |
| 443 | |
| 444 | if (pStrings != NULL) { |
| 445 | for (int i = 0 ; i < countStrings ; i++) { |
| 446 | #ifdef MEMSET_FREED |
| 447 | memsetString (pStrings[i]); |
| 448 | #endif |
| 449 | free(pStrings[i]); |
| 450 | } |
| 451 | |
| 452 | #ifdef MEMSET_FREED |
| 453 | memset(pStrings, 0, datalen); |
| 454 | #endif |
| 455 | } |
| 456 | |
| 457 | return; |
| 458 | invalid: |
| 459 | invalidCommandBlock(pRI); |
| 460 | return; |
| 461 | } |
| 462 | |
| 463 | /** Callee expects const int * */ |
| 464 | static void |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 465 | dispatchInts (Parcel &p, RequestInfo *pRI) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 466 | int32_t count; |
| 467 | status_t status; |
| 468 | size_t datalen; |
| 469 | int *pInts; |
| 470 | |
| 471 | status = p.readInt32 (&count); |
| 472 | |
| 473 | if (status != NO_ERROR || count == 0) { |
| 474 | goto invalid; |
| 475 | } |
| 476 | |
| 477 | datalen = sizeof(int) * count; |
| 478 | pInts = (int *)alloca(datalen); |
| 479 | |
| 480 | startRequest; |
| 481 | for (int i = 0 ; i < count ; i++) { |
| 482 | int32_t t; |
| 483 | |
| 484 | status = p.readInt32(&t); |
| 485 | pInts[i] = (int)t; |
| 486 | appendPrintBuf("%s%d,", printBuf, t); |
| 487 | |
| 488 | if (status != NO_ERROR) { |
| 489 | goto invalid; |
| 490 | } |
| 491 | } |
| 492 | removeLastChar; |
| 493 | closeRequest; |
| 494 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 495 | |
| 496 | s_callbacks.onRequest(pRI->pCI->requestNumber, const_cast<int *>(pInts), |
| 497 | datalen, pRI); |
| 498 | |
| 499 | #ifdef MEMSET_FREED |
| 500 | memset(pInts, 0, datalen); |
| 501 | #endif |
| 502 | |
| 503 | return; |
| 504 | invalid: |
| 505 | invalidCommandBlock(pRI); |
| 506 | return; |
| 507 | } |
| 508 | |
| 509 | |
| 510 | /** |
| 511 | * Callee expects const RIL_SMS_WriteArgs * |
| 512 | * Payload is: |
| 513 | * int32_t status |
| 514 | * String pdu |
| 515 | */ |
| 516 | static void |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 517 | dispatchSmsWrite (Parcel &p, RequestInfo *pRI) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 518 | RIL_SMS_WriteArgs args; |
| 519 | int32_t t; |
| 520 | status_t status; |
| 521 | |
| 522 | memset (&args, 0, sizeof(args)); |
| 523 | |
| 524 | status = p.readInt32(&t); |
| 525 | args.status = (int)t; |
| 526 | |
| 527 | args.pdu = strdupReadString(p); |
| 528 | |
| 529 | if (status != NO_ERROR || args.pdu == NULL) { |
| 530 | goto invalid; |
| 531 | } |
| 532 | |
| 533 | args.smsc = strdupReadString(p); |
| 534 | |
| 535 | startRequest; |
| 536 | appendPrintBuf("%s%d,%s,smsc=%s", printBuf, args.status, |
| 537 | (char*)args.pdu, (char*)args.smsc); |
| 538 | closeRequest; |
| 539 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 540 | |
| 541 | s_callbacks.onRequest(pRI->pCI->requestNumber, &args, sizeof(args), pRI); |
| 542 | |
| 543 | #ifdef MEMSET_FREED |
| 544 | memsetString (args.pdu); |
| 545 | #endif |
| 546 | |
| 547 | free (args.pdu); |
| 548 | |
| 549 | #ifdef MEMSET_FREED |
| 550 | memset(&args, 0, sizeof(args)); |
| 551 | #endif |
| 552 | |
| 553 | return; |
| 554 | invalid: |
| 555 | invalidCommandBlock(pRI); |
| 556 | return; |
| 557 | } |
| 558 | |
| 559 | /** |
| 560 | * Callee expects const RIL_Dial * |
| 561 | * Payload is: |
| 562 | * String address |
| 563 | * int32_t clir |
| 564 | */ |
| 565 | static void |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 566 | dispatchDial (Parcel &p, RequestInfo *pRI) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 567 | RIL_Dial dial; |
| 568 | int32_t t; |
| 569 | status_t status; |
| 570 | |
| 571 | memset (&dial, 0, sizeof(dial)); |
| 572 | |
| 573 | dial.address = strdupReadString(p); |
| 574 | |
| 575 | status = p.readInt32(&t); |
| 576 | dial.clir = (int)t; |
| 577 | |
| 578 | if (status != NO_ERROR || dial.address == NULL) { |
| 579 | goto invalid; |
| 580 | } |
| 581 | |
| 582 | startRequest; |
| 583 | appendPrintBuf("%snum=%s,clir=%d", printBuf, dial.address, dial.clir); |
| 584 | closeRequest; |
| 585 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 586 | |
| 587 | s_callbacks.onRequest(pRI->pCI->requestNumber, &dial, sizeof(dial), pRI); |
| 588 | |
| 589 | #ifdef MEMSET_FREED |
| 590 | memsetString (dial.address); |
| 591 | #endif |
| 592 | |
| 593 | free (dial.address); |
| 594 | |
| 595 | #ifdef MEMSET_FREED |
| 596 | memset(&dial, 0, sizeof(dial)); |
| 597 | #endif |
| 598 | |
| 599 | return; |
| 600 | invalid: |
| 601 | invalidCommandBlock(pRI); |
| 602 | return; |
| 603 | } |
| 604 | |
| 605 | /** |
| 606 | * Callee expects const RIL_SIM_IO * |
| 607 | * Payload is: |
| 608 | * int32_t command |
| 609 | * int32_t fileid |
| 610 | * String path |
| 611 | * int32_t p1, p2, p3 |
| 612 | * String data |
| 613 | * String pin2 |
| 614 | */ |
| 615 | static void |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 616 | dispatchSIM_IO (Parcel &p, RequestInfo *pRI) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 617 | RIL_SIM_IO simIO; |
| 618 | int32_t t; |
| 619 | status_t status; |
| 620 | |
| 621 | memset (&simIO, 0, sizeof(simIO)); |
| 622 | |
| 623 | // note we only check status at the end |
| 624 | |
| 625 | status = p.readInt32(&t); |
| 626 | simIO.command = (int)t; |
| 627 | |
| 628 | status = p.readInt32(&t); |
| 629 | simIO.fileid = (int)t; |
| 630 | |
| 631 | simIO.path = strdupReadString(p); |
| 632 | |
| 633 | status = p.readInt32(&t); |
| 634 | simIO.p1 = (int)t; |
| 635 | |
| 636 | status = p.readInt32(&t); |
| 637 | simIO.p2 = (int)t; |
| 638 | |
| 639 | status = p.readInt32(&t); |
| 640 | simIO.p3 = (int)t; |
| 641 | |
| 642 | simIO.data = strdupReadString(p); |
| 643 | simIO.pin2 = strdupReadString(p); |
| 644 | |
| 645 | startRequest; |
| 646 | appendPrintBuf("%scmd=0x%X,efid=0x%X,path=%s,%d,%d,%d,%s,pin2=%s", printBuf, |
| 647 | simIO.command, simIO.fileid, (char*)simIO.path, |
| 648 | simIO.p1, simIO.p2, simIO.p3, |
| 649 | (char*)simIO.data, (char*)simIO.pin2); |
| 650 | closeRequest; |
| 651 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 652 | |
| 653 | if (status != NO_ERROR) { |
| 654 | goto invalid; |
| 655 | } |
| 656 | |
| 657 | s_callbacks.onRequest(pRI->pCI->requestNumber, &simIO, sizeof(simIO), pRI); |
| 658 | |
| 659 | #ifdef MEMSET_FREED |
| 660 | memsetString (simIO.path); |
| 661 | memsetString (simIO.data); |
| 662 | memsetString (simIO.pin2); |
| 663 | #endif |
| 664 | |
| 665 | free (simIO.path); |
| 666 | free (simIO.data); |
| 667 | free (simIO.pin2); |
| 668 | |
| 669 | #ifdef MEMSET_FREED |
| 670 | memset(&simIO, 0, sizeof(simIO)); |
| 671 | #endif |
| 672 | |
| 673 | return; |
| 674 | invalid: |
| 675 | invalidCommandBlock(pRI); |
| 676 | return; |
| 677 | } |
| 678 | |
| 679 | /** |
| 680 | * Callee expects const RIL_CallForwardInfo * |
| 681 | * Payload is: |
| 682 | * int32_t status/action |
| 683 | * int32_t reason |
| 684 | * int32_t serviceCode |
| 685 | * int32_t toa |
| 686 | * String number (0 length -> null) |
| 687 | * int32_t timeSeconds |
| 688 | */ |
| 689 | static void |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 690 | dispatchCallForward(Parcel &p, RequestInfo *pRI) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 691 | RIL_CallForwardInfo cff; |
| 692 | int32_t t; |
| 693 | status_t status; |
| 694 | |
| 695 | memset (&cff, 0, sizeof(cff)); |
| 696 | |
| 697 | // note we only check status at the end |
| 698 | |
| 699 | status = p.readInt32(&t); |
| 700 | cff.status = (int)t; |
| 701 | |
| 702 | status = p.readInt32(&t); |
| 703 | cff.reason = (int)t; |
| 704 | |
| 705 | status = p.readInt32(&t); |
| 706 | cff.serviceClass = (int)t; |
| 707 | |
| 708 | status = p.readInt32(&t); |
| 709 | cff.toa = (int)t; |
| 710 | |
| 711 | cff.number = strdupReadString(p); |
| 712 | |
| 713 | status = p.readInt32(&t); |
| 714 | cff.timeSeconds = (int)t; |
| 715 | |
| 716 | if (status != NO_ERROR) { |
| 717 | goto invalid; |
| 718 | } |
| 719 | |
| 720 | // special case: number 0-length fields is null |
| 721 | |
| 722 | if (cff.number != NULL && strlen (cff.number) == 0) { |
| 723 | cff.number = NULL; |
| 724 | } |
| 725 | |
| 726 | startRequest; |
| 727 | appendPrintBuf("%sstat=%d,reason=%d,serv=%d,toa=%d,%s,tout=%d", printBuf, |
| 728 | cff.status, cff.reason, cff.serviceClass, cff.toa, |
| 729 | (char*)cff.number, cff.timeSeconds); |
| 730 | closeRequest; |
| 731 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 732 | |
| 733 | s_callbacks.onRequest(pRI->pCI->requestNumber, &cff, sizeof(cff), pRI); |
| 734 | |
| 735 | #ifdef MEMSET_FREED |
| 736 | memsetString(cff.number); |
| 737 | #endif |
| 738 | |
| 739 | free (cff.number); |
| 740 | |
| 741 | #ifdef MEMSET_FREED |
| 742 | memset(&cff, 0, sizeof(cff)); |
| 743 | #endif |
| 744 | |
| 745 | return; |
| 746 | invalid: |
| 747 | invalidCommandBlock(pRI); |
| 748 | return; |
| 749 | } |
| 750 | |
| 751 | |
| 752 | static void |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 753 | dispatchRaw(Parcel &p, RequestInfo *pRI) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 754 | int32_t len; |
| 755 | status_t status; |
| 756 | const void *data; |
| 757 | |
| 758 | status = p.readInt32(&len); |
| 759 | |
| 760 | if (status != NO_ERROR) { |
| 761 | goto invalid; |
| 762 | } |
| 763 | |
| 764 | // The java code writes -1 for null arrays |
| 765 | if (((int)len) == -1) { |
| 766 | data = NULL; |
| 767 | len = 0; |
| 768 | } |
| 769 | |
| 770 | data = p.readInplace(len); |
| 771 | |
| 772 | startRequest; |
| 773 | appendPrintBuf("%sraw_size=%d", printBuf, len); |
| 774 | closeRequest; |
| 775 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 776 | |
| 777 | s_callbacks.onRequest(pRI->pCI->requestNumber, const_cast<void *>(data), len, pRI); |
| 778 | |
| 779 | return; |
| 780 | invalid: |
| 781 | invalidCommandBlock(pRI); |
| 782 | return; |
| 783 | } |
| 784 | |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 785 | static void |
| 786 | dispatchCdmaSms(Parcel &p, RequestInfo *pRI) { |
| 787 | RIL_CDMA_SMS_Message rcsm; |
| 788 | int32_t t; |
| 789 | uint8_t ut; |
| 790 | status_t status; |
| 791 | int32_t digitCount; |
| 792 | int digitLimit; |
| 793 | |
| 794 | memset(&rcsm, 0, sizeof(rcsm)); |
| 795 | |
| 796 | status = p.readInt32(&t); |
| 797 | rcsm.uTeleserviceID = (int) t; |
| 798 | |
| 799 | status = p.read(&ut,sizeof(ut)); |
| 800 | rcsm.bIsServicePresent = (uint8_t) ut; |
| 801 | |
| 802 | status = p.readInt32(&t); |
| 803 | rcsm.uServicecategory = (int) t; |
| 804 | |
| 805 | status = p.readInt32(&t); |
| 806 | rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) t; |
| 807 | |
| 808 | status = p.readInt32(&t); |
| 809 | rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) t; |
| 810 | |
| 811 | status = p.readInt32(&t); |
| 812 | rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) t; |
| 813 | |
| 814 | status = p.readInt32(&t); |
| 815 | rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) t; |
| 816 | |
| 817 | status = p.read(&ut,sizeof(ut)); |
| 818 | rcsm.sAddress.number_of_digits= (uint8_t) ut; |
| 819 | |
| 820 | digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX); |
| 821 | for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { |
| 822 | status = p.read(&ut,sizeof(ut)); |
| 823 | rcsm.sAddress.digits[digitCount] = (uint8_t) ut; |
| 824 | } |
| 825 | |
| 826 | status = p.readInt32(&t); |
| 827 | rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) t; |
| 828 | |
| 829 | status = p.read(&ut,sizeof(ut)); |
| 830 | rcsm.sSubAddress.odd = (uint8_t) ut; |
| 831 | |
| 832 | status = p.read(&ut,sizeof(ut)); |
| 833 | rcsm.sSubAddress.number_of_digits = (uint8_t) ut; |
| 834 | |
| 835 | digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX); |
| 836 | for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { |
| 837 | status = p.read(&ut,sizeof(ut)); |
| 838 | rcsm.sSubAddress.digits[digitCount] = (uint8_t) ut; |
| 839 | } |
| 840 | |
| 841 | status = p.readInt32(&t); |
| 842 | rcsm.uBearerDataLen = (int) t; |
| 843 | |
| 844 | digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX); |
| 845 | for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { |
| 846 | status = p.read(&ut, sizeof(ut)); |
| 847 | rcsm.aBearerData[digitCount] = (uint8_t) ut; |
| 848 | } |
| 849 | |
| 850 | if (status != NO_ERROR) { |
| 851 | goto invalid; |
| 852 | } |
| 853 | |
| 854 | startRequest; |
| 855 | appendPrintBuf("%suTeleserviceID=%d, bIsServicePresent=%d, uServicecategory=%d, \ |
| 856 | sAddress.digitmode=%d, sAddress.NumberMode=%d, sAddress.numberType=%d, ", |
| 857 | printBuf, rcsm.uTeleserviceID,rcsm.bIsServicePresent,rcsm.uServicecategory, |
| 858 | rcsm.sAddress.digitMode, rcsm.sAddress.numberMode,rcsm.sAddress.numberType); |
| 859 | closeRequest; |
| 860 | |
| 861 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 862 | |
| 863 | s_callbacks.onRequest(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm),pRI); |
| 864 | |
| 865 | #ifdef MEMSET_FREED |
| 866 | memset(&rcsm, 0, sizeof(rcsm)); |
| 867 | #endif |
| 868 | |
| 869 | return; |
| 870 | |
| 871 | invalid: |
| 872 | invalidCommandBlock(pRI); |
| 873 | return; |
| 874 | } |
| 875 | |
| 876 | static void |
| 877 | dispatchCdmaSmsAck(Parcel &p, RequestInfo *pRI) { |
| 878 | RIL_CDMA_SMS_Ack rcsa; |
| 879 | int32_t t; |
| 880 | status_t status; |
| 881 | int32_t digitCount; |
| 882 | |
| 883 | memset(&rcsa, 0, sizeof(rcsa)); |
| 884 | |
| 885 | status = p.readInt32(&t); |
| 886 | rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) t; |
| 887 | |
| 888 | status = p.readInt32(&t); |
| 889 | rcsa.uSMSCauseCode = (int) t; |
| 890 | |
| 891 | if (status != NO_ERROR) { |
| 892 | goto invalid; |
| 893 | } |
| 894 | |
| 895 | startRequest; |
| 896 | appendPrintBuf("%suBearerReplySeq=%d, uErrorClass=%d, uTLStatus=%d, ", |
| 897 | printBuf, rcsa.uBearerReplySeq,rcsa.uErrorClass,rcsa.uSMSCauseCode); |
| 898 | closeRequest; |
| 899 | |
| 900 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 901 | |
| 902 | s_callbacks.onRequest(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa),pRI); |
| 903 | |
| 904 | #ifdef MEMSET_FREED |
| 905 | memset(&rcsa, 0, sizeof(rcsa)); |
| 906 | #endif |
| 907 | |
| 908 | return; |
| 909 | |
| 910 | invalid: |
| 911 | invalidCommandBlock(pRI); |
| 912 | return; |
| 913 | } |
| 914 | |
| 915 | static void |
| 916 | dispatchBrSmsCnf(Parcel &p, RequestInfo *pRI) { |
| 917 | RIL_BroadcastSMSConfig rbsc; |
| 918 | int32_t t; |
| 919 | uint8_t ut; |
| 920 | status_t status; |
| 921 | int32_t digitCount; |
| 922 | |
| 923 | memset(&rbsc, 0, sizeof(rbsc)); |
| 924 | |
| 925 | status = p.readInt32(&t); |
| 926 | rbsc.size = (int) t; |
| 927 | |
| 928 | status = p.readInt32(&t); |
| 929 | rbsc.entries->uFromServiceID = (int) t; |
| 930 | |
| 931 | status = p.readInt32(&t); |
| 932 | rbsc.entries->uToserviceID = (int) t; |
| 933 | |
| 934 | //usage of read function on assumption that it reads any length given as 2nd argument |
| 935 | status = p.read(&ut,sizeof(ut)); |
| 936 | rbsc.entries->bSelected = (uint8_t) ut; |
| 937 | |
| 938 | if (status != NO_ERROR) { |
| 939 | goto invalid; |
| 940 | } |
| 941 | |
| 942 | startRequest; |
| 943 | appendPrintBuf("%ssize=%d, uServicecategory=%d, entries.uFromServiceID=%d, \ |
| 944 | entries.uToserviceID=%d, entries.bSelected =%d, ", printBuf, |
| 945 | rbsc.size,rbsc.entries->uFromServiceID, rbsc.entries->uToserviceID, |
| 946 | rbsc.entries->bSelected); |
| 947 | closeRequest; |
| 948 | |
| 949 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 950 | |
| 951 | s_callbacks.onRequest(pRI->pCI->requestNumber, &rbsc, sizeof(rbsc),pRI); |
| 952 | |
| 953 | #ifdef MEMSET_FREED |
| 954 | memset(&rbsc, 0, sizeof(rbsc)); |
| 955 | #endif |
| 956 | |
| 957 | return; |
| 958 | |
| 959 | invalid: |
| 960 | invalidCommandBlock(pRI); |
| 961 | return; |
| 962 | |
| 963 | } |
| 964 | |
| 965 | static void |
| 966 | dispatchCdmaBrSmsCnf(Parcel &p, RequestInfo *pRI) { |
| 967 | RIL_CDMA_BroadcastSMSConfig rcbsc; |
| 968 | int32_t t; |
| 969 | uint8_t ut; |
| 970 | status_t status; |
| 971 | int32_t digitCount; |
| 972 | |
| 973 | memset(&rcbsc, 0, sizeof(rcbsc)); |
| 974 | |
| 975 | status = p.readInt32(&t); |
| 976 | rcbsc.size = (int) t; |
| 977 | |
| 978 | status = p.readInt32(&t); |
| 979 | rcbsc.entries->uServiceCategory = (int) t; |
| 980 | |
| 981 | status = p.readInt32(&t); |
| 982 | rcbsc.entries->uLanguage = (int) t; |
| 983 | |
| 984 | status = p.read(&ut, sizeof(ut)); |
| 985 | rcbsc.entries->bSelected = (uint8_t) ut; |
| 986 | |
| 987 | if (status != NO_ERROR) { |
| 988 | goto invalid; |
| 989 | } |
| 990 | |
| 991 | startRequest; |
| 992 | appendPrintBuf("%sbIsEnabled=%d, size=%d, entries.uServicecategory=%d, \ |
| 993 | entries.uLanguage =%d, entries.bSelected =%d, ", printBuf, rcbsc.bIsEnabled,rcbsc.size, |
| 994 | rcbsc.entries->uServiceCategory,rcbsc.entries->uLanguage, rcbsc.entries->bSelected); |
| 995 | closeRequest; |
| 996 | |
| 997 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 998 | |
| 999 | s_callbacks.onRequest(pRI->pCI->requestNumber, &rcbsc, sizeof(rcbsc),pRI); |
| 1000 | |
| 1001 | #ifdef MEMSET_FREED |
| 1002 | memset(&rcbsc, 0, sizeof(rcbsc)); |
| 1003 | #endif |
| 1004 | |
| 1005 | return; |
| 1006 | |
| 1007 | invalid: |
| 1008 | invalidCommandBlock(pRI); |
| 1009 | return; |
| 1010 | |
| 1011 | } |
| 1012 | |
| 1013 | static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI) { |
| 1014 | RIL_CDMA_SMS_WriteArgs rcsw; |
| 1015 | int32_t t; |
| 1016 | uint32_t ut; |
| 1017 | uint8_t uct; |
| 1018 | status_t status; |
| 1019 | int32_t digitCount; |
| 1020 | |
| 1021 | memset(&rcsw, 0, sizeof(rcsw)); |
| 1022 | |
| 1023 | status = p.readInt32(&t); |
| 1024 | rcsw.status = t; |
| 1025 | |
| 1026 | status = p.readInt32(&t); |
| 1027 | rcsw.message.uTeleserviceID = (int) t; |
| 1028 | |
| 1029 | status = p.read(&uct,sizeof(uct)); |
| 1030 | rcsw.message.bIsServicePresent = (uint8_t) uct; |
| 1031 | |
| 1032 | status = p.readInt32(&t); |
| 1033 | rcsw.message.uServicecategory = (int) t; |
| 1034 | |
| 1035 | status = p.readInt32(&t); |
| 1036 | rcsw.message.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) t; |
| 1037 | |
| 1038 | status = p.readInt32(&t); |
| 1039 | rcsw.message.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) t; |
| 1040 | |
| 1041 | status = p.readInt32(&t); |
| 1042 | rcsw.message.sAddress.number_type = (RIL_CDMA_SMS_NumberType) t; |
| 1043 | |
| 1044 | status = p.readInt32(&t); |
| 1045 | rcsw.message.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) t; |
| 1046 | |
| 1047 | status = p.read(&uct,sizeof(uct)); |
| 1048 | rcsw.message.sAddress.number_of_digits = (uint8_t) uct; |
| 1049 | |
| 1050 | for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_ADDRESS_MAX; digitCount ++) { |
| 1051 | status = p.read(&uct,sizeof(uct)); |
| 1052 | rcsw.message.sAddress.digits[digitCount] = (uint8_t) uct; |
| 1053 | } |
| 1054 | |
| 1055 | status = p.readInt32(&t); |
| 1056 | rcsw.message.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) t; |
| 1057 | |
| 1058 | status = p.read(&uct,sizeof(uct)); |
| 1059 | rcsw.message.sSubAddress.odd = (uint8_t) uct; |
| 1060 | |
| 1061 | status = p.read(&uct,sizeof(uct)); |
| 1062 | rcsw.message.sSubAddress.number_of_digits = (uint8_t) uct; |
| 1063 | |
| 1064 | for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_SUBADDRESS_MAX; digitCount ++) { |
| 1065 | status = p.read(&uct,sizeof(uct)); |
| 1066 | rcsw.message.sSubAddress.digits[digitCount] = (uint8_t) uct; |
| 1067 | } |
| 1068 | |
| 1069 | status = p.readInt32(&t); |
| 1070 | rcsw.message.uBearerDataLen = (int) t; |
| 1071 | |
| 1072 | for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_BEARER_DATA_MAX; digitCount ++) { |
| 1073 | status = p.read(&uct, sizeof(uct)); |
| 1074 | rcsw.message.aBearerData[digitCount] = (uint8_t) uct; |
| 1075 | } |
| 1076 | |
| 1077 | if (status != NO_ERROR) { |
| 1078 | goto invalid; |
| 1079 | } |
| 1080 | |
| 1081 | startRequest; |
| 1082 | appendPrintBuf("%sstatus=%d, message.uTeleserviceID=%d, message.bIsServicePresent=%d, |
| 1083 | message.uServicecategory=%d, message.sAddress.digitmode=%d, |
| 1084 | message.sAddress.NumberMode=%d, |
| 1085 | message.sAddress.numberType=%d, ", |
| 1086 | printBuf, rcsw.status, rcsw.message.uTeleserviceID, rcsw.message.bIsServicePresent, |
| 1087 | rcsw.message.uServicecategory, rcsw.message.sAddress.digitMode, |
| 1088 | rcsw.message.sAddress.numberMode, |
| 1089 | rcsw.message.sAddress.numberType); |
| 1090 | closeRequest; |
| 1091 | |
| 1092 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 1093 | |
| 1094 | s_callbacks.onRequest(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw),pRI); |
| 1095 | |
| 1096 | #ifdef MEMSET_FREED |
| 1097 | memset(&rcsw, 0, sizeof(rcsw)); |
| 1098 | #endif |
| 1099 | |
| 1100 | return; |
| 1101 | |
| 1102 | invalid: |
| 1103 | invalidCommandBlock(pRI); |
| 1104 | return; |
| 1105 | |
| 1106 | } |
| 1107 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1108 | static int |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1109 | blockingWrite(int fd, const void *buffer, size_t len) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1110 | size_t writeOffset = 0; |
| 1111 | const uint8_t *toWrite; |
| 1112 | |
| 1113 | toWrite = (const uint8_t *)buffer; |
| 1114 | |
| 1115 | while (writeOffset < len) { |
| 1116 | ssize_t written; |
| 1117 | do { |
| 1118 | written = write (fd, toWrite + writeOffset, |
| 1119 | len - writeOffset); |
| 1120 | } while (written < 0 && errno == EINTR); |
| 1121 | |
| 1122 | if (written >= 0) { |
| 1123 | writeOffset += written; |
| 1124 | } else { // written < 0 |
| 1125 | LOGE ("RIL Response: unexpected error on write errno:%d", errno); |
| 1126 | close(fd); |
| 1127 | return -1; |
| 1128 | } |
| 1129 | } |
| 1130 | |
| 1131 | return 0; |
| 1132 | } |
| 1133 | |
| 1134 | static int |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1135 | sendResponseRaw (const void *data, size_t dataSize) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1136 | int fd = s_fdCommand; |
| 1137 | int ret; |
| 1138 | uint32_t header; |
| 1139 | |
| 1140 | if (s_fdCommand < 0) { |
| 1141 | return -1; |
| 1142 | } |
| 1143 | |
| 1144 | if (dataSize > MAX_COMMAND_BYTES) { |
| 1145 | LOGE("RIL: packet larger than %u (%u)", |
| 1146 | MAX_COMMAND_BYTES, (unsigned int )dataSize); |
| 1147 | |
| 1148 | return -1; |
| 1149 | } |
| 1150 | |
| 1151 | |
| 1152 | // FIXME is blocking here ok? issue #550970 |
| 1153 | |
| 1154 | pthread_mutex_lock(&s_writeMutex); |
| 1155 | |
| 1156 | header = htonl(dataSize); |
| 1157 | |
| 1158 | ret = blockingWrite(fd, (void *)&header, sizeof(header)); |
| 1159 | |
| 1160 | if (ret < 0) { |
| 1161 | return ret; |
| 1162 | } |
| 1163 | |
| 1164 | blockingWrite(fd, data, dataSize); |
| 1165 | |
| 1166 | if (ret < 0) { |
| 1167 | return ret; |
| 1168 | } |
| 1169 | |
| 1170 | pthread_mutex_unlock(&s_writeMutex); |
| 1171 | |
| 1172 | return 0; |
| 1173 | } |
| 1174 | |
| 1175 | static int |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1176 | sendResponse (Parcel &p) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1177 | printResponse; |
| 1178 | return sendResponseRaw(p.data(), p.dataSize()); |
| 1179 | } |
| 1180 | |
| 1181 | /** response is an int* pointing to an array of ints*/ |
| 1182 | |
| 1183 | static int |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1184 | responseInts(Parcel &p, void *response, size_t responselen) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1185 | int numInts; |
| 1186 | |
| 1187 | if (response == NULL && responselen != 0) { |
| 1188 | LOGE("invalid response: NULL"); |
| 1189 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1190 | } |
| 1191 | if (responselen % sizeof(int) != 0) { |
| 1192 | LOGE("invalid response length %d expected multiple of %d\n", |
| 1193 | (int)responselen, (int)sizeof(int)); |
| 1194 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1195 | } |
| 1196 | |
| 1197 | int *p_int = (int *) response; |
| 1198 | |
| 1199 | numInts = responselen / sizeof(int *); |
| 1200 | p.writeInt32 (numInts); |
| 1201 | |
| 1202 | /* each int*/ |
| 1203 | startResponse; |
| 1204 | for (int i = 0 ; i < numInts ; i++) { |
| 1205 | appendPrintBuf("%s%d,", printBuf, p_int[i]); |
| 1206 | p.writeInt32(p_int[i]); |
| 1207 | } |
| 1208 | removeLastChar; |
| 1209 | closeResponse; |
| 1210 | |
| 1211 | return 0; |
| 1212 | } |
| 1213 | |
| 1214 | /** response is a char **, pointing to an array of char *'s */ |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1215 | static int responseStrings(Parcel &p, void *response, size_t responselen) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1216 | int numStrings; |
| 1217 | |
| 1218 | if (response == NULL && responselen != 0) { |
| 1219 | LOGE("invalid response: NULL"); |
| 1220 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1221 | } |
| 1222 | if (responselen % sizeof(char *) != 0) { |
| 1223 | LOGE("invalid response length %d expected multiple of %d\n", |
| 1224 | (int)responselen, (int)sizeof(char *)); |
| 1225 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1226 | } |
| 1227 | |
| 1228 | if (response == NULL) { |
| 1229 | p.writeInt32 (0); |
| 1230 | } else { |
| 1231 | char **p_cur = (char **) response; |
| 1232 | |
| 1233 | numStrings = responselen / sizeof(char *); |
| 1234 | p.writeInt32 (numStrings); |
| 1235 | |
| 1236 | /* each string*/ |
| 1237 | startResponse; |
| 1238 | for (int i = 0 ; i < numStrings ; i++) { |
| 1239 | appendPrintBuf("%s%s,", printBuf, (char*)p_cur[i]); |
| 1240 | writeStringToParcel (p, p_cur[i]); |
| 1241 | } |
| 1242 | removeLastChar; |
| 1243 | closeResponse; |
| 1244 | } |
| 1245 | return 0; |
| 1246 | } |
| 1247 | |
| 1248 | |
| 1249 | /** |
| 1250 | * NULL strings are accepted |
| 1251 | * FIXME currently ignores responselen |
| 1252 | */ |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1253 | static int responseString(Parcel &p, void *response, size_t responselen) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1254 | /* one string only */ |
| 1255 | startResponse; |
| 1256 | appendPrintBuf("%s%s", printBuf, (char*)response); |
| 1257 | closeResponse; |
| 1258 | |
| 1259 | writeStringToParcel(p, (const char *)response); |
| 1260 | |
| 1261 | return 0; |
| 1262 | } |
| 1263 | |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1264 | static int responseVoid(Parcel &p, void *response, size_t responselen) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1265 | startResponse; |
| 1266 | removeLastChar; |
| 1267 | return 0; |
| 1268 | } |
| 1269 | |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1270 | static int responseCallList(Parcel &p, void *response, size_t responselen) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1271 | int num; |
| 1272 | |
| 1273 | if (response == NULL && responselen != 0) { |
| 1274 | LOGE("invalid response: NULL"); |
| 1275 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1276 | } |
| 1277 | |
| 1278 | if (responselen % sizeof (RIL_Call *) != 0) { |
| 1279 | LOGE("invalid response length %d expected multiple of %d\n", |
| 1280 | (int)responselen, (int)sizeof (RIL_Call *)); |
| 1281 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1282 | } |
| 1283 | |
| 1284 | startResponse; |
| 1285 | /* number of call info's */ |
| 1286 | num = responselen / sizeof(RIL_Call *); |
| 1287 | p.writeInt32(num); |
| 1288 | |
| 1289 | for (int i = 0 ; i < num ; i++) { |
| 1290 | RIL_Call *p_cur = ((RIL_Call **) response)[i]; |
| 1291 | /* each call info */ |
| 1292 | p.writeInt32(p_cur->state); |
| 1293 | p.writeInt32(p_cur->index); |
| 1294 | p.writeInt32(p_cur->toa); |
| 1295 | p.writeInt32(p_cur->isMpty); |
| 1296 | p.writeInt32(p_cur->isMT); |
| 1297 | p.writeInt32(p_cur->als); |
| 1298 | p.writeInt32(p_cur->isVoice); |
| 1299 | writeStringToParcel (p, p_cur->number); |
John Wang | ff36874 | 2009-03-24 17:56:29 -0700 | [diff] [blame] | 1300 | p.writeInt32(p_cur->numberPresentation); |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1301 | appendPrintBuf("%s[%s,id=%d,toa=%d,%s,%s,als=%d,%s,%s,cli=%d],", |
John Wang | ff36874 | 2009-03-24 17:56:29 -0700 | [diff] [blame] | 1302 | printBuf, |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1303 | callStateToString(p_cur->state), |
| 1304 | p_cur->index, p_cur->toa, |
| 1305 | (p_cur->isMpty)?"mpty":"norm", |
| 1306 | (p_cur->isMT)?"mt":"mo", |
| 1307 | p_cur->als, |
| 1308 | (p_cur->isVoice)?"voc":"nonvoc", |
John Wang | ff36874 | 2009-03-24 17:56:29 -0700 | [diff] [blame] | 1309 | (char*)p_cur->number, |
| 1310 | p_cur->numberPresentation); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1311 | } |
| 1312 | removeLastChar; |
| 1313 | closeResponse; |
| 1314 | |
| 1315 | return 0; |
| 1316 | } |
| 1317 | |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1318 | static int responseSMS(Parcel &p, void *response, size_t responselen) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1319 | if (response == NULL) { |
| 1320 | LOGE("invalid response: NULL"); |
| 1321 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1322 | } |
| 1323 | |
| 1324 | if (responselen != sizeof (RIL_SMS_Response) ) { |
| 1325 | LOGE("invalid response length %d expected %d", |
| 1326 | (int)responselen, (int)sizeof (RIL_SMS_Response)); |
| 1327 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1328 | } |
| 1329 | |
| 1330 | RIL_SMS_Response *p_cur = (RIL_SMS_Response *) response; |
| 1331 | |
| 1332 | p.writeInt32(p_cur->messageRef); |
| 1333 | writeStringToParcel(p, p_cur->ackPDU); |
| 1334 | |
| 1335 | startResponse; |
| 1336 | appendPrintBuf("%s%d,%s", printBuf, p_cur->messageRef, |
| 1337 | (char*)p_cur->ackPDU); |
| 1338 | closeResponse; |
| 1339 | |
| 1340 | return 0; |
| 1341 | } |
| 1342 | |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1343 | static int responseDataCallList(Parcel &p, void *response, size_t responselen) |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1344 | { |
| 1345 | if (response == NULL && responselen != 0) { |
| 1346 | LOGE("invalid response: NULL"); |
| 1347 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1348 | } |
| 1349 | |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1350 | if (responselen % sizeof(RIL_Data_Call_Response) != 0) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1351 | LOGE("invalid response length %d expected multiple of %d", |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1352 | (int)responselen, (int)sizeof(RIL_Data_Call_Response)); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1353 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1354 | } |
| 1355 | |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1356 | int num = responselen / sizeof(RIL_Data_Call_Response); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1357 | p.writeInt32(num); |
| 1358 | |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1359 | RIL_Data_Call_Response *p_cur = (RIL_Data_Call_Response *) response; |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1360 | startResponse; |
| 1361 | int i; |
| 1362 | for (i = 0; i < num; i++) { |
| 1363 | p.writeInt32(p_cur[i].cid); |
| 1364 | p.writeInt32(p_cur[i].active); |
| 1365 | writeStringToParcel(p, p_cur[i].type); |
| 1366 | writeStringToParcel(p, p_cur[i].apn); |
| 1367 | writeStringToParcel(p, p_cur[i].address); |
| 1368 | appendPrintBuf("%s[cid=%d,%s,%s,%s,%s],", printBuf, |
| 1369 | p_cur[i].cid, |
| 1370 | (p_cur[i].active==0)?"down":"up", |
| 1371 | (char*)p_cur[i].type, |
| 1372 | (char*)p_cur[i].apn, |
| 1373 | (char*)p_cur[i].address); |
| 1374 | } |
| 1375 | removeLastChar; |
| 1376 | closeResponse; |
| 1377 | |
| 1378 | return 0; |
| 1379 | } |
| 1380 | |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1381 | static int responseRaw(Parcel &p, void *response, size_t responselen) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1382 | if (response == NULL && responselen != 0) { |
| 1383 | LOGE("invalid response: NULL with responselen != 0"); |
| 1384 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1385 | } |
| 1386 | |
| 1387 | // The java code reads -1 size as null byte array |
| 1388 | if (response == NULL) { |
| 1389 | p.writeInt32(-1); |
| 1390 | } else { |
| 1391 | p.writeInt32(responselen); |
| 1392 | p.write(response, responselen); |
| 1393 | } |
| 1394 | |
| 1395 | return 0; |
| 1396 | } |
| 1397 | |
| 1398 | |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1399 | static int responseSIM_IO(Parcel &p, void *response, size_t responselen) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1400 | if (response == NULL) { |
| 1401 | LOGE("invalid response: NULL"); |
| 1402 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1403 | } |
| 1404 | |
| 1405 | if (responselen != sizeof (RIL_SIM_IO_Response) ) { |
| 1406 | LOGE("invalid response length was %d expected %d", |
| 1407 | (int)responselen, (int)sizeof (RIL_SIM_IO_Response)); |
| 1408 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1409 | } |
| 1410 | |
| 1411 | RIL_SIM_IO_Response *p_cur = (RIL_SIM_IO_Response *) response; |
| 1412 | p.writeInt32(p_cur->sw1); |
| 1413 | p.writeInt32(p_cur->sw2); |
| 1414 | writeStringToParcel(p, p_cur->simResponse); |
| 1415 | |
| 1416 | startResponse; |
| 1417 | appendPrintBuf("%ssw1=0x%X,sw2=0x%X,%s", printBuf, p_cur->sw1, p_cur->sw2, |
| 1418 | (char*)p_cur->simResponse); |
| 1419 | closeResponse; |
| 1420 | |
| 1421 | |
| 1422 | return 0; |
| 1423 | } |
| 1424 | |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1425 | static int responseCallForwards(Parcel &p, void *response, size_t responselen) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1426 | int num; |
| 1427 | |
| 1428 | if (response == NULL && responselen != 0) { |
| 1429 | LOGE("invalid response: NULL"); |
| 1430 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1431 | } |
| 1432 | |
| 1433 | if (responselen % sizeof(RIL_CallForwardInfo *) != 0) { |
| 1434 | LOGE("invalid response length %d expected multiple of %d", |
| 1435 | (int)responselen, (int)sizeof(RIL_CallForwardInfo *)); |
| 1436 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1437 | } |
| 1438 | |
| 1439 | /* number of call info's */ |
| 1440 | num = responselen / sizeof(RIL_CallForwardInfo *); |
| 1441 | p.writeInt32(num); |
| 1442 | |
| 1443 | startResponse; |
| 1444 | for (int i = 0 ; i < num ; i++) { |
| 1445 | RIL_CallForwardInfo *p_cur = ((RIL_CallForwardInfo **) response)[i]; |
| 1446 | |
| 1447 | p.writeInt32(p_cur->status); |
| 1448 | p.writeInt32(p_cur->reason); |
| 1449 | p.writeInt32(p_cur->serviceClass); |
| 1450 | p.writeInt32(p_cur->toa); |
| 1451 | writeStringToParcel(p, p_cur->number); |
| 1452 | p.writeInt32(p_cur->timeSeconds); |
| 1453 | appendPrintBuf("%s[%s,reason=%d,cls=%d,toa=%d,%s,tout=%d],", printBuf, |
| 1454 | (p_cur->status==1)?"enable":"disable", |
| 1455 | p_cur->reason, p_cur->serviceClass, p_cur->toa, |
| 1456 | (char*)p_cur->number, |
| 1457 | p_cur->timeSeconds); |
| 1458 | } |
| 1459 | removeLastChar; |
| 1460 | closeResponse; |
| 1461 | |
| 1462 | return 0; |
| 1463 | } |
| 1464 | |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1465 | static int responseSsn(Parcel &p, void *response, size_t responselen) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1466 | if (response == NULL) { |
| 1467 | LOGE("invalid response: NULL"); |
| 1468 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1469 | } |
| 1470 | |
| 1471 | if (responselen != sizeof(RIL_SuppSvcNotification)) { |
| 1472 | LOGE("invalid response length was %d expected %d", |
| 1473 | (int)responselen, (int)sizeof (RIL_SuppSvcNotification)); |
| 1474 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1475 | } |
| 1476 | |
| 1477 | RIL_SuppSvcNotification *p_cur = (RIL_SuppSvcNotification *) response; |
| 1478 | p.writeInt32(p_cur->notificationType); |
| 1479 | p.writeInt32(p_cur->code); |
| 1480 | p.writeInt32(p_cur->index); |
| 1481 | p.writeInt32(p_cur->type); |
| 1482 | writeStringToParcel(p, p_cur->number); |
| 1483 | |
| 1484 | startResponse; |
| 1485 | appendPrintBuf("%s%s,code=%d,id=%d,type=%d,%s", printBuf, |
| 1486 | (p_cur->notificationType==0)?"mo":"mt", |
| 1487 | p_cur->code, p_cur->index, p_cur->type, |
| 1488 | (char*)p_cur->number); |
| 1489 | closeResponse; |
| 1490 | |
| 1491 | return 0; |
| 1492 | } |
| 1493 | |
| 1494 | static int responseCellList(Parcel &p, void *response, size_t responselen) |
| 1495 | { |
| 1496 | int num; |
| 1497 | |
| 1498 | if (response == NULL && responselen != 0) { |
| 1499 | LOGE("invalid response: NULL"); |
| 1500 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1501 | } |
| 1502 | |
| 1503 | if (responselen % sizeof (RIL_NeighboringCell *) != 0) { |
| 1504 | LOGE("invalid response length %d expected multiple of %d\n", |
| 1505 | (int)responselen, (int)sizeof (RIL_NeighboringCell *)); |
| 1506 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1507 | } |
| 1508 | |
| 1509 | startResponse; |
| 1510 | /* number of cell info's */ |
| 1511 | num = responselen / sizeof(RIL_NeighboringCell *); |
| 1512 | p.writeInt32(num); |
| 1513 | |
| 1514 | for (int i = 0 ; i < num ; i++) { |
| 1515 | RIL_NeighboringCell *p_cur = ((RIL_NeighboringCell **) response)[i]; |
| 1516 | |
| 1517 | /* each cell info */ |
| 1518 | p.writeInt32(p_cur->rssi); |
| 1519 | writeStringToParcel (p, p_cur->cid); |
| 1520 | |
| 1521 | appendPrintBuf("%s[cid=%s,rssi=%d],", printBuf, |
| 1522 | p_cur->cid, p_cur->rssi); |
| 1523 | } |
| 1524 | removeLastChar; |
| 1525 | closeResponse; |
| 1526 | |
| 1527 | return 0; |
| 1528 | } |
| 1529 | |
| 1530 | static void triggerEvLoop() |
| 1531 | { |
| 1532 | int ret; |
| 1533 | if (!pthread_equal(pthread_self(), s_tid_dispatch)) { |
| 1534 | /* trigger event loop to wakeup. No reason to do this, |
| 1535 | * if we're in the event loop thread */ |
| 1536 | do { |
| 1537 | ret = write (s_fdWakeupWrite, " ", 1); |
| 1538 | } while (ret < 0 && errno == EINTR); |
| 1539 | } |
| 1540 | } |
| 1541 | |
| 1542 | static void rilEventAddWakeup(struct ril_event *ev) |
| 1543 | { |
| 1544 | ril_event_add(ev); |
| 1545 | triggerEvLoop(); |
| 1546 | } |
| 1547 | |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1548 | static int responseSimStatus(Parcel &p, void *response, size_t responselen) { |
| 1549 | int i; |
| 1550 | |
| 1551 | if (response == NULL && responselen != 0) { |
| 1552 | LOGE("invalid response: NULL"); |
| 1553 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1554 | } |
| 1555 | |
| 1556 | if (responselen % sizeof (RIL_CardStatus *) != 0) { |
| 1557 | LOGE("invalid response length %d expected multiple of %d\n", |
| 1558 | (int)responselen, (int)sizeof (RIL_CardStatus *)); |
| 1559 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1560 | } |
| 1561 | |
| 1562 | RIL_CardStatus *p_cur = ((RIL_CardStatus *) response); |
| 1563 | |
| 1564 | p.writeInt32(p_cur->card_state); |
| 1565 | p.writeInt32(p_cur->universal_pin_state); |
| 1566 | p.writeInt32(p_cur->gsm_umts_subscription_app_index); |
| 1567 | p.writeInt32(p_cur->cdma_subscription_app_index); |
| 1568 | p.writeInt32(p_cur->num_applications); |
| 1569 | |
| 1570 | startResponse; |
| 1571 | for (i = 0; i < p_cur->num_applications; i++) { |
| 1572 | p.writeInt32(p_cur->applications[i].app_type); |
| 1573 | p.writeInt32(p_cur->applications[i].app_state); |
| 1574 | p.writeInt32(p_cur->applications[i].perso_substate); |
| 1575 | writeStringToParcel (p, (const char*)(p_cur->applications[i].aid_ptr)); |
| 1576 | writeStringToParcel (p, (const char*)(p_cur->applications[i].app_label_ptr)); |
| 1577 | p.writeInt32(p_cur->applications[i].pin1_replaced); |
| 1578 | p.writeInt32(p_cur->applications[i].pin1); |
| 1579 | p.writeInt32(p_cur->applications[i].pin2); |
| 1580 | appendPrintBuf("%s[app_type=%d,app_state=%d,perso_substate=%d,aid_ptr=%s,\ |
| 1581 | app_label_ptr=%s,pin1_replaced=%d,pin1=%d,pin2=%d],", |
| 1582 | printBuf, |
| 1583 | p_cur->applications[i].app_type, |
| 1584 | p_cur->applications[i].app_state, |
| 1585 | p_cur->applications[i].perso_substate, |
| 1586 | p_cur->applications[i].aid_ptr, |
| 1587 | p_cur->applications[i].app_label_ptr, |
| 1588 | p_cur->applications[i].pin1_replaced, |
| 1589 | p_cur->applications[i].pin1, |
| 1590 | p_cur->applications[i].pin2); |
| 1591 | } |
| 1592 | closeResponse; |
| 1593 | |
| 1594 | return 0; |
| 1595 | } |
| 1596 | |
| 1597 | static int responseBrSmsCnf(Parcel &p, void *response, size_t responselen) { |
| 1598 | int num; |
| 1599 | |
| 1600 | if (response == NULL && responselen != 0) { |
| 1601 | LOGE("invalid response: NULL"); |
| 1602 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1603 | } |
| 1604 | |
| 1605 | if (responselen % sizeof(RIL_BroadcastSMSConfig *) != 0) { |
| 1606 | LOGE("invalid response length %d expected multiple of %d", |
| 1607 | (int)responselen, (int)sizeof(RIL_BroadcastSMSConfig *)); |
| 1608 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1609 | } |
| 1610 | |
| 1611 | /* number of call info's */ |
| 1612 | num = responselen / sizeof(RIL_BroadcastSMSConfig *); |
| 1613 | p.writeInt32(num); |
| 1614 | |
| 1615 | RIL_BroadcastSMSConfig *p_cur = (RIL_BroadcastSMSConfig *) response; |
| 1616 | p.writeInt32(p_cur->size); |
| 1617 | p.writeInt32(p_cur->entries->uFromServiceID); |
| 1618 | p.writeInt32(p_cur->entries->uToserviceID); |
| 1619 | p.write(&(p_cur->entries->bSelected),sizeof(p_cur->entries->bSelected)); |
| 1620 | |
| 1621 | startResponse; |
| 1622 | appendPrintBuf("%s size=%d, uServicecategory=%d, entries.uFromServiceID=%d, \ |
| 1623 | entries.uToserviceID=%d, entries.bSelected =%d, ", |
| 1624 | printBuf, p_cur->size,p_cur->entries->uFromServiceID, |
| 1625 | p_cur->.entries->uToserviceID,p_cur->entries->bSelected); |
| 1626 | closeResponse; |
| 1627 | |
| 1628 | return 0; |
| 1629 | } |
| 1630 | |
| 1631 | static int responseCdmaBrCnf(Parcel &p, void *response, size_t responselen) { |
| 1632 | int num; |
| 1633 | |
| 1634 | if (response == NULL && responselen != 0) { |
| 1635 | LOGE("invalid response: NULL"); |
| 1636 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1637 | } |
| 1638 | |
| 1639 | if (responselen % sizeof(RIL_CDMA_BroadcastSMSConfig*) != 0) { |
| 1640 | LOGE("invalid response length %d expected multiple of %d", |
| 1641 | (int)responselen, (int)sizeof(RIL_CDMA_BroadcastSMSConfig *)); |
| 1642 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1643 | } |
| 1644 | |
| 1645 | /* number of call info's */ |
| 1646 | num = responselen / sizeof(RIL_CDMA_BroadcastSMSConfig *); |
| 1647 | p.writeInt32(num); |
| 1648 | |
| 1649 | RIL_CDMA_BroadcastSMSConfig *p_cur = (RIL_CDMA_BroadcastSMSConfig * ) response; |
| 1650 | p.writeInt32(p_cur->size); |
| 1651 | p.writeInt32(p_cur->entries->uServiceCategory); |
| 1652 | p.writeInt32(p_cur->entries->uLanguage); |
| 1653 | p.write(&(p_cur->entries->bSelected),sizeof(p_cur->entries->bSelected)); |
| 1654 | |
| 1655 | startResponse; |
| 1656 | appendPrintBuf("%ssize=%d, entries.uServicecategory=%d, entries.uLanguage =%d, \ |
| 1657 | entries.bSelected =%d, ", printBuf,p_cur->size, p_cur->entries->uServiceCategory, |
| 1658 | p_cur->entries->uLanguage, p_cur->entries->bSelected); |
| 1659 | closeResponse; |
| 1660 | |
| 1661 | return 0; |
| 1662 | } |
| 1663 | |
| 1664 | static int responseCdmaSms(Parcel &p, void *response, size_t responselen) { |
| 1665 | int num; |
| 1666 | int digitCount; |
| 1667 | int digitLimit; |
| 1668 | uint8_t uct; |
| 1669 | void* dest; |
| 1670 | |
| 1671 | if (response == NULL && responselen != 0) { |
| 1672 | LOGE("invalid response: NULL"); |
| 1673 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1674 | } |
| 1675 | |
| 1676 | if (responselen != sizeof(RIL_CDMA_SMS_Message*)) { |
| 1677 | LOGE("invalid response length was %d expected %d", |
| 1678 | (int)responselen, (int)sizeof(RIL_CDMA_SMS_Message *)); |
| 1679 | return RIL_ERRNO_INVALID_RESPONSE; |
| 1680 | } |
| 1681 | |
| 1682 | RIL_CDMA_SMS_Message *p_cur = (RIL_CDMA_SMS_Message *) response; |
| 1683 | p.writeInt32(p_cur->uTeleserviceID); |
| 1684 | p.write(&(p_cur->bIsServicePresent),sizeof(uct)); |
| 1685 | p.writeInt32(p_cur->uServicecategory); |
| 1686 | p.writeInt32(p_cur->sAddress.digit_mode); |
| 1687 | p.writeInt32(p_cur->sAddress.number_mode); |
| 1688 | p.writeInt32(p_cur->sAddress.number_type); |
| 1689 | p.writeInt32(p_cur->sAddress.number_plan); |
| 1690 | p.write(&(p_cur->sAddress.number_of_digits), sizeof(uct)); |
| 1691 | digitLimit= MIN((p_cur->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX); |
| 1692 | for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { |
| 1693 | p.write(&(p_cur->sAddress.digits[digitCount]),sizeof(uct)); |
| 1694 | } |
| 1695 | |
| 1696 | p.writeInt32(p_cur->sSubAddress.subaddressType); |
| 1697 | p.write(&(p_cur->sSubAddress.odd),sizeof(uct)); |
| 1698 | p.write(&(p_cur->sSubAddress.number_of_digits),sizeof(uct)); |
| 1699 | digitLimit= MIN((p_cur->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX); |
| 1700 | for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { |
| 1701 | p.write(&(p_cur->sSubAddress.digits[digitCount]),sizeof(uct)); |
| 1702 | } |
| 1703 | |
| 1704 | digitLimit= MIN((p_cur->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX); |
| 1705 | p.writeInt32(p_cur->uBearerDataLen); |
| 1706 | for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { |
| 1707 | p.write(&(p_cur->aBearerData[digitCount]), sizeof(uct)); |
| 1708 | } |
| 1709 | |
| 1710 | startResponse; |
| 1711 | appendPrintBuf("%suTeleserviceID=%d, bIsServicePresent=%d, uServicecategory=%d, \ |
| 1712 | sAddress.digitmode=%d, sAddress.NumberMode=%d, sAddress.numberType=%d, ", |
| 1713 | printBuf, p_cur->uTeleserviceID,p_cur->bIsServicePresent,p_cur->uServicecategory, |
| 1714 | p_cur->sAddress.digit_mode, p_cur->sAddress.number_mode,p_cur->sAddress.number_type); |
| 1715 | closeResponse; |
| 1716 | |
| 1717 | return 0; |
| 1718 | } |
| 1719 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1720 | /** |
| 1721 | * A write on the wakeup fd is done just to pop us out of select() |
| 1722 | * We empty the buffer here and then ril_event will reset the timers on the |
| 1723 | * way back down |
| 1724 | */ |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1725 | static void processWakeupCallback(int fd, short flags, void *param) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1726 | char buff[16]; |
| 1727 | int ret; |
| 1728 | |
| 1729 | LOGV("processWakeupCallback"); |
| 1730 | |
| 1731 | /* empty our wakeup socket out */ |
| 1732 | do { |
| 1733 | ret = read(s_fdWakeupRead, &buff, sizeof(buff)); |
| 1734 | } while (ret > 0 || (ret < 0 && errno == EINTR)); |
| 1735 | } |
| 1736 | |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1737 | static void onCommandsSocketClosed() { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1738 | int ret; |
| 1739 | RequestInfo *p_cur; |
| 1740 | |
| 1741 | /* mark pending requests as "cancelled" so we dont report responses */ |
| 1742 | |
| 1743 | ret = pthread_mutex_lock(&s_pendingRequestsMutex); |
| 1744 | assert (ret == 0); |
| 1745 | |
| 1746 | p_cur = s_pendingRequests; |
| 1747 | |
| 1748 | for (p_cur = s_pendingRequests |
| 1749 | ; p_cur != NULL |
| 1750 | ; p_cur = p_cur->p_next |
| 1751 | ) { |
| 1752 | p_cur->cancelled = 1; |
| 1753 | } |
| 1754 | |
| 1755 | ret = pthread_mutex_unlock(&s_pendingRequestsMutex); |
| 1756 | assert (ret == 0); |
| 1757 | } |
| 1758 | |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1759 | static void processCommandsCallback(int fd, short flags, void *param) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1760 | RecordStream *p_rs; |
| 1761 | void *p_record; |
| 1762 | size_t recordlen; |
| 1763 | int ret; |
| 1764 | |
| 1765 | assert(fd == s_fdCommand); |
| 1766 | |
| 1767 | p_rs = (RecordStream *)param; |
| 1768 | |
| 1769 | for (;;) { |
| 1770 | /* loop until EAGAIN/EINTR, end of stream, or other error */ |
| 1771 | ret = record_stream_get_next(p_rs, &p_record, &recordlen); |
| 1772 | |
| 1773 | if (ret == 0 && p_record == NULL) { |
| 1774 | /* end-of-stream */ |
| 1775 | break; |
| 1776 | } else if (ret < 0) { |
| 1777 | break; |
| 1778 | } else if (ret == 0) { /* && p_record != NULL */ |
| 1779 | processCommandBuffer(p_record, recordlen); |
| 1780 | } |
| 1781 | } |
| 1782 | |
| 1783 | if (ret == 0 || !(errno == EAGAIN || errno == EINTR)) { |
| 1784 | /* fatal error or end-of-stream */ |
| 1785 | if (ret != 0) { |
| 1786 | LOGE("error on reading command socket errno:%d\n", errno); |
| 1787 | } else { |
| 1788 | LOGW("EOS. Closing command socket."); |
| 1789 | } |
| 1790 | |
| 1791 | close(s_fdCommand); |
| 1792 | s_fdCommand = -1; |
| 1793 | |
| 1794 | ril_event_del(&s_commands_event); |
| 1795 | |
| 1796 | record_stream_free(p_rs); |
| 1797 | |
| 1798 | /* start listening for new connections again */ |
| 1799 | rilEventAddWakeup(&s_listen_event); |
| 1800 | |
| 1801 | onCommandsSocketClosed(); |
| 1802 | } |
| 1803 | } |
| 1804 | |
| 1805 | |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1806 | static void onNewCommandConnect() { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1807 | // implicit radio state changed |
| 1808 | RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, |
| 1809 | NULL, 0); |
| 1810 | |
| 1811 | // Send last NITZ time data, in case it was missed |
| 1812 | if (s_lastNITZTimeData != NULL) { |
| 1813 | sendResponseRaw(s_lastNITZTimeData, s_lastNITZTimeDataSize); |
| 1814 | |
| 1815 | free(s_lastNITZTimeData); |
| 1816 | s_lastNITZTimeData = NULL; |
| 1817 | } |
| 1818 | |
| 1819 | // Get version string |
| 1820 | if (s_callbacks.getVersion != NULL) { |
| 1821 | const char *version; |
| 1822 | version = s_callbacks.getVersion(); |
| 1823 | LOGI("RIL Daemon version: %s\n", version); |
| 1824 | |
| 1825 | property_set(PROPERTY_RIL_IMPL, version); |
| 1826 | } else { |
| 1827 | LOGI("RIL Daemon version: unavailable\n"); |
| 1828 | property_set(PROPERTY_RIL_IMPL, "unavailable"); |
| 1829 | } |
| 1830 | |
| 1831 | } |
| 1832 | |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1833 | static void listenCallback (int fd, short flags, void *param) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1834 | int ret; |
| 1835 | int err; |
| 1836 | int is_phone_socket; |
| 1837 | RecordStream *p_rs; |
| 1838 | |
| 1839 | struct sockaddr_un peeraddr; |
| 1840 | socklen_t socklen = sizeof (peeraddr); |
| 1841 | |
| 1842 | struct ucred creds; |
| 1843 | socklen_t szCreds = sizeof(creds); |
| 1844 | |
| 1845 | struct passwd *pwd = NULL; |
| 1846 | |
| 1847 | assert (s_fdCommand < 0); |
| 1848 | assert (fd == s_fdListen); |
| 1849 | |
| 1850 | s_fdCommand = accept(s_fdListen, (sockaddr *) &peeraddr, &socklen); |
| 1851 | |
| 1852 | if (s_fdCommand < 0 ) { |
| 1853 | LOGE("Error on accept() errno:%d", errno); |
| 1854 | /* start listening for new connections again */ |
| 1855 | rilEventAddWakeup(&s_listen_event); |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1856 | return; |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1857 | } |
| 1858 | |
| 1859 | /* check the credential of the other side and only accept socket from |
| 1860 | * phone process |
| 1861 | */ |
| 1862 | errno = 0; |
| 1863 | is_phone_socket = 0; |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1864 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1865 | err = getsockopt(s_fdCommand, SOL_SOCKET, SO_PEERCRED, &creds, &szCreds); |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1866 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1867 | if (err == 0 && szCreds > 0) { |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1868 | errno = 0; |
| 1869 | pwd = getpwuid(creds.uid); |
| 1870 | if (pwd != NULL) { |
| 1871 | if (strcmp(pwd->pw_name, PHONE_PROCESS) == 0) { |
| 1872 | is_phone_socket = 1; |
| 1873 | } else { |
| 1874 | LOGE("RILD can't accept socket from process %s", pwd->pw_name); |
| 1875 | } |
| 1876 | } else { |
| 1877 | LOGE("Error on getpwuid() errno: %d", errno); |
| 1878 | } |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1879 | } else { |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1880 | LOGD("Error on getsockopt() errno: %d", errno); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1881 | } |
| 1882 | |
| 1883 | if ( !is_phone_socket ) { |
| 1884 | LOGE("RILD must accept socket from %s", PHONE_PROCESS); |
| 1885 | |
| 1886 | close(s_fdCommand); |
| 1887 | s_fdCommand = -1; |
| 1888 | |
| 1889 | onCommandsSocketClosed(); |
| 1890 | |
| 1891 | /* start listening for new connections again */ |
| 1892 | rilEventAddWakeup(&s_listen_event); |
| 1893 | |
| 1894 | return; |
| 1895 | } |
| 1896 | |
| 1897 | ret = fcntl(s_fdCommand, F_SETFL, O_NONBLOCK); |
| 1898 | |
| 1899 | if (ret < 0) { |
| 1900 | LOGE ("Error setting O_NONBLOCK errno:%d", errno); |
| 1901 | } |
| 1902 | |
| 1903 | LOGI("libril: new connection"); |
| 1904 | |
| 1905 | p_rs = record_stream_new(s_fdCommand, MAX_COMMAND_BYTES); |
| 1906 | |
| 1907 | ril_event_set (&s_commands_event, s_fdCommand, 1, |
| 1908 | processCommandsCallback, p_rs); |
| 1909 | |
| 1910 | rilEventAddWakeup (&s_commands_event); |
| 1911 | |
| 1912 | onNewCommandConnect(); |
| 1913 | } |
| 1914 | |
| 1915 | static void freeDebugCallbackArgs(int number, char **args) { |
| 1916 | for (int i = 0; i < number; i++) { |
| 1917 | if (args[i] != NULL) { |
| 1918 | free(args[i]); |
| 1919 | } |
| 1920 | } |
| 1921 | free(args); |
| 1922 | } |
| 1923 | |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 1924 | static void debugCallback (int fd, short flags, void *param) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1925 | int acceptFD, option; |
| 1926 | struct sockaddr_un peeraddr; |
| 1927 | socklen_t socklen = sizeof (peeraddr); |
| 1928 | int data; |
| 1929 | unsigned int qxdm_data[6]; |
| 1930 | const char *deactData[1] = {"1"}; |
| 1931 | char *actData[1]; |
| 1932 | RIL_Dial dialData; |
| 1933 | int hangupData[1] = {1}; |
| 1934 | int number; |
| 1935 | char **args; |
| 1936 | |
| 1937 | acceptFD = accept (fd, (sockaddr *) &peeraddr, &socklen); |
| 1938 | |
| 1939 | if (acceptFD < 0) { |
| 1940 | LOGE ("error accepting on debug port: %d\n", errno); |
| 1941 | return; |
| 1942 | } |
| 1943 | |
| 1944 | if (recv(acceptFD, &number, sizeof(int), 0) != sizeof(int)) { |
| 1945 | LOGE ("error reading on socket: number of Args: \n"); |
| 1946 | return; |
| 1947 | } |
| 1948 | args = (char **) malloc(sizeof(char*) * number); |
| 1949 | |
| 1950 | for (int i = 0; i < number; i++) { |
| 1951 | int len; |
| 1952 | if (recv(acceptFD, &len, sizeof(int), 0) != sizeof(int)) { |
| 1953 | LOGE ("error reading on socket: Len of Args: \n"); |
| 1954 | freeDebugCallbackArgs(i, args); |
| 1955 | return; |
| 1956 | } |
| 1957 | // +1 for null-term |
| 1958 | args[i] = (char *) malloc((sizeof(char) * len) + 1); |
| 1959 | if (recv(acceptFD, args[i], sizeof(char) * len, 0) |
| 1960 | != sizeof(char) * len) { |
| 1961 | LOGE ("error reading on socket: Args[%d] \n", i); |
| 1962 | freeDebugCallbackArgs(i, args); |
| 1963 | return; |
| 1964 | } |
| 1965 | char * buf = args[i]; |
| 1966 | buf[len] = 0; |
| 1967 | } |
| 1968 | |
| 1969 | switch (atoi(args[0])) { |
| 1970 | case 0: |
| 1971 | LOGI ("Connection on debug port: issuing reset."); |
| 1972 | issueLocalRequest(RIL_REQUEST_RESET_RADIO, NULL, 0); |
| 1973 | break; |
| 1974 | case 1: |
| 1975 | LOGI ("Connection on debug port: issuing radio power off."); |
| 1976 | data = 0; |
| 1977 | issueLocalRequest(RIL_REQUEST_RADIO_POWER, &data, sizeof(int)); |
| 1978 | // Close the socket |
| 1979 | close(s_fdCommand); |
| 1980 | s_fdCommand = -1; |
| 1981 | break; |
| 1982 | case 2: |
| 1983 | LOGI ("Debug port: issuing unsolicited network change."); |
| 1984 | RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED, |
| 1985 | NULL, 0); |
| 1986 | break; |
| 1987 | case 3: |
| 1988 | LOGI ("Debug port: QXDM log enable."); |
| 1989 | qxdm_data[0] = 65536; |
| 1990 | qxdm_data[1] = 16; |
| 1991 | qxdm_data[2] = 1; |
| 1992 | qxdm_data[3] = 32; |
| 1993 | qxdm_data[4] = 0; |
| 1994 | qxdm_data[4] = 8; |
| 1995 | issueLocalRequest(RIL_REQUEST_OEM_HOOK_RAW, qxdm_data, |
| 1996 | 6 * sizeof(int)); |
| 1997 | break; |
| 1998 | case 4: |
| 1999 | LOGI ("Debug port: QXDM log disable."); |
| 2000 | qxdm_data[0] = 65536; |
| 2001 | qxdm_data[1] = 16; |
| 2002 | qxdm_data[2] = 0; |
| 2003 | qxdm_data[3] = 32; |
| 2004 | qxdm_data[4] = 0; |
| 2005 | qxdm_data[4] = 8; |
| 2006 | issueLocalRequest(RIL_REQUEST_OEM_HOOK_RAW, qxdm_data, |
| 2007 | 6 * sizeof(int)); |
| 2008 | break; |
| 2009 | case 5: |
| 2010 | LOGI("Debug port: Radio On"); |
| 2011 | data = 1; |
| 2012 | issueLocalRequest(RIL_REQUEST_RADIO_POWER, &data, sizeof(int)); |
| 2013 | sleep(2); |
| 2014 | // Set network selection automatic. |
| 2015 | issueLocalRequest(RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC, NULL, 0); |
| 2016 | break; |
| 2017 | case 6: |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 2018 | LOGI("Debug port: Setup Data Call, Apn :%s\n", args[1]); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2019 | actData[0] = args[1]; |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 2020 | issueLocalRequest(RIL_REQUEST_SETUP_DATA_CALL, &actData, |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2021 | sizeof(actData)); |
| 2022 | break; |
| 2023 | case 7: |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 2024 | LOGI("Debug port: Deactivate Data Call"); |
| 2025 | issueLocalRequest(RIL_REQUEST_DEACTIVATE_DATA_CALL, &deactData, |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2026 | sizeof(deactData)); |
| 2027 | break; |
| 2028 | case 8: |
| 2029 | LOGI("Debug port: Dial Call"); |
| 2030 | dialData.clir = 0; |
| 2031 | dialData.address = args[1]; |
| 2032 | issueLocalRequest(RIL_REQUEST_DIAL, &dialData, sizeof(dialData)); |
| 2033 | break; |
| 2034 | case 9: |
| 2035 | LOGI("Debug port: Answer Call"); |
| 2036 | issueLocalRequest(RIL_REQUEST_ANSWER, NULL, 0); |
| 2037 | break; |
| 2038 | case 10: |
| 2039 | LOGI("Debug port: End Call"); |
| 2040 | issueLocalRequest(RIL_REQUEST_HANGUP, &hangupData, |
| 2041 | sizeof(hangupData)); |
| 2042 | break; |
| 2043 | default: |
| 2044 | LOGE ("Invalid request"); |
| 2045 | break; |
| 2046 | } |
| 2047 | freeDebugCallbackArgs(number, args); |
| 2048 | close(acceptFD); |
| 2049 | } |
| 2050 | |
| 2051 | |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 2052 | static void userTimerCallback (int fd, short flags, void *param) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2053 | UserCallbackInfo *p_info; |
| 2054 | |
| 2055 | p_info = (UserCallbackInfo *)param; |
| 2056 | |
| 2057 | p_info->p_callback(p_info->userParam); |
| 2058 | |
| 2059 | |
| 2060 | // FIXME generalize this...there should be a cancel mechanism |
| 2061 | if (s_last_wake_timeout_info != NULL && s_last_wake_timeout_info == p_info) { |
| 2062 | s_last_wake_timeout_info = NULL; |
| 2063 | } |
| 2064 | |
| 2065 | free(p_info); |
| 2066 | } |
| 2067 | |
| 2068 | |
| 2069 | static void * |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 2070 | eventLoop(void *param) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2071 | int ret; |
| 2072 | int filedes[2]; |
| 2073 | |
| 2074 | ril_event_init(); |
| 2075 | |
| 2076 | pthread_mutex_lock(&s_startupMutex); |
| 2077 | |
| 2078 | s_started = 1; |
| 2079 | pthread_cond_broadcast(&s_startupCond); |
| 2080 | |
| 2081 | pthread_mutex_unlock(&s_startupMutex); |
| 2082 | |
| 2083 | ret = pipe(filedes); |
| 2084 | |
| 2085 | if (ret < 0) { |
| 2086 | LOGE("Error in pipe() errno:%d", errno); |
| 2087 | return NULL; |
| 2088 | } |
| 2089 | |
| 2090 | s_fdWakeupRead = filedes[0]; |
| 2091 | s_fdWakeupWrite = filedes[1]; |
| 2092 | |
| 2093 | fcntl(s_fdWakeupRead, F_SETFL, O_NONBLOCK); |
| 2094 | |
| 2095 | ril_event_set (&s_wakeupfd_event, s_fdWakeupRead, true, |
| 2096 | processWakeupCallback, NULL); |
| 2097 | |
| 2098 | rilEventAddWakeup (&s_wakeupfd_event); |
| 2099 | |
| 2100 | // Only returns on error |
| 2101 | ril_event_loop(); |
| 2102 | LOGE ("error in event_loop_base errno:%d", errno); |
| 2103 | |
| 2104 | return NULL; |
| 2105 | } |
| 2106 | |
| 2107 | extern "C" void |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 2108 | RIL_startEventLoop(void) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2109 | int ret; |
| 2110 | pthread_attr_t attr; |
| 2111 | |
| 2112 | /* spin up eventLoop thread and wait for it to get started */ |
| 2113 | s_started = 0; |
| 2114 | pthread_mutex_lock(&s_startupMutex); |
| 2115 | |
| 2116 | pthread_attr_init (&attr); |
| 2117 | pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); |
| 2118 | ret = pthread_create(&s_tid_dispatch, &attr, eventLoop, NULL); |
| 2119 | |
| 2120 | while (s_started == 0) { |
| 2121 | pthread_cond_wait(&s_startupCond, &s_startupMutex); |
| 2122 | } |
| 2123 | |
| 2124 | pthread_mutex_unlock(&s_startupMutex); |
| 2125 | |
| 2126 | if (ret < 0) { |
| 2127 | LOGE("Failed to create dispatch thread errno:%d", errno); |
| 2128 | return; |
| 2129 | } |
| 2130 | } |
| 2131 | |
| 2132 | // Used for testing purpose only. |
| 2133 | extern "C" void RIL_setcallbacks (const RIL_RadioFunctions *callbacks) { |
| 2134 | memcpy(&s_callbacks, callbacks, sizeof (RIL_RadioFunctions)); |
| 2135 | } |
| 2136 | |
| 2137 | extern "C" void |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 2138 | RIL_register (const RIL_RadioFunctions *callbacks) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2139 | int ret; |
| 2140 | int flags; |
| 2141 | |
| 2142 | if (callbacks == NULL |
| 2143 | || ! (callbacks->version == RIL_VERSION || callbacks->version == 1) |
| 2144 | ) { |
| 2145 | LOGE( |
| 2146 | "RIL_register: RIL_RadioFunctions * null or invalid version" |
| 2147 | " (expected %d)", RIL_VERSION); |
| 2148 | return; |
| 2149 | } |
| 2150 | |
| 2151 | if (s_registerCalled > 0) { |
| 2152 | LOGE("RIL_register has been called more than once. " |
| 2153 | "Subsequent call ignored"); |
| 2154 | return; |
| 2155 | } |
| 2156 | |
| 2157 | memcpy(&s_callbacks, callbacks, sizeof (RIL_RadioFunctions)); |
| 2158 | |
| 2159 | s_registerCalled = 1; |
| 2160 | |
| 2161 | // Little self-check |
| 2162 | |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 2163 | for (int i = 0; i < (int)NUM_ELEMS(s_commands); i++) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2164 | assert(i == s_commands[i].requestNumber); |
| 2165 | } |
| 2166 | |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 2167 | for (int i = 0; i < (int)NUM_ELEMS(s_unsolResponses); i++) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2168 | assert(i + RIL_UNSOL_RESPONSE_BASE |
| 2169 | == s_unsolResponses[i].requestNumber); |
| 2170 | } |
| 2171 | |
| 2172 | // New rild impl calls RIL_startEventLoop() first |
| 2173 | // old standalone impl wants it here. |
| 2174 | |
| 2175 | if (s_started == 0) { |
| 2176 | RIL_startEventLoop(); |
| 2177 | } |
| 2178 | |
| 2179 | // start listen socket |
| 2180 | |
| 2181 | #if 0 |
| 2182 | ret = socket_local_server (SOCKET_NAME_RIL, |
| 2183 | ANDROID_SOCKET_NAMESPACE_ABSTRACT, SOCK_STREAM); |
| 2184 | |
| 2185 | if (ret < 0) { |
| 2186 | LOGE("Unable to bind socket errno:%d", errno); |
| 2187 | exit (-1); |
| 2188 | } |
| 2189 | s_fdListen = ret; |
| 2190 | |
| 2191 | #else |
| 2192 | s_fdListen = android_get_control_socket(SOCKET_NAME_RIL); |
| 2193 | if (s_fdListen < 0) { |
| 2194 | LOGE("Failed to get socket '" SOCKET_NAME_RIL "'"); |
| 2195 | exit(-1); |
| 2196 | } |
| 2197 | |
| 2198 | ret = listen(s_fdListen, 4); |
| 2199 | |
| 2200 | if (ret < 0) { |
| 2201 | LOGE("Failed to listen on control socket '%d': %s", |
| 2202 | s_fdListen, strerror(errno)); |
| 2203 | exit(-1); |
| 2204 | } |
| 2205 | #endif |
| 2206 | |
| 2207 | |
| 2208 | /* note: non-persistent so we can accept only one connection at a time */ |
| 2209 | ril_event_set (&s_listen_event, s_fdListen, false, |
| 2210 | listenCallback, NULL); |
| 2211 | |
| 2212 | rilEventAddWakeup (&s_listen_event); |
| 2213 | |
| 2214 | #if 1 |
| 2215 | // start debug interface socket |
| 2216 | |
| 2217 | s_fdDebug = android_get_control_socket(SOCKET_NAME_RIL_DEBUG); |
| 2218 | if (s_fdDebug < 0) { |
| 2219 | LOGE("Failed to get socket '" SOCKET_NAME_RIL_DEBUG "' errno:%d", errno); |
| 2220 | exit(-1); |
| 2221 | } |
| 2222 | |
| 2223 | ret = listen(s_fdDebug, 4); |
| 2224 | |
| 2225 | if (ret < 0) { |
| 2226 | LOGE("Failed to listen on ril debug socket '%d': %s", |
| 2227 | s_fdDebug, strerror(errno)); |
| 2228 | exit(-1); |
| 2229 | } |
| 2230 | |
| 2231 | ril_event_set (&s_debug_event, s_fdDebug, true, |
| 2232 | debugCallback, NULL); |
| 2233 | |
| 2234 | rilEventAddWakeup (&s_debug_event); |
| 2235 | #endif |
| 2236 | |
| 2237 | } |
| 2238 | |
| 2239 | static int |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 2240 | checkAndDequeueRequestInfo(struct RequestInfo *pRI) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2241 | int ret = 0; |
| 2242 | |
| 2243 | if (pRI == NULL) { |
| 2244 | return 0; |
| 2245 | } |
| 2246 | |
| 2247 | pthread_mutex_lock(&s_pendingRequestsMutex); |
| 2248 | |
| 2249 | for(RequestInfo **ppCur = &s_pendingRequests |
| 2250 | ; *ppCur != NULL |
| 2251 | ; ppCur = &((*ppCur)->p_next) |
| 2252 | ) { |
| 2253 | if (pRI == *ppCur) { |
| 2254 | ret = 1; |
| 2255 | |
| 2256 | *ppCur = (*ppCur)->p_next; |
| 2257 | break; |
| 2258 | } |
| 2259 | } |
| 2260 | |
| 2261 | pthread_mutex_unlock(&s_pendingRequestsMutex); |
| 2262 | |
| 2263 | return ret; |
| 2264 | } |
| 2265 | |
| 2266 | |
| 2267 | extern "C" void |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 2268 | RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responselen) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2269 | RequestInfo *pRI; |
| 2270 | int ret; |
| 2271 | size_t errorOffset; |
| 2272 | |
| 2273 | pRI = (RequestInfo *)t; |
| 2274 | |
| 2275 | if (!checkAndDequeueRequestInfo(pRI)) { |
| 2276 | LOGE ("RIL_onRequestComplete: invalid RIL_Token"); |
| 2277 | return; |
| 2278 | } |
| 2279 | |
| 2280 | if (pRI->local > 0) { |
| 2281 | // Locally issued command...void only! |
| 2282 | // response does not go back up the command socket |
| 2283 | LOGD("C[locl]< %s", requestToString(pRI->pCI->requestNumber)); |
| 2284 | |
| 2285 | goto done; |
| 2286 | } |
| 2287 | |
| 2288 | appendPrintBuf("[%04d]< %s", |
| 2289 | pRI->token, requestToString(pRI->pCI->requestNumber)); |
| 2290 | |
| 2291 | if (pRI->cancelled == 0) { |
| 2292 | Parcel p; |
| 2293 | |
| 2294 | p.writeInt32 (RESPONSE_SOLICITED); |
| 2295 | p.writeInt32 (pRI->token); |
| 2296 | errorOffset = p.dataPosition(); |
| 2297 | |
| 2298 | p.writeInt32 (e); |
| 2299 | |
| 2300 | if (e == RIL_E_SUCCESS) { |
| 2301 | /* process response on success */ |
| 2302 | ret = pRI->pCI->responseFunction(p, response, responselen); |
| 2303 | |
| 2304 | /* if an error occurred, rewind and mark it */ |
| 2305 | if (ret != 0) { |
| 2306 | p.setDataPosition(errorOffset); |
| 2307 | p.writeInt32 (ret); |
| 2308 | } |
| 2309 | } else { |
| 2310 | appendPrintBuf("%s returns %s", printBuf, failCauseToString(e)); |
| 2311 | } |
| 2312 | |
| 2313 | if (s_fdCommand < 0) { |
| 2314 | LOGD ("RIL onRequestComplete: Command channel closed"); |
| 2315 | } |
| 2316 | sendResponse(p); |
| 2317 | } |
| 2318 | |
| 2319 | done: |
| 2320 | free(pRI); |
| 2321 | } |
| 2322 | |
| 2323 | |
| 2324 | static void |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 2325 | grabPartialWakeLock() { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2326 | acquire_wake_lock(PARTIAL_WAKE_LOCK, ANDROID_WAKE_LOCK_NAME); |
| 2327 | } |
| 2328 | |
| 2329 | static void |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 2330 | releaseWakeLock() { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2331 | release_wake_lock(ANDROID_WAKE_LOCK_NAME); |
| 2332 | } |
| 2333 | |
| 2334 | /** |
| 2335 | * Timer callback to put us back to sleep before the default timeout |
| 2336 | */ |
| 2337 | static void |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 2338 | wakeTimeoutCallback (void *param) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2339 | // We're using "param != NULL" as a cancellation mechanism |
| 2340 | if (param == NULL) { |
| 2341 | //LOGD("wakeTimeout: releasing wake lock"); |
| 2342 | |
| 2343 | releaseWakeLock(); |
| 2344 | } else { |
| 2345 | //LOGD("wakeTimeout: releasing wake lock CANCELLED"); |
| 2346 | } |
| 2347 | } |
| 2348 | |
| 2349 | extern "C" |
| 2350 | void RIL_onUnsolicitedResponse(int unsolResponse, void *data, |
| 2351 | size_t datalen) |
| 2352 | { |
| 2353 | int unsolResponseIndex; |
| 2354 | int ret; |
| 2355 | int64_t timeReceived = 0; |
| 2356 | bool shouldScheduleTimeout = false; |
| 2357 | |
| 2358 | if (s_registerCalled == 0) { |
| 2359 | // Ignore RIL_onUnsolicitedResponse before RIL_register |
| 2360 | LOGW("RIL_onUnsolicitedResponse called before RIL_register"); |
| 2361 | return; |
| 2362 | } |
The Android Open Source Project | 34a5108 | 2009-03-05 14:34:37 -0800 | [diff] [blame] | 2363 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2364 | unsolResponseIndex = unsolResponse - RIL_UNSOL_RESPONSE_BASE; |
| 2365 | |
| 2366 | if ((unsolResponseIndex < 0) |
| 2367 | || (unsolResponseIndex >= (int32_t)NUM_ELEMS(s_unsolResponses))) { |
| 2368 | LOGE("unsupported unsolicited response code %d", unsolResponse); |
| 2369 | return; |
| 2370 | } |
| 2371 | |
| 2372 | // Grab a wake lock if needed for this reponse, |
| 2373 | // as we exit we'll either release it immediately |
| 2374 | // or set a timer to release it later. |
| 2375 | switch (s_unsolResponses[unsolResponseIndex].wakeType) { |
| 2376 | case WAKE_PARTIAL: |
| 2377 | grabPartialWakeLock(); |
| 2378 | shouldScheduleTimeout = true; |
| 2379 | break; |
| 2380 | |
| 2381 | case DONT_WAKE: |
| 2382 | default: |
| 2383 | // No wake lock is grabed so don't set timeout |
| 2384 | shouldScheduleTimeout = false; |
| 2385 | break; |
| 2386 | } |
| 2387 | |
| 2388 | // Mark the time this was received, doing this |
| 2389 | // after grabing the wakelock incase getting |
| 2390 | // the elapsedRealTime might cause us to goto |
| 2391 | // sleep. |
| 2392 | if (unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) { |
| 2393 | timeReceived = elapsedRealtime(); |
| 2394 | } |
| 2395 | |
| 2396 | appendPrintBuf("[UNSL]< %s", requestToString(unsolResponse)); |
| 2397 | |
| 2398 | Parcel p; |
| 2399 | |
| 2400 | p.writeInt32 (RESPONSE_UNSOLICITED); |
| 2401 | p.writeInt32 (unsolResponse); |
| 2402 | |
| 2403 | ret = s_unsolResponses[unsolResponseIndex] |
| 2404 | .responseFunction(p, data, datalen); |
| 2405 | if (ret != 0) { |
| 2406 | // Problem with the response. Don't continue; |
| 2407 | goto error_exit; |
| 2408 | } |
| 2409 | |
| 2410 | // some things get more payload |
| 2411 | switch(unsolResponse) { |
| 2412 | case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: |
| 2413 | p.writeInt32(s_callbacks.onStateRequest()); |
| 2414 | appendPrintBuf("%s {%s}", printBuf, |
| 2415 | radioStateToString(s_callbacks.onStateRequest())); |
| 2416 | break; |
| 2417 | |
| 2418 | |
| 2419 | case RIL_UNSOL_NITZ_TIME_RECEIVED: |
| 2420 | // Store the time that this was received so the |
| 2421 | // handler of this message can account for |
| 2422 | // the time it takes to arrive and process. In |
| 2423 | // particular the system has been known to sleep |
| 2424 | // before this message can be processed. |
| 2425 | p.writeInt64(timeReceived); |
| 2426 | break; |
| 2427 | } |
| 2428 | |
| 2429 | ret = sendResponse(p); |
| 2430 | if (ret != 0 && unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) { |
| 2431 | |
| 2432 | // Unfortunately, NITZ time is not poll/update like everything |
| 2433 | // else in the system. So, if the upstream client isn't connected, |
| 2434 | // keep a copy of the last NITZ response (with receive time noted |
| 2435 | // above) around so we can deliver it when it is connected |
| 2436 | |
| 2437 | if (s_lastNITZTimeData != NULL) { |
| 2438 | free (s_lastNITZTimeData); |
| 2439 | s_lastNITZTimeData = NULL; |
| 2440 | } |
| 2441 | |
| 2442 | s_lastNITZTimeData = malloc(p.dataSize()); |
| 2443 | s_lastNITZTimeDataSize = p.dataSize(); |
| 2444 | memcpy(s_lastNITZTimeData, p.data(), p.dataSize()); |
| 2445 | } |
| 2446 | |
| 2447 | // For now, we automatically go back to sleep after TIMEVAL_WAKE_TIMEOUT |
| 2448 | // FIXME The java code should handshake here to release wake lock |
| 2449 | |
| 2450 | if (shouldScheduleTimeout) { |
| 2451 | // Cancel the previous request |
| 2452 | if (s_last_wake_timeout_info != NULL) { |
| 2453 | s_last_wake_timeout_info->userParam = (void *)1; |
| 2454 | } |
| 2455 | |
| 2456 | s_last_wake_timeout_info |
| 2457 | = internalRequestTimedCallback(wakeTimeoutCallback, NULL, |
| 2458 | &TIMEVAL_WAKE_TIMEOUT); |
| 2459 | } |
| 2460 | |
| 2461 | // Normal exit |
| 2462 | return; |
| 2463 | |
| 2464 | error_exit: |
| 2465 | // There was an error and we've got the wake lock so release it. |
| 2466 | if (shouldScheduleTimeout) { |
| 2467 | releaseWakeLock(); |
| 2468 | } |
| 2469 | } |
| 2470 | |
| 2471 | /** FIXME generalize this if you track UserCAllbackInfo, clear it |
| 2472 | when the callback occurs |
| 2473 | */ |
| 2474 | static UserCallbackInfo * |
| 2475 | internalRequestTimedCallback (RIL_TimedCallback callback, void *param, |
| 2476 | const struct timeval *relativeTime) |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2477 | { |
| 2478 | struct timeval myRelativeTime; |
| 2479 | UserCallbackInfo *p_info; |
| 2480 | |
| 2481 | p_info = (UserCallbackInfo *) malloc (sizeof(UserCallbackInfo)); |
| 2482 | |
| 2483 | p_info->p_callback = callback; |
| 2484 | p_info->userParam = param; |
| 2485 | |
| 2486 | if (relativeTime == NULL) { |
| 2487 | /* treat null parameter as a 0 relative time */ |
| 2488 | memset (&myRelativeTime, 0, sizeof(myRelativeTime)); |
| 2489 | } else { |
| 2490 | /* FIXME I think event_add's tv param is really const anyway */ |
| 2491 | memcpy (&myRelativeTime, relativeTime, sizeof(myRelativeTime)); |
| 2492 | } |
| 2493 | |
| 2494 | ril_event_set(&(p_info->event), -1, false, userTimerCallback, p_info); |
| 2495 | |
| 2496 | ril_timer_add(&(p_info->event), &myRelativeTime); |
| 2497 | |
| 2498 | triggerEvLoop(); |
| 2499 | return p_info; |
| 2500 | } |
| 2501 | |
| 2502 | |
| 2503 | extern "C" void |
| 2504 | RIL_requestTimedCallback (RIL_TimedCallback callback, void *param, |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 2505 | const struct timeval *relativeTime) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2506 | internalRequestTimedCallback (callback, param, relativeTime); |
| 2507 | } |
| 2508 | |
| 2509 | const char * |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 2510 | failCauseToString(RIL_Errno e) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2511 | switch(e) { |
| 2512 | case RIL_E_SUCCESS: return "E_SUCCESS"; |
| 2513 | case RIL_E_RADIO_NOT_AVAILABLE: return "E_RAIDO_NOT_AVAILABLE"; |
| 2514 | case RIL_E_GENERIC_FAILURE: return "E_GENERIC_FAILURE"; |
| 2515 | case RIL_E_PASSWORD_INCORRECT: return "E_PASSWORD_INCORRECT"; |
| 2516 | case RIL_E_SIM_PIN2: return "E_SIM_PIN2"; |
| 2517 | case RIL_E_SIM_PUK2: return "E_SIM_PUK2"; |
| 2518 | case RIL_E_REQUEST_NOT_SUPPORTED: return "E_REQUEST_NOT_SUPPORTED"; |
| 2519 | case RIL_E_CANCELLED: return "E_CANCELLED"; |
| 2520 | case RIL_E_OP_NOT_ALLOWED_DURING_VOICE_CALL: return "E_OP_NOT_ALLOWED_DURING_VOICE_CALL"; |
| 2521 | case RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW: return "E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW"; |
| 2522 | case RIL_E_SMS_SEND_FAIL_RETRY: return "E_SMS_SEND_FAIL_RETRY"; |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 2523 | case RIL_E_SIM_ABSENT:return "E_SIM_ABSENT"; |
| 2524 | #ifdef FEATURE_MULTIMODE_ANDROID |
| 2525 | case RIL_E_SUBSCRIPTION_NOT_AVAILABLE:return "E_SUBSCRIPTION_NOT_AVAILABLE"; |
| 2526 | case RIL_E_MODE_NOT_SUPPORTED:return "E_MODE_NOT_SUPPORTED"; |
| 2527 | #endif |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2528 | default: return "<unknown error>"; |
| 2529 | } |
| 2530 | } |
| 2531 | |
| 2532 | const char * |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 2533 | radioStateToString(RIL_RadioState s) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2534 | switch(s) { |
| 2535 | case RADIO_STATE_OFF: return "RADIO_OFF"; |
| 2536 | case RADIO_STATE_UNAVAILABLE: return "RADIO_UNAVAILABLE"; |
| 2537 | case RADIO_STATE_SIM_NOT_READY: return "RADIO_SIM_NOT_READY"; |
| 2538 | case RADIO_STATE_SIM_LOCKED_OR_ABSENT: return "RADIO_SIM_LOCKED_OR_ABSENT"; |
| 2539 | case RADIO_STATE_SIM_READY: return "RADIO_SIM_READY"; |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 2540 | case RADIO_STATE_RUIM_NOT_READY:return"RADIO_RUIM_NOT_READY"; |
| 2541 | case RADIO_STATE_RUIM_READY:return"RADIO_RUIM_READY"; |
| 2542 | case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:return"RADIO_RUIM_LOCKED_OR_ABSENT"; |
| 2543 | case RADIO_STATE_NV_NOT_READY:return"RADIO_NV_NOT_READY"; |
| 2544 | case RADIO_STATE_NV_READY:return"RADIO_NV_READY"; |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2545 | default: return "<unknown state>"; |
| 2546 | } |
| 2547 | } |
| 2548 | |
| 2549 | const char * |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 2550 | callStateToString(RIL_CallState s) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2551 | switch(s) { |
| 2552 | case RIL_CALL_ACTIVE : return "ACTIVE"; |
| 2553 | case RIL_CALL_HOLDING: return "HOLDING"; |
| 2554 | case RIL_CALL_DIALING: return "DIALING"; |
| 2555 | case RIL_CALL_ALERTING: return "ALERTING"; |
| 2556 | case RIL_CALL_INCOMING: return "INCOMING"; |
| 2557 | case RIL_CALL_WAITING: return "WAITING"; |
| 2558 | default: return "<unknown state>"; |
| 2559 | } |
| 2560 | } |
| 2561 | |
| 2562 | const char * |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 2563 | requestToString(int request) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2564 | /* |
| 2565 | cat libs/telephony/ril_commands.h \ |
| 2566 | | egrep "^ *{RIL_" \ |
| 2567 | | sed -re 's/\{RIL_([^,]+),[^,]+,([^}]+).+/case RIL_\1: return "\1";/' |
| 2568 | |
| 2569 | |
| 2570 | cat libs/telephony/ril_unsol_commands.h \ |
| 2571 | | egrep "^ *{RIL_" \ |
| 2572 | | sed -re 's/\{RIL_([^,]+),([^}]+).+/case RIL_\1: return "\1";/' |
| 2573 | |
| 2574 | */ |
| 2575 | switch(request) { |
| 2576 | case RIL_REQUEST_GET_SIM_STATUS: return "GET_SIM_STATUS"; |
| 2577 | case RIL_REQUEST_ENTER_SIM_PIN: return "ENTER_SIM_PIN"; |
| 2578 | case RIL_REQUEST_ENTER_SIM_PUK: return "ENTER_SIM_PUK"; |
| 2579 | case RIL_REQUEST_ENTER_SIM_PIN2: return "ENTER_SIM_PIN2"; |
| 2580 | case RIL_REQUEST_ENTER_SIM_PUK2: return "ENTER_SIM_PUK2"; |
| 2581 | case RIL_REQUEST_CHANGE_SIM_PIN: return "CHANGE_SIM_PIN"; |
| 2582 | case RIL_REQUEST_CHANGE_SIM_PIN2: return "CHANGE_SIM_PIN2"; |
| 2583 | case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: return "ENTER_NETWORK_DEPERSONALIZATION"; |
| 2584 | case RIL_REQUEST_GET_CURRENT_CALLS: return "GET_CURRENT_CALLS"; |
| 2585 | case RIL_REQUEST_DIAL: return "DIAL"; |
| 2586 | case RIL_REQUEST_GET_IMSI: return "GET_IMSI"; |
| 2587 | case RIL_REQUEST_HANGUP: return "HANGUP"; |
| 2588 | case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: return "HANGUP_WAITING_OR_BACKGROUND"; |
| 2589 | case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: return "HANGUP_FOREGROUND_RESUME_BACKGROUND"; |
| 2590 | case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: return "SWITCH_WAITING_OR_HOLDING_AND_ACTIVE"; |
| 2591 | case RIL_REQUEST_CONFERENCE: return "CONFERENCE"; |
| 2592 | case RIL_REQUEST_UDUB: return "UDUB"; |
| 2593 | case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: return "LAST_CALL_FAIL_CAUSE"; |
| 2594 | case RIL_REQUEST_SIGNAL_STRENGTH: return "SIGNAL_STRENGTH"; |
| 2595 | case RIL_REQUEST_REGISTRATION_STATE: return "REGISTRATION_STATE"; |
| 2596 | case RIL_REQUEST_GPRS_REGISTRATION_STATE: return "GPRS_REGISTRATION_STATE"; |
| 2597 | case RIL_REQUEST_OPERATOR: return "OPERATOR"; |
| 2598 | case RIL_REQUEST_RADIO_POWER: return "RADIO_POWER"; |
| 2599 | case RIL_REQUEST_DTMF: return "DTMF"; |
| 2600 | case RIL_REQUEST_SEND_SMS: return "SEND_SMS"; |
| 2601 | case RIL_REQUEST_SEND_SMS_EXPECT_MORE: return "SEND_SMS_EXPECT_MORE"; |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 2602 | case RIL_REQUEST_SETUP_DATA_CALL: return "SETUP_DATA_CALL"; |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2603 | case RIL_REQUEST_SIM_IO: return "SIM_IO"; |
| 2604 | case RIL_REQUEST_SEND_USSD: return "SEND_USSD"; |
| 2605 | case RIL_REQUEST_CANCEL_USSD: return "CANCEL_USSD"; |
| 2606 | case RIL_REQUEST_GET_CLIR: return "GET_CLIR"; |
| 2607 | case RIL_REQUEST_SET_CLIR: return "SET_CLIR"; |
| 2608 | case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: return "QUERY_CALL_FORWARD_STATUS"; |
| 2609 | case RIL_REQUEST_SET_CALL_FORWARD: return "SET_CALL_FORWARD"; |
| 2610 | case RIL_REQUEST_QUERY_CALL_WAITING: return "QUERY_CALL_WAITING"; |
| 2611 | case RIL_REQUEST_SET_CALL_WAITING: return "SET_CALL_WAITING"; |
| 2612 | case RIL_REQUEST_SMS_ACKNOWLEDGE: return "SMS_ACKNOWLEDGE"; |
| 2613 | case RIL_REQUEST_GET_IMEI: return "GET_IMEI"; |
| 2614 | case RIL_REQUEST_GET_IMEISV: return "GET_IMEISV"; |
| 2615 | case RIL_REQUEST_ANSWER: return "ANSWER"; |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 2616 | case RIL_REQUEST_DEACTIVATE_DATA_CALL: return "DEACTIVATE_DATA_CALL"; |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2617 | case RIL_REQUEST_QUERY_FACILITY_LOCK: return "QUERY_FACILITY_LOCK"; |
| 2618 | case RIL_REQUEST_SET_FACILITY_LOCK: return "SET_FACILITY_LOCK"; |
| 2619 | case RIL_REQUEST_CHANGE_BARRING_PASSWORD: return "CHANGE_BARRING_PASSWORD"; |
| 2620 | case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: return "QUERY_NETWORK_SELECTION_MODE"; |
| 2621 | case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: return "SET_NETWORK_SELECTION_AUTOMATIC"; |
| 2622 | case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: return "SET_NETWORK_SELECTION_MANUAL"; |
| 2623 | case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : return "QUERY_AVAILABLE_NETWORKS "; |
| 2624 | case RIL_REQUEST_DTMF_START: return "DTMF_START"; |
| 2625 | case RIL_REQUEST_DTMF_STOP: return "DTMF_STOP"; |
| 2626 | case RIL_REQUEST_BASEBAND_VERSION: return "BASEBAND_VERSION"; |
| 2627 | case RIL_REQUEST_SEPARATE_CONNECTION: return "SEPARATE_CONNECTION"; |
| 2628 | case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: return "SET_PREFERRED_NETWORK_TYPE"; |
| 2629 | case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: return "GET_PREFERRED_NETWORK_TYPE"; |
| 2630 | case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: return "GET_NEIGHBORING_CELL_IDS"; |
| 2631 | case RIL_REQUEST_SET_MUTE: return "SET_MUTE"; |
| 2632 | case RIL_REQUEST_GET_MUTE: return "GET_MUTE"; |
| 2633 | case RIL_REQUEST_QUERY_CLIP: return "QUERY_CLIP"; |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 2634 | case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: return "LAST_DATA_CALL_FAIL_CAUSE"; |
| 2635 | case RIL_REQUEST_DATA_CALL_LIST: return "DATA_CALL_LIST"; |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2636 | case RIL_REQUEST_RESET_RADIO: return "RESET_RADIO"; |
| 2637 | case RIL_REQUEST_OEM_HOOK_RAW: return "OEM_HOOK_RAW"; |
| 2638 | case RIL_REQUEST_OEM_HOOK_STRINGS: return "OEM_HOOK_STRINGS"; |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 2639 | case RIL_REQUEST_SET_BAND_MODE: return "SET_BAND_MODE"; |
| 2640 | case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: return "QUERY_AVAILABLE_BAND_MODE"; |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2641 | case RIL_REQUEST_STK_GET_PROFILE: return "STK_GET_PROFILE"; |
| 2642 | case RIL_REQUEST_STK_SET_PROFILE: return "STK_SET_PROFILE"; |
| 2643 | case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: return "STK_SEND_ENVELOPE_COMMAND"; |
| 2644 | case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: return "STK_SEND_TERMINAL_RESPONSE"; |
| 2645 | case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: return "STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM"; |
| 2646 | case RIL_REQUEST_SCREEN_STATE: return "SCREEN_STATE"; |
| 2647 | case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: return "EXPLICIT_CALL_TRANSFER"; |
| 2648 | case RIL_REQUEST_SET_LOCATION_UPDATES: return "SET_LOCATION_UPDATES"; |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 2649 | case RIL_REQUEST_CDMA_SET_SUBSCRIPTION:return"CDMA_SET_SUBSCRIPTION"; |
| 2650 | case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE:return"CDMA_SET_ROAMING_PREFERENCE"; |
| 2651 | case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE:return"CDMA_QUERY_ROAMING_PREFERENCE"; |
| 2652 | case RIL_REQUEST_SET_TTY_MODE:return"SET_TTY_MODE"; |
| 2653 | case RIL_REQUEST_QUERY_TTY_MODE:return"QUERY_TTY_MODE"; |
| 2654 | case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE"; |
| 2655 | case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE"; |
| 2656 | case RIL_REQUEST_CDMA_FLASH:return"CDMA_FLASH"; |
| 2657 | case RIL_REQUEST_CDMA_BURST_DTMF:return"CDMA_BURST_DTMF"; |
| 2658 | case RIL_REQUEST_CDMA_SEND_SMS:return"CDMA_SEND_SMS"; |
| 2659 | case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE:return"CDMA_SMS_ACKNOWLEDGE"; |
| 2660 | case RIL_REQUEST_GET_BROADCAST_CONFIG:return"GET_BROADCAST_CONFIG"; |
| 2661 | case RIL_REQUEST_SET_BROADCAST_CONFIG:return"SET_BROADCAST_CONFIG"; |
| 2662 | case RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG:return "CDMA_GET_BROADCAST_CONFIG"; |
| 2663 | case RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG:return "SET_CDMA_BROADCAST_CONFIG"; |
| 2664 | case RIL_REQUEST_BROADCAST_ACTIVATION:return "BROADCAST_ACTIVATION"; |
| 2665 | case RIL_REQUEST_CDMA_VALIDATE_AKEY: return"CDMA_VALIDATE_AKEY"; |
| 2666 | case RIL_REQUEST_CDMA_SUBSCRIPTION: return"CDMA_SUBSCRIPTION"; |
| 2667 | case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: return "CDMA_WRITE_SMS_TO_RUIM"; |
| 2668 | case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: return "CDMA_DELETE_SMS_ON_RUIM"; |
| 2669 | case RIL_REQUEST_DEVICE_IDENTITY: return "DEVICE_IDENTITY"; |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2670 | case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return "UNSOL_RESPONSE_RADIO_STATE_CHANGED"; |
| 2671 | case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return "UNSOL_RESPONSE_CALL_STATE_CHANGED"; |
| 2672 | case RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED: return "UNSOL_RESPONSE_NETWORK_STATE_CHANGED"; |
| 2673 | case RIL_UNSOL_RESPONSE_NEW_SMS: return "UNSOL_RESPONSE_NEW_SMS"; |
| 2674 | case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: return "UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT"; |
| 2675 | case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: return "UNSOL_RESPONSE_NEW_SMS_ON_SIM"; |
| 2676 | case RIL_UNSOL_ON_USSD: return "UNSOL_ON_USSD"; |
| 2677 | case RIL_UNSOL_ON_USSD_REQUEST: return "UNSOL_ON_USSD_REQUEST(obsolete)"; |
| 2678 | case RIL_UNSOL_NITZ_TIME_RECEIVED: return "UNSOL_NITZ_TIME_RECEIVED"; |
| 2679 | case RIL_UNSOL_SIGNAL_STRENGTH: return "UNSOL_SIGNAL_STRENGTH"; |
| 2680 | case RIL_UNSOL_STK_SESSION_END: return "UNSOL_STK_SESSION_END"; |
| 2681 | case RIL_UNSOL_STK_PROACTIVE_COMMAND: return "UNSOL_STK_PROACTIVE_COMMAND"; |
| 2682 | case RIL_UNSOL_STK_EVENT_NOTIFY: return "UNSOL_STK_EVENT_NOTIFY"; |
| 2683 | case RIL_UNSOL_STK_CALL_SETUP: return "UNSOL_STK_CALL_SETUP"; |
| 2684 | case RIL_UNSOL_SIM_SMS_STORAGE_FULL: return "UNSOL_SIM_SMS_STORAGE_FUL"; |
| 2685 | case RIL_UNSOL_SIM_REFRESH: return "UNSOL_SIM_REFRESH"; |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 2686 | case RIL_UNSOL_DATA_CALL_LIST_CHANGED: return "UNSOL_DATA_CALL_LIST_CHANGED"; |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2687 | case RIL_UNSOL_CALL_RING: return "UNSOL_CALL_RING"; |
The Android Open Source Project | 34a5108 | 2009-03-05 14:34:37 -0800 | [diff] [blame] | 2688 | case RIL_UNSOL_RESTRICTED_STATE_CHANGED: return "UNSOL_RESTRICTED_STATE_CHANGED"; |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame^] | 2689 | case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: return "UNSOL_RESPONSE_SIM_STATUS_CHANGED"; |
| 2690 | case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: return "UNSOL_NEW_CDMA_SMS"; |
| 2691 | case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: return "UNSOL_NEW_BROADCAST_SMS"; |
| 2692 | case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: return "UNSOL_CDMA_RUIM_SMS_STORAGE_FULL"; |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 2693 | default: return "<unknown request>"; |
| 2694 | } |
| 2695 | } |
| 2696 | |
| 2697 | } /* namespace android */ |