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