Loading src/java/com/android/internal/telephony/dataconnection/DcTracker.java +21 −76 Original line number Diff line number Diff line Loading @@ -511,10 +511,6 @@ public class DcTracker extends Handler { // really a lower power mode") private boolean mIsScreenOn = true; // Indicates if we found mvno-specific APNs in the full APN list. // used to determine if we can accept mno-specific APN for tethering. private boolean mMvnoMatched = false; /** Allows the generation of unique Id's for DataConnection objects */ private AtomicInteger mUniqueIdGenerator = new AtomicInteger(0); Loading Loading @@ -1709,8 +1705,6 @@ public class DcTracker extends Handler { return new ArrayList<ApnSetting>(0); } int bearer = mPhone.getServiceState().getRilDataRadioTechnology(); IccRecords r = mIccRecords.get(); String operator = (r != null) ? r.getOperatorNumeric() : ""; ArrayList<ApnSetting> dunCandidates = new ArrayList<ApnSetting>(); ArrayList<ApnSetting> retDunSettings = new ArrayList<ApnSetting>(); Loading Loading @@ -1738,17 +1732,8 @@ public class DcTracker extends Handler { ServiceState.rilRadioTechnologyToNetworkType(bearer))) { continue; } if (dunSetting.getOperatorNumeric().equals(operator)) { if (dunSetting.hasMvnoParams()) { if (r != null && ApnSettingUtils.mvnoMatches(r, dunSetting.getMvnoType(), dunSetting.getMvnoMatchData())) { retDunSettings.add(dunSetting); } } else if (mMvnoMatched == false) { retDunSettings.add(dunSetting); } } } if (VDBG) log("fetchDunApns: dunSettings=" + retDunSettings); return retDunSettings; Loading Loading @@ -1820,41 +1805,6 @@ public class DcTracker extends Handler { (mAttached.get() == false || dcFailCause != DcFailCause.SIGNAL_LOST)); } private ArrayList<ApnSetting> createApnList(Cursor cursor) { ArrayList<ApnSetting> mnoApns = new ArrayList<ApnSetting>(); ArrayList<ApnSetting> mvnoApns = new ArrayList<ApnSetting>(); IccRecords r = mIccRecords.get(); if (cursor.moveToFirst()) { do { ApnSetting apn = ApnSetting.makeApnSetting(cursor); if (apn == null) { continue; } if (apn.hasMvnoParams()) { if (r != null && ApnSettingUtils.mvnoMatches(r, apn.getMvnoType(), apn.getMvnoMatchData())) { mvnoApns.add(apn); } } else { mnoApns.add(apn); } } while (cursor.moveToNext()); } ArrayList<ApnSetting> result; if (mvnoApns.isEmpty()) { result = mnoApns; mMvnoMatched = false; } else { result = mvnoApns; mMvnoMatched = true; } if (DBG) log("createApnList: X result=" + result); return result; } private DataConnection findFreeDataConnection() { for (DataConnection dataConnection : mDataConnections.values()) { boolean inUse = false; Loading Loading @@ -3232,34 +3182,28 @@ public class DcTracker extends Handler { * Data Connections and setup the preferredApn. */ private void createAllApnList() { mMvnoMatched = false; mAllApnSettings.clear(); IccRecords r = mIccRecords.get(); String operator = (r != null) ? r.getOperatorNumeric() : ""; if (operator != null) { String selection = Telephony.Carriers.NUMERIC + " = '" + operator + "'"; // query only enabled apn. // carrier_enabled : 1 means enabled apn, 0 disabled apn. // selection += " and carrier_enabled = 1"; if (DBG) log("createAllApnList: selection=" + selection); // ORDER BY Telephony.Carriers._ID ("_id") Cursor cursor = mPhone.getContext().getContentResolver().query( Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "filtered/subId/" + mPhone.getSubId()), null, selection, null, Telephony.Carriers._ID); + mPhone.getSubId()), null, null, null, Telephony.Carriers._ID); if (cursor != null) { if (cursor.getCount() > 0) { mAllApnSettings = createApnList(cursor); } else { if (DBG) log("createAllApnList: cursor count is 0"); mApnSettingsInitializationLog.log("no APN in db for carrier: " + operator); while (cursor.moveToNext()) { ApnSetting apn = ApnSetting.makeApnSetting(cursor); if (apn == null) { continue; } mAllApnSettings.add(apn); } cursor.close(); } else { if (DBG) log("createAllApnList: cursor is null"); mApnSettingsInitializationLog.log("cursor is null for carrier: " + operator); } mApnSettingsInitializationLog.log("cursor is null for carrier, operator: " + operator); } addEmergencyApnSetting(); Loading @@ -3267,8 +3211,9 @@ public class DcTracker extends Handler { dedupeApnSettings(); if (mAllApnSettings.isEmpty()) { if (DBG) log("createAllApnList: No APN found for carrier: " + operator); mApnSettingsInitializationLog.log("no APN found for carrier: " + operator); log("createAllApnList: No APN found for carrier, operator: " + operator); mApnSettingsInitializationLog.log("no APN found for carrier, operator: " + operator); mPreferredApn = null; // TODO: What is the right behavior? //notifyNoData(DataConnection.FailCause.MISSING_UNKNOWN_APN); Loading tests/telephonytests/src/com/android/internal/telephony/dataconnection/DcTrackerTest.java +8 −19 Original line number Diff line number Diff line Loading @@ -98,8 +98,6 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; public class DcTrackerTest extends TelephonyTest { Loading Loading @@ -132,6 +130,7 @@ public class DcTrackerTest extends TelephonyTest { private static final Uri PREFERAPN_URI = Uri.parse( Telephony.Carriers.CONTENT_URI + "/preferapn"); private static final int DATA_ENABLED_CHANGED = 0; private static final String FAKE_PLMN = "44010"; @Mock ISub mIsub; Loading Loading @@ -210,18 +209,9 @@ public class DcTrackerTest extends TelephonyTest { if (uri.compareTo(Telephony.Carriers.CONTENT_URI) == 0 || uri.toString().startsWith(Uri.withAppendedPath( Telephony.Carriers.CONTENT_URI, "filtered").toString())) { if (projection == null && selectionArgs == null && selection != null) { if (projection == null) { Pattern pattern = Pattern.compile("^numeric = '([0-9]*)'"); Matcher matcher = pattern.matcher(selection); if (!matcher.find()) { logd("Cannot find MCC/MNC from " + selection); return null; } String plmn = matcher.group(1); logd("Query '" + plmn + "' APN settings"); logd("Query '" + FAKE_PLMN + "' APN settings"); MatrixCursor mc = new MatrixCursor( new String[]{Telephony.Carriers._ID, Telephony.Carriers.NUMERIC, Telephony.Carriers.NAME, Telephony.Carriers.APN, Loading @@ -248,7 +238,7 @@ public class DcTrackerTest extends TelephonyTest { mc.addRow(new Object[]{ 2163, // id plmn, // numeric FAKE_PLMN, // numeric "sp-mode", // name FAKE_APN1, // apn "", // proxy Loading Loading @@ -280,7 +270,7 @@ public class DcTrackerTest extends TelephonyTest { mc.addRow(new Object[]{ 2164, // id plmn, // numeric FAKE_PLMN, // numeric "mopera U", // name FAKE_APN2, // apn "", // proxy Loading Loading @@ -312,7 +302,7 @@ public class DcTrackerTest extends TelephonyTest { mc.addRow(new Object[]{ 2165, // id plmn, // numeric FAKE_PLMN, // numeric "b-mobile for Nexus", // name FAKE_APN3, // apn "", // proxy Loading Loading @@ -344,7 +334,7 @@ public class DcTrackerTest extends TelephonyTest { mc.addRow(new Object[]{ 2166, // id plmn, // numeric FAKE_PLMN, // numeric "sp-mode ehrpd", // name FAKE_APN4, // apn "", // proxy Loading Loading @@ -376,7 +366,7 @@ public class DcTrackerTest extends TelephonyTest { mc.addRow(new Object[]{ 2166, // id plmn, // numeric FAKE_PLMN, // numeric "b-mobile for Nexus", // name FAKE_APN5, // apn "", // proxy Loading Loading @@ -437,7 +427,6 @@ public class DcTrackerTest extends TelephonyTest { doReturn("fake.action_attached").when(mPhone).getActionAttached(); doReturn(ServiceState.RIL_RADIO_TECHNOLOGY_LTE).when(mServiceState) .getRilDataRadioTechnology(); doReturn("44010").when(mSimRecords).getOperatorNumeric(); mContextFixture.putStringArrayResource(com.android.internal.R.array.networkAttributes, sNetworkAttributes); Loading Loading
src/java/com/android/internal/telephony/dataconnection/DcTracker.java +21 −76 Original line number Diff line number Diff line Loading @@ -511,10 +511,6 @@ public class DcTracker extends Handler { // really a lower power mode") private boolean mIsScreenOn = true; // Indicates if we found mvno-specific APNs in the full APN list. // used to determine if we can accept mno-specific APN for tethering. private boolean mMvnoMatched = false; /** Allows the generation of unique Id's for DataConnection objects */ private AtomicInteger mUniqueIdGenerator = new AtomicInteger(0); Loading Loading @@ -1709,8 +1705,6 @@ public class DcTracker extends Handler { return new ArrayList<ApnSetting>(0); } int bearer = mPhone.getServiceState().getRilDataRadioTechnology(); IccRecords r = mIccRecords.get(); String operator = (r != null) ? r.getOperatorNumeric() : ""; ArrayList<ApnSetting> dunCandidates = new ArrayList<ApnSetting>(); ArrayList<ApnSetting> retDunSettings = new ArrayList<ApnSetting>(); Loading Loading @@ -1738,17 +1732,8 @@ public class DcTracker extends Handler { ServiceState.rilRadioTechnologyToNetworkType(bearer))) { continue; } if (dunSetting.getOperatorNumeric().equals(operator)) { if (dunSetting.hasMvnoParams()) { if (r != null && ApnSettingUtils.mvnoMatches(r, dunSetting.getMvnoType(), dunSetting.getMvnoMatchData())) { retDunSettings.add(dunSetting); } } else if (mMvnoMatched == false) { retDunSettings.add(dunSetting); } } } if (VDBG) log("fetchDunApns: dunSettings=" + retDunSettings); return retDunSettings; Loading Loading @@ -1820,41 +1805,6 @@ public class DcTracker extends Handler { (mAttached.get() == false || dcFailCause != DcFailCause.SIGNAL_LOST)); } private ArrayList<ApnSetting> createApnList(Cursor cursor) { ArrayList<ApnSetting> mnoApns = new ArrayList<ApnSetting>(); ArrayList<ApnSetting> mvnoApns = new ArrayList<ApnSetting>(); IccRecords r = mIccRecords.get(); if (cursor.moveToFirst()) { do { ApnSetting apn = ApnSetting.makeApnSetting(cursor); if (apn == null) { continue; } if (apn.hasMvnoParams()) { if (r != null && ApnSettingUtils.mvnoMatches(r, apn.getMvnoType(), apn.getMvnoMatchData())) { mvnoApns.add(apn); } } else { mnoApns.add(apn); } } while (cursor.moveToNext()); } ArrayList<ApnSetting> result; if (mvnoApns.isEmpty()) { result = mnoApns; mMvnoMatched = false; } else { result = mvnoApns; mMvnoMatched = true; } if (DBG) log("createApnList: X result=" + result); return result; } private DataConnection findFreeDataConnection() { for (DataConnection dataConnection : mDataConnections.values()) { boolean inUse = false; Loading Loading @@ -3232,34 +3182,28 @@ public class DcTracker extends Handler { * Data Connections and setup the preferredApn. */ private void createAllApnList() { mMvnoMatched = false; mAllApnSettings.clear(); IccRecords r = mIccRecords.get(); String operator = (r != null) ? r.getOperatorNumeric() : ""; if (operator != null) { String selection = Telephony.Carriers.NUMERIC + " = '" + operator + "'"; // query only enabled apn. // carrier_enabled : 1 means enabled apn, 0 disabled apn. // selection += " and carrier_enabled = 1"; if (DBG) log("createAllApnList: selection=" + selection); // ORDER BY Telephony.Carriers._ID ("_id") Cursor cursor = mPhone.getContext().getContentResolver().query( Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "filtered/subId/" + mPhone.getSubId()), null, selection, null, Telephony.Carriers._ID); + mPhone.getSubId()), null, null, null, Telephony.Carriers._ID); if (cursor != null) { if (cursor.getCount() > 0) { mAllApnSettings = createApnList(cursor); } else { if (DBG) log("createAllApnList: cursor count is 0"); mApnSettingsInitializationLog.log("no APN in db for carrier: " + operator); while (cursor.moveToNext()) { ApnSetting apn = ApnSetting.makeApnSetting(cursor); if (apn == null) { continue; } mAllApnSettings.add(apn); } cursor.close(); } else { if (DBG) log("createAllApnList: cursor is null"); mApnSettingsInitializationLog.log("cursor is null for carrier: " + operator); } mApnSettingsInitializationLog.log("cursor is null for carrier, operator: " + operator); } addEmergencyApnSetting(); Loading @@ -3267,8 +3211,9 @@ public class DcTracker extends Handler { dedupeApnSettings(); if (mAllApnSettings.isEmpty()) { if (DBG) log("createAllApnList: No APN found for carrier: " + operator); mApnSettingsInitializationLog.log("no APN found for carrier: " + operator); log("createAllApnList: No APN found for carrier, operator: " + operator); mApnSettingsInitializationLog.log("no APN found for carrier, operator: " + operator); mPreferredApn = null; // TODO: What is the right behavior? //notifyNoData(DataConnection.FailCause.MISSING_UNKNOWN_APN); Loading
tests/telephonytests/src/com/android/internal/telephony/dataconnection/DcTrackerTest.java +8 −19 Original line number Diff line number Diff line Loading @@ -98,8 +98,6 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; public class DcTrackerTest extends TelephonyTest { Loading Loading @@ -132,6 +130,7 @@ public class DcTrackerTest extends TelephonyTest { private static final Uri PREFERAPN_URI = Uri.parse( Telephony.Carriers.CONTENT_URI + "/preferapn"); private static final int DATA_ENABLED_CHANGED = 0; private static final String FAKE_PLMN = "44010"; @Mock ISub mIsub; Loading Loading @@ -210,18 +209,9 @@ public class DcTrackerTest extends TelephonyTest { if (uri.compareTo(Telephony.Carriers.CONTENT_URI) == 0 || uri.toString().startsWith(Uri.withAppendedPath( Telephony.Carriers.CONTENT_URI, "filtered").toString())) { if (projection == null && selectionArgs == null && selection != null) { if (projection == null) { Pattern pattern = Pattern.compile("^numeric = '([0-9]*)'"); Matcher matcher = pattern.matcher(selection); if (!matcher.find()) { logd("Cannot find MCC/MNC from " + selection); return null; } String plmn = matcher.group(1); logd("Query '" + plmn + "' APN settings"); logd("Query '" + FAKE_PLMN + "' APN settings"); MatrixCursor mc = new MatrixCursor( new String[]{Telephony.Carriers._ID, Telephony.Carriers.NUMERIC, Telephony.Carriers.NAME, Telephony.Carriers.APN, Loading @@ -248,7 +238,7 @@ public class DcTrackerTest extends TelephonyTest { mc.addRow(new Object[]{ 2163, // id plmn, // numeric FAKE_PLMN, // numeric "sp-mode", // name FAKE_APN1, // apn "", // proxy Loading Loading @@ -280,7 +270,7 @@ public class DcTrackerTest extends TelephonyTest { mc.addRow(new Object[]{ 2164, // id plmn, // numeric FAKE_PLMN, // numeric "mopera U", // name FAKE_APN2, // apn "", // proxy Loading Loading @@ -312,7 +302,7 @@ public class DcTrackerTest extends TelephonyTest { mc.addRow(new Object[]{ 2165, // id plmn, // numeric FAKE_PLMN, // numeric "b-mobile for Nexus", // name FAKE_APN3, // apn "", // proxy Loading Loading @@ -344,7 +334,7 @@ public class DcTrackerTest extends TelephonyTest { mc.addRow(new Object[]{ 2166, // id plmn, // numeric FAKE_PLMN, // numeric "sp-mode ehrpd", // name FAKE_APN4, // apn "", // proxy Loading Loading @@ -376,7 +366,7 @@ public class DcTrackerTest extends TelephonyTest { mc.addRow(new Object[]{ 2166, // id plmn, // numeric FAKE_PLMN, // numeric "b-mobile for Nexus", // name FAKE_APN5, // apn "", // proxy Loading Loading @@ -437,7 +427,6 @@ public class DcTrackerTest extends TelephonyTest { doReturn("fake.action_attached").when(mPhone).getActionAttached(); doReturn(ServiceState.RIL_RADIO_TECHNOLOGY_LTE).when(mServiceState) .getRilDataRadioTechnology(); doReturn("44010").when(mSimRecords).getOperatorNumeric(); mContextFixture.putStringArrayResource(com.android.internal.R.array.networkAttributes, sNetworkAttributes); Loading