aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZiyan <jaraidaniel@gmail.com>2016-09-08 01:23:49 +0200
committerAndreas Blaesius <skate4life@gmx.de>2016-09-25 18:54:51 +0200
commit9bec50660dd955910c2cbe2ab19d47be36a9364e (patch)
treeb5f1c9642a8bf79d8ad026eb2a41338ae7941b3a
parent755baa4d1556feead8459c68d37014f4926f4bee (diff)
downloaddevice_samsung_espresso3g-9bec50660dd955910c2cbe2ab19d47be36a9364e.zip
device_samsung_espresso3g-9bec50660dd955910c2cbe2ab19d47be36a9364e.tar.gz
device_samsung_espresso3g-9bec50660dd955910c2cbe2ab19d47be36a9364e.tar.bz2
ril: add ril shim
Based on https://github.com/OMAP4-AOSP/android_device_samsung_tuna/tree/aosp-6.0/ril/libsecril-shim. Change-Id: I8a21e9100938903d593ad67e0a9574c622d5dab4
-rw-r--r--device.mk1
-rw-r--r--include/telephony/ril.h2
-rw-r--r--rilsrc/libsecril-shim/Android.mk18
-rw-r--r--rilsrc/libsecril-shim/secril-shim.c99
-rw-r--r--rilsrc/libsecril-shim/secril-shim.h24
-rw-r--r--system.prop2
6 files changed, 143 insertions, 3 deletions
diff --git a/device.mk b/device.mk
index 2dbf90f..50dd242 100644
--- a/device.mk
+++ b/device.mk
@@ -32,6 +32,7 @@ PRODUCT_COPY_FILES += \
PRODUCT_PACKAGES += \
libsecril-client \
libsecril-compat \
+ libsecril-shim \
libsecnativefeature
PRODUCT_PROPERTY_OVERRIDES += \
diff --git a/include/telephony/ril.h b/include/telephony/ril.h
index e7dbe09..e045502 100644
--- a/include/telephony/ril.h
+++ b/include/telephony/ril.h
@@ -4391,8 +4391,6 @@ typedef struct {
#define RIL_REQUEST_UICC_GBA_AUTHENTICATE_BOOTSTRAP 10024
#define RIL_REQUEST_UICC_GBA_AUTHENTICATE_NAF 10025
#define RIL_REQUEST_SIM_TRANSMIT_BASIC 10026
-#define RIL_REQUEST_SIM_OPEN_CHANNEL 10027
-#define RIL_REQUEST_SIM_CLOSE_CHANNEL 10028
#define RIL_REQUEST_SIM_TRANSMIT_CHANNEL 10029
#define RIL_REQUEST_SIM_AUTH 10030
#define RIL_REQUEST_PS_ATTACH 10031
diff --git a/rilsrc/libsecril-shim/Android.mk b/rilsrc/libsecril-shim/Android.mk
new file mode 100644
index 0000000..91519f2
--- /dev/null
+++ b/rilsrc/libsecril-shim/Android.mk
@@ -0,0 +1,18 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := \
+ secril-shim.c
+
+LOCAL_SHARED_LIBRARIES := \
+ liblog \
+ libril \
+ libcutils
+
+LOCAL_CFLAGS := -Wall -Werror
+
+LOCAL_MODULE := libsecril-shim
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/rilsrc/libsecril-shim/secril-shim.c b/rilsrc/libsecril-shim/secril-shim.c
new file mode 100644
index 0000000..50723e3
--- /dev/null
+++ b/rilsrc/libsecril-shim/secril-shim.c
@@ -0,0 +1,99 @@
+#include "secril-shim.h"
+
+/* A copy of the original RIL function table. */
+static const RIL_RadioFunctions *origRilFunctions;
+
+/* A copy of the ril environment passed to RIL_Init. */
+static const struct RIL_Env *rilEnv;
+
+static void onRequestShim(int request, void *data, size_t datalen, RIL_Token t)
+{
+ switch (request) {
+ /* Necessary; RILJ may fake this for us if we reply not supported, but we can just implement it. */
+ case RIL_REQUEST_GET_RADIO_CAPABILITY:
+ ; /* lol C standard */
+ RIL_RadioCapability rc[1] =
+ {
+ { /* rc[0] */
+ RIL_RADIO_CAPABILITY_VERSION, /* version */
+ 0, /* session */
+ RC_PHASE_CONFIGURED, /* phase */
+ RAF_GSM | RAF_GPRS | RAF_EDGE | RAF_HSUPA | RAF_HSDPA | RAF_HSPA | RAF_HSPAP | RAF_UMTS, /* rat */
+ { /* logicalModemUuid */
+ 0,
+ },
+ RC_STATUS_SUCCESS /* status */
+ }
+ };
+ RLOGW("%s: got request %s: replied with our implementation!\n", __func__, requestToString(request));
+ rilEnv->OnRequestComplete(t, RIL_E_SUCCESS, rc, sizeof(rc));
+ return;
+
+ /* The following requests were introduced post-4.3. */
+ case RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC:
+ case RIL_REQUEST_SIM_OPEN_CHANNEL: /* !!! */
+ case RIL_REQUEST_SIM_CLOSE_CHANNEL:
+ case RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL:
+ case RIL_REQUEST_NV_READ_ITEM:
+ case RIL_REQUEST_NV_WRITE_ITEM:
+ case RIL_REQUEST_NV_WRITE_CDMA_PRL:
+ case RIL_REQUEST_NV_RESET_CONFIG:
+ case RIL_REQUEST_SET_UICC_SUBSCRIPTION:
+ case RIL_REQUEST_ALLOW_DATA:
+ case RIL_REQUEST_GET_HARDWARE_CONFIG:
+ case RIL_REQUEST_SIM_AUTHENTICATION:
+ case RIL_REQUEST_GET_DC_RT_INFO:
+ case RIL_REQUEST_SET_DC_RT_INFO_RATE:
+ case RIL_REQUEST_SET_DATA_PROFILE:
+ case RIL_REQUEST_SHUTDOWN: /* TODO: Is there something we can do for RIL_REQUEST_SHUTDOWN ? */
+ case RIL_REQUEST_SET_RADIO_CAPABILITY:
+ case RIL_REQUEST_START_LCE:
+ case RIL_REQUEST_STOP_LCE:
+ case RIL_REQUEST_PULL_LCEDATA:
+ RLOGW("%s: got request %s: replied with REQUEST_NOT_SUPPPORTED.\n", __func__, requestToString(request));
+ rilEnv->OnRequestComplete(t, RIL_E_REQUEST_NOT_SUPPORTED, NULL, 0);
+ return;
+ }
+
+ RLOGD("%s: got request %s: forwarded to RIL.\n", __func__, requestToString(request));
+ origRilFunctions->onRequest(request, data, datalen, t);
+}
+
+const RIL_RadioFunctions* RIL_Init(const struct RIL_Env *env, int argc, char **argv)
+{
+ RIL_RadioFunctions const* (*origRilInit)(const struct RIL_Env *env, int argc, char **argv);
+ static RIL_RadioFunctions shimmedFunctions;
+ void *origRil;
+
+ rilEnv = env;
+
+ /* Open and Init the original RIL. */
+
+ origRil = dlopen(RIL_LIB_PATH, RTLD_LOCAL);
+ if (CC_UNLIKELY(!origRil)) {
+ RLOGE("%s: failed to load '" RIL_LIB_PATH "': %s\n", __func__, dlerror());
+ return NULL;
+ }
+
+ origRilInit = dlsym(origRil, "RIL_Init");
+ if (CC_UNLIKELY(!origRilInit)) {
+ RLOGE("%s: couldn't find original RIL_Init!\n", __func__);
+ goto fail_after_dlopen;
+ }
+
+ origRilFunctions = origRilInit(env, argc, argv);
+ if (CC_UNLIKELY(!origRilFunctions)) {
+ RLOGE("%s: the original RIL_Init derped.\n", __func__);
+ goto fail_after_dlopen;
+ }
+
+ /* Shim functions as needed. */
+ shimmedFunctions = *origRilFunctions;
+ shimmedFunctions.onRequest = onRequestShim;
+
+ return &shimmedFunctions;
+
+fail_after_dlopen:
+ dlclose(origRil);
+ return NULL;
+}
diff --git a/rilsrc/libsecril-shim/secril-shim.h b/rilsrc/libsecril-shim/secril-shim.h
new file mode 100644
index 0000000..ad409db
--- /dev/null
+++ b/rilsrc/libsecril-shim/secril-shim.h
@@ -0,0 +1,24 @@
+#ifndef __SECRIL_SHIM_H__
+#define __SECRIL_SHIM_H__
+
+#define LOG_TAG "secril-shim"
+#define RIL_SHLIB
+
+#include <dlfcn.h>
+#include <inttypes.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <cutils/compiler.h>
+#include <cutils/properties.h>
+#include <sys/cdefs.h>
+#include <telephony/ril.h>
+#include <utils/Log.h>
+
+#define RIL_LIB_PATH "/vendor/lib/libsec-ril.so"
+
+extern const char * requestToString(int request);
+
+#endif /* __SECRIL_SHIM_H__ */
diff --git a/system.prop b/system.prop
index a6eeb34..9dfc125 100644
--- a/system.prop
+++ b/system.prop
@@ -1,7 +1,7 @@
#
# system.prop for espresso3g
#
-rild.libpath=/system/vendor/lib/libsec-ril.so
+rild.libpath=/system/lib/libsecril-shim.so
rild.libargs=-d /dev/ttyGS0 --
telephony.lteOnCdmaDevice=0
ro.ril.hsxpa=1