Merge "Refine APN fetching logic" am: 765621670b
am: 74069bc022
Change-Id: I372d73a75a7dd2077e39dfc29c66b29b1a3ace65
This commit is contained in:
@@ -42,7 +42,6 @@ import android.telephony.CarrierConfigManager;
|
|||||||
import android.telephony.SubscriptionInfo;
|
import android.telephony.SubscriptionInfo;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.telephony.data.ApnSetting;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@@ -54,8 +53,6 @@ import android.widget.Toast;
|
|||||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||||
import com.android.internal.telephony.PhoneConstants;
|
import com.android.internal.telephony.PhoneConstants;
|
||||||
import com.android.internal.telephony.TelephonyIntents;
|
import com.android.internal.telephony.TelephonyIntents;
|
||||||
import com.android.internal.telephony.dataconnection.ApnSettingUtils;
|
|
||||||
import com.android.internal.telephony.uicc.IccRecords;
|
|
||||||
import com.android.internal.telephony.uicc.UiccController;
|
import com.android.internal.telephony.uicc.UiccController;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.RestrictedSettingsFragment;
|
import com.android.settings.RestrictedSettingsFragment;
|
||||||
@@ -277,34 +274,27 @@ public class ApnSettings extends RestrictedSettingsFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void fillList() {
|
private void fillList() {
|
||||||
final TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
|
|
||||||
final int subId = mSubscriptionInfo != null ? mSubscriptionInfo.getSubscriptionId()
|
final int subId = mSubscriptionInfo != null ? mSubscriptionInfo.getSubscriptionId()
|
||||||
: SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
: SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||||
final String mccmnc = mSubscriptionInfo == null ? "" : tm.getSimOperator(subId);
|
final Uri simApnUri = Uri.withAppendedPath(Telephony.Carriers.SIM_APN_LIST,
|
||||||
Log.d(TAG, "mccmnc = " + mccmnc);
|
String.valueOf(subId));
|
||||||
StringBuilder where = new StringBuilder("numeric=\"" + mccmnc +
|
StringBuilder where = new StringBuilder("NOT (type='ia' AND (apn=\"\" OR apn IS NULL)) AND "
|
||||||
"\" AND NOT (type='ia' AND (apn=\"\" OR apn IS NULL)) AND user_visible!=0");
|
+ "user_visible!=0");
|
||||||
|
|
||||||
if (mHideImsApn) {
|
if (mHideImsApn) {
|
||||||
where.append(" AND NOT (type='ims')");
|
where.append(" AND NOT (type='ims')");
|
||||||
}
|
}
|
||||||
|
|
||||||
Cursor cursor = getContentResolver().query(Telephony.Carriers.CONTENT_URI,
|
Cursor cursor = getContentResolver().query(simApnUri,
|
||||||
CARRIERS_PROJECTION, where.toString(), null, Telephony.Carriers.DEFAULT_SORT_ORDER);
|
CARRIERS_PROJECTION, where.toString(), null,
|
||||||
|
Telephony.Carriers.DEFAULT_SORT_ORDER);
|
||||||
|
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
IccRecords r = null;
|
PreferenceGroup apnPrefList = (PreferenceGroup) findPreference("apn_list");
|
||||||
if (mUiccController != null && mSubscriptionInfo != null) {
|
apnPrefList.removeAll();
|
||||||
r = mUiccController.getIccRecords(
|
|
||||||
SubscriptionManager.getPhoneId(subId), UiccController.APP_FAM_3GPP);
|
|
||||||
}
|
|
||||||
PreferenceGroup apnList = (PreferenceGroup) findPreference("apn_list");
|
|
||||||
apnList.removeAll();
|
|
||||||
|
|
||||||
ArrayList<ApnPreference> mnoApnList = new ArrayList<ApnPreference>();
|
ArrayList<ApnPreference> apnList = new ArrayList<ApnPreference>();
|
||||||
ArrayList<ApnPreference> mvnoApnList = new ArrayList<ApnPreference>();
|
ArrayList<ApnPreference> mmsApnList = new ArrayList<ApnPreference>();
|
||||||
ArrayList<ApnPreference> mnoMmsApnList = new ArrayList<ApnPreference>();
|
|
||||||
ArrayList<ApnPreference> mvnoMmsApnList = new ArrayList<ApnPreference>();
|
|
||||||
|
|
||||||
mSelectedKey = getSelectedApnKey();
|
mSelectedKey = getSelectedApnKey();
|
||||||
cursor.moveToFirst();
|
cursor.moveToFirst();
|
||||||
@@ -313,9 +303,9 @@ public class ApnSettings extends RestrictedSettingsFragment {
|
|||||||
String apn = cursor.getString(APN_INDEX);
|
String apn = cursor.getString(APN_INDEX);
|
||||||
String key = cursor.getString(ID_INDEX);
|
String key = cursor.getString(ID_INDEX);
|
||||||
String type = cursor.getString(TYPES_INDEX);
|
String type = cursor.getString(TYPES_INDEX);
|
||||||
String mvnoType = cursor.getString(MVNO_TYPE_INDEX);
|
|
||||||
String mvnoMatchData = cursor.getString(MVNO_MATCH_DATA_INDEX);
|
|
||||||
int edited = cursor.getInt(EDITED_INDEX);
|
int edited = cursor.getInt(EDITED_INDEX);
|
||||||
|
mMvnoType = cursor.getString(MVNO_TYPE_INDEX);
|
||||||
|
mMvnoMatchData = cursor.getString(MVNO_MATCH_DATA_INDEX);
|
||||||
|
|
||||||
ApnPreference pref = new ApnPreference(getPrefContext());
|
ApnPreference pref = new ApnPreference(getPrefContext());
|
||||||
|
|
||||||
@@ -335,43 +325,20 @@ public class ApnSettings extends RestrictedSettingsFragment {
|
|||||||
if ((mSelectedKey != null) && mSelectedKey.equals(key)) {
|
if ((mSelectedKey != null) && mSelectedKey.equals(key)) {
|
||||||
pref.setChecked();
|
pref.setChecked();
|
||||||
}
|
}
|
||||||
addApnToList(pref, mnoApnList, mvnoApnList, r, mvnoType, mvnoMatchData);
|
apnList.add(pref);
|
||||||
} else {
|
} else {
|
||||||
addApnToList(pref, mnoMmsApnList, mvnoMmsApnList, r, mvnoType, mvnoMatchData);
|
mmsApnList.add(pref);
|
||||||
}
|
}
|
||||||
cursor.moveToNext();
|
cursor.moveToNext();
|
||||||
}
|
}
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
|
||||||
if (!mvnoApnList.isEmpty()) {
|
for (Preference preference : apnList) {
|
||||||
mnoApnList = mvnoApnList;
|
apnPrefList.addPreference(preference);
|
||||||
mnoMmsApnList = mvnoMmsApnList;
|
|
||||||
|
|
||||||
// Also save the mvno info
|
|
||||||
}
|
}
|
||||||
|
for (Preference preference : mmsApnList) {
|
||||||
for (Preference preference : mnoApnList) {
|
apnPrefList.addPreference(preference);
|
||||||
apnList.addPreference(preference);
|
|
||||||
}
|
}
|
||||||
for (Preference preference : mnoMmsApnList) {
|
|
||||||
apnList.addPreference(preference);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addApnToList(ApnPreference pref, ArrayList<ApnPreference> mnoList,
|
|
||||||
ArrayList<ApnPreference> mvnoList, IccRecords r, String mvnoType,
|
|
||||||
String mvnoMatchData) {
|
|
||||||
if (r != null && !TextUtils.isEmpty(mvnoType) && !TextUtils.isEmpty(mvnoMatchData)) {
|
|
||||||
if (ApnSettingUtils.mvnoMatches(r, ApnSetting.getMvnoTypeIntFromString(mvnoType),
|
|
||||||
mvnoMatchData)) {
|
|
||||||
mvnoList.add(pref);
|
|
||||||
// Since adding to mvno list, save mvno info
|
|
||||||
mMvnoType = mvnoType;
|
|
||||||
mMvnoMatchData = mvnoMatchData;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mnoList.add(pref);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user