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