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