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