From db968d4efd4284de663f1e077011e3242f3fdc97 Mon Sep 17 00:00:00 2001 From: Martin Bouchet Date: Sat, 23 Sep 2017 05:23:52 -0300 Subject: [PATCH] libril: port samsung changes to signalStrength Change-Id: I39c1f5dcb44bcd0cf265243276d7649a9c2fdc8c --- ril/libril/ril_service.cpp | 184 ++++++++++++++++++++++++++++++++++--- 1 file changed, 172 insertions(+), 12 deletions(-) diff --git a/ril/libril/ril_service.cpp b/ril/libril/ril_service.cpp index f6d4a10d..6978be42 100644 --- a/ril/libril/ril_service.cpp +++ b/ril/libril/ril_service.cpp @@ -6696,12 +6696,52 @@ int radio::nitzTimeReceivedInd(int slotId, void convertRilSignalStrengthToHalV5(void *response, size_t responseLen, SignalStrength& signalStrength) { RIL_SignalStrength_v5 *rilSignalStrength = (RIL_SignalStrength_v5 *) response; + int gsmSignalStrength; + int cdmaDbm; + int evdoDbm; - signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength; + gsmSignalStrength = rilSignalStrength->GW_SignalStrength.signalStrength & 0xFF; + +#ifdef MODEM_TYPE_XMM6260 + if (gsmSignalStrength < 0 || + (gsmSignalStrength > 31 && rilSignalStrength->GW_SignalStrength.signalStrength != 99)) { + gsmSignalStrength = rilSignalStrength->CDMA_SignalStrength.dbm; + } +#else + if (gsmSignalStrength < 0) { + gsmSignalStrength = 99; + } else if (gsmSignalStrength > 31 && gsmSignalStrength != 99) { + gsmSignalStrength = 31; + } +#endif + +#if defined(MODEM_TYPE_XMM6262) || defined(SAMSUNG_NEXT_GEN_MODEM) + cdmaDbm = rilSignalStrength->CDMA_SignalStrength.dbm & 0xFF; + if (cdmaDbm < 0) { + cdmaDbm = 99; + } else if (cdmaDbm > 31 && cdmaDbm != 99) { + cdmaDbm = 31; + } +#else + cdmaDbm = rilSignalStrength->CDMA_SignalStrength.dbm; +#endif + +#if defined(MODEM_TYPE_XMM6262) || defined(SAMSUNG_NEXT_GEN_MODEM) + evdoDbm = rilSignalStrength->EVDO_SignalStrength.dbm & 0xFF; + if (evdoDbm < 0) { + evdoDbm = 99; + } else if (evdoDbm > 31 && evdoDbm != 99) { + evdoDbm = 31; + } +#else + evdoDbm = rilSignalStrength->EVDO_SignalStrength.dbm; +#endif + + signalStrength.gw.signalStrength = gsmSignalStrength; signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate; - signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm; + signalStrength.cdma.dbm = cdmaDbm; signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio; - signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm; + signalStrength.evdo.dbm = evdoDbm; signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio; signalStrength.evdo.signalNoiseRatio = rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio; @@ -6717,6 +6757,46 @@ void convertRilSignalStrengthToHalV5(void *response, size_t responseLen, void convertRilSignalStrengthToHalV6(void *response, size_t responseLen, SignalStrength& signalStrength) { RIL_SignalStrength_v6 *rilSignalStrength = (RIL_SignalStrength_v6 *) response; + int gsmSignalStrength; + int cdmaDbm; + int evdoDbm; + + gsmSignalStrength = rilSignalStrength->GW_SignalStrength.signalStrength & 0xFF; + +#ifdef MODEM_TYPE_XMM6260 + if (gsmSignalStrength < 0 || + (gsmSignalStrength > 31 && rilSignalStrength->GW_SignalStrength.signalStrength != 99)) { + gsmSignalStrength = rilSignalStrength->CDMA_SignalStrength.dbm; + } +#else + if (gsmSignalStrength < 0) { + gsmSignalStrength = 99; + } else if (gsmSignalStrength > 31 && gsmSignalStrength != 99) { + gsmSignalStrength = 31; + } +#endif + +#if defined(MODEM_TYPE_XMM6262) || defined(SAMSUNG_NEXT_GEN_MODEM) + cdmaDbm = rilSignalStrength->CDMA_SignalStrength.dbm & 0xFF; + if (cdmaDbm < 0) { + cdmaDbm = 99; + } else if (cdmaDbm > 31 && cdmaDbm != 99) { + cdmaDbm = 31; + } +#else + cdmaDbm = rilSignalStrength->CDMA_SignalStrength.dbm; +#endif + +#if defined(MODEM_TYPE_XMM6262) || defined(SAMSUNG_NEXT_GEN_MODEM) + evdoDbm = rilSignalStrength->EVDO_SignalStrength.dbm & 0xFF; + if (evdoDbm < 0) { + evdoDbm = 99; + } else if (evdoDbm > 31 && evdoDbm != 99) { + evdoDbm = 31; + } +#else + evdoDbm = rilSignalStrength->EVDO_SignalStrength.dbm; +#endif // Fixup LTE for backwards compatibility // signalStrength: -1 -> 99 @@ -6740,11 +6820,11 @@ void convertRilSignalStrengthToHalV6(void *response, size_t responseLen, rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX; } - signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength; + signalStrength.gw.signalStrength = gsmSignalStrength; signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate; - signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm; + signalStrength.cdma.dbm = cdmaDbm; signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio; - signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm; + signalStrength.evdo.dbm = evdoDbm; signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio; signalStrength.evdo.signalNoiseRatio = rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio; @@ -6760,6 +6840,46 @@ void convertRilSignalStrengthToHalV6(void *response, size_t responseLen, void convertRilSignalStrengthToHalV8(void *response, size_t responseLen, SignalStrength& signalStrength) { RIL_SignalStrength_v8 *rilSignalStrength = (RIL_SignalStrength_v8 *) response; + int gsmSignalStrength; + int cdmaDbm; + int evdoDbm; + + gsmSignalStrength = rilSignalStrength->GW_SignalStrength.signalStrength & 0xFF; + +#ifdef MODEM_TYPE_XMM6260 + if (gsmSignalStrength < 0 || + (gsmSignalStrength > 31 && rilSignalStrength->GW_SignalStrength.signalStrength != 99)) { + gsmSignalStrength = rilSignalStrength->CDMA_SignalStrength.dbm; + } +#else + if (gsmSignalStrength < 0) { + gsmSignalStrength = 99; + } else if (gsmSignalStrength > 31 && gsmSignalStrength != 99) { + gsmSignalStrength = 31; + } +#endif + +#if defined(MODEM_TYPE_XMM6262) || defined(SAMSUNG_NEXT_GEN_MODEM) + cdmaDbm = rilSignalStrength->CDMA_SignalStrength.dbm & 0xFF; + if (cdmaDbm < 0) { + cdmaDbm = 99; + } else if (cdmaDbm > 31 && cdmaDbm != 99) { + cdmaDbm = 31; + } +#else + cdmaDbm = rilSignalStrength->CDMA_SignalStrength.dbm; +#endif + +#if defined(MODEM_TYPE_XMM6262) || defined(SAMSUNG_NEXT_GEN_MODEM) + evdoDbm = rilSignalStrength->EVDO_SignalStrength.dbm & 0xFF; + if (evdoDbm < 0) { + evdoDbm = 99; + } else if (evdoDbm > 31 && evdoDbm != 99) { + evdoDbm = 31; + } +#else + evdoDbm = rilSignalStrength->EVDO_SignalStrength.dbm; +#endif // Fixup LTE for backwards compatibility // signalStrength: -1 -> 99 @@ -6783,11 +6903,11 @@ void convertRilSignalStrengthToHalV8(void *response, size_t responseLen, rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX; } - signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength; + signalStrength.gw.signalStrength = gsmSignalStrength; signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate; - signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm; + signalStrength.cdma.dbm = cdmaDbm; signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio; - signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm; + signalStrength.evdo.dbm = evdoDbm; signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio; signalStrength.evdo.signalNoiseRatio = rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio; @@ -6803,6 +6923,46 @@ void convertRilSignalStrengthToHalV8(void *response, size_t responseLen, void convertRilSignalStrengthToHalV10(void *response, size_t responseLen, SignalStrength& signalStrength) { RIL_SignalStrength_v10 *rilSignalStrength = (RIL_SignalStrength_v10 *) response; + int gsmSignalStrength; + int cdmaDbm; + int evdoDbm; + + gsmSignalStrength = rilSignalStrength->GW_SignalStrength.signalStrength & 0xFF; + +#ifdef MODEM_TYPE_XMM6260 + if (gsmSignalStrength < 0 || + (gsmSignalStrength > 31 && rilSignalStrength->GW_SignalStrength.signalStrength != 99)) { + gsmSignalStrength = rilSignalStrength->CDMA_SignalStrength.dbm; + } +#else + if (gsmSignalStrength < 0) { + gsmSignalStrength = 99; + } else if (gsmSignalStrength > 31 && gsmSignalStrength != 99) { + gsmSignalStrength = 31; + } +#endif + +#if defined(MODEM_TYPE_XMM6262) || defined(SAMSUNG_NEXT_GEN_MODEM) + cdmaDbm = rilSignalStrength->CDMA_SignalStrength.dbm & 0xFF; + if (cdmaDbm < 0) { + cdmaDbm = 99; + } else if (cdmaDbm > 31 && cdmaDbm != 99) { + cdmaDbm = 31; + } +#else + cdmaDbm = rilSignalStrength->CDMA_SignalStrength.dbm; +#endif + +#if defined(MODEM_TYPE_XMM6262) || defined(SAMSUNG_NEXT_GEN_MODEM) + evdoDbm = rilSignalStrength->EVDO_SignalStrength.dbm & 0xFF; + if (evdoDbm < 0) { + evdoDbm = 99; + } else if (evdoDbm > 31 && evdoDbm != 99) { + evdoDbm = 31; + } +#else + evdoDbm = rilSignalStrength->EVDO_SignalStrength.dbm; +#endif // Fixup LTE for backwards compatibility // signalStrength: -1 -> 99 @@ -6826,11 +6986,11 @@ void convertRilSignalStrengthToHalV10(void *response, size_t responseLen, rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX; } - signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength; + signalStrength.gw.signalStrength = gsmSignalStrength; signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate; - signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm; + signalStrength.cdma.dbm = cdmaDbm; signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio; - signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm; + signalStrength.evdo.dbm = evdoDbm; signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio; signalStrength.evdo.signalNoiseRatio = rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;