summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaio Schnepper <caioschnepper@gmail.com>2015-12-21 14:49:22 -0200
committerCaio Schnepper <caioschnepper@gmail.com>2015-12-21 20:12:27 -0800
commit51b674be05aebdb3bd34460eece9f9770b734403 (patch)
treeba9735bcca2e8e49368c2321633eb75e1af81f46
parent122bf26fef9e634c45be5af9de3750719ff9ab61 (diff)
downloaddevice_samsung_galaxys2-common-51b674be05aebdb3bd34460eece9f9770b734403.zip
device_samsung_galaxys2-common-51b674be05aebdb3bd34460eece9f9770b734403.tar.gz
device_samsung_galaxys2-common-51b674be05aebdb3bd34460eece9f9770b734403.tar.bz2
galaxys2-common: Use ril-wrapper to stop libsec-ril from crashing
Based off dmitry-ril for the Nexus S Change-Id: I867118237062997c0459e0fb5749b128849f903c
-rw-r--r--common.mk5
-rw-r--r--ril-wrapper/Android.mk9
-rw-r--r--ril-wrapper/ril-wrapper.c86
-rw-r--r--rootdir/init.smdk4210.rc2
4 files changed, 99 insertions, 3 deletions
diff --git a/common.mk b/common.mk
index a4df37d..3ed779c 100644
--- a/common.mk
+++ b/common.mk
@@ -59,9 +59,10 @@ PRODUCT_PACKAGES := \
com.android.future.usb.accessory \
SamsungServiceMode
-# Samsung symbols
+# Legacy RIL
PRODUCT_PACKAGES += \
- libsamsung_symbols
+ libsamsung_symbols \
+ ril-wrapper
# Audio Packages
PRODUCT_PACKAGES += \
diff --git a/ril-wrapper/Android.mk b/ril-wrapper/Android.mk
new file mode 100644
index 0000000..698e1d3
--- /dev/null
+++ b/ril-wrapper/Android.mk
@@ -0,0 +1,9 @@
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= ril-wrapper.c
+LOCAL_SHARED_LIBRARIES := liblog libbinder
+LOCAL_MODULE:= ril-wrapper
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/ril-wrapper/ril-wrapper.c b/ril-wrapper/ril-wrapper.c
new file mode 100644
index 0000000..8371870
--- /dev/null
+++ b/ril-wrapper/ril-wrapper.c
@@ -0,0 +1,86 @@
+#define LOG_TAG "RilWrapper"
+#define RIL_SHLIB
+#include <telephony/ril_cdma_sms.h>
+#include <sys/system_properties.h>
+#include <telephony/librilutils.h>
+#include <cutils/sockets.h>
+#include <telephony/ril.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <sys/cdefs.h>
+#include <utils/Log.h>
+#include <sys/stat.h>
+#include <pthread.h>
+#include <termios.h>
+#include <alloca.h>
+#include <assert.h>
+#include <getopt.h>
+#include <string.h>
+#include <unistd.h>
+#include <dlfcn.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+
+#define REAL_RIL_NAME "/system/lib/libsec-ril.so"
+
+
+static RIL_RadioFunctions const *mRealRadioFuncs;
+static const struct RIL_Env *mEnv;
+
+const RIL_RadioFunctions* RIL_Init(const struct RIL_Env *env, int argc, char **argv)
+{
+ RIL_RadioFunctions const* (*fRealRilInit)(const struct RIL_Env *env, int argc, char **argv);
+ static RIL_RadioFunctions rilInfo;
+ void *realRilLibHandle;
+ int i;
+
+
+ //save the env;
+ mEnv = env;
+
+ //get the real RIL
+ realRilLibHandle = dlopen(REAL_RIL_NAME, RTLD_LOCAL);
+ if (!realRilLibHandle) {
+ RLOGE("Failed to load the real RIL '" REAL_RIL_NAME "': %s\n", dlerror());
+ return NULL;
+ }
+
+ //remove "-c" command line as Samsung's RIL does not understand it - it just barfs instead
+ for (i = 0; i < argc; i++) {
+ if (!strcmp(argv[i], "-c") && i != argc -1) { //found it
+ memcpy(argv + i, argv + i + 2, sizeof(char*[argc - i - 2]));
+ argc -= 2;
+ }
+ }
+
+ //load the real RIL
+ fRealRilInit = dlsym(realRilLibHandle, "RIL_Init");
+ if (!fRealRilInit) {
+ RLOGE("Failed to find the real RIL's entry point\n");
+ goto out_fail;
+ }
+
+ RLOGD("Calling the real RIL's entry point with %u args\n", argc);
+ for (i = 0; i < argc; i++)
+ RLOGD(" argv[%2d] = '%s'\n", i, argv[i]);
+
+ //try to init the real ril
+ mRealRadioFuncs = fRealRilInit(env, argc, argv);
+ if (!mRealRadioFuncs) {
+ RLOGE("The real RIL's entry point failed\n");
+ goto out_fail;
+ }
+
+ //copy the real RIL's info struct, then replace the onRequest pointer with our own
+ rilInfo = *mRealRadioFuncs;
+
+ RLOGD("Wrapped RIL version is '%s'\n", mRealRadioFuncs->getVersion());
+
+ //we're all good - return to caller
+ return &rilInfo;
+
+out_fail:
+ dlclose(realRilLibHandle);
+ return NULL;
+}
diff --git a/rootdir/init.smdk4210.rc b/rootdir/init.smdk4210.rc
index 7a22741..b399584 100644
--- a/rootdir/init.smdk4210.rc
+++ b/rootdir/init.smdk4210.rc
@@ -2,7 +2,7 @@ import init.smdk4210.usb.rc
import init.gps.rc
on init
- export LD_SHIM_LIBS /system/lib/libril.so|libsamsung_symbols.so
+ export LD_SHIM_LIBS /system/lib/libsec-ril.so|libsamsung_symbols.so
mkdir /efs 0771 radio system
mkdir /preload 0771 system system