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