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

Commit 0de49694 authored by Shareef Ali's avatar Shareef Ali Committed by Gerrit Code Review
Browse files

Merge "SamsungQualcommRIL: Add Operator replace functionality to search network." into cm-11.0

parents de0da030 09bb3948
Loading
Loading
Loading
Loading
+32 −0
Original line number Original line Diff line number Diff line
@@ -116,4 +116,36 @@ public class Operators{
        storedOperators = operators.containsKey(response) ? operators.get(response) : response;
        storedOperators = operators.containsKey(response) ? operators.get(response) : response;
        return storedOperators;
        return storedOperators;
    }
    }

    // this will not stay persistant in memory, this will be taken care of
    // iin garbage collection routiene.
    private Map<String, String> unOptOperators = null;
    // unoptimized version of operatorreplace for responseOperatorInfos
    // this will provide a little more flexiblilty  in a loop like sisuation
    // same numbers of checks like before
    // this is for the search network functionality
    public String unOptimizedOperatorReplace(String response){
        // sanity checking if the value is actually not equal to the range apn
        // numerics
        // if it is null, check your ril class.
        if(response == null ||
           (5 != response.length() && response.length() != 6)){
            return response;
        }

        try {
            // this will find out if it a number then it will catch it based
            // on invalid chars.
            Integer.parseInt(response);
        }  catch(NumberFormatException E){
            // an illegal char is found i.e a word
            return response;
        }

        if (unOptOperators == null){
            unOptOperators = initList();
        }

        return unOptOperators.containsKey(response) ? unOptOperators.get(response) : response;
    }
}
}
+32 −2
Original line number Original line Diff line number Diff line
@@ -65,8 +65,6 @@ public class SamsungQualcommRIL extends RIL implements CommandsInterface {
    private boolean mIsSendingSMS = false;
    private boolean mIsSendingSMS = false;
    private boolean isGSM = false;
    private boolean isGSM = false;
    public static final long SEND_SMS_TIMEOUT_IN_MS = 30000;
    public static final long SEND_SMS_TIMEOUT_IN_MS = 30000;
    private String homeOperator= SystemProperties.get("ro.cdma.home.operator.numeric");
    private String operator= SystemProperties.get("ro.cdma.home.operator.alpha");
    private boolean oldRilState = needsOldRilFeature("exynos4RadioState");
    private boolean oldRilState = needsOldRilFeature("exynos4RadioState");
    private boolean googleEditionSS = needsOldRilFeature("googleEditionSS");
    private boolean googleEditionSS = needsOldRilFeature("googleEditionSS");
    private boolean driverCall = needsOldRilFeature("newDriverCall");
    private boolean driverCall = needsOldRilFeature("newDriverCall");
@@ -755,4 +753,36 @@ public class SamsungQualcommRIL extends RIL implements CommandsInterface {


        send(rr);
        send(rr);
    }
    }

    //this method is used in the search network functionality.
    // in mobile network setting-> network operators
    @Override
    protected Object
    responseOperatorInfos(Parcel p) {
        String strings[] = (String [])responseStrings(p);
        ArrayList<OperatorInfo> ret;

        if (strings.length % mQANElements != 0) {
            throw new RuntimeException(
                                       "RIL_REQUEST_QUERY_AVAILABLE_NETWORKS: invalid response. Got "
                                       + strings.length + " strings, expected multiple of " + mQANElements);
        }

        ret = new ArrayList<OperatorInfo>(strings.length / mQANElements);
        Operators init = null;
        if (strings.length != 0) {
            init = new Operators();
        }
        for (int i = 0 ; i < strings.length ; i += mQANElements) {
            String temp = init.unOptimizedOperatorReplace(strings[i+0]);
            ret.add (
                     new OperatorInfo(
                                      temp, //operatorAlphaLong
                                      temp,//operatorAlphaShort
                                      strings[i+2],//operatorNumeric
                                      strings[i+3]));//state
        }

        return ret;
    }
}
}