From b047db596821cbcbe33f3ca638fb78871302143f Mon Sep 17 00:00:00 2001 From: tilaksidduram Date: Wed, 2 Dec 2015 10:17:26 +0530 Subject: n7100: make ril work use ril-wrapper to stop libsec-ril from crashing (based off dmitry-ril for the Nexus S) --- ril-wrapper/ril-wrapper.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 ril-wrapper/ril-wrapper.c (limited to 'ril-wrapper/ril-wrapper.c') 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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; +} -- cgit v1.1 From 0e7e0240eb089f9c8c5e65b61ea625861e37d56f Mon Sep 17 00:00:00 2001 From: Simon Shields Date: Sat, 12 Dec 2015 18:12:16 +1100 Subject: n7100: ril-wrapper: fake GET_RADIO_CAPABILITY response Samsung's RIL doesn't support this, but doesn't error on it either. Change-Id: I5a470c55fecf85183e9c7b4b37aef3b3cbffaf90 --- ril-wrapper/ril-wrapper.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'ril-wrapper/ril-wrapper.c') diff --git a/ril-wrapper/ril-wrapper.c b/ril-wrapper/ril-wrapper.c index 8371870..886cb34 100644 --- a/ril-wrapper/ril-wrapper.c +++ b/ril-wrapper/ril-wrapper.c @@ -28,6 +28,18 @@ static RIL_RadioFunctions const *mRealRadioFuncs; static const struct RIL_Env *mEnv; +static void rilOnRequest(int request, void *data, size_t datalen, RIL_Token t) +{ + switch (request) { + case RIL_REQUEST_GET_RADIO_CAPABILITY: + RLOGW("Returning NOT_SUPPORTED on GET_RADIO_CAPABILITY"); + mEnv->OnRequestComplete(t, RIL_E_REQUEST_NOT_SUPPORTED, NULL, 0); + break; + default: + mRealRadioFuncs->onRequest(request, data, datalen, t); + } +} + 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); @@ -74,6 +86,7 @@ const RIL_RadioFunctions* RIL_Init(const struct RIL_Env *env, int argc, char **a //copy the real RIL's info struct, then replace the onRequest pointer with our own rilInfo = *mRealRadioFuncs; + rilInfo.onRequest = rilOnRequest; RLOGD("Wrapped RIL version is '%s'\n", mRealRadioFuncs->getVersion()); -- cgit v1.1 From 67db5ee1bb3b3835041a90ee043e0fee868a96bd Mon Sep 17 00:00:00 2001 From: tilaksidduram Date: Tue, 22 Dec 2015 20:07:09 +0530 Subject: Revert "n7100: ril-wrapper: fake GET_RADIO_CAPABILITY response" This reverts commit 0e7e0240eb089f9c8c5e65b61ea625861e37d56f. --- ril-wrapper/ril-wrapper.c | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'ril-wrapper/ril-wrapper.c') diff --git a/ril-wrapper/ril-wrapper.c b/ril-wrapper/ril-wrapper.c index 886cb34..8371870 100644 --- a/ril-wrapper/ril-wrapper.c +++ b/ril-wrapper/ril-wrapper.c @@ -28,18 +28,6 @@ static RIL_RadioFunctions const *mRealRadioFuncs; static const struct RIL_Env *mEnv; -static void rilOnRequest(int request, void *data, size_t datalen, RIL_Token t) -{ - switch (request) { - case RIL_REQUEST_GET_RADIO_CAPABILITY: - RLOGW("Returning NOT_SUPPORTED on GET_RADIO_CAPABILITY"); - mEnv->OnRequestComplete(t, RIL_E_REQUEST_NOT_SUPPORTED, NULL, 0); - break; - default: - mRealRadioFuncs->onRequest(request, data, datalen, t); - } -} - 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); @@ -86,7 +74,6 @@ const RIL_RadioFunctions* RIL_Init(const struct RIL_Env *env, int argc, char **a //copy the real RIL's info struct, then replace the onRequest pointer with our own rilInfo = *mRealRadioFuncs; - rilInfo.onRequest = rilOnRequest; RLOGD("Wrapped RIL version is '%s'\n", mRealRadioFuncs->getVersion()); -- cgit v1.1 From 559a7ad0a443510916fa676b4da04d310b74be99 Mon Sep 17 00:00:00 2001 From: Simon Shields Date: Sat, 12 Dec 2015 18:12:16 +1100 Subject: n7100: ril-wrapper: fake GET_RADIO_CAPABILITY response Samsung's RIL doesn't support this, but doesn't error on it either. Change-Id: I5a470c55fecf85183e9c7b4b37aef3b3cbffaf90 --- ril-wrapper/ril-wrapper.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'ril-wrapper/ril-wrapper.c') diff --git a/ril-wrapper/ril-wrapper.c b/ril-wrapper/ril-wrapper.c index 8371870..886cb34 100644 --- a/ril-wrapper/ril-wrapper.c +++ b/ril-wrapper/ril-wrapper.c @@ -28,6 +28,18 @@ static RIL_RadioFunctions const *mRealRadioFuncs; static const struct RIL_Env *mEnv; +static void rilOnRequest(int request, void *data, size_t datalen, RIL_Token t) +{ + switch (request) { + case RIL_REQUEST_GET_RADIO_CAPABILITY: + RLOGW("Returning NOT_SUPPORTED on GET_RADIO_CAPABILITY"); + mEnv->OnRequestComplete(t, RIL_E_REQUEST_NOT_SUPPORTED, NULL, 0); + break; + default: + mRealRadioFuncs->onRequest(request, data, datalen, t); + } +} + 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); @@ -74,6 +86,7 @@ const RIL_RadioFunctions* RIL_Init(const struct RIL_Env *env, int argc, char **a //copy the real RIL's info struct, then replace the onRequest pointer with our own rilInfo = *mRealRadioFuncs; + rilInfo.onRequest = rilOnRequest; RLOGD("Wrapped RIL version is '%s'\n", mRealRadioFuncs->getVersion()); -- cgit v1.1