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