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

Commit 5c9771b3 authored by Ricardo Cerqueira's avatar Ricardo Cerqueira Committed by Gerrit Code Review
Browse files

ApnSettings: Exclude MVNO listings that are known not to match

When listing APNs for selection, exclude all of the MVNO entries
of "SPN" type when the SPN doesn't match. This still needs to
be extended for the imsi and gid types, but spn is the majority
of known cases and this helps preventing huge listings for those
MNO that support several MVNO

Addresses CYNGNOS-670

Change-Id: Iea538e84619a96740c65adfac72d32f6a35db082
parent 2677fb5c
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import android.provider.Telephony;
import android.telephony.ServiceState;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -77,6 +78,8 @@ public class ApnSettings extends SettingsPreferenceFragment implements
    private static final int APN_INDEX = 2;
    private static final int TYPES_INDEX = 3;
    private static final int RO_INDEX = 4;
    private static final int MVNOTYPE_INDEX = 5;
    private static final int MVNODATA_INDEX = 6;

    private static final int MENU_NEW = Menu.FIRST;
    private static final int MENU_RESTORE = Menu.FIRST + 1;
@@ -217,8 +220,9 @@ public class ApnSettings extends SettingsPreferenceFragment implements
    private void fillList() {
        String where = getOperatorNumericSelection();
        Cursor cursor = getContentResolver().query(getUri(Telephony.Carriers.CONTENT_URI),
                new String[] {"_id", "name", "apn", "type", "read_only"}, where, null,
                new String[] {"_id", "name", "apn", "type", "read_only", "mvno_type", "mvno_match_data" }, where, null,
                Telephony.Carriers.DEFAULT_SORT_ORDER);
        String simOperatorName = TelephonyManager.getDefault().getSimOperatorNameForSubscription(mSubId);

        if (cursor != null) {
            PreferenceGroup apnList = (PreferenceGroup) findPreference("apn_list");
@@ -234,6 +238,19 @@ public class ApnSettings extends SettingsPreferenceFragment implements
                String key = cursor.getString(ID_INDEX);
                String type = cursor.getString(TYPES_INDEX);
                boolean readOnly = (cursor.getInt(RO_INDEX) == 1);
                String mvnoType = cursor.getString(MVNOTYPE_INDEX);
                String mvnoData = cursor.getString(MVNODATA_INDEX);
                boolean isMvno = !TextUtils.isEmpty(mvnoType) && !TextUtils.isEmpty(mvnoData);

                // Incomplete set of skip rules for MVNOs. We still need
                // something for IMSI and GID mismatches, but those rules
                // are a bit more complex. Still... spn-type is 93% of what
                // we support...
                if (isMvno &&
                  (mvnoType.equalsIgnoreCase("spn") && !mvnoData.equalsIgnoreCase(simOperatorName))) {
                    cursor.moveToNext();
                    continue;
                }

                ApnPreference pref = new ApnPreference(getActivity());