summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSrikanth Chintala <srikchin@codeaurora.org>2012-01-19 17:52:31 +0530
committerLinux Build Service Account <lnxbuild@localhost>2013-10-31 19:03:42 -0600
commit62851c62760ef6d098ba8ccc839f912431c9ef01 (patch)
treea3fa1c94e82e6ae265da4e61383a0e1bb0c231d8
parent19be06d4fc1f21db76b6c23514a3ff12c5136c56 (diff)
downloadandroid_hardware_ril-62851c62760ef6d098ba8ccc839f912431c9ef01.tar.gz
android_hardware_ril-62851c62760ef6d098ba8ccc839f912431c9ef01.tar.bz2
android_hardware_ril-62851c62760ef6d098ba8ccc839f912431c9ef01.zip
Add Multi RILD support.
Support Multiple instances of RILD identified by the arguments passed to RILD Change-Id: I3ac00242aed7fd40e3b7a71d00f906e7c9805c7c Conflicts: reference-ril/reference-ril.c (cherry picked from commit 424e8db95c9d483dcefcbd8d861364f1589e8dd1)
-rw-r--r--include/telephony/ril.h8
-rwxr-xr-xlibril/ril.cpp30
-rw-r--r--reference-ril/reference-ril.c20
-rw-r--r--rild/rild.c28
4 files changed, 76 insertions, 10 deletions
diff --git a/include/telephony/ril.h b/include/telephony/ril.h
index 84708ee..9648f7a 100644
--- a/include/telephony/ril.h
+++ b/include/telephony/ril.h
@@ -1,4 +1,6 @@
/*
+ * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+ * Not a Contribution
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -34,6 +36,12 @@ extern "C" {
#define CDMA_ALPHA_INFO_BUFFER_LENGTH 64
#define CDMA_NUMBER_INFO_BUFFER_LENGTH 81
+#define MAX_RILDS 3
+#define MAX_SOCKET_NAME_LENGTH 6
+#define MAX_CLIENT_ID_LENGTH 2
+#define MAX_DEBUG_SOCKET_NAME_LENGTH 12
+#define MAX_QEMU_PIPE_NAME_LENGTH 11
+
typedef void * RIL_Token;
typedef enum {
diff --git a/libril/ril.cpp b/libril/ril.cpp
index 4580326..7ebf75b 100755
--- a/libril/ril.cpp
+++ b/libril/ril.cpp
@@ -143,7 +143,8 @@ typedef struct UserCallbackInfo {
struct UserCallbackInfo *p_next;
} UserCallbackInfo;
-
+extern "C"
+char rild[MAX_SOCKET_NAME_LENGTH] = SOCKET_NAME_RIL;
/*******************************************************************/
RIL_RadioFunctions s_callbacks = {0, NULL, NULL, NULL, NULL, NULL};
@@ -290,6 +291,15 @@ int cdmaSubscriptionSource = -1;
*/
int simRuimStatus = -1;
+static char * RIL_getRilSocketName() {
+ return rild;
+}
+
+extern "C"
+void RIL_setRilSocketName(char * s) {
+ strncpy(rild, s, MAX_SOCKET_NAME_LENGTH);
+}
+
static char *
strdupReadString(Parcel &p) {
size_t stringlen;
@@ -3326,9 +3336,9 @@ RIL_register (const RIL_RadioFunctions *callbacks) {
s_fdListen = ret;
#else
- s_fdListen = android_get_control_socket(SOCKET_NAME_RIL);
+ s_fdListen = android_get_control_socket(RIL_getRilSocketName());
if (s_fdListen < 0) {
- RLOGE("Failed to get socket '" SOCKET_NAME_RIL "'");
+ RLOGE("Failed to get socket %s",RIL_getRilSocketName());
exit(-1);
}
@@ -3351,9 +3361,19 @@ RIL_register (const RIL_RadioFunctions *callbacks) {
#if 1
// start debug interface socket
- s_fdDebug = android_get_control_socket(SOCKET_NAME_RIL_DEBUG);
+ char *inst = NULL;
+ if (strlen(RIL_getRilSocketName()) >= strlen(SOCKET_NAME_RIL)) {
+ inst = RIL_getRilSocketName() + strlen(SOCKET_NAME_RIL);
+ }
+
+ char rildebug[MAX_DEBUG_SOCKET_NAME_LENGTH] = SOCKET_NAME_RIL_DEBUG;
+ if (inst != NULL) {
+ strncat(rildebug, inst, MAX_DEBUG_SOCKET_NAME_LENGTH);
+ }
+
+ s_fdDebug = android_get_control_socket(rildebug);
if (s_fdDebug < 0) {
- RLOGE("Failed to get socket '" SOCKET_NAME_RIL_DEBUG "' errno:%d", errno);
+ RLOGE("Failed to get socket : %s errno:%d", rildebug, errno);
exit(-1);
}
diff --git a/reference-ril/reference-ril.c b/reference-ril/reference-ril.c
index edd02ca..f235aa9 100644
--- a/reference-ril/reference-ril.c
+++ b/reference-ril/reference-ril.c
@@ -1,6 +1,8 @@
/* //device/system/reference-ril/reference-ril.c
**
-** Copyright 2006, The Android Open Source Project
+** Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+** Not a Contribution
+** Copyright 2006 The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
@@ -199,6 +201,7 @@ static pthread_cond_t s_state_cond = PTHREAD_COND_INITIALIZER;
static int s_port = -1;
static const char * s_device_path = NULL;
static int s_device_socket = 0;
+const char * ril_inst_id = NULL;
/* trigger change to this with s_state_cond */
static int s_closed = 0;
@@ -3289,7 +3292,13 @@ mainLoop(void *param)
* now another "legacy" way of communicating with the
* emulator), we will try to connecto to gsm service via
* qemu pipe. */
- fd = qemu_pipe_open("qemud:gsm");
+ char qemuPipe[MAX_QEMU_PIPE_NAME_LENGTH] = "qemud:gsm";
+ if (strncmp(ril_inst_id, "0", MAX_CLIENT_ID_LENGTH)) {
+ strncat(qemuPipe, ril_inst_id ,MAX_QEMU_PIPE_NAME_LENGTH);
+ }
+ RLOGD("qemu pipe name : %s\n", qemuPipe);
+ fd = qemu_pipe_open(qemuPipe);
+
if (fd < 0) {
/* Qemu-specific control socket */
fd = socket_local_client( "qemud",
@@ -3362,7 +3371,7 @@ const RIL_RadioFunctions *RIL_Init(const struct RIL_Env *env, int argc, char **a
s_rilenv = env;
- while ( -1 != (opt = getopt(argc, argv, "p:d:s:"))) {
+ while ( -1 != (opt = getopt(argc, argv, "p:d:s:c:"))) {
switch (opt) {
case 'p':
s_port = atoi(optarg);
@@ -3384,6 +3393,11 @@ const RIL_RadioFunctions *RIL_Init(const struct RIL_Env *env, int argc, char **a
RLOGI("Opening socket %s\n", s_device_path);
break;
+ case 'c':
+ ril_inst_id = optarg;
+ RLOGI("ReferRil is using instance %s ", ril_inst_id);
+ break;
+
default:
usage(argv[0]);
return NULL;
diff --git a/rild/rild.c b/rild/rild.c
index 70530c6..fa9d72a 100644
--- a/rild/rild.c
+++ b/rild/rild.c
@@ -1,6 +1,8 @@
/* //device/system/rild/rild.c
**
-** Copyright 2006, The Android Open Source Project
+** Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+** Not a Contribution
+** Copyright 2006 The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
@@ -45,6 +47,8 @@ static void usage(const char *argv0)
exit(-1);
}
+extern char rild[MAX_SOCKET_NAME_LENGTH];
+
extern void RIL_register (const RIL_RadioFunctions *callbacks);
extern void RIL_onRequestComplete(RIL_Token t, RIL_Errno e,
@@ -108,6 +112,9 @@ int main(int argc, char **argv)
unsigned char hasLibArgs = 0;
int i;
+ const char *clientId = NULL;
+ RLOGD("**RIL Daemon Started**");
+ RLOGD("**RILd param count=%d**", argc);
umask(S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH);
for (i = 1; i < argc ;) {
@@ -118,11 +125,24 @@ int main(int argc, char **argv)
i++;
hasLibArgs = 1;
break;
+ } else if (0 == strcmp(argv[i], "-c") && (argc - i > 1)) {
+ clientId = argv[i+1];
+ i += 2;
} else {
usage(argv[0]);
}
}
+ if (clientId == NULL) {
+ clientId = "0";
+ } else if (atoi(clientId) >= MAX_RILDS) {
+ RLOGE("Max Number of rild's supported is: %d", MAX_RILDS);
+ exit(0);
+ }
+ if (strncmp(clientId, "0", MAX_CLIENT_ID_LENGTH)) {
+ RIL_setRilSocketName(strncat(rild, clientId, MAX_SOCKET_NAME_LENGTH));
+ }
+
if (rilLibPath == NULL) {
if ( 0 == property_get(LIB_PATH_PROPERTY, libPath, NULL)) {
// No lib sepcified on the command line, and nothing set in props.
@@ -136,7 +156,7 @@ int main(int argc, char **argv)
/* special override when in the emulator */
#if 1
{
- static char* arg_overrides[3];
+ static char* arg_overrides[5];
static char arg_device[32];
int done = 0;
@@ -269,6 +289,10 @@ OpenLib:
argc = make_argv(args, rilArgv);
}
+ rilArgv[argc++] = "-c";
+ rilArgv[argc++] = clientId;
+ RLOGD("RIL_Init argc = %d clientId = %s", argc, rilArgv[argc-1]);
+
// Make sure there's a reasonable argv[0]
rilArgv[0] = argv[0];