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

Commit 604d7ad5 authored by Ricardo Cerqueira's avatar Ricardo Cerqueira
Browse files

Revert "Telephony: Use new apn.sim.operator_numeric property"

This reverts commit 0ff226ff.

Change-Id: I64e24ec783cf1ae62ad4e2f67886b40be0c623f3
parent 7bf09f5e
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -247,7 +247,7 @@ public class ApnEditor extends SettingsPreferenceFragment

        mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

        fillUi(intent.getStringExtra(ApnSettings.OPERATOR_NUMERIC_EXTRA));
        fillUi();
        setHasOptionsMenu(true);
    }

@@ -265,7 +265,7 @@ public class ApnEditor extends SettingsPreferenceFragment
        super.onPause();
    }

    private void fillUi(String defaultOperatorNumeric) {
    private void fillUi() {
        if (mFirstTime) {
            mFirstTime = false;
            // Fill in all the values from the db in both text editor and summary
@@ -283,12 +283,14 @@ public class ApnEditor extends SettingsPreferenceFragment
            mMnc.setText(mCursor.getString(MNC_INDEX));
            mApnType.setText(mCursor.getString(TYPE_INDEX));
            if (mNewApn) {
                String numeric =
                    SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC);
                // MCC is first 3 chars and then in 2 - 3 chars of MNC
                if (defaultOperatorNumeric != null && defaultOperatorNumeric.length() > 4) {
                if (numeric != null && numeric.length() > 4) {
                    // Country code
                    String mcc = defaultOperatorNumeric.substring(0, 3);
                    String mcc = numeric.substring(0, 3);
                    // Network code
                    String mnc = defaultOperatorNumeric.substring(3);
                    String mnc = numeric.substring(3);
                    // Auto populate MNC and MCC for new entries, based on what SIM reports
                    mMcc.setText(mcc);
                    mMnc.setText(mnc);
+3 −36
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.os.SystemProperties;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceGroup;
@@ -62,7 +61,6 @@ public class ApnSettings extends SettingsPreferenceFragment implements
        "content://telephony/carriers/restore";
    public static final String PREFERRED_APN_URI =
        "content://telephony/carriers/preferapn";
    public static final String OPERATOR_NUMERIC_EXTRA = "operator";

    public static final String APN_ID = "apn_id";

@@ -92,9 +90,6 @@ public class ApnSettings extends SettingsPreferenceFragment implements
    private int mSubscription = 0;
    private String mSelectedKey;

    private boolean mUseNvOperatorForEhrpd = SystemProperties.getBoolean(
            "persist.radio.use_nv_for_ehrpd", false);

    private IntentFilter mMobileStateFilter;

    private final BroadcastReceiver mMobileStateReceiver = new BroadcastReceiver() {
@@ -172,12 +167,9 @@ public class ApnSettings extends SettingsPreferenceFragment implements
    }

    private void fillList() {
        String where = getOperatorNumericSelection();

        if (TextUtils.isEmpty(where)) {
            Log.d(TAG, "getOperatorNumericSelection is empty ");
            return;
        }
        String where = "numeric=\""
            + android.os.SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, "")
            + "\"";

        Cursor cursor = getContentResolver().query(Telephony.Carriers.CONTENT_URI, new String[] {
                "_id", "name", "apn", "type"}, where, null,
@@ -255,7 +247,6 @@ public class ApnSettings extends SettingsPreferenceFragment implements
        Bundle editBundle = new Bundle();
        editBundle.putString(ApnEditor.EDIT_ACTION, Intent.ACTION_INSERT);
        editBundle.putString(ApnEditor.EDIT_DATA, Telephony.Carriers.CONTENT_URI.toSafeString());
        editBundle.putString(OPERATOR_NUMERIC_EXTRA, getOperatorNumeric()[0]);
        ((PreferenceActivity) getActivity()).startPreferencePanel(ApnEditor.class.getName(), editBundle,
                            R.string.apn_edit, null, null, 0);
    }
@@ -386,28 +377,4 @@ public class ApnSettings extends SettingsPreferenceFragment implements
        return null;
    }

    private String getOperatorNumericSelection() {
        String[] mccmncs = getOperatorNumeric();
        String where;
        where = (mccmncs[0] != null) ? "numeric=\"" + mccmncs[0] + "\"" : "";
        where += (mccmncs[1] != null) ? " or numeric=\"" + mccmncs[1] + "\"" : "";
        Log.d(TAG, "getOperatorNumericSelection: " + where);
        return where;
    }

    private String[] getOperatorNumeric() {
        ArrayList<String> result = new ArrayList<String>();
        if (mUseNvOperatorForEhrpd) {
            String mccMncForEhrpd = SystemProperties.get("ro.cdma.home.operator.numeric", null);
            if (mccMncForEhrpd != null && mccMncForEhrpd.length() > 0) {
                result.add(mccMncForEhrpd);
            }
        }
        String mccMncFromSim = MSimTelephonyManager.getTelephonyProperty(
                TelephonyProperties.PROPERTY_APN_SIM_OPERATOR_NUMERIC, mSubscription, null);
        if (mccMncFromSim != null && mccMncFromSim.length() > 0) {
            result.add(mccMncFromSim);
        }
        return result.toArray(new String[2]);
    }
}