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