| xj | 112b967 | 2022-01-25 16:13:48 +0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: MediaTekProprietary |
| xj | b04a402 | 2021-11-25 15:01:52 +0800 | [diff] [blame] | 2 | /* //device/libs/telephony/ril.cpp |
| 3 | ** |
| 4 | ** Copyright 2006, The Android Open Source Project |
| 5 | ** |
| 6 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | ** you may not use this file except in compliance with the License. |
| 8 | ** You may obtain a copy of the License at |
| 9 | ** |
| 10 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | ** |
| 12 | ** Unless required by applicable law or agreed to in writing, software |
| 13 | ** distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | ** See the License for the specific language governing permissions and |
| 16 | ** limitations under the License. |
| 17 | */ |
| 18 | |
| 19 | #define LOG_TAG "RILC" |
| 20 | |
| 21 | #include "mtk_log.h" |
| 22 | #include <mtk_power.h> |
| 23 | #include <telephony/ril_cdma_sms.h> |
| 24 | #include <telephony/mtk_ril.h> |
| 25 | #include <telephony/mtk_ril_ivt.h> |
| 26 | #include <libmtkrilutils.h> |
| 27 | #include <cutils/sockets.h> |
| 28 | #include <cutils/jstring.h> |
| 29 | #include <telephony/record_stream.h> |
| 30 | #include <log/mtk_log.h> |
| 31 | #include <utils/SystemClock.h> |
| 32 | #include <pthread.h> |
| 33 | #include <binder/Parcel.h> |
| 34 | #include <cutils/jstring.h> |
| 35 | #include <sys/types.h> |
| 36 | #include <limits.h> |
| 37 | #include <pwd.h> |
| 38 | #include <stdio.h> |
| 39 | #include <stdlib.h> |
| 40 | #include <stdarg.h> |
| 41 | #include <string.h> |
| 42 | #include <unistd.h> |
| 43 | #include <fcntl.h> |
| 44 | #include <time.h> |
| 45 | #include <errno.h> |
| 46 | #include <assert.h> |
| 47 | #include <ctype.h> |
| 48 | #include <sys/un.h> |
| 49 | #include <assert.h> |
| 50 | #include <netinet/in.h> |
| 51 | #include <mtk_properties.h> |
| 52 | #include <RilSapSocket.h> |
| 53 | #include <semaphore.h> |
| 54 | #if !defined(__ANDROID__) |
| 55 | #include <signal.h> |
| 56 | #endif |
| 57 | /// M: eMBMS feature |
| 58 | #include <telephony/mtk_ril_embms_def.h> |
| 59 | #include <telephony/mtk_ril_request_info.h> |
| 60 | |
| 61 | #ifdef HAVE_AEE_FEATURE |
| 62 | #include "aee.h" |
| 63 | #endif |
| 64 | |
| 65 | #include <netagent/NetAgentService.h> |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | extern "C" void |
| 71 | RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responselen); |
| 72 | |
| 73 | extern "C" void |
| 74 | RIL_onRequestAck(RIL_Token t); |
| 75 | |
| 76 | /// MTK_RIL_ADAPTER @{ |
| 77 | extern "C" void |
| 78 | RIL_onIssueLocalRequest(int request, void *data, int len, RIL_SOCKET_ID socket_id); |
| 79 | /// @} |
| 80 | |
| 81 | extern void |
| 82 | onRequest (int request, Parcel *parcel, RIL_Token t, RIL_SOCKET_ID socket_id); |
| 83 | |
| 84 | namespace android { |
| 85 | |
| 86 | #define PHONE_PROCESS "radio" |
| 87 | #define BLUETOOTH_PROCESS "bluetooth" |
| 88 | |
| 89 | #define SOCKET_NAME_RIL_NORMAL "rild" |
| 90 | #define SOCKET2_NAME_RIL_NORMAL "rild2" |
| 91 | #define SOCKET3_NAME_RIL_NORMAL "rild3" |
| 92 | #define SOCKET4_NAME_RIL_NORMAL "rild4" |
| 93 | |
| 94 | #define SOCKET_NAME_RIL_TEST "rild-test" |
| 95 | #define SOCKET2_NAME_RIL_TEST "rild2-test" |
| 96 | #define SOCKET3_NAME_RIL_TEST "rild3-test" |
| 97 | #define SOCKET4_NAME_RIL_TEST "rild4-test" |
| 98 | |
| 99 | const char socket_status[RIL_SLOT_MAX][35]= { |
| 100 | "rild.socket.status1", |
| 101 | "rild.socket.status2", |
| 102 | }; |
| 103 | |
| 104 | char semName[RIL_SLOT_MAX][20] = { |
| 105 | "/sem_socket1", |
| 106 | "/sem_socket2", |
| 107 | }; |
| 108 | |
| 109 | extern "C" const char * RIL_getRilSocketNameById(RIL_SOCKET_ID socket_id) { |
| 110 | const char* socket_name; |
| 111 | char test_mode[PROP_VALUE_MAX] = {0}; |
| 112 | mtk_property_get("persist.ril.test_mode", test_mode, "0"); |
| 113 | if (strcmp(test_mode, "0") == 0) { |
| 114 | switch (socket_id) { |
| 115 | case RIL_SOCKET_1: |
| 116 | socket_name = SOCKET_NAME_RIL_NORMAL; |
| 117 | break; |
| 118 | case RIL_SOCKET_2: |
| 119 | socket_name = SOCKET2_NAME_RIL_NORMAL; |
| 120 | break; |
| 121 | case RIL_SOCKET_3: |
| 122 | socket_name = SOCKET3_NAME_RIL_NORMAL; |
| 123 | break; |
| 124 | case RIL_SOCKET_4: |
| 125 | socket_name = SOCKET4_NAME_RIL_NORMAL; |
| 126 | break; |
| 127 | default: |
| 128 | RLOGE("Socket id is wrong!!"); |
| 129 | return NULL; |
| 130 | } |
| 131 | } else { //test mode |
| 132 | RLOGD("getRilSocketNameById %d under debug mode!", socket_id); |
| 133 | switch (socket_id) { |
| 134 | case RIL_SOCKET_1: |
| 135 | socket_name = SOCKET_NAME_RIL_TEST; |
| 136 | break; |
| 137 | case RIL_SOCKET_2: |
| 138 | socket_name = SOCKET2_NAME_RIL_TEST; |
| 139 | break; |
| 140 | case RIL_SOCKET_3: |
| 141 | socket_name = SOCKET3_NAME_RIL_TEST; |
| 142 | break; |
| 143 | case RIL_SOCKET_4: |
| 144 | socket_name = SOCKET4_NAME_RIL_TEST; |
| 145 | break; |
| 146 | default: |
| 147 | RLOGE("Socket id is wrong!!"); |
| 148 | return NULL; |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | return socket_name; |
| 153 | } |
| 154 | |
| 155 | #define SOCKET_NAME_RIL RIL_getRilSocketNameById(RIL_SOCKET_1) |
| 156 | #define SOCKET2_NAME_RIL RIL_getRilSocketNameById(RIL_SOCKET_2) |
| 157 | #define SOCKET3_NAME_RIL RIL_getRilSocketNameById(RIL_SOCKET_3) |
| 158 | #define SOCKET4_NAME_RIL RIL_getRilSocketNameById(RIL_SOCKET_4) |
| 159 | |
| 160 | #define SOCKET_NAME_RIL_DEBUG "rild-debug" |
| 161 | |
| 162 | #define ANDROID_WAKE_LOCK_NAME "radio-interface" |
| 163 | |
| 164 | #define ANDROID_WAKE_LOCK_SECS 0 |
| 165 | #define ANDROID_WAKE_LOCK_USECS 200000 |
| 166 | |
| 167 | #define CONF_CALL_ID_SHIFT 100 |
| 168 | |
| 169 | #define PROPERTY_RIL_IMPL "gsm.version.ril-impl" |
| 170 | |
| 171 | // match with constant in RIL.java |
| 172 | #define MAX_COMMAND_BYTES (20 * 1024) |
| 173 | |
| 174 | // Basically: memset buffers that the client library |
| 175 | // shouldn't be using anymore in an attempt to find |
| 176 | // memory usage issues sooner. |
| 177 | #define MEMSET_FREED 1 |
| 178 | |
| 179 | #define NUM_ELEMS(a) (sizeof (a) / sizeof (a)[0]) |
| 180 | |
| 181 | #define MIN(a,b) ((a)<(b) ? (a) : (b)) |
| 182 | |
| 183 | /* Constants for response types */ |
| 184 | #define RESPONSE_SOLICITED 0 |
| 185 | #define RESPONSE_UNSOLICITED 1 |
| 186 | #define RESPONSE_SOLICITED_ACK 2 |
| 187 | #define RESPONSE_SOLICITED_ACK_EXP 3 |
| 188 | #define RESPONSE_UNSOLICITED_ACK_EXP 4 |
| 189 | |
| 190 | /* Negative values for private RIL errno's */ |
| 191 | #define RIL_ERRNO_INVALID_RESPONSE -1 |
| 192 | #define RIL_ERRNO_NO_MEMORY -12 |
| 193 | |
| 194 | // request, response, and unsolicited msg print macro |
| 195 | #define PRINTBUF_SIZE 8096 |
| 196 | |
| 197 | // Enable verbose logging |
| 198 | #define VDBG 1 |
| 199 | #define RILJDBG 0 |
| 200 | |
| 201 | // Enable RILC log |
| 202 | #define RILC_LOG 0 |
| 203 | |
| 204 | #if RILC_LOG |
| 205 | #define startRequest sprintf(printBuf, "(") |
| 206 | #define closeRequest sprintf(printBuf, "%s)", printBuf) |
| 207 | #define printRequest(token, req) \ |
| 208 | RLOGD("[%04d]> %s %s", token, requestToString(req), printBuf) |
| 209 | |
| 210 | #define startResponse sprintf(printBuf, "%s {", printBuf) |
| 211 | #define closeResponse sprintf(printBuf, "%s}", printBuf) |
| 212 | #define printResponse RLOGD("%s", printBuf) |
| 213 | |
| 214 | #define clearPrintBuf printBuf[0] = 0 |
| 215 | #define removeLastChar printBuf[strlen(printBuf)-1] = 0 |
| 216 | #define appendPrintBuf(x...) snprintf(printBuf, PRINTBUF_SIZE, x) |
| 217 | #else |
| 218 | #define startRequest |
| 219 | #define closeRequest |
| 220 | #define printRequest(token, req) |
| 221 | #define startResponse |
| 222 | #define closeResponse |
| 223 | #define printResponse |
| 224 | #define clearPrintBuf |
| 225 | #define removeLastChar |
| 226 | #define appendPrintBuf(x...) |
| 227 | #endif |
| 228 | |
| 229 | enum WakeType {DONT_WAKE, WAKE_PARTIAL}; |
| 230 | |
| 231 | // MTK-START [mtk80776] WiFi Calling |
| 232 | typedef struct { |
| 233 | int sessionId; /* for +CRLA */ |
| 234 | int command; /* one of the commands listed for TS 27.007 +CRSM/CRLA*/ |
| 235 | int fileId; /* EF id */ |
| 236 | char *path; /* "pathid" from TS 27.007 +CRSM command. |
| 237 | Path is in hex asciii format eg "7f205f70" |
| 238 | Path must always be provided. |
| 239 | */ |
| 240 | int p1; |
| 241 | int p2; |
| 242 | int p3; |
| 243 | char *data; /* May be NULL*/ |
| 244 | char *pin2; /* May be NULL*/ |
| 245 | char *aidPtr; /* AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value. */ |
| 246 | } RIL_UICC_IO_v6; |
| 247 | |
| 248 | typedef struct { |
| 249 | int session_id; |
| 250 | char *context1; |
| 251 | char *context2; |
| 252 | } RIL_UICC_Authentication; |
| 253 | |
| 254 | // [New R8 modem FD] |
| 255 | typedef struct { |
| 256 | int argsNum; // record total number of arguments of this mode |
| 257 | int mode; // allowed mode:0,1,2,3 |
| 258 | int parameter1; // only mode 2 and 3 has parameter1 this field |
| 259 | int parameter2; // only mode2 has parameter2 this field |
| 260 | }RIL_FdModeData; |
| 261 | |
| 262 | typedef struct { |
| 263 | int type; /* type of the entry, refer to RIL_PhbStorageType */ |
| 264 | int index; /* the stored index of the entry */ |
| 265 | char *number; /* the phone number */ |
| 266 | int ton; /* type of the number */ |
| 267 | char * alphaId; /* the alpha ID, using Hexdecimal coding method */ |
| 268 | } RIL_PhbEntryStrucutre; |
| 269 | |
| 270 | typedef struct { |
| 271 | int requestNumber; |
| 272 | int (*responseFunction) (Parcel &p, void *response, size_t responselen); |
| 273 | WakeType wakeType; |
| 274 | } UnsolResponseInfo; |
| 275 | |
| 276 | typedef struct UserCallbackInfo { |
| 277 | RIL_TimedCallback p_callback; |
| 278 | void *userParam; |
| 279 | struct ril_event event; |
| 280 | struct UserCallbackInfo *p_next; |
| 281 | } UserCallbackInfo; |
| 282 | |
| 283 | extern "C" const char * requestToString(int request); |
| 284 | extern "C" const char * failCauseToString(RIL_Errno); |
| 285 | extern "C" const char * callStateToString(RIL_CallState); |
| 286 | extern "C" const char * radioStateToString(RIL_RadioState); |
| 287 | extern "C" const char * rilSocketIdToString(RIL_SOCKET_ID socket_id); |
| 288 | extern "C" |
| 289 | char rild[MAX_SOCKET_NAME_LENGTH] = { 0 }; |
| 290 | /*******************************************************************/ |
| 291 | |
| 292 | RIL_RadioFunctions s_callbacks = {0, NULL, NULL, NULL, NULL, NULL}; |
| 293 | static int s_registerCalled = 0; |
| 294 | |
| 295 | static pthread_t s_tid_dispatch; |
| 296 | static pthread_t s_tid_reader; |
| 297 | static int s_started = 0; |
| 298 | |
| 299 | static int s_fdDebug = -1; |
| 300 | static int s_fdDebug_socket2 = -1; |
| 301 | |
| 302 | static int s_fdWakeupRead; |
| 303 | static int s_fdWakeupWrite; |
| 304 | |
| 305 | int s_wakelock_count = 0; |
| 306 | |
| 307 | static struct ril_event s_commands_event; |
| 308 | static struct ril_event s_wakeupfd_event; |
| 309 | static struct ril_event s_listen_event; |
| 310 | static SocketListenParam s_ril_param_socket; |
| 311 | |
| 312 | static pthread_mutex_t s_pendingRequestsMutex = PTHREAD_MUTEX_INITIALIZER; |
| 313 | static pthread_mutex_t s_writeMutex = PTHREAD_MUTEX_INITIALIZER; |
| 314 | static pthread_mutex_t s_wakeLockCountMutex = PTHREAD_MUTEX_INITIALIZER; |
| 315 | static RequestInfo *s_pendingRequests = NULL; |
| 316 | |
| 317 | static struct ril_event s_commands_event_socket2; |
| 318 | static struct ril_event s_listen_event_socket2; |
| 319 | static SocketListenParam s_ril_param_socket2; |
| 320 | |
| 321 | static pthread_mutex_t s_pendingRequestsMutex_socket2 = PTHREAD_MUTEX_INITIALIZER; |
| 322 | static pthread_mutex_t s_writeMutex_socket2 = PTHREAD_MUTEX_INITIALIZER; |
| 323 | static RequestInfo *s_pendingRequests_socket2 = NULL; |
| 324 | |
| 325 | static struct ril_event s_commands_event_socket3; |
| 326 | static struct ril_event s_listen_event_socket3; |
| 327 | static SocketListenParam s_ril_param_socket3; |
| 328 | |
| 329 | static pthread_mutex_t s_pendingRequestsMutex_socket3 = PTHREAD_MUTEX_INITIALIZER; |
| 330 | static pthread_mutex_t s_writeMutex_socket3 = PTHREAD_MUTEX_INITIALIZER; |
| 331 | static RequestInfo *s_pendingRequests_socket3 = NULL; |
| 332 | |
| 333 | static struct ril_event s_commands_event_socket4; |
| 334 | static struct ril_event s_listen_event_socket4; |
| 335 | static SocketListenParam s_ril_param_socket4; |
| 336 | |
| 337 | static pthread_mutex_t s_pendingRequestsMutex_socket4 = PTHREAD_MUTEX_INITIALIZER; |
| 338 | static pthread_mutex_t s_writeMutex_socket4 = PTHREAD_MUTEX_INITIALIZER; |
| 339 | static RequestInfo *s_pendingRequests_socket4 = NULL; |
| 340 | |
| 341 | |
| 342 | // support for multi-client socket |
| 343 | static struct ril_event* s_commands_event_socket_client; |
| 344 | static struct ril_event* s_listen_event_socket_client; |
| 345 | static SocketListenParam* s_ril_param_socket_clients; |
| 346 | |
| 347 | static pthread_mutex_t* s_pendingRequestsMutex_socket_client; |
| 348 | static pthread_mutex_t* s_writeMutex_socket_client; |
| 349 | static RequestInfo **s_pendingRequests_socket_client; |
| 350 | |
| 351 | /* RILJ client socket @{ */ |
| 352 | |
| 353 | static struct ril_event s_commands_event_socket_rilj; |
| 354 | static struct ril_event s_listen_event_socket_rilj; |
| 355 | static SocketListenParam s_ril_param_socket_rilj; |
| 356 | |
| 357 | static pthread_mutex_t s_pendingRequestsMutex_socket_rilj = PTHREAD_MUTEX_INITIALIZER; |
| 358 | static pthread_mutex_t s_writeMutex_socket_rilj = PTHREAD_MUTEX_INITIALIZER; |
| 359 | static RequestInfo *s_pendingRequests_socket_rilj = NULL; |
| 360 | |
| 361 | static struct ril_event s_commands_event_socket_rilj2; |
| 362 | static struct ril_event s_listen_event_socket_rilj2; |
| 363 | static SocketListenParam s_ril_param_socket_rilj2; |
| 364 | |
| 365 | static pthread_mutex_t s_pendingRequestsMutex_socket_rilj2 = PTHREAD_MUTEX_INITIALIZER; |
| 366 | static pthread_mutex_t s_writeMutex_socket_rilj2 = PTHREAD_MUTEX_INITIALIZER; |
| 367 | static RequestInfo *s_pendingRequests_socket_rilj2 = NULL; |
| 368 | |
| 369 | static SocketListenParam* s_rilj_socket_params[] = { |
| 370 | &s_ril_param_socket_rilj, &s_ril_param_socket_rilj2 }; |
| 371 | |
| 372 | static SocketListenParam* s_ril_socket_params[] = { &s_ril_param_socket, |
| 373 | &s_ril_param_socket2, &s_ril_param_socket3, &s_ril_param_socket4, |
| 374 | &s_ril_param_socket_rilj, &s_ril_param_socket_rilj2 }; |
| 375 | |
| 376 | #define SOCKET_NAME_RILJCLIENT "rild-rilj" |
| 377 | #define SOCKET2_NAME_RILJCLIENT "rild-rilj2" |
| 378 | static int s_riljclient_support = -1; |
| 379 | #define RILJ_CLIENT_SUPPORT_KEY "persist.ril.riljsupport" |
| 380 | |
| 381 | /* }@ */ |
| 382 | |
| 383 | static struct ril_event s_wake_timeout_event; |
| 384 | static struct ril_event s_debug_event; |
| 385 | |
| 386 | |
| 387 | static const struct timeval TIMEVAL_WAKE_TIMEOUT = {ANDROID_WAKE_LOCK_SECS,ANDROID_WAKE_LOCK_USECS}; |
| 388 | |
| 389 | |
| 390 | static pthread_mutex_t s_startupMutex = PTHREAD_MUTEX_INITIALIZER; |
| 391 | static pthread_cond_t s_startupCond = PTHREAD_COND_INITIALIZER; |
| 392 | |
| 393 | static pthread_mutex_t s_dispatchMutex = PTHREAD_MUTEX_INITIALIZER; |
| 394 | static pthread_cond_t s_dispatchCond = PTHREAD_COND_INITIALIZER; |
| 395 | |
| 396 | static RequestInfo *s_toDispatchHead = NULL; |
| 397 | static RequestInfo *s_toDispatchTail = NULL; |
| 398 | |
| 399 | static UserCallbackInfo *s_last_wake_timeout_info = NULL; |
| 400 | |
| 401 | static void *s_lastNITZTimeData = NULL; |
| 402 | static size_t s_lastNITZTimeDataSize; |
| 403 | |
| 404 | #if RILC_LOG |
| 405 | static char printBuf[PRINTBUF_SIZE]; |
| 406 | #endif |
| 407 | |
| 408 | // M: cache URC when RILJ socket is not connected |
| 409 | typedef struct AtResponseList { |
| 410 | int id; |
| 411 | Parcel* data; |
| 412 | size_t datalen; |
| 413 | AtResponseList *pNext; |
| 414 | } AtResponseList; |
| 415 | |
| 416 | void cacheUrc(int unsolResponse, const void *data, size_t datalen, RIL_SOCKET_ID id); |
| 417 | void sendPendedUrcs(RIL_SOCKET_ID socket_id, int fdCommand); |
| 418 | void sendUrc(RIL_SOCKET_ID socket_id, AtResponseList * urcCached); |
| 419 | bool isDsds(); |
| 420 | |
| 421 | int haveActiveFd(int socket_id); |
| 422 | |
| 423 | static AtResponseList* pendedUrcList1 = NULL; |
| 424 | static AtResponseList* pendedUrcList2 = NULL; |
| 425 | static AtResponseList* pendedUrcList3 = NULL; |
| 426 | static AtResponseList* pendedUrcList4 = NULL; |
| 427 | static AtResponseList* pendedUrcList_rilj = NULL; |
| 428 | static AtResponseList* pendedUrcList_rilj2 = NULL; |
| 429 | |
| 430 | pthread_mutex_t s_pendingUrcMutex[RIL_SOCKET_NUM]; |
| 431 | static int s_fdCommand[RIL_SOCKET_NUM]; |
| 432 | // extern "C" int SIM_COUNT = 2; |
| 433 | |
| 434 | static pthread_mutex_t s_state_mutex[RIL_SOCKET_NUM]; |
| 435 | |
| 436 | static int *s_fdCommand_client; |
| 437 | |
| 438 | |
| 439 | /*******************************************************************/ |
| 440 | static int sendResponse (Parcel &p, RIL_SOCKET_ID socket_id, int clientId); |
| 441 | |
| 442 | static void dispatchVoid (Parcel& p, RequestInfo *pRI); |
| 443 | static void dispatchString (Parcel& p, RequestInfo *pRI); |
| 444 | static void dispatchStrings (Parcel& p, RequestInfo *pRI); |
| 445 | static void dispatchInts (Parcel& p, RequestInfo *pRI); |
| 446 | static void dispatchDial (Parcel& p, RequestInfo *pRI); |
| 447 | static void dispatchSIM_IO (Parcel& p, RequestInfo *pRI); |
| 448 | static void dispatchSIM_APDU (Parcel& p, RequestInfo *pRI); |
| 449 | static void dispatchCallForward(Parcel& p, RequestInfo *pRI); |
| 450 | static void dispatchCallForwardEx(Parcel& p, RequestInfo *pRI); |
| 451 | static void dispatchRaw(Parcel& p, RequestInfo *pRI); |
| 452 | static void dispatchSmsWrite (Parcel &p, RequestInfo *pRI); |
| 453 | static void dispatchDataCall (Parcel& p, RequestInfo *pRI); |
| 454 | static void dispatchSetInitialAttachApn (Parcel& p, RequestInfo *pRI); |
| 455 | |
| 456 | static void dispatchCdmaSms(Parcel &p, RequestInfo *pRI); |
| 457 | static void dispatchImsSms(Parcel &p, RequestInfo *pRI); |
| 458 | static void dispatchImsCdmaSms(Parcel &p, RequestInfo *pRI, uint8_t retry, int32_t messageRef); |
| 459 | static void dispatchImsGsmSms(Parcel &p, RequestInfo *pRI, uint8_t retry, int32_t messageRef); |
| 460 | static void dispatchCdmaSmsAck(Parcel &p, RequestInfo *pRI); |
| 461 | static void dispatchGsmBrSmsCnf(Parcel &p, RequestInfo *pRI); |
| 462 | static void dispatchCdmaBrSmsCnf(Parcel &p, RequestInfo *pRI); |
| 463 | static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI); |
| 464 | static void dispatchNVReadItem(Parcel &p, RequestInfo *pRI); |
| 465 | static void dispatchNVWriteItem(Parcel &p, RequestInfo *pRI); |
| 466 | static void dispatchUiccSubscripton(Parcel &p, RequestInfo *pRI); |
| 467 | static void dispatchSimAuthentication(Parcel &p, RequestInfo *pRI); |
| 468 | static void dispatchDataProfile(Parcel &p, RequestInfo *pRI); |
| 469 | static void dispatchRadioCapability(Parcel &p, RequestInfo *pRI); |
| 470 | static void dispatchCarrierRestrictions(Parcel &p, RequestInfo *pRI); |
| 471 | //MTK-START [mtk80776] WiFi Calling |
| 472 | static void dispatchUiccIo(Parcel &p, RequestInfo *pRI); |
| 473 | static void dispatchUiccAuthentication(Parcel &p, RequestInfo *pRI); |
| 474 | //MTK-END [mtk80776] WiFi Calling |
| 475 | // New SIM Authentication |
| 476 | static void dispatchSimAuth(Parcel &p, RequestInfo *pRI); |
| 477 | //[New R8 modem FD] |
| 478 | static void dispatchFdMode(Parcel &p, RequestInfo *pRI); |
| 479 | //MTK-START PHB |
| 480 | static void dispatchPhbEntry(Parcel &p, RequestInfo *pRI); |
| 481 | static void dispatchWritePhbEntryExt(Parcel &p, RequestInfo *pRI); |
| 482 | //MTK-END PHB |
| 483 | //MTK-START SMS |
| 484 | static void dispatchSmsParams(Parcel &p, RequestInfo *pRI); |
| 485 | //MTK-END SMS |
| 486 | |
| 487 | // MTK-START: SIM OPEN CHANNEL WITH P2 |
| 488 | static void dispatchOpenChannelParams(Parcel &p, RequestInfo *pRI); |
| 489 | // MTK-END |
| 490 | |
| 491 | // Add for porting telematics |
| 492 | static void dispatchNetworkScan(Parcel &p, RequestInfo *pRI); |
| 493 | static void dispatchLinkCapacityReportingCriteria(Parcel &p, RequestInfo *pRI); |
| 494 | |
| 495 | static int responseNetworkScanResult(Parcel &p, void *response, size_t responselen); |
| 496 | static int responseQueryNetworkLock(android::Parcel &p, void *response, size_t responselen); |
| 497 | static void dispatchEcallSetMsd(Parcel &p, RequestInfo *pRI); |
| 498 | static void dispatchFastMakeEcall(Parcel &p, RequestInfo *pRI); |
| 499 | static void dispatchEcallSetNum(Parcel &p, RequestInfo *pRI); |
| 500 | static int responseEcallInd(Parcel &p, void *response, size_t responselen); |
| 501 | |
| 502 | // M: [VzW] Data Framework |
| 503 | static int responsePcoDataAfterAttached(Parcel &p, void *response, size_t responselen); |
| 504 | |
| 505 | static int responseLinkCapacityEstimate(Parcel &p, void *response, size_t responselen); |
| 506 | |
| 507 | static int responseInts(Parcel &p, void *response, size_t responselen); |
| 508 | static int responseFailCause(Parcel &p, void *response, size_t responselen); |
| 509 | static int responseStrings(Parcel &p, void *response, size_t responselen); |
| 510 | static int responseString(Parcel &p, void *response, size_t responselen); |
| 511 | static int responseVoid(Parcel &p, void *response, size_t responselen); |
| 512 | static int responseCallList(Parcel &p, void *response, size_t responselen); |
| 513 | static int responseSMS(Parcel &p, void *response, size_t responselen); |
| 514 | static int responseSIM_IO(Parcel &p, void *response, size_t responselen); |
| 515 | static int responseCallForwards(Parcel &p, void *response, size_t responselen); |
| 516 | static int responseCallForwardsEx(Parcel &p, void *response, size_t responselen); |
| 517 | static int responseDataCallList(Parcel &p, void *response, size_t responselen); |
| 518 | static int responseSetupDataCall(Parcel &p, void *response, size_t responselen); |
| 519 | static int responseRaw(Parcel &p, void *response, size_t responselen); |
| 520 | static int responseSsn(Parcel &p, void *response, size_t responselen); |
| 521 | static int responseSimStatus(Parcel &p, void *response, size_t responselen); |
| 522 | static int responseGsmBrSmsCnf(Parcel &p, void *response, size_t responselen); |
| 523 | static int responseCdmaBrSmsCnf(Parcel &p, void *response, size_t responselen); |
| 524 | static int responseCdmaSms(Parcel &p, void *response, size_t responselen); |
| 525 | static int responseCellList(Parcel &p, void *response, size_t responselen); |
| 526 | static int responseCdmaInformationRecords(Parcel &p,void *response, size_t responselen); |
| 527 | static int responseRilSignalStrength(Parcel &p,void *response, size_t responselen); |
| 528 | static int responseCallRing(Parcel &p, void *response, size_t responselen); |
| 529 | static int responseCdmaSignalInfoRecord(Parcel &p,void *response, size_t responselen); |
| 530 | static int responseCdmaCallWaiting(Parcel &p,void *response, size_t responselen); |
| 531 | static int responseSimRefresh(Parcel &p, void *response, size_t responselen); |
| 532 | static int responseCellInfoList(Parcel &p, void *response, size_t responselen); |
| 533 | static int responseGetSmsSimMemStatusCnf(Parcel &p,void *response, size_t responselen); |
| 534 | static int responseEtwsNotification(Parcel &p, void *response, size_t responselen); |
| 535 | static int responseHardwareConfig(Parcel &p, void *response, size_t responselen); |
| 536 | static int responseDcRtInfo(Parcel &p, void *response, size_t responselen); |
| 537 | static int responseRadioCapability(Parcel &p, void *response, size_t responselen); |
| 538 | static int responseSSData(Parcel &p, void *response, size_t responselen); |
| 539 | static int responseLceStatus(Parcel &p, void *response, size_t responselen); |
| 540 | static int responseLceData(Parcel &p, void *response, size_t responselen); |
| 541 | static int responseActivityData(Parcel &p, void *response, size_t responselen); |
| 542 | static int responseCarrierRestrictions(Parcel &p, void *response, size_t responselen); |
| 543 | static int responsePcoData(Parcel &p, void *response, size_t responselen); |
| 544 | static int responseCrssN(Parcel &p, void *response, size_t responselen); |
| 545 | //MTK-START PHB |
| 546 | static int responsePhbEntries(Parcel &p,void *response, size_t responselen); |
| 547 | static int responseGetPhbMemStorage(Parcel &p,void *response, size_t responselen); |
| 548 | static int responseReadPhbEntryExt(Parcel &p,void *response, size_t responselen); |
| 549 | //MTK-END PHB |
| 550 | static int responseImsBearerNotify(Parcel &p, void *response, size_t responselen); |
| 551 | //MTK-START SMS |
| 552 | static int responseSmsParams(Parcel &p, void *response, size_t responselen); |
| 553 | //MTK-END SMS |
| 554 | |
| 555 | static int decodeVoiceRadioTechnology (RIL_RadioState radioState); |
| 556 | static int decodeCdmaSubscriptionSource (RIL_RadioState radioState); |
| 557 | // static RIL_RadioState processRadioState(RIL_RadioState newRadioState); |
| 558 | static void grabPartialWakeLock(); |
| 559 | static void releaseWakeLock(); |
| 560 | static void wakeTimeoutCallback(void *); |
| 561 | |
| 562 | static bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType); |
| 563 | |
| 564 | static bool isDebuggable(); |
| 565 | |
| 566 | /// M: eMBMS feature |
| 567 | static int responseEmbmsEnable(Parcel &p, void *response, size_t responselen); |
| 568 | static int responseEmbmsDisable(Parcel &p, void *response, size_t responselen); |
| 569 | static void dispatchEmbmsStartSessionInfo(Parcel &p, RequestInfo *pRI); |
| 570 | static void dispatchEmbmsStopSessionInfo(Parcel &p, RequestInfo *pRI); |
| 571 | static int responseEmbmsSessionInfo(Parcel &p, void *response, size_t responselen); |
| 572 | static int responseEmbmsNetworkTime(Parcel &p, void *response, size_t responselen); |
| 573 | static int responseEmbmsGetCoverageState(Parcel &p, void *response, size_t responselen); |
| 574 | static int responseEmbmsOosNotify(Parcel &p, void *response, size_t responselen); |
| 575 | static int responseEmbmsActiveSessionNotify(Parcel &p, void *response, size_t responselen); |
| 576 | static int responseEmbmsCellInfoNotify(Parcel &p, void *response, size_t responselen); |
| 577 | static int responseEmbmsSaiNotify(Parcel &p, void *response, size_t responselen); |
| 578 | static int responseEmbmsModemEeNotify(Parcel &p, void *response, size_t responselen); |
| 579 | |
| 580 | static int responseVoiceRegState(Parcel &p, void *response, size_t responselen); |
| 581 | static int responseDataRegState(Parcel &p, void *response, size_t responselen); |
| 582 | static int responseKeepaliveStatus(Parcel &p, void *response, size_t responselen); |
| 583 | |
| 584 | // External SIM - Start |
| 585 | static void dispatchVsimEvent(Parcel &p, RequestInfo *pRI); |
| 586 | static void dispatchVsimOperationEvent(Parcel &p, RequestInfo *pRI); |
| 587 | static int responseVsimOperationEvent(Parcel &p, void *response, size_t responselen); |
| 588 | static int responseVsimNotificationResponse(Parcel &p, void *response, size_t responselen); |
| 589 | // External SIM - End |
| 590 | |
| 591 | /// since vendor ril uses socket id, so change slot id to socket id again |
| 592 | static RIL_SOCKET_ID mapingSlotIdToRilSocketId(RIL_SLOT_ID slot_id); |
| 593 | |
| 594 | /// change libril's socket id to slot id to initialize slot id |
| 595 | extern "C" RIL_SLOT_ID mappingSocketIdToSlotId(RIL_SOCKET_ID socket_id); |
| 596 | |
| 597 | #ifdef HAVE_AEE_FEATURE |
| 598 | void triggerWarning(char *pErrMsg); |
| 599 | #endif |
| 600 | |
| 601 | #ifdef RIL_SHLIB |
| 602 | #if defined(ANDROID_MULTI_SIM) |
| 603 | extern "C" void RIL_onUnsolicitedResponse(int unsolResponse, const void *data, |
| 604 | size_t datalen, RIL_SOCKET_ID socket_id); |
| 605 | #else |
| 606 | extern "C" void RIL_onUnsolicitedResponse(int unsolResponse, const void *data, |
| 607 | size_t datalen); |
| 608 | #endif |
| 609 | #endif |
| 610 | |
| 611 | static void RIL_onUnsolicitedResponseInternal(int unsolResponse, const void *data, |
| 612 | size_t datalen, SocketListenParam* socket_param); |
| 613 | |
| 614 | #if defined(ANDROID_MULTI_SIM) |
| 615 | #define RIL_UNSOL_RESPONSE(a, b, c, d) RIL_onUnsolicitedResponse((a), (b), (c), (d)) |
| 616 | #define CALL_ONREQUEST(a, b, c, d, e) android::s_callbacks.onRequest((a), (b), (c), (d), (e)) |
| 617 | #define CALL_ONSTATEREQUEST(a) android::s_callbacks.onStateRequest(a) |
| 618 | #else |
| 619 | #define RIL_UNSOL_RESPONSE(a, b, c, d) RIL_onUnsolicitedResponse((a), (b), (c)) |
| 620 | #define CALL_ONREQUEST(a, b, c, d, e) android::s_callbacks.onRequest((a), (b), (c), (d)) |
| 621 | #define CALL_ONSTATEREQUEST(a) android::s_callbacks.onStateRequest() |
| 622 | #endif |
| 623 | |
| 624 | // Multiple Radio HIDL Client for IMS |
| 625 | |
| 626 | static UserCallbackInfo * internalRequestTimedCallback |
| 627 | (RIL_TimedCallback callback, void *param, |
| 628 | const struct timeval *relativeTime); |
| 629 | |
| 630 | |
| 631 | /** Index == requestNumber */ |
| 632 | static CommandInfo s_commands[] = { |
| 633 | #include "telephony/ril_commands.h" |
| 634 | }; |
| 635 | |
| 636 | static UnsolResponseInfo s_unsolResponses[] = { |
| 637 | #include "telephony/ril_unsol_commands.h" |
| 638 | }; |
| 639 | |
| 640 | /// M: mtk request table |
| 641 | CommandInfo s_mtk_commands[] = { |
| 642 | #include "telephony/mtk_ril_commands.h" |
| 643 | }; |
| 644 | |
| 645 | static UnsolResponseInfo s_mtk_unsolResponses[] = { |
| 646 | #include "telephony/mtk_ril_unsol_commands.h" |
| 647 | }; |
| 648 | /// M |
| 649 | |
| 650 | /// M: mtk ivt request table |
| 651 | CommandInfo s_mtk_ivt_commands[] = { |
| 652 | #include "telephony/mtk_ril_ivt_commands.h" |
| 653 | }; |
| 654 | |
| 655 | static UnsolResponseInfo s_mtk_ivt_unsolResponses[] = { |
| 656 | #include "telephony/mtk_ril_ivt_unsol_commands.h" |
| 657 | }; |
| 658 | /// M |
| 659 | |
| 660 | /* For older RILs that do not support new commands RIL_REQUEST_VOICE_RADIO_TECH and |
| 661 | RIL_UNSOL_VOICE_RADIO_TECH_CHANGED messages, decode the voice radio tech from |
| 662 | radio state message and store it. Every time there is a change in Radio State |
| 663 | check to see if voice radio tech changes and notify telephony |
| 664 | */ |
| 665 | int voiceRadioTech = -1; |
| 666 | |
| 667 | /* For older RILs that do not support new commands RIL_REQUEST_GET_CDMA_SUBSCRIPTION_SOURCE |
| 668 | and RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED messages, decode the subscription |
| 669 | source from radio state and store it. Every time there is a change in Radio State |
| 670 | check to see if subscription source changed and notify telephony |
| 671 | */ |
| 672 | int cdmaSubscriptionSource = -1; |
| 673 | |
| 674 | /* For older RILs that do not send RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, decode the |
| 675 | SIM/RUIM state from radio state and store it. Every time there is a change in Radio State, |
| 676 | check to see if SIM/RUIM status changed and notify telephony |
| 677 | */ |
| 678 | int simRuimStatus = -1; |
| 679 | |
| 680 | static void changeClientSoketStatus(int slot_id, int client_id, int value){ |
| 681 | long long status = 0; |
| 682 | char property_status[PROP_VALUE_MAX] = {0}; |
| 683 | char clientNum[PROP_VALUE_MAX] = {0}; |
| 684 | int clientSocketNum = 0; |
| 685 | |
| 686 | mtk_property_get("persist.ril.client.num", clientNum, "0"); |
| 687 | clientSocketNum = std::stoi(clientNum); |
| 688 | RLOGD("[changeClientSoketStatus] persist.ril.client.num= %d, slot_id=%d, client_id=%d,value=%d", |
| 689 | clientSocketNum, slot_id, client_id, value); |
| 690 | |
| 691 | if((0 != value) && (1!=value)){ //value must be 0 or 1 |
| 692 | RLOGE("[changeClientSoketStatus]error!value must be 0 or 1"); |
| 693 | return; |
| 694 | } |
| 695 | if((slot_id >= RIL_SLOT_MAX) || (client_id >= clientSocketNum) || (client_id >= (8*sizeof(long long) -1))){ |
| 696 | RLOGE("[changeClientSoketStatus]error, RIL_SLOT_MAX=%d, slot_id=%d, persist.ril.client.num=%d, client_id=d", |
| 697 | RIL_SLOT_MAX, slot_id, clientSocketNum, client_id); |
| 698 | return; |
| 699 | } |
| 700 | |
| 701 | mtk_property_get(socket_status[slot_id], property_status, "0"); |
| 702 | RLOGD("[changeClientSoketStatus]before sscanf: %s = %s, status = 0x%llx", |
| 703 | socket_status[slot_id], property_status, status); |
| 704 | sscanf(property_status, "%lld", &status); |
| 705 | RLOGD("[changeClientSoketStatus]before: %s = %s, status = 0x%llx", |
| 706 | socket_status[slot_id], property_status, status); |
| 707 | if(0 == value) { |
| 708 | status = (~(1 << client_id)) & status; |
| 709 | } else if (1 == value) { |
| 710 | status = (1 << client_id) | status; |
| 711 | } |
| 712 | sprintf(property_status, "%lld", status); |
| 713 | mtk_property_set(socket_status[slot_id], property_status); |
| 714 | RLOGD("[changeClientSoketStatus]after: %s = %s, status = 0x%llx", socket_status[slot_id], property_status, status); |
| 715 | } |
| 716 | static char * RIL_getRilSocketName() { |
| 717 | char test_mode[PROP_VALUE_MAX] = { 0 }; |
| 718 | if (strlen(rild) == 0) { |
| 719 | strcpy(rild, RIL_getRilSocketNameById(RIL_SOCKET_1)); |
| 720 | } |
| 721 | mtk_property_get("persist.ril.test_mode", test_mode, "0"); |
| 722 | if (strcmp(test_mode, "0") == 0) { |
| 723 | //no test mode |
| 724 | return rild; |
| 725 | } else { |
| 726 | strcpy(rild, RIL_getRilSocketNameById(RIL_SOCKET_1)); |
| 727 | } |
| 728 | return rild; |
| 729 | } |
| 730 | |
| xj | b04a402 | 2021-11-25 15:01:52 +0800 | [diff] [blame] | 731 | static char * |
| 732 | strdupReadString(Parcel &p) { |
| 733 | size_t stringlen; |
| 734 | const char16_t *s16; |
| 735 | |
| 736 | s16 = p.readString16Inplace(&stringlen); |
| 737 | |
| 738 | return strndup16to8(s16, stringlen); |
| 739 | } |
| 740 | |
| 741 | static status_t |
| 742 | readStringFromParcelInplace(Parcel &p, char *str, size_t maxLen) { |
| 743 | size_t s16Len; |
| 744 | const char16_t *s16; |
| 745 | |
| 746 | s16 = p.readString16Inplace(&s16Len); |
| 747 | if (s16 == NULL) { |
| 748 | return NO_MEMORY; |
| 749 | } |
| 750 | size_t strLen = strnlen16to8(s16, s16Len); |
| 751 | if ((strLen + 1) > maxLen) { |
| 752 | return NO_MEMORY; |
| 753 | } |
| 754 | if (strncpy16to8(str, s16, strLen) == NULL) { |
| 755 | return NO_MEMORY; |
| 756 | } else { |
| 757 | return NO_ERROR; |
| 758 | } |
| 759 | } |
| 760 | |
| 761 | static void writeStringToParcel(Parcel &p, const char *s) { |
| 762 | char16_t *s16; |
| 763 | size_t s16_len; |
| 764 | s16 = strdup8to16(s, &s16_len); |
| 765 | p.writeString16(s16, s16_len); |
| 766 | free(s16); |
| 767 | } |
| 768 | |
| 769 | |
| 770 | static void |
| 771 | memsetString (char *s) { |
| 772 | if (s != NULL) { |
| 773 | memset (s, 0, strlen(s)); |
| 774 | } |
| 775 | } |
| 776 | |
| 777 | void nullParcelReleaseFunction (const uint8_t* data, size_t dataSize, |
| 778 | const size_t* objects, size_t objectsSize, |
| 779 | void* cookie) { |
| 780 | // do nothing -- the data reference lives longer than the Parcel object |
| 781 | } |
| 782 | |
| 783 | /** |
| 784 | * To be called from dispatch thread |
| 785 | * Issue a single local request, ensuring that the response |
| 786 | * is not sent back up to the command process |
| 787 | */ |
| 788 | static void |
| 789 | issueLocalRequest(int request, void *data, int len, RIL_SOCKET_ID socket_id) { |
| 790 | RequestInfo *pRI; |
| 791 | int ret; |
| 792 | /* Hook for current context */ |
| 793 | /* pendingRequestsMutextHook refer to &s_pendingRequestsMutex */ |
| 794 | pthread_mutex_t* pendingRequestsMutexHook = &s_pendingRequestsMutex; |
| 795 | /* pendingRequestsHook refer to &s_pendingRequests */ |
| 796 | RequestInfo** pendingRequestsHook = &s_pendingRequests; |
| 797 | |
| 798 | if (socket_id == RIL_SOCKET_2) { |
| 799 | pendingRequestsMutexHook = &s_pendingRequestsMutex_socket2; |
| 800 | pendingRequestsHook = &s_pendingRequests_socket2; |
| 801 | } |
| 802 | if (request < 1 || request >= (int32_t)NUM_ELEMS(s_commands)) { |
| 803 | /// M: customize for mtk request |
| 804 | if ((request >= (int32_t)NUM_ELEMS(s_commands) && request < RIL_REQUEST_VENDOR_BASE) || |
| 805 | (request > (RIL_REQUEST_VENDOR_BASE + (int32_t)NUM_ELEMS(s_mtk_commands)) && request < RIL_REQUEST_VENDOR_IVT_BASE) || |
| 806 | request > (RIL_REQUEST_VENDOR_IVT_BASE + (int32_t)NUM_ELEMS(s_mtk_ivt_commands))) { |
| 807 | /// M |
| 808 | RLOGE("unsupported local request code %d", request); |
| 809 | return; |
| 810 | } |
| 811 | } |
| 812 | |
| 813 | pRI = (RequestInfo *)calloc(1, sizeof(RequestInfo)); |
| 814 | if (pRI == NULL) { |
| 815 | RLOGE("Memory allocation failed for request %s", requestToString(request)); |
| 816 | return; |
| 817 | } |
| 818 | |
| 819 | pRI->local = 1; |
| 820 | pRI->token = 0xffffffff; // token is not used in this context |
| 821 | if (request >= RIL_REQUEST_VENDOR_IVT_BASE) { |
| 822 | pRI->pCI = &(s_mtk_ivt_commands[request - RIL_REQUEST_VENDOR_IVT_BASE]); |
| 823 | } else if (request >= RIL_REQUEST_VENDOR_BASE) { |
| 824 | pRI->pCI = &(s_mtk_commands[request - RIL_REQUEST_VENDOR_BASE]); |
| 825 | } else { |
| 826 | pRI->pCI = &(s_commands[request]); |
| 827 | } |
| 828 | pRI->socket_id = socket_id; |
| 829 | pRI->slot_id = mappingSocketIdToSlotId(socket_id); |
| 830 | |
| 831 | ret = pthread_mutex_lock(pendingRequestsMutexHook); |
| 832 | assert (ret == 0); |
| 833 | |
| 834 | pRI->p_next = *pendingRequestsHook; |
| 835 | *pendingRequestsHook = pRI; |
| 836 | |
| 837 | ret = pthread_mutex_unlock(pendingRequestsMutexHook); |
| 838 | assert (ret == 0); |
| 839 | |
| 840 | RLOGD("C[locl]> %s", requestToString(request)); |
| 841 | |
| 842 | onRequest(request,(Parcel *)data,pRI,pRI->socket_id); |
| 843 | //CALL_ONREQUEST(request, data, len, pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 844 | } |
| 845 | |
| 846 | static int |
| 847 | processCommandBuffer(void *buffer, size_t buflen, RIL_SOCKET_ID socket_id, int clientId) { |
| 848 | Parcel *p = new Parcel(); |
| 849 | status_t status; |
| 850 | int32_t request = 0; |
| 851 | int32_t token; |
| 852 | RequestInfo *pRI; |
| 853 | int ret; |
| 854 | /* Hook for current context */ |
| 855 | /* pendingRequestsMutextHook refer to &s_pendingRequestsMutex */ |
| 856 | pthread_mutex_t* pendingRequestsMutexHook = &s_pendingRequestsMutex; |
| 857 | /* pendingRequestsHook refer to &s_pendingRequests */ |
| 858 | RequestInfo** pendingRequestsHook = &s_pendingRequests; |
| 859 | |
| 860 | if(p == NULL) { |
| 861 | RLOGE("processCommandBuffer new parcel fail!!!"); |
| 862 | return 0; |
| 863 | } |
| 864 | p->setData((uint8_t *) buffer, buflen); |
| 865 | |
| 866 | // status checked at end |
| 867 | status = p->readInt32(&request); |
| 868 | status = p->readInt32 (&token); |
| 869 | |
| 870 | /// M: support rilj client @{ |
| 871 | |
| 872 | if (socket_id == RIL_SOCKET_2) { |
| 873 | pendingRequestsMutexHook = &s_pendingRequestsMutex_socket2; |
| 874 | pendingRequestsHook = &s_pendingRequests_socket2; |
| 875 | } |
| 876 | else if (socket_id == RIL_SOCKET_3) { |
| 877 | pendingRequestsMutexHook = &s_pendingRequestsMutex_socket3; |
| 878 | pendingRequestsHook = &s_pendingRequests_socket3; |
| 879 | } |
| 880 | else if (socket_id == RIL_SOCKET_4) { |
| 881 | pendingRequestsMutexHook = &s_pendingRequestsMutex_socket4; |
| 882 | pendingRequestsHook = &s_pendingRequests_socket4; |
| 883 | } |
| 884 | else if (socket_id == RIL_SOCKET_RILJ) { |
| 885 | pendingRequestsMutexHook = &s_pendingRequestsMutex_socket_rilj; |
| 886 | pendingRequestsHook = &s_pendingRequests_socket_rilj; |
| 887 | } else if (socket_id == RIL_SOCKET_RILJ2) { |
| 888 | pendingRequestsMutexHook = &s_pendingRequestsMutex_socket_rilj2; |
| 889 | pendingRequestsHook = &s_pendingRequests_socket_rilj2; |
| 890 | } |
| 891 | |
| 892 | if (clientId >= 0) { |
| 893 | pendingRequestsMutexHook = &s_pendingRequestsMutex_socket_client[clientId]; |
| 894 | pendingRequestsHook = &s_pendingRequests_socket_client[clientId]; |
| 895 | } |
| 896 | |
| 897 | /// @} |
| 898 | |
| 899 | if (status != NO_ERROR) { |
| 900 | delete(p); |
| 901 | RLOGE("invalid request block"); |
| 902 | return 0; |
| 903 | } |
| 904 | |
| 905 | // Received an Ack for the previous result sent to RIL.java, |
| 906 | // so release wakelock and exit |
| 907 | if (request == RIL_RESPONSE_ACKNOWLEDGEMENT) { |
| 908 | releaseWakeLock(); |
| 909 | delete(p); |
| 910 | return 0; |
| 911 | } |
| 912 | |
| 913 | if (request < 1 || request >= (int32_t)NUM_ELEMS(s_commands)) { |
| 914 | /// M: customize for mtk request |
| 915 | if ((request >= (int32_t)NUM_ELEMS(s_commands) && request < RIL_REQUEST_VENDOR_BASE) || |
| 916 | (request >= (RIL_REQUEST_VENDOR_BASE + (int32_t)NUM_ELEMS(s_mtk_commands)) && request < RIL_REQUEST_VENDOR_IVT_BASE) || |
| 917 | request >= (RIL_REQUEST_VENDOR_IVT_BASE + (int32_t)NUM_ELEMS(s_mtk_ivt_commands))) { |
| 918 | /// M |
| 919 | Parcel pErr; |
| 920 | RLOGE("unsupported request code %d token %d", request, token); |
| 921 | // FIXME this should perhaps return a response |
| 922 | pErr.writeInt32 (RESPONSE_SOLICITED); |
| 923 | pErr.writeInt32 (token); |
| 924 | pErr.writeInt32 (RIL_E_GENERIC_FAILURE); |
| 925 | |
| 926 | /// support RILJ client, using real socket id |
| 927 | sendResponse(pErr, socket_id, clientId); |
| 928 | delete(p); |
| 929 | return 0; |
| 930 | } |
| 931 | } |
| 932 | |
| 933 | pRI = (RequestInfo *)calloc(1, sizeof(RequestInfo)); |
| 934 | if (pRI == NULL) { |
| 935 | RLOGE("Memory allocation failed for request %s", requestToString(request)); |
| 936 | delete(p); |
| 937 | return 0; |
| 938 | } |
| 939 | |
| 940 | pRI->token = token; |
| 941 | |
| 942 | RLOGD("socket id = %s, token = %d, request = %s(%d)", rilSocketIdToString(socket_id), |
| 943 | token, requestToString(request), request); |
| 944 | /// M: ril proxy |
| 945 | if (request >= RIL_REQUEST_VENDOR_IVT_BASE) { |
| 946 | pRI->pCI = &(s_mtk_ivt_commands[request - RIL_REQUEST_VENDOR_IVT_BASE]); |
| 947 | } else if (request >= RIL_REQUEST_VENDOR_BASE) { |
| 948 | pRI->pCI = &(s_mtk_commands[request - RIL_REQUEST_VENDOR_BASE]); |
| 949 | } else { |
| 950 | pRI->pCI = &(s_commands[request]); |
| 951 | } |
| 952 | /// M |
| 953 | |
| 954 | pRI->socket_id = socket_id; |
| 955 | /// M: support rilj client |
| 956 | pRI->slot_id = mappingSocketIdToSlotId(socket_id); |
| 957 | |
| 958 | pRI->clientId = clientId; |
| 959 | |
| 960 | ret = pthread_mutex_lock(pendingRequestsMutexHook); |
| 961 | assert (ret == 0); |
| 962 | |
| 963 | pRI->p_next = *pendingRequestsHook; |
| 964 | *pendingRequestsHook = pRI; |
| 965 | |
| 966 | ret = pthread_mutex_unlock(pendingRequestsMutexHook); |
| 967 | assert (ret == 0); |
| 968 | |
| 969 | /* sLastDispatchedToken = token; */ |
| 970 | // TODO: remove this! temp solution |
| 971 | if (pRI->pCI->dispatchFunction != NULL) { |
| 972 | //pRI->pCI->dispatchFunction(p, pRI); |
| 973 | onRequest(request,p,pRI,pRI->socket_id); |
| 974 | } else { |
| 975 | RIL_onRequestComplete(pRI, RIL_E_REQUEST_NOT_SUPPORTED, NULL, 0); |
| 976 | } |
| 977 | |
| 978 | return 0; |
| 979 | } |
| 980 | |
| 981 | static void |
| 982 | invalidCommandBlock (RequestInfo *pRI) { |
| 983 | RLOGE("invalid command block for token %d request %s", |
| 984 | pRI->token, requestToString(pRI->pCI->requestNumber)); |
| 985 | } |
| 986 | |
| 987 | /** Callee expects NULL */ |
| 988 | static void |
| 989 | dispatchVoid (Parcel& p, RequestInfo *pRI) { |
| 990 | clearPrintBuf; |
| 991 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 992 | CALL_ONREQUEST(pRI->pCI->requestNumber, NULL, 0, pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 993 | } |
| 994 | |
| 995 | /** Callee expects const char * */ |
| 996 | static void |
| 997 | dispatchString (Parcel& p, RequestInfo *pRI) { |
| 998 | status_t status; |
| 999 | size_t datalen; |
| 1000 | size_t stringlen; |
| 1001 | char *string8 = NULL; |
| 1002 | |
| 1003 | string8 = strdupReadString(p); |
| 1004 | |
| 1005 | startRequest; |
| 1006 | appendPrintBuf("%s%s", printBuf, string8); |
| 1007 | closeRequest; |
| 1008 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 1009 | |
| 1010 | CALL_ONREQUEST(pRI->pCI->requestNumber, string8, |
| 1011 | sizeof(char *), pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 1012 | |
| 1013 | #ifdef MEMSET_FREED |
| 1014 | memsetString(string8); |
| 1015 | #endif |
| 1016 | |
| 1017 | free(string8); |
| 1018 | return; |
| 1019 | invalid: |
| 1020 | invalidCommandBlock(pRI); |
| 1021 | return; |
| 1022 | } |
| 1023 | |
| 1024 | /** Callee expects const char ** */ |
| 1025 | static void |
| 1026 | dispatchStrings (Parcel &p, RequestInfo *pRI) { |
| 1027 | int32_t countStrings; |
| 1028 | status_t status; |
| 1029 | size_t datalen; |
| 1030 | char **pStrings; |
| 1031 | |
| 1032 | status = p.readInt32 (&countStrings); |
| 1033 | |
| 1034 | if (status != NO_ERROR) { |
| 1035 | goto invalid; |
| 1036 | } |
| 1037 | |
| 1038 | startRequest; |
| 1039 | if (countStrings == 0) { |
| 1040 | // just some non-null pointer |
| 1041 | pStrings = (char **)calloc(1, sizeof(char *)); |
| 1042 | if (pStrings == NULL) { |
| 1043 | RLOGE("Memory allocation failed for request %s", |
| 1044 | requestToString(pRI->pCI->requestNumber)); |
| 1045 | closeRequest; |
| 1046 | return; |
| 1047 | } |
| 1048 | |
| 1049 | datalen = 0; |
| 1050 | } else if (countStrings < 0) { |
| 1051 | pStrings = NULL; |
| 1052 | datalen = 0; |
| 1053 | } else { |
| 1054 | datalen = sizeof(char *) * countStrings; |
| 1055 | |
| 1056 | pStrings = (char **)calloc(countStrings, sizeof(char *)); |
| 1057 | if (pStrings == NULL) { |
| 1058 | RLOGE("Memory allocation failed for request %s", |
| 1059 | requestToString(pRI->pCI->requestNumber)); |
| 1060 | closeRequest; |
| 1061 | return; |
| 1062 | } |
| 1063 | |
| 1064 | for (int i = 0 ; i < countStrings ; i++) { |
| 1065 | pStrings[i] = strdupReadString(p); |
| 1066 | appendPrintBuf("%s%s,", printBuf, pStrings[i]); |
| 1067 | } |
| 1068 | } |
| 1069 | removeLastChar; |
| 1070 | closeRequest; |
| 1071 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 1072 | |
| 1073 | CALL_ONREQUEST(pRI->pCI->requestNumber, pStrings, datalen, pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 1074 | |
| 1075 | if (pStrings != NULL) { |
| 1076 | for (int i = 0 ; i < countStrings ; i++) { |
| 1077 | #ifdef MEMSET_FREED |
| 1078 | memsetString (pStrings[i]); |
| 1079 | #endif |
| 1080 | free(pStrings[i]); |
| 1081 | } |
| 1082 | |
| 1083 | #ifdef MEMSET_FREED |
| 1084 | memset(pStrings, 0, datalen); |
| 1085 | #endif |
| 1086 | free(pStrings); |
| 1087 | } |
| 1088 | |
| 1089 | return; |
| 1090 | invalid: |
| 1091 | invalidCommandBlock(pRI); |
| 1092 | return; |
| 1093 | } |
| 1094 | |
| 1095 | /** Callee expects const int * */ |
| 1096 | static void |
| 1097 | dispatchInts (Parcel &p, RequestInfo *pRI) { |
| 1098 | int32_t count = 0; |
| 1099 | status_t status; |
| 1100 | size_t datalen; |
| 1101 | int *pInts; |
| 1102 | |
| 1103 | status = p.readInt32 (&count); |
| 1104 | |
| 1105 | if (status != NO_ERROR || count <= 0) { |
| 1106 | goto invalid; |
| 1107 | } |
| 1108 | |
| 1109 | datalen = sizeof(int) * count; |
| 1110 | pInts = (int *)calloc(count, sizeof(int)); |
| 1111 | if (pInts == NULL) { |
| 1112 | RLOGE("Memory allocation failed for request %s", requestToString(pRI->pCI->requestNumber)); |
| 1113 | return; |
| 1114 | } |
| 1115 | |
| 1116 | startRequest; |
| 1117 | for (int i = 0 ; i < count ; i++) { |
| 1118 | int32_t t = 0; |
| 1119 | |
| 1120 | status = p.readInt32(&t); |
| 1121 | pInts[i] = (int)t; |
| 1122 | appendPrintBuf("%s%d,", printBuf, t); |
| 1123 | |
| 1124 | if (status != NO_ERROR) { |
| 1125 | free(pInts); |
| 1126 | goto invalid; |
| 1127 | } |
| 1128 | } |
| 1129 | removeLastChar; |
| 1130 | closeRequest; |
| 1131 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 1132 | |
| 1133 | CALL_ONREQUEST(pRI->pCI->requestNumber, const_cast<int *>(pInts), |
| 1134 | datalen, pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 1135 | |
| 1136 | #ifdef MEMSET_FREED |
| 1137 | memset(pInts, 0, datalen); |
| 1138 | #endif |
| 1139 | free(pInts); |
| 1140 | return; |
| 1141 | invalid: |
| 1142 | invalidCommandBlock(pRI); |
| 1143 | return; |
| 1144 | } |
| 1145 | |
| 1146 | |
| 1147 | /** |
| 1148 | * Callee expects const RIL_SMS_WriteArgs * |
| 1149 | * Payload is: |
| 1150 | * int32_t status |
| 1151 | * String pdu |
| 1152 | */ |
| 1153 | static void |
| 1154 | dispatchSmsWrite (Parcel &p, RequestInfo *pRI) { |
| 1155 | RIL_SMS_WriteArgs args; |
| 1156 | int32_t t = 0; |
| 1157 | status_t status; |
| 1158 | |
| 1159 | RLOGD("dispatchSmsWrite"); |
| 1160 | memset (&args, 0, sizeof(args)); |
| 1161 | |
| 1162 | status = p.readInt32(&t); |
| 1163 | args.status = (int)t; |
| 1164 | |
| 1165 | args.pdu = strdupReadString(p); |
| 1166 | |
| 1167 | if (status != NO_ERROR || args.pdu == NULL) { |
| 1168 | goto invalid; |
| 1169 | } |
| 1170 | |
| 1171 | args.smsc = strdupReadString(p); |
| 1172 | |
| 1173 | startRequest; |
| 1174 | appendPrintBuf("%s%d,%s,smsc=%s", printBuf, args.status, |
| 1175 | (char*)args.pdu, (char*)args.smsc); |
| 1176 | closeRequest; |
| 1177 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 1178 | |
| 1179 | CALL_ONREQUEST(pRI->pCI->requestNumber, &args, sizeof(args), pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 1180 | |
| 1181 | #ifdef MEMSET_FREED |
| 1182 | memsetString (args.pdu); |
| 1183 | #endif |
| 1184 | |
| 1185 | free (args.pdu); |
| 1186 | |
| 1187 | #ifdef MEMSET_FREED |
| 1188 | memset(&args, 0, sizeof(args)); |
| 1189 | #endif |
| 1190 | |
| 1191 | return; |
| 1192 | invalid: |
| 1193 | invalidCommandBlock(pRI); |
| 1194 | return; |
| 1195 | } |
| 1196 | |
| 1197 | /** |
| 1198 | * Callee expects const RIL_Dial * |
| 1199 | * Payload is: |
| 1200 | * String address |
| 1201 | * int32_t clir |
| 1202 | */ |
| 1203 | static void |
| 1204 | dispatchDial (Parcel &p, RequestInfo *pRI) { |
| 1205 | RIL_Dial dial; |
| 1206 | RIL_UUS_Info uusInfo; |
| 1207 | int32_t sizeOfDial; |
| 1208 | int32_t t; |
| 1209 | int32_t uusPresent; |
| 1210 | status_t status; |
| 1211 | |
| 1212 | RLOGD("dispatchDial"); |
| 1213 | memset (&dial, 0, sizeof(dial)); |
| 1214 | |
| 1215 | dial.address = strdupReadString(p); |
| 1216 | |
| 1217 | status = p.readInt32(&t); |
| 1218 | dial.clir = (int)t; |
| 1219 | |
| 1220 | if (status != NO_ERROR || dial.address == NULL) { |
| 1221 | goto invalid; |
| 1222 | } |
| 1223 | |
| 1224 | if (s_callbacks.version < 3) { // Remove when partners upgrade to version 3 |
| 1225 | uusPresent = 0; |
| 1226 | sizeOfDial = sizeof(dial) - sizeof(RIL_UUS_Info *); |
| 1227 | } else { |
| 1228 | status = p.readInt32(&uusPresent); |
| 1229 | |
| 1230 | if (status != NO_ERROR) { |
| 1231 | goto invalid; |
| 1232 | } |
| 1233 | |
| 1234 | if (uusPresent == 0) { |
| 1235 | dial.uusInfo = NULL; |
| 1236 | } else { |
| 1237 | int32_t len; |
| 1238 | |
| 1239 | memset(&uusInfo, 0, sizeof(RIL_UUS_Info)); |
| 1240 | |
| 1241 | status = p.readInt32(&t); |
| 1242 | uusInfo.uusType = (RIL_UUS_Type) t; |
| 1243 | |
| 1244 | status = p.readInt32(&t); |
| 1245 | uusInfo.uusDcs = (RIL_UUS_DCS) t; |
| 1246 | |
| 1247 | status = p.readInt32(&len); |
| 1248 | if (status != NO_ERROR) { |
| 1249 | goto invalid; |
| 1250 | } |
| 1251 | |
| 1252 | // The java code writes -1 for null arrays |
| 1253 | if (((int) len) == -1) { |
| 1254 | uusInfo.uusData = NULL; |
| 1255 | len = 0; |
| 1256 | } else { |
| 1257 | uusInfo.uusData = (char*) p.readInplace(len); |
| 1258 | } |
| 1259 | |
| 1260 | uusInfo.uusLength = len; |
| 1261 | dial.uusInfo = &uusInfo; |
| 1262 | } |
| 1263 | sizeOfDial = sizeof(dial); |
| 1264 | } |
| 1265 | |
| 1266 | startRequest; |
| 1267 | appendPrintBuf("%snum=%s,clir=%d", printBuf, dial.address, dial.clir); |
| 1268 | if (uusPresent) { |
| 1269 | appendPrintBuf("%s,uusType=%d,uusDcs=%d,uusLen=%d", printBuf, |
| 1270 | dial.uusInfo->uusType, dial.uusInfo->uusDcs, |
| 1271 | dial.uusInfo->uusLength); |
| 1272 | } |
| 1273 | closeRequest; |
| 1274 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 1275 | |
| 1276 | CALL_ONREQUEST(pRI->pCI->requestNumber, &dial, sizeOfDial, pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 1277 | |
| 1278 | #ifdef MEMSET_FREED |
| 1279 | memsetString (dial.address); |
| 1280 | #endif |
| 1281 | |
| 1282 | free (dial.address); |
| 1283 | |
| 1284 | #ifdef MEMSET_FREED |
| 1285 | memset(&uusInfo, 0, sizeof(RIL_UUS_Info)); |
| 1286 | memset(&dial, 0, sizeof(dial)); |
| 1287 | #endif |
| 1288 | |
| 1289 | return; |
| 1290 | invalid: |
| 1291 | invalidCommandBlock(pRI); |
| 1292 | return; |
| 1293 | } |
| 1294 | |
| 1295 | /** |
| 1296 | * Callee expects const RIL_SIM_IO * |
| 1297 | * Payload is: |
| 1298 | * int32_t command |
| 1299 | * int32_t fileid |
| 1300 | * String path |
| 1301 | * int32_t p1, p2, p3 |
| 1302 | * String data |
| 1303 | * String pin2 |
| 1304 | * String aidPtr |
| 1305 | */ |
| 1306 | static void |
| 1307 | dispatchSIM_IO (Parcel &p, RequestInfo *pRI) { |
| 1308 | union RIL_SIM_IO { |
| 1309 | RIL_SIM_IO_v6 v6; |
| 1310 | RIL_SIM_IO_v5 v5; |
| 1311 | } simIO; |
| 1312 | |
| 1313 | int32_t t = 0; |
| 1314 | int size; |
| 1315 | status_t status; |
| 1316 | |
| 1317 | #if VDBG |
| 1318 | RLOGD("dispatchSIM_IO"); |
| 1319 | #endif |
| 1320 | memset (&simIO, 0, sizeof(simIO)); |
| 1321 | |
| 1322 | // note we only check status at the end |
| 1323 | |
| 1324 | status = p.readInt32(&t); |
| 1325 | simIO.v6.command = (int)t; |
| 1326 | |
| 1327 | status = p.readInt32(&t); |
| 1328 | simIO.v6.fileid = (int)t; |
| 1329 | |
| 1330 | simIO.v6.path = strdupReadString(p); |
| 1331 | |
| 1332 | status = p.readInt32(&t); |
| 1333 | simIO.v6.p1 = (int)t; |
| 1334 | |
| 1335 | status = p.readInt32(&t); |
| 1336 | simIO.v6.p2 = (int)t; |
| 1337 | |
| 1338 | status = p.readInt32(&t); |
| 1339 | simIO.v6.p3 = (int)t; |
| 1340 | |
| 1341 | simIO.v6.data = strdupReadString(p); |
| 1342 | simIO.v6.pin2 = strdupReadString(p); |
| 1343 | simIO.v6.aidPtr = strdupReadString(p); |
| 1344 | |
| 1345 | startRequest; |
| 1346 | appendPrintBuf("%scmd=0x%X,efid=0x%X,path=%s,%d,%d,%d,%s,pin2=%s,aid=%s", printBuf, |
| 1347 | simIO.v6.command, simIO.v6.fileid, (char*)simIO.v6.path, |
| 1348 | simIO.v6.p1, simIO.v6.p2, simIO.v6.p3, |
| 1349 | (char*)simIO.v6.data, (char*)simIO.v6.pin2, simIO.v6.aidPtr); |
| 1350 | closeRequest; |
| 1351 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 1352 | |
| 1353 | if (status != NO_ERROR) { |
| 1354 | goto invalid; |
| 1355 | } |
| 1356 | |
| 1357 | size = (s_callbacks.version < 6) ? sizeof(simIO.v5) : sizeof(simIO.v6); |
| 1358 | CALL_ONREQUEST(pRI->pCI->requestNumber, &simIO, size, pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 1359 | |
| 1360 | #ifdef MEMSET_FREED |
| 1361 | memsetString (simIO.v6.path); |
| 1362 | memsetString (simIO.v6.data); |
| 1363 | memsetString (simIO.v6.pin2); |
| 1364 | memsetString (simIO.v6.aidPtr); |
| 1365 | #endif |
| 1366 | |
| 1367 | free (simIO.v6.path); |
| 1368 | free (simIO.v6.data); |
| 1369 | free (simIO.v6.pin2); |
| 1370 | free (simIO.v6.aidPtr); |
| 1371 | |
| 1372 | #ifdef MEMSET_FREED |
| 1373 | memset(&simIO, 0, sizeof(simIO)); |
| 1374 | #endif |
| 1375 | |
| 1376 | return; |
| 1377 | invalid: |
| 1378 | invalidCommandBlock(pRI); |
| 1379 | return; |
| 1380 | } |
| 1381 | |
| 1382 | /** |
| 1383 | * Callee expects const RIL_SIM_APDU * |
| 1384 | * Payload is: |
| 1385 | * int32_t sessionid |
| 1386 | * int32_t cla |
| 1387 | * int32_t instruction |
| 1388 | * int32_t p1, p2, p3 |
| 1389 | * String data |
| 1390 | */ |
| 1391 | static void |
| 1392 | dispatchSIM_APDU (Parcel &p, RequestInfo *pRI) { |
| 1393 | int32_t t = 0; |
| 1394 | status_t status; |
| 1395 | RIL_SIM_APDU apdu; |
| 1396 | |
| 1397 | #if VDBG |
| 1398 | RLOGD("dispatchSIM_APDU"); |
| 1399 | #endif |
| 1400 | memset (&apdu, 0, sizeof(RIL_SIM_APDU)); |
| 1401 | |
| 1402 | // Note we only check status at the end. Any single failure leads to |
| 1403 | // subsequent reads filing. |
| 1404 | status = p.readInt32(&t); |
| 1405 | apdu.sessionid = (int)t; |
| 1406 | |
| 1407 | status = p.readInt32(&t); |
| 1408 | apdu.cla = (int)t; |
| 1409 | |
| 1410 | status = p.readInt32(&t); |
| 1411 | apdu.instruction = (int)t; |
| 1412 | |
| 1413 | status = p.readInt32(&t); |
| 1414 | apdu.p1 = (int)t; |
| 1415 | |
| 1416 | status = p.readInt32(&t); |
| 1417 | apdu.p2 = (int)t; |
| 1418 | |
| 1419 | status = p.readInt32(&t); |
| 1420 | apdu.p3 = (int)t; |
| 1421 | |
| 1422 | apdu.data = strdupReadString(p); |
| 1423 | |
| 1424 | startRequest; |
| 1425 | appendPrintBuf("%ssessionid=%d,cla=%d,ins=%d,p1=%d,p2=%d,p3=%d,data=%s", |
| 1426 | printBuf, apdu.sessionid, apdu.cla, apdu.instruction, apdu.p1, apdu.p2, |
| 1427 | apdu.p3, (char*)apdu.data); |
| 1428 | closeRequest; |
| 1429 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 1430 | |
| 1431 | if (status != NO_ERROR) { |
| 1432 | goto invalid; |
| 1433 | } |
| 1434 | |
| 1435 | CALL_ONREQUEST(pRI->pCI->requestNumber, &apdu, sizeof(RIL_SIM_APDU), pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 1436 | |
| 1437 | #ifdef MEMSET_FREED |
| 1438 | memsetString(apdu.data); |
| 1439 | #endif |
| 1440 | free(apdu.data); |
| 1441 | |
| 1442 | #ifdef MEMSET_FREED |
| 1443 | memset(&apdu, 0, sizeof(RIL_SIM_APDU)); |
| 1444 | #endif |
| 1445 | |
| 1446 | return; |
| 1447 | invalid: |
| 1448 | invalidCommandBlock(pRI); |
| 1449 | return; |
| 1450 | } |
| 1451 | |
| 1452 | |
| 1453 | /** |
| 1454 | * Callee expects const RIL_CallForwardInfo * |
| 1455 | * Payload is: |
| 1456 | * int32_t status/action |
| 1457 | * int32_t reason |
| 1458 | * int32_t serviceCode |
| 1459 | * int32_t toa |
| 1460 | * String number (0 length -> null) |
| 1461 | * int32_t timeSeconds |
| 1462 | */ |
| 1463 | static void |
| 1464 | dispatchCallForward(Parcel &p, RequestInfo *pRI) { |
| 1465 | RIL_CallForwardInfo cff; |
| 1466 | int32_t t = 0; |
| 1467 | status_t status; |
| 1468 | |
| 1469 | RLOGD("dispatchCallForward"); |
| 1470 | memset (&cff, 0, sizeof(cff)); |
| 1471 | |
| 1472 | // note we only check status at the end |
| 1473 | |
| 1474 | status = p.readInt32(&t); |
| 1475 | cff.status = (int)t; |
| 1476 | |
| 1477 | status = p.readInt32(&t); |
| 1478 | cff.reason = (int)t; |
| 1479 | |
| 1480 | status = p.readInt32(&t); |
| 1481 | cff.serviceClass = (int)t; |
| 1482 | |
| 1483 | status = p.readInt32(&t); |
| 1484 | cff.toa = (int)t; |
| 1485 | |
| 1486 | cff.number = strdupReadString(p); |
| 1487 | |
| 1488 | status = p.readInt32(&t); |
| 1489 | cff.timeSeconds = (int)t; |
| 1490 | |
| 1491 | if (status != NO_ERROR) { |
| 1492 | goto invalid; |
| 1493 | } |
| 1494 | |
| 1495 | // special case: number 0-length fields is null |
| 1496 | |
| 1497 | if (cff.number != NULL && strlen (cff.number) == 0) { |
| 1498 | cff.number = NULL; |
| 1499 | } |
| 1500 | |
| 1501 | startRequest; |
| 1502 | appendPrintBuf("%sstat=%d,reason=%d,serv=%d,toa=%d,%s,tout=%d", printBuf, |
| 1503 | cff.status, cff.reason, cff.serviceClass, cff.toa, |
| 1504 | (char*)cff.number, cff.timeSeconds); |
| 1505 | closeRequest; |
| 1506 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 1507 | |
| 1508 | CALL_ONREQUEST(pRI->pCI->requestNumber, &cff, sizeof(cff), pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 1509 | |
| 1510 | #ifdef MEMSET_FREED |
| 1511 | memsetString(cff.number); |
| 1512 | #endif |
| 1513 | |
| 1514 | free (cff.number); |
| 1515 | |
| 1516 | #ifdef MEMSET_FREED |
| 1517 | memset(&cff, 0, sizeof(cff)); |
| 1518 | #endif |
| 1519 | |
| 1520 | return; |
| 1521 | invalid: |
| 1522 | invalidCommandBlock(pRI); |
| 1523 | return; |
| 1524 | } |
| 1525 | |
| 1526 | /** |
| 1527 | * Callee expects const RIL_CallForwardInfoEx * |
| 1528 | * Payload is: |
| 1529 | * int32_t status/action |
| 1530 | * int32_t reason |
| 1531 | * int32_t serviceCode |
| 1532 | * int32_t toa |
| 1533 | * String number (0 length -> null) |
| 1534 | * int32_t timeSeconds |
| 1535 | * String timeSlotBegin (0 length -> null) |
| 1536 | * String timeSlotEnd (0 length -> null) |
| 1537 | */ |
| 1538 | static void |
| 1539 | dispatchCallForwardEx(Parcel &p, RequestInfo *pRI) { |
| 1540 | RIL_CallForwardInfoEx cff; |
| 1541 | int32_t t = 0; |
| 1542 | status_t status; |
| 1543 | |
| 1544 | RLOGD("dispatchCallForwardEx"); |
| 1545 | memset (&cff, 0, sizeof(cff)); |
| 1546 | |
| 1547 | // note we only check status at the end |
| 1548 | |
| 1549 | status = p.readInt32(&t); |
| 1550 | cff.status = (int)t; |
| 1551 | |
| 1552 | status = p.readInt32(&t); |
| 1553 | cff.reason = (int)t; |
| 1554 | |
| 1555 | status = p.readInt32(&t); |
| 1556 | cff.serviceClass = (int)t; |
| 1557 | |
| 1558 | status = p.readInt32(&t); |
| 1559 | cff.toa = (int)t; |
| 1560 | |
| 1561 | cff.number = strdupReadString(p); |
| 1562 | |
| 1563 | status = p.readInt32(&t); |
| 1564 | cff.timeSeconds = (int)t; |
| 1565 | |
| 1566 | cff.timeSlotBegin = strdupReadString(p); |
| 1567 | cff.timeSlotEnd = strdupReadString(p); |
| 1568 | |
| 1569 | if (status != NO_ERROR) { |
| 1570 | goto invalid; |
| 1571 | } |
| 1572 | |
| 1573 | // special case: number 0-length fields is null |
| 1574 | |
| 1575 | if (cff.number != NULL && strlen (cff.number) == 0) { |
| 1576 | cff.number = NULL; |
| 1577 | } |
| 1578 | |
| 1579 | if (cff.timeSlotBegin != NULL && strlen (cff.timeSlotBegin) == 0) { |
| 1580 | cff.timeSlotBegin = NULL; |
| 1581 | } |
| 1582 | if (cff.timeSlotEnd != NULL && strlen (cff.timeSlotEnd) == 0) { |
| 1583 | cff.timeSlotEnd = NULL; |
| 1584 | } |
| 1585 | |
| 1586 | startRequest; |
| 1587 | appendPrintBuf("%sstat=%d,reason=%d,serv=%d,toa=%d,%s,tout=%d,timeSlot=%s,%s", printBuf, |
| 1588 | cff.status, cff.reason, cff.serviceClass, cff.toa, |
| 1589 | (char*)cff.number, cff.timeSeconds, cff.timeSlotBegin, cff.timeSlotEnd); |
| 1590 | closeRequest; |
| 1591 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 1592 | |
| 1593 | CALL_ONREQUEST(pRI->pCI->requestNumber, &cff, sizeof(cff), pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 1594 | |
| 1595 | #ifdef MEMSET_FREED |
| 1596 | memsetString(cff.number); |
| 1597 | memsetString(cff.timeSlotBegin); |
| 1598 | memsetString(cff.timeSlotEnd); |
| 1599 | #endif |
| 1600 | |
| 1601 | free (cff.number); |
| 1602 | free (cff.timeSlotBegin); |
| 1603 | free (cff.timeSlotEnd); |
| 1604 | |
| 1605 | #ifdef MEMSET_FREED |
| 1606 | memset(&cff, 0, sizeof(cff)); |
| 1607 | #endif |
| 1608 | |
| 1609 | return; |
| 1610 | invalid: |
| 1611 | invalidCommandBlock(pRI); |
| 1612 | return; |
| 1613 | } |
| 1614 | |
| 1615 | static void |
| 1616 | dispatchRaw(Parcel &p, RequestInfo *pRI) { |
| 1617 | int32_t len; |
| 1618 | status_t status; |
| 1619 | const void *data; |
| 1620 | |
| 1621 | status = p.readInt32(&len); |
| 1622 | |
| 1623 | if (status != NO_ERROR) { |
| 1624 | goto invalid; |
| 1625 | } |
| 1626 | |
| 1627 | // The java code writes -1 for null arrays |
| 1628 | if (((int)len) == -1) { |
| 1629 | data = NULL; |
| 1630 | len = 0; |
| 1631 | } |
| 1632 | |
| 1633 | data = p.readInplace(len); |
| 1634 | |
| 1635 | startRequest; |
| 1636 | appendPrintBuf("%sraw_size=%d", printBuf, len); |
| 1637 | closeRequest; |
| 1638 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 1639 | |
| 1640 | CALL_ONREQUEST(pRI->pCI->requestNumber, const_cast<void *>(data), len, pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 1641 | |
| 1642 | return; |
| 1643 | invalid: |
| 1644 | invalidCommandBlock(pRI); |
| 1645 | return; |
| 1646 | } |
| 1647 | |
| 1648 | static status_t |
| 1649 | constructCdmaSms(Parcel &p, RequestInfo *pRI, RIL_CDMA_SMS_Message& rcsm) { |
| 1650 | int32_t t = 0; |
| 1651 | uint8_t ut = 0; |
| 1652 | status_t status; |
| 1653 | int32_t digitCount; |
| 1654 | int digitLimit; |
| 1655 | |
| 1656 | memset(&rcsm, 0, sizeof(rcsm)); |
| 1657 | |
| 1658 | status = p.readInt32(&t); |
| 1659 | rcsm.uTeleserviceID = (int) t; |
| 1660 | |
| 1661 | status = p.read(&ut,sizeof(ut)); |
| 1662 | rcsm.bIsServicePresent = (uint8_t) ut; |
| 1663 | |
| 1664 | status = p.readInt32(&t); |
| 1665 | rcsm.uServicecategory = (int) t; |
| 1666 | |
| 1667 | status = p.readInt32(&t); |
| 1668 | rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) t; |
| 1669 | |
| 1670 | status = p.readInt32(&t); |
| 1671 | rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) t; |
| 1672 | |
| 1673 | status = p.readInt32(&t); |
| 1674 | rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) t; |
| 1675 | |
| 1676 | status = p.readInt32(&t); |
| 1677 | rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) t; |
| 1678 | |
| 1679 | status = p.read(&ut,sizeof(ut)); |
| 1680 | rcsm.sAddress.number_of_digits= (uint8_t) ut; |
| 1681 | |
| 1682 | digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX); |
| 1683 | for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { |
| 1684 | status = p.read(&ut,sizeof(ut)); |
| 1685 | rcsm.sAddress.digits[digitCount] = (uint8_t) ut; |
| 1686 | } |
| 1687 | |
| 1688 | status = p.readInt32(&t); |
| 1689 | rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) t; |
| 1690 | |
| 1691 | status = p.read(&ut,sizeof(ut)); |
| 1692 | rcsm.sSubAddress.odd = (uint8_t) ut; |
| 1693 | |
| 1694 | status = p.read(&ut,sizeof(ut)); |
| 1695 | rcsm.sSubAddress.number_of_digits = (uint8_t) ut; |
| 1696 | |
| 1697 | digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX); |
| 1698 | for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { |
| 1699 | status = p.read(&ut,sizeof(ut)); |
| 1700 | rcsm.sSubAddress.digits[digitCount] = (uint8_t) ut; |
| 1701 | } |
| 1702 | |
| 1703 | status = p.readInt32(&t); |
| 1704 | rcsm.uBearerDataLen = (int) t; |
| 1705 | |
| 1706 | digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX); |
| 1707 | for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { |
| 1708 | status = p.read(&ut, sizeof(ut)); |
| 1709 | rcsm.aBearerData[digitCount] = (uint8_t) ut; |
| 1710 | } |
| 1711 | |
| 1712 | if (status != NO_ERROR) { |
| 1713 | return status; |
| 1714 | } |
| 1715 | |
| 1716 | startRequest; |
| 1717 | appendPrintBuf("%suTeleserviceID=%d, bIsServicePresent=%d, uServicecategory=%d, \ |
| 1718 | sAddress.digit_mode=%d, sAddress.Number_mode=%d, sAddress.number_type=%d, ", |
| 1719 | printBuf, rcsm.uTeleserviceID,rcsm.bIsServicePresent,rcsm.uServicecategory, |
| 1720 | rcsm.sAddress.digit_mode, rcsm.sAddress.number_mode,rcsm.sAddress.number_type); |
| 1721 | closeRequest; |
| 1722 | |
| 1723 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 1724 | |
| 1725 | return status; |
| 1726 | } |
| 1727 | |
| 1728 | static void |
| 1729 | dispatchCdmaSms(Parcel &p, RequestInfo *pRI) { |
| 1730 | RIL_CDMA_SMS_Message rcsm; |
| 1731 | |
| 1732 | RLOGD("dispatchCdmaSms"); |
| 1733 | if (NO_ERROR != constructCdmaSms(p, pRI, rcsm)) { |
| 1734 | goto invalid; |
| 1735 | } |
| 1736 | |
| 1737 | CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm),pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 1738 | |
| 1739 | #ifdef MEMSET_FREED |
| 1740 | memset(&rcsm, 0, sizeof(rcsm)); |
| 1741 | #endif |
| 1742 | |
| 1743 | return; |
| 1744 | |
| 1745 | invalid: |
| 1746 | invalidCommandBlock(pRI); |
| 1747 | return; |
| 1748 | } |
| 1749 | |
| 1750 | static void |
| 1751 | dispatchImsCdmaSms(Parcel &p, RequestInfo *pRI, uint8_t retry, int32_t messageRef) { |
| 1752 | RIL_IMS_SMS_Message rism; |
| 1753 | RIL_CDMA_SMS_Message rcsm; |
| 1754 | |
| 1755 | RLOGD("dispatchImsCdmaSms: retry=%d, messageRef=%d", retry, messageRef); |
| 1756 | |
| 1757 | if (NO_ERROR != constructCdmaSms(p, pRI, rcsm)) { |
| 1758 | goto invalid; |
| 1759 | } |
| 1760 | memset(&rism, 0, sizeof(rism)); |
| 1761 | rism.tech = RADIO_TECH_3GPP2; |
| 1762 | rism.retry = retry; |
| 1763 | rism.messageRef = messageRef; |
| 1764 | rism.message.cdmaMessage = &rcsm; |
| 1765 | |
| 1766 | CALL_ONREQUEST(pRI->pCI->requestNumber, &rism, |
| 1767 | sizeof(RIL_RadioTechnologyFamily)+sizeof(uint8_t)+sizeof(int32_t) |
| 1768 | +sizeof(rcsm),pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 1769 | |
| 1770 | #ifdef MEMSET_FREED |
| 1771 | memset(&rcsm, 0, sizeof(rcsm)); |
| 1772 | memset(&rism, 0, sizeof(rism)); |
| 1773 | #endif |
| 1774 | |
| 1775 | return; |
| 1776 | |
| 1777 | invalid: |
| 1778 | invalidCommandBlock(pRI); |
| 1779 | return; |
| 1780 | } |
| 1781 | |
| 1782 | static void |
| 1783 | dispatchImsGsmSms(Parcel &p, RequestInfo *pRI, uint8_t retry, int32_t messageRef) { |
| 1784 | RIL_IMS_SMS_Message rism; |
| 1785 | int32_t countStrings; |
| 1786 | status_t status; |
| 1787 | size_t datalen; |
| 1788 | char **pStrings; |
| 1789 | RLOGD("dispatchImsGsmSms: retry=%d, messageRef=%d", retry, messageRef); |
| 1790 | |
| 1791 | status = p.readInt32 (&countStrings); |
| 1792 | |
| 1793 | if (status != NO_ERROR) { |
| 1794 | goto invalid; |
| 1795 | } |
| 1796 | |
| 1797 | memset(&rism, 0, sizeof(rism)); |
| 1798 | rism.tech = RADIO_TECH_3GPP; |
| 1799 | rism.retry = retry; |
| 1800 | rism.messageRef = messageRef; |
| 1801 | |
| 1802 | startRequest; |
| 1803 | appendPrintBuf("%stech=%d, retry=%d, messageRef=%d, ", printBuf, |
| 1804 | (int)rism.tech, (int)rism.retry, rism.messageRef); |
| 1805 | if (countStrings == 0) { |
| 1806 | // just some non-null pointer |
| 1807 | pStrings = (char **)calloc(1, sizeof(char *)); |
| 1808 | if (pStrings == NULL) { |
| 1809 | RLOGE("Memory allocation failed for request %s", |
| 1810 | requestToString(pRI->pCI->requestNumber)); |
| 1811 | closeRequest; |
| 1812 | return; |
| 1813 | } |
| 1814 | |
| 1815 | datalen = 0; |
| 1816 | } else if (countStrings < 0) { |
| 1817 | pStrings = NULL; |
| 1818 | datalen = 0; |
| 1819 | } else { |
| 1820 | if ((size_t)countStrings > (INT_MAX/sizeof(char *))) { |
| 1821 | RLOGE("Invalid value of countStrings: \n"); |
| 1822 | closeRequest; |
| 1823 | return; |
| 1824 | } |
| 1825 | datalen = sizeof(char *) * countStrings; |
| 1826 | |
| 1827 | pStrings = (char **)calloc(countStrings, sizeof(char *)); |
| 1828 | if (pStrings == NULL) { |
| 1829 | RLOGE("Memory allocation failed for request %s", |
| 1830 | requestToString(pRI->pCI->requestNumber)); |
| 1831 | closeRequest; |
| 1832 | return; |
| 1833 | } |
| 1834 | |
| 1835 | for (int i = 0 ; i < countStrings ; i++) { |
| 1836 | pStrings[i] = strdupReadString(p); |
| 1837 | appendPrintBuf("%s%s,", printBuf, pStrings[i]); |
| 1838 | } |
| 1839 | RLOGE("ImsGsmSms smsc %s, pdu %s", ((pStrings[0] != NULL)? pStrings[0] : "null"), |
| 1840 | ((pStrings[1] != NULL)? pStrings[1] : "null")); |
| 1841 | } |
| 1842 | removeLastChar; |
| 1843 | closeRequest; |
| 1844 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 1845 | |
| 1846 | rism.message.gsmMessage = pStrings; |
| 1847 | CALL_ONREQUEST(pRI->pCI->requestNumber, &rism, |
| 1848 | sizeof(RIL_RadioTechnologyFamily)+sizeof(uint8_t)+sizeof(int32_t) |
| 1849 | +datalen, pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 1850 | |
| 1851 | if (pStrings != NULL) { |
| 1852 | for (int i = 0 ; i < countStrings ; i++) { |
| 1853 | #ifdef MEMSET_FREED |
| 1854 | memsetString (pStrings[i]); |
| 1855 | #endif |
| 1856 | free(pStrings[i]); |
| 1857 | } |
| 1858 | |
| 1859 | #ifdef MEMSET_FREED |
| 1860 | memset(pStrings, 0, datalen); |
| 1861 | #endif |
| 1862 | free(pStrings); |
| 1863 | } |
| 1864 | |
| 1865 | #ifdef MEMSET_FREED |
| 1866 | memset(&rism, 0, sizeof(rism)); |
| 1867 | #endif |
| 1868 | return; |
| 1869 | invalid: |
| 1870 | ALOGE("dispatchImsGsmSms invalid block"); |
| 1871 | invalidCommandBlock(pRI); |
| 1872 | return; |
| 1873 | } |
| 1874 | |
| 1875 | static void |
| 1876 | dispatchImsSms(Parcel &p, RequestInfo *pRI) { |
| 1877 | int32_t t; |
| 1878 | status_t status = p.readInt32(&t); |
| 1879 | RIL_RadioTechnologyFamily format; |
| 1880 | uint8_t retry; |
| 1881 | int32_t messageRef; |
| 1882 | |
| 1883 | RLOGD("dispatchImsSms"); |
| 1884 | if (status != NO_ERROR) { |
| 1885 | goto invalid; |
| 1886 | } |
| 1887 | format = (RIL_RadioTechnologyFamily) t; |
| 1888 | RLOGE("tech %d", t); |
| 1889 | |
| 1890 | // read retry field |
| 1891 | status = p.read(&retry,sizeof(retry)); |
| 1892 | if (status != NO_ERROR) { |
| 1893 | goto invalid; |
| 1894 | } |
| 1895 | RLOGE("retry %d", retry); |
| 1896 | |
| 1897 | // read messageRef field |
| 1898 | status = p.read(&messageRef,sizeof(messageRef)); |
| 1899 | if (status != NO_ERROR) { |
| 1900 | goto invalid; |
| 1901 | } |
| 1902 | RLOGE("messageRef %d", messageRef); |
| 1903 | |
| 1904 | if (RADIO_TECH_3GPP == format) { |
| 1905 | dispatchImsGsmSms(p, pRI, retry, messageRef); |
| 1906 | } else if (RADIO_TECH_3GPP2 == format) { |
| 1907 | dispatchImsCdmaSms(p, pRI, retry, messageRef); |
| 1908 | } else { |
| 1909 | ALOGE("requestImsSendSMS invalid format value =%d", format); |
| 1910 | } |
| 1911 | |
| 1912 | return; |
| 1913 | |
| 1914 | invalid: |
| 1915 | invalidCommandBlock(pRI); |
| 1916 | return; |
| 1917 | } |
| 1918 | |
| 1919 | static void |
| 1920 | dispatchCdmaSmsAck(Parcel &p, RequestInfo *pRI) { |
| 1921 | RIL_CDMA_SMS_Ack rcsa; |
| 1922 | int32_t t = 0; |
| 1923 | status_t status; |
| 1924 | int32_t digitCount; |
| 1925 | |
| 1926 | RLOGD("dispatchCdmaSmsAck"); |
| 1927 | memset(&rcsa, 0, sizeof(rcsa)); |
| 1928 | |
| 1929 | status = p.readInt32(&t); |
| 1930 | rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) t; |
| 1931 | |
| 1932 | status = p.readInt32(&t); |
| 1933 | rcsa.uSMSCauseCode = (int) t; |
| 1934 | |
| 1935 | if (status != NO_ERROR) { |
| 1936 | goto invalid; |
| 1937 | } |
| 1938 | |
| 1939 | startRequest; |
| 1940 | appendPrintBuf("%suErrorClass=%d, uTLStatus=%d, ", |
| 1941 | printBuf, rcsa.uErrorClass, rcsa.uSMSCauseCode); |
| 1942 | closeRequest; |
| 1943 | |
| 1944 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 1945 | |
| 1946 | CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa),pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 1947 | |
| 1948 | #ifdef MEMSET_FREED |
| 1949 | memset(&rcsa, 0, sizeof(rcsa)); |
| 1950 | #endif |
| 1951 | |
| 1952 | return; |
| 1953 | |
| 1954 | invalid: |
| 1955 | invalidCommandBlock(pRI); |
| 1956 | return; |
| 1957 | } |
| 1958 | |
| 1959 | static void |
| 1960 | dispatchGsmBrSmsCnf(Parcel &p, RequestInfo *pRI) { |
| 1961 | int32_t t; |
| 1962 | status_t status; |
| 1963 | int32_t num; |
| 1964 | |
| 1965 | status = p.readInt32(&num); |
| 1966 | if (status != NO_ERROR) { |
| 1967 | goto invalid; |
| 1968 | } |
| 1969 | |
| 1970 | { |
| 1971 | RIL_GSM_BroadcastSmsConfigInfo gsmBci[num]; |
| 1972 | RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num]; |
| 1973 | |
| 1974 | startRequest; |
| 1975 | for (int i = 0 ; i < num ; i++ ) { |
| 1976 | gsmBciPtrs[i] = &gsmBci[i]; |
| 1977 | |
| 1978 | status = p.readInt32(&t); |
| 1979 | gsmBci[i].fromServiceId = (int) t; |
| 1980 | |
| 1981 | status = p.readInt32(&t); |
| 1982 | gsmBci[i].toServiceId = (int) t; |
| 1983 | |
| 1984 | status = p.readInt32(&t); |
| 1985 | gsmBci[i].fromCodeScheme = (int) t; |
| 1986 | |
| 1987 | status = p.readInt32(&t); |
| 1988 | gsmBci[i].toCodeScheme = (int) t; |
| 1989 | |
| 1990 | status = p.readInt32(&t); |
| 1991 | gsmBci[i].selected = (uint8_t) t; |
| 1992 | |
| 1993 | appendPrintBuf("%s [%d: fromServiceId=%d, toServiceId =%d, \ |
| 1994 | fromCodeScheme=%d, toCodeScheme=%d, selected =%d]", printBuf, i, |
| 1995 | gsmBci[i].fromServiceId, gsmBci[i].toServiceId, |
| 1996 | gsmBci[i].fromCodeScheme, gsmBci[i].toCodeScheme, |
| 1997 | gsmBci[i].selected); |
| 1998 | } |
| 1999 | closeRequest; |
| 2000 | |
| 2001 | if (status != NO_ERROR) { |
| 2002 | goto invalid; |
| 2003 | } |
| 2004 | |
| 2005 | CALL_ONREQUEST(pRI->pCI->requestNumber, |
| 2006 | gsmBciPtrs, |
| 2007 | num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), |
| 2008 | pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 2009 | |
| 2010 | #ifdef MEMSET_FREED |
| 2011 | memset(gsmBci, 0, num * sizeof(RIL_GSM_BroadcastSmsConfigInfo)); |
| 2012 | memset(gsmBciPtrs, 0, num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *)); |
| 2013 | #endif |
| 2014 | } |
| 2015 | |
| 2016 | return; |
| 2017 | |
| 2018 | invalid: |
| 2019 | invalidCommandBlock(pRI); |
| 2020 | return; |
| 2021 | } |
| 2022 | |
| 2023 | static void |
| 2024 | dispatchCdmaBrSmsCnf(Parcel &p, RequestInfo *pRI) { |
| 2025 | int32_t t; |
| 2026 | status_t status; |
| 2027 | int32_t num; |
| 2028 | |
| 2029 | status = p.readInt32(&num); |
| 2030 | if (status != NO_ERROR) { |
| 2031 | goto invalid; |
| 2032 | } |
| 2033 | |
| 2034 | { |
| 2035 | RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num]; |
| 2036 | RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num]; |
| 2037 | |
| 2038 | startRequest; |
| 2039 | for (int i = 0 ; i < num ; i++ ) { |
| 2040 | cdmaBciPtrs[i] = &cdmaBci[i]; |
| 2041 | |
| 2042 | status = p.readInt32(&t); |
| 2043 | cdmaBci[i].service_category = (int) t; |
| 2044 | |
| 2045 | status = p.readInt32(&t); |
| 2046 | cdmaBci[i].language = (int) t; |
| 2047 | |
| 2048 | status = p.readInt32(&t); |
| 2049 | cdmaBci[i].selected = (uint8_t) t; |
| 2050 | |
| 2051 | appendPrintBuf("%s [%d: service_category=%d, language =%d, \ |
| 2052 | entries.bSelected =%d]", printBuf, i, cdmaBci[i].service_category, |
| 2053 | cdmaBci[i].language, cdmaBci[i].selected); |
| 2054 | } |
| 2055 | closeRequest; |
| 2056 | |
| 2057 | if (status != NO_ERROR) { |
| 2058 | goto invalid; |
| 2059 | } |
| 2060 | |
| 2061 | CALL_ONREQUEST(pRI->pCI->requestNumber, |
| 2062 | cdmaBciPtrs, |
| 2063 | num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), |
| 2064 | pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 2065 | |
| 2066 | #ifdef MEMSET_FREED |
| 2067 | memset(cdmaBci, 0, num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo)); |
| 2068 | memset(cdmaBciPtrs, 0, num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *)); |
| 2069 | #endif |
| 2070 | } |
| 2071 | |
| 2072 | return; |
| 2073 | |
| 2074 | invalid: |
| 2075 | invalidCommandBlock(pRI); |
| 2076 | return; |
| 2077 | } |
| 2078 | |
| 2079 | static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI) { |
| 2080 | RIL_CDMA_SMS_WriteArgs rcsw; |
| 2081 | int32_t t = 0; |
| 2082 | uint32_t ut = 0; |
| 2083 | uint8_t uct = 0; |
| 2084 | status_t status; |
| 2085 | int32_t digitCount; |
| 2086 | int32_t digitLimit; |
| 2087 | |
| 2088 | memset(&rcsw, 0, sizeof(rcsw)); |
| 2089 | |
| 2090 | status = p.readInt32(&t); |
| 2091 | rcsw.status = t; |
| 2092 | |
| 2093 | status = p.readInt32(&t); |
| 2094 | rcsw.message.uTeleserviceID = (int) t; |
| 2095 | |
| 2096 | status = p.read(&uct,sizeof(uct)); |
| 2097 | rcsw.message.bIsServicePresent = (uint8_t) uct; |
| 2098 | |
| 2099 | status = p.readInt32(&t); |
| 2100 | rcsw.message.uServicecategory = (int) t; |
| 2101 | |
| 2102 | status = p.readInt32(&t); |
| 2103 | rcsw.message.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) t; |
| 2104 | |
| 2105 | status = p.readInt32(&t); |
| 2106 | rcsw.message.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) t; |
| 2107 | |
| 2108 | status = p.readInt32(&t); |
| 2109 | rcsw.message.sAddress.number_type = (RIL_CDMA_SMS_NumberType) t; |
| 2110 | |
| 2111 | status = p.readInt32(&t); |
| 2112 | rcsw.message.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) t; |
| 2113 | |
| 2114 | status = p.read(&uct,sizeof(uct)); |
| 2115 | rcsw.message.sAddress.number_of_digits = (uint8_t) uct; |
| 2116 | |
| 2117 | digitLimit = MIN((rcsw.message.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX); |
| 2118 | |
| 2119 | for(digitCount = 0 ; digitCount < digitLimit; digitCount ++) { |
| 2120 | status = p.read(&uct,sizeof(uct)); |
| 2121 | rcsw.message.sAddress.digits[digitCount] = (uint8_t) uct; |
| 2122 | } |
| 2123 | |
| 2124 | status = p.readInt32(&t); |
| 2125 | rcsw.message.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) t; |
| 2126 | |
| 2127 | status = p.read(&uct,sizeof(uct)); |
| 2128 | rcsw.message.sSubAddress.odd = (uint8_t) uct; |
| 2129 | |
| 2130 | status = p.read(&uct,sizeof(uct)); |
| 2131 | rcsw.message.sSubAddress.number_of_digits = (uint8_t) uct; |
| 2132 | |
| 2133 | digitLimit = MIN((rcsw.message.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX); |
| 2134 | |
| 2135 | for(digitCount = 0 ; digitCount < digitLimit; digitCount ++) { |
| 2136 | status = p.read(&uct,sizeof(uct)); |
| 2137 | rcsw.message.sSubAddress.digits[digitCount] = (uint8_t) uct; |
| 2138 | } |
| 2139 | |
| 2140 | status = p.readInt32(&t); |
| 2141 | rcsw.message.uBearerDataLen = (int) t; |
| 2142 | |
| 2143 | digitLimit = MIN((rcsw.message.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX); |
| 2144 | |
| 2145 | for(digitCount = 0 ; digitCount < digitLimit; digitCount ++) { |
| 2146 | status = p.read(&uct, sizeof(uct)); |
| 2147 | rcsw.message.aBearerData[digitCount] = (uint8_t) uct; |
| 2148 | } |
| 2149 | |
| 2150 | if (status != NO_ERROR) { |
| 2151 | goto invalid; |
| 2152 | } |
| 2153 | |
| 2154 | startRequest; |
| 2155 | appendPrintBuf("%sstatus=%d, message.uTeleserviceID=%d, message.bIsServicePresent=%d, \ |
| 2156 | message.uServicecategory=%d, message.sAddress.digit_mode=%d, \ |
| 2157 | message.sAddress.number_mode=%d, \ |
| 2158 | message.sAddress.number_type=%d, ", |
| 2159 | printBuf, rcsw.status, rcsw.message.uTeleserviceID, rcsw.message.bIsServicePresent, |
| 2160 | rcsw.message.uServicecategory, rcsw.message.sAddress.digit_mode, |
| 2161 | rcsw.message.sAddress.number_mode, |
| 2162 | rcsw.message.sAddress.number_type); |
| 2163 | closeRequest; |
| 2164 | |
| 2165 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 2166 | |
| 2167 | CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw),pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 2168 | |
| 2169 | #ifdef MEMSET_FREED |
| 2170 | memset(&rcsw, 0, sizeof(rcsw)); |
| 2171 | #endif |
| 2172 | |
| 2173 | return; |
| 2174 | |
| 2175 | invalid: |
| 2176 | invalidCommandBlock(pRI); |
| 2177 | return; |
| 2178 | |
| 2179 | } |
| 2180 | |
| 2181 | // For backwards compatibility in RIL_REQUEST_SETUP_DATA_CALL. |
| 2182 | // Version 4 of the RIL interface adds a new PDP type parameter to support |
| 2183 | // IPv6 and dual-stack PDP contexts. When dealing with a previous version of |
| 2184 | // RIL, remove the parameter from the request. |
| 2185 | static void dispatchDataCall(Parcel& p, RequestInfo *pRI) { |
| 2186 | // In RIL v3, REQUEST_SETUP_DATA_CALL takes 6 parameters. |
| 2187 | const int numParamsRilV3 = 6; |
| 2188 | |
| 2189 | // The first bytes of the RIL parcel contain the request number and the |
| 2190 | // serial number - see processCommandBuffer(). Copy them over too. |
| 2191 | int pos = p.dataPosition(); |
| 2192 | |
| 2193 | int numParams = p.readInt32(); |
| 2194 | #if defined(__MTK_ANDROID__) |
| 2195 | if (s_callbacks.version < 4 && numParams > numParamsRilV3) { |
| 2196 | Parcel p2; |
| 2197 | p2.appendFrom(&p, 0, pos); |
| 2198 | p2.writeInt32(numParamsRilV3); |
| 2199 | for(int i = 0; i < numParamsRilV3; i++) { |
| 2200 | p2.writeString16(p.readString16()); |
| 2201 | } |
| 2202 | p2.setDataPosition(pos); |
| 2203 | dispatchStrings(p2, pRI); |
| 2204 | } else { |
| 2205 | p.setDataPosition(pos); |
| 2206 | dispatchStrings(p, pRI); |
| 2207 | } |
| 2208 | #else |
| 2209 | p.setDataPosition(pos); |
| 2210 | dispatchStrings(p, pRI); |
| 2211 | #endif |
| 2212 | } |
| 2213 | |
| 2214 | |
| 2215 | static void dispatchSetInitialAttachApn(Parcel &p, RequestInfo *pRI) |
| 2216 | { |
| 2217 | RIL_InitialAttachApn_v15 pf; |
| 2218 | char *roamingProtocol; |
| 2219 | int32_t t = 0; |
| 2220 | status_t status; |
| 2221 | |
| 2222 | memset(&pf, 0, sizeof(pf)); |
| 2223 | |
| 2224 | pf.apn = strdupReadString(p); |
| 2225 | pf.protocol = strdupReadString(p); |
| 2226 | |
| 2227 | // compatible for lagecy chip implementation in ril java |
| 2228 | //roamingProtocol= strdupReadString(p); |
| 2229 | |
| 2230 | status = p.readInt32(&t); |
| 2231 | pf.authtype = (int) t; |
| 2232 | |
| 2233 | pf.username = strdupReadString(p); |
| 2234 | pf.password = strdupReadString(p); |
| 2235 | |
| 2236 | startRequest; |
| 2237 | appendPrintBuf("%sapn=%s, protocol=%s, authtype=%d, username=%s, password=%s", |
| 2238 | printBuf, pf.apn, pf.protocol, pf.authtype, pf.username, pf.password); |
| 2239 | closeRequest; |
| 2240 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 2241 | |
| 2242 | if (status != NO_ERROR) { |
| 2243 | goto invalid; |
| 2244 | } |
| 2245 | CALL_ONREQUEST(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 2246 | |
| 2247 | #ifdef MEMSET_FREED |
| 2248 | memsetString(pf.apn); |
| 2249 | memsetString(pf.protocol); |
| 2250 | memsetString(pf.username); |
| 2251 | memsetString(pf.password); |
| 2252 | #endif |
| 2253 | |
| 2254 | free(pf.apn); |
| 2255 | free(pf.protocol); |
| 2256 | free(pf.username); |
| 2257 | free(pf.password); |
| 2258 | |
| 2259 | // compatible for lagecy chip implementation in ril java |
| 2260 | //free(roamingProtocol); |
| 2261 | |
| 2262 | #ifdef MEMSET_FREED |
| 2263 | memset(&pf, 0, sizeof(pf)); |
| 2264 | #endif |
| 2265 | |
| 2266 | return; |
| 2267 | invalid: |
| 2268 | invalidCommandBlock(pRI); |
| 2269 | return; |
| 2270 | } |
| 2271 | |
| 2272 | static void dispatchNVReadItem(Parcel &p, RequestInfo *pRI) { |
| 2273 | RIL_NV_ReadItem nvri; |
| 2274 | int32_t t = 0; |
| 2275 | status_t status; |
| 2276 | |
| 2277 | memset(&nvri, 0, sizeof(nvri)); |
| 2278 | |
| 2279 | status = p.readInt32(&t); |
| 2280 | nvri.itemID = (RIL_NV_Item) t; |
| 2281 | |
| 2282 | if (status != NO_ERROR) { |
| 2283 | goto invalid; |
| 2284 | } |
| 2285 | |
| 2286 | startRequest; |
| 2287 | appendPrintBuf("%snvri.itemID=%d, ", printBuf, nvri.itemID); |
| 2288 | closeRequest; |
| 2289 | |
| 2290 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 2291 | |
| 2292 | CALL_ONREQUEST(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 2293 | |
| 2294 | #ifdef MEMSET_FREED |
| 2295 | memset(&nvri, 0, sizeof(nvri)); |
| 2296 | #endif |
| 2297 | |
| 2298 | return; |
| 2299 | |
| 2300 | invalid: |
| 2301 | invalidCommandBlock(pRI); |
| 2302 | return; |
| 2303 | } |
| 2304 | |
| 2305 | static void dispatchNVWriteItem(Parcel &p, RequestInfo *pRI) { |
| 2306 | RIL_NV_WriteItem nvwi; |
| 2307 | int32_t t = 0; |
| 2308 | status_t status; |
| 2309 | |
| 2310 | memset(&nvwi, 0, sizeof(nvwi)); |
| 2311 | |
| 2312 | status = p.readInt32(&t); |
| 2313 | nvwi.itemID = (RIL_NV_Item) t; |
| 2314 | |
| 2315 | nvwi.value = strdupReadString(p); |
| 2316 | |
| 2317 | if (status != NO_ERROR || nvwi.value == NULL) { |
| 2318 | goto invalid; |
| 2319 | } |
| 2320 | |
| 2321 | startRequest; |
| 2322 | appendPrintBuf("%snvwi.itemID=%d, value=%s, ", printBuf, nvwi.itemID, |
| 2323 | nvwi.value); |
| 2324 | closeRequest; |
| 2325 | |
| 2326 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 2327 | |
| 2328 | CALL_ONREQUEST(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 2329 | |
| 2330 | #ifdef MEMSET_FREED |
| 2331 | memsetString(nvwi.value); |
| 2332 | #endif |
| 2333 | |
| 2334 | free(nvwi.value); |
| 2335 | |
| 2336 | #ifdef MEMSET_FREED |
| 2337 | memset(&nvwi, 0, sizeof(nvwi)); |
| 2338 | #endif |
| 2339 | |
| 2340 | return; |
| 2341 | |
| 2342 | invalid: |
| 2343 | invalidCommandBlock(pRI); |
| 2344 | return; |
| 2345 | } |
| 2346 | |
| 2347 | |
| 2348 | static void dispatchUiccSubscripton(Parcel &p, RequestInfo *pRI) { |
| 2349 | RIL_SelectUiccSub uicc_sub; |
| 2350 | status_t status; |
| 2351 | int32_t t; |
| 2352 | memset(&uicc_sub, 0, sizeof(uicc_sub)); |
| 2353 | |
| 2354 | status = p.readInt32(&t); |
| 2355 | if (status != NO_ERROR) { |
| 2356 | goto invalid; |
| 2357 | } |
| 2358 | uicc_sub.slot = (int) t; |
| 2359 | |
| 2360 | status = p.readInt32(&t); |
| 2361 | if (status != NO_ERROR) { |
| 2362 | goto invalid; |
| 2363 | } |
| 2364 | uicc_sub.app_index = (int) t; |
| 2365 | |
| 2366 | status = p.readInt32(&t); |
| 2367 | if (status != NO_ERROR) { |
| 2368 | goto invalid; |
| 2369 | } |
| 2370 | uicc_sub.sub_type = (RIL_SubscriptionType) t; |
| 2371 | |
| 2372 | status = p.readInt32(&t); |
| 2373 | if (status != NO_ERROR) { |
| 2374 | goto invalid; |
| 2375 | } |
| 2376 | uicc_sub.act_status = (RIL_UiccSubActStatus) t; |
| 2377 | |
| 2378 | startRequest; |
| 2379 | appendPrintBuf("slot=%d, app_index=%d, act_status = %d", uicc_sub.slot, uicc_sub.app_index, |
| 2380 | uicc_sub.act_status); |
| 2381 | RLOGD("dispatchUiccSubscription, slot=%d, app_index=%d, act_status = %d", uicc_sub.slot, |
| 2382 | uicc_sub.app_index, uicc_sub.act_status); |
| 2383 | closeRequest; |
| 2384 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 2385 | |
| 2386 | CALL_ONREQUEST(pRI->pCI->requestNumber, &uicc_sub, sizeof(uicc_sub), pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 2387 | |
| 2388 | #ifdef MEMSET_FREED |
| 2389 | memset(&uicc_sub, 0, sizeof(uicc_sub)); |
| 2390 | #endif |
| 2391 | return; |
| 2392 | |
| 2393 | invalid: |
| 2394 | invalidCommandBlock(pRI); |
| 2395 | return; |
| 2396 | } |
| 2397 | |
| 2398 | static void dispatchSimAuthentication(Parcel &p, RequestInfo *pRI) |
| 2399 | { |
| 2400 | RIL_SimAuthentication pf; |
| 2401 | int32_t t = 0; |
| 2402 | status_t status; |
| 2403 | |
| 2404 | memset(&pf, 0, sizeof(pf)); |
| 2405 | |
| 2406 | status = p.readInt32(&t); |
| 2407 | pf.authContext = (int) t; |
| 2408 | pf.authData = strdupReadString(p); |
| 2409 | pf.aid = strdupReadString(p); |
| 2410 | |
| 2411 | startRequest; |
| 2412 | appendPrintBuf("authContext=%s, authData=%s, aid=%s", pf.authContext, pf.authData, pf.aid); |
| 2413 | closeRequest; |
| 2414 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 2415 | |
| 2416 | if (status != NO_ERROR) { |
| 2417 | goto invalid; |
| 2418 | } |
| 2419 | CALL_ONREQUEST(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 2420 | |
| 2421 | #ifdef MEMSET_FREED |
| 2422 | memsetString(pf.authData); |
| 2423 | memsetString(pf.aid); |
| 2424 | #endif |
| 2425 | |
| 2426 | free(pf.authData); |
| 2427 | free(pf.aid); |
| 2428 | |
| 2429 | #ifdef MEMSET_FREED |
| 2430 | memset(&pf, 0, sizeof(pf)); |
| 2431 | #endif |
| 2432 | |
| 2433 | return; |
| 2434 | invalid: |
| 2435 | invalidCommandBlock(pRI); |
| 2436 | return; |
| 2437 | } |
| 2438 | |
| 2439 | static void memsetAndFreeStrings(int numPointers, ...) { |
| 2440 | va_list ap; |
| 2441 | va_start(ap, numPointers); |
| 2442 | for (int i = 0; i < numPointers; i++) { |
| 2443 | char *ptr = va_arg(ap, char *); |
| 2444 | if (ptr) { |
| 2445 | #ifdef MEMSET_FREED |
| 2446 | #define MAX_STRING_LENGTH 4096 |
| 2447 | memset(ptr, 0, strnlen(ptr, MAX_STRING_LENGTH)); |
| 2448 | #endif |
| 2449 | free(ptr); |
| 2450 | } |
| 2451 | } |
| 2452 | va_end(ap); |
| 2453 | } |
| 2454 | |
| 2455 | template <typename T> |
| 2456 | static void freeSetDataProfileData(int numProfiles, T *dataProfiles, T **dataProfilePtrs, |
| 2457 | int numfields, ...) { |
| 2458 | va_list args; |
| 2459 | va_start(args, numfields); |
| 2460 | |
| 2461 | // Iterate through each string-type field that need to be free. |
| 2462 | for (int i = 0; i < numfields; i++) { |
| 2463 | // Iterate through each data profile and free that specific string-type field. |
| 2464 | // The type 'char *T::*' is a type of pointer to a 'char *' member inside T structure. |
| 2465 | char *T::*ptr = va_arg(args, char *T::*); |
| 2466 | for (int j = 0; j < numProfiles; j++) { |
| 2467 | memsetAndFreeStrings(1, dataProfiles[j].*ptr); |
| 2468 | } |
| 2469 | } |
| 2470 | |
| 2471 | va_end(args); |
| 2472 | |
| 2473 | #ifdef MEMSET_FREED |
| 2474 | memset(dataProfiles, 0, numProfiles * sizeof(T)); |
| 2475 | memset(dataProfilePtrs, 0, numProfiles * sizeof(T *)); |
| 2476 | #endif |
| 2477 | free(dataProfiles); |
| 2478 | free(dataProfilePtrs); |
| 2479 | } |
| 2480 | |
| 2481 | static void dispatchDataProfile(Parcel &p, RequestInfo *pRI) { |
| 2482 | int32_t t; |
| 2483 | status_t status; |
| 2484 | int32_t num = 0; |
| 2485 | |
| 2486 | status = p.readInt32(&num); |
| 2487 | if (status != NO_ERROR || num < 0) { |
| 2488 | RLOGE("dispatchDataProfile status = %d num = %d,%s ", |
| 2489 | status, num,requestToString(pRI->pCI->requestNumber)); |
| 2490 | goto invalid; |
| 2491 | } |
| 2492 | |
| 2493 | { |
| 2494 | RIL_MtkDataProfileInfo *dataProfiles = |
| 2495 | (RIL_MtkDataProfileInfo *)calloc(num, sizeof(RIL_MtkDataProfileInfo)); |
| 2496 | if (dataProfiles == NULL) { |
| 2497 | RLOGE("Memory allocation failed for request %s", |
| 2498 | requestToString(pRI->pCI->requestNumber)); |
| 2499 | return; |
| 2500 | } |
| 2501 | RIL_MtkDataProfileInfo **dataProfilePtrs = |
| 2502 | (RIL_MtkDataProfileInfo **)calloc(num, sizeof(RIL_MtkDataProfileInfo *)); |
| 2503 | if (dataProfilePtrs == NULL) { |
| 2504 | RLOGE("Memory allocation failed for request %s", |
| 2505 | requestToString(pRI->pCI->requestNumber)); |
| 2506 | free(dataProfiles); |
| 2507 | return; |
| 2508 | } |
| 2509 | |
| 2510 | startRequest; |
| 2511 | for (int i = 0 ; i < num ; i++ ) { |
| 2512 | dataProfilePtrs[i] = &dataProfiles[i]; |
| 2513 | |
| 2514 | status = p.readInt32(&t); |
| 2515 | dataProfiles[i].profileId = (int) t; |
| 2516 | |
| 2517 | dataProfiles[i].apn = strdupReadString(p); |
| 2518 | dataProfiles[i].protocol = strdupReadString(p); |
| 2519 | status = p.readInt32(&t); |
| 2520 | dataProfiles[i].authType = (int) t; |
| 2521 | |
| 2522 | dataProfiles[i].user = strdupReadString(p); |
| 2523 | dataProfiles[i].password = strdupReadString(p); |
| 2524 | |
| 2525 | status = p.readInt32(&t); |
| 2526 | dataProfiles[i].type = (int) t; |
| 2527 | |
| 2528 | status = p.readInt32(&t); |
| 2529 | dataProfiles[i].maxConnsTime = (int) t; |
| 2530 | status = p.readInt32(&t); |
| 2531 | dataProfiles[i].maxConns = (int) t; |
| 2532 | status = p.readInt32(&t); |
| 2533 | dataProfiles[i].waitTime = (int) t; |
| 2534 | |
| 2535 | status = p.readInt32(&t); |
| 2536 | dataProfiles[i].enabled = (int) t; |
| 2537 | |
| 2538 | status = p.readInt32(&t); |
| 2539 | dataProfiles[i].supportedTypesBitmask = (int) t; |
| 2540 | |
| 2541 | dataProfiles[i].roamingProtocol = strdupReadString(p); |
| 2542 | |
| 2543 | status = p.readInt32(&t); |
| 2544 | dataProfiles[i].bearerBitmask = (int) t; |
| 2545 | |
| 2546 | status = p.readInt32(&t); |
| 2547 | dataProfiles[i].mtu = (int) t; |
| 2548 | |
| 2549 | dataProfiles[i].mvnoType = strdupReadString(p); |
| 2550 | |
| 2551 | dataProfiles[i].mvnoMatchData = strdupReadString(p); |
| 2552 | |
| 2553 | // read modemCognitive |
| 2554 | status = p.readInt32(&t); |
| 2555 | |
| 2556 | appendPrintBuf("%s [%d: profileId=%d, apn =%s, protocol =%s, authType =%d, \ |
| 2557 | user =%s, password =%s, type =%d, maxConnsTime =%d, maxConns =%d, \ |
| 2558 | waitTime =%d, enabled =%d]", printBuf, i, dataProfiles[i].profileId, |
| 2559 | dataProfiles[i].apn, dataProfiles[i].protocol, dataProfiles[i].authType, |
| 2560 | dataProfiles[i].user, dataProfiles[i].password, dataProfiles[i].type, |
| 2561 | dataProfiles[i].maxConnsTime, dataProfiles[i].maxConns, |
| 2562 | dataProfiles[i].waitTime, dataProfiles[i].enabled); |
| 2563 | } |
| 2564 | closeRequest; |
| 2565 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 2566 | |
| 2567 | if (status != NO_ERROR) { |
| 2568 | freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 7, |
| 2569 | &RIL_MtkDataProfileInfo::apn, &RIL_MtkDataProfileInfo::protocol, |
| 2570 | &RIL_MtkDataProfileInfo::roamingProtocol, &RIL_MtkDataProfileInfo::user, |
| 2571 | &RIL_MtkDataProfileInfo::password, &RIL_MtkDataProfileInfo::mvnoType, |
| 2572 | &RIL_MtkDataProfileInfo::mvnoMatchData); |
| 2573 | goto invalid; |
| 2574 | } |
| 2575 | CALL_ONREQUEST(pRI->pCI->requestNumber, |
| 2576 | dataProfilePtrs, |
| 2577 | num * sizeof(RIL_MtkDataProfileInfo *), |
| 2578 | pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 2579 | |
| 2580 | freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 7, |
| 2581 | &RIL_MtkDataProfileInfo::apn, &RIL_MtkDataProfileInfo::protocol, |
| 2582 | &RIL_MtkDataProfileInfo::roamingProtocol, &RIL_MtkDataProfileInfo::user, |
| 2583 | &RIL_MtkDataProfileInfo::password, &RIL_MtkDataProfileInfo::mvnoType, |
| 2584 | &RIL_MtkDataProfileInfo::mvnoMatchData); |
| 2585 | } |
| 2586 | |
| 2587 | return; |
| 2588 | |
| 2589 | invalid: |
| 2590 | invalidCommandBlock(pRI); |
| 2591 | return; |
| 2592 | } |
| 2593 | |
| 2594 | static void dispatchRadioCapability(Parcel &p, RequestInfo *pRI){ |
| 2595 | RIL_RadioCapability rc; |
| 2596 | int32_t t = 0; |
| 2597 | status_t status; |
| 2598 | |
| 2599 | memset (&rc, 0, sizeof(RIL_RadioCapability)); |
| 2600 | |
| 2601 | status = p.readInt32(&t); |
| 2602 | rc.version = (int)t; |
| 2603 | if (status != NO_ERROR) { |
| 2604 | goto invalid; |
| 2605 | } |
| 2606 | |
| 2607 | status = p.readInt32(&t); |
| 2608 | rc.session= (int)t; |
| 2609 | if (status != NO_ERROR) { |
| 2610 | goto invalid; |
| 2611 | } |
| 2612 | |
| 2613 | status = p.readInt32(&t); |
| 2614 | rc.phase= (int)t; |
| 2615 | if (status != NO_ERROR) { |
| 2616 | goto invalid; |
| 2617 | } |
| 2618 | |
| 2619 | status = p.readInt32(&t); |
| 2620 | rc.rat = (int)t; |
| 2621 | if (status != NO_ERROR) { |
| 2622 | goto invalid; |
| 2623 | } |
| 2624 | |
| 2625 | status = readStringFromParcelInplace(p, rc.logicalModemUuid, sizeof(rc.logicalModemUuid)); |
| 2626 | if (status != NO_ERROR) { |
| 2627 | goto invalid; |
| 2628 | } |
| 2629 | |
| 2630 | status = p.readInt32(&t); |
| 2631 | rc.status = (int)t; |
| 2632 | |
| 2633 | if (status != NO_ERROR) { |
| 2634 | goto invalid; |
| 2635 | } |
| 2636 | |
| 2637 | startRequest; |
| 2638 | appendPrintBuf("%s [version:%d, session:%d, phase:%d, rat:%d, \ |
| 2639 | logicalModemUuid:%s, status:%d", printBuf, rc.version, rc.session, |
| 2640 | rc.phase, rc.rat, rc.logicalModemUuid, rc.session); |
| 2641 | |
| 2642 | closeRequest; |
| 2643 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 2644 | |
| 2645 | CALL_ONREQUEST(pRI->pCI->requestNumber, |
| 2646 | &rc, |
| 2647 | sizeof(RIL_RadioCapability), |
| 2648 | pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 2649 | return; |
| 2650 | invalid: |
| 2651 | invalidCommandBlock(pRI); |
| 2652 | return; |
| 2653 | } |
| 2654 | |
| 2655 | /** |
| 2656 | * Callee expects const RIL_CarrierRestrictions * |
| 2657 | */ |
| 2658 | static void dispatchCarrierRestrictions(Parcel &p, RequestInfo *pRI) { |
| 2659 | RIL_CarrierRestrictions cr; |
| 2660 | RIL_Carrier * allowed_carriers = NULL; |
| 2661 | RIL_Carrier * excluded_carriers = NULL; |
| 2662 | int32_t t; |
| 2663 | status_t status; |
| 2664 | |
| 2665 | memset(&cr, 0, sizeof(RIL_CarrierRestrictions)); |
| 2666 | |
| 2667 | if (s_callbacks.version < 14) { |
| 2668 | RLOGE("Unsuppoted RIL version %d, min version expected %d", |
| 2669 | s_callbacks.version, 14); |
| 2670 | RIL_onRequestComplete(pRI, RIL_E_REQUEST_NOT_SUPPORTED, NULL, 0); |
| 2671 | return; |
| 2672 | } |
| 2673 | |
| 2674 | status = p.readInt32(&t); |
| 2675 | if (status != NO_ERROR) { |
| 2676 | goto invalid; |
| 2677 | } |
| 2678 | allowed_carriers = (RIL_Carrier *)calloc(t, sizeof(RIL_Carrier)); |
| 2679 | if (allowed_carriers == NULL) { |
| 2680 | RLOGE("Memory allocation failed for request %s", requestToString(pRI->pCI->requestNumber)); |
| 2681 | goto exit; |
| 2682 | } |
| 2683 | cr.len_allowed_carriers = t; |
| 2684 | cr.allowed_carriers = allowed_carriers; |
| 2685 | |
| 2686 | status = p.readInt32(&t); |
| 2687 | if (status != NO_ERROR) { |
| 2688 | goto invalid; |
| 2689 | } |
| 2690 | excluded_carriers = (RIL_Carrier *)calloc(t, sizeof(RIL_Carrier)); |
| 2691 | if (excluded_carriers == NULL) { |
| 2692 | RLOGE("Memory allocation failed for request %s", requestToString(pRI->pCI->requestNumber)); |
| 2693 | goto exit; |
| 2694 | } |
| 2695 | cr.len_excluded_carriers = t; |
| 2696 | cr.excluded_carriers = excluded_carriers; |
| 2697 | |
| 2698 | startRequest; |
| 2699 | appendPrintBuf("%s len_allowed_carriers:%d, len_excluded_carriers:%d,", |
| 2700 | printBuf, cr.len_allowed_carriers, cr.len_excluded_carriers); |
| 2701 | |
| 2702 | appendPrintBuf("%s allowed_carriers:", printBuf); |
| 2703 | for (int32_t i = 0; i < cr.len_allowed_carriers; i++) { |
| 2704 | RIL_Carrier *p_cr = allowed_carriers + i; |
| 2705 | p_cr->mcc = strdupReadString(p); |
| 2706 | p_cr->mnc = strdupReadString(p); |
| 2707 | status = p.readInt32(&t); |
| 2708 | p_cr->match_type = static_cast<RIL_CarrierMatchType>(t); |
| 2709 | if (status != NO_ERROR) { |
| 2710 | goto invalid; |
| 2711 | } |
| 2712 | p_cr->match_data = strdupReadString(p); |
| 2713 | appendPrintBuf("%s [%d mcc:%s, mnc:%s, match_type:%d, match_data:%s],", |
| 2714 | printBuf, i, p_cr->mcc, p_cr->mnc, p_cr->match_type, p_cr->match_data); |
| 2715 | } |
| 2716 | |
| 2717 | for (int32_t i = 0; i < cr.len_excluded_carriers; i++) { |
| 2718 | RIL_Carrier *p_cr = excluded_carriers + i; |
| 2719 | p_cr->mcc = strdupReadString(p); |
| 2720 | p_cr->mnc = strdupReadString(p); |
| 2721 | status = p.readInt32(&t); |
| 2722 | p_cr->match_type = static_cast<RIL_CarrierMatchType>(t); |
| 2723 | if (status != NO_ERROR) { |
| 2724 | goto invalid; |
| 2725 | } |
| 2726 | p_cr->match_data = strdupReadString(p); |
| 2727 | appendPrintBuf("%s [%d mcc:%s, mnc:%s, match_type:%d, match_data:%s],", |
| 2728 | printBuf, i, p_cr->mcc, p_cr->mnc, p_cr->match_type, p_cr->match_data); |
| 2729 | } |
| 2730 | |
| 2731 | closeRequest; |
| 2732 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 2733 | |
| 2734 | CALL_ONREQUEST(pRI->pCI->requestNumber, |
| 2735 | &cr, |
| 2736 | sizeof(RIL_CarrierRestrictions), |
| 2737 | pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 2738 | |
| 2739 | goto exit; |
| 2740 | |
| 2741 | invalid: |
| 2742 | invalidCommandBlock(pRI); |
| 2743 | RIL_onRequestComplete(pRI, RIL_E_INVALID_ARGUMENTS, NULL, 0); |
| 2744 | exit: |
| 2745 | if (allowed_carriers != NULL) { |
| 2746 | free(allowed_carriers); |
| 2747 | } |
| 2748 | if (excluded_carriers != NULL) { |
| 2749 | free(excluded_carriers); |
| 2750 | } |
| 2751 | return; |
| 2752 | } |
| 2753 | |
| 2754 | //MTK-START [mtk80776] WiFi Calling |
| 2755 | static void dispatchUiccIo(Parcel &p, RequestInfo *pRI) |
| 2756 | { |
| 2757 | RIL_UICC_IO_v6 uiccIo; |
| 2758 | int32_t t = 0; |
| 2759 | status_t status; |
| 2760 | |
| 2761 | memset(&uiccIo, 0, sizeof(uiccIo)); |
| 2762 | |
| 2763 | status = p.readInt32(&t); |
| 2764 | uiccIo.sessionId = (int)t; |
| 2765 | |
| 2766 | status = p.readInt32(&t); |
| 2767 | uiccIo.command = (int)t; |
| 2768 | |
| 2769 | status = p.readInt32(&t); |
| 2770 | uiccIo.fileId = (int)t; |
| 2771 | |
| 2772 | uiccIo.path = strdupReadString(p); |
| 2773 | |
| 2774 | status = p.readInt32(&t); |
| 2775 | uiccIo.p1 = (int)t; |
| 2776 | |
| 2777 | status = p.readInt32(&t); |
| 2778 | uiccIo.p2 = (int)t; |
| 2779 | |
| 2780 | status = p.readInt32(&t); |
| 2781 | uiccIo.p3 = (int)t; |
| 2782 | |
| 2783 | uiccIo.data = strdupReadString(p); |
| 2784 | uiccIo.pin2 = strdupReadString(p); |
| 2785 | |
| 2786 | startRequest; |
| 2787 | appendPrintBuf("%s sessionId=0x%X, cmd=0x%x, efid=0x%x path=%s,%d,%d,%d,%s,pin2=%s", printBuf, |
| 2788 | uiccIo.sessionId, uiccIo.command, uiccIo.fileId, (char *)uiccIo.path, |
| 2789 | uiccIo.p1, uiccIo.p2, uiccIo.p3, (char *)uiccIo.data, (char *)uiccIo.pin2); |
| 2790 | closeRequest; |
| 2791 | printRequest(pRI->token, pRI->pCI->reqeustNumber); |
| 2792 | |
| 2793 | if (status != NO_ERROR) { |
| 2794 | goto invalid; |
| 2795 | } |
| 2796 | |
| 2797 | CALL_ONREQUEST(pRI->pCI->requestNumber, &uiccIo, sizeof(RIL_UICC_IO_v6), pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 2798 | |
| 2799 | #ifdef MEMSET_FREED |
| 2800 | memsetString(uiccIo.path); |
| 2801 | memsetString(uiccIo.data); |
| 2802 | memsetString(uiccIo.pin2); |
| 2803 | #endif |
| 2804 | |
| 2805 | free(uiccIo.path); |
| 2806 | free(uiccIo.data); |
| 2807 | free(uiccIo.pin2); |
| 2808 | |
| 2809 | #ifdef MEMSET_FREED |
| 2810 | memset(&uiccIo, 0, sizeof(RIL_UICC_IO_v6)); |
| 2811 | #endif |
| 2812 | |
| 2813 | return; |
| 2814 | invalid: |
| 2815 | invalidCommandBlock(pRI); |
| 2816 | return; |
| 2817 | } |
| 2818 | |
| 2819 | static void dispatchUiccAuthentication(Parcel &p, RequestInfo *pRI) |
| 2820 | { |
| 2821 | RIL_UICC_Authentication uiccAuth; |
| 2822 | int32_t t = 0; |
| 2823 | int32_t len; |
| 2824 | status_t status; |
| 2825 | |
| 2826 | RLOGD("dispatchUiccAuthentication Enter..."); |
| 2827 | |
| 2828 | memset(&uiccAuth, 0, sizeof(uiccAuth)); |
| 2829 | |
| 2830 | status = p.readInt32(&t); |
| 2831 | uiccAuth.session_id = (int)t; |
| 2832 | |
| 2833 | uiccAuth.context1 = strdupReadString(p); |
| 2834 | uiccAuth.context2 = strdupReadString(p); |
| 2835 | |
| 2836 | startRequest; |
| 2837 | appendPrintBuf("%ssessionId=%d, context1=%s, context2=%s", printBuf, |
| 2838 | uiccAuth.session_id, uiccAuth.context1, uiccAuth.context2); |
| 2839 | closeRequest; |
| 2840 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 2841 | |
| 2842 | if (status != NO_ERROR) { |
| 2843 | goto invalid; |
| 2844 | } |
| 2845 | |
| 2846 | CALL_ONREQUEST(pRI->pCI->requestNumber, &uiccAuth, sizeof(uiccAuth), pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 2847 | |
| 2848 | #ifdef MEMSET_FREED |
| 2849 | memsetString(uiccAuth.context1); |
| 2850 | memsetString(uiccAuth.context2); |
| 2851 | #endif |
| 2852 | |
| 2853 | free(uiccAuth.context1); |
| 2854 | free(uiccAuth.context2); |
| 2855 | |
| 2856 | #ifdef MEMSET_FREED |
| 2857 | memset(&uiccAuth, 0, sizeof(uiccAuth)); |
| 2858 | #endif |
| 2859 | |
| 2860 | return; |
| 2861 | invalid: |
| 2862 | invalidCommandBlock(pRI); |
| 2863 | return; |
| 2864 | } |
| 2865 | //MTK-END [mtk80776] WiFi Calling |
| 2866 | |
| 2867 | // New SIM Authentication |
| 2868 | static void dispatchSimAuth(Parcel &p, RequestInfo *pRI) { |
| 2869 | RIL_SimAuthStructure args; |
| 2870 | int32_t t = 0; |
| 2871 | status_t status; |
| 2872 | |
| 2873 | memset (&args, 0, sizeof(args)); |
| 2874 | |
| 2875 | // Session ID |
| 2876 | status = p.readInt32(&t); |
| 2877 | args.sessionId = (int) t; |
| 2878 | |
| 2879 | // mode |
| 2880 | status = p.readInt32(&t); |
| 2881 | args.mode = (int) t; |
| 2882 | |
| 2883 | args.param1 = strdupReadString(p); |
| 2884 | args.param2 = strdupReadString(p); |
| 2885 | |
| 2886 | if (args.mode == 1) { |
| 2887 | // GBA |
| 2888 | status = p.readInt32(&t); |
| 2889 | args.tag = (int) t; |
| 2890 | } |
| 2891 | |
| 2892 | if (status != NO_ERROR) { |
| 2893 | goto invalid; |
| 2894 | } |
| 2895 | |
| 2896 | CALL_ONREQUEST(pRI->pCI->requestNumber, &args, sizeof(args), pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 2897 | |
| 2898 | return; |
| 2899 | invalid: |
| 2900 | invalidCommandBlock(pRI); |
| 2901 | return; |
| 2902 | } |
| 2903 | |
| 2904 | //[New R8 modem FD] |
| 2905 | static void dispatchFdMode(Parcel &p, RequestInfo *pRI) { |
| 2906 | RIL_FdModeData args; |
| 2907 | status_t status; |
| 2908 | int t_value = 0; |
| 2909 | memset(&args, 0, sizeof(args)); |
| 2910 | status = p.readInt32(&t_value); |
| 2911 | args.argsNum = t_value; |
| 2912 | |
| 2913 | /* AT+EFD=<mode>[,<param1>[,<param2>]] */ |
| 2914 | /* For all modes: but mode 0 & 1 only has one argument */ |
| 2915 | if (args.argsNum >= 1) { |
| 2916 | status = p.readInt32(&t_value); |
| 2917 | args.mode = t_value; |
| 2918 | } |
| 2919 | /* For mode 2 & 3 */ |
| 2920 | if (args.argsNum >= 2) { |
| 2921 | status = p.readInt32(&t_value); |
| 2922 | args.parameter1 = t_value; |
| 2923 | } |
| 2924 | /* Only mode 2 */ |
| 2925 | if (args.argsNum >=3) { |
| 2926 | status = p.readInt32(&t_value); |
| 2927 | args.parameter2 = t_value; |
| 2928 | } |
| 2929 | |
| 2930 | CALL_ONREQUEST(pRI->pCI->requestNumber, &args, sizeof(args), pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 2931 | } |
| 2932 | |
| 2933 | static void dispatchPhbEntry(Parcel &p, RequestInfo *pRI) { |
| 2934 | |
| 2935 | RIL_PhbEntryStrucutre args; |
| 2936 | int32_t t = 0; |
| 2937 | status_t status; |
| 2938 | |
| 2939 | memset (&args, 0, sizeof(args)); |
| 2940 | |
| 2941 | // storage type |
| 2942 | status = p.readInt32(&t); |
| 2943 | args.type = (int) t; |
| 2944 | |
| 2945 | // index of the entry |
| 2946 | status = p.readInt32(&t); |
| 2947 | args.index = (int) t; |
| 2948 | |
| 2949 | // phone number |
| 2950 | args.number = strdupReadString(p); |
| 2951 | |
| 2952 | // Type of the number |
| 2953 | status = p.readInt32(&t); |
| 2954 | args.ton = (int) t; |
| 2955 | |
| 2956 | // alpha Id |
| 2957 | args.alphaId = strdupReadString(p); |
| 2958 | |
| 2959 | if (status != NO_ERROR) { |
| 2960 | goto invalid; |
| 2961 | } |
| 2962 | |
| 2963 | startRequest; |
| 2964 | appendPrintBuf("%s%d,index=%d,num=%s,ton=%d,alphaId=%s", printBuf, args.type, |
| 2965 | args.index, (char*)args.number, args.ton, (char*)args.alphaId); |
| 2966 | closeRequest; |
| 2967 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 2968 | |
| 2969 | CALL_ONREQUEST(pRI->pCI->requestNumber, &args, sizeof(args), pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 2970 | |
| 2971 | #ifdef MEMSET_FREED |
| 2972 | memsetString (args.number); |
| 2973 | memsetString (args.alphaId); |
| 2974 | #endif |
| 2975 | |
| 2976 | free (args.number); |
| 2977 | free (args.alphaId); |
| 2978 | |
| 2979 | #ifdef MEMSET_FREED |
| 2980 | memset(&args, 0, sizeof(args)); |
| 2981 | #endif |
| 2982 | |
| 2983 | return; |
| 2984 | invalid: |
| 2985 | invalidCommandBlock(pRI); |
| 2986 | return; |
| 2987 | |
| 2988 | } |
| 2989 | |
| 2990 | static void dispatchWritePhbEntryExt(Parcel &p, RequestInfo *pRI) { |
| 2991 | |
| 2992 | RIL_PHB_ENTRY args; |
| 2993 | int32_t t = 0; |
| 2994 | status_t status; |
| 2995 | |
| 2996 | memset (&args, 0, sizeof(args)); |
| 2997 | |
| 2998 | // index of the entry |
| 2999 | status = p.readInt32(&t); |
| 3000 | args.index = (int) t; |
| 3001 | // phone number |
| 3002 | args.number = strdupReadString(p); |
| 3003 | // Type of the number |
| 3004 | status = p.readInt32(&t); |
| 3005 | args.type = (int) t; |
| 3006 | //text |
| 3007 | args.text = strdupReadString(p); |
| 3008 | //hidden |
| 3009 | status = p.readInt32(&t); |
| 3010 | args.hidden = (int) t; |
| 3011 | |
| 3012 | //group |
| 3013 | args.group = strdupReadString(p); |
| 3014 | //anr |
| 3015 | args.adnumber = strdupReadString(p); |
| 3016 | // Type of the adnumber |
| 3017 | status = p.readInt32(&t); |
| 3018 | args.adtype = (int) t; |
| 3019 | //SNE |
| 3020 | args.secondtext = strdupReadString(p); |
| 3021 | // email |
| 3022 | args.email = strdupReadString(p); |
| 3023 | |
| 3024 | if (status != NO_ERROR) { |
| 3025 | goto invalid; |
| 3026 | } |
| 3027 | |
| 3028 | startRequest; |
| 3029 | appendPrintBuf("%s,index=%d,num=%s,type=%d,text=%s,hidden=%d,group=%s,adnumber=%s,adtype=%d,secondtext=%s,email=%s", printBuf, |
| 3030 | args.index, (char*)args.number, args.type, (char*)args.text, |
| 3031 | args.hidden, (char*)args.group,(char*)args.adnumber, args.adtype,(char*)args.secondtext,(char*)args.email); |
| 3032 | closeRequest; |
| 3033 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 3034 | |
| 3035 | CALL_ONREQUEST(pRI->pCI->requestNumber, &args, sizeof(args), pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 3036 | |
| 3037 | #ifdef MEMSET_FREED |
| 3038 | memsetString (args.number); |
| 3039 | memsetString (args.text); |
| 3040 | memsetString (args.group); |
| 3041 | memsetString (args.adnumber); |
| 3042 | memsetString (args.secondtext); |
| 3043 | memsetString (args.email); |
| 3044 | #endif |
| 3045 | free (args.number); |
| 3046 | free (args.text); |
| 3047 | free (args.group); |
| 3048 | free (args.adnumber); |
| 3049 | free (args.secondtext); |
| 3050 | free (args.email); |
| 3051 | |
| 3052 | #ifdef MEMSET_FREED |
| 3053 | memset(&args, 0, sizeof(args)); |
| 3054 | #endif |
| 3055 | |
| 3056 | return; |
| 3057 | invalid: |
| 3058 | invalidCommandBlock(pRI); |
| 3059 | return; |
| 3060 | |
| 3061 | } |
| 3062 | |
| 3063 | |
| 3064 | static int |
| 3065 | blockingWrite(int fd, const void *buffer, size_t len) { |
| 3066 | size_t writeOffset = 0; |
| 3067 | const uint8_t *toWrite; |
| 3068 | |
| 3069 | toWrite = (const uint8_t *)buffer; |
| 3070 | |
| 3071 | while (writeOffset < len) { |
| 3072 | ssize_t written; |
| 3073 | do { |
| 3074 | written = write (fd, toWrite + writeOffset, |
| 3075 | len - writeOffset); |
| 3076 | } while (written < 0 && ((errno == EINTR) || (errno == EAGAIN))); |
| 3077 | |
| 3078 | if (written >= 0) { |
| 3079 | writeOffset += written; |
| 3080 | } else { // written < 0 |
| 3081 | RLOGE ("RIL Response: unexpected error on write errno:%d", errno); |
| 3082 | close(fd); |
| 3083 | return -1; |
| 3084 | } |
| 3085 | } |
| 3086 | #if VDBG |
| 3087 | RLOGE("RIL Response bytes written:%d", writeOffset); |
| 3088 | #endif |
| 3089 | return 0; |
| 3090 | } |
| 3091 | |
| 3092 | static int |
| 3093 | sendResponseRaw (const void *data, size_t dataSize, RIL_SOCKET_ID socket_id, int clientId) { |
| 3094 | int fd = s_ril_param_socket.fdCommand; |
| 3095 | int ret; |
| 3096 | uint32_t header; |
| 3097 | pthread_mutex_t * writeMutexHook = &s_writeMutex; |
| 3098 | |
| 3099 | #if VDBG |
| 3100 | RLOGE("Send Response to %s %d", rilSocketIdToString(socket_id), clientId); |
| 3101 | #endif |
| 3102 | if (clientId >= 0) { |
| 3103 | fd = s_ril_param_socket_clients[clientId].fdCommand; |
| 3104 | writeMutexHook = &(s_writeMutex_socket_client[clientId]); |
| 3105 | RLOGD("Send Response to client %d", clientId); |
| 3106 | } else { |
| 3107 | if (socket_id == RIL_SOCKET_2) { |
| 3108 | fd = s_ril_param_socket2.fdCommand; |
| 3109 | writeMutexHook = &s_writeMutex_socket2; |
| 3110 | } |
| 3111 | else if (socket_id == RIL_SOCKET_3) { |
| 3112 | fd = s_ril_param_socket3.fdCommand; |
| 3113 | writeMutexHook = &s_writeMutex_socket3; |
| 3114 | } |
| 3115 | else if (socket_id == RIL_SOCKET_4) { |
| 3116 | fd = s_ril_param_socket4.fdCommand; |
| 3117 | writeMutexHook = &s_writeMutex_socket4; |
| 3118 | } |
| 3119 | else if (socket_id == RIL_SOCKET_RILJ) { |
| 3120 | fd = s_ril_param_socket_rilj.fdCommand; |
| 3121 | writeMutexHook = &s_writeMutex_socket_rilj; |
| 3122 | } |
| 3123 | else if (socket_id == RIL_SOCKET_RILJ2) { |
| 3124 | fd = s_ril_param_socket_rilj2.fdCommand; |
| 3125 | writeMutexHook = &s_writeMutex_socket_rilj2; |
| 3126 | } |
| 3127 | } |
| 3128 | if (fd < 0) { |
| 3129 | return -1; |
| 3130 | } |
| 3131 | |
| 3132 | if (dataSize > MAX_COMMAND_BYTES) { |
| 3133 | RLOGE("RIL: packet larger than %u (%u)", |
| 3134 | MAX_COMMAND_BYTES, (unsigned int )dataSize); |
| 3135 | |
| 3136 | return -1; |
| 3137 | } |
| 3138 | |
| 3139 | pthread_mutex_lock(writeMutexHook); |
| 3140 | |
| 3141 | header = htonl(dataSize); |
| 3142 | |
| 3143 | ret = blockingWrite(fd, (void *)&header, sizeof(header)); |
| 3144 | |
| 3145 | if (ret < 0) { |
| 3146 | pthread_mutex_unlock(writeMutexHook); |
| 3147 | return ret; |
| 3148 | } |
| 3149 | |
| 3150 | ret = blockingWrite(fd, data, dataSize); |
| 3151 | |
| 3152 | if (ret < 0) { |
| 3153 | pthread_mutex_unlock(writeMutexHook); |
| 3154 | return ret; |
| 3155 | } |
| 3156 | |
| 3157 | pthread_mutex_unlock(writeMutexHook); |
| 3158 | return 0; |
| 3159 | } |
| 3160 | |
| 3161 | static int |
| 3162 | sendResponse (Parcel &p, RIL_SOCKET_ID socket_id, int clientId) { |
| 3163 | printResponse; |
| 3164 | return sendResponseRaw(p.data(), p.dataSize(), socket_id, clientId); |
| 3165 | } |
| 3166 | |
| 3167 | /** response is an int* pointing to an array of ints */ |
| 3168 | |
| 3169 | static int |
| 3170 | responseInts(Parcel &p, void *response, size_t responselen) { |
| 3171 | int numInts; |
| 3172 | |
| 3173 | if (response == NULL && responselen != 0) { |
| 3174 | RLOGE("invalid response: NULL"); |
| 3175 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3176 | } |
| 3177 | if (responselen % sizeof(int) != 0) { |
| 3178 | RLOGE("responseInts: invalid response length %d expected multiple of %d\n", |
| 3179 | (int)responselen, (int)sizeof(int)); |
| 3180 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3181 | } |
| 3182 | |
| 3183 | int *p_int = (int *) response; |
| 3184 | |
| 3185 | numInts = responselen / sizeof(int); |
| 3186 | p.writeInt32 (numInts); |
| 3187 | |
| 3188 | /* each int*/ |
| 3189 | startResponse; |
| 3190 | for (int i = 0 ; i < numInts ; i++) { |
| 3191 | appendPrintBuf("%s%d,", printBuf, p_int[i]); |
| 3192 | p.writeInt32(p_int[i]); |
| 3193 | } |
| 3194 | removeLastChar; |
| 3195 | closeResponse; |
| 3196 | |
| 3197 | return 0; |
| 3198 | } |
| 3199 | |
| 3200 | // Response is an int or RIL_LastCallFailCauseInfo. |
| 3201 | // Currently, only Shamu plans to use RIL_LastCallFailCauseInfo. |
| 3202 | // TODO(yjl): Let all implementations use RIL_LastCallFailCauseInfo. |
| 3203 | static int responseFailCause(Parcel &p, void *response, size_t responselen) { |
| 3204 | if (response == NULL && responselen != 0) { |
| 3205 | RLOGE("invalid response: NULL"); |
| 3206 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3207 | } |
| 3208 | |
| 3209 | if (responselen == sizeof(int)) { |
| 3210 | startResponse; |
| 3211 | int *p_int = (int *) response; |
| 3212 | appendPrintBuf("%s%d,", printBuf, p_int[0]); |
| 3213 | p.writeInt32(p_int[0]); |
| 3214 | removeLastChar; |
| 3215 | closeResponse; |
| 3216 | } else if (responselen == sizeof(RIL_LastCallFailCauseInfo)) { |
| 3217 | startResponse; |
| 3218 | RIL_LastCallFailCauseInfo *p_fail_cause_info = (RIL_LastCallFailCauseInfo *) response; |
| 3219 | appendPrintBuf("%s[cause_code=%d,vendor_cause=%s]", printBuf, p_fail_cause_info->cause_code, |
| 3220 | p_fail_cause_info->vendor_cause); |
| 3221 | p.writeInt32(p_fail_cause_info->cause_code); |
| 3222 | writeStringToParcel(p, p_fail_cause_info->vendor_cause); |
| 3223 | removeLastChar; |
| 3224 | closeResponse; |
| 3225 | } else { |
| 3226 | RLOGE("responseFailCause: invalid response length %d expected an int or " |
| 3227 | "RIL_LastCallFailCauseInfo", (int)responselen); |
| 3228 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3229 | } |
| 3230 | |
| 3231 | return 0; |
| 3232 | } |
| 3233 | |
| 3234 | /** response is a char **, pointing to an array of char *'s |
| 3235 | The parcel will begin with the version */ |
| 3236 | static int responseStringsWithVersion(int version, Parcel &p, void *response, size_t responselen) { |
| 3237 | p.writeInt32(version); |
| 3238 | return responseStrings(p, response, responselen); |
| 3239 | } |
| 3240 | |
| 3241 | /** response is a char **, pointing to an array of char *'s */ |
| 3242 | static int responseStrings(Parcel &p, void *response, size_t responselen) { |
| 3243 | int numStrings; |
| 3244 | |
| 3245 | if (response == NULL && responselen != 0) { |
| 3246 | RLOGE("invalid response: NULL"); |
| 3247 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3248 | } |
| 3249 | if (responselen % sizeof(char *) != 0) { |
| 3250 | RLOGE("responseStrings: invalid response length %d expected multiple of %d\n", |
| 3251 | (int)responselen, (int)sizeof(char *)); |
| 3252 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3253 | } |
| 3254 | |
| 3255 | if (response == NULL) { |
| 3256 | p.writeInt32 (0); |
| 3257 | } else { |
| 3258 | char **p_cur = (char **) response; |
| 3259 | |
| 3260 | numStrings = responselen / sizeof(char *); |
| 3261 | p.writeInt32 (numStrings); |
| 3262 | |
| 3263 | /* each string*/ |
| 3264 | startResponse; |
| 3265 | for (int i = 0 ; i < numStrings ; i++) { |
| 3266 | appendPrintBuf("%s%s,", printBuf, (char*)p_cur[i]); |
| 3267 | writeStringToParcel (p, p_cur[i]); |
| 3268 | } |
| 3269 | removeLastChar; |
| 3270 | closeResponse; |
| 3271 | } |
| 3272 | return 0; |
| 3273 | } |
| 3274 | |
| 3275 | static void responseRIL_CellIdentity_v16(Parcel &p, RIL_CellIdentity_v16 *ci) { |
| 3276 | p.writeInt32(ci->cellInfoType); |
| 3277 | switch (ci->cellInfoType) { |
| 3278 | case RIL_CELL_INFO_TYPE_GSM: { |
| 3279 | p.writeInt32(ci->cellIdentityGsm.mcc); |
| 3280 | p.writeInt32(ci->cellIdentityGsm.mnc); |
| 3281 | p.writeInt32(ci->cellIdentityGsm.mnc_len); |
| 3282 | p.writeInt32(ci->cellIdentityGsm.lac); |
| 3283 | p.writeInt32(ci->cellIdentityGsm.cid); |
| 3284 | p.writeInt32(ci->cellIdentityGsm.arfcn); |
| 3285 | p.writeByte(ci->cellIdentityGsm.bsic); |
| 3286 | writeStringToParcel(p, (const char *)ci->cellIdentityGsm.operName.long_name); |
| 3287 | writeStringToParcel(p, (const char *)ci->cellIdentityGsm.operName.short_name); |
| 3288 | break; |
| 3289 | } |
| 3290 | case RIL_CELL_INFO_TYPE_WCDMA: { |
| 3291 | p.writeInt32(ci->cellIdentityWcdma.mcc); |
| 3292 | p.writeInt32(ci->cellIdentityWcdma.mnc); |
| 3293 | p.writeInt32(ci->cellIdentityWcdma.mnc_len); |
| 3294 | p.writeInt32(ci->cellIdentityWcdma.lac); |
| 3295 | p.writeInt32(ci->cellIdentityWcdma.cid); |
| 3296 | p.writeInt32(ci->cellIdentityWcdma.uarfcn); |
| 3297 | writeStringToParcel(p, (const char *)ci->cellIdentityWcdma.operName.long_name); |
| 3298 | writeStringToParcel(p, (const char *)ci->cellIdentityWcdma.operName.short_name); |
| 3299 | break; |
| 3300 | } |
| 3301 | case RIL_CELL_INFO_TYPE_CDMA: { |
| 3302 | p.writeInt32(ci->cellIdentityCdma.networkId); |
| 3303 | p.writeInt32(ci->cellIdentityCdma.systemId); |
| 3304 | p.writeInt32(ci->cellIdentityCdma.basestationId); |
| 3305 | p.writeInt32(ci->cellIdentityCdma.longitude); |
| 3306 | p.writeInt32(ci->cellIdentityCdma.latitude); |
| 3307 | writeStringToParcel(p, (const char *)ci->cellIdentityCdma.operName.long_name); |
| 3308 | writeStringToParcel(p, (const char *)ci->cellIdentityCdma.operName.short_name); |
| 3309 | break; |
| 3310 | } |
| 3311 | case RIL_CELL_INFO_TYPE_LTE: { |
| 3312 | p.writeInt32(ci->cellIdentityLte.mcc); |
| 3313 | p.writeInt32(ci->cellIdentityLte.mnc); |
| 3314 | p.writeInt32(ci->cellIdentityLte.mnc_len); |
| 3315 | p.writeInt32(ci->cellIdentityLte.ci); |
| 3316 | p.writeInt32(ci->cellIdentityLte.pci); |
| 3317 | p.writeInt32(ci->cellIdentityLte.tac); |
| 3318 | p.writeInt32(ci->cellIdentityLte.earfcn); |
| 3319 | writeStringToParcel(p, (const char *)ci->cellIdentityLte.operName.long_name); |
| 3320 | writeStringToParcel(p, (const char *)ci->cellIdentityLte.operName.short_name); |
| 3321 | p.writeInt32(ci->cellIdentityLte.bandwidth); |
| 3322 | break; |
| 3323 | } |
| 3324 | case RIL_CELL_INFO_TYPE_TD_SCDMA: { |
| 3325 | p.writeInt32(ci->cellIdentityTdscdma.mcc); |
| 3326 | p.writeInt32(ci->cellIdentityTdscdma.mnc); |
| 3327 | p.writeInt32(ci->cellIdentityTdscdma.mnc_len); |
| 3328 | p.writeInt32(ci->cellIdentityTdscdma.lac); |
| 3329 | p.writeInt32(ci->cellIdentityTdscdma.cid); |
| 3330 | p.writeInt32(ci->cellIdentityTdscdma.cpid); |
| 3331 | writeStringToParcel(p, (const char *)ci->cellIdentityTdscdma.operName.long_name); |
| 3332 | writeStringToParcel(p, (const char *)ci->cellIdentityTdscdma.operName.short_name); |
| 3333 | break; |
| 3334 | } |
| 3335 | |
| 3336 | default: { |
| 3337 | break; |
| 3338 | } |
| 3339 | } |
| 3340 | } |
| 3341 | |
| 3342 | static int responseVoiceRegState(Parcel &p, void *response, size_t responselen) { |
| 3343 | if (response == NULL && responselen != 0) { |
| 3344 | RLOGE("invalid response: NULL"); |
| 3345 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3346 | } else if (s_callbacks.version >= 15) { |
| 3347 | if (responselen == sizeof(RIL_VoiceRegistrationStateResponse)) { |
| 3348 | RIL_VoiceRegistrationStateResponse *res = (RIL_VoiceRegistrationStateResponse *) response; |
| 3349 | p.writeInt32(res->regState); |
| 3350 | p.writeInt32(res->rat); |
| 3351 | p.writeInt32(res->cssSupported); |
| 3352 | p.writeInt32(res->roamingIndicator); |
| 3353 | p.writeInt32(res->systemIsInPrl); |
| 3354 | p.writeInt32(res->defaultRoamingIndicator); |
| 3355 | p.writeInt32(res->reasonForDenial); |
| 3356 | responseRIL_CellIdentity_v16(p, &(res->cellIdentity)); |
| 3357 | } else { |
| 3358 | RLOGE("invalid response: size not matched"); |
| 3359 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3360 | } |
| 3361 | } else { |
| 3362 | responseStrings(p, response, responselen); |
| 3363 | } |
| 3364 | return 0; |
| 3365 | } |
| 3366 | |
| 3367 | static int responseDataRegState(Parcel &p, void *response, size_t responselen) { |
| 3368 | if (response == NULL && responselen != 0) { |
| 3369 | RLOGE("invalid response: NULL"); |
| 3370 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3371 | } else if (s_callbacks.version >= 15) { |
| 3372 | if (responselen == sizeof(RIL_DataRegistrationStateResponse)) { |
| 3373 | RIL_DataRegistrationStateResponse *res = (RIL_DataRegistrationStateResponse *) response; |
| 3374 | p.writeInt32(res->regState); |
| 3375 | p.writeInt32(res->rat); |
| 3376 | p.writeInt32(res->reasonDataDenied); |
| 3377 | p.writeInt32(res->maxDataCalls); |
| 3378 | responseRIL_CellIdentity_v16(p, &(res->cellIdentity)); |
| 3379 | } else { |
| 3380 | RLOGE("invalid response: size not matched"); |
| 3381 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3382 | } |
| 3383 | } else { |
| 3384 | responseStrings(p, response, responselen); |
| 3385 | } |
| 3386 | return 0; |
| 3387 | } |
| 3388 | |
| 3389 | static int responseKeepaliveStatus(Parcel &p, void *response, size_t responselen) { |
| 3390 | if (response == NULL && responselen != 0) { |
| 3391 | RLOGE("invalid response: NULL"); |
| 3392 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3393 | } else if (s_callbacks.version >= 15) { |
| 3394 | if (responselen == sizeof(RIL_KeepaliveStatus)) { |
| 3395 | RIL_KeepaliveStatus *stat = (RIL_KeepaliveStatus *)response; |
| 3396 | p.writeInt32(stat->sessionHandle); |
| 3397 | p.writeInt32(stat->code); |
| 3398 | } else { |
| 3399 | RLOGE("invalid response: size not matched"); |
| 3400 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3401 | } |
| 3402 | } else { |
| 3403 | return responseVoid(p, response, responselen); |
| 3404 | } |
| 3405 | return 0; |
| 3406 | } |
| 3407 | |
| 3408 | /** |
| 3409 | * NULL strings are accepted |
| 3410 | * FIXME currently ignores responselen |
| 3411 | */ |
| 3412 | static int responseString(Parcel &p, void *response, size_t responselen) { |
| 3413 | /* one string only */ |
| 3414 | startResponse; |
| 3415 | appendPrintBuf("%s%s", printBuf, (char*)response); |
| 3416 | closeResponse; |
| 3417 | |
| 3418 | writeStringToParcel(p, (const char *)response); |
| 3419 | |
| 3420 | return 0; |
| 3421 | } |
| 3422 | |
| 3423 | static int responseVoid(Parcel &p, void *response, size_t responselen) { |
| 3424 | startResponse; |
| 3425 | removeLastChar; |
| 3426 | return 0; |
| 3427 | } |
| 3428 | |
| 3429 | static int responseCallList(Parcel &p, void *response, size_t responselen) { |
| 3430 | int num; |
| 3431 | |
| 3432 | if (response == NULL && responselen != 0) { |
| 3433 | RLOGE("invalid response: NULL"); |
| 3434 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3435 | } |
| 3436 | |
| 3437 | if (responselen % sizeof (RIL_Call *) != 0) { |
| 3438 | RLOGE("responseCallList: invalid response length %d expected multiple of %d\n", |
| 3439 | (int)responselen, (int)sizeof (RIL_Call *)); |
| 3440 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3441 | } |
| 3442 | |
| 3443 | startResponse; |
| 3444 | /* number of call info's */ |
| 3445 | num = responselen / sizeof(RIL_Call *); |
| 3446 | /// MTK_RIL_ADAPTER for IMS CC @{ |
| 3447 | int count = 0; |
| 3448 | for (int i = 0 ; i < num ; i++) { |
| 3449 | RIL_Call *p_cur = ((RIL_Call **) response)[i]; |
| 3450 | if (p_cur->index < CONF_CALL_ID_SHIFT) { |
| 3451 | count++; |
| 3452 | } |
| 3453 | } |
| 3454 | p.writeInt32(count); |
| 3455 | /// @} |
| 3456 | |
| 3457 | for (int i = 0 ; i < num ; i++) { |
| 3458 | RIL_Call *p_cur = ((RIL_Call **) response)[i]; |
| 3459 | /// MTK_RIL_ADAPTER for IMS CC @{ |
| 3460 | if (p_cur->index >= CONF_CALL_ID_SHIFT) { |
| 3461 | continue; |
| 3462 | } |
| 3463 | /// @} |
| 3464 | /* each call info */ |
| 3465 | p.writeInt32(p_cur->state); |
| 3466 | p.writeInt32(p_cur->index); |
| 3467 | p.writeInt32(p_cur->toa); |
| 3468 | p.writeInt32(p_cur->isMpty); |
| 3469 | p.writeInt32(p_cur->isMT); |
| 3470 | p.writeInt32(p_cur->als); |
| 3471 | p.writeInt32(p_cur->isVoice); |
| 3472 | p.writeInt32(p_cur->isVoicePrivacy); |
| 3473 | writeStringToParcel(p, p_cur->number); |
| 3474 | p.writeInt32(p_cur->numberPresentation); |
| 3475 | writeStringToParcel(p, p_cur->name); |
| 3476 | p.writeInt32(p_cur->namePresentation); |
| 3477 | // Remove when partners upgrade to version 3 |
| 3478 | if ((s_callbacks.version < 3) || (p_cur->uusInfo == NULL || p_cur->uusInfo->uusData == NULL)) { |
| 3479 | p.writeInt32(0); /* UUS Information is absent */ |
| 3480 | } else { |
| 3481 | RIL_UUS_Info *uusInfo = p_cur->uusInfo; |
| 3482 | p.writeInt32(1); /* UUS Information is present */ |
| 3483 | p.writeInt32(uusInfo->uusType); |
| 3484 | p.writeInt32(uusInfo->uusDcs); |
| 3485 | p.writeInt32(uusInfo->uusLength); |
| 3486 | p.write(uusInfo->uusData, uusInfo->uusLength); |
| 3487 | } |
| 3488 | p.writeInt32(p_cur->speechCodec); |
| 3489 | appendPrintBuf("%s[id=%d,%s,toa=%d,", |
| 3490 | printBuf, |
| 3491 | p_cur->index, |
| 3492 | callStateToString(p_cur->state), |
| 3493 | p_cur->toa); |
| 3494 | appendPrintBuf("%s%s,%s,als=%d,%s,%s,", |
| 3495 | printBuf, |
| 3496 | (p_cur->isMpty)?"conf":"norm", |
| 3497 | (p_cur->isMT)?"mt":"mo", |
| 3498 | p_cur->als, |
| 3499 | (p_cur->isVoice)?"voc":"nonvoc", |
| 3500 | (p_cur->isVoicePrivacy)?"evp":"noevp"); |
| 3501 | appendPrintBuf("%s%s,cli=%d,name='%s',%d]", |
| 3502 | printBuf, |
| 3503 | p_cur->number, |
| 3504 | p_cur->numberPresentation, |
| 3505 | p_cur->name, |
| 3506 | p_cur->namePresentation); |
| 3507 | } |
| 3508 | removeLastChar; |
| 3509 | closeResponse; |
| 3510 | |
| 3511 | return 0; |
| 3512 | } |
| 3513 | |
| 3514 | static int responseSMS(Parcel &p, void *response, size_t responselen) { |
| 3515 | if (response == NULL) { |
| 3516 | RLOGE("invalid response: NULL"); |
| 3517 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3518 | } |
| 3519 | |
| 3520 | if (responselen != sizeof (RIL_SMS_Response) ) { |
| 3521 | RLOGE("invalid response length %d expected %d", |
| 3522 | (int)responselen, (int)sizeof (RIL_SMS_Response)); |
| 3523 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3524 | } |
| 3525 | |
| 3526 | RIL_SMS_Response *p_cur = (RIL_SMS_Response *) response; |
| 3527 | |
| 3528 | p.writeInt32(p_cur->messageRef); |
| 3529 | writeStringToParcel(p, p_cur->ackPDU); |
| 3530 | p.writeInt32(p_cur->errorCode); |
| 3531 | |
| 3532 | startResponse; |
| 3533 | appendPrintBuf("%s%d,%s,%d", printBuf, p_cur->messageRef, |
| 3534 | (char*)p_cur->ackPDU, p_cur->errorCode); |
| 3535 | closeResponse; |
| 3536 | |
| 3537 | return 0; |
| 3538 | } |
| 3539 | |
| 3540 | static int responseDataCallListV4(Parcel &p, void *response, size_t responselen) |
| 3541 | { |
| 3542 | if (response == NULL && responselen != 0) { |
| 3543 | RLOGE("invalid response: NULL"); |
| 3544 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3545 | } |
| 3546 | |
| 3547 | if (responselen % sizeof(RIL_Data_Call_Response_v4) != 0) { |
| 3548 | RLOGE("responseDataCallListV4: invalid response length %d expected multiple of %d", |
| 3549 | (int)responselen, (int)sizeof(RIL_Data_Call_Response_v4)); |
| 3550 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3551 | } |
| 3552 | |
| 3553 | // Write version |
| 3554 | p.writeInt32(4); |
| 3555 | |
| 3556 | int num = responselen / sizeof(RIL_Data_Call_Response_v4); |
| 3557 | p.writeInt32(num); |
| 3558 | |
| 3559 | RIL_Data_Call_Response_v4 *p_cur = (RIL_Data_Call_Response_v4 *) response; |
| 3560 | startResponse; |
| 3561 | int i; |
| 3562 | for (i = 0; i < num; i++) { |
| 3563 | p.writeInt32(p_cur[i].cid); |
| 3564 | p.writeInt32(p_cur[i].active); |
| 3565 | writeStringToParcel(p, p_cur[i].type); |
| 3566 | // apn is not used, so don't send. |
| 3567 | writeStringToParcel(p, p_cur[i].address); |
| 3568 | appendPrintBuf("%s[cid=%d,%s,%s,%s],", printBuf, |
| 3569 | p_cur[i].cid, |
| 3570 | (p_cur[i].active==0)?"down":"up", |
| 3571 | (char*)p_cur[i].type, |
| 3572 | (char*)p_cur[i].address); |
| 3573 | } |
| 3574 | removeLastChar; |
| 3575 | closeResponse; |
| 3576 | |
| 3577 | return 0; |
| 3578 | } |
| 3579 | |
| 3580 | static int responseDataCallListV6(Parcel &p, void *response, size_t responselen) |
| 3581 | { |
| 3582 | if (response == NULL && responselen != 0) { |
| 3583 | RLOGE("invalid response: NULL"); |
| 3584 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3585 | } |
| 3586 | |
| 3587 | if (responselen % sizeof(RIL_Data_Call_Response_v6) != 0) { |
| 3588 | RLOGE("responseDataCallListV6: invalid response length %d expected multiple of %d", |
| 3589 | (int)responselen, (int)sizeof(RIL_Data_Call_Response_v6)); |
| 3590 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3591 | } |
| 3592 | |
| 3593 | // Write version |
| 3594 | p.writeInt32(6); |
| 3595 | |
| 3596 | int num = responselen / sizeof(RIL_Data_Call_Response_v6); |
| 3597 | p.writeInt32(num); |
| 3598 | |
| 3599 | RIL_Data_Call_Response_v6 *p_cur = (RIL_Data_Call_Response_v6 *) response; |
| 3600 | startResponse; |
| 3601 | int i; |
| 3602 | for (i = 0; i < num; i++) { |
| 3603 | p.writeInt32((int)p_cur[i].status); |
| 3604 | p.writeInt32(p_cur[i].suggestedRetryTime); |
| 3605 | p.writeInt32(p_cur[i].cid); |
| 3606 | p.writeInt32(p_cur[i].active); |
| 3607 | writeStringToParcel(p, p_cur[i].type); |
| 3608 | writeStringToParcel(p, p_cur[i].ifname); |
| 3609 | writeStringToParcel(p, p_cur[i].addresses); |
| 3610 | writeStringToParcel(p, p_cur[i].dnses); |
| 3611 | writeStringToParcel(p, p_cur[i].gateways); |
| 3612 | appendPrintBuf("%s[status=%d,retry=%d,cid=%d,%s,%s,%s,%s,%s,%s],", printBuf, |
| 3613 | p_cur[i].status, |
| 3614 | p_cur[i].suggestedRetryTime, |
| 3615 | p_cur[i].cid, |
| 3616 | (p_cur[i].active==0)?"down":"up", |
| 3617 | (char*)p_cur[i].type, |
| 3618 | (char*)p_cur[i].ifname, |
| 3619 | (char*)p_cur[i].addresses, |
| 3620 | (char*)p_cur[i].dnses, |
| 3621 | (char*)p_cur[i].gateways); |
| 3622 | } |
| 3623 | removeLastChar; |
| 3624 | closeResponse; |
| 3625 | |
| 3626 | return 0; |
| 3627 | } |
| 3628 | |
| 3629 | static int responseDataCallListV9(Parcel &p, void *response, size_t responselen) |
| 3630 | { |
| 3631 | if (response == NULL && responselen != 0) { |
| 3632 | RLOGE("invalid response: NULL"); |
| 3633 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3634 | } |
| 3635 | |
| 3636 | if (responselen % sizeof(RIL_Data_Call_Response_v9) != 0) { |
| 3637 | RLOGE("responseDataCallListV9: invalid response length %d expected multiple of %d", |
| 3638 | (int)responselen, (int)sizeof(RIL_Data_Call_Response_v9)); |
| 3639 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3640 | } |
| 3641 | |
| 3642 | // Write version |
| 3643 | p.writeInt32(10); |
| 3644 | |
| 3645 | int num = responselen / sizeof(RIL_Data_Call_Response_v9); |
| 3646 | p.writeInt32(num); |
| 3647 | |
| 3648 | RIL_Data_Call_Response_v9 *p_cur = (RIL_Data_Call_Response_v9 *) response; |
| 3649 | startResponse; |
| 3650 | int i; |
| 3651 | for (i = 0; i < num; i++) { |
| 3652 | p.writeInt32((int)p_cur[i].status); |
| 3653 | p.writeInt32(p_cur[i].suggestedRetryTime); |
| 3654 | p.writeInt32(p_cur[i].cid); |
| 3655 | p.writeInt32(p_cur[i].active); |
| 3656 | writeStringToParcel(p, p_cur[i].type); |
| 3657 | writeStringToParcel(p, p_cur[i].ifname); |
| 3658 | writeStringToParcel(p, p_cur[i].addresses); |
| 3659 | writeStringToParcel(p, p_cur[i].dnses); |
| 3660 | writeStringToParcel(p, p_cur[i].gateways); |
| 3661 | writeStringToParcel(p, p_cur[i].pcscf); |
| 3662 | appendPrintBuf("%s[status=%d,retry=%d,cid=%d,%s,%s,%s,%s,%s,%s,%s],", printBuf, |
| 3663 | p_cur[i].status, |
| 3664 | p_cur[i].suggestedRetryTime, |
| 3665 | p_cur[i].cid, |
| 3666 | (p_cur[i].active==0)?"down":"up", |
| 3667 | (char*)p_cur[i].type, |
| 3668 | (char*)p_cur[i].ifname, |
| 3669 | (char*)p_cur[i].addresses, |
| 3670 | (char*)p_cur[i].dnses, |
| 3671 | (char*)p_cur[i].gateways, |
| 3672 | (char*)p_cur[i].pcscf); |
| 3673 | } |
| 3674 | removeLastChar; |
| 3675 | closeResponse; |
| 3676 | |
| 3677 | return 0; |
| 3678 | } |
| 3679 | |
| 3680 | static int responseDataCallListV11(Parcel &p, void *response, size_t responselen) { |
| 3681 | if (response == NULL && responselen != 0) { |
| 3682 | RLOGE("invalid response: NULL"); |
| 3683 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3684 | } |
| 3685 | |
| 3686 | if (responselen % sizeof(MTK_RIL_Data_Call_Response_v11) != 0) { |
| 3687 | RLOGE("invalid response length %d expected multiple of %d", |
| 3688 | (int)responselen, (int)sizeof(MTK_RIL_Data_Call_Response_v11)); |
| 3689 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3690 | } |
| 3691 | |
| 3692 | // Write version |
| 3693 | p.writeInt32(11); |
| 3694 | |
| 3695 | int num = responselen / sizeof(MTK_RIL_Data_Call_Response_v11); |
| 3696 | p.writeInt32(num); |
| 3697 | |
| 3698 | MTK_RIL_Data_Call_Response_v11 *p_cur = (MTK_RIL_Data_Call_Response_v11 *) response; |
| 3699 | startResponse; |
| 3700 | int i; |
| 3701 | for (i = 0; i < num; i++) { |
| 3702 | p.writeInt32((int)p_cur[i].status); |
| 3703 | p.writeInt32(p_cur[i].suggestedRetryTime); |
| 3704 | p.writeInt32(p_cur[i].cid); |
| 3705 | p.writeInt32(p_cur[i].active); |
| 3706 | writeStringToParcel(p, p_cur[i].type); |
| 3707 | writeStringToParcel(p, p_cur[i].ifname); |
| 3708 | writeStringToParcel(p, p_cur[i].addresses); |
| 3709 | writeStringToParcel(p, p_cur[i].dnses); |
| 3710 | writeStringToParcel(p, p_cur[i].gateways); |
| 3711 | writeStringToParcel(p, p_cur[i].pcscf); |
| 3712 | p.writeInt32(p_cur[i].mtu); |
| 3713 | p.writeInt32(p_cur[i].rat); |
| 3714 | appendPrintBuf("%s[status=%d,retry=%d,cid=%d,%s,%s,%s,%s,%s,%s,%s,%d,rat=%d],", printBuf, |
| 3715 | p_cur[i].status, |
| 3716 | p_cur[i].suggestedRetryTime, |
| 3717 | p_cur[i].cid, |
| 3718 | (p_cur[i].active==0)?"down":"up", |
| 3719 | (char*)p_cur[i].type, |
| 3720 | (char*)p_cur[i].ifname, |
| 3721 | (char*)p_cur[i].addresses, |
| 3722 | (char*)p_cur[i].dnses, |
| 3723 | (char*)p_cur[i].gateways, |
| 3724 | (char*)p_cur[i].pcscf, |
| 3725 | p_cur[i].mtu, |
| 3726 | p_cur[i].rat); |
| 3727 | } |
| 3728 | removeLastChar; |
| 3729 | closeResponse; |
| 3730 | |
| 3731 | return 0; |
| 3732 | } |
| 3733 | |
| 3734 | static int responseDataCallList(Parcel &p, void *response, size_t responselen) |
| 3735 | { |
| 3736 | if (s_callbacks.version <= LAST_IMPRECISE_RIL_VERSION) { |
| 3737 | if (s_callbacks.version < 5) { |
| 3738 | RLOGD("responseDataCallList: v4"); |
| 3739 | return responseDataCallListV4(p, response, responselen); |
| 3740 | } else if (responselen % sizeof(RIL_Data_Call_Response_v6) == 0) { |
| 3741 | return responseDataCallListV6(p, response, responselen); |
| 3742 | } else if (responselen % sizeof(RIL_Data_Call_Response_v9) == 0) { |
| 3743 | return responseDataCallListV9(p, response, responselen); |
| 3744 | } else { |
| 3745 | return responseDataCallListV11(p, response, responselen); |
| 3746 | } |
| 3747 | } else { // RIL version >= 13 |
| 3748 | if (responselen % sizeof(MTK_RIL_Data_Call_Response_v11) != 0) { |
| 3749 | RLOGE("Data structure expected is MTK_RIL_Data_Call_Response_v11"); |
| 3750 | if (!isDebuggable()) { |
| 3751 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3752 | } else { |
| 3753 | assert(0); |
| 3754 | } |
| 3755 | } |
| 3756 | return responseDataCallListV11(p, response, responselen); |
| 3757 | } |
| 3758 | } |
| 3759 | |
| 3760 | static int responseSetupDataCall(Parcel &p, void *response, size_t responselen) |
| 3761 | { |
| 3762 | if (s_callbacks.version < 5) { |
| 3763 | return responseStringsWithVersion(s_callbacks.version, p, response, responselen); |
| 3764 | } else { |
| 3765 | return responseDataCallList(p, response, responselen); |
| 3766 | } |
| 3767 | } |
| 3768 | |
| 3769 | static int responseRaw(Parcel &p, void *response, size_t responselen) { |
| 3770 | if (response == NULL && responselen != 0) { |
| 3771 | RLOGE("invalid response: NULL with responselen != 0"); |
| 3772 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3773 | } |
| 3774 | |
| 3775 | // The java code reads -1 size as null byte array |
| 3776 | if (response == NULL) { |
| 3777 | p.writeInt32(-1); |
| 3778 | } else { |
| 3779 | p.writeInt32(responselen); |
| 3780 | p.write(response, responselen); |
| 3781 | } |
| 3782 | |
| 3783 | return 0; |
| 3784 | } |
| 3785 | |
| 3786 | |
| 3787 | static int responseSIM_IO(Parcel &p, void *response, size_t responselen) { |
| 3788 | if (response == NULL) { |
| 3789 | RLOGE("invalid response: NULL"); |
| 3790 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3791 | } |
| 3792 | |
| 3793 | if (responselen != sizeof (RIL_SIM_IO_Response) ) { |
| 3794 | RLOGE("invalid response length was %d expected %d", |
| 3795 | (int)responselen, (int)sizeof (RIL_SIM_IO_Response)); |
| 3796 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3797 | } |
| 3798 | |
| 3799 | RIL_SIM_IO_Response *p_cur = (RIL_SIM_IO_Response *) response; |
| 3800 | p.writeInt32(p_cur->sw1); |
| 3801 | p.writeInt32(p_cur->sw2); |
| 3802 | writeStringToParcel(p, p_cur->simResponse); |
| 3803 | |
| 3804 | startResponse; |
| 3805 | appendPrintBuf("%ssw1=0x%X,sw2=0x%X,%s", printBuf, p_cur->sw1, p_cur->sw2, |
| 3806 | (char*)p_cur->simResponse); |
| 3807 | closeResponse; |
| 3808 | |
| 3809 | |
| 3810 | return 0; |
| 3811 | } |
| 3812 | |
| 3813 | static int responseCallForwards(Parcel &p, void *response, size_t responselen) { |
| 3814 | int num; |
| 3815 | |
| 3816 | if (response == NULL && responselen != 0) { |
| 3817 | RLOGE("invalid response: NULL"); |
| 3818 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3819 | } |
| 3820 | |
| 3821 | if (responselen % sizeof(RIL_CallForwardInfo *) != 0) { |
| 3822 | RLOGE("responseCallForwards: invalid response length %d expected multiple of %d", |
| 3823 | (int)responselen, (int)sizeof(RIL_CallForwardInfo *)); |
| 3824 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3825 | } |
| 3826 | |
| 3827 | /* number of call info's */ |
| 3828 | num = responselen / sizeof(RIL_CallForwardInfo *); |
| 3829 | p.writeInt32(num); |
| 3830 | |
| 3831 | startResponse; |
| 3832 | for (int i = 0 ; i < num ; i++) { |
| 3833 | RIL_CallForwardInfo *p_cur = ((RIL_CallForwardInfo **) response)[i]; |
| 3834 | |
| 3835 | p.writeInt32(p_cur->status); |
| 3836 | p.writeInt32(p_cur->reason); |
| 3837 | p.writeInt32(p_cur->serviceClass); |
| 3838 | p.writeInt32(p_cur->toa); |
| 3839 | writeStringToParcel(p, p_cur->number); |
| 3840 | p.writeInt32(p_cur->timeSeconds); |
| 3841 | appendPrintBuf("%s[%s,reason=%d,cls=%d,toa=%d,%s,tout=%d],", printBuf, |
| 3842 | (p_cur->status==1)?"enable":"disable", |
| 3843 | p_cur->reason, p_cur->serviceClass, p_cur->toa, |
| 3844 | (char*)p_cur->number, |
| 3845 | p_cur->timeSeconds); |
| 3846 | } |
| 3847 | removeLastChar; |
| 3848 | closeResponse; |
| 3849 | |
| 3850 | return 0; |
| 3851 | } |
| 3852 | |
| 3853 | static int responseCallForwardsEx(Parcel &p, void *response, size_t responselen) { |
| 3854 | int num; |
| 3855 | |
| 3856 | if (response == NULL && responselen != 0) { |
| 3857 | RLOGE("invalid response: NULL"); |
| 3858 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3859 | } |
| 3860 | |
| 3861 | if (responselen % sizeof(RIL_CallForwardInfoEx *) != 0) { |
| 3862 | RLOGE("responseCallForwardsEx: invalid response length %d expected multiple of %d", |
| 3863 | (int)responselen, (int)sizeof(RIL_CallForwardInfoEx *)); |
| 3864 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3865 | } |
| 3866 | |
| 3867 | /* number of call info's */ |
| 3868 | num = responselen / sizeof(RIL_CallForwardInfoEx *); |
| 3869 | p.writeInt32(num); |
| 3870 | |
| 3871 | startResponse; |
| 3872 | for (int i = 0 ; i < num ; i++) { |
| 3873 | RIL_CallForwardInfoEx *p_cur = ((RIL_CallForwardInfoEx **) response)[i]; |
| 3874 | |
| 3875 | p.writeInt32(p_cur->status); |
| 3876 | p.writeInt32(p_cur->reason); |
| 3877 | p.writeInt32(p_cur->serviceClass); |
| 3878 | p.writeInt32(p_cur->toa); |
| 3879 | writeStringToParcel(p, p_cur->number); |
| 3880 | p.writeInt32(p_cur->timeSeconds); |
| 3881 | |
| 3882 | writeStringToParcel(p, p_cur->timeSlotBegin); |
| 3883 | writeStringToParcel(p, p_cur->timeSlotEnd); |
| 3884 | |
| 3885 | appendPrintBuf("%s[%s,reason=%d,cls=%d,toa=%d,%s,tout=%d,timeSlot=%s,%s],", printBuf, |
| 3886 | (p_cur->status==1)?"enable":"disable", |
| 3887 | p_cur->reason, p_cur->serviceClass, p_cur->toa, |
| 3888 | (char*)p_cur->number, |
| 3889 | p_cur->timeSeconds, |
| 3890 | p_cur->timeSlotBegin, |
| 3891 | p_cur->timeSlotEnd); |
| 3892 | } |
| 3893 | removeLastChar; |
| 3894 | closeResponse; |
| 3895 | |
| 3896 | return 0; |
| 3897 | } |
| 3898 | |
| 3899 | static int responseSsn(Parcel &p, void *response, size_t responselen) { |
| 3900 | if (response == NULL) { |
| 3901 | RLOGE("invalid response: NULL"); |
| 3902 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3903 | } |
| 3904 | |
| 3905 | if (responselen != sizeof(RIL_SuppSvcNotification)) { |
| 3906 | RLOGE("invalid response length was %d expected %d", |
| 3907 | (int)responselen, (int)sizeof (RIL_SuppSvcNotification)); |
| 3908 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3909 | } |
| 3910 | |
| 3911 | RIL_SuppSvcNotification *p_cur = (RIL_SuppSvcNotification *) response; |
| 3912 | p.writeInt32(p_cur->notificationType); |
| 3913 | p.writeInt32(p_cur->code); |
| 3914 | p.writeInt32(p_cur->index); |
| 3915 | p.writeInt32(p_cur->type); |
| 3916 | writeStringToParcel(p, p_cur->number); |
| 3917 | |
| 3918 | startResponse; |
| 3919 | appendPrintBuf("%s%s,code=%d,id=%d,type=%d,%s", printBuf, |
| 3920 | (p_cur->notificationType==0)?"mo":"mt", |
| 3921 | p_cur->code, p_cur->index, p_cur->type, |
| 3922 | (char*)p_cur->number); |
| 3923 | closeResponse; |
| 3924 | |
| 3925 | return 0; |
| 3926 | } |
| 3927 | |
| 3928 | static int responseCellList(Parcel &p, void *response, size_t responselen) { |
| 3929 | int num; |
| 3930 | |
| 3931 | if (response == NULL && responselen != 0) { |
| 3932 | RLOGE("invalid response: NULL"); |
| 3933 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3934 | } |
| 3935 | |
| 3936 | if (responselen % sizeof (RIL_NeighboringCell *) != 0) { |
| 3937 | RLOGE("responseCellList: invalid response length %d expected multiple of %d\n", |
| 3938 | (int)responselen, (int)sizeof (RIL_NeighboringCell *)); |
| 3939 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3940 | } |
| 3941 | |
| 3942 | startResponse; |
| 3943 | /* number of records */ |
| 3944 | num = responselen / sizeof(RIL_NeighboringCell *); |
| 3945 | p.writeInt32(num); |
| 3946 | |
| 3947 | for (int i = 0 ; i < num ; i++) { |
| 3948 | RIL_NeighboringCell *p_cur = ((RIL_NeighboringCell **) response)[i]; |
| 3949 | |
| 3950 | p.writeInt32(p_cur->rssi); |
| 3951 | writeStringToParcel (p, p_cur->cid); |
| 3952 | |
| 3953 | appendPrintBuf("%s[cid=%s,rssi=%d],", printBuf, |
| 3954 | p_cur->cid, p_cur->rssi); |
| 3955 | } |
| 3956 | removeLastChar; |
| 3957 | closeResponse; |
| 3958 | |
| 3959 | return 0; |
| 3960 | } |
| 3961 | |
| 3962 | /** |
| 3963 | * Marshall the signalInfoRecord into the parcel if it exists. |
| 3964 | */ |
| 3965 | static void marshallSignalInfoRecord(Parcel &p, |
| 3966 | RIL_CDMA_SignalInfoRecord &p_signalInfoRecord) { |
| 3967 | p.writeInt32(p_signalInfoRecord.isPresent); |
| 3968 | p.writeInt32(p_signalInfoRecord.signalType); |
| 3969 | p.writeInt32(p_signalInfoRecord.alertPitch); |
| 3970 | p.writeInt32(p_signalInfoRecord.signal); |
| 3971 | } |
| 3972 | |
| 3973 | static int responseCdmaInformationRecords(Parcel &p, |
| 3974 | void *response, size_t responselen) { |
| 3975 | int num; |
| 3976 | char* string8 = NULL; |
| 3977 | int buffer_lenght; |
| 3978 | RIL_CDMA_InformationRecord *infoRec; |
| 3979 | |
| 3980 | if (response == NULL && responselen != 0) { |
| 3981 | RLOGE("invalid response: NULL"); |
| 3982 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3983 | } |
| 3984 | |
| 3985 | if (responselen != sizeof (RIL_CDMA_InformationRecords)) { |
| 3986 | RLOGE("responseCdmaInformationRecords: invalid response length %d expected multiple of %d\n", |
| 3987 | (int)responselen, (int)sizeof (RIL_CDMA_InformationRecords *)); |
| 3988 | return RIL_ERRNO_INVALID_RESPONSE; |
| 3989 | } |
| 3990 | |
| 3991 | RIL_CDMA_InformationRecords *p_cur = |
| 3992 | (RIL_CDMA_InformationRecords *) response; |
| 3993 | num = MIN(p_cur->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS); |
| 3994 | |
| 3995 | startResponse; |
| 3996 | p.writeInt32(num); |
| 3997 | |
| 3998 | for (int i = 0 ; i < num ; i++) { |
| 3999 | infoRec = &p_cur->infoRec[i]; |
| 4000 | p.writeInt32(infoRec->name); |
| 4001 | switch (infoRec->name) { |
| 4002 | case RIL_CDMA_DISPLAY_INFO_REC: |
| 4003 | case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: |
| 4004 | if (infoRec->rec.display.alpha_len > |
| 4005 | CDMA_ALPHA_INFO_BUFFER_LENGTH) { |
| 4006 | RLOGE("invalid display info response length %d \ |
| 4007 | expected not more than %d\n", |
| 4008 | (int)infoRec->rec.display.alpha_len, |
| 4009 | CDMA_ALPHA_INFO_BUFFER_LENGTH); |
| 4010 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4011 | } |
| 4012 | string8 = (char*) calloc(infoRec->rec.display.alpha_len + 1, sizeof(char)); |
| 4013 | if (string8 == NULL) { |
| 4014 | RLOGE("Memory allocation failed for responseCdmaInformationRecords"); |
| 4015 | closeRequest; |
| 4016 | return RIL_ERRNO_NO_MEMORY; |
| 4017 | } |
| 4018 | for (int i = 0 ; i < infoRec->rec.display.alpha_len ; i++) { |
| 4019 | string8[i] = infoRec->rec.display.alpha_buf[i]; |
| 4020 | } |
| 4021 | string8[(int)infoRec->rec.display.alpha_len] = '\0'; |
| 4022 | writeStringToParcel(p, (const char*)string8); |
| 4023 | free(string8); |
| 4024 | string8 = NULL; |
| 4025 | break; |
| 4026 | case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC: |
| 4027 | case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC: |
| 4028 | case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: |
| 4029 | if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) { |
| 4030 | RLOGE("invalid display info response length %d \ |
| 4031 | expected not more than %d\n", |
| 4032 | (int)infoRec->rec.number.len, |
| 4033 | CDMA_NUMBER_INFO_BUFFER_LENGTH); |
| 4034 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4035 | } |
| 4036 | string8 = (char*) calloc(infoRec->rec.number.len + 1, sizeof(char)); |
| 4037 | if (string8 == NULL) { |
| 4038 | RLOGE("Memory allocation failed for responseCdmaInformationRecords"); |
| 4039 | closeRequest; |
| 4040 | return RIL_ERRNO_NO_MEMORY; |
| 4041 | } |
| 4042 | for (int i = 0 ; i < infoRec->rec.number.len; i++) { |
| 4043 | string8[i] = infoRec->rec.number.buf[i]; |
| 4044 | } |
| 4045 | string8[(int)infoRec->rec.number.len] = '\0'; |
| 4046 | writeStringToParcel(p, (const char*)string8); |
| 4047 | free(string8); |
| 4048 | string8 = NULL; |
| 4049 | p.writeInt32(infoRec->rec.number.number_type); |
| 4050 | p.writeInt32(infoRec->rec.number.number_plan); |
| 4051 | p.writeInt32(infoRec->rec.number.pi); |
| 4052 | p.writeInt32(infoRec->rec.number.si); |
| 4053 | break; |
| 4054 | case RIL_CDMA_SIGNAL_INFO_REC: |
| 4055 | p.writeInt32(infoRec->rec.signal.isPresent); |
| 4056 | p.writeInt32(infoRec->rec.signal.signalType); |
| 4057 | p.writeInt32(infoRec->rec.signal.alertPitch); |
| 4058 | p.writeInt32(infoRec->rec.signal.signal); |
| 4059 | |
| 4060 | appendPrintBuf("%sisPresent=%X, signalType=%X, \ |
| 4061 | alertPitch=%X, signal=%X, ", |
| 4062 | printBuf, (int)infoRec->rec.signal.isPresent, |
| 4063 | (int)infoRec->rec.signal.signalType, |
| 4064 | (int)infoRec->rec.signal.alertPitch, |
| 4065 | (int)infoRec->rec.signal.signal); |
| 4066 | removeLastChar; |
| 4067 | break; |
| 4068 | case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: |
| 4069 | if (infoRec->rec.redir.redirectingNumber.len > |
| 4070 | CDMA_NUMBER_INFO_BUFFER_LENGTH) { |
| 4071 | RLOGE("invalid display info response length %d \ |
| 4072 | expected not more than %d\n", |
| 4073 | (int)infoRec->rec.redir.redirectingNumber.len, |
| 4074 | CDMA_NUMBER_INFO_BUFFER_LENGTH); |
| 4075 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4076 | } |
| 4077 | string8 = (char*) calloc(infoRec->rec.redir.redirectingNumber.len + 1, |
| 4078 | sizeof(char)); |
| 4079 | if (string8 == NULL) { |
| 4080 | RLOGE("Memory allocation failed for responseCdmaInformationRecords"); |
| 4081 | closeRequest; |
| 4082 | return RIL_ERRNO_NO_MEMORY; |
| 4083 | } |
| 4084 | for (int i = 0; |
| 4085 | i < infoRec->rec.redir.redirectingNumber.len; |
| 4086 | i++) { |
| 4087 | string8[i] = infoRec->rec.redir.redirectingNumber.buf[i]; |
| 4088 | } |
| 4089 | string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0'; |
| 4090 | writeStringToParcel(p, (const char*)string8); |
| 4091 | free(string8); |
| 4092 | string8 = NULL; |
| 4093 | p.writeInt32(infoRec->rec.redir.redirectingNumber.number_type); |
| 4094 | p.writeInt32(infoRec->rec.redir.redirectingNumber.number_plan); |
| 4095 | p.writeInt32(infoRec->rec.redir.redirectingNumber.pi); |
| 4096 | p.writeInt32(infoRec->rec.redir.redirectingNumber.si); |
| 4097 | p.writeInt32(infoRec->rec.redir.redirectingReason); |
| 4098 | break; |
| 4099 | case RIL_CDMA_LINE_CONTROL_INFO_REC: |
| 4100 | p.writeInt32(infoRec->rec.lineCtrl.lineCtrlPolarityIncluded); |
| 4101 | p.writeInt32(infoRec->rec.lineCtrl.lineCtrlToggle); |
| 4102 | p.writeInt32(infoRec->rec.lineCtrl.lineCtrlReverse); |
| 4103 | p.writeInt32(infoRec->rec.lineCtrl.lineCtrlPowerDenial); |
| 4104 | |
| 4105 | appendPrintBuf("%slineCtrlPolarityIncluded=%d, \ |
| 4106 | lineCtrlToggle=%d, lineCtrlReverse=%d, \ |
| 4107 | lineCtrlPowerDenial=%d, ", printBuf, |
| 4108 | (int)infoRec->rec.lineCtrl.lineCtrlPolarityIncluded, |
| 4109 | (int)infoRec->rec.lineCtrl.lineCtrlToggle, |
| 4110 | (int)infoRec->rec.lineCtrl.lineCtrlReverse, |
| 4111 | (int)infoRec->rec.lineCtrl.lineCtrlPowerDenial); |
| 4112 | removeLastChar; |
| 4113 | break; |
| 4114 | case RIL_CDMA_T53_CLIR_INFO_REC: |
| 4115 | p.writeInt32((int)(infoRec->rec.clir.cause)); |
| 4116 | |
| 4117 | appendPrintBuf("%scause%d", printBuf, infoRec->rec.clir.cause); |
| 4118 | removeLastChar; |
| 4119 | break; |
| 4120 | case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: |
| 4121 | p.writeInt32(infoRec->rec.audioCtrl.upLink); |
| 4122 | p.writeInt32(infoRec->rec.audioCtrl.downLink); |
| 4123 | |
| 4124 | appendPrintBuf("%supLink=%d, downLink=%d, ", printBuf, |
| 4125 | infoRec->rec.audioCtrl.upLink, |
| 4126 | infoRec->rec.audioCtrl.downLink); |
| 4127 | removeLastChar; |
| 4128 | break; |
| 4129 | case RIL_CDMA_T53_RELEASE_INFO_REC: |
| 4130 | // TODO(Moto): See David Krause, he has the answer:) |
| 4131 | RLOGE("RIL_CDMA_T53_RELEASE_INFO_REC: return INVALID_RESPONSE"); |
| 4132 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4133 | default: |
| 4134 | RLOGE("Incorrect name value"); |
| 4135 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4136 | } |
| 4137 | } |
| 4138 | closeResponse; |
| 4139 | |
| 4140 | return 0; |
| 4141 | } |
| 4142 | |
| 4143 | static void responseRilSignalStrengthV5(Parcel &p, RIL_SignalStrength_v10 *p_cur) { |
| 4144 | p.writeInt32(p_cur->GW_SignalStrength.signalStrength); |
| 4145 | p.writeInt32(p_cur->GW_SignalStrength.bitErrorRate); |
| 4146 | p.writeInt32(p_cur->CDMA_SignalStrength.dbm); |
| 4147 | p.writeInt32(p_cur->CDMA_SignalStrength.ecio); |
| 4148 | p.writeInt32(p_cur->EVDO_SignalStrength.dbm); |
| 4149 | p.writeInt32(p_cur->EVDO_SignalStrength.ecio); |
| 4150 | p.writeInt32(p_cur->EVDO_SignalStrength.signalNoiseRatio); |
| 4151 | } |
| 4152 | |
| 4153 | static void responseRilSignalStrengthV6Extra(Parcel &p, RIL_SignalStrength_v10 *p_cur) { |
| 4154 | /* |
| 4155 | * Fixup LTE for backwards compatibility |
| 4156 | */ |
| 4157 | // signalStrength: -1 -> 99 |
| 4158 | if (p_cur->LTE_SignalStrength.signalStrength == -1) { |
| 4159 | p_cur->LTE_SignalStrength.signalStrength = 99; |
| 4160 | } |
| 4161 | // rsrp: -1 -> INT_MAX all other negative value to positive. |
| 4162 | // So remap here |
| 4163 | if (p_cur->LTE_SignalStrength.rsrp == -1) { |
| 4164 | p_cur->LTE_SignalStrength.rsrp = INT_MAX; |
| 4165 | } else if (p_cur->LTE_SignalStrength.rsrp < -1) { |
| 4166 | p_cur->LTE_SignalStrength.rsrp = -p_cur->LTE_SignalStrength.rsrp; |
| 4167 | } |
| 4168 | // rsrq: -1 -> INT_MAX |
| 4169 | if (p_cur->LTE_SignalStrength.rsrq == -1) { |
| 4170 | p_cur->LTE_SignalStrength.rsrq = INT_MAX; |
| 4171 | } |
| 4172 | // Not remapping rssnr is already using INT_MAX |
| 4173 | |
| 4174 | // cqi: -1 -> INT_MAX |
| 4175 | if (p_cur->LTE_SignalStrength.cqi == -1) { |
| 4176 | p_cur->LTE_SignalStrength.cqi = INT_MAX; |
| 4177 | } |
| 4178 | |
| 4179 | p.writeInt32(p_cur->LTE_SignalStrength.signalStrength); |
| 4180 | p.writeInt32(p_cur->LTE_SignalStrength.rsrp); |
| 4181 | p.writeInt32(p_cur->LTE_SignalStrength.rsrq); |
| 4182 | p.writeInt32(p_cur->LTE_SignalStrength.rssnr); |
| 4183 | p.writeInt32(p_cur->LTE_SignalStrength.cqi); |
| 4184 | } |
| 4185 | |
| 4186 | static void responseRilSignalStrengthV10(Parcel &p, RIL_SignalStrength_v10 *p_cur) { |
| 4187 | responseRilSignalStrengthV5(p, p_cur); |
| 4188 | responseRilSignalStrengthV6Extra(p, p_cur); |
| 4189 | p.writeInt32(p_cur->TD_SCDMA_SignalStrength.rscp); |
| 4190 | } |
| 4191 | |
| 4192 | static int responseRilSignalStrength(Parcel &p, |
| 4193 | void *response, size_t responselen) { |
| 4194 | if (response == NULL && responselen != 0) { |
| 4195 | RLOGE("invalid response: NULL"); |
| 4196 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4197 | } |
| 4198 | |
| 4199 | RIL_SignalStrength_v10 *p_cur; |
| 4200 | if (s_callbacks.version <= LAST_IMPRECISE_RIL_VERSION) { |
| 4201 | if (responselen >= sizeof (RIL_SignalStrength_v5)) { |
| 4202 | p_cur = ((RIL_SignalStrength_v10 *) response); |
| 4203 | |
| 4204 | responseRilSignalStrengthV5(p, p_cur); |
| 4205 | |
| 4206 | if (responselen >= sizeof (RIL_SignalStrength_v6)) { |
| 4207 | responseRilSignalStrengthV6Extra(p, p_cur); |
| 4208 | if (responselen >= sizeof (RIL_SignalStrength_v10)) { |
| 4209 | p.writeInt32(p_cur->TD_SCDMA_SignalStrength.rscp); |
| 4210 | } else { |
| 4211 | p.writeInt32(INT_MAX); |
| 4212 | } |
| 4213 | } else { |
| 4214 | p.writeInt32(99); |
| 4215 | p.writeInt32(INT_MAX); |
| 4216 | p.writeInt32(INT_MAX); |
| 4217 | p.writeInt32(INT_MAX); |
| 4218 | p.writeInt32(INT_MAX); |
| 4219 | p.writeInt32(INT_MAX); |
| 4220 | } |
| 4221 | } else { |
| 4222 | RLOGE("invalid response length"); |
| 4223 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4224 | } |
| 4225 | } else { // RIL version >= 13 |
| 4226 | if (responselen % sizeof(RIL_SignalStrength_v10) != 0) { |
| 4227 | RLOGE("Data structure expected is RIL_SignalStrength_v10"); |
| 4228 | if (!isDebuggable()) { |
| 4229 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4230 | } else { |
| 4231 | assert(0); |
| 4232 | } |
| 4233 | } |
| 4234 | p_cur = ((RIL_SignalStrength_v10 *) response); |
| 4235 | responseRilSignalStrengthV10(p, p_cur); |
| 4236 | } |
| 4237 | startResponse; |
| 4238 | appendPrintBuf("%s[signalStrength=%d,bitErrorRate=%d,\ |
| 4239 | CDMA_SS.dbm=%d,CDMA_SSecio=%d,\ |
| 4240 | EVDO_SS.dbm=%d,EVDO_SS.ecio=%d,\ |
| 4241 | EVDO_SS.signalNoiseRatio=%d,\ |
| 4242 | LTE_SS.signalStrength=%d,LTE_SS.rsrp=%d,LTE_SS.rsrq=%d,\ |
| 4243 | LTE_SS.rssnr=%d,LTE_SS.cqi=%d,TDSCDMA_SS.rscp=%d]", |
| 4244 | printBuf, |
| 4245 | p_cur->GW_SignalStrength.signalStrength, |
| 4246 | p_cur->GW_SignalStrength.bitErrorRate, |
| 4247 | p_cur->CDMA_SignalStrength.dbm, |
| 4248 | p_cur->CDMA_SignalStrength.ecio, |
| 4249 | p_cur->EVDO_SignalStrength.dbm, |
| 4250 | p_cur->EVDO_SignalStrength.ecio, |
| 4251 | p_cur->EVDO_SignalStrength.signalNoiseRatio, |
| 4252 | p_cur->LTE_SignalStrength.signalStrength, |
| 4253 | p_cur->LTE_SignalStrength.rsrp, |
| 4254 | p_cur->LTE_SignalStrength.rsrq, |
| 4255 | p_cur->LTE_SignalStrength.rssnr, |
| 4256 | p_cur->LTE_SignalStrength.cqi, |
| 4257 | p_cur->TD_SCDMA_SignalStrength.rscp); |
| 4258 | closeResponse; |
| 4259 | return 0; |
| 4260 | } |
| 4261 | |
| 4262 | static int responseCallRing(Parcel &p, void *response, size_t responselen) { |
| 4263 | if ((response == NULL) || (responselen == 0)) { |
| 4264 | return responseVoid(p, response, responselen); |
| 4265 | } else { |
| 4266 | return responseCdmaSignalInfoRecord(p, response, responselen); |
| 4267 | } |
| 4268 | } |
| 4269 | |
| 4270 | static int responseCdmaSignalInfoRecord(Parcel &p, void *response, size_t responselen) { |
| 4271 | if (response == NULL || responselen == 0) { |
| 4272 | RLOGE("invalid response: NULL"); |
| 4273 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4274 | } |
| 4275 | |
| 4276 | if (responselen != sizeof (RIL_CDMA_SignalInfoRecord)) { |
| 4277 | RLOGE("invalid response length %d expected sizeof (RIL_CDMA_SignalInfoRecord) of %d\n", |
| 4278 | (int)responselen, (int)sizeof (RIL_CDMA_SignalInfoRecord)); |
| 4279 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4280 | } |
| 4281 | |
| 4282 | startResponse; |
| 4283 | |
| 4284 | RIL_CDMA_SignalInfoRecord *p_cur = ((RIL_CDMA_SignalInfoRecord *) response); |
| 4285 | marshallSignalInfoRecord(p, *p_cur); |
| 4286 | |
| 4287 | appendPrintBuf("%s[isPresent=%d,signalType=%d,alertPitch=%d\ |
| 4288 | signal=%d]", |
| 4289 | printBuf, |
| 4290 | p_cur->isPresent, |
| 4291 | p_cur->signalType, |
| 4292 | p_cur->alertPitch, |
| 4293 | p_cur->signal); |
| 4294 | |
| 4295 | closeResponse; |
| 4296 | return 0; |
| 4297 | } |
| 4298 | |
| 4299 | static int responseCdmaCallWaiting(Parcel &p, void *response, |
| 4300 | size_t responselen) { |
| 4301 | if (response == NULL && responselen != 0) { |
| 4302 | RLOGE("invalid response: NULL"); |
| 4303 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4304 | } |
| 4305 | |
| 4306 | if (responselen < sizeof(RIL_CDMA_CallWaiting_v6)) { |
| 4307 | RLOGW("Upgrade to ril version %d\n", RIL_VERSION); |
| 4308 | } |
| 4309 | |
| 4310 | RIL_CDMA_CallWaiting_v6 *p_cur = ((RIL_CDMA_CallWaiting_v6 *) response); |
| 4311 | |
| 4312 | writeStringToParcel(p, p_cur->number); |
| 4313 | p.writeInt32(p_cur->numberPresentation); |
| 4314 | writeStringToParcel(p, p_cur->name); |
| 4315 | marshallSignalInfoRecord(p, p_cur->signalInfoRecord); |
| 4316 | |
| 4317 | if (s_callbacks.version <= LAST_IMPRECISE_RIL_VERSION) { |
| 4318 | if (responselen >= sizeof(RIL_CDMA_CallWaiting_v6)) { |
| 4319 | p.writeInt32(p_cur->number_type); |
| 4320 | p.writeInt32(p_cur->number_plan); |
| 4321 | } else { |
| 4322 | p.writeInt32(0); |
| 4323 | p.writeInt32(0); |
| 4324 | } |
| 4325 | } else { // RIL version >= 13 |
| 4326 | if (responselen % sizeof(RIL_CDMA_CallWaiting_v6) != 0) { |
| 4327 | RLOGE("Data structure expected is RIL_CDMA_CallWaiting_v6"); |
| 4328 | if (!isDebuggable()) { |
| 4329 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4330 | } else { |
| 4331 | assert(0); |
| 4332 | } |
| 4333 | } |
| 4334 | p.writeInt32(p_cur->number_type); |
| 4335 | p.writeInt32(p_cur->number_plan); |
| 4336 | } |
| 4337 | |
| 4338 | startResponse; |
| 4339 | appendPrintBuf("%snumber=%s,numberPresentation=%d, name=%s,\ |
| 4340 | signalInfoRecord[isPresent=%d,signalType=%d,alertPitch=%d\ |
| 4341 | signal=%d,number_type=%d,number_plan=%d]", |
| 4342 | printBuf, |
| 4343 | p_cur->number, |
| 4344 | p_cur->numberPresentation, |
| 4345 | p_cur->name, |
| 4346 | p_cur->signalInfoRecord.isPresent, |
| 4347 | p_cur->signalInfoRecord.signalType, |
| 4348 | p_cur->signalInfoRecord.alertPitch, |
| 4349 | p_cur->signalInfoRecord.signal, |
| 4350 | p_cur->number_type, |
| 4351 | p_cur->number_plan); |
| 4352 | closeResponse; |
| 4353 | |
| 4354 | return 0; |
| 4355 | } |
| 4356 | |
| 4357 | static void responseSimRefreshV7(Parcel &p, void *response) { |
| 4358 | RIL_SimRefreshResponse_v7 *p_cur = ((RIL_SimRefreshResponse_v7 *) response); |
| 4359 | p.writeInt32(p_cur->result); |
| 4360 | p.writeInt32(p_cur->ef_id); |
| 4361 | writeStringToParcel(p, p_cur->aid); |
| 4362 | |
| 4363 | appendPrintBuf("%sresult=%d, ef_id=%d, aid=%s", |
| 4364 | printBuf, |
| 4365 | p_cur->result, |
| 4366 | p_cur->ef_id, |
| 4367 | p_cur->aid); |
| 4368 | |
| 4369 | } |
| 4370 | |
| 4371 | static int responseSimRefresh(Parcel &p, void *response, size_t responselen) { |
| 4372 | if (response == NULL && responselen != 0) { |
| 4373 | RLOGE("responseSimRefresh: invalid response: NULL"); |
| 4374 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4375 | } |
| 4376 | |
| 4377 | startResponse; |
| 4378 | if (s_callbacks.version <= LAST_IMPRECISE_RIL_VERSION) { |
| 4379 | if (s_callbacks.version >= 7) { |
| 4380 | responseSimRefreshV7(p, response); |
| 4381 | } else { |
| 4382 | int *p_cur = ((int *) response); |
| 4383 | p.writeInt32(p_cur[0]); |
| 4384 | p.writeInt32(p_cur[1]); |
| 4385 | writeStringToParcel(p, NULL); |
| 4386 | |
| 4387 | appendPrintBuf("%sresult=%d, ef_id=%d", |
| 4388 | printBuf, |
| 4389 | p_cur[0], |
| 4390 | p_cur[1]); |
| 4391 | } |
| 4392 | } else { // RIL version >= 13 |
| 4393 | if (responselen % sizeof(RIL_SimRefreshResponse_v7) != 0) { |
| 4394 | RLOGE("Data structure expected is RIL_SimRefreshResponse_v7"); |
| 4395 | if (!isDebuggable()) { |
| 4396 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4397 | } else { |
| 4398 | assert(0); |
| 4399 | } |
| 4400 | } |
| 4401 | responseSimRefreshV7(p, response); |
| 4402 | |
| 4403 | } |
| 4404 | closeResponse; |
| 4405 | |
| 4406 | return 0; |
| 4407 | } |
| 4408 | |
| 4409 | static int responseCellInfoListV6(Parcel &p, void *response, size_t responselen) { |
| 4410 | if (response == NULL && responselen != 0) { |
| 4411 | RLOGE("invalid response: NULL"); |
| 4412 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4413 | } |
| 4414 | |
| 4415 | if (responselen % sizeof(RIL_CellInfo) != 0) { |
| 4416 | RLOGE("responseCellInfoList: invalid response length %d expected multiple of %d", |
| 4417 | (int)responselen, (int)sizeof(RIL_CellInfo)); |
| 4418 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4419 | } |
| 4420 | |
| 4421 | int num = responselen / sizeof(RIL_CellInfo); |
| 4422 | p.writeInt32(num); |
| 4423 | |
| 4424 | RIL_CellInfo *p_cur = (RIL_CellInfo *) response; |
| 4425 | startResponse; |
| 4426 | int i; |
| 4427 | for (i = 0; i < num; i++) { |
| 4428 | p.writeInt32((int)p_cur->cellInfoType); |
| 4429 | p.writeInt32(p_cur->registered); |
| 4430 | p.writeInt32(p_cur->timeStampType); |
| 4431 | p.writeInt64(p_cur->timeStamp); |
| 4432 | switch(p_cur->cellInfoType) { |
| 4433 | case RIL_CELL_INFO_TYPE_GSM: { |
| 4434 | p.writeInt32(p_cur->CellInfo.gsm.cellIdentityGsm.mcc); |
| 4435 | p.writeInt32(p_cur->CellInfo.gsm.cellIdentityGsm.mnc); |
| 4436 | p.writeInt32(p_cur->CellInfo.gsm.cellIdentityGsm.lac); |
| 4437 | p.writeInt32(p_cur->CellInfo.gsm.cellIdentityGsm.cid); |
| 4438 | p.writeInt32(p_cur->CellInfo.gsm.signalStrengthGsm.signalStrength); |
| 4439 | p.writeInt32(p_cur->CellInfo.gsm.signalStrengthGsm.bitErrorRate); |
| 4440 | break; |
| 4441 | } |
| 4442 | case RIL_CELL_INFO_TYPE_WCDMA: { |
| 4443 | p.writeInt32(p_cur->CellInfo.wcdma.cellIdentityWcdma.mcc); |
| 4444 | p.writeInt32(p_cur->CellInfo.wcdma.cellIdentityWcdma.mnc); |
| 4445 | p.writeInt32(p_cur->CellInfo.wcdma.cellIdentityWcdma.lac); |
| 4446 | p.writeInt32(p_cur->CellInfo.wcdma.cellIdentityWcdma.cid); |
| 4447 | p.writeInt32(p_cur->CellInfo.wcdma.cellIdentityWcdma.psc); |
| 4448 | p.writeInt32(p_cur->CellInfo.wcdma.signalStrengthWcdma.signalStrength); |
| 4449 | p.writeInt32(p_cur->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate); |
| 4450 | break; |
| 4451 | } |
| 4452 | case RIL_CELL_INFO_TYPE_CDMA: { |
| 4453 | p.writeInt32(p_cur->CellInfo.cdma.cellIdentityCdma.networkId); |
| 4454 | p.writeInt32(p_cur->CellInfo.cdma.cellIdentityCdma.systemId); |
| 4455 | p.writeInt32(p_cur->CellInfo.cdma.cellIdentityCdma.basestationId); |
| 4456 | p.writeInt32(p_cur->CellInfo.cdma.cellIdentityCdma.longitude); |
| 4457 | p.writeInt32(p_cur->CellInfo.cdma.cellIdentityCdma.latitude); |
| 4458 | |
| 4459 | p.writeInt32(p_cur->CellInfo.cdma.signalStrengthCdma.dbm); |
| 4460 | p.writeInt32(p_cur->CellInfo.cdma.signalStrengthCdma.ecio); |
| 4461 | p.writeInt32(p_cur->CellInfo.cdma.signalStrengthEvdo.dbm); |
| 4462 | p.writeInt32(p_cur->CellInfo.cdma.signalStrengthEvdo.ecio); |
| 4463 | p.writeInt32(p_cur->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio); |
| 4464 | break; |
| 4465 | } |
| 4466 | case RIL_CELL_INFO_TYPE_LTE: { |
| 4467 | p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.mcc); |
| 4468 | p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.mnc); |
| 4469 | p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.ci); |
| 4470 | p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.pci); |
| 4471 | p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.tac); |
| 4472 | |
| 4473 | p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.signalStrength); |
| 4474 | p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.rsrp); |
| 4475 | p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.rsrq); |
| 4476 | p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.rssnr); |
| 4477 | p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.cqi); |
| 4478 | p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.timingAdvance); |
| 4479 | break; |
| 4480 | } |
| 4481 | case RIL_CELL_INFO_TYPE_TD_SCDMA: { |
| 4482 | p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.mcc); |
| 4483 | p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.mnc); |
| 4484 | p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.lac); |
| 4485 | p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.cid); |
| 4486 | p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.cpid); |
| 4487 | p.writeInt32(p_cur->CellInfo.tdscdma.signalStrengthTdscdma.rscp); |
| 4488 | break; |
| 4489 | } |
| 4490 | } |
| 4491 | p_cur += 1; |
| 4492 | } |
| 4493 | removeLastChar; |
| 4494 | closeResponse; |
| 4495 | |
| 4496 | return 0; |
| 4497 | } |
| 4498 | |
| 4499 | static int responseCellInfoListV12(Parcel &p, void *response, size_t responselen) { |
| 4500 | if (response == NULL && responselen != 0) { |
| 4501 | RLOGE("invalid response: NULL"); |
| 4502 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4503 | } |
| 4504 | |
| 4505 | if (responselen % sizeof(RIL_CellInfo_v12) != 0) { |
| 4506 | RLOGE("responseCellInfoList: invalid response length %d expected multiple of %d", |
| 4507 | (int)responselen, (int)sizeof(RIL_CellInfo_v12)); |
| 4508 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4509 | } |
| 4510 | |
| 4511 | int num = responselen / sizeof(RIL_CellInfo_v12); |
| 4512 | p.writeInt32(num); |
| 4513 | |
| 4514 | RIL_CellInfo_v12 *p_cur = (RIL_CellInfo_v12 *) response; |
| 4515 | startResponse; |
| 4516 | int i; |
| 4517 | for (i = 0; i < num; i++) { |
| 4518 | p.writeInt32((int)p_cur->cellInfoType); |
| 4519 | p.writeInt32(p_cur->registered); |
| 4520 | p.writeInt32(p_cur->timeStampType); |
| 4521 | p.writeInt64(p_cur->timeStamp); |
| 4522 | switch(p_cur->cellInfoType) { |
| 4523 | case RIL_CELL_INFO_TYPE_GSM: { |
| 4524 | p.writeInt32(p_cur->CellInfo.gsm.cellIdentityGsm.mcc); |
| 4525 | p.writeInt32(p_cur->CellInfo.gsm.cellIdentityGsm.mnc); |
| 4526 | p.writeInt32(p_cur->CellInfo.gsm.cellIdentityGsm.lac); |
| 4527 | p.writeInt32(p_cur->CellInfo.gsm.cellIdentityGsm.cid); |
| 4528 | p.writeInt32(p_cur->CellInfo.gsm.cellIdentityGsm.arfcn); |
| 4529 | p.writeInt32(p_cur->CellInfo.gsm.cellIdentityGsm.bsic); |
| 4530 | p.writeInt32(p_cur->CellInfo.gsm.signalStrengthGsm.signalStrength); |
| 4531 | p.writeInt32(p_cur->CellInfo.gsm.signalStrengthGsm.bitErrorRate); |
| 4532 | p.writeInt32(p_cur->CellInfo.gsm.signalStrengthGsm.timingAdvance); |
| 4533 | break; |
| 4534 | } |
| 4535 | case RIL_CELL_INFO_TYPE_WCDMA: { |
| 4536 | p.writeInt32(p_cur->CellInfo.wcdma.cellIdentityWcdma.mcc); |
| 4537 | p.writeInt32(p_cur->CellInfo.wcdma.cellIdentityWcdma.mnc); |
| 4538 | p.writeInt32(p_cur->CellInfo.wcdma.cellIdentityWcdma.lac); |
| 4539 | p.writeInt32(p_cur->CellInfo.wcdma.cellIdentityWcdma.cid); |
| 4540 | p.writeInt32(p_cur->CellInfo.wcdma.cellIdentityWcdma.psc); |
| 4541 | p.writeInt32(p_cur->CellInfo.wcdma.cellIdentityWcdma.uarfcn); |
| 4542 | p.writeInt32(p_cur->CellInfo.wcdma.signalStrengthWcdma.signalStrength); |
| 4543 | p.writeInt32(p_cur->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate); |
| 4544 | break; |
| 4545 | } |
| 4546 | case RIL_CELL_INFO_TYPE_CDMA: { |
| 4547 | p.writeInt32(p_cur->CellInfo.cdma.cellIdentityCdma.networkId); |
| 4548 | p.writeInt32(p_cur->CellInfo.cdma.cellIdentityCdma.systemId); |
| 4549 | p.writeInt32(p_cur->CellInfo.cdma.cellIdentityCdma.basestationId); |
| 4550 | p.writeInt32(p_cur->CellInfo.cdma.cellIdentityCdma.longitude); |
| 4551 | p.writeInt32(p_cur->CellInfo.cdma.cellIdentityCdma.latitude); |
| 4552 | |
| 4553 | p.writeInt32(p_cur->CellInfo.cdma.signalStrengthCdma.dbm); |
| 4554 | p.writeInt32(p_cur->CellInfo.cdma.signalStrengthCdma.ecio); |
| 4555 | p.writeInt32(p_cur->CellInfo.cdma.signalStrengthEvdo.dbm); |
| 4556 | p.writeInt32(p_cur->CellInfo.cdma.signalStrengthEvdo.ecio); |
| 4557 | p.writeInt32(p_cur->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio); |
| 4558 | break; |
| 4559 | } |
| 4560 | case RIL_CELL_INFO_TYPE_LTE: { |
| 4561 | p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.mcc); |
| 4562 | p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.mnc); |
| 4563 | p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.ci); |
| 4564 | p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.pci); |
| 4565 | p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.tac); |
| 4566 | p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.earfcn); |
| 4567 | |
| 4568 | p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.signalStrength); |
| 4569 | p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.rsrp); |
| 4570 | p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.rsrq); |
| 4571 | p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.rssnr); |
| 4572 | p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.cqi); |
| 4573 | p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.timingAdvance); |
| 4574 | break; |
| 4575 | } |
| 4576 | case RIL_CELL_INFO_TYPE_TD_SCDMA: { |
| 4577 | p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.mcc); |
| 4578 | p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.mnc); |
| 4579 | p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.lac); |
| 4580 | p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.cid); |
| 4581 | p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.cpid); |
| 4582 | p.writeInt32(p_cur->CellInfo.tdscdma.signalStrengthTdscdma.rscp); |
| 4583 | break; |
| 4584 | } |
| 4585 | } |
| 4586 | p_cur += 1; |
| 4587 | } |
| 4588 | removeLastChar; |
| 4589 | closeResponse; |
| 4590 | return 0; |
| 4591 | } |
| 4592 | |
| 4593 | static int responseCellInfoList(Parcel &p, void *response, size_t responselen) |
| 4594 | { |
| 4595 | if (s_callbacks.version <= LAST_IMPRECISE_RIL_VERSION) { |
| 4596 | if (s_callbacks.version < 12) { |
| 4597 | RLOGD("responseCellInfoList: v6"); |
| 4598 | return responseCellInfoListV6(p, response, responselen); |
| 4599 | } else { |
| 4600 | RLOGD("responseCellInfoList: v12"); |
| 4601 | return responseCellInfoListV12(p, response, responselen); |
| 4602 | } |
| 4603 | } else { // RIL version >= 13 |
| 4604 | if (responselen % sizeof(RIL_CellInfo_v12) != 0) { |
| 4605 | RLOGE("Data structure expected is RIL_CellInfo_v12"); |
| 4606 | if (!isDebuggable()) { |
| 4607 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4608 | } else { |
| 4609 | assert(0); |
| 4610 | } |
| 4611 | } |
| 4612 | return responseCellInfoListV12(p, response, responselen); |
| 4613 | } |
| 4614 | |
| 4615 | return 0; |
| 4616 | } |
| 4617 | |
| 4618 | static int responseHardwareConfig(Parcel &p, void *response, size_t responselen) |
| 4619 | { |
| 4620 | if (response == NULL && responselen != 0) { |
| 4621 | RLOGE("invalid response: NULL"); |
| 4622 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4623 | } |
| 4624 | |
| 4625 | if (responselen % sizeof(RIL_HardwareConfig) != 0) { |
| 4626 | RLOGE("responseHardwareConfig: invalid response length %d expected multiple of %d", |
| 4627 | (int)responselen, (int)sizeof(RIL_HardwareConfig)); |
| 4628 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4629 | } |
| 4630 | |
| 4631 | int num = responselen / sizeof(RIL_HardwareConfig); |
| 4632 | int i; |
| 4633 | RIL_HardwareConfig *p_cur = (RIL_HardwareConfig *) response; |
| 4634 | |
| 4635 | p.writeInt32(num); |
| 4636 | |
| 4637 | startResponse; |
| 4638 | for (i = 0; i < num; i++) { |
| 4639 | switch (p_cur[i].type) { |
| 4640 | case RIL_HARDWARE_CONFIG_MODEM: { |
| 4641 | p.writeInt32(p_cur[i].type); |
| 4642 | writeStringToParcel(p, p_cur[i].uuid); |
| 4643 | p.writeInt32((int)p_cur[i].state); |
| 4644 | p.writeInt32(p_cur[i].cfg.modem.rilModel); |
| 4645 | p.writeInt32(p_cur[i].cfg.modem.rat); |
| 4646 | p.writeInt32(p_cur[i].cfg.modem.maxVoice); |
| 4647 | p.writeInt32(p_cur[i].cfg.modem.maxData); |
| 4648 | p.writeInt32(p_cur[i].cfg.modem.maxStandby); |
| 4649 | |
| 4650 | appendPrintBuf("%s modem: uuid=%s,state=%d,rat=%08x,maxV=%d,maxD=%d,maxS=%d", printBuf, |
| 4651 | p_cur[i].uuid, (int)p_cur[i].state, p_cur[i].cfg.modem.rat, |
| 4652 | p_cur[i].cfg.modem.maxVoice, p_cur[i].cfg.modem.maxData, p_cur[i].cfg.modem.maxStandby); |
| 4653 | break; |
| 4654 | } |
| 4655 | case RIL_HARDWARE_CONFIG_SIM: { |
| 4656 | p.writeInt32(p_cur[i].type); |
| 4657 | writeStringToParcel(p, p_cur[i].uuid); |
| 4658 | p.writeInt32((int)p_cur[i].state); |
| 4659 | writeStringToParcel(p, p_cur[i].cfg.sim.modemUuid); |
| 4660 | |
| 4661 | appendPrintBuf("%s sim: uuid=%s,state=%d,modem-uuid=%s", printBuf, |
| 4662 | p_cur[i].uuid, (int)p_cur[i].state, p_cur[i].cfg.sim.modemUuid); |
| 4663 | break; |
| 4664 | } |
| 4665 | } |
| 4666 | } |
| 4667 | removeLastChar; |
| 4668 | closeResponse; |
| 4669 | return 0; |
| 4670 | } |
| 4671 | |
| 4672 | static int responseRadioCapability(Parcel &p, void *response, size_t responselen) { |
| 4673 | if (response == NULL) { |
| 4674 | RLOGE("invalid response: NULL"); |
| 4675 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4676 | } |
| 4677 | |
| 4678 | if (responselen != sizeof (RIL_RadioCapability) ) { |
| 4679 | RLOGE("invalid response length was %d expected %d", |
| 4680 | (int)responselen, (int)sizeof (RIL_SIM_IO_Response)); |
| 4681 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4682 | } |
| 4683 | |
| 4684 | RIL_RadioCapability *p_cur = (RIL_RadioCapability *) response; |
| 4685 | p.writeInt32(p_cur->version); |
| 4686 | p.writeInt32(p_cur->session); |
| 4687 | p.writeInt32(p_cur->phase); |
| 4688 | p.writeInt32(p_cur->rat); |
| 4689 | writeStringToParcel(p, p_cur->logicalModemUuid); |
| 4690 | p.writeInt32(p_cur->status); |
| 4691 | |
| 4692 | startResponse; |
| 4693 | appendPrintBuf("%s[version=%d,session=%d,phase=%d,\ |
| 4694 | rat=%s,logicalModemUuid=%s,status=%d]", |
| 4695 | printBuf, |
| 4696 | p_cur->version, |
| 4697 | p_cur->session, |
| 4698 | p_cur->phase, |
| 4699 | p_cur->rat, |
| 4700 | p_cur->logicalModemUuid, |
| 4701 | p_cur->status); |
| 4702 | closeResponse; |
| 4703 | return 0; |
| 4704 | } |
| 4705 | |
| 4706 | static int responseSSData(Parcel &p, void *response, size_t responselen) { |
| 4707 | RLOGD("In responseSSData"); |
| 4708 | int num; |
| 4709 | |
| 4710 | if (response == NULL && responselen != 0) { |
| 4711 | RLOGE("invalid response length was %d expected %d", |
| 4712 | (int)responselen, (int)sizeof (RIL_SIM_IO_Response)); |
| 4713 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4714 | } |
| 4715 | |
| 4716 | if (responselen != sizeof(RIL_StkCcUnsolSsResponse)) { |
| 4717 | RLOGE("invalid response length %d, expected %d", |
| 4718 | (int)responselen, (int)sizeof(RIL_StkCcUnsolSsResponse)); |
| 4719 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4720 | } |
| 4721 | |
| 4722 | startResponse; |
| 4723 | RIL_StkCcUnsolSsResponse *p_cur = (RIL_StkCcUnsolSsResponse *) response; |
| 4724 | p.writeInt32(p_cur->serviceType); |
| 4725 | p.writeInt32(p_cur->requestType); |
| 4726 | p.writeInt32(p_cur->teleserviceType); |
| 4727 | p.writeInt32(p_cur->serviceClass); |
| 4728 | p.writeInt32(p_cur->result); |
| 4729 | |
| 4730 | if (isServiceTypeCfQuery(p_cur->serviceType, p_cur->requestType)) { |
| 4731 | RLOGD("responseSSData CF type, num of Cf elements %d", p_cur->cfData.numValidIndexes); |
| 4732 | if (p_cur->cfData.numValidIndexes > NUM_SERVICE_CLASSES) { |
| 4733 | RLOGE("numValidIndexes is greater than max value %d, " |
| 4734 | "truncating it to max value", NUM_SERVICE_CLASSES); |
| 4735 | p_cur->cfData.numValidIndexes = NUM_SERVICE_CLASSES; |
| 4736 | } |
| 4737 | /* number of call info's */ |
| 4738 | p.writeInt32(p_cur->cfData.numValidIndexes); |
| 4739 | |
| 4740 | for (int i = 0; i < p_cur->cfData.numValidIndexes; i++) { |
| 4741 | RIL_CallForwardInfo cf = p_cur->cfData.cfInfo[i]; |
| 4742 | |
| 4743 | p.writeInt32(cf.status); |
| 4744 | p.writeInt32(cf.reason); |
| 4745 | p.writeInt32(cf.serviceClass); |
| 4746 | p.writeInt32(cf.toa); |
| 4747 | writeStringToParcel(p, cf.number); |
| 4748 | p.writeInt32(cf.timeSeconds); |
| 4749 | appendPrintBuf("%s[%s,reason=%d,cls=%d,toa=%d,%s,tout=%d],", printBuf, |
| 4750 | (cf.status==1)?"enable":"disable", cf.reason, cf.serviceClass, cf.toa, |
| 4751 | (char*)cf.number, cf.timeSeconds); |
| 4752 | RLOGD("Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status, |
| 4753 | cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds); |
| 4754 | } |
| 4755 | } else { |
| 4756 | p.writeInt32 (SS_INFO_MAX); |
| 4757 | |
| 4758 | /* each int*/ |
| 4759 | for (int i = 0; i < SS_INFO_MAX; i++) { |
| 4760 | appendPrintBuf("%s%d,", printBuf, p_cur->ssInfo[i]); |
| 4761 | RLOGD("Data: %d",p_cur->ssInfo[i]); |
| 4762 | p.writeInt32(p_cur->ssInfo[i]); |
| 4763 | } |
| 4764 | } |
| 4765 | removeLastChar; |
| 4766 | closeResponse; |
| 4767 | |
| 4768 | return 0; |
| 4769 | } |
| 4770 | |
| 4771 | static bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) { |
| 4772 | if ((reqType == SS_INTERROGATION) && |
| 4773 | (serType == SS_CFU || |
| 4774 | serType == SS_CF_BUSY || |
| 4775 | serType == SS_CF_NO_REPLY || |
| 4776 | serType == SS_CF_NOT_REACHABLE || |
| 4777 | serType == SS_CF_ALL || |
| 4778 | serType == SS_CF_ALL_CONDITIONAL)) { |
| 4779 | return true; |
| 4780 | } |
| 4781 | return false; |
| 4782 | } |
| 4783 | |
| 4784 | static void triggerEvLoop() { |
| 4785 | int ret; |
| 4786 | if (!pthread_equal(pthread_self(), s_tid_dispatch)) { |
| 4787 | /* trigger event loop to wakeup. No reason to do this, |
| 4788 | * if we're in the event loop thread */ |
| 4789 | do { |
| 4790 | ret = write (s_fdWakeupWrite, " ", 1); |
| 4791 | } while (ret < 0 && errno == EINTR); |
| 4792 | } |
| 4793 | } |
| 4794 | |
| 4795 | static void rilEventAddWakeup(struct ril_event *ev) { |
| 4796 | ril_event_add(ev); |
| 4797 | triggerEvLoop(); |
| 4798 | } |
| 4799 | |
| 4800 | static void sendSimStatusAppInfo(Parcel &p, int num_apps, RIL_AppStatus appStatus[]) { |
| 4801 | p.writeInt32(num_apps); |
| 4802 | startResponse; |
| 4803 | for (int i = 0; i < num_apps; i++) { |
| 4804 | p.writeInt32(appStatus[i].app_type); |
| 4805 | p.writeInt32(appStatus[i].app_state); |
| 4806 | p.writeInt32(appStatus[i].perso_substate); |
| 4807 | writeStringToParcel(p, (const char*)(appStatus[i].aid_ptr)); |
| 4808 | writeStringToParcel(p, (const char*) |
| 4809 | (appStatus[i].app_label_ptr)); |
| 4810 | p.writeInt32(appStatus[i].pin1_replaced); |
| 4811 | p.writeInt32(appStatus[i].pin1); |
| 4812 | p.writeInt32(appStatus[i].pin2); |
| 4813 | appendPrintBuf("%s[app_type=%d,app_state=%d,perso_substate=%d,\ |
| 4814 | aid_ptr=%s,app_label_ptr=%s,pin1_replaced=%d,pin1=%d,pin2=%d],", |
| 4815 | printBuf, |
| 4816 | appStatus[i].app_type, |
| 4817 | appStatus[i].app_state, |
| 4818 | appStatus[i].perso_substate, |
| 4819 | appStatus[i].aid_ptr, |
| 4820 | appStatus[i].app_label_ptr, |
| 4821 | appStatus[i].pin1_replaced, |
| 4822 | appStatus[i].pin1, |
| 4823 | appStatus[i].pin2); |
| 4824 | } |
| 4825 | closeResponse; |
| 4826 | } |
| 4827 | |
| 4828 | static void responseSimStatusV5(Parcel &p, void *response) { |
| 4829 | RIL_CardStatus_v5 *p_cur = ((RIL_CardStatus_v5 *) response); |
| 4830 | |
| 4831 | p.writeInt32(p_cur->card_state); |
| 4832 | p.writeInt32(p_cur->universal_pin_state); |
| 4833 | p.writeInt32(p_cur->gsm_umts_subscription_app_index); |
| 4834 | p.writeInt32(p_cur->cdma_subscription_app_index); |
| 4835 | |
| 4836 | sendSimStatusAppInfo(p, p_cur->num_applications, p_cur->applications); |
| 4837 | } |
| 4838 | |
| 4839 | static void responseSimStatusV6(Parcel &p, void *response) { |
| 4840 | RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response); |
| 4841 | |
| 4842 | p.writeInt32(p_cur->card_state); |
| 4843 | p.writeInt32(p_cur->universal_pin_state); |
| 4844 | p.writeInt32(p_cur->gsm_umts_subscription_app_index); |
| 4845 | p.writeInt32(p_cur->cdma_subscription_app_index); |
| 4846 | p.writeInt32(p_cur->ims_subscription_app_index); |
| 4847 | |
| 4848 | sendSimStatusAppInfo(p, p_cur->num_applications, p_cur->applications); |
| 4849 | } |
| 4850 | |
| 4851 | static void responseSimStatusV7(Parcel &p, void *response) { |
| 4852 | RIL_CardStatus_v7 *p_cur = ((RIL_CardStatus_v7 *) response); |
| 4853 | |
| 4854 | p.writeInt32(p_cur->card_state); |
| 4855 | p.writeInt32(p_cur->universal_pin_state); |
| 4856 | p.writeInt32(p_cur->gsm_umts_subscription_app_index); |
| 4857 | p.writeInt32(p_cur->cdma_subscription_app_index); |
| 4858 | p.writeInt32(p_cur->ims_subscription_app_index); |
| 4859 | |
| 4860 | sendSimStatusAppInfo(p, p_cur->num_applications, p_cur->applications); |
| 4861 | p.writeInt32(p_cur->physicalSlotId); |
| 4862 | writeStringToParcel(p, (const char *)p_cur->atr); |
| 4863 | writeStringToParcel(p, (const char *)p_cur->iccId); |
| 4864 | } |
| 4865 | |
| 4866 | static int responseSimStatus(Parcel &p, void *response, size_t responselen) { |
| 4867 | int i; |
| 4868 | |
| 4869 | if (response == NULL && responselen != 0) { |
| 4870 | RLOGE("invalid response: NULL"); |
| 4871 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4872 | } |
| 4873 | |
| 4874 | if (s_callbacks.version <= LAST_IMPRECISE_RIL_VERSION) { |
| 4875 | if (responselen == sizeof (RIL_CardStatus_v6)) { |
| 4876 | responseSimStatusV6(p, response); |
| 4877 | } else if (responselen == sizeof (RIL_CardStatus_v5)) { |
| 4878 | responseSimStatusV5(p, response); |
| 4879 | } else { |
| 4880 | RLOGE("responseSimStatus: A RilCardStatus_v6 or _v5 expected\n"); |
| 4881 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4882 | } |
| 4883 | } else { // RIL version >= 13 |
| 4884 | if (responselen == sizeof(RIL_CardStatus_v6)) { |
| 4885 | responseSimStatusV6(p, response); |
| 4886 | } else if(responselen == sizeof(RIL_CardStatus_v7)) { |
| 4887 | responseSimStatusV7(p, response); |
| 4888 | } else { |
| 4889 | RLOGE("Data structure expected is RIL_CardStatus_v7 or v6"); |
| 4890 | if (!isDebuggable()) { |
| 4891 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4892 | } else { |
| 4893 | assert(0); |
| 4894 | } |
| 4895 | } |
| 4896 | } |
| 4897 | |
| 4898 | return 0; |
| 4899 | } |
| 4900 | |
| 4901 | static int responseGsmBrSmsCnf(Parcel &p, void *response, size_t responselen) { |
| 4902 | int num = responselen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *); |
| 4903 | p.writeInt32(num); |
| 4904 | |
| 4905 | startResponse; |
| 4906 | RIL_GSM_BroadcastSmsConfigInfo **p_cur = |
| 4907 | (RIL_GSM_BroadcastSmsConfigInfo **) response; |
| 4908 | for (int i = 0; i < num; i++) { |
| 4909 | p.writeInt32(p_cur[i]->fromServiceId); |
| 4910 | p.writeInt32(p_cur[i]->toServiceId); |
| 4911 | p.writeInt32(p_cur[i]->fromCodeScheme); |
| 4912 | p.writeInt32(p_cur[i]->toCodeScheme); |
| 4913 | p.writeInt32(p_cur[i]->selected); |
| 4914 | |
| 4915 | appendPrintBuf("%s [%d: fromServiceId=%d, toServiceId=%d, \ |
| 4916 | fromCodeScheme=%d, toCodeScheme=%d, selected =%d]", |
| 4917 | printBuf, i, p_cur[i]->fromServiceId, p_cur[i]->toServiceId, |
| 4918 | p_cur[i]->fromCodeScheme, p_cur[i]->toCodeScheme, |
| 4919 | p_cur[i]->selected); |
| 4920 | } |
| 4921 | closeResponse; |
| 4922 | |
| 4923 | return 0; |
| 4924 | } |
| 4925 | |
| 4926 | static int responseCdmaBrSmsCnf(Parcel &p, void *response, size_t responselen) { |
| 4927 | RIL_CDMA_BroadcastSmsConfigInfo **p_cur = |
| 4928 | (RIL_CDMA_BroadcastSmsConfigInfo **) response; |
| 4929 | |
| 4930 | int num = responselen / sizeof (RIL_CDMA_BroadcastSmsConfigInfo *); |
| 4931 | p.writeInt32(num); |
| 4932 | |
| 4933 | startResponse; |
| 4934 | for (int i = 0 ; i < num ; i++ ) { |
| 4935 | p.writeInt32(p_cur[i]->service_category); |
| 4936 | p.writeInt32(p_cur[i]->language); |
| 4937 | p.writeInt32(p_cur[i]->selected); |
| 4938 | |
| 4939 | appendPrintBuf("%s [%d: srvice_category=%d, language =%d, \ |
| 4940 | selected =%d], ", |
| 4941 | printBuf, i, p_cur[i]->service_category, p_cur[i]->language, |
| 4942 | p_cur[i]->selected); |
| 4943 | } |
| 4944 | closeResponse; |
| 4945 | |
| 4946 | return 0; |
| 4947 | } |
| 4948 | |
| 4949 | static int responseCdmaSms(Parcel &p, void *response, size_t responselen) { |
| 4950 | int num; |
| 4951 | int digitCount; |
| 4952 | int digitLimit; |
| 4953 | uint8_t uct; |
| 4954 | void* dest; |
| 4955 | |
| 4956 | RLOGD("Inside responseCdmaSms"); |
| 4957 | |
| 4958 | if (response == NULL && responselen != 0) { |
| 4959 | RLOGE("invalid response: NULL"); |
| 4960 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4961 | } |
| 4962 | |
| 4963 | if (responselen != sizeof(RIL_CDMA_SMS_Message)) { |
| 4964 | RLOGE("invalid response length was %d expected %d", |
| 4965 | (int)responselen, (int)sizeof(RIL_CDMA_SMS_Message)); |
| 4966 | return RIL_ERRNO_INVALID_RESPONSE; |
| 4967 | } |
| 4968 | |
| 4969 | RIL_CDMA_SMS_Message *p_cur = (RIL_CDMA_SMS_Message *) response; |
| 4970 | p.writeInt32(p_cur->uTeleserviceID); |
| 4971 | p.write(&(p_cur->bIsServicePresent),sizeof(uct)); |
| 4972 | p.writeInt32(p_cur->uServicecategory); |
| 4973 | p.writeInt32(p_cur->sAddress.digit_mode); |
| 4974 | p.writeInt32(p_cur->sAddress.number_mode); |
| 4975 | p.writeInt32(p_cur->sAddress.number_type); |
| 4976 | p.writeInt32(p_cur->sAddress.number_plan); |
| 4977 | p.write(&(p_cur->sAddress.number_of_digits), sizeof(uct)); |
| 4978 | digitLimit= MIN((p_cur->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX); |
| 4979 | for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { |
| 4980 | p.write(&(p_cur->sAddress.digits[digitCount]),sizeof(uct)); |
| 4981 | } |
| 4982 | |
| 4983 | p.writeInt32(p_cur->sSubAddress.subaddressType); |
| 4984 | p.write(&(p_cur->sSubAddress.odd),sizeof(uct)); |
| 4985 | p.write(&(p_cur->sSubAddress.number_of_digits),sizeof(uct)); |
| 4986 | digitLimit= MIN((p_cur->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX); |
| 4987 | for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { |
| 4988 | p.write(&(p_cur->sSubAddress.digits[digitCount]),sizeof(uct)); |
| 4989 | } |
| 4990 | |
| 4991 | digitLimit= MIN((p_cur->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX); |
| 4992 | p.writeInt32(p_cur->uBearerDataLen); |
| 4993 | for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { |
| 4994 | p.write(&(p_cur->aBearerData[digitCount]), sizeof(uct)); |
| 4995 | } |
| 4996 | |
| 4997 | startResponse; |
| 4998 | appendPrintBuf("%suTeleserviceID=%d, bIsServicePresent=%d, uServicecategory=%d, \ |
| 4999 | sAddress.digit_mode=%d, sAddress.number_mode=%d, sAddress.number_type=%d, ", |
| 5000 | printBuf, p_cur->uTeleserviceID,p_cur->bIsServicePresent,p_cur->uServicecategory, |
| 5001 | p_cur->sAddress.digit_mode, p_cur->sAddress.number_mode,p_cur->sAddress.number_type); |
| 5002 | closeResponse; |
| 5003 | |
| 5004 | return 0; |
| 5005 | } |
| 5006 | |
| 5007 | static int responseGetSmsSimMemStatusCnf(Parcel &p,void *response, size_t responselen) |
| 5008 | { |
| 5009 | if (response == NULL || responselen == 0) { |
| 5010 | RLOGE("invalid response: NULL"); |
| 5011 | return RIL_ERRNO_INVALID_RESPONSE; |
| 5012 | } |
| 5013 | |
| 5014 | if (responselen != sizeof (RIL_SMS_Memory_Status)) { |
| 5015 | RLOGE("invalid response length %d expected sizeof (RIL_SMS_Memory_Status) of %d\n", |
| 5016 | (int)responselen, (int)sizeof(RIL_SMS_Memory_Status)); |
| 5017 | return RIL_ERRNO_INVALID_RESPONSE; |
| 5018 | } |
| 5019 | |
| 5020 | startResponse; |
| 5021 | |
| 5022 | RIL_SMS_Memory_Status *mem_status = (RIL_SMS_Memory_Status*)response; |
| 5023 | |
| 5024 | p.writeInt32(mem_status->used); |
| 5025 | p.writeInt32(mem_status->total); |
| 5026 | |
| 5027 | appendPrintBuf("%s [used = %d, total = %d]", printBuf, mem_status->used, mem_status->total); |
| 5028 | |
| 5029 | closeResponse; |
| 5030 | |
| 5031 | return 0; |
| 5032 | } |
| 5033 | |
| 5034 | |
| 5035 | static int responseEtwsNotification(Parcel &p, void *response, size_t responselen) { |
| 5036 | if(NULL == response) { |
| 5037 | RLOGE("invalid response: NULL"); |
| 5038 | return RIL_ERRNO_INVALID_RESPONSE; |
| 5039 | } |
| 5040 | |
| 5041 | if(responselen != sizeof(RIL_CBEtwsNotification)) { |
| 5042 | RLOGE("invalid response length %d expected %d", |
| 5043 | responselen, sizeof(RIL_CBEtwsNotification)); |
| 5044 | return RIL_ERRNO_INVALID_RESPONSE; |
| 5045 | } |
| 5046 | |
| 5047 | RIL_CBEtwsNotification *p_cur = (RIL_CBEtwsNotification *)response; |
| 5048 | p.writeInt32(p_cur->warningType); |
| 5049 | p.writeInt32(p_cur->messageId); |
| 5050 | p.writeInt32(p_cur->serialNumber); |
| 5051 | writeStringToParcel(p, p_cur->plmnId); |
| 5052 | writeStringToParcel(p, p_cur->securityInfo); |
| 5053 | |
| 5054 | startResponse; |
| 5055 | appendPrintBuf("%s%d,%d,%d,%s,%s", printBuf, p_cur->waringType, p_cur->messageId, |
| 5056 | p_cur->serialNumber, p_cur->plmnId, p_cur->securityInfo); |
| 5057 | closeResponse; |
| 5058 | |
| 5059 | return 0; |
| 5060 | } |
| 5061 | |
| 5062 | static int responseDcRtInfo(Parcel &p, void *response, size_t responselen) |
| 5063 | { |
| 5064 | int num = responselen / sizeof(RIL_DcRtInfo); |
| 5065 | if ((responselen % sizeof(RIL_DcRtInfo) != 0) || (num != 1)) { |
| 5066 | RLOGE("responseDcRtInfo: invalid response length %d expected multiple of %d", |
| 5067 | (int)responselen, (int)sizeof(RIL_DcRtInfo)); |
| 5068 | return RIL_ERRNO_INVALID_RESPONSE; |
| 5069 | } |
| 5070 | |
| 5071 | startResponse; |
| 5072 | RIL_DcRtInfo *pDcRtInfo = (RIL_DcRtInfo *)response; |
| 5073 | p.writeInt64(pDcRtInfo->time); |
| 5074 | p.writeInt32(pDcRtInfo->powerState); |
| 5075 | appendPrintBuf("%s[time=%d,powerState=%d]", printBuf, |
| 5076 | pDcRtInfo->time, |
| 5077 | pDcRtInfo->powerState); |
| 5078 | closeResponse; |
| 5079 | |
| 5080 | return 0; |
| 5081 | } |
| 5082 | |
| 5083 | static int responseLceStatus(Parcel &p, void *response, size_t responselen) { |
| 5084 | if (response == NULL || responselen != sizeof(RIL_LceStatusInfo)) { |
| 5085 | if (response == NULL) { |
| 5086 | RLOGE("invalid response: NULL"); |
| 5087 | } |
| 5088 | else { |
| 5089 | RLOGE("responseLceStatus: invalid response length %u expecting len: %u", |
| 5090 | (unsigned)sizeof(RIL_LceStatusInfo), (unsigned)responselen); |
| 5091 | } |
| 5092 | return RIL_ERRNO_INVALID_RESPONSE; |
| 5093 | } |
| 5094 | |
| 5095 | RIL_LceStatusInfo *p_cur = (RIL_LceStatusInfo *)response; |
| 5096 | p.write((void *)p_cur, 1); // p_cur->lce_status takes one byte. |
| 5097 | p.writeInt32(p_cur->actual_interval_ms); |
| 5098 | |
| 5099 | startResponse; |
| 5100 | appendPrintBuf("LCE Status: %d, actual_interval_ms: %d", |
| 5101 | p_cur->lce_status, p_cur->actual_interval_ms); |
| 5102 | closeResponse; |
| 5103 | |
| 5104 | return 0; |
| 5105 | } |
| 5106 | |
| 5107 | static int responseLceData(Parcel &p, void *response, size_t responselen) { |
| 5108 | if (response == NULL || responselen != sizeof(RIL_LceDataInfo)) { |
| 5109 | if (response == NULL) { |
| 5110 | RLOGE("invalid response: NULL"); |
| 5111 | } |
| 5112 | else { |
| 5113 | RLOGE("responseLceData: invalid response length %u expecting len: %u", |
| 5114 | (unsigned)sizeof(RIL_LceDataInfo), (unsigned)responselen); |
| 5115 | } |
| 5116 | return RIL_ERRNO_INVALID_RESPONSE; |
| 5117 | } |
| 5118 | |
| 5119 | RIL_LceDataInfo *p_cur = (RIL_LceDataInfo *)response; |
| 5120 | p.writeInt32(p_cur->last_hop_capacity_kbps); |
| 5121 | |
| 5122 | /* p_cur->confidence_level and p_cur->lce_suspended take 1 byte each.*/ |
| 5123 | p.write((void *)&(p_cur->confidence_level), 1); |
| 5124 | p.write((void *)&(p_cur->lce_suspended), 1); |
| 5125 | |
| 5126 | startResponse; |
| 5127 | appendPrintBuf("LCE info received: capacity %d confidence level %d \ |
| 5128 | and suspended %d", |
| 5129 | p_cur->last_hop_capacity_kbps, p_cur->confidence_level, |
| 5130 | p_cur->lce_suspended); |
| 5131 | closeResponse; |
| 5132 | |
| 5133 | return 0; |
| 5134 | } |
| 5135 | |
| 5136 | static int responseActivityData(Parcel &p, void *response, size_t responselen) { |
| 5137 | if (response == NULL || responselen != sizeof(RIL_ActivityStatsInfo)) { |
| 5138 | if (response == NULL) { |
| 5139 | RLOGE("invalid response: NULL"); |
| 5140 | } |
| 5141 | else { |
| 5142 | RLOGE("responseActivityData: invalid response length %u expecting len: %u", |
| 5143 | (unsigned)sizeof(RIL_ActivityStatsInfo), (unsigned)responselen); |
| 5144 | } |
| 5145 | return RIL_ERRNO_INVALID_RESPONSE; |
| 5146 | } |
| 5147 | |
| 5148 | RIL_ActivityStatsInfo *p_cur = (RIL_ActivityStatsInfo *)response; |
| 5149 | p.writeInt32(p_cur->sleep_mode_time_ms); |
| 5150 | p.writeInt32(p_cur->idle_mode_time_ms); |
| 5151 | for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) { |
| 5152 | p.writeInt32(p_cur->tx_mode_time_ms[i]); |
| 5153 | } |
| 5154 | p.writeInt32(p_cur->rx_mode_time_ms); |
| 5155 | |
| 5156 | startResponse; |
| 5157 | appendPrintBuf("Modem activity info received: sleep_mode_time_ms %d idle_mode_time_ms %d \ |
| 5158 | tx_mode_time_ms %d %d %d %d %d and rx_mode_time_ms %d", |
| 5159 | p_cur->sleep_mode_time_ms, p_cur->idle_mode_time_ms, p_cur->tx_mode_time_ms[0], |
| 5160 | p_cur->tx_mode_time_ms[1], p_cur->tx_mode_time_ms[2], p_cur->tx_mode_time_ms[3], |
| 5161 | p_cur->tx_mode_time_ms[4], p_cur->rx_mode_time_ms); |
| 5162 | closeResponse; |
| 5163 | |
| 5164 | return 0; |
| 5165 | } |
| 5166 | |
| 5167 | static int responseCarrierRestrictions(Parcel &p, void *response, size_t responselen) { |
| 5168 | if (response == NULL) { |
| 5169 | RLOGE("invalid response: NULL"); |
| 5170 | return RIL_ERRNO_INVALID_RESPONSE; |
| 5171 | } |
| 5172 | if (responselen != sizeof(RIL_CarrierRestrictions)) { |
| 5173 | RLOGE("responseCarrierRestrictions: invalid response length %u expecting len: %u", |
| 5174 | (unsigned)responselen, (unsigned)sizeof(RIL_CarrierRestrictions)); |
| 5175 | return RIL_ERRNO_INVALID_RESPONSE; |
| 5176 | } |
| 5177 | |
| 5178 | RIL_CarrierRestrictions *p_cr = (RIL_CarrierRestrictions *)response; |
| 5179 | startResponse; |
| 5180 | |
| 5181 | p.writeInt32(p_cr->len_allowed_carriers); |
| 5182 | p.writeInt32(p_cr->len_excluded_carriers); |
| 5183 | appendPrintBuf(" %s len_allowed_carriers: %d, len_excluded_carriers: %d,", printBuf, |
| 5184 | p_cr->len_allowed_carriers,p_cr->len_excluded_carriers); |
| 5185 | |
| 5186 | appendPrintBuf(" %s allowed_carriers:", printBuf); |
| 5187 | for(int32_t i = 0; i < p_cr->len_allowed_carriers; i++) { |
| 5188 | RIL_Carrier *carrier = p_cr->allowed_carriers + i; |
| 5189 | writeStringToParcel(p, carrier->mcc); |
| 5190 | writeStringToParcel(p, carrier->mnc); |
| 5191 | p.writeInt32(carrier->match_type); |
| 5192 | writeStringToParcel(p, carrier->match_data); |
| 5193 | appendPrintBuf(" %s [%d mcc: %s, mnc: %s, match_type: %d, match_data: %s],", printBuf, |
| 5194 | i, carrier->mcc, carrier->mnc, carrier->match_type, carrier->match_data); |
| 5195 | } |
| 5196 | |
| 5197 | appendPrintBuf(" %s excluded_carriers:", printBuf); |
| 5198 | for(int32_t i = 0; i < p_cr->len_excluded_carriers; i++) { |
| 5199 | RIL_Carrier *carrier = p_cr->excluded_carriers + i; |
| 5200 | writeStringToParcel(p, carrier->mcc); |
| 5201 | writeStringToParcel(p, carrier->mnc); |
| 5202 | p.writeInt32(carrier->match_type); |
| 5203 | writeStringToParcel(p, carrier->match_data); |
| 5204 | appendPrintBuf(" %s [%d mcc: %s, mnc: %s, match_type: %d, match_data: %s],", printBuf, |
| 5205 | i, carrier->mcc, carrier->mnc, carrier->match_type, carrier->match_data); |
| 5206 | } |
| 5207 | |
| 5208 | closeResponse; |
| 5209 | |
| 5210 | return 0; |
| 5211 | } |
| 5212 | |
| 5213 | static int responsePcoData(Parcel &p, void *response, size_t responselen) { |
| 5214 | if (response == NULL) { |
| 5215 | RLOGE("responsePcoData: invalid NULL response"); |
| 5216 | return RIL_ERRNO_INVALID_RESPONSE; |
| 5217 | } |
| 5218 | if (responselen != sizeof(RIL_PCO_Data)) { |
| 5219 | RLOGE("responsePcoData: invalid response length %u, expecting %u", |
| 5220 | (unsigned)responselen, (unsigned)sizeof(RIL_PCO_Data)); |
| 5221 | return RIL_ERRNO_INVALID_RESPONSE; |
| 5222 | } |
| 5223 | |
| 5224 | RIL_PCO_Data *p_cur = (RIL_PCO_Data *)response; |
| 5225 | p.writeInt32(p_cur->cid); |
| 5226 | writeStringToParcel(p, p_cur->bearer_proto); |
| 5227 | p.writeInt32(p_cur->pco_id); |
| 5228 | p.writeInt32(p_cur->contents_length); |
| 5229 | p.write(p_cur->contents, p_cur->contents_length); |
| 5230 | |
| 5231 | startResponse; |
| 5232 | appendPrintBuf("PCO data received: cid %d, id %d, length %d", |
| 5233 | p_cur->cid, p_cur->pco_id, p_cur->contents_length); |
| 5234 | closeResponse; |
| 5235 | |
| 5236 | return 0; |
| 5237 | } |
| 5238 | |
| 5239 | static int responseCrssN(Parcel &p, void *response, size_t responselen) { |
| 5240 | if (response == NULL) { |
| 5241 | RLOGE("invalid response: NULL"); |
| 5242 | return RIL_ERRNO_INVALID_RESPONSE; |
| 5243 | } |
| 5244 | |
| 5245 | if (responselen != sizeof(RIL_CrssNotification)) { |
| 5246 | RLOGE("invalid response length was %d expected %d", |
| 5247 | (int)responselen, (int)sizeof (RIL_CrssNotification)); |
| 5248 | return RIL_ERRNO_INVALID_RESPONSE; |
| 5249 | } |
| 5250 | |
| 5251 | RIL_CrssNotification *p_cur = (RIL_CrssNotification *) response; |
| 5252 | p.writeInt32(p_cur->code); |
| 5253 | p.writeInt32(p_cur->type); |
| 5254 | writeStringToParcel(p, p_cur->number); |
| 5255 | writeStringToParcel(p, p_cur->alphaid); |
| 5256 | p.writeInt32(p_cur->cli_validity); |
| 5257 | return 0; |
| 5258 | } |
| 5259 | |
| 5260 | static int responsePhbEntries(Parcel &p,void *response, size_t responselen) { |
| 5261 | |
| 5262 | |
| 5263 | if (response == NULL && responselen != 0) { |
| 5264 | RLOGE("invalid response: NULL"); |
| 5265 | return RIL_ERRNO_INVALID_RESPONSE; |
| 5266 | } |
| 5267 | |
| 5268 | if (responselen % sizeof (RIL_PhbEntryStrucutre *) != 0) { |
| 5269 | RLOGE("invalid response length %d expected multiple of %d\n", |
| 5270 | (int)responselen, (int)sizeof (RIL_PhbEntryStrucutre *)); |
| 5271 | return RIL_ERRNO_INVALID_RESPONSE; |
| 5272 | } |
| 5273 | |
| 5274 | int num = responselen / sizeof(RIL_PhbEntryStrucutre *); |
| 5275 | p.writeInt32(num); |
| 5276 | |
| 5277 | startResponse; |
| 5278 | RIL_PhbEntryStrucutre **p_cur = |
| 5279 | (RIL_PhbEntryStrucutre **) response; |
| 5280 | for (int i = 0; i < num; i++) { |
| 5281 | p.writeInt32(p_cur[i]->type); |
| 5282 | p.writeInt32(p_cur[i]->index); |
| 5283 | writeStringToParcel(p, p_cur[i]->number); |
| 5284 | p.writeInt32(p_cur[i]->ton); |
| 5285 | writeStringToParcel(p, p_cur[i]->alphaId); |
| 5286 | |
| 5287 | appendPrintBuf("%s [%d: type=%d, index=%d, \ |
| 5288 | number=%s, ton=%d, alphaId =%s]", |
| 5289 | printBuf, i, p_cur[i]->type, p_cur[i]->index, |
| 5290 | p_cur[i]->number, p_cur[i]->ton, |
| 5291 | p_cur[i]->alphaId); |
| 5292 | } |
| 5293 | closeResponse; |
| 5294 | |
| 5295 | return 0; |
| 5296 | |
| 5297 | } |
| 5298 | |
| 5299 | static int responseReadPhbEntryExt(Parcel &p,void *response, size_t responselen) |
| 5300 | { |
| 5301 | if (response == NULL && responselen != 0) { |
| 5302 | RLOGE("invalid response: NULL"); |
| 5303 | return RIL_ERRNO_INVALID_RESPONSE; |
| 5304 | } |
| 5305 | if (responselen % sizeof (RIL_PHB_ENTRY *) != 0) { |
| 5306 | RLOGE("invalid response length %d expected multiple of %d\n", |
| 5307 | (int)responselen, (int)sizeof (RIL_PHB_ENTRY *)); |
| 5308 | return RIL_ERRNO_INVALID_RESPONSE; |
| 5309 | } |
| 5310 | int num = responselen / sizeof(RIL_PHB_ENTRY *); |
| 5311 | p.writeInt32(num); |
| 5312 | startResponse; |
| 5313 | RIL_PHB_ENTRY **p_cur = |
| 5314 | (RIL_PHB_ENTRY **) response; |
| 5315 | |
| 5316 | for (int i = 0; i < num; i++) { |
| 5317 | p.writeInt32(p_cur[i]->index); |
| 5318 | writeStringToParcel(p, p_cur[i]->number); |
| 5319 | p.writeInt32(p_cur[i]->type); |
| 5320 | writeStringToParcel(p, p_cur[i]->text); |
| 5321 | p.writeInt32(p_cur[i]->hidden); |
| 5322 | writeStringToParcel(p, p_cur[i]->group); |
| 5323 | writeStringToParcel(p, p_cur[i]->adnumber); |
| 5324 | p.writeInt32(p_cur[i]->adtype); |
| 5325 | writeStringToParcel(p, p_cur[i]->secondtext); |
| 5326 | writeStringToParcel(p, p_cur[i]->email); |
| 5327 | |
| 5328 | appendPrintBuf("%s [%d: index=%d, \ |
| 5329 | number=%s, type=%d, text =%s, hidden=%d,group=%s,adnumber=%s,adtype=%d,sectext=%s,email=%s]", |
| 5330 | printBuf, i, p_cur[i]->index, |
| 5331 | p_cur[i]->number, p_cur[i]->type, |
| 5332 | p_cur[i]->text, p_cur[i]->hidden,p_cur[i]->group,p_cur[i]->adnumber, |
| 5333 | p_cur[i]->adtype,p_cur[i]->secondtext,p_cur[i]->email); |
| 5334 | } |
| 5335 | |
| 5336 | closeResponse; |
| 5337 | |
| 5338 | return 0; |
| 5339 | |
| 5340 | } |
| 5341 | |
| 5342 | static int responseGetPhbMemStorage(Parcel &p,void *response, size_t responselen) |
| 5343 | { |
| 5344 | if (response == NULL || responselen == 0) { |
| 5345 | RLOGE("responseGetPhbMemStorage invalid response: NULL"); |
| 5346 | return RIL_ERRNO_INVALID_RESPONSE; |
| 5347 | } |
| 5348 | if (responselen != sizeof (RIL_PHB_MEM_STORAGE_RESPONSE)) { |
| 5349 | RLOGE("invalid response length %d expected sizeof (RIL_PHB_MEM_STORAGE_RESPONSE) of %d\n", |
| 5350 | (int)responselen, (int)sizeof(RIL_PHB_MEM_STORAGE_RESPONSE)); |
| 5351 | return RIL_ERRNO_INVALID_RESPONSE; |
| 5352 | } |
| 5353 | |
| 5354 | startResponse; |
| 5355 | |
| 5356 | RIL_PHB_MEM_STORAGE_RESPONSE *mem_status = (RIL_PHB_MEM_STORAGE_RESPONSE*)response; |
| 5357 | writeStringToParcel (p, mem_status->storage); |
| 5358 | p.writeInt32(mem_status->used); |
| 5359 | p.writeInt32(mem_status->total); |
| 5360 | |
| 5361 | appendPrintBuf("%s [storage = %s, used = %d, total = %d]", printBuf, mem_status->storage, mem_status->used, mem_status->total); |
| 5362 | |
| 5363 | closeResponse; |
| 5364 | return 0; |
| 5365 | } |
| 5366 | |
| 5367 | static int responseImsBearerNotify(Parcel &p, void *response, size_t responselen) { |
| 5368 | if (response == NULL) { |
| 5369 | RLOGE("invalid response: NULL"); |
| 5370 | return RIL_ERRNO_INVALID_RESPONSE; |
| 5371 | } |
| 5372 | |
| 5373 | if (responselen != sizeof(RIL_CrssNotification)) { |
| 5374 | RLOGE("invalid response length was %d expected %d", |
| 5375 | (int)responselen, (int)sizeof (RIL_IMS_BearerNotification)); |
| 5376 | return RIL_ERRNO_INVALID_RESPONSE; |
| 5377 | } |
| 5378 | |
| 5379 | RIL_IMS_BearerNotification *p_cur = (RIL_IMS_BearerNotification *) response; |
| 5380 | p.writeInt32(p_cur->phone); |
| 5381 | p.writeInt32(p_cur->aid); |
| 5382 | writeStringToParcel(p, p_cur->type); |
| 5383 | return 0; |
| 5384 | } |
| 5385 | |
| 5386 | //MTK-START SMS |
| 5387 | static void dispatchSmsParams(Parcel &p, RequestInfo *pRI) { |
| 5388 | RIL_SmsParams smsParams; |
| 5389 | int32_t t; |
| 5390 | status_t status; |
| 5391 | |
| 5392 | RLOGD("dispatchSmsParams Enter."); |
| 5393 | |
| 5394 | memset(&smsParams, 0, sizeof(smsParams)); |
| 5395 | |
| 5396 | status = p.readInt32(&t); |
| 5397 | if (status != NO_ERROR) { |
| 5398 | goto invalid; |
| 5399 | } |
| 5400 | |
| 5401 | status = p.readInt32(&t); |
| 5402 | smsParams.format = t; |
| 5403 | if (status != NO_ERROR) { |
| 5404 | goto invalid; |
| 5405 | } |
| 5406 | |
| 5407 | status = p.readInt32(&t); |
| 5408 | smsParams.vp = t; |
| 5409 | if (status != NO_ERROR) { |
| 5410 | goto invalid; |
| 5411 | } |
| 5412 | |
| 5413 | status = p.readInt32(&t); |
| 5414 | smsParams.pid = t; |
| 5415 | if (status != NO_ERROR) { |
| 5416 | goto invalid; |
| 5417 | } |
| 5418 | |
| 5419 | status = p.readInt32(&t); |
| 5420 | smsParams.dcs = t; |
| 5421 | if (status != NO_ERROR) { |
| 5422 | goto invalid; |
| 5423 | } |
| 5424 | |
| 5425 | RLOGD("dispatchSmsParams format: %d, vp: %d, pid: %d, dcs: %d", smsParams.format, smsParams.vp, |
| 5426 | smsParams.pid, smsParams.dcs); |
| 5427 | |
| 5428 | startRequest; |
| 5429 | appendPrintBuf("%sformat=%d,vp=%d,pid=%d,dcs=%d", printBuf, |
| 5430 | smsParams.format, smsParams.vp, smsParams.pid, smsParams.dcs); |
| 5431 | closeRequest; |
| 5432 | |
| 5433 | CALL_ONREQUEST(pRI->pCI->requestNumber, &smsParams, sizeof(smsParams), pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 5434 | |
| 5435 | #ifdef MEMSET_FREED |
| 5436 | memset(&smsParams, 0, sizeof(smsParams)); |
| 5437 | #endif |
| 5438 | |
| 5439 | return; |
| 5440 | invalid: |
| 5441 | invalidCommandBlock(pRI); |
| 5442 | return; |
| 5443 | } |
| 5444 | |
| 5445 | static int responseSmsParams(Parcel &p, void *response, size_t responselen) { |
| 5446 | if(response == NULL) { |
| 5447 | RLOGE("invalid response: NULL"); |
| 5448 | return RIL_ERRNO_INVALID_RESPONSE; |
| 5449 | } |
| 5450 | |
| 5451 | if(responselen != (int)sizeof(RIL_SmsParams)) { |
| 5452 | RLOGE("invalid response length %d expected %d", |
| 5453 | (int)responselen, (int)sizeof(RIL_SmsParams)); |
| 5454 | return RIL_ERRNO_INVALID_RESPONSE; |
| 5455 | } |
| 5456 | |
| 5457 | RIL_SmsParams *p_cur = (RIL_SmsParams *)response; |
| 5458 | p.writeInt32(p_cur->format); |
| 5459 | p.writeInt32(p_cur->vp); |
| 5460 | p.writeInt32(p_cur->pid); |
| 5461 | p.writeInt32(p_cur->dcs); |
| 5462 | |
| 5463 | startResponse; |
| 5464 | appendPrintBuf("%s%d,%d,%d,%d", printBuf, p_cur->format, p_cur->vp, |
| 5465 | p_cur->pid, p_cur->dcs); |
| 5466 | closeResponse; |
| 5467 | |
| 5468 | return 0; |
| 5469 | } |
| 5470 | |
| 5471 | //MTK-END SMS |
| 5472 | |
| 5473 | // External SIM [Start] |
| 5474 | static void dispatchVsimEvent(Parcel &p, RequestInfo *pRI) { |
| 5475 | RIL_VsimEvent args; |
| 5476 | int32_t t = 0; |
| 5477 | status_t status; |
| 5478 | |
| 5479 | memset (&args, 0, sizeof(args)); |
| 5480 | |
| 5481 | // Transcation id |
| 5482 | status = p.readInt32(&t); |
| 5483 | args.transaction_id = (int) t; |
| 5484 | |
| 5485 | // Event id |
| 5486 | status = p.readInt32(&t); |
| 5487 | args.eventId = (int) t; |
| 5488 | |
| 5489 | // Sim type |
| 5490 | status = p.readInt32(&t); |
| 5491 | args.sim_type = (int) t; |
| 5492 | |
| 5493 | startRequest; |
| 5494 | appendPrintBuf("%scmd=0x%X,transaction_id=%d,eventId=%d,sim_type=%d", printBuf, |
| 5495 | args.transaction_id, args.eventId, args.sim_type); |
| 5496 | closeRequest; |
| 5497 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 5498 | |
| 5499 | if (status != NO_ERROR) { |
| 5500 | goto invalid; |
| 5501 | } |
| 5502 | |
| 5503 | CALL_ONREQUEST(pRI->pCI->requestNumber, &args, sizeof(args), pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 5504 | |
| 5505 | return; |
| 5506 | |
| 5507 | invalid: |
| 5508 | invalidCommandBlock(pRI); |
| 5509 | return; |
| 5510 | } |
| 5511 | |
| 5512 | static void dispatchVsimOperationEvent(Parcel &p, RequestInfo *pRI) { |
| 5513 | RIL_VsimOperationEvent args; |
| 5514 | int32_t t = 0; |
| 5515 | status_t status; |
| 5516 | |
| 5517 | memset (&args, 0, sizeof(args)); |
| 5518 | |
| 5519 | // Transcation id |
| 5520 | status = p.readInt32(&t); |
| 5521 | args.transaction_id = (int) t; |
| 5522 | |
| 5523 | // Event id |
| 5524 | status = p.readInt32(&t); |
| 5525 | args.eventId = (int) t; |
| 5526 | |
| 5527 | // Result |
| 5528 | status = p.readInt32(&t); |
| 5529 | args.result = (int) t; |
| 5530 | |
| 5531 | // Data length |
| 5532 | status = p.readInt32(&t); |
| 5533 | args.data_length = (int) t; |
| 5534 | |
| 5535 | // Data array |
| 5536 | args.data = (char *)strdupReadString(p); |
| 5537 | |
| 5538 | RLOGI ("[dispatchVsimOperationEvent]%d, %d, %d, %d, data:%s, response_addr:%p", |
| 5539 | args.transaction_id, args.eventId, args.result, args.data_length, args.data, &args); |
| 5540 | |
| 5541 | startRequest; |
| 5542 | appendPrintBuf("%scmd=0x%X,transaction_id=%d,eventId=%d,result=%d, data_len=%d, data=%s", printBuf, |
| 5543 | args.transaction_id, args.eventId, args.result, args.data_length, args.data); |
| 5544 | closeRequest; |
| 5545 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 5546 | |
| 5547 | if (status != NO_ERROR) { |
| 5548 | goto invalid; |
| 5549 | } |
| 5550 | |
| 5551 | CALL_ONREQUEST(pRI->pCI->requestNumber, &args, sizeof(args), pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 5552 | |
| 5553 | return; |
| 5554 | |
| 5555 | invalid: |
| 5556 | invalidCommandBlock(pRI); |
| 5557 | return; |
| 5558 | } |
| 5559 | |
| 5560 | static int responseVsimNotificationResponse(Parcel &p, void *response, size_t responselen) { |
| 5561 | if (response == NULL) { |
| 5562 | RLOGE("invalid response: NULL"); |
| 5563 | return RIL_ERRNO_INVALID_RESPONSE; |
| 5564 | } |
| 5565 | |
| 5566 | if (responselen != sizeof(RIL_VsimEvent)) { |
| 5567 | RLOGE("invalid response length was %d expected %d", |
| 5568 | (int)responselen, (int)sizeof (RIL_VsimEvent)); |
| 5569 | return RIL_ERRNO_INVALID_RESPONSE; |
| 5570 | } |
| 5571 | |
| 5572 | RIL_VsimEvent *p_cur = ((RIL_VsimEvent *) response); |
| 5573 | p.writeInt32(p_cur->transaction_id); |
| 5574 | p.writeInt32(p_cur->eventId); |
| 5575 | p.writeInt32(p_cur->sim_type); |
| 5576 | |
| 5577 | startResponse; |
| 5578 | appendPrintBuf("%stransaction_id=%d,eventId=%d,simtype=%d", printBuf, p_cur->transaction_id, |
| 5579 | p_cur->eventId, p_cur->sim_type); |
| 5580 | closeResponse; |
| 5581 | |
| 5582 | return 0; |
| 5583 | } |
| 5584 | |
| 5585 | static int responseVsimOperationEvent(Parcel &p, void *response, size_t responselen) { |
| 5586 | if (response == NULL) { |
| 5587 | RLOGE("invalid response: NULL"); |
| 5588 | return RIL_ERRNO_INVALID_RESPONSE; |
| 5589 | } |
| 5590 | |
| 5591 | if (responselen != sizeof (RIL_VsimOperationEvent) ) { |
| 5592 | RLOGE("invalid response length was %d expected %d", |
| 5593 | (int)responselen, (int)sizeof (RIL_VsimOperationEvent)); |
| 5594 | return RIL_ERRNO_INVALID_RESPONSE; |
| 5595 | } |
| 5596 | |
| 5597 | RIL_VsimOperationEvent *p_cur = (RIL_VsimOperationEvent *) response; |
| 5598 | p.writeInt32(p_cur->transaction_id); |
| 5599 | p.writeInt32(p_cur->eventId); |
| 5600 | p.writeInt32(p_cur->result); |
| 5601 | p.writeInt32(p_cur->data_length); |
| 5602 | writeStringToParcel(p, p_cur->data); |
| 5603 | |
| 5604 | startResponse; |
| 5605 | appendPrintBuf("%stransaction_id=%d,eventId=%d,datalen=%d", printBuf, p_cur->transaction_id, |
| 5606 | p_cur->eventId, p_cur->data_length); |
| 5607 | closeResponse; |
| 5608 | |
| 5609 | return 0; |
| 5610 | } |
| 5611 | // External SIM [Start] |
| 5612 | |
| 5613 | |
| 5614 | /** |
| 5615 | * A write on the wakeup fd is done just to pop us out of select() |
| 5616 | * We empty the buffer here and then ril_event will reset the timers on the |
| 5617 | * way back down |
| 5618 | */ |
| 5619 | static void processWakeupCallback(int fd, short flags, void *param) { |
| 5620 | char buff[16]; |
| 5621 | int ret; |
| 5622 | |
| 5623 | RLOGV("processWakeupCallback"); |
| 5624 | |
| 5625 | /* empty our wakeup socket out */ |
| 5626 | do { |
| 5627 | ret = read(s_fdWakeupRead, &buff, sizeof(buff)); |
| 5628 | } while (ret > 0 || (ret < 0 && errno == EINTR)); |
| 5629 | } |
| 5630 | |
| 5631 | static void onCommandsSocketClosed(RIL_SOCKET_ID socket_id, int clientId) { |
| 5632 | int ret; |
| 5633 | RequestInfo *p_cur; |
| 5634 | /* Hook for current context |
| 5635 | pendingRequestsMutextHook refer to &s_pendingRequestsMutex */ |
| 5636 | pthread_mutex_t * pendingRequestsMutexHook = &s_pendingRequestsMutex; |
| 5637 | /* pendingRequestsHook refer to &s_pendingRequests */ |
| 5638 | RequestInfo ** pendingRequestsHook = &s_pendingRequests; |
| 5639 | |
| 5640 | if (socket_id == RIL_SOCKET_2) { |
| 5641 | pendingRequestsMutexHook = &s_pendingRequestsMutex_socket2; |
| 5642 | pendingRequestsHook = &s_pendingRequests_socket2; |
| 5643 | } |
| 5644 | else if (socket_id == RIL_SOCKET_3) { |
| 5645 | pendingRequestsMutexHook = &s_pendingRequestsMutex_socket3; |
| 5646 | pendingRequestsHook = &s_pendingRequests_socket3; |
| 5647 | } |
| 5648 | else if (socket_id == RIL_SOCKET_4) { |
| 5649 | pendingRequestsMutexHook = &s_pendingRequestsMutex_socket4; |
| 5650 | pendingRequestsHook = &s_pendingRequests_socket4; |
| 5651 | } |
| 5652 | else if (socket_id == RIL_SOCKET_RILJ) { |
| 5653 | pendingRequestsMutexHook = &s_pendingRequestsMutex_socket_rilj; |
| 5654 | pendingRequestsHook = &s_pendingRequests_socket_rilj; |
| 5655 | } |
| 5656 | else if (socket_id == RIL_SOCKET_RILJ2) { |
| 5657 | pendingRequestsMutexHook = &s_pendingRequestsMutex_socket_rilj2; |
| 5658 | pendingRequestsHook = &s_pendingRequests_socket_rilj2; |
| 5659 | } |
| 5660 | |
| 5661 | if (clientId >= 0) { |
| 5662 | pendingRequestsMutexHook = &s_pendingRequestsMutex_socket_client[clientId]; |
| 5663 | pendingRequestsHook = &s_pendingRequests_socket_client[clientId]; |
| 5664 | } |
| 5665 | |
| 5666 | /// M: Hangup all if the socket is closed. |
| 5667 | issueLocalRequest(RIL_REQUEST_HANGUP_ALL, NULL, 0, socket_id); |
| 5668 | |
| 5669 | /* mark pending requests as "cancelled" so we dont report responses */ |
| 5670 | ret = pthread_mutex_lock(pendingRequestsMutexHook); |
| 5671 | assert (ret == 0); |
| 5672 | |
| 5673 | p_cur = *pendingRequestsHook; |
| 5674 | |
| 5675 | for (p_cur = *pendingRequestsHook |
| 5676 | ; p_cur != NULL |
| 5677 | ; p_cur = p_cur->p_next |
| 5678 | ) { |
| 5679 | p_cur->cancelled = 1; |
| 5680 | } |
| 5681 | |
| 5682 | ret = pthread_mutex_unlock(pendingRequestsMutexHook); |
| 5683 | assert (ret == 0); |
| 5684 | } |
| 5685 | |
| 5686 | static void processCommandsCallback(int fd, short flags, void *param) { |
| 5687 | RecordStream *p_rs; |
| 5688 | void *p_record; |
| 5689 | size_t recordlen; |
| 5690 | int ret; |
| 5691 | SocketListenParam *p_info = (SocketListenParam *)param; |
| 5692 | int slot_id = p_info->slot_id; |
| 5693 | int clientId_tmp = (true == isDsds())? ((p_info->clientId)/2) : (p_info->clientId); |
| 5694 | sem_t* sem; |
| 5695 | |
| 5696 | assert(fd == p_info->fdCommand); |
| 5697 | |
| 5698 | p_rs = p_info->p_rs; |
| 5699 | |
| 5700 | for (;;) { |
| 5701 | /* loop until EAGAIN/EINTR, end of stream, or other error */ |
| 5702 | ret = record_stream_get_next(p_rs, &p_record, &recordlen); |
| 5703 | |
| 5704 | if (ret == 0 && p_record == NULL) { |
| 5705 | /* end-of-stream */ |
| 5706 | break; |
| 5707 | } else if (ret < 0) { |
| 5708 | break; |
| 5709 | } else if (ret == 0) { /* && p_record != NULL */ |
| 5710 | processCommandBuffer(p_record, recordlen, p_info->socket_id, p_info->clientId); |
| 5711 | } |
| 5712 | } |
| 5713 | |
| 5714 | if (ret == 0 || !(errno == EAGAIN || errno == EINTR)) { |
| 5715 | /* fatal error or end-of-stream */ |
| 5716 | if (ret != 0) { |
| 5717 | RLOGE("rild error on reading command socket errno:%d\n", errno); |
| 5718 | } else { |
| 5719 | RLOGW("EOS. Closing command socket."); |
| 5720 | } |
| 5721 | |
| 5722 | close(fd); |
| 5723 | p_info->fdCommand = -1; |
| 5724 | |
| 5725 | if (p_info->clientId >= 0) { |
| 5726 | s_fdCommand_client[p_info->clientId] = -1; |
| 5727 | } else { |
| 5728 | s_fdCommand[p_info->socket_id] = -1; |
| 5729 | } |
| 5730 | |
| 5731 | ril_event_del(p_info->commands_event); |
| 5732 | |
| 5733 | record_stream_free(p_rs); |
| 5734 | RLOGD("[processCommandsCallback] get semaphone: %s", semName[slot_id]); |
| 5735 | sem = sem_open(semName[slot_id], O_CREAT, 0644, 1); |
| 5736 | if(SEM_FAILED == sem) { |
| 5737 | RLOGD("[processCommandsCallback]sem_open failed, errno = %d (%s)", errno, strerror(errno)); |
| 5738 | } |
| 5739 | sem_wait(sem); |
| 5740 | changeClientSoketStatus(slot_id, clientId_tmp, 0); |
| 5741 | sem_post(sem); |
| 5742 | RLOGD("[processCommandsCallback] release semaphone: %s", semName[slot_id]); |
| 5743 | sem_close(sem); |
| 5744 | /* start listening for new connections again */ |
| 5745 | rilEventAddWakeup(p_info->listen_event); |
| 5746 | |
| 5747 | onCommandsSocketClosed(p_info->socket_id, p_info->clientId); |
| 5748 | } |
| 5749 | } |
| 5750 | |
| 5751 | |
| 5752 | static void onNewCommandConnect(RIL_SOCKET_ID socket_id, int clientId) { |
| 5753 | // Inform we are connected and the ril version |
| 5754 | int rilVer = s_callbacks.version; |
| 5755 | /// support rilj client @{ |
| 5756 | SocketListenParam* soc_params = NULL; |
| 5757 | |
| 5758 | for (int i = 0; i < NUM_ELEMS(s_ril_socket_params); i++) { |
| 5759 | /// since vendor ril using socket id, mapping to libril's slot id |
| 5760 | if (s_ril_socket_params[i]->socket_id == socket_id) { |
| 5761 | soc_params = s_ril_socket_params[i]; |
| 5762 | break; |
| 5763 | } |
| 5764 | } |
| 5765 | if (clientId >= 0) { |
| 5766 | soc_params = &s_ril_param_socket_clients[clientId]; |
| 5767 | } |
| 5768 | |
| 5769 | if (soc_params == NULL) { |
| 5770 | RLOGE("onNewCommandConnect invalid socket id %d", socket_id); |
| 5771 | return; |
| 5772 | } |
| 5773 | RLOGD("onNewCommandConnect rilversion %d",rilVer); |
| 5774 | Parcel *parcel = new Parcel(); |
| 5775 | if(parcel == NULL) { |
| 5776 | RLOGE("onNewCommandConnect new parcel fail!!!"); |
| 5777 | return; |
| 5778 | } |
| 5779 | parcel->writeInt32(1); |
| 5780 | parcel->writeInt32(rilVer); |
| 5781 | RIL_onUnsolicitedResponseInternal(RIL_UNSOL_RIL_CONNECTED, |
| 5782 | parcel, parcel->dataSize(), soc_params); |
| 5783 | |
| 5784 | // implicit radio state changed |
| 5785 | RIL_onUnsolicitedResponseInternal(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, |
| 5786 | NULL, 0, soc_params); |
| 5787 | /// @} |
| 5788 | |
| 5789 | // Send last NITZ time data, in case it was missed |
| 5790 | if (s_lastNITZTimeData != NULL) { |
| 5791 | RLOGE("onNewCommandConnect send last NTIZ to socket_id=%d", socket_id); |
| 5792 | sendResponseRaw(s_lastNITZTimeData, s_lastNITZTimeDataSize, socket_id, clientId); |
| 5793 | // for multi user, we keep the nitz data for the next one. |
| 5794 | /* |
| 5795 | free(s_lastNITZTimeData); |
| 5796 | s_lastNITZTimeData = NULL; |
| 5797 | */ |
| 5798 | } |
| 5799 | |
| 5800 | // Get version string |
| 5801 | if (s_callbacks.getVersion != NULL) { |
| 5802 | const char *version; |
| 5803 | version = s_callbacks.getVersion(); |
| 5804 | RLOGI("RIL Daemon version: %s\n", version); |
| 5805 | |
| 5806 | mtk_property_set(PROPERTY_RIL_IMPL, version); |
| 5807 | } else { |
| 5808 | RLOGI("RIL Daemon version: unavailable\n"); |
| 5809 | mtk_property_set(PROPERTY_RIL_IMPL, "unavailable"); |
| 5810 | } |
| 5811 | |
| 5812 | delete(parcel); |
| 5813 | } |
| 5814 | |
| 5815 | static void listenCallback (int fd, short flags, void *param) { |
| 5816 | int ret; |
| 5817 | int err; |
| 5818 | int is_phone_socket; |
| 5819 | int fdCommand = -1; |
| 5820 | const char* processName; |
| 5821 | RecordStream *p_rs; |
| 5822 | MySocketListenParam* listenParam; |
| 5823 | RilSocket *sapSocket = NULL; |
| 5824 | socketClient *sClient = NULL; |
| 5825 | |
| 5826 | SocketListenParam *p_info = (SocketListenParam *)param; |
| 5827 | |
| 5828 | if(RIL_SAP_SOCKET == p_info->type) { |
| 5829 | listenParam = (MySocketListenParam *)param; |
| 5830 | sapSocket = listenParam->socket; |
| 5831 | } |
| 5832 | |
| 5833 | struct sockaddr_un peeraddr; |
| 5834 | socklen_t socklen = sizeof (peeraddr); |
| 5835 | |
| 5836 | struct ucred creds; |
| 5837 | socklen_t szCreds = sizeof(creds); |
| 5838 | |
| 5839 | struct passwd *pwd = NULL; |
| 5840 | |
| 5841 | if(NULL == sapSocket) { |
| 5842 | assert (p_info->fdCommand < 0); |
| 5843 | assert (fd == p_info->fdListen); |
| 5844 | processName = PHONE_PROCESS; |
| 5845 | } else { |
| 5846 | assert (sapSocket->getCommandFd() < 0); |
| 5847 | assert (fd == sapSocket->getListenFd()); |
| 5848 | processName = BLUETOOTH_PROCESS; |
| 5849 | } |
| 5850 | |
| 5851 | |
| 5852 | fdCommand = accept(fd, (sockaddr *) &peeraddr, &socklen); |
| 5853 | |
| 5854 | if (fdCommand < 0 ) { |
| 5855 | RLOGE("Error on accept() errno:%d", errno); |
| 5856 | /* start listening for new connections again */ |
| 5857 | if(NULL == sapSocket) { |
| 5858 | rilEventAddWakeup(p_info->listen_event); |
| 5859 | } else { |
| 5860 | rilEventAddWakeup(sapSocket->getListenEvent()); |
| 5861 | } |
| 5862 | return; |
| 5863 | } |
| 5864 | |
| 5865 | /* check the credential of the other side and only accept socket from |
| 5866 | * phone process |
| 5867 | */ |
| 5868 | errno = 0; |
| 5869 | is_phone_socket = 1; |
| 5870 | |
| 5871 | err = getsockopt(fdCommand, SOL_SOCKET, SO_PEERCRED, &creds, &szCreds); |
| 5872 | |
| 5873 | if (err == 0 && szCreds > 0) { |
| 5874 | errno = 0; |
| 5875 | pwd = getpwuid(creds.uid); |
| 5876 | if (pwd != NULL) { |
| 5877 | /*TODO:bringup disable process check |
| 5878 | if (strcmp(pwd->pw_name, processName) == 0) { |
| 5879 | is_phone_socket = 1; |
| 5880 | } else { |
| 5881 | RLOGE("RILD can't accept socket from process %s", pwd->pw_name); |
| 5882 | }*/ |
| 5883 | RLOGD("RILD receive socket request from process %s", pwd->pw_name); |
| 5884 | is_phone_socket = 1; |
| 5885 | } else { |
| 5886 | RLOGE("Error on getpwuid() errno: %d", errno); |
| 5887 | } |
| 5888 | } else { |
| 5889 | RLOGD("Error on getsockopt() errno: %d", errno); |
| 5890 | } |
| 5891 | |
| 5892 | if (!is_phone_socket) { |
| 5893 | RLOGE("RILD must accept socket from %s", processName); |
| 5894 | |
| 5895 | close(fdCommand); |
| 5896 | fdCommand = -1; |
| 5897 | |
| 5898 | if(NULL == sapSocket) { |
| 5899 | onCommandsSocketClosed(p_info->socket_id, p_info->clientId); |
| 5900 | |
| 5901 | /* start listening for new connections again */ |
| 5902 | rilEventAddWakeup(p_info->listen_event); |
| 5903 | } else { |
| 5904 | sapSocket->onCommandsSocketClosed(); |
| 5905 | |
| 5906 | /* start listening for new connections again */ |
| 5907 | rilEventAddWakeup(sapSocket->getListenEvent()); |
| 5908 | } |
| 5909 | |
| 5910 | return; |
| 5911 | } |
| 5912 | |
| 5913 | ret = fcntl(fdCommand, F_SETFL, O_NONBLOCK); |
| 5914 | |
| 5915 | if (ret < 0) { |
| 5916 | RLOGE ("Error setting O_NONBLOCK errno:%d", errno); |
| 5917 | } |
| 5918 | |
| 5919 | if(NULL == sapSocket) { |
| 5920 | RLOGI("libril: new connection to %s, clientId:%d", |
| 5921 | rilSocketIdToString(p_info->socket_id), p_info->clientId); |
| 5922 | |
| 5923 | p_info->fdCommand = fdCommand; |
| 5924 | p_rs = record_stream_new(p_info->fdCommand, MAX_COMMAND_BYTES); |
| 5925 | p_info->p_rs = p_rs; |
| 5926 | |
| 5927 | ril_event_set (p_info->commands_event, p_info->fdCommand, 1, |
| 5928 | p_info->processCommandsCallback, p_info); |
| 5929 | rilEventAddWakeup (p_info->commands_event); |
| 5930 | |
| 5931 | onNewCommandConnect(p_info->socket_id, p_info->clientId); |
| 5932 | |
| 5933 | // M: ril proxy |
| 5934 | pthread_mutex_lock(&s_pendingUrcMutex[p_info->socket_id]); |
| 5935 | if (p_info->clientId >= 0) { |
| 5936 | s_fdCommand_client[p_info->clientId] = p_info->fdCommand; |
| 5937 | } else { |
| 5938 | s_fdCommand[p_info->socket_id] = p_info->fdCommand; |
| 5939 | } |
| 5940 | sendPendedUrcs(p_info->socket_id, p_info->fdCommand); |
| 5941 | pthread_mutex_unlock(&s_pendingUrcMutex[p_info->socket_id]); |
| 5942 | // |
| 5943 | } else { |
| 5944 | RLOGI("libril: new connection"); |
| 5945 | |
| 5946 | sapSocket->setCommandFd(fdCommand); |
| 5947 | p_rs = record_stream_new(sapSocket->getCommandFd(), MAX_COMMAND_BYTES); |
| 5948 | sClient = new socketClient(sapSocket,p_rs); |
| 5949 | ril_event_set (sapSocket->getCallbackEvent(), sapSocket->getCommandFd(), 1, |
| 5950 | sapSocket->getCommandCb(), sClient); |
| 5951 | |
| 5952 | rilEventAddWakeup(sapSocket->getCallbackEvent()); |
| 5953 | sapSocket->onNewCommandConnect(); |
| 5954 | } |
| 5955 | } |
| 5956 | |
| 5957 | static void freeDebugCallbackArgs(int number, char **args) { |
| 5958 | for (int i = 0; i < number; i++) { |
| 5959 | if (args[i] != NULL) { |
| 5960 | free(args[i]); |
| 5961 | } |
| 5962 | } |
| 5963 | free(args); |
| 5964 | } |
| 5965 | |
| 5966 | static void debugCallback (int fd, short flags, void *param) { |
| 5967 | int acceptFD, option; |
| 5968 | struct sockaddr_un peeraddr; |
| 5969 | socklen_t socklen = sizeof (peeraddr); |
| 5970 | int data; |
| 5971 | unsigned int qxdm_data[6]; |
| 5972 | const char *deactData[1] = {"1"}; |
| 5973 | RIL_Dial dialData; |
| 5974 | int hangupData[1] = {1}; |
| 5975 | int number; |
| 5976 | char **args; |
| 5977 | RIL_SOCKET_ID socket_id = RIL_SOCKET_1; |
| 5978 | int MAX_DIAL_ADDRESS = 128; |
| 5979 | int sim_id = 0; |
| 5980 | |
| 5981 | RLOGI("debugCallback for socket %s", rilSocketIdToString(socket_id)); |
| 5982 | |
| 5983 | acceptFD = accept (fd, (sockaddr *) &peeraddr, &socklen); |
| 5984 | |
| 5985 | if (acceptFD < 0) { |
| 5986 | RLOGE ("error accepting on debug port: %d\n", errno); |
| 5987 | return; |
| 5988 | } |
| 5989 | |
| 5990 | if (recv(acceptFD, &number, sizeof(int), 0) != sizeof(int)) { |
| 5991 | RLOGE ("error reading on socket: number of Args: \n"); |
| 5992 | close(acceptFD); |
| 5993 | return; |
| 5994 | } |
| 5995 | |
| 5996 | if (number < 0) { |
| 5997 | RLOGE ("Invalid number of arguments: \n"); |
| 5998 | close(acceptFD); |
| 5999 | return; |
| 6000 | } |
| 6001 | |
| 6002 | args = (char **) calloc(number, sizeof(char*)); |
| 6003 | if (args == NULL) { |
| 6004 | RLOGE("Memory allocation failed for debug args"); |
| 6005 | close(acceptFD); |
| 6006 | return; |
| 6007 | } |
| 6008 | |
| 6009 | for (int i = 0; i < number; i++) { |
| 6010 | int len; |
| 6011 | if (recv(acceptFD, &len, sizeof(int), 0) != sizeof(int)) { |
| 6012 | RLOGE ("error reading on socket: Len of Args: \n"); |
| 6013 | freeDebugCallbackArgs(i, args); |
| 6014 | close(acceptFD); |
| 6015 | return; |
| 6016 | } |
| 6017 | if (len == INT_MAX || len < 0) { |
| 6018 | RLOGE("Invalid value of len: \n"); |
| 6019 | freeDebugCallbackArgs(i, args); |
| 6020 | close(acceptFD); |
| 6021 | return; |
| 6022 | } |
| 6023 | |
| 6024 | // +1 for null-term |
| 6025 | args[i] = (char *) calloc(len + 1, sizeof(char)); |
| 6026 | if (args[i] == NULL) { |
| 6027 | RLOGE("Memory allocation failed for debug args"); |
| 6028 | freeDebugCallbackArgs(i, args); |
| 6029 | close(acceptFD); |
| 6030 | return; |
| 6031 | } |
| 6032 | if (recv(acceptFD, args[i], sizeof(char) * len, 0) |
| 6033 | != (int)sizeof(char) * len) { |
| 6034 | RLOGE ("error reading on socket: Args[%d] \n", i); |
| 6035 | freeDebugCallbackArgs(i, args); |
| 6036 | close(acceptFD); |
| 6037 | return; |
| 6038 | } |
| 6039 | char * buf = args[i]; |
| 6040 | buf[len] = 0; |
| 6041 | if ((i+1) == number) { |
| 6042 | /* The last argument should be sim id 0(SIM1)~3(SIM4) */ |
| 6043 | sim_id = atoi(args[i]); |
| 6044 | switch (sim_id) { |
| 6045 | case 0: |
| 6046 | socket_id = RIL_SOCKET_1; |
| 6047 | break; |
| 6048 | case 1: |
| 6049 | socket_id = RIL_SOCKET_2; |
| 6050 | break; |
| 6051 | case 2: |
| 6052 | socket_id = RIL_SOCKET_3; |
| 6053 | break; |
| 6054 | case 3: |
| 6055 | socket_id = RIL_SOCKET_4; |
| 6056 | break; |
| 6057 | default: |
| 6058 | socket_id = RIL_SOCKET_1; |
| 6059 | break; |
| 6060 | } |
| 6061 | } |
| 6062 | } |
| 6063 | |
| 6064 | switch (atoi(args[0])) { |
| 6065 | case 0: |
| 6066 | RLOGI ("Connection on debug port: issuing reset."); |
| 6067 | issueLocalRequest(RIL_REQUEST_RESET_RADIO, NULL, 0, socket_id); |
| 6068 | break; |
| 6069 | case 1: |
| 6070 | RLOGI ("Connection on debug port: issuing radio power off."); |
| 6071 | data = 0; |
| 6072 | issueLocalRequest(RIL_REQUEST_RADIO_POWER, &data, sizeof(int), socket_id); |
| 6073 | // Close the socket |
| 6074 | if (socket_id == RIL_SOCKET_1 && s_ril_param_socket.fdCommand > 0) { |
| 6075 | close(s_ril_param_socket.fdCommand); |
| 6076 | s_ril_param_socket.fdCommand = -1; |
| 6077 | } |
| 6078 | else if (socket_id == RIL_SOCKET_2 && s_ril_param_socket2.fdCommand > 0) { |
| 6079 | close(s_ril_param_socket2.fdCommand); |
| 6080 | s_ril_param_socket2.fdCommand = -1; |
| 6081 | } |
| 6082 | break; |
| 6083 | case 2: |
| 6084 | RLOGI ("Debug port: issuing unsolicited voice network change."); |
| 6085 | RIL_UNSOL_RESPONSE(RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED, NULL, 0, socket_id); |
| 6086 | break; |
| 6087 | case 3: |
| 6088 | RLOGI ("Debug port: QXDM log enable."); |
| 6089 | qxdm_data[0] = 65536; // head.func_tag |
| 6090 | qxdm_data[1] = 16; // head.len |
| 6091 | qxdm_data[2] = 1; // mode: 1 for 'start logging' |
| 6092 | qxdm_data[3] = 32; // log_file_size: 32megabytes |
| 6093 | qxdm_data[4] = 0; // log_mask |
| 6094 | qxdm_data[5] = 8; // log_max_fileindex |
| 6095 | issueLocalRequest(RIL_REQUEST_OEM_HOOK_RAW, qxdm_data, |
| 6096 | 6 * sizeof(int), socket_id); |
| 6097 | break; |
| 6098 | case 4: |
| 6099 | RLOGI ("Debug port: QXDM log disable."); |
| 6100 | qxdm_data[0] = 65536; |
| 6101 | qxdm_data[1] = 16; |
| 6102 | qxdm_data[2] = 0; // mode: 0 for 'stop logging' |
| 6103 | qxdm_data[3] = 32; |
| 6104 | qxdm_data[4] = 0; |
| 6105 | qxdm_data[5] = 8; |
| 6106 | issueLocalRequest(RIL_REQUEST_OEM_HOOK_RAW, qxdm_data, |
| 6107 | 6 * sizeof(int), socket_id); |
| 6108 | break; |
| 6109 | case 5: |
| 6110 | RLOGI("Debug port: Radio On"); |
| 6111 | data = 1; |
| 6112 | issueLocalRequest(RIL_REQUEST_RADIO_POWER, &data, sizeof(int), socket_id); |
| 6113 | sleep(2); |
| 6114 | // Set network selection automatic. |
| 6115 | issueLocalRequest(RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC, NULL, 0, socket_id); |
| 6116 | break; |
| 6117 | case 7: |
| 6118 | RLOGI("Debug port: Deactivate Data Call"); |
| 6119 | issueLocalRequest(RIL_REQUEST_DEACTIVATE_DATA_CALL, &deactData, |
| 6120 | sizeof(deactData), socket_id); |
| 6121 | break; |
| 6122 | case 8: |
| 6123 | RLOGI("Debug port: Dial Call"); |
| 6124 | dialData.clir = 0; |
| 6125 | if (strlen(args[1]) > MAX_DIAL_ADDRESS) { |
| 6126 | RLOGE("Debug port: Error calling Dial"); |
| 6127 | freeDebugCallbackArgs(number, args); |
| 6128 | close(acceptFD); |
| 6129 | return; |
| 6130 | } |
| 6131 | dialData.address = args[1]; |
| 6132 | issueLocalRequest(RIL_REQUEST_DIAL, &dialData, sizeof(dialData), socket_id); |
| 6133 | break; |
| 6134 | case 9: |
| 6135 | RLOGI("Debug port: Answer Call"); |
| 6136 | issueLocalRequest(RIL_REQUEST_ANSWER, NULL, 0, socket_id); |
| 6137 | break; |
| 6138 | case 10: |
| 6139 | RLOGI("Debug port: End Call"); |
| 6140 | issueLocalRequest(RIL_REQUEST_HANGUP, &hangupData, |
| 6141 | sizeof(hangupData), socket_id); |
| 6142 | break; |
| 6143 | default: |
| 6144 | RLOGE ("Invalid request"); |
| 6145 | break; |
| 6146 | } |
| 6147 | freeDebugCallbackArgs(number, args); |
| 6148 | close(acceptFD); |
| 6149 | } |
| 6150 | |
| 6151 | |
| 6152 | static void userTimerCallback (int fd, short flags, void *param) { |
| 6153 | UserCallbackInfo *p_info; |
| 6154 | |
| 6155 | p_info = (UserCallbackInfo *)param; |
| 6156 | |
| 6157 | p_info->p_callback(p_info->userParam); |
| 6158 | |
| 6159 | |
| 6160 | // FIXME generalize this...there should be a cancel mechanism |
| 6161 | if (s_last_wake_timeout_info != NULL && s_last_wake_timeout_info == p_info) { |
| 6162 | s_last_wake_timeout_info = NULL; |
| 6163 | } |
| 6164 | |
| 6165 | free(p_info); |
| 6166 | } |
| 6167 | |
| 6168 | |
| 6169 | static void * |
| 6170 | eventLoop(void *param) { |
| 6171 | int ret; |
| 6172 | int filedes[2]; |
| 6173 | |
| 6174 | ril_event_init(); |
| 6175 | |
| 6176 | pthread_mutex_lock(&s_startupMutex); |
| 6177 | |
| 6178 | s_started = 1; |
| 6179 | pthread_cond_broadcast(&s_startupCond); |
| 6180 | |
| 6181 | pthread_mutex_unlock(&s_startupMutex); |
| 6182 | |
| 6183 | ret = pipe(filedes); |
| 6184 | |
| 6185 | if (ret < 0) { |
| 6186 | RLOGE("Error in pipe() errno:%d", errno); |
| 6187 | return NULL; |
| 6188 | } |
| 6189 | |
| 6190 | s_fdWakeupRead = filedes[0]; |
| 6191 | s_fdWakeupWrite = filedes[1]; |
| 6192 | |
| 6193 | fcntl(s_fdWakeupRead, F_SETFL, O_NONBLOCK); |
| 6194 | |
| 6195 | ril_event_set (&s_wakeupfd_event, s_fdWakeupRead, true, |
| 6196 | processWakeupCallback, NULL); |
| 6197 | |
| 6198 | rilEventAddWakeup (&s_wakeupfd_event); |
| 6199 | |
| 6200 | // Only returns on error |
| 6201 | ril_event_loop(); |
| 6202 | RLOGE ("error in event_loop_base errno:%d", errno); |
| 6203 | // kill self to restart on error |
| 6204 | kill(0, SIGKILL); |
| 6205 | |
| 6206 | return NULL; |
| 6207 | } |
| 6208 | |
| 6209 | extern "C" void |
| 6210 | RIL_startEventLoop(void) { |
| 6211 | /* spin up eventLoop thread and wait for it to get started */ |
| 6212 | s_started = 0; |
| 6213 | pthread_mutex_lock(&s_startupMutex); |
| 6214 | |
| 6215 | pthread_attr_t attr; |
| 6216 | pthread_attr_init(&attr); |
| 6217 | pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); |
| 6218 | |
| 6219 | int result = pthread_create(&s_tid_dispatch, &attr, eventLoop, NULL); |
| 6220 | if (result != 0) { |
| 6221 | RLOGE("Failed to create dispatch thread: %s", strerror(result)); |
| 6222 | goto done; |
| 6223 | } |
| 6224 | |
| 6225 | while (s_started == 0) { |
| 6226 | pthread_cond_wait(&s_startupCond, &s_startupMutex); |
| 6227 | } |
| 6228 | |
| 6229 | done: |
| 6230 | pthread_mutex_unlock(&s_startupMutex); |
| 6231 | } |
| 6232 | |
| 6233 | extern "C" void |
| 6234 | RIL_startNetagent(void) { |
| 6235 | |
| 6236 | |
| 6237 | RLOGD("start NetAgentService"); |
| 6238 | bool bSuccess = false; |
| 6239 | do { |
| 6240 | bSuccess = NetAgentService::createNetAgentService(); |
| 6241 | if(!bSuccess) { |
| 6242 | RLOGE("Fail to create NetAgent service!"); |
| 6243 | sleep(10); |
| 6244 | /* never returns */ |
| 6245 | } |
| 6246 | } while (!bSuccess); |
| 6247 | |
| 6248 | RLOGD("started NetAgentService"); |
| 6249 | } |
| 6250 | |
| 6251 | |
| 6252 | // Used for testing purpose only. |
| 6253 | extern "C" void RIL_setcallbacks (const RIL_RadioFunctions *callbacks) { |
| 6254 | memcpy(&s_callbacks, callbacks, sizeof (RIL_RadioFunctions)); |
| 6255 | } |
| 6256 | |
| 6257 | static void startListen(RIL_SOCKET_ID socket_id, SocketListenParam* socket_listen_p) { |
| 6258 | int fdListen = -1; |
| 6259 | int ret; |
| 6260 | char socket_name[20]; |
| 6261 | |
| 6262 | memset(socket_name, 0, sizeof(char)*20); |
| 6263 | |
| 6264 | switch(socket_id) { |
| 6265 | case RIL_SOCKET_1: |
| 6266 | strncpy(socket_name, RIL_getRilSocketName(), 19); |
| 6267 | break; |
| 6268 | case RIL_SOCKET_2: |
| 6269 | strncpy(socket_name, SOCKET2_NAME_RIL, 19); |
| 6270 | break; |
| 6271 | case RIL_SOCKET_3: |
| 6272 | strncpy(socket_name, SOCKET3_NAME_RIL, 19); |
| 6273 | break; |
| 6274 | case RIL_SOCKET_4: |
| 6275 | strncpy(socket_name, SOCKET4_NAME_RIL, 19); |
| 6276 | break; |
| 6277 | case RIL_SOCKET_RILJ: |
| 6278 | strncpy(socket_name, SOCKET_NAME_RILJCLIENT, 19); |
| 6279 | break; |
| 6280 | case RIL_SOCKET_RILJ2: |
| 6281 | strncpy(socket_name, SOCKET2_NAME_RILJCLIENT, 19); |
| 6282 | break; |
| 6283 | default: |
| 6284 | RLOGE("Socket id is wrong!!"); |
| 6285 | return; |
| 6286 | } |
| 6287 | |
| 6288 | RLOGI("Start to listen %s %s", rilSocketIdToString(socket_id), socket_name); |
| 6289 | |
| 6290 | fdListen = android_get_control_socket(socket_name); |
| 6291 | if (fdListen < 0) { |
| 6292 | RLOGE("Failed to get socket %s", socket_name); |
| 6293 | exit(-1); |
| 6294 | } |
| 6295 | |
| 6296 | ret = listen(fdListen, 4); |
| 6297 | |
| 6298 | if (ret < 0) { |
| 6299 | RLOGE("Failed to listen on control socket '%d': %s", |
| 6300 | fdListen, strerror(errno)); |
| 6301 | exit(-1); |
| 6302 | } |
| 6303 | socket_listen_p->fdListen = fdListen; |
| 6304 | |
| 6305 | /* note: non-persistent so we can accept only one connection at a time */ |
| 6306 | ril_event_set (socket_listen_p->listen_event, fdListen, false, |
| 6307 | listenCallback, socket_listen_p); |
| 6308 | |
| 6309 | rilEventAddWakeup (socket_listen_p->listen_event); |
| 6310 | } |
| 6311 | |
| 6312 | static bool isRiljEnable() { |
| 6313 | if (s_riljclient_support != -1) { |
| 6314 | return s_riljclient_support; |
| 6315 | } else { |
| 6316 | char rilj_support[PROP_VALUE_MAX] = { 0 }; |
| 6317 | mtk_property_get(RILJ_CLIENT_SUPPORT_KEY, rilj_support, "0"); |
| 6318 | if (strcmp(rilj_support, "1") == 0) { |
| 6319 | return true; |
| 6320 | } |
| 6321 | return false; |
| 6322 | } |
| 6323 | } |
| 6324 | |
| 6325 | bool isDsds() { |
| 6326 | char isDsdsString[PROP_VALUE_MAX] = {0}; |
| 6327 | mtk_property_get("persist.radio.multisim.config", isDsdsString, ""); |
| 6328 | if (strcmp(isDsdsString, "dsds") == 0) { |
| 6329 | return true; |
| 6330 | } else { |
| 6331 | return false; |
| 6332 | } |
| 6333 | } |
| 6334 | |
| 6335 | static int getDisableSim() { |
| 6336 | char disableSimNum[PROP_VALUE_MAX] = {0}; |
| 6337 | mtk_property_get("persist.radio.dsss.sim.disable", disableSimNum, ""); |
| 6338 | if (strcmp(disableSimNum, "1") == 0) { |
| 6339 | return 1; |
| 6340 | } else if (strcmp(disableSimNum, "2") == 0) { |
| 6341 | return 2; |
| 6342 | } else { |
| 6343 | return 0; |
| 6344 | } |
| 6345 | } |
| 6346 | |
| 6347 | static void initSocketParam(int clientId, int listenFd) { |
| 6348 | bool isDsdsClient = isDsds(); |
| 6349 | int disableSim = getDisableSim(); |
| 6350 | if (isDsdsClient) { |
| 6351 | if((clientId % 2) == 1){ |
| 6352 | s_ril_param_socket_clients[clientId].socket_id = RIL_SOCKET_2; |
| 6353 | s_ril_param_socket_clients[clientId].slot_id = RIL_SLOT_2; |
| 6354 | } else { |
| 6355 | s_ril_param_socket_clients[clientId].socket_id = RIL_SOCKET_1; |
| 6356 | s_ril_param_socket_clients[clientId].slot_id = RIL_SLOT_1; |
| 6357 | } |
| 6358 | } else { |
| 6359 | if (disableSim == 1) { |
| 6360 | s_ril_param_socket_clients[clientId].socket_id = RIL_SOCKET_2; |
| 6361 | s_ril_param_socket_clients[clientId].slot_id = RIL_SLOT_2; |
| 6362 | } else { |
| 6363 | s_ril_param_socket_clients[clientId].socket_id = RIL_SOCKET_1; |
| 6364 | s_ril_param_socket_clients[clientId].slot_id = RIL_SLOT_1; |
| 6365 | } |
| 6366 | } |
| 6367 | s_ril_param_socket_clients[clientId].fdListen = listenFd; |
| 6368 | s_ril_param_socket_clients[clientId].fdCommand = -1; |
| 6369 | s_ril_param_socket_clients[clientId].processName = PHONE_PROCESS; |
| 6370 | s_ril_param_socket_clients[clientId].commands_event = &s_commands_event_socket_client[clientId]; |
| 6371 | s_ril_param_socket_clients[clientId].listen_event = &s_listen_event_socket_client[clientId]; |
| 6372 | s_ril_param_socket_clients[clientId].processCommandsCallback = processCommandsCallback; |
| 6373 | s_ril_param_socket_clients[clientId].p_rs = NULL; |
| 6374 | s_ril_param_socket_clients[clientId].type = RIL_TELEPHONY_SOCKET; |
| 6375 | s_ril_param_socket_clients[clientId].clientId = clientId; |
| 6376 | return; |
| 6377 | } |
| 6378 | |
| 6379 | |
| 6380 | static int createClientSocket(char* socketName, int clientId) { |
| 6381 | struct sockaddr_un my_addr; |
| 6382 | struct sockaddr_un peer_addr; |
| 6383 | int ret; |
| 6384 | |
| 6385 | int listenFd = android_get_control_socket(socketName); |
| 6386 | |
| 6387 | //do retry if init.rc didn't define socket |
| 6388 | if (listenFd < 0) { |
| 6389 | RLOGD("init.rc didn't define, create client socket"); |
| 6390 | listenFd = socket_local_server(socketName, ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM); |
| 6391 | RLOGD("[createClientSocket]listenFd = %d", listenFd); |
| 6392 | } |
| 6393 | |
| 6394 | if (listenFd < 0) { |
| 6395 | return listenFd; |
| 6396 | } |
| 6397 | |
| 6398 | RLOGI("start listen on fd: %d, socket name: %s", listenFd, socketName); |
| 6399 | |
| 6400 | ret = listen(listenFd, 4); |
| 6401 | |
| 6402 | if (ret < 0) { |
| 6403 | RLOGE("Failed to listen on control socket '%d': %s", listenFd, strerror(errno)); |
| 6404 | close(listenFd); |
| 6405 | return -1; |
| 6406 | } |
| 6407 | |
| 6408 | RLOGI("createClientSocket start listen end"); |
| 6409 | |
| 6410 | initSocketParam(clientId, listenFd); |
| 6411 | /* note: non-persistent so we can accept only one connection at a time */ |
| 6412 | ril_event_set(&s_listen_event_socket_client[clientId], listenFd, |
| 6413 | false, listenCallback, &s_ril_param_socket_clients[clientId]); |
| 6414 | rilEventAddWakeup(&s_listen_event_socket_client[clientId]); |
| 6415 | |
| 6416 | |
| 6417 | return listenFd; |
| 6418 | } |
| 6419 | |
| 6420 | static int getClientNum() { |
| 6421 | char clientNum[PROP_VALUE_MAX] = {0}; |
| 6422 | int clientSocketNum = 0; |
| 6423 | mtk_property_get("persist.ril.client.num", clientNum, "0"); |
| 6424 | clientSocketNum = std::stoi(clientNum); |
| 6425 | |
| 6426 | if (isDsds()) { |
| 6427 | clientSocketNum = clientSocketNum * 2; |
| 6428 | } |
| 6429 | |
| 6430 | return clientSocketNum; |
| 6431 | } |
| 6432 | |
| 6433 | static void RIL_client_register() { |
| 6434 | RLOGI("RIL_client_register enter"); |
| 6435 | // start listen client socket |
| 6436 | |
| 6437 | int clientSocketNum = getClientNum(); |
| 6438 | RLOGD("RIL_client_register create socket clientNum %d", clientSocketNum); |
| 6439 | |
| 6440 | for(int i = 0; i < RIL_SLOT_MAX; i++) { |
| 6441 | if(0 != strlen(socket_status[i])){ |
| 6442 | mtk_property_set(socket_status[i], "0"); //init property |
| 6443 | } |
| 6444 | } |
| 6445 | |
| 6446 | if (clientSocketNum > 0) { |
| 6447 | RLOGD("RIL_client_register clientSocketNum >0"); |
| 6448 | s_ril_param_socket_clients = new SocketListenParam[clientSocketNum]; |
| 6449 | s_commands_event_socket_client = new ril_event[clientSocketNum]; |
| 6450 | s_listen_event_socket_client = new ril_event[clientSocketNum]; |
| 6451 | |
| 6452 | s_pendingRequestsMutex_socket_client = new pthread_mutex_t[clientSocketNum]; |
| 6453 | s_writeMutex_socket_client = new pthread_mutex_t[clientSocketNum]; |
| 6454 | s_pendingRequests_socket_client = new RequestInfo*[clientSocketNum]; |
| 6455 | |
| 6456 | s_fdCommand_client = new int[clientSocketNum]; |
| 6457 | |
| 6458 | for (int i = 0; i < clientSocketNum; i++) { |
| 6459 | RLOGD("RIL_client_register create socket"); |
| 6460 | s_writeMutex_socket_client[i] = PTHREAD_MUTEX_INITIALIZER; |
| 6461 | s_pendingRequestsMutex_socket_client[i] = PTHREAD_MUTEX_INITIALIZER; |
| 6462 | s_pendingRequests_socket_client[i] = NULL; |
| 6463 | |
| 6464 | char clientSocketName[20]; |
| 6465 | if (isDsds()) { |
| 6466 | if (i % 2 == 0) { |
| 6467 | sprintf(clientSocketName, "%s%d%s", "rild-client", i/2, "-0"); |
| 6468 | } else { |
| 6469 | sprintf(clientSocketName, "%s%d%s", "rild-client", i/2, "-1"); |
| 6470 | } |
| 6471 | } else { |
| 6472 | sprintf(clientSocketName, "%s%d", "rild-client", i); |
| 6473 | } |
| 6474 | |
| 6475 | RLOGD("RIL_client_register create socket clientSocketName %s", clientSocketName); |
| 6476 | |
| 6477 | if (createClientSocket(clientSocketName, i) < 0) { |
| 6478 | RLOGE("create client failed"); |
| 6479 | return; |
| 6480 | } |
| 6481 | |
| 6482 | s_fdCommand_client[i] = -1; |
| 6483 | } |
| 6484 | } |
| 6485 | } |
| 6486 | |
| 6487 | static void RILJ_register () { |
| 6488 | /* Initialize RILJ socket parameters */ |
| 6489 | s_ril_param_socket_rilj = { |
| 6490 | RIL_SOCKET_RILJ, /* socket_id */ |
| 6491 | -1, /* fdListen */ |
| 6492 | -1, /* fdCommand */ |
| 6493 | PHONE_PROCESS, /* processName */ |
| 6494 | &s_commands_event_socket_rilj, /* commands_event */ |
| 6495 | &s_listen_event_socket_rilj, /* listen_event */ |
| 6496 | processCommandsCallback, /* processCommandsCallback */ |
| 6497 | NULL, /* p_rs */ |
| 6498 | RIL_TELEPHONY_SOCKET, /* type */ |
| 6499 | RIL_SLOT_1, |
| 6500 | -1 /* clientId */ |
| 6501 | }; |
| 6502 | |
| 6503 | s_ril_param_socket_rilj2 = { |
| 6504 | RIL_SOCKET_RILJ2, /* socket_id */ |
| 6505 | -1, /* fdListen */ |
| 6506 | -1, /* fdCommand */ |
| 6507 | PHONE_PROCESS, /* processName */ |
| 6508 | &s_commands_event_socket_rilj2, /* commands_event */ |
| 6509 | &s_listen_event_socket_rilj2, /* listen_event */ |
| 6510 | processCommandsCallback, /* processCommandsCallback */ |
| 6511 | NULL, /* p_rs */ |
| 6512 | RIL_TELEPHONY_SOCKET, /* type */ |
| 6513 | RIL_SLOT_2, |
| 6514 | -1 /* clientId */ |
| 6515 | }; |
| 6516 | |
| 6517 | if(!isRiljEnable()) { |
| 6518 | RLOGD("Not Support RILJ CLient"); |
| 6519 | return; |
| 6520 | } |
| 6521 | // start listen socket1 |
| 6522 | startListen(RIL_SOCKET_RILJ, &s_ril_param_socket_rilj); |
| 6523 | |
| 6524 | if (SIM_COUNT >= 2) { |
| 6525 | // start listen socket2 |
| 6526 | startListen(RIL_SOCKET_RILJ2, &s_ril_param_socket_rilj2); |
| 6527 | } |
| 6528 | |
| 6529 | } |
| 6530 | |
| 6531 | |
| 6532 | extern "C" void |
| 6533 | RIL_register (const RIL_RadioFunctions *callbacks) { |
| 6534 | int ret; |
| 6535 | int flags; |
| 6536 | |
| 6537 | RLOGI("SIM_COUNT: %d", SIM_COUNT); |
| 6538 | |
| 6539 | if (callbacks == NULL) { |
| 6540 | RLOGE("RIL_register: RIL_RadioFunctions * null"); |
| 6541 | return; |
| 6542 | } |
| 6543 | if (callbacks->version < RIL_VERSION_MIN) { |
| 6544 | RLOGE("RIL_register: version %d is to old, min version is %d", |
| 6545 | callbacks->version, RIL_VERSION_MIN); |
| 6546 | return; |
| 6547 | } |
| 6548 | |
| 6549 | RLOGE("RIL_register: RIL version %d", callbacks->version); |
| 6550 | |
| 6551 | if (s_registerCalled > 0) { |
| 6552 | RLOGE("RIL_register has been called more than once. " |
| 6553 | "Subsequent call ignored"); |
| 6554 | return; |
| 6555 | } |
| 6556 | |
| 6557 | memcpy(&s_callbacks, callbacks, sizeof (RIL_RadioFunctions)); |
| 6558 | |
| 6559 | /* Initialize socket1 parameters */ |
| 6560 | s_ril_param_socket = { |
| 6561 | RIL_SOCKET_1, /* socket_id */ |
| 6562 | -1, /* fdListen */ |
| 6563 | -1, /* fdCommand */ |
| 6564 | PHONE_PROCESS, /* processName */ |
| 6565 | &s_commands_event, /* commands_event */ |
| 6566 | &s_listen_event, /* listen_event */ |
| 6567 | processCommandsCallback, /* processCommandsCallback */ |
| 6568 | NULL, /* p_rs */ |
| 6569 | RIL_TELEPHONY_SOCKET, /* type */ |
| 6570 | RIL_SLOT_1, |
| 6571 | -1 /* clientId */ |
| 6572 | }; |
| 6573 | |
| 6574 | s_ril_param_socket2 = { |
| 6575 | RIL_SOCKET_2, /* socket_id */ |
| 6576 | -1, /* fdListen */ |
| 6577 | -1, /* fdCommand */ |
| 6578 | PHONE_PROCESS, /* processName */ |
| 6579 | &s_commands_event_socket2, /* commands_event */ |
| 6580 | &s_listen_event_socket2, /* listen_event */ |
| 6581 | processCommandsCallback, /* processCommandsCallback */ |
| 6582 | NULL, /* p_rs */ |
| 6583 | RIL_TELEPHONY_SOCKET, /* type */ |
| 6584 | RIL_SLOT_2, |
| 6585 | -1 /* clientId */ |
| 6586 | }; |
| 6587 | |
| 6588 | /// support RILJ client @{ |
| 6589 | s_ril_param_socket3 = { |
| 6590 | RIL_SOCKET_3, /* socket_id */ |
| 6591 | -1, /* fdListen */ |
| 6592 | -1, /* fdCommand */ |
| 6593 | PHONE_PROCESS, /* processName */ |
| 6594 | &s_commands_event_socket3, /* commands_event */ |
| 6595 | &s_listen_event_socket3, /* listen_event */ |
| 6596 | processCommandsCallback, /* processCommandsCallback */ |
| 6597 | NULL, /* p_rs */ |
| 6598 | RIL_TELEPHONY_SOCKET, /* type */ |
| 6599 | RIL_SLOT_3, |
| 6600 | -1 /* clientId */ |
| 6601 | }; |
| 6602 | |
| 6603 | s_ril_param_socket4 = { |
| 6604 | RIL_SOCKET_4, /* socket_id */ |
| 6605 | -1, /* fdListen */ |
| 6606 | -1, /* fdCommand */ |
| 6607 | PHONE_PROCESS, /* processName */ |
| 6608 | &s_commands_event_socket4, /* commands_event */ |
| 6609 | &s_listen_event_socket4, /* listen_event */ |
| 6610 | processCommandsCallback, /* processCommandsCallback */ |
| 6611 | NULL, /* p_rs */ |
| 6612 | RIL_TELEPHONY_SOCKET, /* type */ |
| 6613 | RIL_SLOT_4, |
| 6614 | -1 /* clientId */ |
| 6615 | }; |
| 6616 | /// @} |
| 6617 | |
| 6618 | s_registerCalled = 1; |
| 6619 | |
| 6620 | RLOGI("s_registerCalled flag set, %d", s_started); |
| 6621 | // Little self-check |
| 6622 | |
| 6623 | // for (int i = 0; i < (int)NUM_ELEMS(s_commands); i++) { |
| 6624 | // assert(i == s_commands[i].requestNumber); |
| 6625 | // } |
| 6626 | // |
| 6627 | // for (int i = 0; i < (int)NUM_ELEMS(s_unsolResponses); i++) { |
| 6628 | // assert(i + RIL_UNSOL_RESPONSE_BASE |
| 6629 | // == s_unsolResponses[i].requestNumber); |
| 6630 | // } |
| 6631 | |
| 6632 | // for (int i = 0; i < (int)NUM_ELEMS(s_mtk_commands); i++) { |
| 6633 | // if (i + RIL_REQUEST_VENDOR_BASE != s_mtk_commands[i].requestNumber) { |
| 6634 | // RLOGE("mtk_ril_commands table error. index : %d, requestNumber = %d", |
| 6635 | // i, s_mtk_commands[i].requestNumber); |
| 6636 | // #ifdef HAVE_AEE_FEATURE |
| 6637 | // char *msg = NULL; |
| 6638 | // asprintf(&msg, "mtk_ril_commands table error. index : %d, requestNumber = %d", |
| 6639 | // i, s_mtk_commands[i].requestNumber); |
| 6640 | // triggerWarning(msg); |
| 6641 | // free(msg); |
| 6642 | // #else |
| 6643 | // assert(0); |
| 6644 | // #endif |
| 6645 | // } |
| 6646 | // } |
| 6647 | // |
| 6648 | // for (int i = 0; i < (int)NUM_ELEMS(s_mtk_unsolResponses); i++) { |
| 6649 | // if (i + RIL_UNSOL_VENDOR_BASE != s_mtk_unsolResponses[i].requestNumber) { |
| 6650 | // RLOGE("mtk_ril_unsol_commands table error. index : %d, requestNumber = %d", |
| 6651 | // i, s_mtk_unsolResponses[i].requestNumber); |
| 6652 | // #ifdef HAVE_AEE_FEATURE |
| 6653 | // char *msg = NULL; |
| 6654 | // asprintf(&msg, "mtk_ril_unsol_commands table error. index : %d, requestNumber = %d", |
| 6655 | // i, s_mtk_unsolResponses[i].requestNumber); |
| 6656 | // triggerWarning(msg); |
| 6657 | // free(msg); |
| 6658 | // #else |
| 6659 | // assert(0); |
| 6660 | // #endif |
| 6661 | // } |
| 6662 | // } |
| 6663 | |
| 6664 | for (int i = 0; i < RIL_SOCKET_NUM; i++) { |
| 6665 | pthread_mutex_init(&s_state_mutex[i], NULL); |
| 6666 | } |
| 6667 | |
| 6668 | // New rild impl calls RIL_startEventLoop() first |
| 6669 | // old standalone impl wants it here. |
| 6670 | |
| 6671 | if (s_started == 0) { |
| 6672 | RIL_startEventLoop(); |
| 6673 | } |
| 6674 | |
| 6675 | // start listen socket1 |
| 6676 | startListen(RIL_SOCKET_1, &s_ril_param_socket); |
| 6677 | |
| 6678 | if (SIM_COUNT >= 2) { |
| 6679 | // start listen socket2 |
| 6680 | startListen(RIL_SOCKET_2, &s_ril_param_socket2); |
| 6681 | } |
| 6682 | |
| 6683 | if (SIM_COUNT >= 3) { |
| 6684 | // start listen socket3 |
| 6685 | startListen(RIL_SOCKET_3, &s_ril_param_socket3); |
| 6686 | } |
| 6687 | |
| 6688 | if (SIM_COUNT >= 4) { |
| 6689 | // start listen socket4 |
| 6690 | startListen(RIL_SOCKET_4, &s_ril_param_socket4); |
| 6691 | } |
| 6692 | |
| 6693 | // initialize mutex |
| 6694 | for (int i = 0; i < RIL_SOCKET_NUM; i++) { |
| 6695 | pthread_mutex_init(&s_pendingUrcMutex[i], NULL); |
| 6696 | s_fdCommand[i] = -1; |
| 6697 | } |
| 6698 | /// @} |
| 6699 | RILJ_register(); |
| 6700 | |
| 6701 | RIL_client_register(); |
| 6702 | #if 1 |
| 6703 | // start debug interface socket |
| 6704 | |
| 6705 | char *inst = NULL; |
| 6706 | if (strlen(RIL_getRilSocketName()) >= strlen(SOCKET_NAME_RIL)) { |
| 6707 | inst = RIL_getRilSocketName() + strlen(SOCKET_NAME_RIL); |
| 6708 | } |
| 6709 | |
| 6710 | char rildebug[MAX_DEBUG_SOCKET_NAME_LENGTH] = SOCKET_NAME_RIL_DEBUG; |
| 6711 | if (inst != NULL) { |
| 6712 | strncat(rildebug, inst, MAX_DEBUG_SOCKET_NAME_LENGTH); |
| 6713 | } |
| 6714 | |
| 6715 | s_fdDebug = android_get_control_socket(rildebug); |
| 6716 | if (s_fdDebug < 0) { |
| 6717 | RLOGE("Failed to get socket : %s errno:%d", rildebug, errno); |
| 6718 | exit(-1); |
| 6719 | } |
| 6720 | |
| 6721 | ret = listen(s_fdDebug, 4); |
| 6722 | |
| 6723 | if (ret < 0) { |
| 6724 | RLOGE("Failed to listen on ril debug socket '%d': %s", |
| 6725 | s_fdDebug, strerror(errno)); |
| 6726 | exit(-1); |
| 6727 | } |
| 6728 | |
| 6729 | ril_event_set (&s_debug_event, s_fdDebug, true, |
| 6730 | debugCallback, NULL); |
| 6731 | |
| 6732 | rilEventAddWakeup (&s_debug_event); |
| 6733 | #endif |
| 6734 | |
| 6735 | } |
| 6736 | |
| 6737 | extern "C" void |
| 6738 | RIL_register_socket (const RIL_RadioFunctions *(*Init)(const struct RIL_Env *, int, char **),RIL_SOCKET_TYPE socketType, int argc, char **argv) { |
| 6739 | |
| 6740 | const RIL_RadioFunctions* UimFuncs = NULL; |
| 6741 | |
| 6742 | if(Init) { |
| 6743 | UimFuncs = Init(&RilSapSocket::uimRilEnv, argc, argv); |
| 6744 | |
| 6745 | switch(socketType) { |
| 6746 | case RIL_SAP_SOCKET: |
| 6747 | RilSapSocket::initSapSocket("sap_uim_socket1", UimFuncs); |
| 6748 | if (SIM_COUNT >= 2) { |
| 6749 | RilSapSocket::initSapSocket("sap_uim_socket2", UimFuncs); |
| 6750 | } |
| 6751 | if (SIM_COUNT >= 3) { |
| 6752 | RilSapSocket::initSapSocket("sap_uim_socket3", UimFuncs); |
| 6753 | } |
| 6754 | if (SIM_COUNT >= 4) { |
| 6755 | RilSapSocket::initSapSocket("sap_uim_socket4", UimFuncs); |
| 6756 | } |
| 6757 | break; |
| 6758 | default:; |
| 6759 | } |
| 6760 | } |
| 6761 | } |
| 6762 | |
| 6763 | // Check and remove RequestInfo if its a response and not just ack sent back |
| 6764 | static int |
| 6765 | checkAndDequeueRequestInfoIfAck(struct RequestInfo *pRI, bool isAck) { |
| 6766 | int ret = 0; |
| 6767 | /* Hook for current context |
| 6768 | pendingRequestsMutextHook refer to &s_pendingRequestsMutex */ |
| 6769 | pthread_mutex_t* pendingRequestsMutexHook = &s_pendingRequestsMutex; |
| 6770 | /* pendingRequestsHook refer to &s_pendingRequests */ |
| 6771 | RequestInfo ** pendingRequestsHook = &s_pendingRequests; |
| 6772 | |
| 6773 | if (pRI == NULL) { |
| 6774 | return 0; |
| 6775 | } |
| 6776 | |
| 6777 | if (pRI->socket_id == RIL_SOCKET_2) { |
| 6778 | pendingRequestsMutexHook = &s_pendingRequestsMutex_socket2; |
| 6779 | pendingRequestsHook = &s_pendingRequests_socket2; |
| 6780 | } |
| 6781 | if (pRI->socket_id == RIL_SOCKET_3) { |
| 6782 | pendingRequestsMutexHook = &s_pendingRequestsMutex_socket3; |
| 6783 | pendingRequestsHook = &s_pendingRequests_socket3; |
| 6784 | } |
| 6785 | if (pRI->socket_id == RIL_SOCKET_4) { |
| 6786 | pendingRequestsMutexHook = &s_pendingRequestsMutex_socket4; |
| 6787 | pendingRequestsHook = &s_pendingRequests_socket4; |
| 6788 | } |
| 6789 | if (pRI->socket_id == RIL_SOCKET_RILJ) { |
| 6790 | pendingRequestsMutexHook = &s_pendingRequestsMutex_socket_rilj; |
| 6791 | pendingRequestsHook = &s_pendingRequests_socket_rilj; |
| 6792 | } |
| 6793 | if (pRI->socket_id == RIL_SOCKET_RILJ2) { |
| 6794 | pendingRequestsMutexHook = &s_pendingRequestsMutex_socket_rilj2; |
| 6795 | pendingRequestsHook = &s_pendingRequests_socket_rilj2; |
| 6796 | } |
| 6797 | |
| 6798 | if (pRI->clientId >= 0) { |
| 6799 | pendingRequestsMutexHook = &s_pendingRequestsMutex_socket_client[pRI->clientId]; |
| 6800 | pendingRequestsHook = &s_pendingRequests_socket_client[pRI->clientId]; |
| 6801 | } |
| 6802 | |
| 6803 | pthread_mutex_lock(pendingRequestsMutexHook); |
| 6804 | |
| 6805 | for(RequestInfo **ppCur = pendingRequestsHook |
| 6806 | ; *ppCur != NULL |
| 6807 | ; ppCur = &((*ppCur)->p_next) |
| 6808 | ) { |
| 6809 | if (pRI == *ppCur) { |
| 6810 | ret = 1; |
| 6811 | if (isAck) { // Async ack |
| 6812 | if (pRI->wasAckSent == 1) { |
| 6813 | RLOGD("Ack was already sent for %s", requestToString(pRI->pCI->requestNumber)); |
| 6814 | } else { |
| 6815 | pRI->wasAckSent = 1; |
| 6816 | } |
| 6817 | } else { |
| 6818 | *ppCur = (*ppCur)->p_next; |
| 6819 | } |
| 6820 | break; |
| 6821 | } |
| 6822 | } |
| 6823 | |
| 6824 | pthread_mutex_unlock(pendingRequestsMutexHook); |
| 6825 | |
| 6826 | return ret; |
| 6827 | } |
| 6828 | |
| 6829 | static int findFd(int socket_id, int clientId) { |
| 6830 | int fd = -1; |
| 6831 | if (clientId >= 0) { |
| 6832 | fd = s_ril_param_socket_clients[clientId].fdCommand; |
| 6833 | } else { |
| 6834 | fd = s_ril_param_socket.fdCommand; |
| 6835 | if (socket_id == RIL_SOCKET_2) { |
| 6836 | fd = s_ril_param_socket2.fdCommand; |
| 6837 | } |
| 6838 | if (socket_id == RIL_SOCKET_3) { |
| 6839 | fd = s_ril_param_socket3.fdCommand; |
| 6840 | } |
| 6841 | if (socket_id == RIL_SOCKET_4) { |
| 6842 | fd = s_ril_param_socket4.fdCommand; |
| 6843 | } |
| 6844 | if (socket_id == RIL_SOCKET_RILJ) { |
| 6845 | fd = s_ril_param_socket_rilj.fdCommand; |
| 6846 | } |
| 6847 | if (socket_id == RIL_SOCKET_RILJ2) { |
| 6848 | fd = s_ril_param_socket_rilj2.fdCommand; |
| 6849 | } |
| 6850 | } |
| 6851 | RLOGD("findFd end socket_id=%d, clientId =%d, fd=%d", socket_id, clientId, fd); |
| 6852 | return fd; |
| 6853 | } |
| 6854 | |
| 6855 | /// since vendor ril uses socket id, so change slot id to socket id again |
| 6856 | static RIL_SOCKET_ID mapingSlotIdToRilSocketId(RIL_SLOT_ID slot_id) { |
| 6857 | RIL_SOCKET_ID soc_id = RIL_SOCKET_1; |
| 6858 | switch(slot_id) { |
| 6859 | case RIL_SLOT_2: |
| 6860 | soc_id = RIL_SOCKET_2; |
| 6861 | break; |
| 6862 | case RIL_SLOT_3: |
| 6863 | soc_id = RIL_SOCKET_3; |
| 6864 | break; |
| 6865 | case RIL_SLOT_4: |
| 6866 | soc_id = RIL_SOCKET_4; |
| 6867 | break; |
| 6868 | } |
| 6869 | return soc_id; |
| 6870 | } |
| 6871 | |
| 6872 | /// change libril's socket id to slot id to initialize slot id |
| 6873 | extern "C" |
| 6874 | RIL_SLOT_ID mappingSocketIdToSlotId(RIL_SOCKET_ID socket_id) { |
| 6875 | RIL_SLOT_ID slot_id = RIL_SLOT_1; |
| 6876 | for (int i = 0; i < NUM_ELEMS(s_ril_socket_params); i++) { |
| 6877 | if (socket_id == s_ril_socket_params[i]->socket_id) { |
| 6878 | slot_id = s_ril_socket_params[i]->slot_id; |
| 6879 | break; |
| 6880 | } |
| 6881 | } |
| 6882 | return slot_id; |
| 6883 | } |
| 6884 | |
| 6885 | extern "C" void |
| 6886 | RIL_onRequestAck(RIL_Token t) { |
| 6887 | RequestInfo *pRI; |
| 6888 | int ret, fd; |
| 6889 | |
| 6890 | size_t errorOffset; |
| 6891 | RIL_SOCKET_ID socket_id = RIL_SOCKET_1; |
| 6892 | int clientId = -1; |
| 6893 | |
| 6894 | pRI = (RequestInfo *)t; |
| 6895 | |
| 6896 | if (!checkAndDequeueRequestInfoIfAck(pRI, true)) { |
| 6897 | RLOGE ("RIL_onRequestAck: invalid RIL_Token"); |
| 6898 | return; |
| 6899 | } |
| 6900 | /// support client socket |
| 6901 | socket_id = pRI->socket_id; |
| 6902 | clientId = pRI->clientId; |
| 6903 | fd = findFd(socket_id, clientId); |
| 6904 | |
| 6905 | #if VDBG |
| 6906 | RLOGD("Request Ack, %s", rilSocketIdToString(socket_id)); |
| 6907 | #endif |
| 6908 | |
| 6909 | appendPrintBuf("Ack [%04d]< %s", pRI->token, requestToString(pRI->pCI->requestNumber)); |
| 6910 | |
| 6911 | if (pRI->cancelled == 0) { |
| 6912 | Parcel p; |
| 6913 | |
| 6914 | p.writeInt32 (RESPONSE_SOLICITED_ACK); |
| 6915 | p.writeInt32 (pRI->token); |
| 6916 | |
| 6917 | if (fd < 0) { |
| 6918 | RLOGD ("RIL onRequestComplete: Command channel closed"); |
| 6919 | } |
| 6920 | |
| 6921 | sendResponse(p, socket_id, clientId); |
| 6922 | } |
| 6923 | } |
| 6924 | |
| 6925 | extern "C" void |
| 6926 | RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responselen) { |
| 6927 | RequestInfo *pRI; |
| 6928 | int ret; |
| 6929 | int fd; |
| 6930 | size_t errorOffset; |
| 6931 | RIL_SOCKET_ID socket_id = RIL_SOCKET_1; |
| 6932 | |
| 6933 | pRI = (RequestInfo *)t; |
| 6934 | |
| 6935 | if (!checkAndDequeueRequestInfoIfAck(pRI, false)) { |
| 6936 | RLOGE ("RIL_onRequestComplete: invalid RIL_Token"); |
| 6937 | return; |
| 6938 | } |
| 6939 | |
| 6940 | socket_id = pRI->socket_id; |
| 6941 | fd = findFd(socket_id, pRI->clientId); |
| 6942 | if (fd < 0) { |
| 6943 | RLOGD ("RIL onRequestComplete: Command channel closed"); |
| 6944 | } |
| 6945 | |
| 6946 | #if RILJDBG |
| 6947 | RLOGD("RequestComplete, %s, type %d", rilSocketIdToString(socket_id), pRI->type); |
| 6948 | #endif |
| 6949 | |
| 6950 | if (pRI->local > 0) { |
| 6951 | // Locally issued command...void only! |
| 6952 | // response does not go back up the command socket |
| 6953 | if (pRI->cancelled == 0) { |
| 6954 | RLOGD("C[locl]< %s", requestToString(pRI->pCI->requestNumber)); |
| 6955 | } |
| 6956 | |
| 6957 | goto done; |
| 6958 | } |
| 6959 | |
| 6960 | appendPrintBuf("[%04d]< %s", |
| 6961 | pRI->token, requestToString(pRI->pCI->requestNumber)); |
| 6962 | RLOGD("RequestComplete, sendResponse, %d",pRI->cancelled); |
| 6963 | |
| 6964 | if (pRI->cancelled == 0) { |
| 6965 | Parcel p; |
| 6966 | |
| 6967 | if (s_callbacks.version >= 13 && pRI->wasAckSent == 1) { |
| 6968 | // If ack was already sent, then this call is an asynchronous response. So we need to |
| 6969 | // send id indicating that we expect an ack from RIL.java as we acquire wakelock here. |
| 6970 | p.writeInt32 (RESPONSE_SOLICITED_ACK_EXP); |
| 6971 | grabPartialWakeLock(); |
| 6972 | } else { |
| 6973 | p.writeInt32 (RESPONSE_SOLICITED); |
| 6974 | } |
| 6975 | p.writeInt32 (pRI->token); |
| 6976 | errorOffset = p.dataPosition(); |
| 6977 | |
| 6978 | p.writeInt32 (e); |
| 6979 | |
| 6980 | if (response != NULL) { |
| 6981 | Parcel *resp = (Parcel *) response; |
| 6982 | // there is a response payload, no matter success or not. |
| 6983 | //ret = pRI->pCI->responseFunction(p, response, responselen); |
| 6984 | resp->setDataPosition(0); |
| 6985 | ret = p.appendFrom(resp,0,resp->dataSize()); |
| 6986 | /* if an error occurred, rewind and mark it */ |
| 6987 | if (ret != 0) { |
| 6988 | RLOGE ("responseFunction error, ret %d", ret); |
| 6989 | p.setDataPosition(errorOffset); |
| 6990 | p.writeInt32 (ret); |
| 6991 | } |
| 6992 | } |
| 6993 | RLOGD("RequestComplete, before sendResponse, %d",responselen); |
| 6994 | |
| 6995 | if (e != RIL_E_SUCCESS) { |
| 6996 | appendPrintBuf("%s fails by %s", printBuf, failCauseToString(e)); |
| 6997 | } |
| 6998 | |
| 6999 | sendResponse(p, socket_id, pRI->clientId); |
| 7000 | } |
| 7001 | |
| 7002 | done: |
| 7003 | free(pRI); |
| 7004 | } |
| 7005 | |
| 7006 | extern "C" |
| 7007 | void resetWakelock(void) { |
| 7008 | RLOGD("reset Wakelock %s", ANDROID_WAKE_LOCK_NAME); |
| 7009 | mtk_release_wake_lock(ANDROID_WAKE_LOCK_NAME); |
| 7010 | } |
| 7011 | |
| 7012 | /// MTK_RIL_ADAPTER @{ |
| 7013 | extern "C" void |
| 7014 | RIL_onIssueLocalRequest(int request, void *data, int len, RIL_SOCKET_ID socket_id) { |
| 7015 | RLOGD("issue local request: %s", requestToString(request)); |
| 7016 | issueLocalRequest(request, data, len, socket_id); //data changed to parcel* type |
| 7017 | } |
| 7018 | /// @} |
| 7019 | |
| 7020 | static void |
| 7021 | grabPartialWakeLock() { |
| 7022 | if (s_callbacks.version >= 13) { |
| 7023 | int ret; |
| 7024 | ret = pthread_mutex_lock(&s_wakeLockCountMutex); |
| 7025 | assert(ret == 0); |
| 7026 | mtk_acquire_wake_lock(ANDROID_WAKE_LOCK_NAME); |
| 7027 | |
| 7028 | UserCallbackInfo *p_info = |
| 7029 | internalRequestTimedCallback(wakeTimeoutCallback, NULL, &TIMEVAL_WAKE_TIMEOUT); |
| 7030 | if (p_info == NULL) { |
| 7031 | mtk_release_wake_lock(ANDROID_WAKE_LOCK_NAME); |
| 7032 | } else { |
| 7033 | s_wakelock_count++; |
| 7034 | if (s_last_wake_timeout_info != NULL) { |
| 7035 | s_last_wake_timeout_info->userParam = (void *)1; |
| 7036 | } |
| 7037 | s_last_wake_timeout_info = p_info; |
| 7038 | } |
| 7039 | ret = pthread_mutex_unlock(&s_wakeLockCountMutex); |
| 7040 | assert(ret == 0); |
| 7041 | } else { |
| 7042 | mtk_acquire_wake_lock(ANDROID_WAKE_LOCK_NAME); |
| 7043 | } |
| 7044 | } |
| 7045 | |
| 7046 | static void |
| 7047 | releaseWakeLock() { |
| 7048 | if (s_callbacks.version >= 13) { |
| 7049 | int ret; |
| 7050 | ret = pthread_mutex_lock(&s_wakeLockCountMutex); |
| 7051 | assert(ret == 0); |
| 7052 | |
| 7053 | if (s_wakelock_count > 1) { |
| 7054 | s_wakelock_count--; |
| 7055 | } else { |
| 7056 | s_wakelock_count = 0; |
| 7057 | mtk_release_wake_lock(ANDROID_WAKE_LOCK_NAME); |
| 7058 | if (s_last_wake_timeout_info != NULL) { |
| 7059 | s_last_wake_timeout_info->userParam = (void *)1; |
| 7060 | } |
| 7061 | } |
| 7062 | |
| 7063 | ret = pthread_mutex_unlock(&s_wakeLockCountMutex); |
| 7064 | assert(ret == 0); |
| 7065 | } else { |
| 7066 | mtk_release_wake_lock(ANDROID_WAKE_LOCK_NAME); |
| 7067 | } |
| 7068 | } |
| 7069 | |
| 7070 | /** |
| 7071 | * Timer callback to put us back to sleep before the default timeout |
| 7072 | */ |
| 7073 | static void |
| 7074 | wakeTimeoutCallback (void *param) { |
| 7075 | // We're using "param != NULL" as a cancellation mechanism |
| 7076 | if (s_callbacks.version >= 13) { |
| 7077 | if (param == NULL) { |
| 7078 | int ret; |
| 7079 | ret = pthread_mutex_lock(&s_wakeLockCountMutex); |
| 7080 | assert(ret == 0); |
| 7081 | s_wakelock_count = 0; |
| 7082 | mtk_release_wake_lock(ANDROID_WAKE_LOCK_NAME); |
| 7083 | ret = pthread_mutex_unlock(&s_wakeLockCountMutex); |
| 7084 | assert(ret == 0); |
| 7085 | } |
| 7086 | } else { |
| 7087 | if (param == NULL) { |
| 7088 | releaseWakeLock(); |
| 7089 | } |
| 7090 | } |
| 7091 | } |
| 7092 | |
| 7093 | static bool is3gpp2(int radioTech) { |
| 7094 | switch (radioTech) { |
| 7095 | case RADIO_TECH_IS95A: |
| 7096 | case RADIO_TECH_IS95B: |
| 7097 | case RADIO_TECH_1xRTT: |
| 7098 | case RADIO_TECH_EVDO_0: |
| 7099 | case RADIO_TECH_EVDO_A: |
| 7100 | case RADIO_TECH_EVDO_B: |
| 7101 | case RADIO_TECH_EHRPD: |
| 7102 | return true; |
| 7103 | default: |
| 7104 | return false; |
| 7105 | } |
| 7106 | } |
| 7107 | |
| 7108 | #if defined(ANDROID_MULTI_SIM) |
| 7109 | extern "C" |
| 7110 | void RIL_onUnsolicitedResponse(int unsolResponse, const void *data, |
| 7111 | size_t datalen, RIL_SOCKET_ID soc_id) |
| 7112 | #else |
| 7113 | extern "C" |
| 7114 | void RIL_onUnsolicitedResponse(int unsolResponse, const void *data, |
| 7115 | size_t datalen) |
| 7116 | #endif |
| 7117 | { |
| 7118 | #if defined(ANDROID_MULTI_SIM) |
| 7119 | RIL_SOCKET_ID socId = soc_id; |
| 7120 | #else |
| 7121 | RIL_SOCKET_ID socId = RIL_SOCKET_1; |
| 7122 | #endif |
| 7123 | RLOGD("RIL_onUnsolicitedResponse %d\n",unsolResponse); |
| 7124 | // alway keeps a copy of NITZ URC so we can use it later. |
| 7125 | if (unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) { |
| 7126 | RLOGD("alway keeps a copy of NITZ URC so we can use it later"); |
| 7127 | Parcel p; |
| 7128 | int64_t timeReceived = elapsedRealtime(); |
| 7129 | int unsolResponseIndex = unsolResponse - RIL_UNSOL_RESPONSE_BASE; |
| 7130 | p.writeInt32 (RESPONSE_UNSOLICITED); |
| 7131 | p.writeInt32 (unsolResponse); |
| 7132 | int ret = -1; |
| 7133 | if (data != NULL) { |
| 7134 | Parcel *parcelUrc = (Parcel *) data; |
| 7135 | ret = p.appendFrom(parcelUrc,0,parcelUrc->dataSize()); |
| 7136 | } |
| 7137 | if (ret == 0) { |
| 7138 | p.writeInt64(timeReceived); |
| 7139 | if (s_lastNITZTimeData != NULL) { |
| 7140 | free (s_lastNITZTimeData); |
| 7141 | s_lastNITZTimeData = NULL; |
| 7142 | } |
| 7143 | |
| 7144 | s_lastNITZTimeData = calloc(p.dataSize(), 1); |
| 7145 | if (s_lastNITZTimeData != NULL) { |
| 7146 | s_lastNITZTimeDataSize = p.dataSize(); |
| 7147 | memcpy(s_lastNITZTimeData, p.data(), p.dataSize()); |
| 7148 | } else { |
| 7149 | RLOGE("Memory allocation failed when keep nitz urc"); |
| 7150 | } |
| 7151 | } else { |
| 7152 | RLOGE("responseFunction failed when keep nitz urc"); |
| 7153 | } |
| 7154 | } |
| 7155 | /// support RILJ Client, and send URC to all the slot client @{ |
| 7156 | for (int i = 0; i < NUM_ELEMS(s_ril_socket_params); i++) { |
| 7157 | /// since vendor ril using socket id, mapping to libril's slot id |
| 7158 | if (s_ril_socket_params[i]->socket_id == socId && s_fdCommand[socId] != -1) { |
| 7159 | RIL_onUnsolicitedResponseInternal(unsolResponse, data, datalen, |
| 7160 | s_ril_socket_params[i]); |
| 7161 | } |
| 7162 | } |
| 7163 | /// @} |
| 7164 | int clientNum = getClientNum(); |
| 7165 | for (int j = 0; j < clientNum; j++) { |
| 7166 | if (s_fdCommand_client[j] != -1 && s_ril_param_socket_clients[j].socket_id == socId) { |
| 7167 | RIL_onUnsolicitedResponseInternal(unsolResponse, data, datalen, |
| 7168 | &s_ril_param_socket_clients[j]); |
| 7169 | } |
| 7170 | } |
| 7171 | } |
| 7172 | |
| 7173 | static void RIL_onUnsolicitedResponseInternal(int unsolResponse, const void *data, |
| 7174 | size_t datalen, SocketListenParam* socket_param) { |
| 7175 | int unsolResponseIndex; |
| 7176 | int ret = 0; |
| 7177 | int64_t timeReceived = 0; |
| 7178 | bool shouldScheduleTimeout = false; |
| 7179 | RIL_RadioState newState; |
| 7180 | RIL_SOCKET_ID soc_id = socket_param->socket_id; |
| 7181 | RIL_SLOT_ID slot_id = socket_param->slot_id; |
| 7182 | int clientId = socket_param->clientId; |
| 7183 | int fdCommand; |
| 7184 | |
| 7185 | if (s_registerCalled == 0) { |
| 7186 | // Ignore RIL_onUnsolicitedResponse before RIL_register |
| 7187 | RLOGW("RIL_onUnsolicitedResponse called before RIL_register"); |
| 7188 | return; |
| 7189 | } |
| 7190 | |
| 7191 | if ((soc_id == RIL_SOCKET_RILJ || soc_id == RIL_SOCKET_RILJ2) |
| 7192 | && !isRiljEnable()) { |
| 7193 | /// ignore urc since rilj is not enable |
| 7194 | return; |
| 7195 | } |
| 7196 | |
| 7197 | unsolResponseIndex = unsolResponse - RIL_UNSOL_RESPONSE_BASE; |
| 7198 | |
| 7199 | if ((unsolResponseIndex < 0) |
| 7200 | || (unsolResponseIndex >= (int32_t)NUM_ELEMS(s_unsolResponses))) { |
| 7201 | //M: ril proxy |
| 7202 | if ((unsolResponse < RIL_UNSOL_VENDOR_BASE) || |
| 7203 | ((unsolResponse >= RIL_UNSOL_VENDOR_BASE + (int32_t)NUM_ELEMS(s_mtk_unsolResponses)) && |
| 7204 | unsolResponse < RIL_UNSOL_VENDOR_IVT_BASE) || |
| 7205 | (unsolResponse >= RIL_UNSOL_VENDOR_IVT_BASE + (int32_t)NUM_ELEMS(s_mtk_ivt_unsolResponses))) { |
| 7206 | RLOGE("unsupported unsolicited response code %d", unsolResponse); |
| 7207 | return; |
| 7208 | } |
| 7209 | // |
| 7210 | } |
| 7211 | |
| 7212 | // M: ril proxy |
| 7213 | fdCommand = findFd(soc_id, clientId); |
| 7214 | /// @} |
| 7215 | |
| 7216 | if (fdCommand == -1) { |
| 7217 | if (unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) { |
| 7218 | RLOGD("Use default cache to handle RIL_UNSOL_NITZ_TIME_RECEIVED"); |
| 7219 | } else { |
| 7220 | RLOGD("Can't send URC because there is no connection yet."\ |
| 7221 | "Try to cache request:%s in RIL%s", |
| 7222 | requestToString(unsolResponse), rilSocketIdToString(soc_id)); |
| 7223 | pthread_mutex_lock(&s_pendingUrcMutex[soc_id]); |
| 7224 | cacheUrc(unsolResponse, data, datalen , soc_id); |
| 7225 | pthread_mutex_unlock(&s_pendingUrcMutex[soc_id]); |
| 7226 | return; //cahche then return |
| 7227 | } |
| 7228 | } |
| 7229 | // |
| 7230 | // Grab a wake lock if needed for this reponse, |
| 7231 | // as we exit we'll either release it immediately |
| 7232 | // or set a timer to release it later. |
| 7233 | // M: ril proxy |
| 7234 | WakeType wakeType; |
| 7235 | if (unsolResponse >= RIL_UNSOL_VENDOR_IVT_BASE) { |
| 7236 | RLOGD("RIL_onUnsolicitedResponse: ivt"); |
| 7237 | unsolResponseIndex = unsolResponse - RIL_UNSOL_VENDOR_IVT_BASE; |
| 7238 | if (s_mtk_ivt_unsolResponses[unsolResponseIndex].responseFunction == NULL) { |
| 7239 | RLOGE("Need add response function to command table"); |
| 7240 | return; |
| 7241 | } |
| 7242 | wakeType = s_mtk_ivt_unsolResponses[unsolResponseIndex].wakeType; |
| 7243 | } else if (unsolResponse >= RIL_UNSOL_VENDOR_BASE) { |
| 7244 | RLOGD("RIL_onUnsolicitedResponse: GSM/C2K"); |
| 7245 | unsolResponseIndex = unsolResponse - RIL_UNSOL_VENDOR_BASE; |
| 7246 | if (s_mtk_unsolResponses[unsolResponseIndex].responseFunction == NULL) { |
| 7247 | RLOGE("Need add response function to command table"); |
| 7248 | return; |
| 7249 | } |
| 7250 | wakeType = s_mtk_unsolResponses[unsolResponseIndex].wakeType; |
| 7251 | } else { |
| 7252 | RLOGD("RIL_onUnsolicitedResponse: default"); |
| 7253 | if (s_unsolResponses[unsolResponseIndex].responseFunction == NULL) { |
| 7254 | RLOGE("Need add response function to command table"); |
| 7255 | return; |
| 7256 | } |
| 7257 | wakeType = s_unsolResponses[unsolResponseIndex].wakeType; |
| 7258 | } |
| 7259 | // |
| 7260 | |
| 7261 | switch (wakeType) { |
| 7262 | case WAKE_PARTIAL: |
| 7263 | grabPartialWakeLock(); |
| 7264 | shouldScheduleTimeout = true; |
| 7265 | break; |
| 7266 | |
| 7267 | case DONT_WAKE: |
| 7268 | default: |
| 7269 | // No wake lock is grabed so don't set timeout |
| 7270 | shouldScheduleTimeout = false; |
| 7271 | break; |
| 7272 | } |
| 7273 | |
| 7274 | // Mark the time this was received, doing this |
| 7275 | // after grabing the wakelock incase getting |
| 7276 | // the elapsedRealTime might cause us to goto |
| 7277 | // sleep. |
| 7278 | if (unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) { |
| 7279 | timeReceived = elapsedRealtime(); |
| 7280 | } |
| 7281 | |
| 7282 | appendPrintBuf("[UNSL]< %s", requestToString(unsolResponse)); |
| 7283 | |
| 7284 | Parcel p; |
| 7285 | //if (s_callbacks.version >= 13 |
| 7286 | // && s_unsolResponses[unsolResponseIndex].wakeType == WAKE_PARTIAL) { |
| 7287 | // p.writeInt32 (RESPONSE_UNSOLICITED_ACK_EXP); |
| 7288 | //} else { |
| 7289 | p.writeInt32 (RESPONSE_UNSOLICITED); |
| 7290 | //} |
| 7291 | p.writeInt32 (unsolResponse); |
| 7292 | |
| 7293 | #if 0 |
| 7294 | /// M: ril proxy |
| 7295 | if (unsolResponse >= RIL_UNSOL_VENDOR_IVT_BASE) { |
| 7296 | ret = s_mtk_ivt_unsolResponses[unsolResponseIndex] |
| 7297 | .responseFunction(p, const_cast<void*>(data), datalen); |
| 7298 | } |
| 7299 | else if (unsolResponse >= RIL_UNSOL_VENDOR_BASE) { |
| 7300 | ret = s_mtk_unsolResponses[unsolResponseIndex] |
| 7301 | .responseFunction(p, const_cast<void*>(data), datalen); |
| 7302 | } else { |
| 7303 | ret = s_unsolResponses[unsolResponseIndex] |
| 7304 | .responseFunction(p, const_cast<void*>(data), datalen); |
| 7305 | } |
| 7306 | #else |
| 7307 | if (data != NULL) { |
| 7308 | Parcel *parcelUrc = (Parcel *) data; |
| 7309 | ret = p.appendFrom(parcelUrc,0,parcelUrc->dataSize()); |
| 7310 | } |
| 7311 | #endif |
| 7312 | if (ret != 0) { |
| 7313 | RLOGI("RIL_onUnsolicitedResponse ret %d", ret); |
| 7314 | // Problem with the response. Don't continue; |
| 7315 | goto error_exit; |
| 7316 | } |
| 7317 | |
| 7318 | // some things get more payload |
| 7319 | switch(unsolResponse) { |
| 7320 | case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: |
| 7321 | /// Add mutex to avoid async error when handle this unsolResponse.@{ |
| 7322 | /// Such as radio state off send before unavailable. |
| 7323 | pthread_mutex_lock(&s_state_mutex[soc_id]); |
| 7324 | /// @} |
| 7325 | |
| 7326 | newState = CALL_ONSTATEREQUEST(soc_id); |
| 7327 | p.writeInt32(newState); |
| 7328 | appendPrintBuf("%s {%s}", printBuf, radioStateToString(CALL_ONSTATEREQUEST(soc_id))); |
| 7329 | break; |
| 7330 | |
| 7331 | |
| 7332 | case RIL_UNSOL_NITZ_TIME_RECEIVED: |
| 7333 | // Store the time that this was received so the |
| 7334 | // handler of this message can account for |
| 7335 | // the time it takes to arrive and process. In |
| 7336 | // particular the system has been known to sleep |
| 7337 | // before this message can be processed. |
| 7338 | p.writeInt64(timeReceived); |
| 7339 | break; |
| 7340 | } |
| 7341 | |
| 7342 | if (s_callbacks.version < 13) { |
| 7343 | if (shouldScheduleTimeout) { |
| 7344 | UserCallbackInfo *p_info = internalRequestTimedCallback(wakeTimeoutCallback, NULL, |
| 7345 | &TIMEVAL_WAKE_TIMEOUT); |
| 7346 | |
| 7347 | if (p_info == NULL) { |
| 7348 | /// relase state lock @{ |
| 7349 | if (unsolResponse == RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED) { |
| 7350 | pthread_mutex_unlock(&s_state_mutex[soc_id]); |
| 7351 | } |
| 7352 | /// @} |
| 7353 | goto error_exit; |
| 7354 | } else { |
| 7355 | // Cancel the previous request |
| 7356 | if (s_last_wake_timeout_info != NULL) { |
| 7357 | s_last_wake_timeout_info->userParam = (void *)1; |
| 7358 | } |
| 7359 | s_last_wake_timeout_info = p_info; |
| 7360 | } |
| 7361 | } |
| 7362 | } |
| 7363 | |
| 7364 | #if VDBG |
| 7365 | RLOGI("%s UNSOLICITED: %s length:%d", rilSocketIdToString(soc_id), requestToString(unsolResponse), p.dataSize()); |
| 7366 | #endif |
| 7367 | ret = sendResponse(p, soc_id, socket_param->clientId); |
| 7368 | |
| 7369 | /// release state lock @{ |
| 7370 | if (unsolResponse == RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED) { |
| 7371 | pthread_mutex_unlock(&s_state_mutex[soc_id]); |
| 7372 | } |
| 7373 | /// @} |
| 7374 | |
| 7375 | if (ret != 0 && unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) { |
| 7376 | |
| 7377 | // Unfortunately, NITZ time is not poll/update like everything |
| 7378 | // else in the system. So, if the upstream client isn't connected, |
| 7379 | // keep a copy of the last NITZ response (with receive time noted |
| 7380 | // above) around so we can deliver it when it is connected |
| 7381 | |
| 7382 | if (s_lastNITZTimeData != NULL) { |
| 7383 | free (s_lastNITZTimeData); |
| 7384 | s_lastNITZTimeData = NULL; |
| 7385 | } |
| 7386 | |
| 7387 | s_lastNITZTimeData = calloc(p.dataSize(), 1); |
| 7388 | if (s_lastNITZTimeData == NULL) { |
| 7389 | RLOGE("Memory allocation failed in RIL_onUnsolicitedResponse"); |
| 7390 | goto error_exit; |
| 7391 | } |
| 7392 | s_lastNITZTimeDataSize = p.dataSize(); |
| 7393 | memcpy(s_lastNITZTimeData, p.data(), p.dataSize()); |
| 7394 | } |
| 7395 | |
| 7396 | // Normal exit |
| 7397 | return; |
| 7398 | |
| 7399 | error_exit: |
| 7400 | |
| 7401 | if (shouldScheduleTimeout) { |
| 7402 | releaseWakeLock(); |
| 7403 | } |
| 7404 | } |
| 7405 | |
| 7406 | /** FIXME generalize this if you track UserCAllbackInfo, clear it |
| 7407 | when the callback occurs |
| 7408 | */ |
| 7409 | static UserCallbackInfo * |
| 7410 | internalRequestTimedCallback (RIL_TimedCallback callback, void *param, |
| 7411 | const struct timeval *relativeTime) |
| 7412 | { |
| 7413 | struct timeval myRelativeTime; |
| 7414 | UserCallbackInfo *p_info; |
| 7415 | |
| 7416 | p_info = (UserCallbackInfo *) calloc(1, sizeof(UserCallbackInfo)); |
| 7417 | if (p_info == NULL) { |
| 7418 | RLOGE("Memory allocation failed in internalRequestTimedCallback"); |
| 7419 | return p_info; |
| 7420 | |
| 7421 | } |
| 7422 | |
| 7423 | p_info->p_callback = callback; |
| 7424 | p_info->userParam = param; |
| 7425 | |
| 7426 | if (relativeTime == NULL) { |
| 7427 | /* treat null parameter as a 0 relative time */ |
| 7428 | memset (&myRelativeTime, 0, sizeof(myRelativeTime)); |
| 7429 | } else { |
| 7430 | /* FIXME I think event_add's tv param is really const anyway */ |
| 7431 | memcpy (&myRelativeTime, relativeTime, sizeof(myRelativeTime)); |
| 7432 | } |
| 7433 | |
| 7434 | ril_event_set(&(p_info->event), -1, false, userTimerCallback, p_info); |
| 7435 | |
| 7436 | ril_timer_add(&(p_info->event), &myRelativeTime); |
| 7437 | |
| 7438 | triggerEvLoop(); |
| 7439 | return p_info; |
| 7440 | } |
| 7441 | |
| 7442 | |
| 7443 | extern "C" void |
| 7444 | RIL_requestTimedCallback (RIL_TimedCallback callback, void *param, |
| 7445 | const struct timeval *relativeTime) { |
| 7446 | internalRequestTimedCallback (callback, param, relativeTime); |
| 7447 | } |
| 7448 | |
| 7449 | const char * |
| 7450 | failCauseToString(RIL_Errno e) { |
| 7451 | switch(e) { |
| 7452 | case RIL_E_SUCCESS: return "E_SUCCESS"; |
| 7453 | case RIL_E_RADIO_NOT_AVAILABLE: return "E_RADIO_NOT_AVAILABLE"; |
| 7454 | case RIL_E_GENERIC_FAILURE: return "E_GENERIC_FAILURE"; |
| 7455 | case RIL_E_PASSWORD_INCORRECT: return "E_PASSWORD_INCORRECT"; |
| 7456 | case RIL_E_SIM_PIN2: return "E_SIM_PIN2"; |
| 7457 | case RIL_E_SIM_PUK2: return "E_SIM_PUK2"; |
| 7458 | case RIL_E_REQUEST_NOT_SUPPORTED: return "E_REQUEST_NOT_SUPPORTED"; |
| 7459 | case RIL_E_CANCELLED: return "E_CANCELLED"; |
| 7460 | case RIL_E_OP_NOT_ALLOWED_DURING_VOICE_CALL: return "E_OP_NOT_ALLOWED_DURING_VOICE_CALL"; |
| 7461 | case RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW: return "E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW"; |
| 7462 | case RIL_E_SMS_SEND_FAIL_RETRY: return "E_SMS_SEND_FAIL_RETRY"; |
| 7463 | case RIL_E_SIM_ABSENT:return "E_SIM_ABSENT"; |
| 7464 | case RIL_E_ILLEGAL_SIM_OR_ME:return "E_ILLEGAL_SIM_OR_ME"; |
| 7465 | #ifdef FEATURE_MULTIMODE_ANDROID |
| 7466 | case RIL_E_SUBSCRIPTION_NOT_AVAILABLE:return "E_SUBSCRIPTION_NOT_AVAILABLE"; |
| 7467 | case RIL_E_MODE_NOT_SUPPORTED:return "E_MODE_NOT_SUPPORTED"; |
| 7468 | #endif |
| 7469 | case RIL_E_FDN_CHECK_FAILURE: return "E_FDN_CHECK_FAILURE"; |
| 7470 | case RIL_E_MISSING_RESOURCE: return "E_MISSING_RESOURCE"; |
| 7471 | case RIL_E_NO_SUCH_ELEMENT: return "E_NO_SUCH_ELEMENT"; |
| 7472 | case RIL_E_DIAL_MODIFIED_TO_USSD: return "E_DIAL_MODIFIED_TO_USSD"; |
| 7473 | case RIL_E_DIAL_MODIFIED_TO_SS: return "E_DIAL_MODIFIED_TO_SS"; |
| 7474 | case RIL_E_DIAL_MODIFIED_TO_DIAL: return "E_DIAL_MODIFIED_TO_DIAL"; |
| 7475 | case RIL_E_USSD_MODIFIED_TO_DIAL: return "E_USSD_MODIFIED_TO_DIAL"; |
| 7476 | case RIL_E_USSD_MODIFIED_TO_SS: return "E_USSD_MODIFIED_TO_SS"; |
| 7477 | case RIL_E_USSD_MODIFIED_TO_USSD: return "E_USSD_MODIFIED_TO_USSD"; |
| 7478 | case RIL_E_SS_MODIFIED_TO_DIAL: return "E_SS_MODIFIED_TO_DIAL"; |
| 7479 | case RIL_E_SS_MODIFIED_TO_USSD: return "E_SS_MODIFIED_TO_USSD"; |
| 7480 | case RIL_E_SUBSCRIPTION_NOT_SUPPORTED: return "E_SUBSCRIPTION_NOT_SUPPORTED"; |
| 7481 | case RIL_E_SS_MODIFIED_TO_SS: return "E_SS_MODIFIED_TO_SS"; |
| 7482 | case RIL_E_LCE_NOT_SUPPORTED: return "E_LCE_NOT_SUPPORTED"; |
| 7483 | case RIL_E_NO_MEMORY: return "E_NO_MEMORY"; |
| 7484 | case RIL_E_INTERNAL_ERR: return "E_INTERNAL_ERR"; |
| 7485 | case RIL_E_SYSTEM_ERR: return "E_SYSTEM_ERR"; |
| 7486 | case RIL_E_MODEM_ERR: return "E_MODEM_ERR"; |
| 7487 | case RIL_E_INVALID_STATE: return "E_INVALID_STATE"; |
| 7488 | case RIL_E_NO_RESOURCES: return "E_NO_RESOURCES"; |
| 7489 | case RIL_E_SIM_ERR: return "E_SIM_ERR"; |
| 7490 | case RIL_E_INVALID_ARGUMENTS: return "E_INVALID_ARGUMENTS"; |
| 7491 | case RIL_E_INVALID_SIM_STATE: return "E_INVALID_SIM_STATE"; |
| 7492 | case RIL_E_INVALID_MODEM_STATE: return "E_INVALID_MODEM_STATE"; |
| 7493 | case RIL_E_INVALID_CALL_ID: return "E_INVALID_CALL_ID"; |
| 7494 | case RIL_E_NO_SMS_TO_ACK: return "E_NO_SMS_TO_ACK"; |
| 7495 | case RIL_E_NETWORK_ERR: return "E_NETWORK_ERR"; |
| 7496 | case RIL_E_REQUEST_RATE_LIMITED: return "E_REQUEST_RATE_LIMITED"; |
| 7497 | case RIL_E_SIM_BUSY: return "E_SIM_BUSY"; |
| 7498 | case RIL_E_SIM_FULL: return "E_SIM_FULL"; |
| 7499 | case RIL_E_NETWORK_REJECT: return "E_NETWORK_REJECT"; |
| 7500 | case RIL_E_OPERATION_NOT_ALLOWED: return "E_OPERATION_NOT_ALLOWED"; |
| 7501 | case RIL_E_EMPTY_RECORD: "E_EMPTY_RECORD"; |
| 7502 | case RIL_E_INVALID_SMS_FORMAT: return "E_INVALID_SMS_FORMAT"; |
| 7503 | case RIL_E_ENCODING_ERR: return "E_ENCODING_ERR"; |
| 7504 | case RIL_E_INVALID_SMSC_ADDRESS: return "E_INVALID_SMSC_ADDRESS"; |
| 7505 | case RIL_E_NO_SUCH_ENTRY: return "E_NO_SUCH_ENTRY"; |
| 7506 | case RIL_E_NETWORK_NOT_READY: return "E_NETWORK_NOT_READY"; |
| 7507 | case RIL_E_NOT_PROVISIONED: return "E_NOT_PROVISIONED"; |
| 7508 | case RIL_E_NO_SUBSCRIPTION: return "E_NO_SUBSCRIPTION"; |
| 7509 | case RIL_E_NO_NETWORK_FOUND: return "E_NO_NETWORK_FOUND"; |
| 7510 | case RIL_E_DEVICE_IN_USE: return "E_DEVICE_IN_USE"; |
| 7511 | case RIL_E_ABORTED: return "E_ABORTED"; |
| 7512 | case RIL_E_OEM_ERROR_1: return "E_OEM_ERROR_1"; |
| 7513 | case RIL_E_OEM_ERROR_2: return "E_OEM_ERROR_2"; |
| 7514 | case RIL_E_OEM_ERROR_3: return "E_OEM_ERROR_3"; |
| 7515 | case RIL_E_OEM_ERROR_4: return "E_OEM_ERROR_4"; |
| 7516 | case RIL_E_OEM_ERROR_5: return "E_OEM_ERROR_5"; |
| 7517 | case RIL_E_OEM_ERROR_6: return "E_OEM_ERROR_6"; |
| 7518 | case RIL_E_OEM_ERROR_7: return "E_OEM_ERROR_7"; |
| 7519 | case RIL_E_OEM_ERROR_8: return "E_OEM_ERROR_8"; |
| 7520 | case RIL_E_OEM_ERROR_9: return "E_OEM_ERROR_9"; |
| 7521 | case RIL_E_OEM_ERROR_10: return "E_OEM_ERROR_10"; |
| 7522 | case RIL_E_OEM_ERROR_11: return "E_OEM_ERROR_11"; |
| 7523 | case RIL_E_OEM_ERROR_12: return "E_OEM_ERROR_12"; |
| 7524 | case RIL_E_OEM_ERROR_13: return "E_OEM_ERROR_13"; |
| 7525 | case RIL_E_OEM_ERROR_14: return "E_OEM_ERROR_14"; |
| 7526 | case RIL_E_OEM_ERROR_15: return "E_OEM_ERROR_15"; |
| 7527 | case RIL_E_OEM_ERROR_16: return "E_OEM_ERROR_16"; |
| 7528 | case RIL_E_OEM_ERROR_17: return "E_OEM_ERROR_17"; |
| 7529 | case RIL_E_OEM_ERROR_18: return "E_OEM_ERROR_18"; |
| 7530 | case RIL_E_OEM_ERROR_19: return "E_OEM_ERROR_19"; |
| 7531 | case RIL_E_OEM_ERROR_20: return "E_OEM_ERROR_20"; |
| 7532 | case RIL_E_OEM_ERROR_21: return "E_OEM_ERROR_21"; |
| 7533 | case RIL_E_OEM_ERROR_22: return "E_OEM_ERROR_22"; |
| 7534 | case RIL_E_OEM_ERROR_23: return "E_OEM_ERROR_23"; |
| 7535 | case RIL_E_OEM_ERROR_24: return "E_OEM_ERROR_24"; |
| 7536 | case RIL_E_OEM_ERROR_25: return "E_OEM_ERROR_25"; |
| 7537 | default: return "<unknown error>"; |
| 7538 | } |
| 7539 | } |
| 7540 | |
| 7541 | const char * |
| 7542 | callStateToString(RIL_CallState s) { |
| 7543 | switch(s) { |
| 7544 | case RIL_CALL_ACTIVE : return "ACTIVE"; |
| 7545 | case RIL_CALL_HOLDING: return "HOLDING"; |
| 7546 | case RIL_CALL_DIALING: return "DIALING"; |
| 7547 | case RIL_CALL_ALERTING: return "ALERTING"; |
| 7548 | case RIL_CALL_INCOMING: return "INCOMING"; |
| 7549 | case RIL_CALL_WAITING: return "WAITING"; |
| 7550 | default: return "<unknown state>"; |
| 7551 | } |
| 7552 | } |
| 7553 | |
| 7554 | const char * |
| 7555 | requestToString(int request) { |
| 7556 | /* |
| 7557 | cat libs/telephony/ril_commands.h \ |
| 7558 | | egrep "^ *{RIL_" \ |
| 7559 | | sed -re 's/\{RIL_([^,]+),[^,]+,([^}]+).+/case RIL_\1: return "\1";/' |
| 7560 | |
| 7561 | |
| 7562 | cat libs/telephony/ril_unsol_commands.h \ |
| 7563 | | egrep "^ *{RIL_" \ |
| 7564 | | sed -re 's/\{RIL_([^,]+),([^}]+).+/case RIL_\1: return "\1";/' |
| 7565 | |
| 7566 | */ |
| 7567 | switch(request) { |
| 7568 | case RIL_REQUEST_GET_SIM_STATUS: return "GET_SIM_STATUS"; |
| 7569 | case RIL_REQUEST_ENTER_SIM_PIN: return "ENTER_SIM_PIN"; |
| 7570 | case RIL_REQUEST_ENTER_SIM_PUK: return "ENTER_SIM_PUK"; |
| 7571 | case RIL_REQUEST_ENTER_SIM_PIN2: return "ENTER_SIM_PIN2"; |
| 7572 | case RIL_REQUEST_ENTER_SIM_PUK2: return "ENTER_SIM_PUK2"; |
| 7573 | case RIL_REQUEST_CHANGE_SIM_PIN: return "CHANGE_SIM_PIN"; |
| 7574 | case RIL_REQUEST_CHANGE_SIM_PIN2: return "CHANGE_SIM_PIN2"; |
| 7575 | case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: return "ENTER_NETWORK_DEPERSONALIZATION"; |
| 7576 | case RIL_REQUEST_GET_CURRENT_CALLS: return "GET_CURRENT_CALLS"; |
| 7577 | case RIL_REQUEST_DIAL: return "DIAL"; |
| 7578 | case RIL_REQUEST_GET_IMSI: return "GET_IMSI"; |
| 7579 | case RIL_REQUEST_HANGUP: return "HANGUP"; |
| 7580 | case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: return "HANGUP_WAITING_OR_BACKGROUND"; |
| 7581 | case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: return "HANGUP_FOREGROUND_RESUME_BACKGROUND"; |
| 7582 | case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: return "SWITCH_WAITING_OR_HOLDING_AND_ACTIVE"; |
| 7583 | case RIL_REQUEST_CONFERENCE: return "CONFERENCE"; |
| 7584 | case RIL_REQUEST_UDUB: return "UDUB"; |
| 7585 | case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: return "LAST_CALL_FAIL_CAUSE"; |
| 7586 | case RIL_REQUEST_SIGNAL_STRENGTH: return "SIGNAL_STRENGTH"; |
| 7587 | case RIL_REQUEST_VOICE_REGISTRATION_STATE: return "VOICE_REGISTRATION_STATE"; |
| 7588 | case RIL_REQUEST_DATA_REGISTRATION_STATE: return "DATA_REGISTRATION_STATE"; |
| 7589 | case RIL_REQUEST_OPERATOR: return "OPERATOR"; |
| 7590 | case RIL_REQUEST_RADIO_POWER: return "RADIO_POWER"; |
| 7591 | case RIL_REQUEST_DTMF: return "DTMF"; |
| 7592 | case RIL_REQUEST_SEND_SMS: return "SEND_SMS"; |
| 7593 | case RIL_REQUEST_SEND_SMS_EXPECT_MORE: return "SEND_SMS_EXPECT_MORE"; |
| 7594 | case RIL_REQUEST_SETUP_DATA_CALL: return "SETUP_DATA_CALL"; |
| 7595 | case RIL_REQUEST_SIM_IO: return "SIM_IO"; |
| 7596 | case RIL_REQUEST_SEND_USSD: return "SEND_USSD"; |
| 7597 | case RIL_REQUEST_CANCEL_USSD: return "CANCEL_USSD"; |
| 7598 | case RIL_REQUEST_GET_CLIR: return "GET_CLIR"; |
| 7599 | case RIL_REQUEST_SET_CLIR: return "SET_CLIR"; |
| 7600 | case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: return "QUERY_CALL_FORWARD_STATUS"; |
| 7601 | case RIL_REQUEST_SET_CALL_FORWARD: return "SET_CALL_FORWARD"; |
| 7602 | case RIL_REQUEST_QUERY_CALL_WAITING: return "QUERY_CALL_WAITING"; |
| 7603 | case RIL_REQUEST_SET_CALL_WAITING: return "SET_CALL_WAITING"; |
| 7604 | case RIL_REQUEST_SMS_ACKNOWLEDGE: return "SMS_ACKNOWLEDGE"; |
| 7605 | case RIL_REQUEST_GET_IMEI: return "GET_IMEI"; |
| 7606 | case RIL_REQUEST_GET_IMEISV: return "GET_IMEISV"; |
| 7607 | case RIL_REQUEST_ANSWER: return "ANSWER"; |
| 7608 | case RIL_REQUEST_DEACTIVATE_DATA_CALL: return "DEACTIVATE_DATA_CALL"; |
| 7609 | case RIL_REQUEST_QUERY_FACILITY_LOCK: return "QUERY_FACILITY_LOCK"; |
| 7610 | case RIL_REQUEST_SET_FACILITY_LOCK: return "SET_FACILITY_LOCK"; |
| 7611 | case RIL_REQUEST_CHANGE_BARRING_PASSWORD: return "CHANGE_BARRING_PASSWORD"; |
| 7612 | case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: return "QUERY_NETWORK_SELECTION_MODE"; |
| 7613 | case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: return "SET_NETWORK_SELECTION_AUTOMATIC"; |
| 7614 | case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: return "SET_NETWORK_SELECTION_MANUAL"; |
| 7615 | case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : return "QUERY_AVAILABLE_NETWORKS"; |
| 7616 | case RIL_REQUEST_DTMF_START: return "DTMF_START"; |
| 7617 | case RIL_REQUEST_DTMF_STOP: return "DTMF_STOP"; |
| 7618 | case RIL_REQUEST_BASEBAND_VERSION: return "BASEBAND_VERSION"; |
| 7619 | case RIL_REQUEST_SEPARATE_CONNECTION: return "SEPARATE_CONNECTION"; |
| 7620 | case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: return "SET_PREFERRED_NETWORK_TYPE"; |
| 7621 | case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: return "GET_PREFERRED_NETWORK_TYPE"; |
| 7622 | case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: return "GET_NEIGHBORING_CELL_IDS"; |
| 7623 | case RIL_REQUEST_SET_MUTE: return "SET_MUTE"; |
| 7624 | case RIL_REQUEST_GET_MUTE: return "GET_MUTE"; |
| 7625 | case RIL_REQUEST_QUERY_CLIP: return "QUERY_CLIP"; |
| 7626 | case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: return "LAST_DATA_CALL_FAIL_CAUSE"; |
| 7627 | case RIL_REQUEST_DATA_CALL_LIST: return "DATA_CALL_LIST"; |
| 7628 | case RIL_REQUEST_NV_RESET_CONFIG: return "NV_RESET_CONFIG"; |
| 7629 | case RIL_REQUEST_RESET_RADIO: return "RESET_RADIO"; |
| 7630 | case RIL_REQUEST_OEM_HOOK_RAW: return "OEM_HOOK_RAW"; |
| 7631 | case RIL_REQUEST_OEM_HOOK_STRINGS: return "OEM_HOOK_STRINGS"; |
| 7632 | case RIL_REQUEST_SET_BAND_MODE: return "SET_BAND_MODE"; |
| 7633 | case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: return "QUERY_AVAILABLE_BAND_MODE"; |
| 7634 | case RIL_REQUEST_STK_GET_PROFILE: return "STK_GET_PROFILE"; |
| 7635 | case RIL_REQUEST_STK_SET_PROFILE: return "STK_SET_PROFILE"; |
| 7636 | case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: return "STK_SEND_ENVELOPE_COMMAND"; |
| 7637 | case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: return "STK_SEND_TERMINAL_RESPONSE"; |
| 7638 | case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: return "STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM"; |
| 7639 | case RIL_REQUEST_SCREEN_STATE: return "SCREEN_STATE"; |
| 7640 | case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: return "EXPLICIT_CALL_TRANSFER"; |
| 7641 | case RIL_REQUEST_SET_LOCATION_UPDATES: return "SET_LOCATION_UPDATES"; |
| 7642 | case RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE:return"CDMA_SET_SUBSCRIPTION_SOURCE"; |
| 7643 | case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE:return"CDMA_SET_ROAMING_PREFERENCE"; |
| 7644 | case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE:return"CDMA_QUERY_ROAMING_PREFERENCE"; |
| 7645 | case RIL_REQUEST_SET_TTY_MODE:return"SET_TTY_MODE"; |
| 7646 | case RIL_REQUEST_QUERY_TTY_MODE:return"QUERY_TTY_MODE"; |
| 7647 | case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE"; |
| 7648 | case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE"; |
| 7649 | case RIL_REQUEST_CDMA_FLASH:return"CDMA_FLASH"; |
| 7650 | case RIL_REQUEST_CDMA_BURST_DTMF:return"CDMA_BURST_DTMF"; |
| 7651 | case RIL_REQUEST_CDMA_SEND_SMS:return"CDMA_SEND_SMS"; |
| 7652 | case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE:return"CDMA_SMS_ACKNOWLEDGE"; |
| 7653 | case RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG:return"GSM_GET_BROADCAST_SMS_CONFIG"; |
| 7654 | case RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG:return"GSM_SET_BROADCAST_SMS_CONFIG"; |
| 7655 | case RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG:return "CDMA_GET_BROADCAST_SMS_CONFIG"; |
| 7656 | case RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG:return "CDMA_SET_BROADCAST_SMS_CONFIG"; |
| 7657 | case RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION:return "CDMA_SMS_BROADCAST_ACTIVATION"; |
| 7658 | case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: return"CDMA_VALIDATE_AND_WRITE_AKEY"; |
| 7659 | case RIL_REQUEST_CDMA_SUBSCRIPTION: return"CDMA_SUBSCRIPTION"; |
| 7660 | case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: return "CDMA_WRITE_SMS_TO_RUIM"; |
| 7661 | case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: return "CDMA_DELETE_SMS_ON_RUIM"; |
| 7662 | case RIL_REQUEST_DEVICE_IDENTITY: return "DEVICE_IDENTITY"; |
| 7663 | case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: return "EXIT_EMERGENCY_CALLBACK_MODE"; |
| 7664 | case RIL_REQUEST_GET_SMSC_ADDRESS: return "GET_SMSC_ADDRESS"; |
| 7665 | case RIL_REQUEST_SET_SMSC_ADDRESS: return "SET_SMSC_ADDRESS"; |
| 7666 | case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: return "REPORT_SMS_MEMORY_STATUS"; |
| 7667 | case RIL_REQUEST_GET_SMS_SIM_MEM_STATUS: return "GET_SMS_SIM_MEM_STATUS"; |
| 7668 | case RIL_REQUEST_GSM_GET_BROADCAST_LANGUAGE: return "GSM_GET_BROADCAST_LANGUAGE"; |
| 7669 | case RIL_REQUEST_GSM_SET_BROADCAST_LANGUAGE: return "GSM_SET_BROADCAST_LANGUAGE"; |
| 7670 | case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: return "REPORT_STK_SERVICE_IS_RUNNING"; |
| 7671 | case RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE: return "CDMA_GET_SUBSCRIPTION_SOURCE"; |
| 7672 | case RIL_REQUEST_ISIM_AUTHENTICATION: return "ISIM_AUTHENTICATION"; |
| 7673 | case RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU: return "RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU"; |
| 7674 | case RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS: return "RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS"; |
| 7675 | case RIL_REQUEST_VOICE_RADIO_TECH: return "VOICE_RADIO_TECH"; |
| 7676 | case RIL_REQUEST_WRITE_SMS_TO_SIM: return "WRITE_SMS_TO_SIM"; |
| 7677 | case RIL_REQUEST_GET_CELL_INFO_LIST: return"GET_CELL_INFO_LIST"; |
| 7678 | case RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE: return"SET_UNSOL_CELL_INFO_LIST_RATE"; |
| 7679 | case RIL_REQUEST_SET_INITIAL_ATTACH_APN: return "RIL_REQUEST_SET_INITIAL_ATTACH_APN"; |
| 7680 | case RIL_REQUEST_IMS_REGISTRATION_STATE: return "IMS_REGISTRATION_STATE"; |
| 7681 | case RIL_REQUEST_IMS_SEND_SMS: return "IMS_SEND_SMS"; |
| 7682 | case RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC: return "SIM_TRANSMIT_APDU_BASIC"; |
| 7683 | case RIL_REQUEST_SIM_OPEN_CHANNEL: return "SIM_OPEN_CHANNEL"; |
| 7684 | case RIL_REQUEST_SIM_CLOSE_CHANNEL: return "SIM_CLOSE_CHANNEL"; |
| 7685 | case RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL: return "SIM_TRANSMIT_APDU_CHANNEL"; |
| 7686 | case RIL_REQUEST_GET_RADIO_CAPABILITY: return "RIL_REQUEST_GET_RADIO_CAPABILITY"; |
| 7687 | case RIL_REQUEST_SET_RADIO_CAPABILITY: return "RIL_REQUEST_SET_RADIO_CAPABILITY"; |
| 7688 | case RIL_REQUEST_SET_UICC_SUBSCRIPTION: return "SET_UICC_SUBSCRIPTION"; |
| 7689 | case RIL_REQUEST_ALLOW_DATA: return "ALLOW_DATA"; |
| 7690 | case RIL_REQUEST_GET_HARDWARE_CONFIG: return "GET_HARDWARE_CONFIG"; |
| 7691 | case RIL_REQUEST_SIM_AUTHENTICATION: return "SIM_AUTHENTICATION"; |
| 7692 | case RIL_REQUEST_GET_DC_RT_INFO: return "GET_DC_RT_INFO"; |
| 7693 | case RIL_REQUEST_SET_DC_RT_INFO_RATE: return "SET_DC_RT_INFO_RATE"; |
| 7694 | case RIL_REQUEST_SET_DATA_PROFILE: return "SET_DATA_PROFILE"; |
| 7695 | case RIL_REQUEST_SET_CARRIER_RESTRICTIONS: return "SET_CARRIER_RESTRICTIONS"; |
| 7696 | case RIL_REQUEST_GET_CARRIER_RESTRICTIONS: return "GET_CARRIER_RESTRICTIONS"; |
| 7697 | // case RIL_REQUEST_SET_PSEUDO_BS_ENABLE: return "SET_PSEUDO_BS_ENABLE"; |
| 7698 | // case RIL_REQUEST_GET_PSEUDO_BS_RECORDS: return "GET_PSEUDO_BS_RECORDS"; |
| 7699 | case RIL_REQUEST_IMS_BEARER_ACTIVATION_DONE: return "RIL_REQUEST_IMS_BEARER_ACTIVATION_DONE"; |
| 7700 | case RIL_REQUEST_IMS_BEARER_DEACTIVATION_DONE: return "RIL_REQUEST_IMS_BEARER_DEACTIVATION_DONE"; |
| 7701 | case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return "UNSOL_RESPONSE_RADIO_STATE_CHANGED"; |
| 7702 | case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return "UNSOL_RESPONSE_CALL_STATE_CHANGED"; |
| 7703 | case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: return "UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED"; |
| 7704 | case RIL_UNSOL_RESPONSE_NEW_SMS: return "UNSOL_RESPONSE_NEW_SMS"; |
| 7705 | case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: return "UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT"; |
| 7706 | case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: return "UNSOL_RESPONSE_NEW_SMS_ON_SIM"; |
| 7707 | case RIL_UNSOL_ON_USSD: return "UNSOL_ON_USSD"; |
| 7708 | case RIL_UNSOL_ON_USSD_REQUEST: return "UNSOL_ON_USSD_REQUEST(obsolete)"; |
| 7709 | case RIL_UNSOL_NITZ_TIME_RECEIVED: return "UNSOL_NITZ_TIME_RECEIVED"; |
| 7710 | case RIL_UNSOL_SIGNAL_STRENGTH: return "UNSOL_SIGNAL_STRENGTH"; |
| 7711 | case RIL_UNSOL_SUPP_SVC_NOTIFICATION: return "UNSOL_SUPP_SVC_NOTIFICATION"; |
| 7712 | case RIL_UNSOL_STK_SESSION_END: return "UNSOL_STK_SESSION_END"; |
| 7713 | case RIL_UNSOL_STK_PROACTIVE_COMMAND: return "UNSOL_STK_PROACTIVE_COMMAND"; |
| 7714 | case RIL_UNSOL_STK_EVENT_NOTIFY: return "UNSOL_STK_EVENT_NOTIFY"; |
| 7715 | case RIL_UNSOL_STK_CALL_SETUP: return "UNSOL_STK_CALL_SETUP"; |
| 7716 | case RIL_UNSOL_SIM_SMS_STORAGE_FULL: return "UNSOL_SIM_SMS_STORAGE_FUL"; |
| 7717 | case RIL_UNSOL_SIM_REFRESH: return "UNSOL_SIM_REFRESH"; |
| 7718 | case RIL_UNSOL_DATA_CALL_LIST_CHANGED: return "UNSOL_DATA_CALL_LIST_CHANGED"; |
| 7719 | case RIL_UNSOL_CALL_RING: return "UNSOL_CALL_RING"; |
| 7720 | case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: return "UNSOL_RESPONSE_SIM_STATUS_CHANGED"; |
| 7721 | case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: return "UNSOL_NEW_CDMA_SMS"; |
| 7722 | case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: return "UNSOL_NEW_BROADCAST_SMS"; |
| 7723 | case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: return "UNSOL_CDMA_RUIM_SMS_STORAGE_FULL"; |
| 7724 | case RIL_UNSOL_RESTRICTED_STATE_CHANGED: return "UNSOL_RESTRICTED_STATE_CHANGED"; |
| 7725 | case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: return "UNSOL_ENTER_EMERGENCY_CALLBACK_MODE"; |
| 7726 | case RIL_UNSOL_CDMA_CALL_WAITING: return "UNSOL_CDMA_CALL_WAITING"; |
| 7727 | case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: return "UNSOL_CDMA_OTA_PROVISION_STATUS"; |
| 7728 | case RIL_UNSOL_CDMA_INFO_REC: return "UNSOL_CDMA_INFO_REC"; |
| 7729 | case RIL_UNSOL_OEM_HOOK_RAW: return "UNSOL_OEM_HOOK_RAW"; |
| 7730 | case RIL_UNSOL_RINGBACK_TONE: return "UNSOL_RINGBACK_TONE"; |
| 7731 | case RIL_UNSOL_RESEND_INCALL_MUTE: return "UNSOL_RESEND_INCALL_MUTE"; |
| 7732 | case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: return "UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED"; |
| 7733 | case RIL_UNSOL_CDMA_PRL_CHANGED: return "UNSOL_CDMA_PRL_CHANGED"; |
| 7734 | case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: return "UNSOL_EXIT_EMERGENCY_CALLBACK_MODE"; |
| 7735 | case RIL_UNSOL_RIL_CONNECTED: return "UNSOL_RIL_CONNECTED"; |
| 7736 | case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED: return "UNSOL_VOICE_RADIO_TECH_CHANGED"; |
| 7737 | case RIL_UNSOL_CELL_INFO_LIST: return "UNSOL_CELL_INFO_LIST"; |
| 7738 | case RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED: return "RESPONSE_IMS_NETWORK_STATE_CHANGED"; |
| 7739 | case RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED: return "UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED"; |
| 7740 | case RIL_UNSOL_SRVCC_STATE_NOTIFY: return "UNSOL_SRVCC_STATE_NOTIFY"; |
| 7741 | case RIL_UNSOL_HARDWARE_CONFIG_CHANGED: return "HARDWARE_CONFIG_CHANGED"; |
| 7742 | case RIL_UNSOL_DC_RT_INFO_CHANGED: return "UNSOL_DC_RT_INFO_CHANGED"; |
| 7743 | case RIL_REQUEST_SHUTDOWN: return "SHUTDOWN"; |
| 7744 | case RIL_UNSOL_RADIO_CAPABILITY: return "RIL_UNSOL_RADIO_CAPABILITY"; |
| 7745 | case RIL_RESPONSE_ACKNOWLEDGEMENT: return "RIL_RESPONSE_ACKNOWLEDGEMENT"; |
| 7746 | case RIL_UNSOL_PCO_DATA: return "RIL_UNSOL_PCO_DATA"; |
| 7747 | // case RIL_UNSOL_PSEUDO_BS_INFO_LIST: return "UNSOL_PSEUDO_BS_INFO_LIST"; |
| 7748 | case RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION: return "RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION"; |
| 7749 | case RIL_REQUEST_SET_COLR: return "RIL_REQUEST_SET_COLR"; |
| 7750 | case RIL_REQUEST_GET_COLP: return "RIL_REQUEST_GET_COLP"; |
| 7751 | case RIL_REQUEST_GET_COLR: return "RIL_REQUEST_GET_COLR"; |
| 7752 | case RIL_REQUEST_SET_CLIP: return "RIL_REQUEST_SET_CLIP"; |
| 7753 | case RIL_REQUEST_SET_COLP: return "RIL_REQUEST_SET_COLP"; |
| 7754 | case RIL_REQUEST_QUERY_CALL_FORWARD_IN_TIME_SLOT: return "RIL_REQUEST_QUERY_CALL_FORWARD_IN_TIME_SLOT"; |
| 7755 | case RIL_REQUEST_SET_CALL_FORWARD_IN_TIME_SLOT: return "RIL_REQUEST_SET_CALL_FORWARD_IN_TIME_SLOT"; |
| 7756 | case RIL_REQUEST_RUN_GBA: return "RIL_REQUEST_RUN_GBA"; |
| 7757 | case RIL_UNSOL_IMS_BEARER_ACTIVATION: return "RIL_UNSOL_IMS_BEARER_ACTIVATION"; |
| 7758 | case RIL_UNSOL_IMS_BEARER_DEACTIVATION: return "RIL_UNSOL_IMS_BEARER_DEACTIVATION"; |
| 7759 | case RIL_UNSOL_IMS_BEARER_INIT: return "RIL_UNSOL_IMS_BEARER_INIT"; |
| 7760 | // case RIL_REQUEST_SETUP_DATA_CALL_ALT: return "RIL_REQUEST_SETUP_DATA_CALL_ALT"; |
| 7761 | // case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE_ALT: return "RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE_ALT"; |
| 7762 | // case RIL_REQUEST_PCSCF_DISCOVERY_PCO_ALT: return "RIL_REQUEST_PCSCF_DISCOVERY_PCO_ALT"; |
| 7763 | case RIL_REQUEST_SET_MD_IMSCFG: return "RIL_REQUEST_SET_MD_IMSCFG"; |
| 7764 | // case RIL_REQUEST_SET_IMS_EVS_ENABLE : return "RIL_REQUEST_SET_IMS_EVS_ENABLE"; |
| 7765 | default: return mtkRequestToString(request); |
| 7766 | } |
| 7767 | } |
| 7768 | |
| 7769 | const char * |
| 7770 | rilSocketIdToString(RIL_SOCKET_ID socket_id) |
| 7771 | { |
| 7772 | switch(socket_id) { |
| 7773 | case RIL_SOCKET_1: |
| 7774 | return "RIL_SOCKET_1"; |
| 7775 | case RIL_SOCKET_2: |
| 7776 | return "RIL_SOCKET_2"; |
| 7777 | case RIL_SOCKET_3: |
| 7778 | return "RIL_SOCKET_3"; |
| 7779 | case RIL_SOCKET_4: |
| 7780 | return "RIL_SOCKET_4"; |
| 7781 | case RIL_SOCKET_RILJ: |
| 7782 | return SOCKET_NAME_RILJCLIENT; |
| 7783 | case RIL_SOCKET_RILJ2: |
| 7784 | return SOCKET2_NAME_RILJCLIENT; |
| 7785 | default: |
| 7786 | return "not a valid RIL"; |
| 7787 | } |
| 7788 | } |
| 7789 | |
| 7790 | // M: ril proxy |
| 7791 | void cacheUrc(int unsolResponse, const void *data, size_t datalen, RIL_SOCKET_ID socket_id){ |
| 7792 | //Only the URC list we wanted. |
| 7793 | if (unsolResponse != RIL_UNSOL_STK_PROACTIVE_COMMAND |
| 7794 | && unsolResponse != RIL_UNSOL_STK_EVENT_NOTIFY |
| 7795 | && unsolResponse != RIL_UNSOL_CALL_FORWARDING |
| 7796 | && unsolResponse != RIL_UNSOL_SMS_READY_NOTIFICATION |
| 7797 | && unsolResponse != RIL_UNSOL_IMEI_LOCK |
| 7798 | && unsolResponse != RIL_UNSOL_PHB_READY_NOTIFICATION |
| 7799 | && unsolResponse != RIL_UNSOL_SIM_SMS_STORAGE_FULL |
| 7800 | && unsolResponse != RIL_UNSOL_ME_SMS_STORAGE_FULL |
| 7801 | && unsolResponse != RIL_UNSOL_RADIO_CAPABILITY |
| 7802 | && unsolResponse != RIL_UNSOL_SIM_PLUG_IN |
| 7803 | && unsolResponse != RIL_UNSOL_SIM_PLUG_OUT |
| 7804 | && unsolResponse != RIL_UNSOL_RESPONSE_PLMN_CHANGED |
| 7805 | && unsolResponse != RIL_UNSOL_RESPONSE_REGISTRATION_SUSPENDED |
| 7806 | && unsolResponse != RIL_UNSOL_VOICE_RADIO_TECH_CHANGED |
| 7807 | && unsolResponse != RIL_UNSOL_WORLD_MODE_CHANGED |
| 7808 | && unsolResponse != RIL_UNSOL_CDMA_CARD_INITIAL_ESN_OR_MEID |
| 7809 | && unsolResponse != RIL_UNSOL_RESPONSE_CDMA_NEW_SMS |
| 7810 | && unsolResponse != RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL |
| 7811 | && unsolResponse != RIL_UNSOL_TX_POWER |
| 7812 | && unsolResponse != RIL_UNSOL_HARDWARE_CONFIG_CHANGED |
| 7813 | /*&& unsolResponse != RIL_UNSOL_TRAY_PLUG_IN*/) { |
| 7814 | RLOGI("Don't need to cache the request"); |
| 7815 | return; |
| 7816 | } |
| 7817 | AtResponseList* urcCur = NULL; |
| 7818 | AtResponseList* urcPrev = NULL; |
| 7819 | int pendedUrcCount = 0; |
| 7820 | |
| 7821 | switch(socket_id) { |
| 7822 | case RIL_SOCKET_1: |
| 7823 | urcCur = pendedUrcList1; |
| 7824 | break; |
| 7825 | case RIL_SOCKET_2: |
| 7826 | urcCur = pendedUrcList2; |
| 7827 | break; |
| 7828 | case RIL_SOCKET_3: |
| 7829 | urcCur = pendedUrcList3; |
| 7830 | break; |
| 7831 | case RIL_SOCKET_4: |
| 7832 | urcCur = pendedUrcList4; |
| 7833 | break; |
| 7834 | case RIL_SOCKET_RILJ: |
| 7835 | urcCur = pendedUrcList_rilj; |
| 7836 | break; |
| 7837 | case RIL_SOCKET_RILJ2: |
| 7838 | urcCur = pendedUrcList_rilj2; |
| 7839 | break; |
| 7840 | default: |
| 7841 | RLOGE("Socket id is wrong!!"); |
| 7842 | return; |
| 7843 | } |
| 7844 | while (urcCur != NULL) { |
| 7845 | RLOGD("Pended URC:%d, RILD:%s, :%s", |
| 7846 | pendedUrcCount, |
| 7847 | rilSocketIdToString(socket_id), |
| 7848 | requestToString(urcCur->id)); |
| 7849 | urcPrev = urcCur; |
| 7850 | urcCur = urcCur->pNext; |
| 7851 | pendedUrcCount++; |
| 7852 | } |
| 7853 | urcCur = (AtResponseList*)calloc(1, sizeof(AtResponseList)); |
| 7854 | if (urcPrev != NULL) |
| 7855 | urcPrev->pNext = urcCur; |
| 7856 | urcCur->pNext = NULL; |
| 7857 | urcCur->id = unsolResponse; |
| 7858 | if (data != NULL) { |
| 7859 | urcCur->data = new Parcel(); |
| 7860 | Parcel *parcelUrc = (Parcel *) data; |
| 7861 | urcCur->datalen = parcelUrc->dataSize(); |
| 7862 | urcCur->data->appendFrom(parcelUrc,0,parcelUrc->dataSize()); |
| 7863 | }else { |
| 7864 | urcCur->data = NULL; |
| 7865 | urcCur->datalen = 0; |
| 7866 | } |
| 7867 | if (pendedUrcCount == 0) { |
| 7868 | switch(socket_id) { |
| 7869 | case RIL_SOCKET_1: |
| 7870 | pendedUrcList1 = urcCur; |
| 7871 | break; |
| 7872 | case RIL_SOCKET_2: |
| 7873 | pendedUrcList2 = urcCur; |
| 7874 | break; |
| 7875 | case RIL_SOCKET_3: |
| 7876 | pendedUrcList3 = urcCur; |
| 7877 | break; |
| 7878 | case RIL_SOCKET_4: |
| 7879 | pendedUrcList4 = urcCur; |
| 7880 | break; |
| 7881 | case RIL_SOCKET_RILJ: |
| 7882 | pendedUrcList_rilj = urcCur; |
| 7883 | break; |
| 7884 | case RIL_SOCKET_RILJ2: |
| 7885 | pendedUrcList_rilj2 = urcCur; |
| 7886 | break; |
| 7887 | default: |
| 7888 | RLOGE("Socket id is wrong!!"); |
| 7889 | return; |
| 7890 | } |
| 7891 | } |
| 7892 | |
| 7893 | RLOGD("Current pendedUrcCount = %d", pendedUrcCount + 1); |
| 7894 | |
| 7895 | int activeFd = haveActiveFd(socket_id); |
| 7896 | if (activeFd != -1) { |
| 7897 | RLOGD("s_fdCommand [%d] = %d, sendUrc again", socket_id, activeFd); |
| 7898 | sendPendedUrcs(socket_id, activeFd); |
| 7899 | } |
| 7900 | } |
| 7901 | |
| 7902 | int haveActiveFd(int socket_id) { |
| 7903 | if (s_fdCommand[socket_id] != -1) { |
| 7904 | return s_fdCommand[socket_id]; |
| 7905 | } |
| 7906 | int clientNum = getClientNum(); |
| 7907 | for (int i = 0; i < clientNum; i++) { |
| 7908 | if (s_fdCommand_client[i] != -1) { |
| 7909 | return s_fdCommand_client[i]; |
| 7910 | } |
| 7911 | } |
| 7912 | return -1; |
| 7913 | } |
| 7914 | |
| 7915 | void sendUrc(RIL_SOCKET_ID socket_id, AtResponseList* urcCached) { |
| 7916 | AtResponseList* urc = urcCached; |
| 7917 | AtResponseList* urc_temp; |
| 7918 | while (urc != NULL) { |
| 7919 | RLOGD("sendPendedUrcs RIL%s, %s", |
| 7920 | rilSocketIdToString(socket_id), |
| 7921 | requestToString(urc->id)); |
| 7922 | #if defined(ANDROID_MULTI_SIM) |
| 7923 | RIL_onUnsolicitedResponse(urc->id, urc->data, urc->datalen, socket_id); |
| 7924 | #else |
| 7925 | RIL_onUnsolicitedResponse(urc->id, urc->data, urc->datalen); |
| 7926 | #endif |
| 7927 | if(urc->data != NULL) |
| 7928 | delete urc->data; |
| 7929 | urc_temp = urc; |
| 7930 | urc = urc->pNext; |
| 7931 | free(urc_temp); |
| 7932 | } |
| 7933 | } |
| 7934 | |
| 7935 | void sendPendedUrcs(RIL_SOCKET_ID socket_id, int fdCommand) { |
| 7936 | RLOGD("Ready to send pended URCs, socket:%s, fdCommand:%d", |
| 7937 | rilSocketIdToString(socket_id), fdCommand); |
| 7938 | |
| 7939 | if ((RIL_SOCKET_1 == socket_id) && (fdCommand != -1)) { |
| 7940 | sendUrc(socket_id, pendedUrcList1); |
| 7941 | pendedUrcList1 = NULL; |
| 7942 | } |
| 7943 | else if ((RIL_SOCKET_2 == socket_id) && (fdCommand != -1)) { |
| 7944 | sendUrc(socket_id, pendedUrcList2); |
| 7945 | pendedUrcList2 = NULL; |
| 7946 | } |
| 7947 | else if ((RIL_SOCKET_3 == socket_id) && (fdCommand != -1)) { |
| 7948 | sendUrc(socket_id, pendedUrcList3); |
| 7949 | pendedUrcList3 = NULL; |
| 7950 | } |
| 7951 | else if ((RIL_SOCKET_4 == socket_id) && (fdCommand != -1)) { |
| 7952 | sendUrc(socket_id, pendedUrcList4); |
| 7953 | pendedUrcList4 = NULL; |
| 7954 | } |
| 7955 | else if ((RIL_SOCKET_RILJ == socket_id || RIL_SOCKET_RILJ2 == socket_id) |
| 7956 | && fdCommand != -1) { |
| 7957 | AtResponseList** pendedUrcAddress = |
| 7958 | RIL_SOCKET_RILJ == socket_id ? &pendedUrcList_rilj : &pendedUrcList_rilj2; |
| 7959 | sendUrc(socket_id, *pendedUrcAddress); |
| 7960 | *pendedUrcAddress = NULL; |
| 7961 | } |
| 7962 | } |
| 7963 | // |
| 7964 | |
| 7965 | /* |
| 7966 | * Returns true for a debuggable build. |
| 7967 | */ |
| 7968 | static bool isDebuggable() { |
| 7969 | char debuggable[PROP_VALUE_MAX]; |
| 7970 | mtk_property_get("ro.debuggable", debuggable, "0"); |
| 7971 | if (strcmp(debuggable, "1") == 0) { |
| 7972 | return true; |
| 7973 | } |
| 7974 | return false; |
| 7975 | |
| 7976 | } |
| 7977 | #ifdef HAVE_AEE_FEATURE |
| 7978 | void triggerWarning(char *pErrMsg) { |
| 7979 | if (pErrMsg != NULL) { |
| 7980 | aee_system_warning("ril-proxy", NULL, DB_OPT_DEFAULT, pErrMsg); |
| 7981 | exit(0); |
| 7982 | } else { |
| 7983 | assert(0); |
| 7984 | } |
| 7985 | } |
| 7986 | #endif |
| 7987 | |
| 7988 | /* M: eMBMS feature */ |
| 7989 | static void dispatchEmbmsStartSessionInfo(Parcel &p, RequestInfo *pRI) { |
| 7990 | RIL_EMBMS_StartSessionReq args; |
| 7991 | int32_t t = 0; |
| 7992 | status_t status; |
| 7993 | |
| 7994 | memset (&args, 0, sizeof(args)); |
| 7995 | |
| 7996 | status = p.readInt32(&args.trans_id); |
| 7997 | RLOGD("dispatchEmbmsStartSessionInfo, trans_id = %d", args.trans_id); |
| 7998 | |
| 7999 | status = p.readInt32(&t); |
| 8000 | args.tmgi_info.tmgi_len = (uint32_t)t; |
| 8001 | RLOGD("dispatchEmbmsStartSessionInfo, tmgi_len = %d", args.tmgi_info.tmgi_len); |
| 8002 | |
| 8003 | startRequest; |
| 8004 | appendPrintBuf("%strans_id=%d,tmgi_len=%s", |
| 8005 | printBuf, args.trans_id, args.tmgi_info.tmgi_len); |
| 8006 | |
| 8007 | if (args.tmgi_info.tmgi_len > EMBMS_MAX_BYTES_TMGI) { |
| 8008 | RLOGE("dispatchStartSession Invalid TMGI length %d", args.tmgi_info.tmgi_len); |
| 8009 | goto invalid; |
| 8010 | } |
| 8011 | for (unsigned int i=0; i < args.tmgi_info.tmgi_len; i++) { |
| 8012 | uint8_t ut = 0; |
| 8013 | status = p.read(&ut, sizeof(ut)); |
| 8014 | args.tmgi_info.tmgi[i] = (uint8_t)ut; |
| 8015 | } |
| 8016 | RLOGD("dispatchStartSession, tmgi[%02X,%02X,%02X,%02X,%02X,%02X]", |
| 8017 | args.tmgi_info.tmgi[0], |
| 8018 | args.tmgi_info.tmgi[1], |
| 8019 | args.tmgi_info.tmgi[2], |
| 8020 | args.tmgi_info.tmgi[3], |
| 8021 | args.tmgi_info.tmgi[4], |
| 8022 | args.tmgi_info.tmgi[5]); |
| 8023 | |
| 8024 | |
| 8025 | status = p.readInt32(&t); |
| 8026 | args.earfcnlist_count = (uint32_t)t; |
| 8027 | RLOGD("dispatchEmbmsStartSessionInfo, earfcnlist_count = %d", args.earfcnlist_count); |
| 8028 | appendPrintBuf("%earfcnlist_count=%d", printBuf, args.earfcnlist_count); |
| 8029 | |
| 8030 | for (unsigned int i = 0 ; i < args.earfcnlist_count ; i++) { |
| 8031 | status = p.readInt32(&t); |
| 8032 | if (i < EMBMS_MAX_NUM_FREQ) { |
| 8033 | args.earfcnlist[i] = t; |
| 8034 | RLOGD("searfcnlist[%d]= %d", i, args.earfcnlist[i]); |
| 8035 | appendPrintBuf("%searfcnlist=%d", printBuf, args.earfcnlist[i]); |
| 8036 | } else { |
| 8037 | RLOGD("searfcnlist[%d] out of index", i); |
| 8038 | } |
| 8039 | } |
| 8040 | |
| 8041 | status = p.readInt32(&t); |
| 8042 | args.saiList_valid = (uint8_t)t; |
| 8043 | RLOGD("dispatchEmbmsStartSessionInfo, saiList_valid = %d", args.saiList_valid); |
| 8044 | appendPrintBuf("%saiList_valid=%d", printBuf, args.saiList_valid); |
| 8045 | |
| 8046 | if (args.saiList_valid) { |
| 8047 | status = p.readInt32(&t); |
| 8048 | args.saiList_count = (uint32_t)t; |
| 8049 | RLOGD("dispatchEmbmsStartSessionInfo, saiList_count = %d", args.saiList_count); |
| 8050 | appendPrintBuf("%saiList_count=%d", printBuf, args.saiList_count); |
| 8051 | |
| 8052 | for (unsigned int i = 0 ; i < args.saiList_count ; i++) { |
| 8053 | status = p.readInt32(&args.saiList[i]); |
| 8054 | RLOGV("saiList[%d]= %d", i, args.saiList[i]); |
| 8055 | appendPrintBuf("%ssaiList=%d", printBuf, args.saiList[i]); |
| 8056 | } |
| 8057 | } else { |
| 8058 | args.saiList_count = 0; |
| 8059 | RLOGD("dispatchEmbmsStartSessionInfo, saiList_count = 0 due to not valid"); |
| 8060 | appendPrintBuf("%saiList_count=%d", printBuf, args.saiList_count); |
| 8061 | } |
| 8062 | |
| 8063 | closeRequest; |
| 8064 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 8065 | |
| 8066 | if (status != NO_ERROR) { |
| 8067 | goto invalid; |
| 8068 | } |
| 8069 | |
| 8070 | CALL_ONREQUEST(pRI->pCI->requestNumber, &args, sizeof(args), pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 8071 | |
| 8072 | return; |
| 8073 | |
| 8074 | invalid: |
| 8075 | invalidCommandBlock(pRI); |
| 8076 | return; |
| 8077 | } |
| 8078 | |
| 8079 | static void dispatchEmbmsStopSessionInfo(Parcel &p, RequestInfo *pRI) { |
| 8080 | RIL_EMBMS_StopSessionReq args; |
| 8081 | int32_t t = 0; |
| 8082 | status_t status; |
| 8083 | |
| 8084 | memset (&args, 0, sizeof(args)); |
| 8085 | |
| 8086 | startRequest; |
| 8087 | status = p.readInt32(&t); |
| 8088 | args.trans_id = (int)t; |
| 8089 | RLOGD("dispatchStopSession, status:%d, trans_id%d", status, args.trans_id); |
| 8090 | |
| 8091 | // readByteArray |
| 8092 | status = p.readInt32(&t); |
| 8093 | args.tmgi_info.tmgi_len = (uint32_t)t; |
| 8094 | RLOGD("dispatchStopSession, tmgi_len status = %d ,tmgi_len = %d ", status , args.tmgi_info.tmgi_len); |
| 8095 | |
| 8096 | if (args.tmgi_info.tmgi_len > EMBMS_MAX_BYTES_TMGI) { |
| 8097 | RLOGE("dispatchStopSession Invalid TMGI length %d", args.tmgi_info.tmgi_len); |
| 8098 | goto invalid; |
| 8099 | } |
| 8100 | for (unsigned int i=0; i < args.tmgi_info.tmgi_len; i++) { |
| 8101 | uint8_t ut = 0; |
| 8102 | status = p.read(&ut, sizeof(ut)); |
| 8103 | args.tmgi_info.tmgi[i] = (uint8_t)ut; |
| 8104 | } |
| 8105 | RLOGD("dispatchStopSession, tmgi[%02X,%02X,%02X,%02X,%02X,%02X]", |
| 8106 | args.tmgi_info.tmgi[0], |
| 8107 | args.tmgi_info.tmgi[1], |
| 8108 | args.tmgi_info.tmgi[2], |
| 8109 | args.tmgi_info.tmgi[3], |
| 8110 | args.tmgi_info.tmgi[4], |
| 8111 | args.tmgi_info.tmgi[5]); |
| 8112 | |
| 8113 | |
| 8114 | appendPrintBuf("%strans_id=%d,tmgi_len=%d", |
| 8115 | printBuf, args.trans_id, args.tmgi_info.tmgi_len); |
| 8116 | closeRequest; |
| 8117 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 8118 | |
| 8119 | if (status != NO_ERROR) { |
| 8120 | goto invalid; |
| 8121 | } |
| 8122 | |
| 8123 | CALL_ONREQUEST(pRI->pCI->requestNumber, &args, sizeof(args), pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 8124 | |
| 8125 | return; |
| 8126 | |
| 8127 | invalid: |
| 8128 | invalidCommandBlock(pRI); |
| 8129 | return; |
| 8130 | } |
| 8131 | |
| 8132 | static int responseEmbmsNetworkTime(Parcel &p, void *response, size_t responselen) { |
| 8133 | if (response == NULL) { |
| 8134 | RLOGE("invalid response: NULL"); |
| 8135 | return RIL_ERRNO_INVALID_RESPONSE; |
| 8136 | } |
| 8137 | |
| 8138 | if (responselen % sizeof(RIL_EMBMS_GetTimeResp) != 0) { |
| 8139 | RLOGE("responseEmbmsNetworkTime: invalid response length %d expected multiple of %d", |
| 8140 | (int)responselen, (int)sizeof(RIL_EMBMS_GetTimeResp)); |
| 8141 | assert(false); |
| 8142 | return RIL_ERRNO_INVALID_RESPONSE; |
| 8143 | } |
| 8144 | |
| 8145 | RIL_EMBMS_GetTimeResp *p_cur = (RIL_EMBMS_GetTimeResp *)response; |
| 8146 | p.writeInt32(p_cur->trans_id); |
| 8147 | p.writeInt32(p_cur->response); |
| 8148 | p.writeInt64(p_cur->milli_sec); |
| 8149 | p.writeInt32(p_cur->day_light_saving_valid); |
| 8150 | p.writeInt32(p_cur->day_light_saving); |
| 8151 | p.writeInt32(p_cur->leap_seconds_valid); |
| 8152 | p.writeInt32(p_cur->leap_seconds); |
| 8153 | p.writeInt32(p_cur->local_time_offset_valid); |
| 8154 | p.writeInt32(p_cur->local_time_offset); |
| 8155 | |
| 8156 | startResponse; |
| 8157 | appendPrintBuf("%s%d,%d,%lu,%d,%d,%d,%d,%d,%d", printBuf, p_cur->trans_id, p_cur->response |
| 8158 | , p_cur->milli_sec, p_cur->day_light_saving_valid, p_cur->day_light_saving |
| 8159 | , p_cur->leap_seconds_valid, p_cur->leap_seconds, p_cur->local_time_offset_valid |
| 8160 | , p_cur->local_time_offset); |
| 8161 | closeResponse; |
| 8162 | |
| 8163 | return 0; |
| 8164 | } |
| 8165 | |
| 8166 | static int responseEmbmsOosNotify(Parcel &p, void *response, size_t responselen) { |
| 8167 | if (response == NULL) { |
| 8168 | RLOGE("invalid response: NULL"); |
| 8169 | return RIL_ERRNO_INVALID_RESPONSE; |
| 8170 | } |
| 8171 | |
| 8172 | if (responselen % sizeof(RIL_EMBMS_OosNotify) != 0) { |
| 8173 | RLOGE("responseEmbmsOosNotify: invalid response length %d expected multiple of %d", |
| 8174 | (int)responselen, (int)sizeof(RIL_EMBMS_OosNotify)); |
| 8175 | assert(false); |
| 8176 | return RIL_ERRNO_INVALID_RESPONSE; |
| 8177 | } |
| 8178 | |
| 8179 | startResponse; |
| 8180 | RIL_EMBMS_OosNotify *p_cur = (RIL_EMBMS_OosNotify *)response; |
| 8181 | p.writeInt32(p_cur->trans_id); |
| 8182 | p.writeInt32(p_cur->reason); |
| 8183 | p.writeInt32(p_cur->tmgi_info_count); |
| 8184 | RLOGD("tmgi_info_count, %d", p_cur->tmgi_info_count); |
| 8185 | appendPrintBuf("%s%d,%d,%d", printBuf, p_cur->trans_id, |
| 8186 | p_cur->reason, p_cur->tmgi_info_count); |
| 8187 | |
| 8188 | for (uint32_t i = 0; i < p_cur->tmgi_info_count; i++) { |
| 8189 | // writeByteArray will introduce endian issue |
| 8190 | p.writeInt32(p_cur->tmgi_info[i].tmgi_len); |
| 8191 | uint8_t uct; |
| 8192 | for (uint32_t j=0; j < p_cur->tmgi_info[i].tmgi_len; j++) { |
| 8193 | p.write(&(p_cur->tmgi_info[i].tmgi[j]), sizeof(uct)); |
| 8194 | } |
| 8195 | appendPrintBuf("%s%d", printBuf, p_cur->tmgi_info[i].tmgi_len); |
| 8196 | } |
| 8197 | closeResponse; |
| 8198 | |
| 8199 | return 0; |
| 8200 | } |
| 8201 | |
| 8202 | static int responseEmbmsCellInfoNotify(Parcel &p, void *response, size_t responselen) { |
| 8203 | if (response == NULL) { |
| 8204 | RLOGE("invalid response: NULL"); |
| 8205 | return RIL_ERRNO_INVALID_RESPONSE; |
| 8206 | } |
| 8207 | |
| 8208 | if (responselen % sizeof(RIL_EMBMS_CellInfoNotify) != 0) { |
| 8209 | RLOGE("responseEmbmsCellInfoNotify: invalid response length %d expected multiple of %d", |
| 8210 | (int)responselen, (int)sizeof(RIL_EMBMS_CellInfoNotify)); |
| 8211 | assert(false); |
| 8212 | return RIL_ERRNO_INVALID_RESPONSE; |
| 8213 | } |
| 8214 | |
| 8215 | RIL_EMBMS_CellInfoNotify *p_cur = (RIL_EMBMS_CellInfoNotify *) response; |
| 8216 | p.writeInt32(p_cur->trans_id); |
| 8217 | p.writeInt32(p_cur->cell_id); |
| 8218 | startResponse; |
| 8219 | appendPrintBuf("%s%d,%d", printBuf, p_cur->trans_id, p_cur->cell_id); |
| 8220 | closeResponse; |
| 8221 | return 0; |
| 8222 | } |
| 8223 | |
| 8224 | static int responseEmbmsModemEeNotify(Parcel &p, void *response, size_t responselen) { |
| 8225 | if (response == NULL) { |
| 8226 | RLOGE("invalid response: NULL"); |
| 8227 | return RIL_ERRNO_INVALID_RESPONSE; |
| 8228 | } |
| 8229 | |
| 8230 | if (responselen % sizeof(RIL_EMBMS_ModemEeNotify) != 0) { |
| 8231 | RLOGE("responseEmbmsModemEeNotify: invalid response length %d expected multiple of %d", |
| 8232 | (int)responselen, (int)sizeof(RIL_EMBMS_ModemEeNotify)); |
| 8233 | assert(false); |
| 8234 | return RIL_ERRNO_INVALID_RESPONSE; |
| 8235 | } |
| 8236 | |
| 8237 | RIL_EMBMS_ModemEeNotify *p_cur = (RIL_EMBMS_ModemEeNotify *) response; |
| 8238 | p.writeInt32(p_cur->trans_id); |
| 8239 | p.writeInt32(p_cur->state); |
| 8240 | startResponse; |
| 8241 | appendPrintBuf("%s%d,%d", printBuf, p_cur->trans_id, p_cur->state); |
| 8242 | closeResponse; |
| 8243 | return 0; |
| 8244 | } |
| 8245 | |
| 8246 | static int responseEmbmsSaiNotify(Parcel &p, void *response, size_t responselen) { |
| 8247 | if (response == NULL) { |
| 8248 | RLOGE("invalid response: NULL"); |
| 8249 | return RIL_ERRNO_INVALID_RESPONSE; |
| 8250 | } |
| 8251 | |
| 8252 | if (responselen % sizeof(RIL_EMBMS_SaiNotify) != 0) { |
| 8253 | RLOGE("responseEmbmsSaiNotify: invalid response length %d expected multiple of %d", |
| 8254 | (int)responselen, (int)sizeof(RIL_EMBMS_SaiNotify)); |
| 8255 | assert(false); |
| 8256 | return RIL_ERRNO_INVALID_RESPONSE; |
| 8257 | } |
| 8258 | |
| 8259 | RIL_EMBMS_SaiNotify *p_cur = (RIL_EMBMS_SaiNotify *) response; |
| 8260 | startResponse; |
| 8261 | // trans_id |
| 8262 | p.writeInt32(p_cur->trans_id); |
| 8263 | |
| 8264 | // cf_total |
| 8265 | p.writeInt32(p_cur->cf_total); |
| 8266 | |
| 8267 | // curFreqData |
| 8268 | for (uint32_t i = 0; i < p_cur->cf_total; i++) { |
| 8269 | p.writeInt32(p_cur->curFreqData[i]); |
| 8270 | } |
| 8271 | |
| 8272 | // csai_count_per_group |
| 8273 | for (uint32_t i = 0; i < p_cur->cf_total; i++) { |
| 8274 | p.writeInt32(p_cur->csai_count_per_group[i]); |
| 8275 | } |
| 8276 | |
| 8277 | // csai_total |
| 8278 | p.writeInt32(p_cur->csai_total); |
| 8279 | |
| 8280 | // curSaiData |
| 8281 | for (uint32_t i = 0; i < p_cur->csai_total; i++) { |
| 8282 | p.writeInt32(p_cur->curSaiData[i]); |
| 8283 | } |
| 8284 | |
| 8285 | // nf_total |
| 8286 | p.writeInt32(p_cur->nf_total); |
| 8287 | |
| 8288 | // neiFreqData |
| 8289 | for (uint32_t i = 0; i < p_cur->nf_total; i++) { |
| 8290 | p.writeInt32(p_cur->neiFreqData[i]); |
| 8291 | } |
| 8292 | |
| 8293 | // nsai_count_per_group |
| 8294 | for (uint32_t i = 0; i < p_cur->nf_total; i++) { |
| 8295 | p.writeInt32(p_cur->nsai_count_per_group[i]); |
| 8296 | } |
| 8297 | |
| 8298 | // nsai_total |
| 8299 | p.writeInt32(p_cur->nsai_total); |
| 8300 | |
| 8301 | // neiSaiData |
| 8302 | for (uint32_t i = 0; i < p_cur->nsai_total; i++) { |
| 8303 | p.writeInt32(p_cur->neiSaiData[i]); |
| 8304 | } |
| 8305 | |
| 8306 | appendPrintBuf("%s%d,%d,%d,%d,%d", printBuf, p_cur->trans_id, p_cur->cf_total |
| 8307 | , p_cur->csai_total, p_cur->nf_total, p_cur->nsai_total); |
| 8308 | RLOGD("responseEmbmsSaiNotify cf_total[%d], csai_total[%d], nf_total[%d], nf_total[%d]" |
| 8309 | , p_cur->cf_total, p_cur->csai_total, p_cur->nf_total, p_cur->nf_total); |
| 8310 | |
| 8311 | closeResponse; |
| 8312 | return 0; |
| 8313 | } |
| 8314 | |
| 8315 | static int responseEmbmsActiveSessionNotify(Parcel &p, void *response, size_t responselen) { |
| 8316 | if (response == NULL) { |
| 8317 | RLOGE("invalid response: NULL"); |
| 8318 | return RIL_ERRNO_INVALID_RESPONSE; |
| 8319 | } |
| 8320 | |
| 8321 | if (responselen % sizeof(RIL_EMBMS_ActiveSessionNotify) != 0) { |
| 8322 | RLOGE("responseEmbmsActiveSessionNotify: invalid response length %d expected multiple of %d", |
| 8323 | (int)responselen, (int)sizeof(RIL_EMBMS_ActiveSessionNotify)); |
| 8324 | assert(false); |
| 8325 | return RIL_ERRNO_INVALID_RESPONSE; |
| 8326 | } |
| 8327 | |
| 8328 | startResponse; |
| 8329 | RIL_EMBMS_ActiveSessionNotify *p_cur = (RIL_EMBMS_ActiveSessionNotify *)response; |
| 8330 | p.writeInt32(p_cur->trans_id); |
| 8331 | p.writeInt32(p_cur->tmgi_info_count); |
| 8332 | appendPrintBuf("%s%d,%d", printBuf, p_cur->trans_id, p_cur->tmgi_info_count); |
| 8333 | for (uint32_t i = 0; i < p_cur->tmgi_info_count; i++) { |
| 8334 | // writeByteArray will introduce endian issue |
| 8335 | p.writeInt32(p_cur->tmgi_info[i].tmgi_len); |
| 8336 | uint8_t uct; |
| 8337 | for (uint32_t j=0; j < p_cur->tmgi_info[i].tmgi_len; j++) { |
| 8338 | p.write(&(p_cur->tmgi_info[i].tmgi[j]), sizeof(uct)); |
| 8339 | } |
| 8340 | RLOGD("responseAvailableActiveSession, TMGI[%02X,%02X,%02X,%02X,%02X,%02X]", |
| 8341 | p_cur->tmgi_info[i].tmgi[0], |
| 8342 | p_cur->tmgi_info[i].tmgi[1], |
| 8343 | p_cur->tmgi_info[i].tmgi[2], |
| 8344 | p_cur->tmgi_info[i].tmgi[3], |
| 8345 | p_cur->tmgi_info[i].tmgi[4], |
| 8346 | p_cur->tmgi_info[i].tmgi[5]); |
| 8347 | } |
| 8348 | closeResponse; |
| 8349 | return 0; |
| 8350 | } |
| 8351 | |
| 8352 | static int responseEmbmsSessionInfo(Parcel &p, void *response, size_t responselen) { |
| 8353 | if (response == NULL) { |
| 8354 | RLOGE("invalid response: NULL"); |
| 8355 | return RIL_ERRNO_INVALID_RESPONSE; |
| 8356 | } |
| 8357 | |
| 8358 | if (responselen % sizeof(RIL_EMBMS_StartSessionResp) != 0) { |
| 8359 | RLOGE("responseEmbmsSessionInfo: invalid response length %d expected multiple of %d", |
| 8360 | (int)responselen, (int)sizeof(RIL_EMBMS_StartSessionResp)); |
| 8361 | assert(false); |
| 8362 | return RIL_ERRNO_INVALID_RESPONSE; |
| 8363 | } |
| 8364 | |
| 8365 | startResponse; |
| 8366 | RIL_EMBMS_StartSessionResp *p_cur = (RIL_EMBMS_StartSessionResp *)response; |
| 8367 | p.writeInt32(p_cur->trans_id); |
| 8368 | p.writeInt32(p_cur->response); |
| 8369 | p.writeInt32(p_cur->tmgi_info_valid); |
| 8370 | RLOGD("responseStartStopSession trans_id=%d, response=%d, tmgi_info_valid=%d, tmgi_len=%d", |
| 8371 | p_cur->trans_id, p_cur->response, p_cur->tmgi_info_valid, p_cur->tmgi_info.tmgi_len); |
| 8372 | appendPrintBuf("%s%d,%d,%d,%d", printBuf, p_cur->trans_id, |
| 8373 | p_cur->response, p_cur->tmgi_info_valid, p_cur->tmgi_info.tmgi_len); |
| 8374 | |
| 8375 | // writeByteArray will introduce endian issue |
| 8376 | p.writeInt32(p_cur->tmgi_info.tmgi_len); |
| 8377 | uint8_t uct; |
| 8378 | for (uint32_t j=0; j < p_cur->tmgi_info.tmgi_len; j++) { |
| 8379 | p.write(&(p_cur->tmgi_info.tmgi[j]), sizeof(uct)); |
| 8380 | } |
| 8381 | |
| 8382 | for (uint32_t i=0; i < p_cur->tmgi_info.tmgi_len; i++) { |
| 8383 | appendPrintBuf("%s%d", printBuf, p_cur->tmgi_info.tmgi[i]); |
| 8384 | RLOGD("responseStartStopSession tmgi[%d] = %02X", i, p_cur->tmgi_info.tmgi[i]); |
| 8385 | } |
| 8386 | |
| 8387 | closeResponse; |
| 8388 | return 0; |
| 8389 | } |
| 8390 | |
| 8391 | static int responseEmbmsEnable(Parcel &p, void *response, size_t responselen) { |
| 8392 | if (response == NULL) { |
| 8393 | RLOGE("invalid response: NULL"); |
| 8394 | return RIL_ERRNO_INVALID_RESPONSE; |
| 8395 | } |
| 8396 | |
| 8397 | if (responselen % sizeof(RIL_EMBMS_EnableResp) != 0) { |
| 8398 | RLOGE("responseEmbmsEnable: invalid response length %d expected multiple of %d", |
| 8399 | (int)responselen, (int)sizeof(RIL_EMBMS_EnableResp)); |
| 8400 | assert(false); |
| 8401 | return RIL_ERRNO_INVALID_RESPONSE; |
| 8402 | } |
| 8403 | |
| 8404 | RIL_EMBMS_EnableResp *p_cur = (RIL_EMBMS_EnableResp *) response; |
| 8405 | p.writeInt32(p_cur->trans_id); |
| 8406 | p.writeInt32(p_cur->response); |
| 8407 | p.writeInt32(p_cur->interface_index_valid); |
| 8408 | p.writeInt32(p_cur->interface_index); |
| 8409 | startResponse; |
| 8410 | appendPrintBuf("%s%d,%d,%d,%d", printBuf, p_cur->trans_id, p_cur->response, |
| 8411 | p_cur->interface_index_valid, p_cur->interface_index); |
| 8412 | closeResponse; |
| 8413 | return 0; |
| 8414 | } |
| 8415 | |
| 8416 | static int responseEmbmsDisable(Parcel &p, void *response, size_t responselen) { |
| 8417 | if (response == NULL) { |
| 8418 | RLOGE("invalid response: NULL"); |
| 8419 | return RIL_ERRNO_INVALID_RESPONSE; |
| 8420 | } |
| 8421 | |
| 8422 | if (responselen % sizeof(RIL_EMBMS_DisableResp) != 0) { |
| 8423 | RLOGE("responseEmbmsDisable: invalid response length %d expected multiple of %d", |
| 8424 | (int)responselen, (int)sizeof(RIL_EMBMS_DisableResp)); |
| 8425 | assert(false); |
| 8426 | return RIL_ERRNO_INVALID_RESPONSE; |
| 8427 | } |
| 8428 | |
| 8429 | RIL_EMBMS_DisableResp *p_cur = (RIL_EMBMS_DisableResp *) response; |
| 8430 | p.writeInt32(p_cur->trans_id); |
| 8431 | p.writeInt32(p_cur->response); |
| 8432 | startResponse; |
| 8433 | appendPrintBuf("%s%d,%d", printBuf, p_cur->trans_id, p_cur->response); |
| 8434 | closeResponse; |
| 8435 | return 0; |
| 8436 | } |
| 8437 | |
| 8438 | static int responseEmbmsGetCoverageState(Parcel &p, void *response, size_t responselen) { |
| 8439 | if (response == NULL) { |
| 8440 | RLOGE("invalid response: NULL"); |
| 8441 | return RIL_ERRNO_INVALID_RESPONSE; |
| 8442 | } |
| 8443 | |
| 8444 | if (responselen % sizeof(RIL_EMBMS_GetCoverageResp) != 0) { |
| 8445 | RLOGE("responseEmbmsGetCoverageState: invalid response length %d expected multiple of %d", |
| 8446 | (int)responselen, (int)sizeof(RIL_EMBMS_GetCoverageResp)); |
| 8447 | assert(false); |
| 8448 | return RIL_ERRNO_INVALID_RESPONSE; |
| 8449 | } |
| 8450 | |
| 8451 | RIL_EMBMS_GetCoverageResp *p_cur = (RIL_EMBMS_GetCoverageResp *) response; |
| 8452 | p.writeInt32(p_cur->trans_id); |
| 8453 | p.writeInt32(p_cur->response); |
| 8454 | p.writeInt32(p_cur->coverage_state_valid); |
| 8455 | p.writeInt32(p_cur->coverage_state); |
| 8456 | startResponse; |
| 8457 | appendPrintBuf("%s%d,%d,%d,%d", printBuf, p_cur->trans_id, p_cur->response, |
| 8458 | p_cur->coverage_state_valid, p_cur->coverage_state); |
| 8459 | closeResponse; |
| 8460 | return 0; |
| 8461 | } |
| 8462 | |
| 8463 | // MTK-START: SIM OPEN CHANNEL WITH P2 |
| 8464 | static void dispatchOpenChannelParams(android::Parcel &p, android::RequestInfo *pRI) { |
| 8465 | RIL_OpenChannelParams openChannelParams; |
| 8466 | int32_t t = 0; |
| 8467 | android::status_t status; |
| 8468 | |
| 8469 | RLOGD("dispatchOpenChannelParams Enter."); |
| 8470 | |
| 8471 | memset(&openChannelParams, 0, sizeof(openChannelParams)); |
| 8472 | |
| 8473 | openChannelParams.aidPtr = strdupReadString(p); |
| 8474 | |
| 8475 | status = p.readInt32(&t); |
| 8476 | openChannelParams.p2 = t; |
| 8477 | if (status != android::NO_ERROR) { |
| 8478 | goto invalid; |
| 8479 | } |
| 8480 | |
| 8481 | RLOGD("dispatchOpenChannelParams aid: %s, p2: %d", |
| 8482 | openChannelParams.aidPtr, openChannelParams.p2); |
| 8483 | |
| 8484 | startRequest; |
| 8485 | appendPrintBuf("%said=%s,p2=%d", printBuf, |
| 8486 | openChannelParams.aidPtr, openChannelParams.p2); |
| 8487 | closeRequest; |
| 8488 | |
| 8489 | CALL_ONREQUEST(pRI->pCI->requestNumber, &openChannelParams, |
| 8490 | sizeof(openChannelParams), pRI, pRI->socket_id); |
| 8491 | |
| 8492 | #ifdef MEMSET_FREED |
| 8493 | android::memsetString(openChannelParams.aidPtr); |
| 8494 | #endif |
| 8495 | if (openChannelParams.aidPtr != NULL) { |
| 8496 | free(openChannelParams.aidPtr); |
| 8497 | } |
| 8498 | #ifdef MEMSET_FREED |
| 8499 | memset(&openChannelParams, 0, sizeof(openChannelParams)); |
| 8500 | #endif |
| 8501 | |
| 8502 | return; |
| 8503 | invalid: |
| 8504 | invalidCommandBlock(pRI); |
| 8505 | return; |
| 8506 | } |
| 8507 | |
| 8508 | // ecall start |
| 8509 | static void dispatchEcallSetMsd(Parcel &p, RequestInfo *pRI) { |
| 8510 | RIL_ECallSetMSD msd; |
| 8511 | |
| 8512 | int32_t id = 0; |
| 8513 | int length = 0; |
| 8514 | unsigned int value = 0; |
| 8515 | int size; |
| 8516 | status_t status; |
| 8517 | |
| 8518 | memset(&msd, 0, sizeof(msd)); |
| 8519 | |
| 8520 | status = p.readInt32(&id); |
| 8521 | msd.call_id= id; |
| 8522 | |
| 8523 | status = p.readInt32(&length); |
| 8524 | |
| 8525 | msd.length = (unsigned int)length; |
| 8526 | |
| 8527 | RLOGD("dispatchEcallSetMsd length=%d, call_id =%d", length, id); |
| 8528 | |
| 8529 | if((msd.msd_data = (unsigned char*)malloc(sizeof(unsigned char)*msd.length)) == NULL){ |
| 8530 | |
| 8531 | RLOGD("malloc msd_data fail\n"); |
| 8532 | return; |
| 8533 | } |
| 8534 | |
| 8535 | memset(msd.msd_data, 0, sizeof(unsigned char)*msd.length); |
| 8536 | |
| 8537 | for(int i = 0; i< msd.length; i++){ |
| 8538 | status = p.readUint32(&value); |
| 8539 | msd.msd_data[i] = (unsigned char) value; |
| 8540 | //debug |
| 8541 | RLOGD("msd_data[%d] = %d",i,msd.msd_data[i]); |
| 8542 | } |
| 8543 | |
| 8544 | startRequest; |
| 8545 | appendPrintBuf("%scall_id=%d,data_length=%d", printBuf, |
| 8546 | msd.call_id,msd.length); |
| 8547 | closeRequest; |
| 8548 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 8549 | |
| 8550 | if (status != NO_ERROR) { |
| xj | 112b967 | 2022-01-25 16:13:48 +0800 | [diff] [blame] | 8551 | free(msd.msd_data); |
| xj | b04a402 | 2021-11-25 15:01:52 +0800 | [diff] [blame] | 8552 | goto invalid; |
| 8553 | } |
| 8554 | |
| 8555 | size = sizeof(RIL_ECallSetMSD)+sizeof(unsigned char)*msd.length; |
| 8556 | CALL_ONREQUEST(pRI->pCI->requestNumber, &msd, size, pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 8557 | |
| 8558 | #ifdef MEMSET_FREED |
| 8559 | memset(msd.msd_data,0,sizeof(unsigned char)*msd.length); |
| 8560 | #endif |
| 8561 | |
| 8562 | free(msd.msd_data); |
| 8563 | |
| 8564 | #ifdef MEMSET_FREED |
| 8565 | memset(&msd, 0, sizeof(msd)); |
| 8566 | #endif |
| 8567 | |
| 8568 | return; |
| 8569 | invalid: |
| 8570 | invalidCommandBlock(pRI); |
| 8571 | return; |
| 8572 | } |
| 8573 | |
| 8574 | static void dispatchFastMakeEcall(Parcel &p, RequestInfo *pRI) { |
| 8575 | RIL_ECallReqMsg eCallReqMsg; |
| 8576 | |
| 8577 | int32_t t = 0; |
| 8578 | int size; |
| 8579 | status_t status; |
| 8580 | unsigned int len; |
| 8581 | unsigned int value; |
| 8582 | |
| 8583 | memset(&eCallReqMsg, 0, sizeof(eCallReqMsg)); |
| 8584 | |
| 8585 | status = p.readInt32(&t); |
| 8586 | eCallReqMsg.ecall_cat = (RIL_ECall_Category)t; |
| 8587 | |
| 8588 | status = p.readInt32(&t); |
| 8589 | eCallReqMsg.ecall_variant = (RIL_ECall_Variant)t; |
| 8590 | |
| xj | b04a402 | 2021-11-25 15:01:52 +0800 | [diff] [blame] | 8591 | eCallReqMsg.address = strdupReadString(p); |
| 8592 | |
| 8593 | //debug |
| 8594 | RLOGD("eCallReqMsg address = %s\n",eCallReqMsg.address); |
| 8595 | |
| 8596 | status = p.readInt32(&t); |
| 8597 | |
| 8598 | eCallReqMsg.length = (unsigned int)t; |
| 8599 | |
| 8600 | if((eCallReqMsg.msd_data = (unsigned char*)malloc(sizeof(unsigned char)*eCallReqMsg.length)) == NULL){ |
| 8601 | free(eCallReqMsg.address); |
| 8602 | return; |
| 8603 | } |
| 8604 | |
| 8605 | memset(eCallReqMsg.msd_data, 0, sizeof(unsigned char)*eCallReqMsg.length); |
| 8606 | |
| 8607 | for(int i = 0; i< eCallReqMsg.length; i++){ |
| 8608 | status = p.readUint32(&value); |
| 8609 | eCallReqMsg.msd_data[i] = (unsigned char) value; |
| 8610 | //debug |
| 8611 | RLOGD("msd_data[%d] = %d",i,eCallReqMsg.msd_data[i]); |
| 8612 | } |
| 8613 | |
| 8614 | startRequest; |
| rjw | 2e8229f | 2022-02-15 21:08:12 +0800 | [diff] [blame^] | 8615 | appendPrintBuf("%secall_cat=%d,ecall_variant=%d,address=%s,length=%d", printBuf, |
| 8616 | eCallReqMsg.ecall_cat, eCallReqMsg.ecall_variant, (char*)eCallReqMsg.address,\ |
| xj | b04a402 | 2021-11-25 15:01:52 +0800 | [diff] [blame] | 8617 | eCallReqMsg.length |
| 8618 | ); |
| 8619 | closeRequest; |
| 8620 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 8621 | |
| 8622 | if (status != NO_ERROR) { |
| xj | 112b967 | 2022-01-25 16:13:48 +0800 | [diff] [blame] | 8623 | free(eCallReqMsg.address); |
| 8624 | free(eCallReqMsg.msd_data); |
| xj | b04a402 | 2021-11-25 15:01:52 +0800 | [diff] [blame] | 8625 | goto invalid; |
| 8626 | } |
| 8627 | |
| 8628 | size = sizeof(eCallReqMsg); |
| 8629 | CALL_ONREQUEST(pRI->pCI->requestNumber, &eCallReqMsg, size, pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 8630 | |
| 8631 | #ifdef MEMSET_FREED |
| 8632 | memsetString(eCallReqMsg.address); |
| 8633 | memset(eCallReqMsg.msd_data,0,eCallReqMsg.length); |
| 8634 | #endif |
| 8635 | |
| 8636 | free(eCallReqMsg.address); |
| 8637 | free(eCallReqMsg.msd_data); |
| 8638 | |
| 8639 | #ifdef MEMSET_FREED |
| 8640 | memset(&eCallReqMsg, 0, sizeof(eCallReqMsg)); |
| 8641 | #endif |
| 8642 | |
| 8643 | return; |
| 8644 | invalid: |
| 8645 | invalidCommandBlock(pRI); |
| 8646 | return; |
| 8647 | } |
| 8648 | |
| 8649 | static void dispatchEcallSetNum(Parcel &p, RequestInfo *pRI) { |
| 8650 | RIL_ECallSetNum num; |
| 8651 | |
| 8652 | int32_t t = 0; |
| 8653 | status_t status; |
| 8654 | |
| 8655 | memset(&num, 0, sizeof(num)); |
| 8656 | |
| 8657 | status = p.readInt32(&t); |
| 8658 | num.arg_num = t; |
| 8659 | |
| 8660 | status = p.readInt32(&t); |
| 8661 | num.type = t; |
| 8662 | |
| 8663 | num.address = strdupReadString(p); |
| 8664 | |
| 8665 | if (status != NO_ERROR) { |
| 8666 | goto invalid; |
| 8667 | } |
| 8668 | |
| 8669 | RLOGD("dispatchEcallSetNum status: %d, address: %s", num.type, num.address); |
| 8670 | |
| 8671 | startRequest; |
| 8672 | appendPrintBuf("%stype=%d,num=%s", printBuf, num.type, (char*)num.address); |
| 8673 | closeRequest; |
| 8674 | |
| 8675 | CALL_ONREQUEST(pRI->pCI->requestNumber, &num, sizeof(num), pRI, mapingSlotIdToRilSocketId(pRI->slot_id)); |
| 8676 | |
| 8677 | #ifdef MEMSET_FREED |
| 8678 | memsetString(num.address); |
| 8679 | #endif |
| 8680 | if (num.address != NULL) { |
| 8681 | free(num.address); |
| 8682 | } |
| 8683 | |
| 8684 | #ifdef MEMSET_FREED |
| 8685 | memset(&num, 0, sizeof(num)); |
| 8686 | #endif |
| 8687 | |
| 8688 | return; |
| 8689 | invalid: |
| 8690 | invalidCommandBlock(pRI); |
| 8691 | return; |
| 8692 | } |
| 8693 | |
| 8694 | static int responseEcallInd(android::Parcel &p, void *response, size_t responselen) { |
| 8695 | if (response == NULL) { |
| 8696 | LOGE("invalid response: NULL"); |
| 8697 | return RIL_ERRNO_INVALID_RESPONSE; |
| 8698 | } |
| 8699 | |
| 8700 | if (responselen != sizeof(RIL_Ecall_Unsol_Indications)) { |
| 8701 | LOGE("invalid response length was %d expected %d", |
| 8702 | (int)responselen, (int)sizeof (RIL_Ecall_Unsol_Indications)); |
| 8703 | return RIL_ERRNO_INVALID_RESPONSE; |
| 8704 | } |
| 8705 | |
| 8706 | RIL_Ecall_Unsol_Indications *p_cur = (RIL_Ecall_Unsol_Indications *)response; |
| 8707 | RLOGD("responseEcallInd ind:%d call_id:%d", p_cur->ind, p_cur->call_id); |
| 8708 | |
| 8709 | p.writeInt32(p_cur->ind); |
| 8710 | p.writeInt32(p_cur->call_id); |
| 8711 | |
| 8712 | return 0; |
| 8713 | } |
| 8714 | // MTK-END |
| 8715 | |
| 8716 | static int responseQueryNetworkLock(android::Parcel &p, void *response, size_t responselen) { |
| 8717 | if (response == NULL) { |
| 8718 | RLOGE("responseQueryNetworkLock: invalid NULL response"); |
| 8719 | return RIL_ERRNO_INVALID_RESPONSE; |
| 8720 | } |
| 8721 | if (responselen != sizeof(RIL_SimMeLockCatInfo)) { |
| 8722 | RLOGE("responseQueryNetworkLock: invalid response length %u, expecting %u", |
| 8723 | (unsigned)responselen, (unsigned)sizeof(RIL_SimMeLockCatInfo)); |
| 8724 | return RIL_ERRNO_INVALID_RESPONSE; |
| 8725 | } |
| 8726 | |
| 8727 | RIL_SimMeLockCatInfo *p_result = (RIL_SimMeLockCatInfo *) response; |
| 8728 | |
| 8729 | p.writeInt32(p_result->catagory); |
| 8730 | p.writeInt32(p_result->state); |
| 8731 | p.writeInt32(p_result->retry_cnt); |
| 8732 | p.writeInt32(p_result->autolock_cnt); |
| 8733 | p.writeInt32(p_result->num_set); |
| 8734 | p.writeInt32(p_result->total_set); |
| 8735 | p.writeInt32(p_result->key_state); |
| 8736 | |
| 8737 | startResponse; |
| 8738 | appendPrintBuf("responseQueryNetworkLock result: catagory %d, state %d ,retry_cnt %d " |
| 8739 | ",autolock_cnt %d ,num_set %d ,total_set %d ,key_state %d", |
| 8740 | p_result->catagory, p_result->state, p_result->retry_cnt, |
| 8741 | p_result->autolock_cnt, p_result->num_set, p_result->total_set, p_result->key_state); |
| 8742 | closeResponse; |
| 8743 | return 0; |
| 8744 | } |
| 8745 | |
| 8746 | static void dispatchNetworkScan(android::Parcel &p, android::RequestInfo *pRI) { |
| 8747 | RIL_NetworkScanRequest args; |
| 8748 | int32_t t = 0; |
| 8749 | android::status_t status; |
| 8750 | |
| 8751 | memset (&args, 0, sizeof(args)); |
| 8752 | |
| 8753 | status = p.readInt32(&t); |
| 8754 | args.type = (RIL_ScanType) t; |
| 8755 | |
| 8756 | status = p.readInt32(&t); |
| 8757 | args.interval = (int32_t) t; |
| 8758 | |
| 8759 | status = p.readInt32(&t); |
| 8760 | args.specifiers_length = (uint32_t) t; |
| 8761 | |
| 8762 | for (int i = 0 ; i < args.specifiers_length ; i++) { |
| 8763 | status = p.readInt32(&t); |
| 8764 | args.specifiers[i].radio_access_network = (RIL_RadioAccessNetworks) t; |
| 8765 | |
| 8766 | status = p.readInt32(&t); |
| 8767 | args.specifiers[i].bands_length = (uint32_t) t; |
| 8768 | |
| 8769 | for (int j = 0 ; j < args.specifiers[i].bands_length ; j++) { |
| 8770 | status = p.readInt32(&t); |
| 8771 | if (args.specifiers[i].radio_access_network == GERAN) { |
| 8772 | args.specifiers[i].bands.geran_bands[j] = (RIL_GeranBands) t; |
| 8773 | } else if (args.specifiers[i].radio_access_network == UTRAN) { |
| 8774 | args.specifiers[i].bands.utran_bands[j] = (RIL_UtranBands) t; |
| 8775 | } else { |
| 8776 | args.specifiers[i].bands.eutran_bands[j] = (RIL_EutranBands) t; |
| 8777 | } |
| 8778 | } |
| 8779 | |
| 8780 | status = p.readInt32(&t); |
| 8781 | args.specifiers[i].channels_length = (uint32_t) t; |
| 8782 | |
| 8783 | for (int k = 0 ; k < args.specifiers[i].channels_length ; k++) { |
| 8784 | status = p.readInt32(&t); |
| 8785 | args.specifiers[i].channels[k] = (uint32_t) t; |
| 8786 | } |
| 8787 | } |
| 8788 | |
| 8789 | startRequest; |
| 8790 | appendPrintBuf("%scmd=0x%X,type=%d,interval=%d,specifiers_length=%d", printBuf, |
| 8791 | args.type, args.interval, args.specifiers_length); |
| 8792 | closeRequest; |
| 8793 | printRequest(pRI->token, pRI->pCI->requestNumber); |
| 8794 | |
| 8795 | if (status != android::NO_ERROR) { |
| 8796 | goto invalid; |
| 8797 | } |
| 8798 | |
| 8799 | CALL_ONREQUEST(pRI->pCI->requestNumber, &args, sizeof(args), pRI, pRI->socket_id); |
| 8800 | |
| 8801 | return; |
| 8802 | |
| 8803 | invalid: |
| 8804 | invalidCommandBlock(pRI); |
| 8805 | return; |
| 8806 | } |
| 8807 | |
| 8808 | static void dispatchLinkCapacityReportingCriteria(android::Parcel &p, android::RequestInfo *pRI) { |
| 8809 | android::status_t status; |
| 8810 | int t = 0; |
| 8811 | int num = 0; |
| 8812 | |
| 8813 | RIL_LinkCapacityReportingCriteria *data = (RIL_LinkCapacityReportingCriteria *) calloc(1, |
| 8814 | sizeof(RIL_LinkCapacityReportingCriteria)); |
| 8815 | if (data == NULL) { |
| 8816 | RLOGE("setLinkCapacityReportingCriteria: data memory allocation failed for request %s", |
| 8817 | android::requestToString(pRI->pCI->requestNumber)); |
| 8818 | return; |
| 8819 | } |
| 8820 | |
| 8821 | status = p.readInt32(&t); |
| 8822 | if (status != android::NO_ERROR) { |
| 8823 | goto invalid; |
| 8824 | } |
| 8825 | data->hysteresisMs = (int)t; |
| 8826 | |
| 8827 | status = p.readInt32(&t); |
| 8828 | if (status != android::NO_ERROR) { |
| 8829 | goto invalid; |
| 8830 | } |
| 8831 | data->hysteresisDlKbps = (int)t; |
| 8832 | |
| 8833 | status = p.readInt32(&t); |
| 8834 | if (status != android::NO_ERROR) { |
| 8835 | goto invalid; |
| 8836 | } |
| 8837 | data->hysteresisUlKbps = (int)t; |
| 8838 | |
| 8839 | status = p.readInt32(&t); |
| 8840 | if (status != android::NO_ERROR) { |
| 8841 | goto invalid; |
| 8842 | } |
| 8843 | num = (int)t; |
| 8844 | data->thresholdDlKbpsNumber = num > MAX_LCE_THRESHOLD_NUMBER ? MAX_LCE_THRESHOLD_NUMBER : num; |
| 8845 | for (int i = 0; i < num; i++) { |
| 8846 | status = p.readInt32(&t); |
| 8847 | if (status != android::NO_ERROR) { |
| 8848 | goto invalid; |
| 8849 | } |
| 8850 | if (i < MAX_LCE_THRESHOLD_NUMBER) { |
| 8851 | data->thresholdDlKbpsList[i] = (int)t; |
| 8852 | } |
| 8853 | } |
| 8854 | |
| 8855 | status = p.readInt32(&t); |
| 8856 | if (status != android::NO_ERROR) { |
| 8857 | goto invalid; |
| 8858 | } |
| 8859 | num = (int)t; |
| 8860 | data->thresholdUlKbpsNumber = num > MAX_LCE_THRESHOLD_NUMBER ? MAX_LCE_THRESHOLD_NUMBER : num; |
| 8861 | for (int i = 0; i < num; i++) { |
| 8862 | status = p.readInt32(&t); |
| 8863 | if (status != android::NO_ERROR) { |
| 8864 | goto invalid; |
| 8865 | } |
| 8866 | if (i < MAX_LCE_THRESHOLD_NUMBER) { |
| 8867 | data->thresholdUlKbpsList[i] = (int)t; |
| 8868 | } |
| 8869 | } |
| 8870 | |
| 8871 | status = p.readInt32(&t); |
| 8872 | if (status != android::NO_ERROR) { |
| 8873 | goto invalid; |
| 8874 | } |
| 8875 | data->accessNetwork = (int)t; |
| 8876 | |
| 8877 | CALL_ONREQUEST(pRI->pCI->requestNumber, data, sizeof(RIL_LinkCapacityReportingCriteria), pRI, |
| 8878 | pRI->socket_id); |
| 8879 | |
| 8880 | free(data); |
| 8881 | return; |
| 8882 | |
| 8883 | invalid: |
| 8884 | RLOGE("setLinkCapacityReportingCriteria: invalidCommandBlock for request %s", |
| 8885 | android::requestToString(pRI->pCI->requestNumber)); |
| 8886 | free(data); |
| 8887 | invalidCommandBlock(pRI); |
| 8888 | return; |
| 8889 | } |
| 8890 | |
| 8891 | |
| 8892 | static int responseNetworkScanResult(android::Parcel &p, void *response, size_t responselen) { |
| 8893 | if (response == NULL) { |
| 8894 | RLOGE("responseNetworkScanResult: invalid NULL response"); |
| 8895 | return RIL_ERRNO_INVALID_RESPONSE; |
| 8896 | } |
| 8897 | if (responselen != sizeof(RIL_NetworkScanResult)) { |
| 8898 | RLOGE("responseNetworkScanResult: invalid response length %u, expecting %u", |
| 8899 | (unsigned)responselen, (unsigned)sizeof(RIL_NetworkScanResult)); |
| 8900 | return RIL_ERRNO_INVALID_RESPONSE; |
| 8901 | } |
| 8902 | |
| 8903 | RIL_NetworkScanResult *p_result = (RIL_NetworkScanResult *)response; |
| 8904 | p.writeInt32(p_result->status); |
| 8905 | p.writeInt32(p_result->network_infos_length); |
| 8906 | |
| 8907 | RIL_CellInfo_v12 *p_cur = (RIL_CellInfo_v12 *) p_result->network_infos; |
| 8908 | for (int i = 0; i < p_result->network_infos_length; i++) { |
| 8909 | p.writeInt32((int)p_cur->cellInfoType); |
| 8910 | p.writeInt32(p_cur->registered); |
| 8911 | p.writeInt32(p_cur->timeStampType); |
| 8912 | p.writeInt64(p_cur->timeStamp); |
| 8913 | switch (p_cur->cellInfoType) { |
| 8914 | case RIL_CELL_INFO_TYPE_GSM: { |
| 8915 | p.writeInt32(p_cur->CellInfo.gsm.cellIdentityGsm.mcc); |
| 8916 | p.writeInt32(p_cur->CellInfo.gsm.cellIdentityGsm.mnc); |
| 8917 | p.writeInt32(p_cur->CellInfo.gsm.cellIdentityGsm.lac); |
| 8918 | p.writeInt32(p_cur->CellInfo.gsm.cellIdentityGsm.cid); |
| 8919 | p.writeInt32(p_cur->CellInfo.gsm.cellIdentityGsm.arfcn); |
| 8920 | p.writeInt32(p_cur->CellInfo.gsm.cellIdentityGsm.bsic); |
| 8921 | p.writeInt32(p_cur->CellInfo.gsm.signalStrengthGsm.signalStrength); |
| 8922 | p.writeInt32(p_cur->CellInfo.gsm.signalStrengthGsm.bitErrorRate); |
| 8923 | p.writeInt32(p_cur->CellInfo.gsm.signalStrengthGsm.timingAdvance); |
| 8924 | break; |
| 8925 | } |
| 8926 | case RIL_CELL_INFO_TYPE_WCDMA: { |
| 8927 | p.writeInt32(p_cur->CellInfo.wcdma.cellIdentityWcdma.mcc); |
| 8928 | p.writeInt32(p_cur->CellInfo.wcdma.cellIdentityWcdma.mnc); |
| 8929 | p.writeInt32(p_cur->CellInfo.wcdma.cellIdentityWcdma.lac); |
| 8930 | p.writeInt32(p_cur->CellInfo.wcdma.cellIdentityWcdma.cid); |
| 8931 | p.writeInt32(p_cur->CellInfo.wcdma.cellIdentityWcdma.psc); |
| 8932 | p.writeInt32(p_cur->CellInfo.wcdma.cellIdentityWcdma.uarfcn); |
| 8933 | p.writeInt32(p_cur->CellInfo.wcdma.signalStrengthWcdma.signalStrength); |
| 8934 | p.writeInt32(p_cur->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate); |
| 8935 | break; |
| 8936 | } |
| 8937 | case RIL_CELL_INFO_TYPE_CDMA: { |
| 8938 | p.writeInt32(p_cur->CellInfo.cdma.cellIdentityCdma.networkId); |
| 8939 | p.writeInt32(p_cur->CellInfo.cdma.cellIdentityCdma.systemId); |
| 8940 | p.writeInt32(p_cur->CellInfo.cdma.cellIdentityCdma.basestationId); |
| 8941 | p.writeInt32(p_cur->CellInfo.cdma.cellIdentityCdma.longitude); |
| 8942 | p.writeInt32(p_cur->CellInfo.cdma.cellIdentityCdma.latitude); |
| 8943 | p.writeInt32(p_cur->CellInfo.cdma.signalStrengthCdma.dbm); |
| 8944 | p.writeInt32(p_cur->CellInfo.cdma.signalStrengthCdma.ecio); |
| 8945 | p.writeInt32(p_cur->CellInfo.cdma.signalStrengthEvdo.dbm); |
| 8946 | p.writeInt32(p_cur->CellInfo.cdma.signalStrengthEvdo.ecio); |
| 8947 | p.writeInt32(p_cur->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio); |
| 8948 | break; |
| 8949 | } |
| 8950 | case RIL_CELL_INFO_TYPE_LTE: { |
| 8951 | p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.mcc); |
| 8952 | p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.mnc); |
| 8953 | p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.ci); |
| 8954 | p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.pci); |
| 8955 | p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.tac); |
| 8956 | p.writeInt32(p_cur->CellInfo.lte.cellIdentityLte.earfcn); |
| 8957 | p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.signalStrength); |
| 8958 | p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.rsrp); |
| 8959 | p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.rsrq); |
| 8960 | p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.rssnr); |
| 8961 | p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.cqi); |
| 8962 | p.writeInt32(p_cur->CellInfo.lte.signalStrengthLte.timingAdvance); |
| 8963 | break; |
| 8964 | } |
| 8965 | case RIL_CELL_INFO_TYPE_TD_SCDMA: { |
| 8966 | p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.mcc); |
| 8967 | p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.mnc); |
| 8968 | p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.lac); |
| 8969 | p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.cid); |
| 8970 | p.writeInt32(p_cur->CellInfo.tdscdma.cellIdentityTdscdma.cpid); |
| 8971 | p.writeInt32(p_cur->CellInfo.tdscdma.signalStrengthTdscdma.rscp); |
| 8972 | break; |
| 8973 | } |
| 8974 | default: { |
| 8975 | break; |
| 8976 | } |
| 8977 | } |
| 8978 | p_cur += 1; |
| 8979 | } |
| 8980 | startResponse; |
| 8981 | appendPrintBuf("Network scan result: status %d, network_infos_length %d", |
| 8982 | p_result->status, p_result->network_infos_length); |
| 8983 | closeResponse; |
| 8984 | return 0; |
| 8985 | } |
| 8986 | |
| 8987 | // M: [VzW] Data Framework @{ |
| 8988 | static int responsePcoDataAfterAttached(android::Parcel &p, void *response, size_t responselen) { |
| 8989 | if (response == NULL) { |
| 8990 | RLOGE("responsePcoDataAfterAttached: invalid NULL response"); |
| 8991 | return RIL_ERRNO_INVALID_RESPONSE; |
| 8992 | } |
| 8993 | if (responselen != sizeof(RIL_PCO_Data_attached)) { |
| 8994 | RLOGE("responsePcoDataAfterAttached: invalid response length %u, expecting %u", |
| 8995 | (unsigned)responselen, (unsigned)sizeof(RIL_PCO_Data_attached)); |
| 8996 | return RIL_ERRNO_INVALID_RESPONSE; |
| 8997 | } |
| 8998 | |
| 8999 | RIL_PCO_Data_attached *p_cur = (RIL_PCO_Data_attached *)response; |
| 9000 | p.writeInt32(p_cur->cid); |
| 9001 | writeStringToParcel(p, p_cur->apn_name); |
| 9002 | writeStringToParcel(p, p_cur->bearer_proto); |
| 9003 | p.writeInt32(p_cur->pco_id); |
| 9004 | p.writeInt32(p_cur->contents_length); |
| 9005 | p.write(p_cur->contents, p_cur->contents_length); |
| 9006 | |
| 9007 | startResponse; |
| 9008 | appendPrintBuf("PCO data received: cid %d, id %d, apn name %s, length %d", |
| 9009 | p_cur->cid, p_cur->pco_id, p_cur->apn_name, p_cur->contents_length); |
| 9010 | closeResponse; |
| 9011 | |
| 9012 | return 0; |
| 9013 | } |
| 9014 | // M: [VzW] Data Framework @} |
| 9015 | |
| 9016 | static int responseLinkCapacityEstimate(android::Parcel &p, void *response, size_t responselen) { |
| 9017 | if (response == NULL) { |
| 9018 | RLOGE("responseLinkCapacityEstimate: invalid NULL response"); |
| 9019 | return RIL_ERRNO_INVALID_RESPONSE; |
| 9020 | } |
| 9021 | if (responselen != sizeof(RIL_LinkCapacityEstimate)) { |
| 9022 | RLOGE("responseLinkCapacityEstimate: invalid response length %d, expecting length: %d", |
| 9023 | (int)responselen, (int)sizeof(RIL_LinkCapacityEstimate)); |
| 9024 | return RIL_ERRNO_INVALID_RESPONSE; |
| 9025 | } |
| 9026 | |
| 9027 | RIL_LinkCapacityEstimate *p_cur = (RIL_LinkCapacityEstimate *)response; |
| 9028 | p.writeInt32(p_cur->downlinkCapacityKbps); |
| 9029 | p.writeInt32(p_cur->uplinkCapacityKbps); |
| 9030 | |
| 9031 | startResponse; |
| 9032 | appendPrintBuf("responseLinkCapacityEstimate: downlinkCapacityKbps %d uplinkCapacityKbps %d", |
| 9033 | p_cur->downlinkCapacityKbps, p_cur->uplinkCapacityKbps); |
| 9034 | closeResponse; |
| 9035 | |
| 9036 | return 0; |
| 9037 | } |
| 9038 | |
| 9039 | |
| 9040 | |
| 9041 | } /* namespace android */ |
| 9042 | |
| 9043 | void rilEventAddWakeup_helper(struct ril_event *ev) { |
| 9044 | android::rilEventAddWakeup(ev); |
| 9045 | } |
| 9046 | |
| 9047 | void listenCallback_helper(int fd, short flags, void *param) { |
| 9048 | android::listenCallback(fd, flags, param); |
| 9049 | } |
| 9050 | |
| 9051 | int blockingWrite_helper(int fd, void *buffer, size_t len) { |
| 9052 | return android::blockingWrite(fd, buffer, len); |
| 9053 | } |