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

Unverified Commit ba918a60 authored by Ricardo Cerqueira's avatar Ricardo Cerqueira Committed by Michael Bestas
Browse files

Framework: Fix GSM signal strength

Certain OEM gsm ril libs send back a bogus value for LTE signal
that causes SignalStrength.java to default to LTE and report
incorrect signal values.
Use prop value ro.telephony.ril.config=signalstrength to get proper
GSM signal reading on certain devices.

Commit includes "telephony: hide needsOldRilFeature" from Chirayu Desai.

Change-Id: I9a0b68f6c3789218a4a20337496e6264996deab7
parent c23cf812
Loading
Loading
Loading
Loading
+17 −3
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@ package android.telephony;
import android.os.Bundle;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable;
import android.os.SystemProperties;
import android.telephony.Rlog;
import android.telephony.Rlog;
import android.content.res.Resources;
import android.content.res.Resources;


@@ -494,6 +495,16 @@ public class SignalStrength implements Parcelable {
        return mLteCqi;
        return mLteCqi;
    }
    }


    /** @hide */
    public boolean needsOldRilFeature(String feature) {
        String[] features = SystemProperties.get("ro.telephony.ril.config", "").split(",");
        for (String found: features) {
            if (found.equals(feature))
                return true;
        }
        return false;
    }

    /**
    /**
     * Retrieve an abstract level value for the overall signal strength.
     * Retrieve an abstract level value for the overall signal strength.
     *
     *
@@ -506,8 +517,9 @@ public class SignalStrength implements Parcelable {
        int level = 0;
        int level = 0;


        if (isGsm) {
        if (isGsm) {
            boolean oldRil = needsOldRilFeature("signalstrength");
            level = getLteLevel();
            level = getLteLevel();
            if (level == SIGNAL_STRENGTH_NONE_OR_UNKNOWN) {
            if (level == SIGNAL_STRENGTH_NONE_OR_UNKNOWN || oldRil) {
                level = getTdScdmaLevel();
                level = getTdScdmaLevel();
                if (level == SIGNAL_STRENGTH_NONE_OR_UNKNOWN) {
                if (level == SIGNAL_STRENGTH_NONE_OR_UNKNOWN) {
                    level = getGsmLevel();
                    level = getGsmLevel();
@@ -539,7 +551,8 @@ public class SignalStrength implements Parcelable {
    public int getAsuLevel() {
    public int getAsuLevel() {
        int asuLevel = 0;
        int asuLevel = 0;
        if (isGsm) {
        if (isGsm) {
            if (getLteLevel() == SIGNAL_STRENGTH_NONE_OR_UNKNOWN) {
            boolean oldRil = needsOldRilFeature("signalstrength");
            if (getLteLevel() == SIGNAL_STRENGTH_NONE_OR_UNKNOWN || oldRil) {
                if (getTdScdmaLevel() == SIGNAL_STRENGTH_NONE_OR_UNKNOWN) {
                if (getTdScdmaLevel() == SIGNAL_STRENGTH_NONE_OR_UNKNOWN) {
                    asuLevel = getGsmAsuLevel();
                    asuLevel = getGsmAsuLevel();
                } else {
                } else {
@@ -575,8 +588,9 @@ public class SignalStrength implements Parcelable {
        int dBm = INVALID;
        int dBm = INVALID;


        if(isGsm()) {
        if(isGsm()) {
            boolean oldRil = needsOldRilFeature("signalstrength");
            dBm = getLteDbm();
            dBm = getLteDbm();
            if (dBm == INVALID) {
            if (dBm == INVALID || oldRil) {
                if (getTdScdmaLevel() == SIGNAL_STRENGTH_NONE_OR_UNKNOWN) {
                if (getTdScdmaLevel() == SIGNAL_STRENGTH_NONE_OR_UNKNOWN) {
                    dBm = getGsmDbm();
                    dBm = getGsmDbm();
                } else {
                } else {