diff options
author | forkbomb <keepcalm444@gmail.com> | 2015-11-21 18:53:12 +1100 |
---|---|---|
committer | forkbomb <keepcalm444@gmail.com> | 2015-11-25 08:06:10 +1100 |
commit | 549a1c6690b905748645107c1a1099761849c8e9 (patch) | |
tree | e3fe634111c8321d52b9941562fd7b9f3e68d3ac /ril-wrapper | |
parent | 5202b0fd2cddefa31009861b825df42c13d6a706 (diff) | |
download | device_samsung_i9300-549a1c6690b905748645107c1a1099761849c8e9.zip device_samsung_i9300-549a1c6690b905748645107c1a1099761849c8e9.tar.gz device_samsung_i9300-549a1c6690b905748645107c1a1099761849c8e9.tar.bz2 |
i9300: squash RIL bringup
* ril: update ril header to v11
from https://github.com/ArchiDroid/android_device_samsung_i9300/commit/706bc3c354d2f6d6d905e6a26ccee282357c26ee
* ril: LCE support
* set BOARD_RIL_CLASS and add SamsungExynos4RIL
* add Samsung symbols shim library
* use ril-wrapper to stop libsec-ril from crashing
(based off dmitry-ril for the Nexus S)
Change-Id: I169024341621ea05db5b8d8e82c4bf958b7bc6c0
Diffstat (limited to 'ril-wrapper')
-rw-r--r-- | ril-wrapper/Android.mk | 9 | ||||
-rw-r--r-- | ril-wrapper/ril-wrapper.c | 86 |
2 files changed, 95 insertions, 0 deletions
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; +} |