summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortilaksidduram <tilaksidduram@gmail.com>2015-12-02 10:17:26 +0530
committertilaksidduram <tilaksidduram@gmail.com>2015-12-02 10:17:26 +0530
commitb047db596821cbcbe33f3ca638fb78871302143f (patch)
tree6443bfd63fc5941548508b3e8d457ecf85f91de0
parente9e28e3b6176332c43b41bb802b3513c7b701faa (diff)
downloaddevice_samsung_n7100-b047db596821cbcbe33f3ca638fb78871302143f.zip
device_samsung_n7100-b047db596821cbcbe33f3ca638fb78871302143f.tar.gz
device_samsung_n7100-b047db596821cbcbe33f3ca638fb78871302143f.tar.bz2
n7100: make ril work
use ril-wrapper to stop libsec-ril from crashing (based off dmitry-ril for the Nexus S)
-rw-r--r--n7100.mk4
-rw-r--r--ril-wrapper/Android.mk9
-rw-r--r--ril-wrapper/ril-wrapper.c86
-rw-r--r--rootdir/init.target.rc2
-rw-r--r--system.prop2
5 files changed, 101 insertions, 2 deletions
diff --git a/n7100.mk b/n7100.mk
index 1f0e323..5da4762 100644
--- a/n7100.mk
+++ b/n7100.mk
@@ -53,6 +53,10 @@ PRODUCT_PACKAGES += \
libsecril-client-sap \
SamsungServiceMode
+# RIL
+PRODUCT_PACKAGES += \
+ ril-wrapper
+
# Additional apps
PRODUCT_PACKAGES += \
OpenDelta
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.target.rc b/rootdir/init.target.rc
index fe05cea..3e7ba2c 100644
--- a/rootdir/init.target.rc
+++ b/rootdir/init.target.rc
@@ -1,5 +1,5 @@
on init
- export LD_PRELOAD "/system/lib/libsamsung_symbols.so"
+ export LD_SHIM_LIBS /system/lib/libsec-ril.so|libsamsung_symbols.so
# Vibetonz
export VIBE_PIPE_PATH /dev/pipes
mkdir /dev/pipes 0771 shell shell
diff --git a/system.prop b/system.prop
index 47d42de..db6bcfd 100644
--- a/system.prop
+++ b/system.prop
@@ -3,7 +3,7 @@
#
dalvik.vm.dexopt-data-only=1
-rild.libpath=/system/lib/libsec-ril.so
+rild.libpath=/system/lib/ril-wrapper.so
rild.libargs=-d /dev/ttyS0
ro.sf.lcd_density=320
ro.lcd_min_brightness=20