From a6dde2b6078ba30ff37aa9d2a5aabf7b3def89f6 Mon Sep 17 00:00:00 2001 From: Simon Shields Date: Tue, 24 May 2016 23:09:42 +0200 Subject: n5100 : fake GET_RADIO_CAPABILITY response Change-Id: I7ae2a38bf144cd68322d9b7aa6fc7fb41fefb7ae --- n5100.mk | 4 +- ril-wrapper/Android.mk | 9 +++++ ril-wrapper/ril-wrapper.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++ system.prop | 5 +-- 4 files changed, 112 insertions(+), 5 deletions(-) create mode 100644 ril-wrapper/Android.mk create mode 100644 ril-wrapper/ril-wrapper.c diff --git a/n5100.mk b/n5100.mk index 3921258..6ce2b82 100755 --- a/n5100.mk +++ b/n5100.mk @@ -24,8 +24,8 @@ PRODUCT_COPY_FILES += \ # Packages PRODUCT_PACKAGES += \ - libsecril-client-sap \ - libsamsung_symbols + libsamsung_symbols \ + ril-wrapper # RIL PRODUCT_PROPERTY_OVERRIDES += \ 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..886cb34 --- /dev/null +++ b/ril-wrapper/ril-wrapper.c @@ -0,0 +1,99 @@ +#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; + +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); + 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; + rilInfo.onRequest = rilOnRequest; + + 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/system.prop b/system.prop index 6b73a5f..67bcb37 100755 --- a/system.prop +++ b/system.prop @@ -2,10 +2,9 @@ # system.prop for smdk4x12 # 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.hwrotation=270 ro.sf.lcd_density=213 ro.lcd_min_brightness=20 -ro.hdcp2.rx=tz -persist.radio.apm_sim_not_pwdn=1 +ro.hdcp2.rx=tz \ No newline at end of file -- cgit v1.1