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

Commit 4bed829b authored by Ricardo Cerqueira's avatar Ricardo Cerqueira Committed by Lin Ma
Browse files

SignalStrength: Allow for custom signal buckets in LTE

STRICT levels are too low, LENIENT levels are too high. Let us
use something in between...

To make things more fun, getAlternateLteLevel() used yet another
set of values. Subsume all of this functionality into a main
getLteLevel() function that uses whatever the device has configured
as the signal limits, and wrap the old methods around it in
case we additionally need to force RSRP for all cases. getLteLevel()
without arguments and getAlternateLteLevel() retain the same
functionality.

RENDANG-471
Change-Id: I134774ed471e1805eac95cfbf8af957378fd8293
(cherry picked from commit 7e9570dd)
parent a1a1a9c1
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -2197,6 +2197,7 @@
          when evaluating RSRP for LTE antenna bar display
           0. Strict threshold
           1. Lenient threshold
           2. Custom threshold
    -->
    <integer name="config_LTE_RSRP_threshold_type">1</integer>

@@ -2332,4 +2333,15 @@
    <string name="config_defaultQuickSettingsTiles">wifi,bt,cell,airplane,rotation,flashlight,location,cast,visualizer,hotspot,live_display</string>

    <string-array name="config_externalCMServices"></string-array>

    <!-- When config_LTE_RSRP_threshold_type is set to "custom" -->
    <integer-array name="config_LTE_RSRP_custom_levels">
        <item>-140</item>
        <item>-128</item>
        <item>-118</item>
        <item>-108</item>
        <item>-98</item>
        <item>-44</item>
    </integer-array>

</resources>
+1 −0
Original line number Diff line number Diff line
@@ -2173,5 +2173,6 @@

  <!-- From SignalStrength -->
  <java-symbol type="integer" name="config_LTE_RSRP_threshold_type" />
  <java-symbol type="array"   name="config_LTE_RSRP_custom_levels" />

</resources>
+18 −10
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ public class SignalStrength implements Parcelable {
    public static final int INVALID = 0x7FFFFFFF;

    private static final int RSRP_THRESH_TYPE_STRICT = 0;
    private static final int RSRP_THRESH_TYPE_CUSTOM = 2;
    private static final int[] RSRP_THRESH_STRICT = new int[] {-140, -115, -105, -95, -85, -44};
    private static final int[] RSRP_THRESH_LENIENT = new int[] {-140, -128, -118, -108, -98, -44};

@@ -795,16 +796,7 @@ public class SignalStrength implements Parcelable {
     * @hide
     */
    public int getAlternateLteLevel() {
        int rsrpIconLevel = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;

        if (mLteRsrp > -44) rsrpIconLevel = -1;
        else if (mLteRsrp >= -97) rsrpIconLevel = SIGNAL_STRENGTH_GREAT;
        else if (mLteRsrp >= -105) rsrpIconLevel = SIGNAL_STRENGTH_GOOD;
        else if (mLteRsrp >= -113) rsrpIconLevel = SIGNAL_STRENGTH_MODERATE;
        else if (mLteRsrp >= -120) rsrpIconLevel = SIGNAL_STRENGTH_POOR;
        else if (mLteRsrp >= -140) rsrpIconLevel = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;

        return rsrpIconLevel;
        return getLteLevel(true);
    }

    /**
@@ -813,6 +805,15 @@ public class SignalStrength implements Parcelable {
     * @hide
     */
    public int getLteLevel() {
        return getLteLevel(false);
    }

    /**
     * Get LTE as level 0..4
     *
     * @hide
     */
    private int getLteLevel(boolean forceRsrp) {
        /*
         * TS 36.214 Physical Layer Section 5.1.3 TS 36.331 RRC RSSI = received
         * signal + noise RSRP = reference signal dBm RSRQ = quality of signal
@@ -826,6 +827,9 @@ public class SignalStrength implements Parcelable {
        int[] threshRsrp;
        if (rsrpThreshType == RSRP_THRESH_TYPE_STRICT) {
            threshRsrp = RSRP_THRESH_STRICT;
        } else if (rsrpThreshType == RSRP_THRESH_TYPE_CUSTOM) {
            threshRsrp = Resources.getSystem().getIntArray(com.android.internal.R.array.
                    config_LTE_RSRP_custom_levels);
        } else {
            threshRsrp = RSRP_THRESH_LENIENT;
        }
@@ -837,6 +841,10 @@ 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 (forceRsrp) {
            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