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

Commit 6144c25d authored by Muhammed Siju's avatar Muhammed Siju Committed by Gerrit - the friendly Code Review server
Browse files

MSIM: Select preferred apn based on subscription id.

While querying and setting preferred apn in APN settings,
use the PREFERRED_APN_URI based on current subscription id.
This will make sure that the preferred apn is selected
correctly based on the SIM card selected.

Change-Id: I826295f993d99b6f1fafbab9ad7dba9cad04ffbb
CRs-Fixed: 958420
parent 7fdce129
Loading
Loading
Loading
Loading
+14 −3
Original line number Original line Diff line number Diff line
@@ -168,6 +168,8 @@ public class ApnSettings extends RestrictedSettingsFragment implements
        final int subId = activity.getIntent().getIntExtra(SUB_ID,
        final int subId = activity.getIntent().getIntExtra(SUB_ID,
                SubscriptionManager.INVALID_SUBSCRIPTION_ID);
                SubscriptionManager.INVALID_SUBSCRIPTION_ID);
        fillOperatorIccidset();
        fillOperatorIccidset();
        Log.d(TAG, "onCreate: subId = " + subId);



        mMobileStateFilter = new IntentFilter(
        mMobileStateFilter = new IntentFilter(
                TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
                TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
@@ -519,13 +521,13 @@ public class ApnSettings extends RestrictedSettingsFragment implements


        ContentValues values = new ContentValues();
        ContentValues values = new ContentValues();
        values.put(APN_ID, mSelectedKey);
        values.put(APN_ID, mSelectedKey);
        resolver.update(PREFERAPN_URI, values, null, null);
        resolver.update(getUri(PREFERAPN_URI), values, null, null);
    }
    }


    private String getSelectedApnKey() {
    private String getSelectedApnKey() {
        String key = null;
        String key = null;


        Cursor cursor = getContentResolver().query(PREFERAPN_URI, new String[] {"_id"},
        Cursor cursor = getContentResolver().query(getUri(PREFERAPN_URI), new String[] {"_id"},
                null, null, Telephony.Carriers.DEFAULT_SORT_ORDER);
                null, null, Telephony.Carriers.DEFAULT_SORT_ORDER);
        if (cursor.getCount() > 0) {
        if (cursor.getCount() > 0) {
            cursor.moveToFirst();
            cursor.moveToFirst();
@@ -596,7 +598,7 @@ public class ApnSettings extends RestrictedSettingsFragment implements
            switch (msg.what) {
            switch (msg.what) {
                case EVENT_RESTORE_DEFAULTAPN_START:
                case EVENT_RESTORE_DEFAULTAPN_START:
                    ContentResolver resolver = getContentResolver();
                    ContentResolver resolver = getContentResolver();
                    resolver.delete(DEFAULTAPN_URI, null, null);
                    resolver.delete(getUri(DEFAULTAPN_URI), null, null);
                    mRestoreApnUiHandler
                    mRestoreApnUiHandler
                        .sendEmptyMessage(EVENT_RESTORE_DEFAULTAPN_COMPLETE);
                        .sendEmptyMessage(EVENT_RESTORE_DEFAULTAPN_COMPLETE);
                    break;
                    break;
@@ -618,4 +620,13 @@ public class ApnSettings extends RestrictedSettingsFragment implements
        }
        }
        return null;
        return null;
    }
    }

    private Uri getUri(Uri uri) {
        int subId = SubscriptionManager.getDefaultDataSubscriptionId();
        if (mSubscriptionInfo != null && SubscriptionManager.isValidSubscriptionId(
                mSubscriptionInfo.getSubscriptionId())) {
            subId = mSubscriptionInfo.getSubscriptionId();
        }
        return Uri.withAppendedPath(uri, "/subId/" + subId);
    }
}
}