Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 427be571 authored by Fang Yunong's avatar Fang Yunong Committed by Linux Build Service Account
Browse files

Regional: Change signal strength thresholds for LTE and UMTS

Add customized signal strength calculation algorithm for LTE and UMTS.
And use config to turn on/off the features.

CRs-Fixed: 1039313
Change-Id: I16a56000421f63e6befd2a97d1210700bc6a037e
parent b8166563
Loading
Loading
Loading
Loading
+41 −12
Original line number Diff line number Diff line
@@ -619,8 +619,24 @@ public class SignalStrength implements Parcelable {
     * @hide
     */
    public int getGsmLevel() {
        int level;

        int level = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
        if (Resources.getSystem().getBoolean(
                com.android.internal.R.bool.config_regional_umts_singnal_threshold)) {
            int dbm = getGsmDbm();
            int[] threshGsm;
            threshGsm = Resources.getSystem().getIntArray(
                    com.android.internal.R.array.umts_signal_strength_threshold);;
            if (threshGsm.length < 6)
                return level;
            if (dbm > threshGsm[5]) level = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
            else if (dbm >= threshGsm[4]) level = SIGNAL_STRENGTH_GREAT;
            else if (dbm >= threshGsm[3]) level = SIGNAL_STRENGTH_GOOD;
            else if (dbm >= threshGsm[2]) level = SIGNAL_STRENGTH_MODERATE;
            else if (dbm >= threshGsm[1]) level = SIGNAL_STRENGTH_POOR;
            else if (dbm >= threshGsm[0]) level = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
            if (DBG) log("getCustomizedGsmDbmLevel - dbm:" + dbm + " gsmLevel:"
                    + level);
        } else {
            // ASU ranges from 0 to 31 - TS 27.007 Sec 8.5
            // asu = 0 (-113dB or less) is very weak
            // signal, its better to show 0 bars to the user in such cases.
@@ -632,6 +648,8 @@ public class SignalStrength implements Parcelable {
            else if (asu >= 5)  level = SIGNAL_STRENGTH_MODERATE;
            else level = SIGNAL_STRENGTH_POOR;
            if (DBG) log("getGsmLevel=" + level);
        }

        return level;
    }

@@ -799,6 +817,11 @@ public class SignalStrength implements Parcelable {
        } else {
            threshRsrp = RSRP_THRESH_LENIENT;
        }
        if (Resources.getSystem().getBoolean(
                com.android.internal.R.bool.config_regional_lte_singnal_threshold)){
            threshRsrp = Resources.getSystem().getIntArray(
                    com.android.internal.R.array.lte_signal_strength_threshold);
        }

        if (mLteRsrp > threshRsrp[5]) rsrpIconLevel = -1;
        else if (mLteRsrp >= threshRsrp[4]) rsrpIconLevel = SIGNAL_STRENGTH_GREAT;
@@ -807,6 +830,12 @@ public class SignalStrength implements Parcelable {
        else if (mLteRsrp >= threshRsrp[1]) rsrpIconLevel = SIGNAL_STRENGTH_POOR;
        else if (mLteRsrp >= threshRsrp[0]) rsrpIconLevel = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;

        if (Resources.getSystem().getBoolean(
                com.android.internal.R.bool.config_regional_lte_singnal_threshold)){
            log("getLTELevel - rsrp = " + rsrpIconLevel);
            if (rsrpIconLevel != -1) return rsrpIconLevel;
        }

        /*
         * Values are -200 dB to +300 (SNR*10dB) RS_SNR >= 13.0 dB =>4 bars 4.5
         * dB <= RS_SNR < 13.0 dB => 3 bars 1.0 dB <= RS_SNR < 4.5 dB => 2 bars