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

Commit 0d7a1ddd authored by d34d's avatar d34d
Browse files

Catch possible NumberFormatException in ServiceStateTracker

If operatorNumeric has any non numeric characters Integer.parseInt
will fail with a NumberFormatException.  Catch these exceptions and
return false.

Change-Id: I721fdbcff8566b59d11a64d506165496246dd099
TICKET: CYNGNOS-961
parent 5a8338a1
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -1099,8 +1099,18 @@ public abstract class ServiceStateTracker extends Handler {
        boolean inSameCountry = true;
        final String networkMCC = operatorNumeric.substring(0, 3);
        final String homeMCC = homeNumeric.substring(0, 3);
        final String networkCountry = MccTable.countryCodeForMcc(Integer.parseInt(networkMCC));
        final String homeCountry = MccTable.countryCodeForMcc(Integer.parseInt(homeMCC));
        final int networkMccInt;
        final int homeMccInt;
        try {
            networkMccInt = Integer.parseInt(networkMCC);
            homeMccInt = Integer.parseInt(homeMCC);
        } catch (NumberFormatException e) {
            // Not a valid network MCC or home MCC
            return false;
        }

        final String networkCountry = MccTable.countryCodeForMcc(networkMccInt);
        final String homeCountry = MccTable.countryCodeForMcc(homeMccInt);
        if (networkCountry.isEmpty() || homeCountry.isEmpty()) {
            // Not a valid country
            return false;