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