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 ANDROID_WAKE_LOCK_NAME "radio-interface" |
| 63 | |
Nathan Harold | a015339 | 2015-07-28 14:54:58 -0700 | [diff] [blame] | 64 | #define ANDROID_WAKE_LOCK_SECS 0 |
| 65 | #define ANDROID_WAKE_LOCK_USECS 200000 |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 66 | |
| 67 | #define PROPERTY_RIL_IMPL "gsm.version.ril-impl" |
| 68 | |
| 69 | // match with constant in RIL.java |
| 70 | #define MAX_COMMAND_BYTES (8 * 1024) |
| 71 | |
| 72 | // Basically: memset buffers that the client library |
| 73 | // shouldn't be using anymore in an attempt to find |
| 74 | // memory usage issues sooner. |
| 75 | #define MEMSET_FREED 1 |
| 76 | |
| 77 | #define NUM_ELEMS(a) (sizeof (a) / sizeof (a)[0]) |
| 78 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 79 | /* Negative values for private RIL errno's */ |
Chih-Hung Hsieh | 434554c | 2016-05-12 10:01:16 -0700 | [diff] [blame] | 80 | #define RIL_ERRNO_INVALID_RESPONSE (-1) |
Robert Greenwalt | 78e2c9c | 2016-05-16 12:36:42 -0700 | [diff] [blame] | 81 | #define RIL_ERRNO_NO_MEMORY (-12) |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 82 | |
| 83 | // request, response, and unsolicited msg print macro |
| 84 | #define PRINTBUF_SIZE 8096 |
| 85 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 86 | enum WakeType {DONT_WAKE, WAKE_PARTIAL}; |
| 87 | |
| 88 | typedef struct { |
| 89 | int requestNumber; |
Amit Mahajan | 759786a | 2017-03-03 17:35:47 -0800 | [diff] [blame] | 90 | int (*responseFunction) (int slotId, int responseType, int token, |
Amit Mahajan | 18fe36b | 2016-08-25 11:19:21 -0700 | [diff] [blame] | 91 | RIL_Errno e, void *response, size_t responselen); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 92 | WakeType wakeType; |
| 93 | } UnsolResponseInfo; |
| 94 | |
Wink Saville | 3d54e74 | 2009-05-18 18:00:44 -0700 | [diff] [blame] | 95 | typedef struct UserCallbackInfo { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 96 | RIL_TimedCallback p_callback; |
| 97 | void *userParam; |
| 98 | struct ril_event event; |
| 99 | struct UserCallbackInfo *p_next; |
| 100 | } UserCallbackInfo; |
| 101 | |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 102 | extern "C" const char * failCauseToString(RIL_Errno); |
| 103 | extern "C" const char * callStateToString(RIL_CallState); |
| 104 | extern "C" const char * radioStateToString(RIL_RadioState); |
| 105 | extern "C" const char * rilSocketIdToString(RIL_SOCKET_ID socket_id); |
| 106 | |
| 107 | extern "C" |
Amit Mahajan | bd5595a | 2017-03-28 11:17:55 -0700 | [diff] [blame] | 108 | char ril_service_name_base[MAX_SERVICE_NAME_LENGTH] = RIL_SERVICE_NAME_BASE; |
| 109 | extern "C" |
| 110 | char ril_service_name[MAX_SERVICE_NAME_LENGTH] = RIL1_SERVICE_NAME; |
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_wakeupfd_event; |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 129 | |
| 130 | static pthread_mutex_t s_pendingRequestsMutex = PTHREAD_MUTEX_INITIALIZER; |
| 131 | static pthread_mutex_t s_writeMutex = PTHREAD_MUTEX_INITIALIZER; |
Sanket Padawe | 6ff9a87 | 2016-01-27 15:09:12 -0800 | [diff] [blame] | 132 | static pthread_mutex_t s_wakeLockCountMutex = PTHREAD_MUTEX_INITIALIZER; |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 133 | static RequestInfo *s_pendingRequests = NULL; |
| 134 | |
| 135 | #if (SIM_COUNT >= 2) |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 136 | static pthread_mutex_t s_pendingRequestsMutex_socket2 = PTHREAD_MUTEX_INITIALIZER; |
| 137 | static pthread_mutex_t s_writeMutex_socket2 = PTHREAD_MUTEX_INITIALIZER; |
| 138 | static RequestInfo *s_pendingRequests_socket2 = NULL; |
| 139 | #endif |
| 140 | |
| 141 | #if (SIM_COUNT >= 3) |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 142 | static pthread_mutex_t s_pendingRequestsMutex_socket3 = PTHREAD_MUTEX_INITIALIZER; |
| 143 | static pthread_mutex_t s_writeMutex_socket3 = PTHREAD_MUTEX_INITIALIZER; |
| 144 | static RequestInfo *s_pendingRequests_socket3 = NULL; |
| 145 | #endif |
| 146 | |
| 147 | #if (SIM_COUNT >= 4) |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 148 | static pthread_mutex_t s_pendingRequestsMutex_socket4 = PTHREAD_MUTEX_INITIALIZER; |
| 149 | static pthread_mutex_t s_writeMutex_socket4 = PTHREAD_MUTEX_INITIALIZER; |
| 150 | static RequestInfo *s_pendingRequests_socket4 = NULL; |
| 151 | #endif |
| 152 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 153 | static struct ril_event s_wake_timeout_event; |
| 154 | static struct ril_event s_debug_event; |
| 155 | |
| 156 | |
Nathan Harold | a015339 | 2015-07-28 14:54:58 -0700 | [diff] [blame] | 157 | 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] | 158 | |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 159 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 160 | static pthread_mutex_t s_startupMutex = PTHREAD_MUTEX_INITIALIZER; |
| 161 | static pthread_cond_t s_startupCond = PTHREAD_COND_INITIALIZER; |
| 162 | |
| 163 | static pthread_mutex_t s_dispatchMutex = PTHREAD_MUTEX_INITIALIZER; |
| 164 | static pthread_cond_t s_dispatchCond = PTHREAD_COND_INITIALIZER; |
| 165 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 166 | static RequestInfo *s_toDispatchHead = NULL; |
| 167 | static RequestInfo *s_toDispatchTail = NULL; |
| 168 | |
| 169 | static UserCallbackInfo *s_last_wake_timeout_info = NULL; |
| 170 | |
| 171 | static void *s_lastNITZTimeData = NULL; |
| 172 | static size_t s_lastNITZTimeDataSize; |
| 173 | |
| 174 | #if RILC_LOG |
| 175 | static char printBuf[PRINTBUF_SIZE]; |
| 176 | #endif |
| 177 | |
| 178 | /*******************************************************************/ |
Sanket Padawe | 6ff9a87 | 2016-01-27 15:09:12 -0800 | [diff] [blame] | 179 | static void grabPartialWakeLock(); |
Sanket Padawe | 85f952a | 2017-01-02 23:46:00 -0800 | [diff] [blame] | 180 | void releaseWakeLock(); |
Sanket Padawe | 6ff9a87 | 2016-01-27 15:09:12 -0800 | [diff] [blame] | 181 | static void wakeTimeoutCallback(void *); |
Naveen Kalla | 2bc78d6 | 2011-12-07 16:22:53 -0800 | [diff] [blame] | 182 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 183 | #ifdef RIL_SHLIB |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 184 | #if defined(ANDROID_MULTI_SIM) |
Vinit Deshpande | 1b1ec2d | 2015-04-15 13:31:05 -0700 | [diff] [blame] | 185 | extern "C" void RIL_onUnsolicitedResponse(int unsolResponse, const void *data, |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 186 | size_t datalen, RIL_SOCKET_ID socket_id); |
| 187 | #else |
Vinit Deshpande | 1b1ec2d | 2015-04-15 13:31:05 -0700 | [diff] [blame] | 188 | 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] | 189 | size_t datalen); |
| 190 | #endif |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 191 | #endif |
| 192 | |
| 193 | #if defined(ANDROID_MULTI_SIM) |
| 194 | #define RIL_UNSOL_RESPONSE(a, b, c, d) RIL_onUnsolicitedResponse((a), (b), (c), (d)) |
| 195 | #define CALL_ONREQUEST(a, b, c, d, e) s_callbacks.onRequest((a), (b), (c), (d), (e)) |
| 196 | #define CALL_ONSTATEREQUEST(a) s_callbacks.onStateRequest(a) |
| 197 | #else |
| 198 | #define RIL_UNSOL_RESPONSE(a, b, c, d) RIL_onUnsolicitedResponse((a), (b), (c)) |
| 199 | #define CALL_ONREQUEST(a, b, c, d, e) s_callbacks.onRequest((a), (b), (c), (d)) |
| 200 | #define CALL_ONSTATEREQUEST(a) s_callbacks.onStateRequest() |
| 201 | #endif |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 202 | |
Wink Saville | 7f85680 | 2009-06-09 10:23:37 -0700 | [diff] [blame] | 203 | static UserCallbackInfo * internalRequestTimedCallback |
Dianne Hackborn | 0d9f0c0 | 2010-06-25 16:50:46 -0700 | [diff] [blame] | 204 | (RIL_TimedCallback callback, void *param, |
| 205 | const struct timeval *relativeTime); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 206 | |
| 207 | /** Index == requestNumber */ |
| 208 | static CommandInfo s_commands[] = { |
| 209 | #include "ril_commands.h" |
| 210 | }; |
| 211 | |
| 212 | static UnsolResponseInfo s_unsolResponses[] = { |
| 213 | #include "ril_unsol_commands.h" |
| 214 | }; |
| 215 | |
Amit Mahajan | bd5595a | 2017-03-28 11:17:55 -0700 | [diff] [blame] | 216 | char * RIL_getServiceName() { |
| 217 | return ril_service_name; |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | extern "C" |
Amit Mahajan | bd5595a | 2017-03-28 11:17:55 -0700 | [diff] [blame] | 221 | void RIL_setServiceName(const char * s) { |
| 222 | strncpy(ril_service_name, s, MAX_SERVICE_NAME_LENGTH); |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 223 | } |
| 224 | |
Sanket Padawe | 85f952a | 2017-01-02 23:46:00 -0800 | [diff] [blame] | 225 | RequestInfo * |
| 226 | addRequestToList(int serial, int slotId, int request) { |
| 227 | RequestInfo *pRI; |
Amit Mahajan | 18fe36b | 2016-08-25 11:19:21 -0700 | [diff] [blame] | 228 | int ret; |
Sanket Padawe | 85f952a | 2017-01-02 23:46:00 -0800 | [diff] [blame] | 229 | RIL_SOCKET_ID socket_id = (RIL_SOCKET_ID) slotId; |
Amit Mahajan | 18fe36b | 2016-08-25 11:19:21 -0700 | [diff] [blame] | 230 | /* Hook for current context */ |
| 231 | /* pendingRequestsMutextHook refer to &s_pendingRequestsMutex */ |
| 232 | pthread_mutex_t* pendingRequestsMutexHook = &s_pendingRequestsMutex; |
| 233 | /* pendingRequestsHook refer to &s_pendingRequests */ |
| 234 | RequestInfo** pendingRequestsHook = &s_pendingRequests; |
| 235 | |
| 236 | #if (SIM_COUNT >= 2) |
| 237 | if (socket_id == RIL_SOCKET_2) { |
| 238 | pendingRequestsMutexHook = &s_pendingRequestsMutex_socket2; |
| 239 | pendingRequestsHook = &s_pendingRequests_socket2; |
| 240 | } |
| 241 | #if (SIM_COUNT >= 3) |
| 242 | else if (socket_id == RIL_SOCKET_3) { |
| 243 | pendingRequestsMutexHook = &s_pendingRequestsMutex_socket3; |
| 244 | pendingRequestsHook = &s_pendingRequests_socket3; |
| 245 | } |
| 246 | #endif |
| 247 | #if (SIM_COUNT >= 4) |
| 248 | else if (socket_id == RIL_SOCKET_4) { |
| 249 | pendingRequestsMutexHook = &s_pendingRequestsMutex_socket4; |
| 250 | pendingRequestsHook = &s_pendingRequests_socket4; |
| 251 | } |
| 252 | #endif |
| 253 | #endif |
| 254 | |
Sanket Padawe | 85f952a | 2017-01-02 23:46:00 -0800 | [diff] [blame] | 255 | pRI = (RequestInfo *)calloc(1, sizeof(RequestInfo)); |
| 256 | if (pRI == NULL) { |
| 257 | RLOGE("Memory allocation failed for request %s", requestToString(request)); |
| 258 | return NULL; |
Amit Mahajan | 18fe36b | 2016-08-25 11:19:21 -0700 | [diff] [blame] | 259 | } |
| 260 | |
Sanket Padawe | 85f952a | 2017-01-02 23:46:00 -0800 | [diff] [blame] | 261 | pRI->token = serial; |
| 262 | pRI->pCI = &(s_commands[request]); |
| 263 | pRI->socket_id = socket_id; |
| 264 | |
Amit Mahajan | 18fe36b | 2016-08-25 11:19:21 -0700 | [diff] [blame] | 265 | ret = pthread_mutex_lock(pendingRequestsMutexHook); |
| 266 | assert (ret == 0); |
| 267 | |
| 268 | pRI->p_next = *pendingRequestsHook; |
| 269 | *pendingRequestsHook = pRI; |
| 270 | |
| 271 | ret = pthread_mutex_unlock(pendingRequestsMutexHook); |
| 272 | assert (ret == 0); |
| 273 | |
Sanket Padawe | 85f952a | 2017-01-02 23:46:00 -0800 | [diff] [blame] | 274 | return pRI; |
Amit Mahajan | 18fe36b | 2016-08-25 11:19:21 -0700 | [diff] [blame] | 275 | } |
| 276 | |
Wink Saville | 3d54e74 | 2009-05-18 18:00:44 -0700 | [diff] [blame] | 277 | static void triggerEvLoop() { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 278 | int ret; |
| 279 | if (!pthread_equal(pthread_self(), s_tid_dispatch)) { |
| 280 | /* trigger event loop to wakeup. No reason to do this, |
| 281 | * if we're in the event loop thread */ |
| 282 | do { |
| 283 | ret = write (s_fdWakeupWrite, " ", 1); |
| 284 | } while (ret < 0 && errno == EINTR); |
| 285 | } |
| 286 | } |
| 287 | |
Wink Saville | 3d54e74 | 2009-05-18 18:00:44 -0700 | [diff] [blame] | 288 | static void rilEventAddWakeup(struct ril_event *ev) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 289 | ril_event_add(ev); |
| 290 | triggerEvLoop(); |
| 291 | } |
| 292 | |
| 293 | /** |
| 294 | * A write on the wakeup fd is done just to pop us out of select() |
| 295 | * We empty the buffer here and then ril_event will reset the timers on the |
| 296 | * way back down |
| 297 | */ |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame] | 298 | static void processWakeupCallback(int fd, short flags, void *param) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 299 | char buff[16]; |
| 300 | int ret; |
| 301 | |
Wink Saville | 8eb2a12 | 2012-11-19 16:05:13 -0800 | [diff] [blame] | 302 | RLOGV("processWakeupCallback"); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 303 | |
| 304 | /* empty our wakeup socket out */ |
| 305 | do { |
| 306 | ret = read(s_fdWakeupRead, &buff, sizeof(buff)); |
Wink Saville | 7f85680 | 2009-06-09 10:23:37 -0700 | [diff] [blame] | 307 | } while (ret > 0 || (ret < 0 && errno == EINTR)); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 308 | } |
| 309 | |
Weilun Du | d2c3093 | 2017-02-09 12:32:42 -0800 | [diff] [blame] | 310 | static void resendLastNITZTimeData(RIL_SOCKET_ID socket_id) { |
| 311 | if (s_lastNITZTimeData != NULL) { |
Weilun Du | d2c3093 | 2017-02-09 12:32:42 -0800 | [diff] [blame] | 312 | int responseType = (s_callbacks.version >= 13) |
| 313 | ? RESPONSE_UNSOLICITED_ACK_EXP |
| 314 | : RESPONSE_UNSOLICITED; |
| 315 | int ret = radio::nitzTimeReceivedInd( |
Amit Mahajan | 759786a | 2017-03-03 17:35:47 -0800 | [diff] [blame] | 316 | (int)socket_id, responseType, 0, |
Weilun Du | d2c3093 | 2017-02-09 12:32:42 -0800 | [diff] [blame] | 317 | RIL_E_SUCCESS, s_lastNITZTimeData, s_lastNITZTimeDataSize); |
| 318 | if (ret == 0) { |
| 319 | free(s_lastNITZTimeData); |
| 320 | s_lastNITZTimeData = NULL; |
| 321 | } |
| 322 | } |
| 323 | } |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 324 | |
Amit Mahajan | c7ad626 | 2017-03-14 16:39:27 -0700 | [diff] [blame] | 325 | void onNewCommandConnect(RIL_SOCKET_ID socket_id) { |
Wink Saville | 5b9df33 | 2011-04-06 16:24:21 -0700 | [diff] [blame] | 326 | // Inform we are connected and the ril version |
Jake Hamby | a9c18d1 | 2011-04-12 23:32:08 -0700 | [diff] [blame] | 327 | int rilVer = s_callbacks.version; |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 328 | RIL_UNSOL_RESPONSE(RIL_UNSOL_RIL_CONNECTED, |
| 329 | &rilVer, sizeof(rilVer), socket_id); |
Wink Saville | 5b9df33 | 2011-04-06 16:24:21 -0700 | [diff] [blame] | 330 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 331 | // implicit radio state changed |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 332 | RIL_UNSOL_RESPONSE(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, |
| 333 | NULL, 0, socket_id); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 334 | |
| 335 | // Send last NITZ time data, in case it was missed |
| 336 | if (s_lastNITZTimeData != NULL) { |
Weilun Du | d2c3093 | 2017-02-09 12:32:42 -0800 | [diff] [blame] | 337 | resendLastNITZTimeData(socket_id); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | // Get version string |
| 341 | if (s_callbacks.getVersion != NULL) { |
| 342 | const char *version; |
| 343 | version = s_callbacks.getVersion(); |
Wink Saville | 8eb2a12 | 2012-11-19 16:05:13 -0800 | [diff] [blame] | 344 | RLOGI("RIL Daemon version: %s\n", version); |
Wink Saville | 7f85680 | 2009-06-09 10:23:37 -0700 | [diff] [blame] | 345 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 346 | property_set(PROPERTY_RIL_IMPL, version); |
| 347 | } else { |
Wink Saville | 8eb2a12 | 2012-11-19 16:05:13 -0800 | [diff] [blame] | 348 | RLOGI("RIL Daemon version: unavailable\n"); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 349 | property_set(PROPERTY_RIL_IMPL, "unavailable"); |
| 350 | } |
| 351 | |
| 352 | } |
| 353 | |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame] | 354 | static void userTimerCallback (int fd, short flags, void *param) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 355 | UserCallbackInfo *p_info; |
| 356 | |
| 357 | p_info = (UserCallbackInfo *)param; |
| 358 | |
| 359 | p_info->p_callback(p_info->userParam); |
| 360 | |
| 361 | |
| 362 | // FIXME generalize this...there should be a cancel mechanism |
| 363 | if (s_last_wake_timeout_info != NULL && s_last_wake_timeout_info == p_info) { |
| 364 | s_last_wake_timeout_info = NULL; |
| 365 | } |
| 366 | |
| 367 | free(p_info); |
| 368 | } |
| 369 | |
| 370 | |
| 371 | static void * |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame] | 372 | eventLoop(void *param) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 373 | int ret; |
| 374 | int filedes[2]; |
| 375 | |
| 376 | ril_event_init(); |
| 377 | |
| 378 | pthread_mutex_lock(&s_startupMutex); |
| 379 | |
| 380 | s_started = 1; |
| 381 | pthread_cond_broadcast(&s_startupCond); |
| 382 | |
| 383 | pthread_mutex_unlock(&s_startupMutex); |
| 384 | |
| 385 | ret = pipe(filedes); |
| 386 | |
| 387 | if (ret < 0) { |
Wink Saville | 8eb2a12 | 2012-11-19 16:05:13 -0800 | [diff] [blame] | 388 | RLOGE("Error in pipe() errno:%d", errno); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 389 | return NULL; |
| 390 | } |
| 391 | |
| 392 | s_fdWakeupRead = filedes[0]; |
| 393 | s_fdWakeupWrite = filedes[1]; |
| 394 | |
| 395 | fcntl(s_fdWakeupRead, F_SETFL, O_NONBLOCK); |
| 396 | |
| 397 | ril_event_set (&s_wakeupfd_event, s_fdWakeupRead, true, |
| 398 | processWakeupCallback, NULL); |
| 399 | |
| 400 | rilEventAddWakeup (&s_wakeupfd_event); |
| 401 | |
| 402 | // Only returns on error |
| 403 | ril_event_loop(); |
Wink Saville | 8eb2a12 | 2012-11-19 16:05:13 -0800 | [diff] [blame] | 404 | RLOGE ("error in event_loop_base errno:%d", errno); |
Kazuhiro Ondo | 5cdc135 | 2011-10-14 17:50:58 -0500 | [diff] [blame] | 405 | // kill self to restart on error |
| 406 | kill(0, SIGKILL); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 407 | |
| 408 | return NULL; |
| 409 | } |
| 410 | |
Wink Saville | 7f85680 | 2009-06-09 10:23:37 -0700 | [diff] [blame] | 411 | extern "C" void |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame] | 412 | RIL_startEventLoop(void) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 413 | /* spin up eventLoop thread and wait for it to get started */ |
| 414 | s_started = 0; |
| 415 | pthread_mutex_lock(&s_startupMutex); |
| 416 | |
Elliott Hughes | c0d8dc6 | 2014-01-03 15:31:42 -0800 | [diff] [blame] | 417 | pthread_attr_t attr; |
| 418 | pthread_attr_init(&attr); |
Wink Saville | 7f85680 | 2009-06-09 10:23:37 -0700 | [diff] [blame] | 419 | pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); |
Elliott Hughes | c0d8dc6 | 2014-01-03 15:31:42 -0800 | [diff] [blame] | 420 | |
Elliott Hughes | fd81e71 | 2014-01-06 12:46:02 -0800 | [diff] [blame] | 421 | int result = pthread_create(&s_tid_dispatch, &attr, eventLoop, NULL); |
| 422 | if (result != 0) { |
| 423 | RLOGE("Failed to create dispatch thread: %s", strerror(result)); |
Elliott Hughes | c0d8dc6 | 2014-01-03 15:31:42 -0800 | [diff] [blame] | 424 | goto done; |
| 425 | } |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 426 | |
| 427 | while (s_started == 0) { |
| 428 | pthread_cond_wait(&s_startupCond, &s_startupMutex); |
| 429 | } |
| 430 | |
Elliott Hughes | c0d8dc6 | 2014-01-03 15:31:42 -0800 | [diff] [blame] | 431 | done: |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 432 | pthread_mutex_unlock(&s_startupMutex); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 433 | } |
| 434 | |
| 435 | // Used for testing purpose only. |
| 436 | extern "C" void RIL_setcallbacks (const RIL_RadioFunctions *callbacks) { |
| 437 | memcpy(&s_callbacks, callbacks, sizeof (RIL_RadioFunctions)); |
| 438 | } |
| 439 | |
Wink Saville | 7f85680 | 2009-06-09 10:23:37 -0700 | [diff] [blame] | 440 | extern "C" void |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame] | 441 | RIL_register (const RIL_RadioFunctions *callbacks) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 442 | int ret; |
| 443 | int flags; |
| 444 | |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 445 | RLOGI("SIM_COUNT: %d", SIM_COUNT); |
| 446 | |
Wink Saville | 4380897 | 2011-01-13 17:39:51 -0800 | [diff] [blame] | 447 | if (callbacks == NULL) { |
Wink Saville | 8eb2a12 | 2012-11-19 16:05:13 -0800 | [diff] [blame] | 448 | RLOGE("RIL_register: RIL_RadioFunctions * null"); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 449 | return; |
| 450 | } |
Wink Saville | 4380897 | 2011-01-13 17:39:51 -0800 | [diff] [blame] | 451 | if (callbacks->version < RIL_VERSION_MIN) { |
Wink Saville | 8eb2a12 | 2012-11-19 16:05:13 -0800 | [diff] [blame] | 452 | RLOGE("RIL_register: version %d is to old, min version is %d", |
Wink Saville | 4380897 | 2011-01-13 17:39:51 -0800 | [diff] [blame] | 453 | callbacks->version, RIL_VERSION_MIN); |
| 454 | return; |
Wink Saville | 3a4840b | 2010-04-07 13:29:58 -0700 | [diff] [blame] | 455 | } |
Sanket Padawe | 4c05f35 | 2016-01-26 16:19:00 -0800 | [diff] [blame] | 456 | |
Wink Saville | 8eb2a12 | 2012-11-19 16:05:13 -0800 | [diff] [blame] | 457 | RLOGE("RIL_register: RIL version %d", callbacks->version); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 458 | |
| 459 | if (s_registerCalled > 0) { |
Wink Saville | 8eb2a12 | 2012-11-19 16:05:13 -0800 | [diff] [blame] | 460 | RLOGE("RIL_register has been called more than once. " |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 461 | "Subsequent call ignored"); |
| 462 | return; |
| 463 | } |
| 464 | |
| 465 | memcpy(&s_callbacks, callbacks, sizeof (RIL_RadioFunctions)); |
| 466 | |
| 467 | s_registerCalled = 1; |
| 468 | |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 469 | RLOGI("s_registerCalled flag set, %d", s_started); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 470 | // Little self-check |
| 471 | |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame] | 472 | 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] | 473 | assert(i == s_commands[i].requestNumber); |
| 474 | } |
| 475 | |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame] | 476 | for (int i = 0; i < (int)NUM_ELEMS(s_unsolResponses); i++) { |
Wink Saville | 7f85680 | 2009-06-09 10:23:37 -0700 | [diff] [blame] | 477 | assert(i + RIL_UNSOL_RESPONSE_BASE |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 478 | == s_unsolResponses[i].requestNumber); |
| 479 | } |
| 480 | |
Amit Mahajan | 18fe36b | 2016-08-25 11:19:21 -0700 | [diff] [blame] | 481 | radio::registerService(&s_callbacks, s_commands); |
| 482 | RLOGI("RILHIDL called registerService"); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 483 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 484 | } |
| 485 | |
Dheeraj Shetty | 27976c4 | 2014-07-02 21:27:57 +0200 | [diff] [blame] | 486 | extern "C" void |
Amit Mahajan | 18fe36b | 2016-08-25 11:19:21 -0700 | [diff] [blame] | 487 | RIL_register_socket (RIL_RadioFunctions *(*Init)(const struct RIL_Env *, int, char **), |
| 488 | RIL_SOCKET_TYPE socketType, int argc, char **argv) { |
Dheeraj Shetty | 27976c4 | 2014-07-02 21:27:57 +0200 | [diff] [blame] | 489 | |
| 490 | RIL_RadioFunctions* UimFuncs = NULL; |
| 491 | |
| 492 | if(Init) { |
| 493 | UimFuncs = Init(&RilSapSocket::uimRilEnv, argc, argv); |
| 494 | |
| 495 | switch(socketType) { |
| 496 | case RIL_SAP_SOCKET: |
Amit Mahajan | bd5595a | 2017-03-28 11:17:55 -0700 | [diff] [blame] | 497 | RilSapSocket::initSapSocket(RIL1_SERVICE_NAME, UimFuncs); |
Dheeraj Shetty | 27976c4 | 2014-07-02 21:27:57 +0200 | [diff] [blame] | 498 | |
| 499 | #if (SIM_COUNT >= 2) |
Amit Mahajan | bd5595a | 2017-03-28 11:17:55 -0700 | [diff] [blame] | 500 | RilSapSocket::initSapSocket(RIL2_SERVICE_NAME, UimFuncs); |
Dheeraj Shetty | 27976c4 | 2014-07-02 21:27:57 +0200 | [diff] [blame] | 501 | #endif |
| 502 | |
| 503 | #if (SIM_COUNT >= 3) |
Amit Mahajan | bd5595a | 2017-03-28 11:17:55 -0700 | [diff] [blame] | 504 | RilSapSocket::initSapSocket(RIL3_SERVICE_NAME, UimFuncs); |
Dheeraj Shetty | 27976c4 | 2014-07-02 21:27:57 +0200 | [diff] [blame] | 505 | #endif |
| 506 | |
| 507 | #if (SIM_COUNT >= 4) |
Amit Mahajan | bd5595a | 2017-03-28 11:17:55 -0700 | [diff] [blame] | 508 | RilSapSocket::initSapSocket(RIL4_SERVICE_NAME, UimFuncs); |
Dheeraj Shetty | 27976c4 | 2014-07-02 21:27:57 +0200 | [diff] [blame] | 509 | #endif |
Meng Wang | ef966a3 | 2016-06-20 17:38:18 -0700 | [diff] [blame] | 510 | break; |
| 511 | default:; |
Dheeraj Shetty | 27976c4 | 2014-07-02 21:27:57 +0200 | [diff] [blame] | 512 | } |
Amit Mahajan | c2c7185 | 2016-11-29 16:48:54 -0800 | [diff] [blame] | 513 | |
| 514 | RLOGI("RIL_register_socket: calling registerService"); |
| 515 | sap::registerService(UimFuncs); |
Dheeraj Shetty | 27976c4 | 2014-07-02 21:27:57 +0200 | [diff] [blame] | 516 | } |
| 517 | } |
| 518 | |
Sanket Padawe | 6ff9a87 | 2016-01-27 15:09:12 -0800 | [diff] [blame] | 519 | // 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] | 520 | static int |
Sanket Padawe | 6ff9a87 | 2016-01-27 15:09:12 -0800 | [diff] [blame] | 521 | checkAndDequeueRequestInfoIfAck(struct RequestInfo *pRI, bool isAck) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 522 | int ret = 0; |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 523 | /* Hook for current context |
| 524 | pendingRequestsMutextHook refer to &s_pendingRequestsMutex */ |
| 525 | pthread_mutex_t* pendingRequestsMutexHook = &s_pendingRequestsMutex; |
| 526 | /* pendingRequestsHook refer to &s_pendingRequests */ |
| 527 | RequestInfo ** pendingRequestsHook = &s_pendingRequests; |
Wink Saville | 7f85680 | 2009-06-09 10:23:37 -0700 | [diff] [blame] | 528 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 529 | if (pRI == NULL) { |
| 530 | return 0; |
| 531 | } |
| 532 | |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 533 | #if (SIM_COUNT >= 2) |
| 534 | if (pRI->socket_id == RIL_SOCKET_2) { |
| 535 | pendingRequestsMutexHook = &s_pendingRequestsMutex_socket2; |
| 536 | pendingRequestsHook = &s_pendingRequests_socket2; |
| 537 | } |
| 538 | #if (SIM_COUNT >= 3) |
| 539 | if (pRI->socket_id == RIL_SOCKET_3) { |
| 540 | pendingRequestsMutexHook = &s_pendingRequestsMutex_socket3; |
| 541 | pendingRequestsHook = &s_pendingRequests_socket3; |
| 542 | } |
| 543 | #endif |
| 544 | #if (SIM_COUNT >= 4) |
| 545 | if (pRI->socket_id == RIL_SOCKET_4) { |
| 546 | pendingRequestsMutexHook = &s_pendingRequestsMutex_socket4; |
| 547 | pendingRequestsHook = &s_pendingRequests_socket4; |
| 548 | } |
| 549 | #endif |
| 550 | #endif |
| 551 | pthread_mutex_lock(pendingRequestsMutexHook); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 552 | |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 553 | for(RequestInfo **ppCur = pendingRequestsHook |
Wink Saville | 7f85680 | 2009-06-09 10:23:37 -0700 | [diff] [blame] | 554 | ; *ppCur != NULL |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 555 | ; ppCur = &((*ppCur)->p_next) |
| 556 | ) { |
| 557 | if (pRI == *ppCur) { |
| 558 | ret = 1; |
Sanket Padawe | 6ff9a87 | 2016-01-27 15:09:12 -0800 | [diff] [blame] | 559 | if (isAck) { // Async ack |
| 560 | if (pRI->wasAckSent == 1) { |
| 561 | RLOGD("Ack was already sent for %s", requestToString(pRI->pCI->requestNumber)); |
| 562 | } else { |
| 563 | pRI->wasAckSent = 1; |
| 564 | } |
| 565 | } else { |
| 566 | *ppCur = (*ppCur)->p_next; |
| 567 | } |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 568 | break; |
| 569 | } |
| 570 | } |
| 571 | |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 572 | pthread_mutex_unlock(pendingRequestsMutexHook); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 573 | |
| 574 | return ret; |
| 575 | } |
| 576 | |
Sanket Padawe | 6ff9a87 | 2016-01-27 15:09:12 -0800 | [diff] [blame] | 577 | extern "C" void |
| 578 | RIL_onRequestAck(RIL_Token t) { |
| 579 | RequestInfo *pRI; |
Amit Mahajan | c7ad626 | 2017-03-14 16:39:27 -0700 | [diff] [blame] | 580 | int ret; |
Sanket Padawe | 6ff9a87 | 2016-01-27 15:09:12 -0800 | [diff] [blame] | 581 | |
| 582 | size_t errorOffset; |
| 583 | RIL_SOCKET_ID socket_id = RIL_SOCKET_1; |
| 584 | |
| 585 | pRI = (RequestInfo *)t; |
| 586 | |
| 587 | if (!checkAndDequeueRequestInfoIfAck(pRI, true)) { |
| 588 | RLOGE ("RIL_onRequestAck: invalid RIL_Token"); |
| 589 | return; |
| 590 | } |
| 591 | |
| 592 | socket_id = pRI->socket_id; |
Sanket Padawe | 6ff9a87 | 2016-01-27 15:09:12 -0800 | [diff] [blame] | 593 | |
| 594 | #if VDBG |
| 595 | RLOGD("Request Ack, %s", rilSocketIdToString(socket_id)); |
| 596 | #endif |
| 597 | |
| 598 | appendPrintBuf("Ack [%04d]< %s", pRI->token, requestToString(pRI->pCI->requestNumber)); |
| 599 | |
| 600 | if (pRI->cancelled == 0) { |
Jack Yu | bbd4b1b | 2017-02-13 11:21:00 -0800 | [diff] [blame] | 601 | pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock( |
| 602 | (int) socket_id); |
| 603 | int rwlockRet = pthread_rwlock_rdlock(radioServiceRwlockPtr); |
| 604 | assert(rwlockRet == 0); |
Sanket Padawe | 6ff9a87 | 2016-01-27 15:09:12 -0800 | [diff] [blame] | 605 | |
Jack Yu | bbd4b1b | 2017-02-13 11:21:00 -0800 | [diff] [blame] | 606 | radio::acknowledgeRequest((int) socket_id, pRI->token); |
Sanket Padawe | 6ff9a87 | 2016-01-27 15:09:12 -0800 | [diff] [blame] | 607 | |
Jack Yu | bbd4b1b | 2017-02-13 11:21:00 -0800 | [diff] [blame] | 608 | rwlockRet = pthread_rwlock_unlock(radioServiceRwlockPtr); |
| 609 | assert(rwlockRet == 0); |
Sanket Padawe | 6ff9a87 | 2016-01-27 15:09:12 -0800 | [diff] [blame] | 610 | } |
| 611 | } |
Sanket Padawe | 6ff9a87 | 2016-01-27 15:09:12 -0800 | [diff] [blame] | 612 | extern "C" void |
| 613 | RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responselen) { |
| 614 | RequestInfo *pRI; |
| 615 | int ret; |
Sanket Padawe | 6ff9a87 | 2016-01-27 15:09:12 -0800 | [diff] [blame] | 616 | size_t errorOffset; |
| 617 | RIL_SOCKET_ID socket_id = RIL_SOCKET_1; |
| 618 | |
| 619 | pRI = (RequestInfo *)t; |
| 620 | |
| 621 | if (!checkAndDequeueRequestInfoIfAck(pRI, false)) { |
| 622 | RLOGE ("RIL_onRequestComplete: invalid RIL_Token"); |
| 623 | return; |
| 624 | } |
| 625 | |
| 626 | socket_id = pRI->socket_id; |
Robert Greenwalt | 191e4dc | 2015-04-29 16:57:39 -0700 | [diff] [blame] | 627 | #if VDBG |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 628 | RLOGD("RequestComplete, %s", rilSocketIdToString(socket_id)); |
Robert Greenwalt | 191e4dc | 2015-04-29 16:57:39 -0700 | [diff] [blame] | 629 | #endif |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 630 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 631 | if (pRI->local > 0) { |
| 632 | // Locally issued command...void only! |
| 633 | // response does not go back up the command socket |
Wink Saville | 8eb2a12 | 2012-11-19 16:05:13 -0800 | [diff] [blame] | 634 | RLOGD("C[locl]< %s", requestToString(pRI->pCI->requestNumber)); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 635 | |
Jack Yu | bbd4b1b | 2017-02-13 11:21:00 -0800 | [diff] [blame] | 636 | free(pRI); |
| 637 | return; |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 638 | } |
| 639 | |
| 640 | appendPrintBuf("[%04d]< %s", |
| 641 | pRI->token, requestToString(pRI->pCI->requestNumber)); |
| 642 | |
| 643 | if (pRI->cancelled == 0) { |
Amit Mahajan | 18fe36b | 2016-08-25 11:19:21 -0700 | [diff] [blame] | 644 | int responseType; |
Sanket Padawe | 6ff9a87 | 2016-01-27 15:09:12 -0800 | [diff] [blame] | 645 | if (s_callbacks.version >= 13 && pRI->wasAckSent == 1) { |
| 646 | // If ack was already sent, then this call is an asynchronous response. So we need to |
| 647 | // 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] | 648 | responseType = RESPONSE_SOLICITED_ACK_EXP; |
Sanket Padawe | 6ff9a87 | 2016-01-27 15:09:12 -0800 | [diff] [blame] | 649 | grabPartialWakeLock(); |
| 650 | } else { |
Amit Mahajan | 18fe36b | 2016-08-25 11:19:21 -0700 | [diff] [blame] | 651 | responseType = RESPONSE_SOLICITED; |
Sanket Padawe | 6ff9a87 | 2016-01-27 15:09:12 -0800 | [diff] [blame] | 652 | } |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 653 | |
Jack Yu | bbd4b1b | 2017-02-13 11:21:00 -0800 | [diff] [blame] | 654 | // there is a response payload, no matter success or not. |
Jayachandran C | 572f2f4 | 2017-03-25 14:30:13 -0700 | [diff] [blame] | 655 | #if VDBG |
Jack Yu | bbd4b1b | 2017-02-13 11:21:00 -0800 | [diff] [blame] | 656 | RLOGE ("Calling responseFunction() for token %d", pRI->token); |
Jayachandran C | 572f2f4 | 2017-03-25 14:30:13 -0700 | [diff] [blame] | 657 | #endif |
Sanket Padawe | 85f952a | 2017-01-02 23:46:00 -0800 | [diff] [blame] | 658 | |
Jack Yu | bbd4b1b | 2017-02-13 11:21:00 -0800 | [diff] [blame] | 659 | pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock((int) socket_id); |
| 660 | int rwlockRet = pthread_rwlock_rdlock(radioServiceRwlockPtr); |
| 661 | assert(rwlockRet == 0); |
Amit Mahajan | 32ec8a4 | 2017-01-24 05:45:02 -0800 | [diff] [blame] | 662 | |
Amit Mahajan | 759786a | 2017-03-03 17:35:47 -0800 | [diff] [blame] | 663 | ret = pRI->pCI->responseFunction((int) socket_id, |
Jack Yu | bbd4b1b | 2017-02-13 11:21:00 -0800 | [diff] [blame] | 664 | responseType, pRI->token, e, response, responselen); |
Amit Mahajan | 32ec8a4 | 2017-01-24 05:45:02 -0800 | [diff] [blame] | 665 | |
Jack Yu | bbd4b1b | 2017-02-13 11:21:00 -0800 | [diff] [blame] | 666 | rwlockRet = pthread_rwlock_unlock(radioServiceRwlockPtr); |
| 667 | assert(rwlockRet == 0); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 668 | } |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 669 | free(pRI); |
| 670 | } |
| 671 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 672 | static void |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame] | 673 | grabPartialWakeLock() { |
Sanket Padawe | 6ff9a87 | 2016-01-27 15:09:12 -0800 | [diff] [blame] | 674 | if (s_callbacks.version >= 13) { |
| 675 | int ret; |
| 676 | ret = pthread_mutex_lock(&s_wakeLockCountMutex); |
| 677 | assert(ret == 0); |
| 678 | acquire_wake_lock(PARTIAL_WAKE_LOCK, ANDROID_WAKE_LOCK_NAME); |
Sanket Padawe | 55227b5 | 2016-02-29 10:09:26 -0800 | [diff] [blame] | 679 | |
| 680 | UserCallbackInfo *p_info = |
| 681 | internalRequestTimedCallback(wakeTimeoutCallback, NULL, &TIMEVAL_WAKE_TIMEOUT); |
| 682 | if (p_info == NULL) { |
| 683 | release_wake_lock(ANDROID_WAKE_LOCK_NAME); |
| 684 | } else { |
| 685 | s_wakelock_count++; |
| 686 | if (s_last_wake_timeout_info != NULL) { |
| 687 | s_last_wake_timeout_info->userParam = (void *)1; |
| 688 | } |
| 689 | s_last_wake_timeout_info = p_info; |
Sanket Padawe | 6ff9a87 | 2016-01-27 15:09:12 -0800 | [diff] [blame] | 690 | } |
Sanket Padawe | 6ff9a87 | 2016-01-27 15:09:12 -0800 | [diff] [blame] | 691 | ret = pthread_mutex_unlock(&s_wakeLockCountMutex); |
| 692 | assert(ret == 0); |
| 693 | } else { |
| 694 | acquire_wake_lock(PARTIAL_WAKE_LOCK, ANDROID_WAKE_LOCK_NAME); |
| 695 | } |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 696 | } |
| 697 | |
Sanket Padawe | 85f952a | 2017-01-02 23:46:00 -0800 | [diff] [blame] | 698 | void |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame] | 699 | releaseWakeLock() { |
Sanket Padawe | 6ff9a87 | 2016-01-27 15:09:12 -0800 | [diff] [blame] | 700 | if (s_callbacks.version >= 13) { |
| 701 | int ret; |
| 702 | ret = pthread_mutex_lock(&s_wakeLockCountMutex); |
| 703 | assert(ret == 0); |
| 704 | |
| 705 | if (s_wakelock_count > 1) { |
| 706 | s_wakelock_count--; |
| 707 | } else { |
| 708 | s_wakelock_count = 0; |
| 709 | release_wake_lock(ANDROID_WAKE_LOCK_NAME); |
| 710 | if (s_last_wake_timeout_info != NULL) { |
| 711 | s_last_wake_timeout_info->userParam = (void *)1; |
| 712 | } |
| 713 | } |
| 714 | |
| 715 | ret = pthread_mutex_unlock(&s_wakeLockCountMutex); |
| 716 | assert(ret == 0); |
| 717 | } else { |
| 718 | release_wake_lock(ANDROID_WAKE_LOCK_NAME); |
| 719 | } |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 720 | } |
| 721 | |
| 722 | /** |
| 723 | * Timer callback to put us back to sleep before the default timeout |
| 724 | */ |
| 725 | static void |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame] | 726 | wakeTimeoutCallback (void *param) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 727 | // We're using "param != NULL" as a cancellation mechanism |
Sanket Padawe | 6ff9a87 | 2016-01-27 15:09:12 -0800 | [diff] [blame] | 728 | if (s_callbacks.version >= 13) { |
| 729 | if (param == NULL) { |
| 730 | int ret; |
| 731 | ret = pthread_mutex_lock(&s_wakeLockCountMutex); |
| 732 | assert(ret == 0); |
| 733 | s_wakelock_count = 0; |
| 734 | release_wake_lock(ANDROID_WAKE_LOCK_NAME); |
| 735 | ret = pthread_mutex_unlock(&s_wakeLockCountMutex); |
| 736 | assert(ret == 0); |
| 737 | } |
| 738 | } else { |
| 739 | if (param == NULL) { |
| 740 | releaseWakeLock(); |
| 741 | } |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 742 | } |
| 743 | } |
| 744 | |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 745 | #if defined(ANDROID_MULTI_SIM) |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 746 | extern "C" |
Bernhard Rosenkränzer | d613b96 | 2014-11-17 20:52:09 +0100 | [diff] [blame] | 747 | void RIL_onUnsolicitedResponse(int unsolResponse, const void *data, |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 748 | size_t datalen, RIL_SOCKET_ID socket_id) |
| 749 | #else |
| 750 | extern "C" |
Bernhard Rosenkränzer | d613b96 | 2014-11-17 20:52:09 +0100 | [diff] [blame] | 751 | void RIL_onUnsolicitedResponse(int unsolResponse, const void *data, |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 752 | size_t datalen) |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 753 | #endif |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 754 | { |
| 755 | int unsolResponseIndex; |
| 756 | int ret; |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 757 | bool shouldScheduleTimeout = false; |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 758 | RIL_SOCKET_ID soc_id = RIL_SOCKET_1; |
| 759 | |
| 760 | #if defined(ANDROID_MULTI_SIM) |
| 761 | soc_id = socket_id; |
| 762 | #endif |
| 763 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 764 | |
| 765 | if (s_registerCalled == 0) { |
| 766 | // Ignore RIL_onUnsolicitedResponse before RIL_register |
Wink Saville | 8eb2a12 | 2012-11-19 16:05:13 -0800 | [diff] [blame] | 767 | RLOGW("RIL_onUnsolicitedResponse called before RIL_register"); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 768 | return; |
| 769 | } |
Wink Saville | 7f85680 | 2009-06-09 10:23:37 -0700 | [diff] [blame] | 770 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 771 | unsolResponseIndex = unsolResponse - RIL_UNSOL_RESPONSE_BASE; |
| 772 | |
| 773 | if ((unsolResponseIndex < 0) |
| 774 | || (unsolResponseIndex >= (int32_t)NUM_ELEMS(s_unsolResponses))) { |
Wink Saville | 8eb2a12 | 2012-11-19 16:05:13 -0800 | [diff] [blame] | 775 | RLOGE("unsupported unsolicited response code %d", unsolResponse); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 776 | return; |
| 777 | } |
| 778 | |
| 779 | // Grab a wake lock if needed for this reponse, |
| 780 | // as we exit we'll either release it immediately |
| 781 | // or set a timer to release it later. |
| 782 | switch (s_unsolResponses[unsolResponseIndex].wakeType) { |
| 783 | case WAKE_PARTIAL: |
| 784 | grabPartialWakeLock(); |
| 785 | shouldScheduleTimeout = true; |
| 786 | break; |
| 787 | |
| 788 | case DONT_WAKE: |
| 789 | default: |
| 790 | // No wake lock is grabed so don't set timeout |
| 791 | shouldScheduleTimeout = false; |
| 792 | break; |
| 793 | } |
| 794 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 795 | appendPrintBuf("[UNSL]< %s", requestToString(unsolResponse)); |
| 796 | |
Amit Mahajan | 18fe36b | 2016-08-25 11:19:21 -0700 | [diff] [blame] | 797 | int responseType; |
Sanket Padawe | d8c0b46 | 2016-02-03 11:46:02 -0800 | [diff] [blame] | 798 | if (s_callbacks.version >= 13 |
| 799 | && s_unsolResponses[unsolResponseIndex].wakeType == WAKE_PARTIAL) { |
Amit Mahajan | 18fe36b | 2016-08-25 11:19:21 -0700 | [diff] [blame] | 800 | responseType = RESPONSE_UNSOLICITED_ACK_EXP; |
Sanket Padawe | d8c0b46 | 2016-02-03 11:46:02 -0800 | [diff] [blame] | 801 | } else { |
Amit Mahajan | 18fe36b | 2016-08-25 11:19:21 -0700 | [diff] [blame] | 802 | responseType = RESPONSE_UNSOLICITED; |
Sanket Padawe | d8c0b46 | 2016-02-03 11:46:02 -0800 | [diff] [blame] | 803 | } |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 804 | |
Amit Mahajan | 32ec8a4 | 2017-01-24 05:45:02 -0800 | [diff] [blame] | 805 | pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock((int) soc_id); |
| 806 | int rwlockRet = pthread_rwlock_rdlock(radioServiceRwlockPtr); |
| 807 | assert(rwlockRet == 0); |
| 808 | |
Amit Mahajan | 18fe36b | 2016-08-25 11:19:21 -0700 | [diff] [blame] | 809 | ret = s_unsolResponses[unsolResponseIndex].responseFunction( |
Amit Mahajan | 759786a | 2017-03-03 17:35:47 -0800 | [diff] [blame] | 810 | (int) soc_id, responseType, 0, RIL_E_SUCCESS, const_cast<void*>(data), |
Amit Mahajan | 18fe36b | 2016-08-25 11:19:21 -0700 | [diff] [blame] | 811 | datalen); |
Amit Mahajan | 32ec8a4 | 2017-01-24 05:45:02 -0800 | [diff] [blame] | 812 | |
| 813 | rwlockRet = pthread_rwlock_unlock(radioServiceRwlockPtr); |
| 814 | assert(rwlockRet == 0); |
| 815 | |
Sanket Padawe | 55227b5 | 2016-02-29 10:09:26 -0800 | [diff] [blame] | 816 | if (s_callbacks.version < 13) { |
| 817 | if (shouldScheduleTimeout) { |
| 818 | UserCallbackInfo *p_info = internalRequestTimedCallback(wakeTimeoutCallback, NULL, |
| 819 | &TIMEVAL_WAKE_TIMEOUT); |
| 820 | |
| 821 | if (p_info == NULL) { |
| 822 | goto error_exit; |
| 823 | } else { |
| 824 | // Cancel the previous request |
| 825 | if (s_last_wake_timeout_info != NULL) { |
| 826 | s_last_wake_timeout_info->userParam = (void *)1; |
| 827 | } |
| 828 | s_last_wake_timeout_info = p_info; |
| 829 | } |
| 830 | } |
| 831 | } |
| 832 | |
Robert Greenwalt | 191e4dc | 2015-04-29 16:57:39 -0700 | [diff] [blame] | 833 | #if VDBG |
Amit Mahajan | 18fe36b | 2016-08-25 11:19:21 -0700 | [diff] [blame] | 834 | RLOGI("%s UNSOLICITED: %s length:%d", rilSocketIdToString(soc_id), |
Amit Mahajan | c7ad626 | 2017-03-14 16:39:27 -0700 | [diff] [blame] | 835 | requestToString(unsolResponse), datalen); |
Robert Greenwalt | 191e4dc | 2015-04-29 16:57:39 -0700 | [diff] [blame] | 836 | #endif |
Weilun Du | d2c3093 | 2017-02-09 12:32:42 -0800 | [diff] [blame] | 837 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 838 | if (ret != 0 && unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 839 | // Unfortunately, NITZ time is not poll/update like everything |
| 840 | // else in the system. So, if the upstream client isn't connected, |
| 841 | // keep a copy of the last NITZ response (with receive time noted |
| 842 | // above) around so we can deliver it when it is connected |
| 843 | |
| 844 | if (s_lastNITZTimeData != NULL) { |
Weilun Du | d2c3093 | 2017-02-09 12:32:42 -0800 | [diff] [blame] | 845 | free(s_lastNITZTimeData); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 846 | s_lastNITZTimeData = NULL; |
| 847 | } |
| 848 | |
Weilun Du | d2c3093 | 2017-02-09 12:32:42 -0800 | [diff] [blame] | 849 | s_lastNITZTimeData = calloc(datalen, 1); |
Sanket Padawe | 55227b5 | 2016-02-29 10:09:26 -0800 | [diff] [blame] | 850 | if (s_lastNITZTimeData == NULL) { |
Weilun Du | d2c3093 | 2017-02-09 12:32:42 -0800 | [diff] [blame] | 851 | RLOGE("Memory allocation failed in RIL_onUnsolicitedResponse"); |
| 852 | goto error_exit; |
Sanket Padawe | 55227b5 | 2016-02-29 10:09:26 -0800 | [diff] [blame] | 853 | } |
Weilun Du | d2c3093 | 2017-02-09 12:32:42 -0800 | [diff] [blame] | 854 | s_lastNITZTimeDataSize = datalen; |
| 855 | memcpy(s_lastNITZTimeData, data, datalen); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 856 | } |
| 857 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 858 | // Normal exit |
| 859 | return; |
| 860 | |
| 861 | error_exit: |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 862 | if (shouldScheduleTimeout) { |
| 863 | releaseWakeLock(); |
| 864 | } |
| 865 | } |
| 866 | |
Wink Saville | 7f85680 | 2009-06-09 10:23:37 -0700 | [diff] [blame] | 867 | /** FIXME generalize this if you track UserCAllbackInfo, clear it |
| 868 | when the callback occurs |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 869 | */ |
| 870 | static UserCallbackInfo * |
Wink Saville | 7f85680 | 2009-06-09 10:23:37 -0700 | [diff] [blame] | 871 | internalRequestTimedCallback (RIL_TimedCallback callback, void *param, |
Dianne Hackborn | 0d9f0c0 | 2010-06-25 16:50:46 -0700 | [diff] [blame] | 872 | const struct timeval *relativeTime) |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 873 | { |
| 874 | struct timeval myRelativeTime; |
| 875 | UserCallbackInfo *p_info; |
| 876 | |
Sanket Padawe | 0cfc553 | 2016-03-07 17:12:19 -0800 | [diff] [blame] | 877 | p_info = (UserCallbackInfo *) calloc(1, sizeof(UserCallbackInfo)); |
Sanket Padawe | 55227b5 | 2016-02-29 10:09:26 -0800 | [diff] [blame] | 878 | if (p_info == NULL) { |
| 879 | RLOGE("Memory allocation failed in internalRequestTimedCallback"); |
| 880 | return p_info; |
| 881 | |
| 882 | } |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 883 | |
Wink Saville | 7f85680 | 2009-06-09 10:23:37 -0700 | [diff] [blame] | 884 | p_info->p_callback = callback; |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 885 | p_info->userParam = param; |
Dianne Hackborn | 0d9f0c0 | 2010-06-25 16:50:46 -0700 | [diff] [blame] | 886 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 887 | if (relativeTime == NULL) { |
| 888 | /* treat null parameter as a 0 relative time */ |
| 889 | memset (&myRelativeTime, 0, sizeof(myRelativeTime)); |
| 890 | } else { |
| 891 | /* FIXME I think event_add's tv param is really const anyway */ |
| 892 | memcpy (&myRelativeTime, relativeTime, sizeof(myRelativeTime)); |
| 893 | } |
| 894 | |
| 895 | ril_event_set(&(p_info->event), -1, false, userTimerCallback, p_info); |
| 896 | |
| 897 | ril_timer_add(&(p_info->event), &myRelativeTime); |
| 898 | |
| 899 | triggerEvLoop(); |
| 900 | return p_info; |
| 901 | } |
| 902 | |
Naveen Kalla | 7edd07c | 2010-06-21 18:54:47 -0700 | [diff] [blame] | 903 | |
| 904 | extern "C" void |
Dianne Hackborn | 0d9f0c0 | 2010-06-25 16:50:46 -0700 | [diff] [blame] | 905 | RIL_requestTimedCallback (RIL_TimedCallback callback, void *param, |
| 906 | const struct timeval *relativeTime) { |
| 907 | internalRequestTimedCallback (callback, param, relativeTime); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 908 | } |
| 909 | |
| 910 | const char * |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame] | 911 | failCauseToString(RIL_Errno e) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 912 | switch(e) { |
| 913 | case RIL_E_SUCCESS: return "E_SUCCESS"; |
Robert Greenwalt | 2126ab2 | 2013-04-09 12:20:45 -0700 | [diff] [blame] | 914 | 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] | 915 | case RIL_E_GENERIC_FAILURE: return "E_GENERIC_FAILURE"; |
| 916 | case RIL_E_PASSWORD_INCORRECT: return "E_PASSWORD_INCORRECT"; |
| 917 | case RIL_E_SIM_PIN2: return "E_SIM_PIN2"; |
| 918 | case RIL_E_SIM_PUK2: return "E_SIM_PUK2"; |
| 919 | case RIL_E_REQUEST_NOT_SUPPORTED: return "E_REQUEST_NOT_SUPPORTED"; |
| 920 | case RIL_E_CANCELLED: return "E_CANCELLED"; |
| 921 | case RIL_E_OP_NOT_ALLOWED_DURING_VOICE_CALL: return "E_OP_NOT_ALLOWED_DURING_VOICE_CALL"; |
| 922 | case RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW: return "E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW"; |
| 923 | 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] | 924 | case RIL_E_SIM_ABSENT:return "E_SIM_ABSENT"; |
John Wang | 7553447 | 2010-04-20 15:11:42 -0700 | [diff] [blame] | 925 | 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] | 926 | #ifdef FEATURE_MULTIMODE_ANDROID |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame] | 927 | case RIL_E_SUBSCRIPTION_NOT_AVAILABLE:return "E_SUBSCRIPTION_NOT_AVAILABLE"; |
| 928 | case RIL_E_MODE_NOT_SUPPORTED:return "E_MODE_NOT_SUPPORTED"; |
| 929 | #endif |
Sanket Padawe | b39e5c9 | 2016-02-08 14:28:59 -0800 | [diff] [blame] | 930 | case RIL_E_FDN_CHECK_FAILURE: return "E_FDN_CHECK_FAILURE"; |
| 931 | case RIL_E_MISSING_RESOURCE: return "E_MISSING_RESOURCE"; |
| 932 | case RIL_E_NO_SUCH_ELEMENT: return "E_NO_SUCH_ELEMENT"; |
| 933 | case RIL_E_DIAL_MODIFIED_TO_USSD: return "E_DIAL_MODIFIED_TO_USSD"; |
| 934 | case RIL_E_DIAL_MODIFIED_TO_SS: return "E_DIAL_MODIFIED_TO_SS"; |
| 935 | case RIL_E_DIAL_MODIFIED_TO_DIAL: return "E_DIAL_MODIFIED_TO_DIAL"; |
| 936 | case RIL_E_USSD_MODIFIED_TO_DIAL: return "E_USSD_MODIFIED_TO_DIAL"; |
| 937 | case RIL_E_USSD_MODIFIED_TO_SS: return "E_USSD_MODIFIED_TO_SS"; |
| 938 | case RIL_E_USSD_MODIFIED_TO_USSD: return "E_USSD_MODIFIED_TO_USSD"; |
| 939 | case RIL_E_SS_MODIFIED_TO_DIAL: return "E_SS_MODIFIED_TO_DIAL"; |
| 940 | case RIL_E_SS_MODIFIED_TO_USSD: return "E_SS_MODIFIED_TO_USSD"; |
| 941 | case RIL_E_SUBSCRIPTION_NOT_SUPPORTED: return "E_SUBSCRIPTION_NOT_SUPPORTED"; |
| 942 | case RIL_E_SS_MODIFIED_TO_SS: return "E_SS_MODIFIED_TO_SS"; |
| 943 | case RIL_E_LCE_NOT_SUPPORTED: return "E_LCE_NOT_SUPPORTED"; |
| 944 | case RIL_E_NO_MEMORY: return "E_NO_MEMORY"; |
| 945 | case RIL_E_INTERNAL_ERR: return "E_INTERNAL_ERR"; |
| 946 | case RIL_E_SYSTEM_ERR: return "E_SYSTEM_ERR"; |
| 947 | case RIL_E_MODEM_ERR: return "E_MODEM_ERR"; |
| 948 | case RIL_E_INVALID_STATE: return "E_INVALID_STATE"; |
| 949 | case RIL_E_NO_RESOURCES: return "E_NO_RESOURCES"; |
| 950 | case RIL_E_SIM_ERR: return "E_SIM_ERR"; |
| 951 | case RIL_E_INVALID_ARGUMENTS: return "E_INVALID_ARGUMENTS"; |
| 952 | case RIL_E_INVALID_SIM_STATE: return "E_INVALID_SIM_STATE"; |
| 953 | case RIL_E_INVALID_MODEM_STATE: return "E_INVALID_MODEM_STATE"; |
| 954 | case RIL_E_INVALID_CALL_ID: return "E_INVALID_CALL_ID"; |
| 955 | case RIL_E_NO_SMS_TO_ACK: return "E_NO_SMS_TO_ACK"; |
| 956 | case RIL_E_NETWORK_ERR: return "E_NETWORK_ERR"; |
| 957 | case RIL_E_REQUEST_RATE_LIMITED: return "E_REQUEST_RATE_LIMITED"; |
twen.chang | df7add0 | 2016-03-04 18:27:48 +0800 | [diff] [blame] | 958 | case RIL_E_SIM_BUSY: return "E_SIM_BUSY"; |
| 959 | case RIL_E_SIM_FULL: return "E_SIM_FULL"; |
| 960 | case RIL_E_NETWORK_REJECT: return "E_NETWORK_REJECT"; |
| 961 | case RIL_E_OPERATION_NOT_ALLOWED: return "E_OPERATION_NOT_ALLOWED"; |
| 962 | case RIL_E_EMPTY_RECORD: "E_EMPTY_RECORD"; |
Ajay Nambi | 68900f5 | 2016-03-11 12:02:55 -0800 | [diff] [blame] | 963 | case RIL_E_INVALID_SMS_FORMAT: return "E_INVALID_SMS_FORMAT"; |
| 964 | case RIL_E_ENCODING_ERR: return "E_ENCODING_ERR"; |
| 965 | case RIL_E_INVALID_SMSC_ADDRESS: return "E_INVALID_SMSC_ADDRESS"; |
| 966 | case RIL_E_NO_SUCH_ENTRY: return "E_NO_SUCH_ENTRY"; |
| 967 | case RIL_E_NETWORK_NOT_READY: return "E_NETWORK_NOT_READY"; |
| 968 | case RIL_E_NOT_PROVISIONED: return "E_NOT_PROVISIONED"; |
Ajay Nambi | 1034589 | 2016-03-19 09:02:28 -0700 | [diff] [blame] | 969 | case RIL_E_NO_SUBSCRIPTION: return "E_NO_SUBSCRIPTION"; |
| 970 | case RIL_E_NO_NETWORK_FOUND: return "E_NO_NETWORK_FOUND"; |
| 971 | case RIL_E_DEVICE_IN_USE: return "E_DEVICE_IN_USE"; |
| 972 | case RIL_E_ABORTED: return "E_ABORTED"; |
Sanket Padawe | 85f952a | 2017-01-02 23:46:00 -0800 | [diff] [blame] | 973 | case RIL_E_INVALID_RESPONSE: return "INVALID_RESPONSE"; |
Sanket Padawe | 0106aed | 2016-02-09 09:56:31 -0800 | [diff] [blame] | 974 | case RIL_E_OEM_ERROR_1: return "E_OEM_ERROR_1"; |
| 975 | case RIL_E_OEM_ERROR_2: return "E_OEM_ERROR_2"; |
| 976 | case RIL_E_OEM_ERROR_3: return "E_OEM_ERROR_3"; |
| 977 | case RIL_E_OEM_ERROR_4: return "E_OEM_ERROR_4"; |
| 978 | case RIL_E_OEM_ERROR_5: return "E_OEM_ERROR_5"; |
| 979 | case RIL_E_OEM_ERROR_6: return "E_OEM_ERROR_6"; |
| 980 | case RIL_E_OEM_ERROR_7: return "E_OEM_ERROR_7"; |
| 981 | case RIL_E_OEM_ERROR_8: return "E_OEM_ERROR_8"; |
| 982 | case RIL_E_OEM_ERROR_9: return "E_OEM_ERROR_9"; |
| 983 | case RIL_E_OEM_ERROR_10: return "E_OEM_ERROR_10"; |
| 984 | case RIL_E_OEM_ERROR_11: return "E_OEM_ERROR_11"; |
| 985 | case RIL_E_OEM_ERROR_12: return "E_OEM_ERROR_12"; |
| 986 | case RIL_E_OEM_ERROR_13: return "E_OEM_ERROR_13"; |
| 987 | case RIL_E_OEM_ERROR_14: return "E_OEM_ERROR_14"; |
| 988 | case RIL_E_OEM_ERROR_15: return "E_OEM_ERROR_15"; |
| 989 | case RIL_E_OEM_ERROR_16: return "E_OEM_ERROR_16"; |
| 990 | case RIL_E_OEM_ERROR_17: return "E_OEM_ERROR_17"; |
| 991 | case RIL_E_OEM_ERROR_18: return "E_OEM_ERROR_18"; |
| 992 | case RIL_E_OEM_ERROR_19: return "E_OEM_ERROR_19"; |
| 993 | case RIL_E_OEM_ERROR_20: return "E_OEM_ERROR_20"; |
| 994 | case RIL_E_OEM_ERROR_21: return "E_OEM_ERROR_21"; |
| 995 | case RIL_E_OEM_ERROR_22: return "E_OEM_ERROR_22"; |
| 996 | case RIL_E_OEM_ERROR_23: return "E_OEM_ERROR_23"; |
| 997 | case RIL_E_OEM_ERROR_24: return "E_OEM_ERROR_24"; |
| 998 | 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] | 999 | default: return "<unknown error>"; |
| 1000 | } |
| 1001 | } |
| 1002 | |
| 1003 | const char * |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame] | 1004 | radioStateToString(RIL_RadioState s) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1005 | switch(s) { |
| 1006 | case RADIO_STATE_OFF: return "RADIO_OFF"; |
| 1007 | case RADIO_STATE_UNAVAILABLE: return "RADIO_UNAVAILABLE"; |
Naveen Kalla | 2bc78d6 | 2011-12-07 16:22:53 -0800 | [diff] [blame] | 1008 | case RADIO_STATE_ON:return"RADIO_ON"; |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1009 | default: return "<unknown state>"; |
| 1010 | } |
| 1011 | } |
| 1012 | |
| 1013 | const char * |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame] | 1014 | callStateToString(RIL_CallState s) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1015 | switch(s) { |
| 1016 | case RIL_CALL_ACTIVE : return "ACTIVE"; |
| 1017 | case RIL_CALL_HOLDING: return "HOLDING"; |
| 1018 | case RIL_CALL_DIALING: return "DIALING"; |
| 1019 | case RIL_CALL_ALERTING: return "ALERTING"; |
| 1020 | case RIL_CALL_INCOMING: return "INCOMING"; |
| 1021 | case RIL_CALL_WAITING: return "WAITING"; |
| 1022 | default: return "<unknown state>"; |
| 1023 | } |
| 1024 | } |
| 1025 | |
| 1026 | const char * |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame] | 1027 | requestToString(int request) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1028 | /* |
| 1029 | cat libs/telephony/ril_commands.h \ |
| 1030 | | egrep "^ *{RIL_" \ |
| 1031 | | sed -re 's/\{RIL_([^,]+),[^,]+,([^}]+).+/case RIL_\1: return "\1";/' |
| 1032 | |
| 1033 | |
| 1034 | cat libs/telephony/ril_unsol_commands.h \ |
| 1035 | | egrep "^ *{RIL_" \ |
| 1036 | | sed -re 's/\{RIL_([^,]+),([^}]+).+/case RIL_\1: return "\1";/' |
| 1037 | |
| 1038 | */ |
| 1039 | switch(request) { |
| 1040 | case RIL_REQUEST_GET_SIM_STATUS: return "GET_SIM_STATUS"; |
| 1041 | case RIL_REQUEST_ENTER_SIM_PIN: return "ENTER_SIM_PIN"; |
| 1042 | case RIL_REQUEST_ENTER_SIM_PUK: return "ENTER_SIM_PUK"; |
| 1043 | case RIL_REQUEST_ENTER_SIM_PIN2: return "ENTER_SIM_PIN2"; |
| 1044 | case RIL_REQUEST_ENTER_SIM_PUK2: return "ENTER_SIM_PUK2"; |
| 1045 | case RIL_REQUEST_CHANGE_SIM_PIN: return "CHANGE_SIM_PIN"; |
| 1046 | case RIL_REQUEST_CHANGE_SIM_PIN2: return "CHANGE_SIM_PIN2"; |
| 1047 | case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: return "ENTER_NETWORK_DEPERSONALIZATION"; |
| 1048 | case RIL_REQUEST_GET_CURRENT_CALLS: return "GET_CURRENT_CALLS"; |
| 1049 | case RIL_REQUEST_DIAL: return "DIAL"; |
| 1050 | case RIL_REQUEST_GET_IMSI: return "GET_IMSI"; |
| 1051 | case RIL_REQUEST_HANGUP: return "HANGUP"; |
| 1052 | case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: return "HANGUP_WAITING_OR_BACKGROUND"; |
| 1053 | case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: return "HANGUP_FOREGROUND_RESUME_BACKGROUND"; |
| 1054 | case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: return "SWITCH_WAITING_OR_HOLDING_AND_ACTIVE"; |
| 1055 | case RIL_REQUEST_CONFERENCE: return "CONFERENCE"; |
| 1056 | case RIL_REQUEST_UDUB: return "UDUB"; |
| 1057 | case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: return "LAST_CALL_FAIL_CAUSE"; |
| 1058 | case RIL_REQUEST_SIGNAL_STRENGTH: return "SIGNAL_STRENGTH"; |
Wink Saville | c0114b3 | 2011-02-18 10:14:07 -0800 | [diff] [blame] | 1059 | case RIL_REQUEST_VOICE_REGISTRATION_STATE: return "VOICE_REGISTRATION_STATE"; |
| 1060 | 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] | 1061 | case RIL_REQUEST_OPERATOR: return "OPERATOR"; |
| 1062 | case RIL_REQUEST_RADIO_POWER: return "RADIO_POWER"; |
| 1063 | case RIL_REQUEST_DTMF: return "DTMF"; |
| 1064 | case RIL_REQUEST_SEND_SMS: return "SEND_SMS"; |
| 1065 | case RIL_REQUEST_SEND_SMS_EXPECT_MORE: return "SEND_SMS_EXPECT_MORE"; |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame] | 1066 | 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] | 1067 | case RIL_REQUEST_SIM_IO: return "SIM_IO"; |
| 1068 | case RIL_REQUEST_SEND_USSD: return "SEND_USSD"; |
| 1069 | case RIL_REQUEST_CANCEL_USSD: return "CANCEL_USSD"; |
| 1070 | case RIL_REQUEST_GET_CLIR: return "GET_CLIR"; |
| 1071 | case RIL_REQUEST_SET_CLIR: return "SET_CLIR"; |
| 1072 | case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: return "QUERY_CALL_FORWARD_STATUS"; |
| 1073 | case RIL_REQUEST_SET_CALL_FORWARD: return "SET_CALL_FORWARD"; |
| 1074 | case RIL_REQUEST_QUERY_CALL_WAITING: return "QUERY_CALL_WAITING"; |
| 1075 | case RIL_REQUEST_SET_CALL_WAITING: return "SET_CALL_WAITING"; |
| 1076 | case RIL_REQUEST_SMS_ACKNOWLEDGE: return "SMS_ACKNOWLEDGE"; |
| 1077 | case RIL_REQUEST_GET_IMEI: return "GET_IMEI"; |
| 1078 | case RIL_REQUEST_GET_IMEISV: return "GET_IMEISV"; |
| 1079 | case RIL_REQUEST_ANSWER: return "ANSWER"; |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame] | 1080 | 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] | 1081 | case RIL_REQUEST_QUERY_FACILITY_LOCK: return "QUERY_FACILITY_LOCK"; |
| 1082 | case RIL_REQUEST_SET_FACILITY_LOCK: return "SET_FACILITY_LOCK"; |
| 1083 | case RIL_REQUEST_CHANGE_BARRING_PASSWORD: return "CHANGE_BARRING_PASSWORD"; |
| 1084 | case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: return "QUERY_NETWORK_SELECTION_MODE"; |
| 1085 | case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: return "SET_NETWORK_SELECTION_AUTOMATIC"; |
| 1086 | case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: return "SET_NETWORK_SELECTION_MANUAL"; |
Matt Mower | 897915e | 2015-04-08 23:16:03 -0500 | [diff] [blame] | 1087 | 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] | 1088 | case RIL_REQUEST_DTMF_START: return "DTMF_START"; |
| 1089 | case RIL_REQUEST_DTMF_STOP: return "DTMF_STOP"; |
| 1090 | case RIL_REQUEST_BASEBAND_VERSION: return "BASEBAND_VERSION"; |
| 1091 | case RIL_REQUEST_SEPARATE_CONNECTION: return "SEPARATE_CONNECTION"; |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1092 | case RIL_REQUEST_SET_MUTE: return "SET_MUTE"; |
| 1093 | case RIL_REQUEST_GET_MUTE: return "GET_MUTE"; |
| 1094 | case RIL_REQUEST_QUERY_CLIP: return "QUERY_CLIP"; |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame] | 1095 | case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: return "LAST_DATA_CALL_FAIL_CAUSE"; |
| 1096 | 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] | 1097 | case RIL_REQUEST_RESET_RADIO: return "RESET_RADIO"; |
| 1098 | case RIL_REQUEST_OEM_HOOK_RAW: return "OEM_HOOK_RAW"; |
| 1099 | case RIL_REQUEST_OEM_HOOK_STRINGS: return "OEM_HOOK_STRINGS"; |
Matt Mower | 897915e | 2015-04-08 23:16:03 -0500 | [diff] [blame] | 1100 | case RIL_REQUEST_SCREEN_STATE: return "SCREEN_STATE"; |
| 1101 | case RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION: return "SET_SUPP_SVC_NOTIFICATION"; |
| 1102 | case RIL_REQUEST_WRITE_SMS_TO_SIM: return "WRITE_SMS_TO_SIM"; |
| 1103 | case RIL_REQUEST_DELETE_SMS_ON_SIM: return "DELETE_SMS_ON_SIM"; |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame] | 1104 | case RIL_REQUEST_SET_BAND_MODE: return "SET_BAND_MODE"; |
| 1105 | 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] | 1106 | case RIL_REQUEST_STK_GET_PROFILE: return "STK_GET_PROFILE"; |
| 1107 | case RIL_REQUEST_STK_SET_PROFILE: return "STK_SET_PROFILE"; |
| 1108 | case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: return "STK_SEND_ENVELOPE_COMMAND"; |
| 1109 | case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: return "STK_SEND_TERMINAL_RESPONSE"; |
| 1110 | 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] | 1111 | case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: return "EXPLICIT_CALL_TRANSFER"; |
Matt Mower | 897915e | 2015-04-08 23:16:03 -0500 | [diff] [blame] | 1112 | case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: return "SET_PREFERRED_NETWORK_TYPE"; |
| 1113 | case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: return "GET_PREFERRED_NETWORK_TYPE"; |
| 1114 | 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] | 1115 | case RIL_REQUEST_SET_LOCATION_UPDATES: return "SET_LOCATION_UPDATES"; |
Matt Mower | 897915e | 2015-04-08 23:16:03 -0500 | [diff] [blame] | 1116 | case RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE: return "CDMA_SET_SUBSCRIPTION_SOURCE"; |
| 1117 | case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE: return "CDMA_SET_ROAMING_PREFERENCE"; |
| 1118 | case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE: return "CDMA_QUERY_ROAMING_PREFERENCE"; |
| 1119 | case RIL_REQUEST_SET_TTY_MODE: return "SET_TTY_MODE"; |
| 1120 | case RIL_REQUEST_QUERY_TTY_MODE: return "QUERY_TTY_MODE"; |
| 1121 | case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE: return "CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE"; |
| 1122 | case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE: return "CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE"; |
| 1123 | case RIL_REQUEST_CDMA_FLASH: return "CDMA_FLASH"; |
| 1124 | case RIL_REQUEST_CDMA_BURST_DTMF: return "CDMA_BURST_DTMF"; |
| 1125 | case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: return "CDMA_VALIDATE_AND_WRITE_AKEY"; |
| 1126 | case RIL_REQUEST_CDMA_SEND_SMS: return "CDMA_SEND_SMS"; |
| 1127 | case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE: return "CDMA_SMS_ACKNOWLEDGE"; |
| 1128 | case RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG: return "GSM_GET_BROADCAST_SMS_CONFIG"; |
| 1129 | case RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG: return "GSM_SET_BROADCAST_SMS_CONFIG"; |
| 1130 | case RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION: return "GSM_SMS_BROADCAST_ACTIVATION"; |
| 1131 | case RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG: return "CDMA_GET_BROADCAST_SMS_CONFIG"; |
| 1132 | case RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG: return "CDMA_SET_BROADCAST_SMS_CONFIG"; |
| 1133 | case RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION: return "CDMA_SMS_BROADCAST_ACTIVATION"; |
| 1134 | case RIL_REQUEST_CDMA_SUBSCRIPTION: return "CDMA_SUBSCRIPTION"; |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame] | 1135 | case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: return "CDMA_WRITE_SMS_TO_RUIM"; |
| 1136 | case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: return "CDMA_DELETE_SMS_ON_RUIM"; |
| 1137 | case RIL_REQUEST_DEVICE_IDENTITY: return "DEVICE_IDENTITY"; |
jsh | 000a9fe | 2009-05-11 14:52:35 -0700 | [diff] [blame] | 1138 | case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: return "EXIT_EMERGENCY_CALLBACK_MODE"; |
| 1139 | case RIL_REQUEST_GET_SMSC_ADDRESS: return "GET_SMSC_ADDRESS"; |
| 1140 | case RIL_REQUEST_SET_SMSC_ADDRESS: return "SET_SMSC_ADDRESS"; |
jsh | 09a68ba | 2009-06-10 11:56:38 -0700 | [diff] [blame] | 1141 | case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: return "REPORT_SMS_MEMORY_STATUS"; |
jsh | 563fd72 | 2010-06-08 16:52:24 -0700 | [diff] [blame] | 1142 | 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] | 1143 | case RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE: return "CDMA_GET_SUBSCRIPTION_SOURCE"; |
Jake Hamby | fa8d584 | 2011-08-19 16:22:18 -0700 | [diff] [blame] | 1144 | case RIL_REQUEST_ISIM_AUTHENTICATION: return "ISIM_AUTHENTICATION"; |
Matt Mower | 897915e | 2015-04-08 23:16:03 -0500 | [diff] [blame] | 1145 | case RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU: return "ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU"; |
| 1146 | 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] | 1147 | case RIL_REQUEST_VOICE_RADIO_TECH: return "VOICE_RADIO_TECH"; |
Matt Mower | 897915e | 2015-04-08 23:16:03 -0500 | [diff] [blame] | 1148 | case RIL_REQUEST_GET_CELL_INFO_LIST: return "GET_CELL_INFO_LIST"; |
| 1149 | case RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE: return "SET_UNSOL_CELL_INFO_LIST_RATE"; |
| 1150 | case RIL_REQUEST_SET_INITIAL_ATTACH_APN: return "SET_INITIAL_ATTACH_APN"; |
Sukanya Rajkhowa | a18b9d1 | 2013-09-10 12:30:13 -0700 | [diff] [blame] | 1151 | case RIL_REQUEST_IMS_REGISTRATION_STATE: return "IMS_REGISTRATION_STATE"; |
| 1152 | case RIL_REQUEST_IMS_SEND_SMS: return "IMS_SEND_SMS"; |
Shishir Agrawal | 2458d8d | 2013-11-27 14:53:05 -0800 | [diff] [blame] | 1153 | case RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC: return "SIM_TRANSMIT_APDU_BASIC"; |
| 1154 | case RIL_REQUEST_SIM_OPEN_CHANNEL: return "SIM_OPEN_CHANNEL"; |
| 1155 | case RIL_REQUEST_SIM_CLOSE_CHANNEL: return "SIM_CLOSE_CHANNEL"; |
| 1156 | case RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL: return "SIM_TRANSMIT_APDU_CHANNEL"; |
Matt Mower | 897915e | 2015-04-08 23:16:03 -0500 | [diff] [blame] | 1157 | case RIL_REQUEST_NV_READ_ITEM: return "NV_READ_ITEM"; |
| 1158 | case RIL_REQUEST_NV_WRITE_ITEM: return "NV_WRITE_ITEM"; |
| 1159 | case RIL_REQUEST_NV_WRITE_CDMA_PRL: return "NV_WRITE_CDMA_PRL"; |
| 1160 | case RIL_REQUEST_NV_RESET_CONFIG: return "NV_RESET_CONFIG"; |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 1161 | case RIL_REQUEST_SET_UICC_SUBSCRIPTION: return "SET_UICC_SUBSCRIPTION"; |
| 1162 | case RIL_REQUEST_ALLOW_DATA: return "ALLOW_DATA"; |
Amit Mahajan | 2b77203 | 2014-06-26 14:20:11 -0700 | [diff] [blame] | 1163 | case RIL_REQUEST_GET_HARDWARE_CONFIG: return "GET_HARDWARE_CONFIG"; |
| 1164 | case RIL_REQUEST_SIM_AUTHENTICATION: return "SIM_AUTHENTICATION"; |
Wink Saville | c29360a | 2014-07-13 05:17:28 -0700 | [diff] [blame] | 1165 | case RIL_REQUEST_GET_DC_RT_INFO: return "GET_DC_RT_INFO"; |
| 1166 | 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] | 1167 | case RIL_REQUEST_SET_DATA_PROFILE: return "SET_DATA_PROFILE"; |
Matt Mower | 897915e | 2015-04-08 23:16:03 -0500 | [diff] [blame] | 1168 | case RIL_REQUEST_SHUTDOWN: return "SHUTDOWN"; |
| 1169 | case RIL_REQUEST_GET_RADIO_CAPABILITY: return "GET_RADIO_CAPABILITY"; |
| 1170 | case RIL_REQUEST_SET_RADIO_CAPABILITY: return "SET_RADIO_CAPABILITY"; |
| 1171 | case RIL_REQUEST_START_LCE: return "START_LCE"; |
| 1172 | case RIL_REQUEST_STOP_LCE: return "STOP_LCE"; |
| 1173 | case RIL_REQUEST_PULL_LCEDATA: return "PULL_LCEDATA"; |
| 1174 | case RIL_REQUEST_GET_ACTIVITY_INFO: return "GET_ACTIVITY_INFO"; |
Meng Wang | b4e3431 | 2016-05-12 14:54:36 -0700 | [diff] [blame] | 1175 | case RIL_REQUEST_SET_CARRIER_RESTRICTIONS: return "SET_CARRIER_RESTRICTIONS"; |
| 1176 | case RIL_REQUEST_GET_CARRIER_RESTRICTIONS: return "GET_CARRIER_RESTRICTIONS"; |
Matt Mower | 897915e | 2015-04-08 23:16:03 -0500 | [diff] [blame] | 1177 | case RIL_RESPONSE_ACKNOWLEDGEMENT: return "RESPONSE_ACKNOWLEDGEMENT"; |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1178 | case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return "UNSOL_RESPONSE_RADIO_STATE_CHANGED"; |
| 1179 | 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] | 1180 | 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] | 1181 | case RIL_UNSOL_RESPONSE_NEW_SMS: return "UNSOL_RESPONSE_NEW_SMS"; |
| 1182 | case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: return "UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT"; |
| 1183 | case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: return "UNSOL_RESPONSE_NEW_SMS_ON_SIM"; |
| 1184 | case RIL_UNSOL_ON_USSD: return "UNSOL_ON_USSD"; |
Matt Mower | 897915e | 2015-04-08 23:16:03 -0500 | [diff] [blame] | 1185 | 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] | 1186 | case RIL_UNSOL_NITZ_TIME_RECEIVED: return "UNSOL_NITZ_TIME_RECEIVED"; |
| 1187 | case RIL_UNSOL_SIGNAL_STRENGTH: return "UNSOL_SIGNAL_STRENGTH"; |
Matt Mower | 897915e | 2015-04-08 23:16:03 -0500 | [diff] [blame] | 1188 | 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] | 1189 | 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] | 1190 | case RIL_UNSOL_STK_SESSION_END: return "UNSOL_STK_SESSION_END"; |
| 1191 | case RIL_UNSOL_STK_PROACTIVE_COMMAND: return "UNSOL_STK_PROACTIVE_COMMAND"; |
| 1192 | case RIL_UNSOL_STK_EVENT_NOTIFY: return "UNSOL_STK_EVENT_NOTIFY"; |
| 1193 | case RIL_UNSOL_STK_CALL_SETUP: return "UNSOL_STK_CALL_SETUP"; |
Matt Mower | 897915e | 2015-04-08 23:16:03 -0500 | [diff] [blame] | 1194 | 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] | 1195 | case RIL_UNSOL_SIM_REFRESH: return "UNSOL_SIM_REFRESH"; |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1196 | case RIL_UNSOL_CALL_RING: return "UNSOL_CALL_RING"; |
Wink Saville | f4c4d36 | 2009-04-02 01:37:03 -0700 | [diff] [blame] | 1197 | 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] | 1198 | case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: return "UNSOL_RESPONSE_CDMA_NEW_SMS"; |
| 1199 | 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] | 1200 | 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] | 1201 | case RIL_UNSOL_RESTRICTED_STATE_CHANGED: return "UNSOL_RESTRICTED_STATE_CHANGED"; |
| 1202 | case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: return "UNSOL_ENTER_EMERGENCY_CALLBACK_MODE"; |
| 1203 | case RIL_UNSOL_CDMA_CALL_WAITING: return "UNSOL_CDMA_CALL_WAITING"; |
| 1204 | case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: return "UNSOL_CDMA_OTA_PROVISION_STATUS"; |
| 1205 | case RIL_UNSOL_CDMA_INFO_REC: return "UNSOL_CDMA_INFO_REC"; |
Jaikumar Ganesh | af6ecbf | 2009-04-29 13:27:51 -0700 | [diff] [blame] | 1206 | case RIL_UNSOL_OEM_HOOK_RAW: return "UNSOL_OEM_HOOK_RAW"; |
John Wang | 5d621da | 2009-09-18 17:17:48 -0700 | [diff] [blame] | 1207 | case RIL_UNSOL_RINGBACK_TONE: return "UNSOL_RINGBACK_TONE"; |
John Wang | 5909cf8 | 2010-01-29 00:18:54 -0800 | [diff] [blame] | 1208 | case RIL_UNSOL_RESEND_INCALL_MUTE: return "UNSOL_RESEND_INCALL_MUTE"; |
Wink Saville | ee27458 | 2011-04-16 15:05:49 -0700 | [diff] [blame] | 1209 | 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] | 1210 | case RIL_UNSOL_CDMA_PRL_CHANGED: return "UNSOL_CDMA_PRL_CHANGED"; |
| 1211 | 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] | 1212 | case RIL_UNSOL_RIL_CONNECTED: return "UNSOL_RIL_CONNECTED"; |
Naveen Kalla | 2bc78d6 | 2011-12-07 16:22:53 -0800 | [diff] [blame] | 1213 | 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] | 1214 | case RIL_UNSOL_CELL_INFO_LIST: return "UNSOL_CELL_INFO_LIST"; |
Matt Mower | 897915e | 2015-04-08 23:16:03 -0500 | [diff] [blame] | 1215 | 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] | 1216 | case RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED: return "UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED"; |
| 1217 | case RIL_UNSOL_SRVCC_STATE_NOTIFY: return "UNSOL_SRVCC_STATE_NOTIFY"; |
Matt Mower | 897915e | 2015-04-08 23:16:03 -0500 | [diff] [blame] | 1218 | case RIL_UNSOL_HARDWARE_CONFIG_CHANGED: return "UNSOL_HARDWARE_CONFIG_CHANGED"; |
Wink Saville | c29360a | 2014-07-13 05:17:28 -0700 | [diff] [blame] | 1219 | 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] | 1220 | case RIL_UNSOL_RADIO_CAPABILITY: return "UNSOL_RADIO_CAPABILITY"; |
Mark Salyzyn | 0078c8d | 2016-12-12 14:41:47 -0800 | [diff] [blame] | 1221 | case RIL_UNSOL_MODEM_RESTART: return "UNSOL_MODEM_RESTART"; |
Matt Mower | 897915e | 2015-04-08 23:16:03 -0500 | [diff] [blame] | 1222 | case RIL_UNSOL_ON_SS: return "UNSOL_ON_SS"; |
| 1223 | case RIL_UNSOL_STK_CC_ALPHA_NOTIFY: return "UNSOL_STK_CC_ALPHA_NOTIFY"; |
| 1224 | case RIL_UNSOL_LCEDATA_RECV: return "UNSOL_LCEDATA_RECV"; |
| 1225 | case RIL_UNSOL_PCO_DATA: return "UNSOL_PCO_DATA"; |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1226 | default: return "<unknown request>"; |
| 1227 | } |
| 1228 | } |
| 1229 | |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 1230 | const char * |
| 1231 | rilSocketIdToString(RIL_SOCKET_ID socket_id) |
| 1232 | { |
| 1233 | switch(socket_id) { |
| 1234 | case RIL_SOCKET_1: |
| 1235 | return "RIL_SOCKET_1"; |
| 1236 | #if (SIM_COUNT >= 2) |
| 1237 | case RIL_SOCKET_2: |
| 1238 | return "RIL_SOCKET_2"; |
| 1239 | #endif |
| 1240 | #if (SIM_COUNT >= 3) |
| 1241 | case RIL_SOCKET_3: |
| 1242 | return "RIL_SOCKET_3"; |
| 1243 | #endif |
| 1244 | #if (SIM_COUNT >= 4) |
| 1245 | case RIL_SOCKET_4: |
| 1246 | return "RIL_SOCKET_4"; |
| 1247 | #endif |
| 1248 | default: |
| 1249 | return "not a valid RIL"; |
| 1250 | } |
| 1251 | } |
| 1252 | |
Amit Mahajan | bd5595a | 2017-03-28 11:17:55 -0700 | [diff] [blame] | 1253 | } /* namespace android */ |