Merge "Add OTADM feature for Verizon requirement. - GsmDataConnectionTracker.java <in function createApnList> : modify parameter type for new ApnSetting. (carrierEnabled has changed to boolean from integer, BEARER has changed to integer from string). <in function createAllApnList> : modify telephony db query statement using carrierEnabled. (carrier_enabled: 1 enable apn, 0: disabled apn) <in function buildWaitingApns> : modify apn management code when current RAT (radio access technology) is LTE or EHRPD. add internal function named needToCheckApnBearer to check current RAT is LTE or EHRPD. - ApnSetting.java : add two member variable (carrierEnabled: apn enable/disable , bearer : Radio Access Technology) - Telephony.java : add two static string CARRIER_ENABLED & BEARER. - ApnSettingTest.java : add two assertEquals in function assertApnSettingEqual. add CARRIER_ENABLED & BEARER parameters."
This commit is contained in:
committed by
Android (Google) Code Review
commit
11fed2b218
14
core/java/android/provider/Telephony.java
Normal file → Executable file
14
core/java/android/provider/Telephony.java
Normal file → Executable file
@@ -1798,6 +1798,20 @@ public final class Telephony {
|
||||
public static final String ROAMING_PROTOCOL = "roaming_protocol";
|
||||
|
||||
public static final String CURRENT = "current";
|
||||
|
||||
/**
|
||||
* Current status of APN
|
||||
* true : enabled APN, false : disabled APN.
|
||||
*/
|
||||
public static final String CARRIER_ENABLED = "carrier_enabled";
|
||||
|
||||
/**
|
||||
* Radio Access Technology info
|
||||
* 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).
|
||||
*/
|
||||
public static final String BEARER = "bearer";
|
||||
}
|
||||
|
||||
public static final class Intents {
|
||||
|
||||
@@ -17,10 +17,9 @@
|
||||
*/
|
||||
-->
|
||||
|
||||
<!-- use empty string to specify no proxy or port -->
|
||||
|
||||
<!-- If you edit this version, also edit the version in the partner-supplied
|
||||
<!-- If you edit this version, also edit the version in the partner-supplied
|
||||
apns-conf.xml configuration file -->
|
||||
<apns version="6">
|
||||
<apns version="7">
|
||||
|
||||
</apns>
|
||||
|
||||
36
telephony/java/com/android/internal/telephony/ApnSetting.java
Normal file → Executable file
36
telephony/java/com/android/internal/telephony/ApnSetting.java
Normal file → Executable file
@@ -38,12 +38,24 @@ public class ApnSetting {
|
||||
public final String numeric;
|
||||
public final String protocol;
|
||||
public final String roamingProtocol;
|
||||
/**
|
||||
* Current status of APN
|
||||
* true : enabled APN, false : disabled APN.
|
||||
*/
|
||||
public final boolean carrierEnabled;
|
||||
/**
|
||||
* Radio Access Technology info
|
||||
* 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).
|
||||
*/
|
||||
public final int bearer;
|
||||
|
||||
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) {
|
||||
String protocol, String roamingProtocol, boolean carrierEnabled, int bearer) {
|
||||
this.id = id;
|
||||
this.numeric = numeric;
|
||||
this.carrier = carrier;
|
||||
@@ -59,6 +71,8 @@ public class ApnSetting {
|
||||
this.types = types;
|
||||
this.protocol = protocol;
|
||||
this.roamingProtocol = roamingProtocol;
|
||||
this.carrierEnabled = carrierEnabled;
|
||||
this.bearer = bearer;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,8 +90,8 @@ public class ApnSetting {
|
||||
*
|
||||
* v2 format:
|
||||
* [ApnSettingV2] <carrier>, <apn>, <proxy>, <port>, <mmsc>, <mmsproxy>,
|
||||
* <mmsport>, <user>, <password, <authtype>, <mcc>, <mnc>,
|
||||
* <type>[| <type>...], <protocol>, <roaming_protocol>
|
||||
* <mmsport>, <user>, <password>, <authtype>, <mcc>, <mnc>,
|
||||
* <type>[| <type>...], <protocol>, <roaming_protocol>, <carrierEnabled>, <bearer>
|
||||
*
|
||||
* Note that the strings generated by toString() do not contain the username
|
||||
* and password and thus cannot be read by this method.
|
||||
@@ -110,22 +124,32 @@ public class ApnSetting {
|
||||
|
||||
String[] typeArray;
|
||||
String protocol, roamingProtocol;
|
||||
boolean carrierEnabled;
|
||||
int bearer;
|
||||
if (version == 1) {
|
||||
typeArray = new String[a.length - 13];
|
||||
System.arraycopy(a, 13, typeArray, 0, a.length - 13);
|
||||
protocol = RILConstants.SETUP_DATA_PROTOCOL_IP;
|
||||
roamingProtocol = RILConstants.SETUP_DATA_PROTOCOL_IP;
|
||||
carrierEnabled = true;
|
||||
bearer = 0;
|
||||
} else {
|
||||
if (a.length < 16) {
|
||||
if (a.length < 18) {
|
||||
return null;
|
||||
}
|
||||
typeArray = a[13].split("\\s*\\|\\s*");
|
||||
protocol = a[14];
|
||||
roamingProtocol = a[15];
|
||||
try {
|
||||
carrierEnabled = Boolean.parseBoolean(a[16]);
|
||||
} catch (Exception e) {
|
||||
carrierEnabled = true;
|
||||
}
|
||||
bearer = Integer.parseInt(a[17]);
|
||||
}
|
||||
|
||||
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);
|
||||
a[9],a[4],a[5],authType,typeArray,protocol,roamingProtocol,carrierEnabled,bearer);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
@@ -149,6 +173,8 @@ public class ApnSetting {
|
||||
}
|
||||
sb.append(", ").append(protocol);
|
||||
sb.append(", ").append(roamingProtocol);
|
||||
sb.append(", ").append(carrierEnabled);
|
||||
sb.append(", ").append(bearer);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -338,7 +338,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
apnId = mDefaultApnId;
|
||||
}
|
||||
mActiveApn = new ApnSetting(apnId, "", "", "", "", "", "", "", "", "",
|
||||
"", 0, types, "IP", "IP");
|
||||
"", 0, types, "IP", "IP", true, 0);
|
||||
if (DBG) log("call conn.bringUp mActiveApn=" + mActiveApn);
|
||||
|
||||
Message msg = obtainMessage();
|
||||
|
||||
@@ -889,7 +889,10 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
||||
types,
|
||||
cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.PROTOCOL)),
|
||||
cursor.getString(cursor.getColumnIndexOrThrow(
|
||||
Telephony.Carriers.ROAMING_PROTOCOL)));
|
||||
Telephony.Carriers.ROAMING_PROTOCOL)),
|
||||
cursor.getInt(cursor.getColumnIndexOrThrow(
|
||||
Telephony.Carriers.CARRIER_ENABLED)) == 1,
|
||||
cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.BEARER)));
|
||||
result.add(apn);
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
@@ -1982,6 +1985,9 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
||||
String operator = mPhone.mIccRecords.getOperatorNumeric();
|
||||
if (operator != null) {
|
||||
String selection = "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);
|
||||
|
||||
Cursor cursor = mPhone.getContext().getContentResolver().query(
|
||||
@@ -2068,6 +2074,18 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check current radio access technology is LTE or EHRPD.
|
||||
*
|
||||
* @param integer value of radio access technology
|
||||
* @return true when current radio access technology is LTE or EHRPD
|
||||
* @ false when current radio access technology is not LTE or EHRPD
|
||||
*/
|
||||
private boolean needToCheckApnBearer(int radioTech) {
|
||||
return (radioTech == ServiceState.RADIO_TECHNOLOGY_LTE ||
|
||||
radioTech == ServiceState.RADIO_TECHNOLOGY_EHRPD);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a list of APNs to be used to create PDP's.
|
||||
*
|
||||
@@ -2088,6 +2106,9 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
||||
}
|
||||
|
||||
String operator = mPhone.mIccRecords.getOperatorNumeric();
|
||||
int radioTech = mPhone.getServiceState().getRadioTechnology();
|
||||
boolean needToCheckApnBearer = needToCheckApnBearer(radioTech);
|
||||
|
||||
if (requestedApnType.equals(Phone.APN_TYPE_DEFAULT)) {
|
||||
if (canSetPreferApn && mPreferredApn != null) {
|
||||
if (DBG) {
|
||||
@@ -2095,9 +2116,15 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
||||
+ mPreferredApn.numeric + ":" + mPreferredApn);
|
||||
}
|
||||
if (mPreferredApn.numeric.equals(operator)) {
|
||||
apnList.add(mPreferredApn);
|
||||
if (DBG) log("buildWaitingApns: X added preferred apnList=" + apnList);
|
||||
return apnList;
|
||||
if (!needToCheckApnBearer || mPreferredApn.bearer == radioTech) {
|
||||
apnList.add(mPreferredApn);
|
||||
if (DBG) log("buildWaitingApns: X added preferred apnList=" + apnList);
|
||||
return apnList;
|
||||
} else {
|
||||
if (DBG) log("buildWaitingApns: no preferred APN");
|
||||
setPreferredApn(-1);
|
||||
mPreferredApn = null;
|
||||
}
|
||||
} else {
|
||||
if (DBG) log("buildWaitingApns: no preferred APN");
|
||||
setPreferredApn(-1);
|
||||
@@ -2108,7 +2135,10 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
||||
if (mAllApns != null) {
|
||||
for (ApnSetting apn : mAllApns) {
|
||||
if (apn.canHandleType(requestedApnType)) {
|
||||
apnList.add(apn);
|
||||
if (!needToCheckApnBearer || apn.bearer == radioTech) {
|
||||
if (DBG) log("apn info : " +apn.toString());
|
||||
apnList.add(apn);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
21
telephony/tests/telephonytests/src/com/android/internal/telephony/ApnSettingTest.java
Normal file → Executable file
21
telephony/tests/telephonytests/src/com/android/internal/telephony/ApnSettingTest.java
Normal file → Executable file
@@ -44,6 +44,8 @@ public class ApnSettingTest extends TestCase {
|
||||
for (i = 0; i < a1.types.length; i++) {
|
||||
assertEquals(a1.types[i], a2.types[i]);
|
||||
}
|
||||
assertEquals(a1.carrierEnabled, a2.carrierEnabled);
|
||||
assertEquals(a1.bearer, a2.bearer);
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
@@ -58,21 +60,21 @@ public class ApnSettingTest extends TestCase {
|
||||
testString = "Vodafone IT,web.omnitel.it,,,,,,,,,222,10,,DUN";
|
||||
expected_apn = new ApnSetting(
|
||||
-1, "22210", "Vodafone IT", "web.omnitel.it", "", "",
|
||||
"", "", "", "", "", 0, dunTypes, "IP", "IP");
|
||||
"", "", "", "", "", 0, dunTypes, "IP", "IP",true,0);
|
||||
assertApnSettingEqual(expected_apn, ApnSetting.fromString(testString));
|
||||
|
||||
// A v2 string.
|
||||
testString = "[ApnSettingV2] Name,apn,,,,,,,,,123,45,,mms|*,IPV6,IP";
|
||||
testString = "[ApnSettingV2] Name,apn,,,,,,,,,123,45,,mms|*,IPV6,IP,true,14";
|
||||
expected_apn = new ApnSetting(
|
||||
-1, "12345", "Name", "apn", "", "",
|
||||
"", "", "", "", "", 0, mmsTypes, "IPV6", "IP");
|
||||
"", "", "", "", "", 0, mmsTypes, "IPV6", "IP",true,14);
|
||||
assertApnSettingEqual(expected_apn, ApnSetting.fromString(testString));
|
||||
|
||||
// A v2 string with spaces.
|
||||
testString = "[ApnSettingV2] Name,apn, ,,,,,,,,123,45,,mms|*,IPV4V6, IP";
|
||||
testString = "[ApnSettingV2] Name,apn, ,,,,,,,,123,45,,mms|*,IPV4V6, IP,true,14";
|
||||
expected_apn = new ApnSetting(
|
||||
-1, "12345", "Name", "apn", "", "",
|
||||
"", "", "", "", "", 0, mmsTypes, "IPV4V6", "IP");
|
||||
"", "", "", "", "", 0, mmsTypes, "IPV4V6", "IP",true,14);
|
||||
assertApnSettingEqual(expected_apn, ApnSetting.fromString(testString));
|
||||
|
||||
// Return null if insufficient fields given.
|
||||
@@ -83,11 +85,11 @@ public class ApnSettingTest extends TestCase {
|
||||
assertEquals(null, ApnSetting.fromString(testString));
|
||||
|
||||
// Parse (incorrect) V2 format without the tag as V1.
|
||||
testString = "Name,apn,,,,,,,,,123, 45,,mms|*,IPV6";
|
||||
testString = "Name,apn,,,,,,,,,123, 45,,mms|*,IPV6,true,14";
|
||||
String[] incorrectTypes = {"mms|*", "IPV6"};
|
||||
expected_apn = new ApnSetting(
|
||||
-1, "12345", "Name", "apn", "", "",
|
||||
"", "", "", "", "", 0, incorrectTypes, "IP", "IP");
|
||||
"", "", "", "", "", 0, incorrectTypes, "IP", "IP",true,14);
|
||||
assertApnSettingEqual(expected_apn, ApnSetting.fromString(testString));
|
||||
}
|
||||
|
||||
@@ -98,11 +100,10 @@ public class ApnSettingTest extends TestCase {
|
||||
ApnSetting apn = new ApnSetting(
|
||||
99, "12345", "Name", "apn", "proxy", "port",
|
||||
"mmsc", "mmsproxy", "mmsport", "user", "password", 0,
|
||||
types, "IPV4V6", "IP");
|
||||
types, "IPV4V6", "IP", true, 14);
|
||||
String expected = "[ApnSettingV2] Name, 99, 12345, apn, proxy, " +
|
||||
"mmsc, mmsproxy, mmsport, port, 0, default | *, " +
|
||||
"IPV4V6, IP";
|
||||
"IPV4V6, IP, true, 14";
|
||||
assertEquals(expected, apn.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user