aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZiyan <jaraidaniel@gmail.com>2016-09-09 10:26:57 +0200
committerAndreas Blaesius <skate4life@gmx.de>2016-09-25 18:54:52 +0200
commit9319d6e7ad32c24506128e74d6a422fa3b7b8817 (patch)
treed0f43f8c21e4c6dd55febe43b4b54ee1f4a76755
parent178f58281d40eaa2fc18a18293614040d4277270 (diff)
downloaddevice_samsung_espresso3g-9319d6e7ad32c24506128e74d6a422fa3b7b8817.zip
device_samsung_espresso3g-9319d6e7ad32c24506128e74d6a422fa3b7b8817.tar.gz
device_samsung_espresso3g-9319d6e7ad32c24506128e74d6a422fa3b7b8817.tar.bz2
libsecril-shim: fix RIL_(REQUEST/UNSOL)_SIGNAL_STRENGTH
The Samsung RIL reports the signal strength in a strange way... Change-Id: I738fa4fbf08d2f16fcc7f5cf638a2d0a8081f125
-rw-r--r--rilsrc/libsecril-shim/secril-shim.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/rilsrc/libsecril-shim/secril-shim.c b/rilsrc/libsecril-shim/secril-shim.c
index ed703c1..2c71709 100644
--- a/rilsrc/libsecril-shim/secril-shim.c
+++ b/rilsrc/libsecril-shim/secril-shim.c
@@ -84,6 +84,28 @@ static void onCompleteQueryAvailableNetworks(RIL_Token t, RIL_Errno e, void *res
free(newResponse);
}
+static void fixupSignalStrength(void *response, size_t responselen) {
+ int gsmSignalStrength;
+
+ RIL_SignalStrength_v10 *p_cur = ((RIL_SignalStrength_v10 *) response);
+
+ gsmSignalStrength = p_cur->GW_SignalStrength.signalStrength & 0xFF;
+
+ if (gsmSignalStrength < 0 ||
+ (gsmSignalStrength > 31 && p_cur->GW_SignalStrength.signalStrength != 99)) {
+ gsmSignalStrength = p_cur->CDMA_SignalStrength.dbm;
+ }
+
+ /* Fix GSM signal strength */
+ p_cur->GW_SignalStrength.signalStrength = gsmSignalStrength;
+
+ /* We don't support LTE - values should be set to INT_MAX */
+ p_cur->LTE_SignalStrength.cqi = INT_MAX;
+ p_cur->LTE_SignalStrength.rsrp = INT_MAX;
+ p_cur->LTE_SignalStrength.rsrq = INT_MAX;
+ p_cur->LTE_SignalStrength.rssnr = INT_MAX;
+}
+
static void onRequestCompleteShim(RIL_Token t, RIL_Errno e, void *response, size_t responselen) {
int request;
RequestInfo *pRI;
@@ -105,6 +127,14 @@ static void onRequestCompleteShim(RIL_Token t, RIL_Errno e, void *response, size
return;
}
break;
+ case RIL_REQUEST_SIGNAL_STRENGTH:
+ /* The Samsung RIL reports the signal strength in a strange way... */
+ if (response != NULL && responselen >= sizeof(RIL_SignalStrength_v5)) {
+ fixupSignalStrength(response, responselen);
+ rilEnv->OnRequestComplete(t, e, response, responselen);
+ return;
+ }
+ break;
}
RLOGD("%s: got request %s: forwarded to libril.\n", __func__, requestToString(request));
@@ -112,6 +142,19 @@ null_token_exit:
rilEnv->OnRequestComplete(t, e, response, responselen);
}
+static void onUnsolicitedResponseShim(int unsolResponse, const void *data, size_t datalen)
+{
+ switch (unsolResponse) {
+ case RIL_UNSOL_SIGNAL_STRENGTH:
+ /* The Samsung RIL reports the signal strength in a strange way... */
+ if (data != NULL && datalen >= sizeof(RIL_SignalStrength_v5))
+ fixupSignalStrength((void*) data, datalen);
+ break;
+ }
+
+ rilEnv->OnUnsolicitedResponse(unsolResponse, data, datalen);
+}
+
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);
@@ -123,6 +166,7 @@ const RIL_RadioFunctions* RIL_Init(const struct RIL_Env *env, int argc, char **a
rilEnv = env;
shimmedEnv = *env;
shimmedEnv.OnRequestComplete = onRequestCompleteShim;
+ shimmedEnv.OnUnsolicitedResponse = onUnsolicitedResponseShim;
/* Open and Init the original RIL. */