The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 1 | /* //device/system/rild/rild.c |
| 2 | ** |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 3 | ** Copyright 2006 The Android Open Source Project |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 4 | ** |
| 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 |
| 8 | ** |
| 9 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | ** |
| 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 |
| 15 | ** limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #include <stdio.h> |
| 19 | #include <stdlib.h> |
| 20 | #include <dlfcn.h> |
| 21 | #include <string.h> |
| 22 | #include <stdint.h> |
| 23 | #include <unistd.h> |
| 24 | #include <fcntl.h> |
| 25 | #include <errno.h> |
| 26 | |
| 27 | #include <telephony/ril.h> |
| 28 | #define LOG_TAG "RILD" |
| 29 | #include <utils/Log.h> |
| 30 | #include <cutils/properties.h> |
| 31 | #include <cutils/sockets.h> |
Nick Kralevich | fe4e1ec | 2013-02-28 14:16:41 -0800 | [diff] [blame] | 32 | #include <sys/capability.h> |
Elliott Hughes | 5d0cb9e | 2014-07-18 17:55:52 -0700 | [diff] [blame] | 33 | #include <sys/prctl.h> |
Andreas Gampe | 8ded996 | 2015-04-06 12:20:24 -0700 | [diff] [blame] | 34 | #include <sys/stat.h> |
| 35 | #include <sys/types.h> |
Dheeraj Shetty | 27976c4 | 2014-07-02 21:27:57 +0200 | [diff] [blame] | 36 | #include <libril/ril_ex.h> |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 37 | |
| 38 | #include <private/android_filesystem_config.h> |
Vladimir Chtchetkine | 385a739 | 2011-08-04 14:03:07 -0700 | [diff] [blame] | 39 | #include "hardware/qemu_pipe.h" |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 40 | |
| 41 | #define LIB_PATH_PROPERTY "rild.libpath" |
| 42 | #define LIB_ARGS_PROPERTY "rild.libargs" |
| 43 | #define MAX_LIB_ARGS 16 |
Sukanya Rajkhowa | 40aa126 | 2015-01-14 17:56:25 -0800 | [diff] [blame] | 44 | #define MAX_CAP_NUM (CAP_TO_INDEX(CAP_LAST_CAP) + 1) |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 45 | |
Dheeraj Shetty | 27976c4 | 2014-07-02 21:27:57 +0200 | [diff] [blame] | 46 | static void usage(const char *argv0) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 47 | fprintf(stderr, "Usage: %s -l <ril impl library> [-- <args for impl library>]\n", argv0); |
Elliott Hughes | e2a70cf | 2013-11-20 13:51:45 -0800 | [diff] [blame] | 48 | exit(EXIT_FAILURE); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 49 | } |
| 50 | |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 51 | extern char rild[MAX_SOCKET_NAME_LENGTH]; |
| 52 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 53 | extern void RIL_register (const RIL_RadioFunctions *callbacks); |
| 54 | |
Dheeraj Shetty | 27976c4 | 2014-07-02 21:27:57 +0200 | [diff] [blame] | 55 | extern void RIL_register_socket (RIL_RadioFunctions *(*rilUimInit) |
| 56 | (const struct RIL_Env *, int, char **), RIL_SOCKET_TYPE socketType, int argc, char **argv); |
| 57 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 58 | extern void RIL_onRequestComplete(RIL_Token t, RIL_Errno e, |
Dheeraj Shetty | 27976c4 | 2014-07-02 21:27:57 +0200 | [diff] [blame] | 59 | void *response, size_t responselen); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 60 | |
Sanket Padawe | 6ff9a87 | 2016-01-27 15:09:12 -0800 | [diff] [blame] | 61 | extern void RIL_onRequestAck(RIL_Token t); |
| 62 | |
Elliott Hughes | e102e95 | 2015-02-20 10:52:14 -0800 | [diff] [blame] | 63 | extern void RIL_setRilSocketName(char *); |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 64 | |
| 65 | #if defined(ANDROID_MULTI_SIM) |
| 66 | extern void RIL_onUnsolicitedResponse(int unsolResponse, const void *data, |
Dheeraj Shetty | 27976c4 | 2014-07-02 21:27:57 +0200 | [diff] [blame] | 67 | size_t datalen, RIL_SOCKET_ID socket_id); |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 68 | #else |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 69 | extern void RIL_onUnsolicitedResponse(int unsolResponse, const void *data, |
Dheeraj Shetty | 27976c4 | 2014-07-02 21:27:57 +0200 | [diff] [blame] | 70 | size_t datalen); |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 71 | #endif |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 72 | |
Wink Saville | 2932f31 | 2010-10-07 16:35:15 -0700 | [diff] [blame] | 73 | extern void RIL_requestTimedCallback (RIL_TimedCallback callback, |
Dheeraj Shetty | 27976c4 | 2014-07-02 21:27:57 +0200 | [diff] [blame] | 74 | void *param, const struct timeval *relativeTime); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 75 | |
| 76 | |
| 77 | static struct RIL_Env s_rilEnv = { |
| 78 | RIL_onRequestComplete, |
| 79 | RIL_onUnsolicitedResponse, |
Sanket Padawe | 6ff9a87 | 2016-01-27 15:09:12 -0800 | [diff] [blame] | 80 | RIL_requestTimedCallback, |
| 81 | RIL_onRequestAck |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 82 | }; |
| 83 | |
| 84 | extern void RIL_startEventLoop(); |
| 85 | |
Dheeraj Shetty | 27976c4 | 2014-07-02 21:27:57 +0200 | [diff] [blame] | 86 | static int make_argv(char * args, char ** argv) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 87 | // Note: reserve argv[0] |
| 88 | int count = 1; |
| 89 | char * tok; |
| 90 | char * s = args; |
| 91 | |
| 92 | while ((tok = strtok(s, " \0"))) { |
| 93 | argv[count] = tok; |
| 94 | s = NULL; |
| 95 | count++; |
| 96 | } |
| 97 | return count; |
| 98 | } |
| 99 | |
| 100 | /* |
| 101 | * switchUser - Switches UID to radio, preserving CAP_NET_ADMIN capabilities. |
| 102 | * Our group, cache, was set by init. |
| 103 | */ |
| 104 | void switchUser() { |
Julien Vuillaumier | faf4676 | 2015-01-22 13:42:58 +0000 | [diff] [blame] | 105 | char debuggable[PROP_VALUE_MAX]; |
| 106 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 107 | prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0); |
| 108 | setuid(AID_RADIO); |
| 109 | |
| 110 | struct __user_cap_header_struct header; |
Elliott Hughes | e2a70cf | 2013-11-20 13:51:45 -0800 | [diff] [blame] | 111 | memset(&header, 0, sizeof(header)); |
| 112 | header.version = _LINUX_CAPABILITY_VERSION_3; |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 113 | header.pid = 0; |
Elliott Hughes | e2a70cf | 2013-11-20 13:51:45 -0800 | [diff] [blame] | 114 | |
Sukanya Rajkhowa | 40aa126 | 2015-01-14 17:56:25 -0800 | [diff] [blame] | 115 | struct __user_cap_data_struct data[MAX_CAP_NUM]; |
Elliott Hughes | e2a70cf | 2013-11-20 13:51:45 -0800 | [diff] [blame] | 116 | memset(&data, 0, sizeof(data)); |
| 117 | |
| 118 | data[CAP_TO_INDEX(CAP_NET_ADMIN)].effective |= CAP_TO_MASK(CAP_NET_ADMIN); |
| 119 | data[CAP_TO_INDEX(CAP_NET_ADMIN)].permitted |= CAP_TO_MASK(CAP_NET_ADMIN); |
| 120 | |
| 121 | data[CAP_TO_INDEX(CAP_NET_RAW)].effective |= CAP_TO_MASK(CAP_NET_RAW); |
| 122 | data[CAP_TO_INDEX(CAP_NET_RAW)].permitted |= CAP_TO_MASK(CAP_NET_RAW); |
| 123 | |
Sukanya Rajkhowa | 40aa126 | 2015-01-14 17:56:25 -0800 | [diff] [blame] | 124 | data[CAP_TO_INDEX(CAP_BLOCK_SUSPEND)].effective |= CAP_TO_MASK(CAP_BLOCK_SUSPEND); |
| 125 | data[CAP_TO_INDEX(CAP_BLOCK_SUSPEND)].permitted |= CAP_TO_MASK(CAP_BLOCK_SUSPEND); |
| 126 | |
Elliott Hughes | e2a70cf | 2013-11-20 13:51:45 -0800 | [diff] [blame] | 127 | if (capset(&header, &data[0]) == -1) { |
| 128 | RLOGE("capset failed: %s", strerror(errno)); |
| 129 | exit(EXIT_FAILURE); |
| 130 | } |
Julien Vuillaumier | faf4676 | 2015-01-22 13:42:58 +0000 | [diff] [blame] | 131 | |
| 132 | /* |
| 133 | * Debuggable build only: |
| 134 | * Set DUMPABLE that was cleared by setuid() to have tombstone on RIL crash |
| 135 | */ |
| 136 | property_get("ro.debuggable", debuggable, "0"); |
| 137 | if (strcmp(debuggable, "1") == 0) { |
| 138 | prctl(PR_SET_DUMPABLE, 1, 0, 0, 0); |
| 139 | } |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 140 | } |
| 141 | |
Dheeraj Shetty | 27976c4 | 2014-07-02 21:27:57 +0200 | [diff] [blame] | 142 | int main(int argc, char **argv) { |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 143 | const char * rilLibPath = NULL; |
| 144 | char **rilArgv; |
| 145 | void *dlHandle; |
| 146 | const RIL_RadioFunctions *(*rilInit)(const struct RIL_Env *, int, char **); |
Dheeraj Shetty | 27976c4 | 2014-07-02 21:27:57 +0200 | [diff] [blame] | 147 | const RIL_RadioFunctions *(*rilUimInit)(const struct RIL_Env *, int, char **); |
| 148 | char *err_str = NULL; |
| 149 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 150 | const RIL_RadioFunctions *funcs; |
| 151 | char libPath[PROPERTY_VALUE_MAX]; |
| 152 | unsigned char hasLibArgs = 0; |
| 153 | |
| 154 | int i; |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 155 | const char *clientId = NULL; |
| 156 | RLOGD("**RIL Daemon Started**"); |
| 157 | RLOGD("**RILd param count=%d**", argc); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 158 | |
Nick Kralevich | aea7d5b | 2010-12-10 15:53:02 -0800 | [diff] [blame] | 159 | umask(S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 160 | for (i = 1; i < argc ;) { |
| 161 | if (0 == strcmp(argv[i], "-l") && (argc - i > 1)) { |
| 162 | rilLibPath = argv[i + 1]; |
| 163 | i += 2; |
| 164 | } else if (0 == strcmp(argv[i], "--")) { |
| 165 | i++; |
| 166 | hasLibArgs = 1; |
| 167 | break; |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 168 | } else if (0 == strcmp(argv[i], "-c") && (argc - i > 1)) { |
| 169 | clientId = argv[i+1]; |
| 170 | i += 2; |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 171 | } else { |
| 172 | usage(argv[0]); |
| 173 | } |
| 174 | } |
| 175 | |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 176 | if (clientId == NULL) { |
| 177 | clientId = "0"; |
| 178 | } else if (atoi(clientId) >= MAX_RILDS) { |
| 179 | RLOGE("Max Number of rild's supported is: %d", MAX_RILDS); |
| 180 | exit(0); |
| 181 | } |
| 182 | if (strncmp(clientId, "0", MAX_CLIENT_ID_LENGTH)) { |
| 183 | RIL_setRilSocketName(strncat(rild, clientId, MAX_SOCKET_NAME_LENGTH)); |
| 184 | } |
| 185 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 186 | if (rilLibPath == NULL) { |
| 187 | if ( 0 == property_get(LIB_PATH_PROPERTY, libPath, NULL)) { |
| 188 | // No lib sepcified on the command line, and nothing set in props. |
| 189 | // Assume "no-ril" case. |
| 190 | goto done; |
| 191 | } else { |
| 192 | rilLibPath = libPath; |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | /* special override when in the emulator */ |
| 197 | #if 1 |
| 198 | { |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 199 | static char* arg_overrides[5]; |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 200 | static char arg_device[32]; |
| 201 | int done = 0; |
| 202 | |
Vince Harron | 60c1f5b | 2014-08-13 23:12:37 -0700 | [diff] [blame] | 203 | #define REFERENCE_RIL_PATH "libreference-ril.so" |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 204 | |
| 205 | /* first, read /proc/cmdline into memory */ |
Ajay Nambi | f980863 | 2016-01-15 10:57:52 -0800 | [diff] [blame] | 206 | char buffer[1024] = {'\0'}, *p, *q; |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 207 | int len; |
| 208 | int fd = open("/proc/cmdline",O_RDONLY); |
| 209 | |
| 210 | if (fd < 0) { |
Wink Saville | 8eb2a12 | 2012-11-19 16:05:13 -0800 | [diff] [blame] | 211 | RLOGD("could not open /proc/cmdline:%s", strerror(errno)); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 212 | goto OpenLib; |
| 213 | } |
| 214 | |
| 215 | do { |
| 216 | len = read(fd,buffer,sizeof(buffer)); } |
| 217 | while (len == -1 && errno == EINTR); |
| 218 | |
| 219 | if (len < 0) { |
Wink Saville | 8eb2a12 | 2012-11-19 16:05:13 -0800 | [diff] [blame] | 220 | RLOGD("could not read /proc/cmdline:%s", strerror(errno)); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 221 | close(fd); |
| 222 | goto OpenLib; |
| 223 | } |
| 224 | close(fd); |
| 225 | |
| 226 | if (strstr(buffer, "android.qemud=") != NULL) |
| 227 | { |
| 228 | /* the qemud daemon is launched after rild, so |
| 229 | * give it some time to create its GSM socket |
| 230 | */ |
| 231 | int tries = 5; |
The Android Open Source Project | e6e6fb2 | 2009-03-18 17:39:47 -0700 | [diff] [blame] | 232 | #define QEMUD_SOCKET_NAME "qemud" |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 233 | |
| 234 | while (1) { |
| 235 | int fd; |
| 236 | |
| 237 | sleep(1); |
| 238 | |
Vladimir Chtchetkine | 385a739 | 2011-08-04 14:03:07 -0700 | [diff] [blame] | 239 | fd = qemu_pipe_open("qemud:gsm"); |
| 240 | if (fd < 0) { |
| 241 | fd = socket_local_client( |
| 242 | QEMUD_SOCKET_NAME, |
| 243 | ANDROID_SOCKET_NAMESPACE_RESERVED, |
| 244 | SOCK_STREAM ); |
| 245 | } |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 246 | if (fd >= 0) { |
| 247 | close(fd); |
| 248 | snprintf( arg_device, sizeof(arg_device), "%s/%s", |
| 249 | ANDROID_SOCKET_DIR, QEMUD_SOCKET_NAME ); |
| 250 | |
| 251 | arg_overrides[1] = "-s"; |
| 252 | arg_overrides[2] = arg_device; |
| 253 | done = 1; |
| 254 | break; |
| 255 | } |
Wink Saville | 8eb2a12 | 2012-11-19 16:05:13 -0800 | [diff] [blame] | 256 | RLOGD("could not connect to %s socket: %s", |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 257 | QEMUD_SOCKET_NAME, strerror(errno)); |
| 258 | if (--tries == 0) |
| 259 | break; |
| 260 | } |
| 261 | if (!done) { |
Wink Saville | 8eb2a12 | 2012-11-19 16:05:13 -0800 | [diff] [blame] | 262 | RLOGE("could not connect to %s socket (giving up): %s", |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 263 | QEMUD_SOCKET_NAME, strerror(errno)); |
| 264 | while(1) |
| 265 | sleep(0x00ffffff); |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | /* otherwise, try to see if we passed a device name from the kernel */ |
| 270 | if (!done) do { |
| 271 | #define KERNEL_OPTION "android.ril=" |
| 272 | #define DEV_PREFIX "/dev/" |
| 273 | |
| 274 | p = strstr( buffer, KERNEL_OPTION ); |
| 275 | if (p == NULL) |
| 276 | break; |
| 277 | |
| 278 | p += sizeof(KERNEL_OPTION)-1; |
| 279 | q = strpbrk( p, " \t\n\r" ); |
| 280 | if (q != NULL) |
| 281 | *q = 0; |
| 282 | |
| 283 | snprintf( arg_device, sizeof(arg_device), DEV_PREFIX "%s", p ); |
| 284 | arg_device[sizeof(arg_device)-1] = 0; |
| 285 | arg_overrides[1] = "-d"; |
| 286 | arg_overrides[2] = arg_device; |
| 287 | done = 1; |
| 288 | |
| 289 | } while (0); |
| 290 | |
| 291 | if (done) { |
| 292 | argv = arg_overrides; |
| 293 | argc = 3; |
| 294 | i = 1; |
| 295 | hasLibArgs = 1; |
| 296 | rilLibPath = REFERENCE_RIL_PATH; |
| 297 | |
Wink Saville | 8eb2a12 | 2012-11-19 16:05:13 -0800 | [diff] [blame] | 298 | RLOGD("overriding with %s %s", arg_overrides[1], arg_overrides[2]); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 299 | } |
| 300 | } |
| 301 | OpenLib: |
| 302 | #endif |
| 303 | switchUser(); |
| 304 | |
| 305 | dlHandle = dlopen(rilLibPath, RTLD_NOW); |
| 306 | |
| 307 | if (dlHandle == NULL) { |
Wink Saville | 8eb2a12 | 2012-11-19 16:05:13 -0800 | [diff] [blame] | 308 | RLOGE("dlopen failed: %s", dlerror()); |
Elliott Hughes | e2a70cf | 2013-11-20 13:51:45 -0800 | [diff] [blame] | 309 | exit(EXIT_FAILURE); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | RIL_startEventLoop(); |
| 313 | |
Dheeraj Shetty | 27976c4 | 2014-07-02 21:27:57 +0200 | [diff] [blame] | 314 | rilInit = |
| 315 | (const RIL_RadioFunctions *(*)(const struct RIL_Env *, int, char **)) |
| 316 | dlsym(dlHandle, "RIL_Init"); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 317 | |
| 318 | if (rilInit == NULL) { |
Wink Saville | 8eb2a12 | 2012-11-19 16:05:13 -0800 | [diff] [blame] | 319 | RLOGE("RIL_Init not defined or exported in %s\n", rilLibPath); |
Elliott Hughes | e2a70cf | 2013-11-20 13:51:45 -0800 | [diff] [blame] | 320 | exit(EXIT_FAILURE); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 321 | } |
| 322 | |
Dheeraj Shetty | 27976c4 | 2014-07-02 21:27:57 +0200 | [diff] [blame] | 323 | dlerror(); // Clear any previous dlerror |
| 324 | rilUimInit = |
| 325 | (const RIL_RadioFunctions *(*)(const struct RIL_Env *, int, char **)) |
| 326 | dlsym(dlHandle, "RIL_SAP_Init"); |
| 327 | err_str = dlerror(); |
| 328 | if (err_str) { |
| 329 | RLOGW("RIL_SAP_Init not defined or exported in %s: %s\n", rilLibPath, err_str); |
| 330 | } else if (!rilUimInit) { |
| 331 | RLOGW("RIL_SAP_Init defined as null in %s. SAP Not usable\n", rilLibPath); |
| 332 | } |
| 333 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 334 | if (hasLibArgs) { |
| 335 | rilArgv = argv + i - 1; |
| 336 | argc = argc -i + 1; |
| 337 | } else { |
| 338 | static char * newArgv[MAX_LIB_ARGS]; |
| 339 | static char args[PROPERTY_VALUE_MAX]; |
| 340 | rilArgv = newArgv; |
| 341 | property_get(LIB_ARGS_PROPERTY, args, ""); |
| 342 | argc = make_argv(args, rilArgv); |
| 343 | } |
| 344 | |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 345 | rilArgv[argc++] = "-c"; |
| 346 | rilArgv[argc++] = clientId; |
| 347 | RLOGD("RIL_Init argc = %d clientId = %s", argc, rilArgv[argc-1]); |
| 348 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 349 | // Make sure there's a reasonable argv[0] |
| 350 | rilArgv[0] = argv[0]; |
| 351 | |
| 352 | funcs = rilInit(&s_rilEnv, argc, rilArgv); |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 353 | RLOGD("RIL_Init rilInit completed"); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 354 | |
| 355 | RIL_register(funcs); |
| 356 | |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 357 | RLOGD("RIL_Init RIL_register completed"); |
| 358 | |
Dheeraj Shetty | 27976c4 | 2014-07-02 21:27:57 +0200 | [diff] [blame] | 359 | if (rilUimInit) { |
| 360 | RLOGD("RIL_register_socket started"); |
| 361 | RIL_register_socket(rilUimInit, RIL_SAP_SOCKET, argc, rilArgv); |
| 362 | } |
| 363 | |
| 364 | RLOGD("RIL_register_socket completed"); |
| 365 | |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 366 | done: |
| 367 | |
Etan Cohen | d365219 | 2014-06-20 08:28:44 -0700 | [diff] [blame] | 368 | RLOGD("RIL_Init starting sleep loop"); |
Elliott Hughes | 164d205 | 2013-11-20 14:53:08 -0800 | [diff] [blame] | 369 | while (true) { |
| 370 | sleep(UINT32_MAX); |
The Android Open Source Project | 00f06fc | 2009-03-03 19:32:15 -0800 | [diff] [blame] | 371 | } |
| 372 | } |