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