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