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

Commit 1505f0fd authored by Alex Yakavenka's avatar Alex Yakavenka Committed by Linux Build Service Account
Browse files

Telephony: Use new apn.sim.operator_numeric property

Use new property to filter apns. We need this new property
because icc.operator_numeric property is also used in cdma
and ApnSetting UI might display wrong set of apns if the
peroperty value used was set by RuimRecords.
CRs-Fixed: 362846

Change-Id: Ie740c9b3bb6a14621e19c55e4fa18c66bc0d7b0c
(cherry picked from commit b74be3a91ed12c29626edf64bce34a154d4b1db1)
(cherry picked from commit bb13705113a67b493530cf1a8e8ffdca2887093f)
(cherry picked from commit 6cd912d7f13d0985eaa03fa2171f7983c0d2671c)
parent d2fccdd8
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
@@ -227,7 +227,7 @@ public class ApnEditor extends PreferenceActivity

        mTelephonyManager = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);

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

    @Override
@@ -244,7 +244,7 @@ public class ApnEditor extends PreferenceActivity
        super.onPause();
    }

    private void fillUi() {
    private void fillUi(String defaultOperatorNumeric) {
        if (mFirstTime) {
            mFirstTime = false;
            // Fill in all the values from the db in both text editor and summary
@@ -262,14 +262,12 @@ public class ApnEditor extends PreferenceActivity
            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 (numeric != null && numeric.length() > 4) {
                if (defaultOperatorNumeric != null && defaultOperatorNumeric.length() > 4) {
                    // Country code
                    String mcc = numeric.substring(0, 3);
                    String mcc = defaultOperatorNumeric.substring(0, 3);
                    // Network code
                    String mnc = numeric.substring(3);
                    String mnc = defaultOperatorNumeric.substring(3);
                    // Auto populate MNC and MCC for new entries, based on what SIM reports
                    mMcc.setText(mcc);
                    mMnc.setText(mnc);
+34 −5
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ 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;
@@ -58,6 +59,7 @@ public class ApnSettings extends PreferenceActivity 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";

@@ -85,6 +87,9 @@ public class ApnSettings extends PreferenceActivity implements

    private String mSelectedKey;

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

    private IntentFilter mMobileStateFilter;

    private final BroadcastReceiver mMobileStateReceiver = new BroadcastReceiver() {
@@ -156,10 +161,7 @@ public class ApnSettings extends PreferenceActivity implements
    }

    private void fillList() {
        String where = "numeric=\""
            + android.os.SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, "")
            + "\"";

        String where = getOperatorNumericSelection();
        Cursor cursor = getContentResolver().query(Telephony.Carriers.CONTENT_URI, new String[] {
                "_id", "name", "apn", "type"}, where, null,
                Telephony.Carriers.DEFAULT_SORT_ORDER);
@@ -234,7 +236,9 @@ public class ApnSettings extends PreferenceActivity implements
    }

    private void addNewApn() {
        startActivity(new Intent(Intent.ACTION_INSERT, Telephony.Carriers.CONTENT_URI));
        Intent intent = new Intent(Intent.ACTION_INSERT, Telephony.Carriers.CONTENT_URI);
        intent.putExtra(OPERATOR_NUMERIC_EXTRA, getOperatorNumeric()[0]);
        startActivity(intent);
    }

    @Override
@@ -357,4 +361,29 @@ public class ApnSettings extends PreferenceActivity implements
            getPreferenceScreen().setEnabled(false);
        }
    }

    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 = SystemProperties.get(
                TelephonyProperties.PROPERTY_APN_SIM_OPERATOR_NUMERIC, null);
        if (mccMncFromSim != null && mccMncFromSim.length() > 0) {
            result.add(mccMncFromSim);
        }
        return result.toArray(new String[2]);
    }
}