galaxys2-common: Use ril-wrapper to stop libsec-ril from crashing
Based off dmitry-ril for the Nexus S Change-Id: I867118237062997c0459e0fb5749b128849f903c
This commit is contained in:
parent
122bf26fef
commit
51b674be05
@ -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 += \
|
||||
|
9
ril-wrapper/Android.mk
Normal file
9
ril-wrapper/Android.mk
Normal file
@ -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)
|
86
ril-wrapper/ril-wrapper.c
Normal file
86
ril-wrapper/ril-wrapper.c
Normal file
@ -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;
|
||||
}
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user