Loading src/java/com/android/internal/telephony/dataconnection/ApnSetting.java +99 −12 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ public class ApnSetting { static final String V2_FORMAT_REGEX = "^\\[ApnSettingV2\\]\\s*"; static final String V3_FORMAT_REGEX = "^\\[ApnSettingV3\\]\\s*"; static final String V4_FORMAT_REGEX = "^\\[ApnSettingV4\\]\\s*"; static final String TAG = "ApnSetting"; public final String carrier; Loading Loading @@ -79,7 +80,10 @@ public class ApnSetting { * To check what values can hold, refer to ServiceState.java. * This should be spread to other technologies, * but currently only used for LTE(14) and EHRPD(13). * * @deprecated use {@code networkTypeBitmask} instead */ @Deprecated private final int bearer; /** * Radio Access Technology info Loading @@ -87,9 +91,19 @@ public class ApnSetting { * technologies in ServiceState. * This should be spread to other technologies, * but currently only used for LTE(14) and EHRPD(13). * * @deprecated use {@code networkTypeBitmask} instead */ @Deprecated public final int bearerBitmask; /** * Radio Technology (Network Type) info * To check what values can hold, refer to TelephonyManager.java. This is a bitmask of radio * technologies ({@code NETWORK_TYPE_} constants) in {@link TelephonyManager}. */ public final int networkTypeBitmask; /* ID of the profile in the modem */ public final int profileId; public final boolean modemCognitive; Loading Loading @@ -120,6 +134,11 @@ public class ApnSetting { * */ public boolean permanentFailed = false; /** * @deprecated this constructor is no longer supported. Use the other constructor which takes * a network type bitmask instead of the deprecated bearer bitmask and bearer field. * */ @Deprecated public ApnSetting(int id, String numeric, String carrier, String apn, String proxy, String port, String mmsc, String mmsProxy, String mmsPort, Loading Loading @@ -160,14 +179,59 @@ public class ApnSetting { this.mtu = mtu; this.mvnoType = mvnoType; this.mvnoMatchData = mvnoMatchData; this.networkTypeBitmask = ServiceState.convertBearerBitmaskToNetworkTypeBitmask( this.bearerBitmask); } public ApnSetting(int id, String numeric, String carrier, String apn, String proxy, String port, String mmsc, String mmsProxy, String mmsPort, String user, String password, int authType, String[] types, String protocol, String roamingProtocol, boolean carrierEnabled, int networkTypeBitmask, int profileId, boolean modemCognitive, int maxConns, int waitTime, int maxConnsTime, int mtu, String mvnoType, String mvnoMatchData) { this.id = id; this.numeric = numeric; this.carrier = carrier; this.apn = apn; this.proxy = proxy; this.port = port; this.mmsc = mmsc; this.mmsProxy = mmsProxy; this.mmsPort = mmsPort; this.user = user; this.password = password; this.authType = authType; this.types = new String[types.length]; int apnBitmap = 0; for (int i = 0; i < types.length; i++) { this.types[i] = types[i].toLowerCase(); apnBitmap |= getApnBitmask(this.types[i]); } this.typesBitmap = apnBitmap; this.protocol = protocol; this.roamingProtocol = roamingProtocol; this.carrierEnabled = carrierEnabled; this.bearer = 0; this.bearerBitmask = ServiceState.convertNetworkTypeBitmaskToBearerBitmask(networkTypeBitmask); this.networkTypeBitmask = networkTypeBitmask; this.profileId = profileId; this.modemCognitive = modemCognitive; this.maxConns = maxConns; this.waitTime = waitTime; this.maxConnsTime = maxConnsTime; this.mtu = mtu; this.mvnoType = mvnoType; this.mvnoMatchData = mvnoMatchData; } public ApnSetting(ApnSetting apn) { this(apn.id, apn.numeric, apn.carrier, apn.apn, apn.proxy, apn.port, apn.mmsc, apn.mmsProxy, apn.mmsPort, apn.user, apn.password, apn.authType, apn.types, apn.protocol, apn.roamingProtocol, apn.carrierEnabled, apn.bearer, apn.bearerBitmask, apn.profileId, apn.modemCognitive, apn.maxConns, apn.waitTime, apn.maxConnsTime, apn.roamingProtocol, apn.carrierEnabled, apn.networkTypeBitmask, apn.profileId, apn.modemCognitive, apn.maxConns, apn.waitTime, apn.maxConnsTime, apn.mtu, apn.mvnoType, apn.mvnoMatchData); } Loading Loading @@ -196,6 +260,13 @@ public class ApnSetting { * <profileId>, <modemCognitive>, <maxConns>, <waitTime>, <maxConnsTime>, <mtu>, * <mvnoType>, <mvnoMatchData> * * v4 format: * [ApnSettingV4] <carrier>, <apn>, <proxy>, <port>, <user>, <password>, <server>, * <mmsc>, <mmsproxy>, <mmsport>, <mcc>, <mnc>, <authtype>, * <type>[| <type>...], <protocol>, <roaming_protocol>, <carrierEnabled>, <bearerBitmask>, * <profileId>, <modemCognitive>, <maxConns>, <waitTime>, <maxConnsTime>, <mtu>, * <mvnoType>, <mvnoMatchData>, <networkTypeBitmask> * * Note that the strings generated by toString() do not contain the username * and password and thus cannot be read by this method. */ Loading @@ -204,7 +275,10 @@ public class ApnSetting { int version; // matches() operates on the whole string, so append .* to the regex. if (data.matches(V3_FORMAT_REGEX + ".*")) { if (data.matches(V4_FORMAT_REGEX + ".*")) { version = 4; data = data.replaceFirst(V4_FORMAT_REGEX, ""); } else if (data.matches(V3_FORMAT_REGEX + ".*")) { version = 3; data = data.replaceFirst(V3_FORMAT_REGEX, ""); } else if (data.matches(V2_FORMAT_REGEX + ".*")) { Loading @@ -230,6 +304,7 @@ public class ApnSetting { String protocol, roamingProtocol; boolean carrierEnabled; int bearerBitmask = 0; int networkTypeBitmask = 0; int profileId = 0; boolean modemCognitive = false; int maxConns = 0; Loading Loading @@ -275,12 +350,21 @@ public class ApnSetting { mvnoType = a[24]; mvnoMatchData = a[25]; } if (a.length > 26) { networkTypeBitmask = ServiceState.getBitmaskFromString(a[26]); } } return new ApnSetting(-1,a[10]+a[11],a[0],a[1],a[2],a[3],a[7],a[8], a[9],a[4],a[5],authType,typeArray,protocol,roamingProtocol,carrierEnabled,0, bearerBitmask, profileId, modemCognitive, maxConns, waitTime, maxConnsTime, mtu, mvnoType, mvnoMatchData); // If both bearerBitmask and networkTypeBitmask were specified, bearerBitmask would be // ignored. if (networkTypeBitmask == 0) { networkTypeBitmask = ServiceState.convertBearerBitmaskToNetworkTypeBitmask(bearerBitmask); } return new ApnSetting(-1, a[10] + a[11], a[0], a[1], a[2], a[3], a[7], a[8], a[9], a[4], a[5], authType, typeArray, protocol, roamingProtocol, carrierEnabled, networkTypeBitmask, profileId, modemCognitive, maxConns, waitTime, maxConnsTime, mtu, mvnoType, mvnoMatchData); } /** Loading Loading @@ -309,7 +393,7 @@ public class ApnSetting { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("[ApnSettingV3] ") sb.append("[ApnSettingV4] ") .append(carrier) .append(", ").append(id) .append(", ").append(numeric) Loading Loading @@ -340,6 +424,7 @@ public class ApnSetting { sb.append(", ").append(mvnoType); sb.append(", ").append(mvnoMatchData); sb.append(", ").append(permanentFailed); sb.append(", ").append(networkTypeBitmask); return sb.toString(); } Loading Loading @@ -565,14 +650,15 @@ public class ApnSetting { && maxConnsTime == other.maxConnsTime && mtu == other.mtu && mvnoType.equals(other.mvnoType) && mvnoMatchData.equals(other.mvnoMatchData); && mvnoMatchData.equals(other.mvnoMatchData) && networkTypeBitmask == other.networkTypeBitmask; } /** * Compare two APN settings * * Note: This method does not compare 'id', 'bearer', 'bearerBitmask'. We only use this for * determining if tearing a data call is needed when conditions change. See * Note: This method does not compare 'id', 'bearer', 'bearerBitmask', 'networkTypeBitmask'. * We only use this for determining if tearing a data call is needed when conditions change. See * cleanUpConnectionsOnUpdatedApns in DcTracker. * * @param o the other object to compare Loading Loading @@ -635,7 +721,8 @@ public class ApnSetting { && Objects.equals(this.mvnoMatchData, other.mvnoMatchData) && xorEquals(this.mmsc, other.mmsc) && xorEquals(this.mmsProxy, other.mmsProxy) && xorEquals(this.mmsPort, other.mmsPort)); && xorEquals(this.mmsPort, other.mmsPort)) && this.networkTypeBitmask == other.networkTypeBitmask; } // check whether the types of two APN same (even only one type of each APN is same) Loading src/java/com/android/internal/telephony/dataconnection/DcTracker.java +32 −13 Original line number Diff line number Diff line Loading @@ -1763,7 +1763,10 @@ public class DcTracker extends Handler { } for (ApnSetting dunSetting : dunCandidates) { if (!ServiceState.bitmaskHasTech(dunSetting.bearerBitmask, bearer)) continue; if (!ServiceState.bitmaskHasTech(dunSetting.networkTypeBitmask, ServiceState.rilRadioTechnologyToNetworkType(bearer))) { continue; } if (dunSetting.numeric.equals(operator)) { if (dunSetting.hasMvnoParams()) { if (r != null && ApnSetting.mvnoMatches(r, dunSetting.mvnoType, Loading Loading @@ -1841,6 +1844,9 @@ public class DcTracker extends Handler { private ApnSetting makeApnSetting(Cursor cursor) { String[] types = parseTypes( cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.TYPE))); int networkTypeBitmask = cursor.getInt( cursor.getColumnIndexOrThrow(Telephony.Carriers.NETWORK_TYPE_BITMASK)); ApnSetting apn = new ApnSetting( cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers._ID)), cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.NUMERIC)), Loading @@ -1866,8 +1872,7 @@ public class DcTracker extends Handler { Telephony.Carriers.ROAMING_PROTOCOL)), cursor.getInt(cursor.getColumnIndexOrThrow( Telephony.Carriers.CARRIER_ENABLED)) == 1, cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.BEARER)), cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.BEARER_BITMASK)), networkTypeBitmask, cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.PROFILE_ID)), cursor.getInt(cursor.getColumnIndexOrThrow( Telephony.Carriers.MODEM_COGNITIVE)) == 1, Loading Loading @@ -3392,13 +3397,19 @@ public class DcTracker extends Handler { String protocol = src.protocol.equals("IPV4V6") ? src.protocol : dest.protocol; String roamingProtocol = src.roamingProtocol.equals("IPV4V6") ? src.roamingProtocol : dest.roamingProtocol; int bearerBitmask = (dest.bearerBitmask == 0 || src.bearerBitmask == 0) ? 0 : (dest.bearerBitmask | src.bearerBitmask); int networkTypeBitmask = (dest.networkTypeBitmask == 0 || src.networkTypeBitmask == 0) ? 0 : (dest.networkTypeBitmask | src.networkTypeBitmask); if (networkTypeBitmask == 0) { int bearerBitmask = (dest.bearerBitmask == 0 || src.bearerBitmask == 0) ? 0 : (dest.bearerBitmask | src.bearerBitmask); networkTypeBitmask = ServiceState.convertBearerBitmaskToNetworkTypeBitmask( bearerBitmask); } return new ApnSetting(id, dest.numeric, dest.carrier, dest.apn, proxy, port, mmsc, mmsProxy, mmsPort, dest.user, dest.password, dest.authType, resultTypes.toArray(new String[0]), protocol, roamingProtocol, dest.carrierEnabled, 0, bearerBitmask, dest.profileId, roamingProtocol, dest.carrierEnabled, networkTypeBitmask, dest.profileId, (dest.modemCognitive || src.modemCognitive), dest.maxConns, dest.waitTime, dest.maxConnsTime, dest.mtu, dest.mvnoType, dest.mvnoMatchData); } Loading Loading @@ -3486,7 +3497,8 @@ public class DcTracker extends Handler { + mPreferredApn.numeric + ":" + mPreferredApn); } if (mPreferredApn.numeric.equals(operator)) { if (ServiceState.bitmaskHasTech(mPreferredApn.bearerBitmask, radioTech)) { if (ServiceState.bitmaskHasTech(mPreferredApn.networkTypeBitmask, ServiceState.rilRadioTechnologyToNetworkType(radioTech))) { apnList.add(mPreferredApn); if (DBG) log("buildWaitingApns: X added preferred apnList=" + apnList); return apnList; Loading @@ -3505,13 +3517,15 @@ public class DcTracker extends Handler { if (DBG) log("buildWaitingApns: mAllApnSettings=" + mAllApnSettings); for (ApnSetting apn : mAllApnSettings) { if (apn.canHandleType(requestedApnType)) { if (ServiceState.bitmaskHasTech(apn.bearerBitmask, radioTech)) { if (ServiceState.bitmaskHasTech(apn.networkTypeBitmask, ServiceState.rilRadioTechnologyToNetworkType(radioTech))) { if (DBG) log("buildWaitingApns: adding apn=" + apn); apnList.add(apn); } else { if (DBG) { log("buildWaitingApns: bearerBitmask:" + apn.bearerBitmask + " does " + "not include radioTech:" + radioTech); log("buildWaitingApns: bearerBitmask:" + apn.bearerBitmask + " or " + "networkTypeBitmask:" + apn.networkTypeBitmask + "do not include radioTech:" + radioTech); } } } else if (DBG) { Loading Loading @@ -4816,9 +4830,14 @@ public class DcTracker extends Handler { @VisibleForTesting public static DataProfile createDataProfile(ApnSetting apn, int profileId) { int profileType; if (apn.bearerBitmask == 0) { int bearerBitmap = 0; bearerBitmap = ServiceState.convertNetworkTypeBitmaskToBearerBitmask( apn.networkTypeBitmask); if (bearerBitmap == 0) { profileType = DataProfile.TYPE_COMMON; } else if (ServiceState.bearerBitmapHasCdma(apn.bearerBitmask)) { } else if (ServiceState.bearerBitmapHasCdma(bearerBitmap)) { profileType = DataProfile.TYPE_3GPP2; } else { profileType = DataProfile.TYPE_3GPP; Loading @@ -4827,7 +4846,7 @@ public class DcTracker extends Handler { return new DataProfile(profileId, apn.apn, apn.protocol, apn.authType, apn.user, apn.password, profileType, apn.maxConnsTime, apn.maxConns, apn.waitTime, apn.carrierEnabled, apn.typesBitmap, apn.roamingProtocol, apn.bearerBitmask, apn.mtu, apn.mvnoType, apn.mvnoMatchData, apn.roamingProtocol, bearerBitmap, apn.mtu, apn.mvnoType, apn.mvnoMatchData, apn.modemCognitive); } } tests/telephonytests/src/com/android/internal/telephony/ServiceStateTest.java +49 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,55 @@ public class ServiceStateTest extends TestCase { assertEquals(ServiceState.STATE_IN_SERVICE, ss.getVoiceRegState()); } @SmallTest public void testBitmaskFromString() { String networkTypeList = "4|7|5|6|12|13|14|19"; int networkTypeBitmask = 1 << (4 - 1) | 1 << (7 - 1) | 1 << (5 - 1) | 1 << (6 - 1) | 1 << (12 - 1) | 1 << (14 - 1) | 1 << (13 - 1) | 1 << (19 - 1); assertEquals(networkTypeBitmask, ServiceState.getBitmaskFromString(networkTypeList)); networkTypeList = "13"; networkTypeBitmask = 1 << (13 - 1); assertEquals(networkTypeBitmask, ServiceState.getBitmaskFromString(networkTypeList)); networkTypeList = ""; networkTypeBitmask = 0; assertEquals(networkTypeBitmask, ServiceState.getBitmaskFromString(networkTypeList)); } @SmallTest public void testConvertNetworkTypeBitmaskToBearerBitmask() { // The value was calculated by adding "4|4|7|5|6|12|14|13|19". int networkTypeBitmask = 276600; // The value was calculated by adding "4|5|6|7|8|12|13|14|19". int bearerBitmask = 276728; assertEquals(bearerBitmask, ServiceState.convertNetworkTypeBitmaskToBearerBitmask(networkTypeBitmask)); networkTypeBitmask = 0; bearerBitmask = 0; assertEquals(bearerBitmask, ServiceState.convertNetworkTypeBitmaskToBearerBitmask(networkTypeBitmask)); } @SmallTest public void testConvertBearerBitmaskToNetworkTypeBitmask() { // The value was calculated by adding "4|4|7|5|6|12|14|13|19". int networkTypeBitmask = 276600; // The value was calculated by adding "4|5|6|7|8|12|13|14|19". int bearerBitmask = 276728; assertEquals(networkTypeBitmask, ServiceState.convertBearerBitmaskToNetworkTypeBitmask(bearerBitmask)); networkTypeBitmask = 0; bearerBitmask = 0; assertEquals(networkTypeBitmask, ServiceState.convertBearerBitmaskToNetworkTypeBitmask(bearerBitmask)); } @SmallTest public void testRAT() { ServiceState ss = new ServiceState(); Loading tests/telephonytests/src/com/android/internal/telephony/dataconnection/ApnSettingTest.java +54 −3 Original line number Diff line number Diff line Loading @@ -137,6 +137,7 @@ public class ApnSettingTest extends TelephonyTest { assertEquals(a1.mtu, a2.mtu); assertEquals(a1.mvnoType, a2.mvnoType); assertEquals(a1.mvnoMatchData, a2.mvnoMatchData); assertEquals(a1.networkTypeBitmask, a2.networkTypeBitmask); } @Test Loading Loading @@ -171,6 +172,11 @@ public class ApnSettingTest extends TelephonyTest { "", "", "", "", "", 0, mmsTypes, "IPV6", "IP", true, 14, 0, 0, false, 0, 0, 0, 0, "", ""); assertApnSettingEqual(expectedApn, ApnSetting.fromString(testString)); int networkTypeBitmask = 1 << (13 - 1); expectedApn = new ApnSetting( -1, "12345", "Name", "apn", "", "", "", "", "", "", "", 0, mmsTypes, "IPV6", "IP", true, networkTypeBitmask, 0, false, 0, 0, 0, 0, "", ""); assertApnSettingEqual(expectedApn, ApnSetting.fromString(testString)); // A v3 string. testString = "[ApnSettingV3] Name,apn,,,,,,,,,123,45,,mms|*,IPV6,IP,true,14,,,,,,,spn,testspn"; Loading @@ -179,6 +185,51 @@ public class ApnSettingTest extends TelephonyTest { "IP", true, 14, 0, 0, false, 0, 0, 0, 0, "spn", "testspn"); assertApnSettingEqual(expectedApn, ApnSetting.fromString(testString)); // A v4 string with network type bitmask. testString = "[ApnSettingV4] Name,apn,,,,,,,,,123,45,,mms|*,IPV6,IP,true,0,,,,,,,spn,testspn,6"; networkTypeBitmask = 1 << (6 - 1); expectedApn = new ApnSetting( -1, "12345", "Name", "apn", "", "", "", "", "", "", "", 0, mmsTypes, "IPV6", "IP", true, networkTypeBitmask, 0, false, 0, 0, 0, 0, "spn", "testspn"); assertApnSettingEqual(expectedApn, ApnSetting.fromString(testString)); testString = "[ApnSettingV4] Name,apn,,,,,,,,,123,45,,mms|*,IPV6,IP,true,0,,,,,,,spn,testspn," + "4|5|6|7|8|12|13|14|19"; // The value was calculated by adding "4|5|6|7|8|12|13|14|19". networkTypeBitmask = 276728; expectedApn = new ApnSetting( -1, "12345", "Name", "apn", "", "", "", "", "", "", "", 0, mmsTypes, "IPV6", "IP", true, networkTypeBitmask, 0, false, 0, 0, 0, 0, "spn", "testspn"); assertApnSettingEqual(expectedApn, ApnSetting.fromString(testString)); // A v4 string with network type bitmask and compatible bearer bitmask. testString = "[ApnSettingV4] Name,apn,,,,,,,,,123,45,,mms|*,IPV6,IP,true,8,,,,,,,spn,testspn, 6"; networkTypeBitmask = 1 << (6 - 1); int bearerBitmask = 1 << (8 - 1); expectedApn = new ApnSetting( -1, "12345", "Name", "apn", "", "", "", "", "", "", "", 0, mmsTypes, "IPV6", "IP", true, 0, bearerBitmask, 0, false, 0, 0, 0, 0, "spn", "testspn"); assertApnSettingEqual(expectedApn, ApnSetting.fromString(testString)); expectedApn = new ApnSetting( -1, "12345", "Name", "apn", "", "", "", "", "", "", "", 0, mmsTypes, "IPV6", "IP", true, networkTypeBitmask, 0, false, 0, 0, 0, 0, "spn", "testspn"); assertApnSettingEqual(expectedApn, ApnSetting.fromString(testString)); // A v4 string with network type bitmask and incompatible bearer bitmask. testString = "[ApnSettingV4] Name,apn,,,,,,,,,123,45,,mms|*,IPV6,IP,true,9,,,,,,,spn,testspn, 6"; bearerBitmask = 1 << (8 - 1); expectedApn = new ApnSetting( -1, "12345", "Name", "apn", "", "", "", "", "", "", "", 0, mmsTypes, "IPV6", "IP", true, 0, bearerBitmask, 0, false, 0, 0, 0, 0, "spn", "testspn"); assertApnSettingEqual(expectedApn, ApnSetting.fromString(testString)); // Return no apn if insufficient fields given. testString = "[ApnSettingV3] Name,apn,,,,,,,,,123, 45,,mms|*"; assertEquals(null, ApnSetting.fromString(testString)); Loading Loading @@ -218,9 +269,9 @@ public class ApnSettingTest extends TelephonyTest { 99, "12345", "Name", "apn", "proxy", "port", "mmsc", "mmsproxy", "mmsport", "user", "password", 0, types, "IPV6", "IP", true, 14, 0, 0, false, 0, 0, 0, 0, "", ""); String expected = "[ApnSettingV3] Name, 99, 12345, apn, proxy, " + "mmsc, mmsproxy, mmsport, port, 0, default | *, " + "IPV6, IP, true, 14, 8192, 0, false, 0, 0, 0, 0, , , false"; String expected = "[ApnSettingV4] Name, 99, 12345, apn, proxy, " + "mmsc, mmsproxy, mmsport, port, 0, default | *, " + "IPV6, IP, true, 14, 8192, 0, false, 0, 0, 0, 0, , , false, 4096"; assertEquals(expected, apn.toString()); } Loading tests/telephonytests/src/com/android/internal/telephony/dataconnection/DataProfileTest.java +49 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.internal.telephony.dataconnection; import android.telephony.ServiceState; import android.telephony.data.DataProfile; import android.test.suitebuilder.annotation.SmallTest; Loading Loading @@ -81,6 +82,34 @@ public class DataProfileTest extends TestCase { "", // mvno_type ""); // mnvo_match_data private ApnSetting mApn3 = new ApnSetting( 2163, // id "44010", // numeric "sp-mode", // name "fake_apn", // apn "", // proxy "", // port "", // mmsc "", // mmsproxy "", // mmsport "user", // user "passwd", // password -1, // authtype new String[]{"default", "supl"}, // types "IP", // protocol "IP", // roaming_protocol true, // carrier_enabled 276600, // network_type_bitmask 1234, // profile_id false, // modem_cognitive 111, // max_conns 456, // wait_time 789, // max_conns_time 0, // mtu "", // mvno_type "" // mnvo_match_data ); @SmallTest public void testCreateFromApnSetting() throws Exception { DataProfile dp = DcTracker.createDataProfile(mApn1, mApn1.profileId); Loading @@ -90,13 +119,32 @@ public class DataProfileTest extends TestCase { assertEquals(RILConstants.SETUP_DATA_AUTH_PAP_CHAP, dp.getAuthType()); assertEquals(mApn1.user, dp.getUserName()); assertEquals(mApn1.password, dp.getPassword()); assertEquals(0, dp.getType()); assertEquals(0, dp.getType()); // TYPE_COMMON assertEquals(mApn1.maxConnsTime, dp.getMaxConnsTime()); assertEquals(mApn1.maxConns, dp.getMaxConns()); assertEquals(mApn1.waitTime, dp.getWaitTime()); assertEquals(mApn1.carrierEnabled, dp.isEnabled()); } @SmallTest public void testCreateFromApnSettingWithNetworkTypeBitmask() throws Exception { DataProfile dp = DcTracker.createDataProfile(mApn3, mApn3.profileId); assertEquals(mApn3.profileId, dp.getProfileId()); assertEquals(mApn3.apn, dp.getApn()); assertEquals(mApn3.protocol, dp.getProtocol()); assertEquals(RILConstants.SETUP_DATA_AUTH_PAP_CHAP, dp.getAuthType()); assertEquals(mApn3.user, dp.getUserName()); assertEquals(mApn3.password, dp.getPassword()); assertEquals(2, dp.getType()); // TYPE_3GPP2 assertEquals(mApn3.maxConnsTime, dp.getMaxConnsTime()); assertEquals(mApn3.maxConns, dp.getMaxConns()); assertEquals(mApn3.waitTime, dp.getWaitTime()); assertEquals(mApn3.carrierEnabled, dp.isEnabled()); int expectedBearerBitmap = ServiceState.convertNetworkTypeBitmaskToBearerBitmask(mApn3.networkTypeBitmask); assertEquals(expectedBearerBitmap, dp.getBearerBitmap()); } @SmallTest public void testEquals() throws Exception { DataProfile dp1 = DcTracker.createDataProfile(mApn1, mApn1.profileId); Loading Loading
src/java/com/android/internal/telephony/dataconnection/ApnSetting.java +99 −12 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ public class ApnSetting { static final String V2_FORMAT_REGEX = "^\\[ApnSettingV2\\]\\s*"; static final String V3_FORMAT_REGEX = "^\\[ApnSettingV3\\]\\s*"; static final String V4_FORMAT_REGEX = "^\\[ApnSettingV4\\]\\s*"; static final String TAG = "ApnSetting"; public final String carrier; Loading Loading @@ -79,7 +80,10 @@ public class ApnSetting { * To check what values can hold, refer to ServiceState.java. * This should be spread to other technologies, * but currently only used for LTE(14) and EHRPD(13). * * @deprecated use {@code networkTypeBitmask} instead */ @Deprecated private final int bearer; /** * Radio Access Technology info Loading @@ -87,9 +91,19 @@ public class ApnSetting { * technologies in ServiceState. * This should be spread to other technologies, * but currently only used for LTE(14) and EHRPD(13). * * @deprecated use {@code networkTypeBitmask} instead */ @Deprecated public final int bearerBitmask; /** * Radio Technology (Network Type) info * To check what values can hold, refer to TelephonyManager.java. This is a bitmask of radio * technologies ({@code NETWORK_TYPE_} constants) in {@link TelephonyManager}. */ public final int networkTypeBitmask; /* ID of the profile in the modem */ public final int profileId; public final boolean modemCognitive; Loading Loading @@ -120,6 +134,11 @@ public class ApnSetting { * */ public boolean permanentFailed = false; /** * @deprecated this constructor is no longer supported. Use the other constructor which takes * a network type bitmask instead of the deprecated bearer bitmask and bearer field. * */ @Deprecated public ApnSetting(int id, String numeric, String carrier, String apn, String proxy, String port, String mmsc, String mmsProxy, String mmsPort, Loading Loading @@ -160,14 +179,59 @@ public class ApnSetting { this.mtu = mtu; this.mvnoType = mvnoType; this.mvnoMatchData = mvnoMatchData; this.networkTypeBitmask = ServiceState.convertBearerBitmaskToNetworkTypeBitmask( this.bearerBitmask); } public ApnSetting(int id, String numeric, String carrier, String apn, String proxy, String port, String mmsc, String mmsProxy, String mmsPort, String user, String password, int authType, String[] types, String protocol, String roamingProtocol, boolean carrierEnabled, int networkTypeBitmask, int profileId, boolean modemCognitive, int maxConns, int waitTime, int maxConnsTime, int mtu, String mvnoType, String mvnoMatchData) { this.id = id; this.numeric = numeric; this.carrier = carrier; this.apn = apn; this.proxy = proxy; this.port = port; this.mmsc = mmsc; this.mmsProxy = mmsProxy; this.mmsPort = mmsPort; this.user = user; this.password = password; this.authType = authType; this.types = new String[types.length]; int apnBitmap = 0; for (int i = 0; i < types.length; i++) { this.types[i] = types[i].toLowerCase(); apnBitmap |= getApnBitmask(this.types[i]); } this.typesBitmap = apnBitmap; this.protocol = protocol; this.roamingProtocol = roamingProtocol; this.carrierEnabled = carrierEnabled; this.bearer = 0; this.bearerBitmask = ServiceState.convertNetworkTypeBitmaskToBearerBitmask(networkTypeBitmask); this.networkTypeBitmask = networkTypeBitmask; this.profileId = profileId; this.modemCognitive = modemCognitive; this.maxConns = maxConns; this.waitTime = waitTime; this.maxConnsTime = maxConnsTime; this.mtu = mtu; this.mvnoType = mvnoType; this.mvnoMatchData = mvnoMatchData; } public ApnSetting(ApnSetting apn) { this(apn.id, apn.numeric, apn.carrier, apn.apn, apn.proxy, apn.port, apn.mmsc, apn.mmsProxy, apn.mmsPort, apn.user, apn.password, apn.authType, apn.types, apn.protocol, apn.roamingProtocol, apn.carrierEnabled, apn.bearer, apn.bearerBitmask, apn.profileId, apn.modemCognitive, apn.maxConns, apn.waitTime, apn.maxConnsTime, apn.roamingProtocol, apn.carrierEnabled, apn.networkTypeBitmask, apn.profileId, apn.modemCognitive, apn.maxConns, apn.waitTime, apn.maxConnsTime, apn.mtu, apn.mvnoType, apn.mvnoMatchData); } Loading Loading @@ -196,6 +260,13 @@ public class ApnSetting { * <profileId>, <modemCognitive>, <maxConns>, <waitTime>, <maxConnsTime>, <mtu>, * <mvnoType>, <mvnoMatchData> * * v4 format: * [ApnSettingV4] <carrier>, <apn>, <proxy>, <port>, <user>, <password>, <server>, * <mmsc>, <mmsproxy>, <mmsport>, <mcc>, <mnc>, <authtype>, * <type>[| <type>...], <protocol>, <roaming_protocol>, <carrierEnabled>, <bearerBitmask>, * <profileId>, <modemCognitive>, <maxConns>, <waitTime>, <maxConnsTime>, <mtu>, * <mvnoType>, <mvnoMatchData>, <networkTypeBitmask> * * Note that the strings generated by toString() do not contain the username * and password and thus cannot be read by this method. */ Loading @@ -204,7 +275,10 @@ public class ApnSetting { int version; // matches() operates on the whole string, so append .* to the regex. if (data.matches(V3_FORMAT_REGEX + ".*")) { if (data.matches(V4_FORMAT_REGEX + ".*")) { version = 4; data = data.replaceFirst(V4_FORMAT_REGEX, ""); } else if (data.matches(V3_FORMAT_REGEX + ".*")) { version = 3; data = data.replaceFirst(V3_FORMAT_REGEX, ""); } else if (data.matches(V2_FORMAT_REGEX + ".*")) { Loading @@ -230,6 +304,7 @@ public class ApnSetting { String protocol, roamingProtocol; boolean carrierEnabled; int bearerBitmask = 0; int networkTypeBitmask = 0; int profileId = 0; boolean modemCognitive = false; int maxConns = 0; Loading Loading @@ -275,12 +350,21 @@ public class ApnSetting { mvnoType = a[24]; mvnoMatchData = a[25]; } if (a.length > 26) { networkTypeBitmask = ServiceState.getBitmaskFromString(a[26]); } } return new ApnSetting(-1,a[10]+a[11],a[0],a[1],a[2],a[3],a[7],a[8], a[9],a[4],a[5],authType,typeArray,protocol,roamingProtocol,carrierEnabled,0, bearerBitmask, profileId, modemCognitive, maxConns, waitTime, maxConnsTime, mtu, mvnoType, mvnoMatchData); // If both bearerBitmask and networkTypeBitmask were specified, bearerBitmask would be // ignored. if (networkTypeBitmask == 0) { networkTypeBitmask = ServiceState.convertBearerBitmaskToNetworkTypeBitmask(bearerBitmask); } return new ApnSetting(-1, a[10] + a[11], a[0], a[1], a[2], a[3], a[7], a[8], a[9], a[4], a[5], authType, typeArray, protocol, roamingProtocol, carrierEnabled, networkTypeBitmask, profileId, modemCognitive, maxConns, waitTime, maxConnsTime, mtu, mvnoType, mvnoMatchData); } /** Loading Loading @@ -309,7 +393,7 @@ public class ApnSetting { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("[ApnSettingV3] ") sb.append("[ApnSettingV4] ") .append(carrier) .append(", ").append(id) .append(", ").append(numeric) Loading Loading @@ -340,6 +424,7 @@ public class ApnSetting { sb.append(", ").append(mvnoType); sb.append(", ").append(mvnoMatchData); sb.append(", ").append(permanentFailed); sb.append(", ").append(networkTypeBitmask); return sb.toString(); } Loading Loading @@ -565,14 +650,15 @@ public class ApnSetting { && maxConnsTime == other.maxConnsTime && mtu == other.mtu && mvnoType.equals(other.mvnoType) && mvnoMatchData.equals(other.mvnoMatchData); && mvnoMatchData.equals(other.mvnoMatchData) && networkTypeBitmask == other.networkTypeBitmask; } /** * Compare two APN settings * * Note: This method does not compare 'id', 'bearer', 'bearerBitmask'. We only use this for * determining if tearing a data call is needed when conditions change. See * Note: This method does not compare 'id', 'bearer', 'bearerBitmask', 'networkTypeBitmask'. * We only use this for determining if tearing a data call is needed when conditions change. See * cleanUpConnectionsOnUpdatedApns in DcTracker. * * @param o the other object to compare Loading Loading @@ -635,7 +721,8 @@ public class ApnSetting { && Objects.equals(this.mvnoMatchData, other.mvnoMatchData) && xorEquals(this.mmsc, other.mmsc) && xorEquals(this.mmsProxy, other.mmsProxy) && xorEquals(this.mmsPort, other.mmsPort)); && xorEquals(this.mmsPort, other.mmsPort)) && this.networkTypeBitmask == other.networkTypeBitmask; } // check whether the types of two APN same (even only one type of each APN is same) Loading
src/java/com/android/internal/telephony/dataconnection/DcTracker.java +32 −13 Original line number Diff line number Diff line Loading @@ -1763,7 +1763,10 @@ public class DcTracker extends Handler { } for (ApnSetting dunSetting : dunCandidates) { if (!ServiceState.bitmaskHasTech(dunSetting.bearerBitmask, bearer)) continue; if (!ServiceState.bitmaskHasTech(dunSetting.networkTypeBitmask, ServiceState.rilRadioTechnologyToNetworkType(bearer))) { continue; } if (dunSetting.numeric.equals(operator)) { if (dunSetting.hasMvnoParams()) { if (r != null && ApnSetting.mvnoMatches(r, dunSetting.mvnoType, Loading Loading @@ -1841,6 +1844,9 @@ public class DcTracker extends Handler { private ApnSetting makeApnSetting(Cursor cursor) { String[] types = parseTypes( cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.TYPE))); int networkTypeBitmask = cursor.getInt( cursor.getColumnIndexOrThrow(Telephony.Carriers.NETWORK_TYPE_BITMASK)); ApnSetting apn = new ApnSetting( cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers._ID)), cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.NUMERIC)), Loading @@ -1866,8 +1872,7 @@ public class DcTracker extends Handler { Telephony.Carriers.ROAMING_PROTOCOL)), cursor.getInt(cursor.getColumnIndexOrThrow( Telephony.Carriers.CARRIER_ENABLED)) == 1, cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.BEARER)), cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.BEARER_BITMASK)), networkTypeBitmask, cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.PROFILE_ID)), cursor.getInt(cursor.getColumnIndexOrThrow( Telephony.Carriers.MODEM_COGNITIVE)) == 1, Loading Loading @@ -3392,13 +3397,19 @@ public class DcTracker extends Handler { String protocol = src.protocol.equals("IPV4V6") ? src.protocol : dest.protocol; String roamingProtocol = src.roamingProtocol.equals("IPV4V6") ? src.roamingProtocol : dest.roamingProtocol; int bearerBitmask = (dest.bearerBitmask == 0 || src.bearerBitmask == 0) ? 0 : (dest.bearerBitmask | src.bearerBitmask); int networkTypeBitmask = (dest.networkTypeBitmask == 0 || src.networkTypeBitmask == 0) ? 0 : (dest.networkTypeBitmask | src.networkTypeBitmask); if (networkTypeBitmask == 0) { int bearerBitmask = (dest.bearerBitmask == 0 || src.bearerBitmask == 0) ? 0 : (dest.bearerBitmask | src.bearerBitmask); networkTypeBitmask = ServiceState.convertBearerBitmaskToNetworkTypeBitmask( bearerBitmask); } return new ApnSetting(id, dest.numeric, dest.carrier, dest.apn, proxy, port, mmsc, mmsProxy, mmsPort, dest.user, dest.password, dest.authType, resultTypes.toArray(new String[0]), protocol, roamingProtocol, dest.carrierEnabled, 0, bearerBitmask, dest.profileId, roamingProtocol, dest.carrierEnabled, networkTypeBitmask, dest.profileId, (dest.modemCognitive || src.modemCognitive), dest.maxConns, dest.waitTime, dest.maxConnsTime, dest.mtu, dest.mvnoType, dest.mvnoMatchData); } Loading Loading @@ -3486,7 +3497,8 @@ public class DcTracker extends Handler { + mPreferredApn.numeric + ":" + mPreferredApn); } if (mPreferredApn.numeric.equals(operator)) { if (ServiceState.bitmaskHasTech(mPreferredApn.bearerBitmask, radioTech)) { if (ServiceState.bitmaskHasTech(mPreferredApn.networkTypeBitmask, ServiceState.rilRadioTechnologyToNetworkType(radioTech))) { apnList.add(mPreferredApn); if (DBG) log("buildWaitingApns: X added preferred apnList=" + apnList); return apnList; Loading @@ -3505,13 +3517,15 @@ public class DcTracker extends Handler { if (DBG) log("buildWaitingApns: mAllApnSettings=" + mAllApnSettings); for (ApnSetting apn : mAllApnSettings) { if (apn.canHandleType(requestedApnType)) { if (ServiceState.bitmaskHasTech(apn.bearerBitmask, radioTech)) { if (ServiceState.bitmaskHasTech(apn.networkTypeBitmask, ServiceState.rilRadioTechnologyToNetworkType(radioTech))) { if (DBG) log("buildWaitingApns: adding apn=" + apn); apnList.add(apn); } else { if (DBG) { log("buildWaitingApns: bearerBitmask:" + apn.bearerBitmask + " does " + "not include radioTech:" + radioTech); log("buildWaitingApns: bearerBitmask:" + apn.bearerBitmask + " or " + "networkTypeBitmask:" + apn.networkTypeBitmask + "do not include radioTech:" + radioTech); } } } else if (DBG) { Loading Loading @@ -4816,9 +4830,14 @@ public class DcTracker extends Handler { @VisibleForTesting public static DataProfile createDataProfile(ApnSetting apn, int profileId) { int profileType; if (apn.bearerBitmask == 0) { int bearerBitmap = 0; bearerBitmap = ServiceState.convertNetworkTypeBitmaskToBearerBitmask( apn.networkTypeBitmask); if (bearerBitmap == 0) { profileType = DataProfile.TYPE_COMMON; } else if (ServiceState.bearerBitmapHasCdma(apn.bearerBitmask)) { } else if (ServiceState.bearerBitmapHasCdma(bearerBitmap)) { profileType = DataProfile.TYPE_3GPP2; } else { profileType = DataProfile.TYPE_3GPP; Loading @@ -4827,7 +4846,7 @@ public class DcTracker extends Handler { return new DataProfile(profileId, apn.apn, apn.protocol, apn.authType, apn.user, apn.password, profileType, apn.maxConnsTime, apn.maxConns, apn.waitTime, apn.carrierEnabled, apn.typesBitmap, apn.roamingProtocol, apn.bearerBitmask, apn.mtu, apn.mvnoType, apn.mvnoMatchData, apn.roamingProtocol, bearerBitmap, apn.mtu, apn.mvnoType, apn.mvnoMatchData, apn.modemCognitive); } }
tests/telephonytests/src/com/android/internal/telephony/ServiceStateTest.java +49 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,55 @@ public class ServiceStateTest extends TestCase { assertEquals(ServiceState.STATE_IN_SERVICE, ss.getVoiceRegState()); } @SmallTest public void testBitmaskFromString() { String networkTypeList = "4|7|5|6|12|13|14|19"; int networkTypeBitmask = 1 << (4 - 1) | 1 << (7 - 1) | 1 << (5 - 1) | 1 << (6 - 1) | 1 << (12 - 1) | 1 << (14 - 1) | 1 << (13 - 1) | 1 << (19 - 1); assertEquals(networkTypeBitmask, ServiceState.getBitmaskFromString(networkTypeList)); networkTypeList = "13"; networkTypeBitmask = 1 << (13 - 1); assertEquals(networkTypeBitmask, ServiceState.getBitmaskFromString(networkTypeList)); networkTypeList = ""; networkTypeBitmask = 0; assertEquals(networkTypeBitmask, ServiceState.getBitmaskFromString(networkTypeList)); } @SmallTest public void testConvertNetworkTypeBitmaskToBearerBitmask() { // The value was calculated by adding "4|4|7|5|6|12|14|13|19". int networkTypeBitmask = 276600; // The value was calculated by adding "4|5|6|7|8|12|13|14|19". int bearerBitmask = 276728; assertEquals(bearerBitmask, ServiceState.convertNetworkTypeBitmaskToBearerBitmask(networkTypeBitmask)); networkTypeBitmask = 0; bearerBitmask = 0; assertEquals(bearerBitmask, ServiceState.convertNetworkTypeBitmaskToBearerBitmask(networkTypeBitmask)); } @SmallTest public void testConvertBearerBitmaskToNetworkTypeBitmask() { // The value was calculated by adding "4|4|7|5|6|12|14|13|19". int networkTypeBitmask = 276600; // The value was calculated by adding "4|5|6|7|8|12|13|14|19". int bearerBitmask = 276728; assertEquals(networkTypeBitmask, ServiceState.convertBearerBitmaskToNetworkTypeBitmask(bearerBitmask)); networkTypeBitmask = 0; bearerBitmask = 0; assertEquals(networkTypeBitmask, ServiceState.convertBearerBitmaskToNetworkTypeBitmask(bearerBitmask)); } @SmallTest public void testRAT() { ServiceState ss = new ServiceState(); Loading
tests/telephonytests/src/com/android/internal/telephony/dataconnection/ApnSettingTest.java +54 −3 Original line number Diff line number Diff line Loading @@ -137,6 +137,7 @@ public class ApnSettingTest extends TelephonyTest { assertEquals(a1.mtu, a2.mtu); assertEquals(a1.mvnoType, a2.mvnoType); assertEquals(a1.mvnoMatchData, a2.mvnoMatchData); assertEquals(a1.networkTypeBitmask, a2.networkTypeBitmask); } @Test Loading Loading @@ -171,6 +172,11 @@ public class ApnSettingTest extends TelephonyTest { "", "", "", "", "", 0, mmsTypes, "IPV6", "IP", true, 14, 0, 0, false, 0, 0, 0, 0, "", ""); assertApnSettingEqual(expectedApn, ApnSetting.fromString(testString)); int networkTypeBitmask = 1 << (13 - 1); expectedApn = new ApnSetting( -1, "12345", "Name", "apn", "", "", "", "", "", "", "", 0, mmsTypes, "IPV6", "IP", true, networkTypeBitmask, 0, false, 0, 0, 0, 0, "", ""); assertApnSettingEqual(expectedApn, ApnSetting.fromString(testString)); // A v3 string. testString = "[ApnSettingV3] Name,apn,,,,,,,,,123,45,,mms|*,IPV6,IP,true,14,,,,,,,spn,testspn"; Loading @@ -179,6 +185,51 @@ public class ApnSettingTest extends TelephonyTest { "IP", true, 14, 0, 0, false, 0, 0, 0, 0, "spn", "testspn"); assertApnSettingEqual(expectedApn, ApnSetting.fromString(testString)); // A v4 string with network type bitmask. testString = "[ApnSettingV4] Name,apn,,,,,,,,,123,45,,mms|*,IPV6,IP,true,0,,,,,,,spn,testspn,6"; networkTypeBitmask = 1 << (6 - 1); expectedApn = new ApnSetting( -1, "12345", "Name", "apn", "", "", "", "", "", "", "", 0, mmsTypes, "IPV6", "IP", true, networkTypeBitmask, 0, false, 0, 0, 0, 0, "spn", "testspn"); assertApnSettingEqual(expectedApn, ApnSetting.fromString(testString)); testString = "[ApnSettingV4] Name,apn,,,,,,,,,123,45,,mms|*,IPV6,IP,true,0,,,,,,,spn,testspn," + "4|5|6|7|8|12|13|14|19"; // The value was calculated by adding "4|5|6|7|8|12|13|14|19". networkTypeBitmask = 276728; expectedApn = new ApnSetting( -1, "12345", "Name", "apn", "", "", "", "", "", "", "", 0, mmsTypes, "IPV6", "IP", true, networkTypeBitmask, 0, false, 0, 0, 0, 0, "spn", "testspn"); assertApnSettingEqual(expectedApn, ApnSetting.fromString(testString)); // A v4 string with network type bitmask and compatible bearer bitmask. testString = "[ApnSettingV4] Name,apn,,,,,,,,,123,45,,mms|*,IPV6,IP,true,8,,,,,,,spn,testspn, 6"; networkTypeBitmask = 1 << (6 - 1); int bearerBitmask = 1 << (8 - 1); expectedApn = new ApnSetting( -1, "12345", "Name", "apn", "", "", "", "", "", "", "", 0, mmsTypes, "IPV6", "IP", true, 0, bearerBitmask, 0, false, 0, 0, 0, 0, "spn", "testspn"); assertApnSettingEqual(expectedApn, ApnSetting.fromString(testString)); expectedApn = new ApnSetting( -1, "12345", "Name", "apn", "", "", "", "", "", "", "", 0, mmsTypes, "IPV6", "IP", true, networkTypeBitmask, 0, false, 0, 0, 0, 0, "spn", "testspn"); assertApnSettingEqual(expectedApn, ApnSetting.fromString(testString)); // A v4 string with network type bitmask and incompatible bearer bitmask. testString = "[ApnSettingV4] Name,apn,,,,,,,,,123,45,,mms|*,IPV6,IP,true,9,,,,,,,spn,testspn, 6"; bearerBitmask = 1 << (8 - 1); expectedApn = new ApnSetting( -1, "12345", "Name", "apn", "", "", "", "", "", "", "", 0, mmsTypes, "IPV6", "IP", true, 0, bearerBitmask, 0, false, 0, 0, 0, 0, "spn", "testspn"); assertApnSettingEqual(expectedApn, ApnSetting.fromString(testString)); // Return no apn if insufficient fields given. testString = "[ApnSettingV3] Name,apn,,,,,,,,,123, 45,,mms|*"; assertEquals(null, ApnSetting.fromString(testString)); Loading Loading @@ -218,9 +269,9 @@ public class ApnSettingTest extends TelephonyTest { 99, "12345", "Name", "apn", "proxy", "port", "mmsc", "mmsproxy", "mmsport", "user", "password", 0, types, "IPV6", "IP", true, 14, 0, 0, false, 0, 0, 0, 0, "", ""); String expected = "[ApnSettingV3] Name, 99, 12345, apn, proxy, " + "mmsc, mmsproxy, mmsport, port, 0, default | *, " + "IPV6, IP, true, 14, 8192, 0, false, 0, 0, 0, 0, , , false"; String expected = "[ApnSettingV4] Name, 99, 12345, apn, proxy, " + "mmsc, mmsproxy, mmsport, port, 0, default | *, " + "IPV6, IP, true, 14, 8192, 0, false, 0, 0, 0, 0, , , false, 4096"; assertEquals(expected, apn.toString()); } Loading
tests/telephonytests/src/com/android/internal/telephony/dataconnection/DataProfileTest.java +49 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.internal.telephony.dataconnection; import android.telephony.ServiceState; import android.telephony.data.DataProfile; import android.test.suitebuilder.annotation.SmallTest; Loading Loading @@ -81,6 +82,34 @@ public class DataProfileTest extends TestCase { "", // mvno_type ""); // mnvo_match_data private ApnSetting mApn3 = new ApnSetting( 2163, // id "44010", // numeric "sp-mode", // name "fake_apn", // apn "", // proxy "", // port "", // mmsc "", // mmsproxy "", // mmsport "user", // user "passwd", // password -1, // authtype new String[]{"default", "supl"}, // types "IP", // protocol "IP", // roaming_protocol true, // carrier_enabled 276600, // network_type_bitmask 1234, // profile_id false, // modem_cognitive 111, // max_conns 456, // wait_time 789, // max_conns_time 0, // mtu "", // mvno_type "" // mnvo_match_data ); @SmallTest public void testCreateFromApnSetting() throws Exception { DataProfile dp = DcTracker.createDataProfile(mApn1, mApn1.profileId); Loading @@ -90,13 +119,32 @@ public class DataProfileTest extends TestCase { assertEquals(RILConstants.SETUP_DATA_AUTH_PAP_CHAP, dp.getAuthType()); assertEquals(mApn1.user, dp.getUserName()); assertEquals(mApn1.password, dp.getPassword()); assertEquals(0, dp.getType()); assertEquals(0, dp.getType()); // TYPE_COMMON assertEquals(mApn1.maxConnsTime, dp.getMaxConnsTime()); assertEquals(mApn1.maxConns, dp.getMaxConns()); assertEquals(mApn1.waitTime, dp.getWaitTime()); assertEquals(mApn1.carrierEnabled, dp.isEnabled()); } @SmallTest public void testCreateFromApnSettingWithNetworkTypeBitmask() throws Exception { DataProfile dp = DcTracker.createDataProfile(mApn3, mApn3.profileId); assertEquals(mApn3.profileId, dp.getProfileId()); assertEquals(mApn3.apn, dp.getApn()); assertEquals(mApn3.protocol, dp.getProtocol()); assertEquals(RILConstants.SETUP_DATA_AUTH_PAP_CHAP, dp.getAuthType()); assertEquals(mApn3.user, dp.getUserName()); assertEquals(mApn3.password, dp.getPassword()); assertEquals(2, dp.getType()); // TYPE_3GPP2 assertEquals(mApn3.maxConnsTime, dp.getMaxConnsTime()); assertEquals(mApn3.maxConns, dp.getMaxConns()); assertEquals(mApn3.waitTime, dp.getWaitTime()); assertEquals(mApn3.carrierEnabled, dp.isEnabled()); int expectedBearerBitmap = ServiceState.convertNetworkTypeBitmaskToBearerBitmask(mApn3.networkTypeBitmask); assertEquals(expectedBearerBitmap, dp.getBearerBitmap()); } @SmallTest public void testEquals() throws Exception { DataProfile dp1 = DcTracker.createDataProfile(mApn1, mApn1.profileId); Loading