Skip to content

Commit 11fed2b

Browse files
Robert GreenwaltAndroid (Google) Code Review
authored andcommitted
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."
2 parents e5847ad + 723facc commit 11fed2b

File tree

6 files changed

+94
-24
lines changed

6 files changed

+94
-24
lines changed

core/java/android/provider/Telephony.java

100644100755
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,6 +1798,20 @@ public static final class Carriers implements BaseColumns {
17981798
public static final String ROAMING_PROTOCOL = "roaming_protocol";
17991799

18001800
public static final String CURRENT = "current";
1801+
1802+
/**
1803+
* Current status of APN
1804+
* true : enabled APN, false : disabled APN.
1805+
*/
1806+
public static final String CARRIER_ENABLED = "carrier_enabled";
1807+
1808+
/**
1809+
* Radio Access Technology info
1810+
* To check what values can hold, refer to ServiceState.java.
1811+
* This should be spread to other technologies,
1812+
* but currently only used for LTE(14) and EHRPD(13).
1813+
*/
1814+
public static final String BEARER = "bearer";
18011815
}
18021816

18031817
public static final class Intents {

core/res/res/xml/apns.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@
1717
*/
1818
-->
1919

20-
<!-- use empty string to specify no proxy or port -->
2120

22-
<!-- If you edit this version, also edit the version in the partner-supplied
21+
<!-- If you edit this version, also edit the version in the partner-supplied
2322
apns-conf.xml configuration file -->
24-
<apns version="6">
23+
<apns version="7">
2524

2625
</apns>

telephony/java/com/android/internal/telephony/ApnSetting.java

100644100755
Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,24 @@ public class ApnSetting {
3838
public final String numeric;
3939
public final String protocol;
4040
public final String roamingProtocol;
41+
/**
42+
* Current status of APN
43+
* true : enabled APN, false : disabled APN.
44+
*/
45+
public final boolean carrierEnabled;
46+
/**
47+
* Radio Access Technology info
48+
* To check what values can hold, refer to ServiceState.java.
49+
* This should be spread to other technologies,
50+
* but currently only used for LTE(14) and EHRPD(13).
51+
*/
52+
public final int bearer;
4153

4254
public ApnSetting(int id, String numeric, String carrier, String apn,
4355
String proxy, String port,
4456
String mmsc, String mmsProxy, String mmsPort,
4557
String user, String password, int authType, String[] types,
46-
String protocol, String roamingProtocol) {
58+
String protocol, String roamingProtocol, boolean carrierEnabled, int bearer) {
4759
this.id = id;
4860
this.numeric = numeric;
4961
this.carrier = carrier;
@@ -59,6 +71,8 @@ public ApnSetting(int id, String numeric, String carrier, String apn,
5971
this.types = types;
6072
this.protocol = protocol;
6173
this.roamingProtocol = roamingProtocol;
74+
this.carrierEnabled = carrierEnabled;
75+
this.bearer = bearer;
6276
}
6377

6478
/**
@@ -76,8 +90,8 @@ public ApnSetting(int id, String numeric, String carrier, String apn,
7690
*
7791
* v2 format:
7892
* [ApnSettingV2] <carrier>, <apn>, <proxy>, <port>, <mmsc>, <mmsproxy>,
79-
* <mmsport>, <user>, <password, <authtype>, <mcc>, <mnc>,
80-
* <type>[| <type>...], <protocol>, <roaming_protocol>
93+
* <mmsport>, <user>, <password>, <authtype>, <mcc>, <mnc>,
94+
* <type>[| <type>...], <protocol>, <roaming_protocol>, <carrierEnabled>, <bearer>
8195
*
8296
* Note that the strings generated by toString() do not contain the username
8397
* and password and thus cannot be read by this method.
@@ -110,22 +124,32 @@ public static ApnSetting fromString(String data) {
110124

111125
String[] typeArray;
112126
String protocol, roamingProtocol;
127+
boolean carrierEnabled;
128+
int bearer;
113129
if (version == 1) {
114130
typeArray = new String[a.length - 13];
115131
System.arraycopy(a, 13, typeArray, 0, a.length - 13);
116132
protocol = RILConstants.SETUP_DATA_PROTOCOL_IP;
117133
roamingProtocol = RILConstants.SETUP_DATA_PROTOCOL_IP;
134+
carrierEnabled = true;
135+
bearer = 0;
118136
} else {
119-
if (a.length < 16) {
137+
if (a.length < 18) {
120138
return null;
121139
}
122140
typeArray = a[13].split("\\s*\\|\\s*");
123141
protocol = a[14];
124142
roamingProtocol = a[15];
143+
try {
144+
carrierEnabled = Boolean.parseBoolean(a[16]);
145+
} catch (Exception e) {
146+
carrierEnabled = true;
147+
}
148+
bearer = Integer.parseInt(a[17]);
125149
}
126150

127151
return new ApnSetting(-1,a[10]+a[11],a[0],a[1],a[2],a[3],a[7],a[8],
128-
a[9],a[4],a[5],authType,typeArray,protocol,roamingProtocol);
152+
a[9],a[4],a[5],authType,typeArray,protocol,roamingProtocol,carrierEnabled,bearer);
129153
}
130154

131155
public String toString() {
@@ -149,6 +173,8 @@ public String toString() {
149173
}
150174
sb.append(", ").append(protocol);
151175
sb.append(", ").append(roamingProtocol);
176+
sb.append(", ").append(carrierEnabled);
177+
sb.append(", ").append(bearer);
152178
return sb.toString();
153179
}
154180

telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ private boolean setupData(String reason) {
338338
apnId = mDefaultApnId;
339339
}
340340
mActiveApn = new ApnSetting(apnId, "", "", "", "", "", "", "", "", "",
341-
"", 0, types, "IP", "IP");
341+
"", 0, types, "IP", "IP", true, 0);
342342
if (DBG) log("call conn.bringUp mActiveApn=" + mActiveApn);
343343

344344
Message msg = obtainMessage();

telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,10 @@ private ArrayList<ApnSetting> createApnList(Cursor cursor) {
889889
types,
890890
cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.PROTOCOL)),
891891
cursor.getString(cursor.getColumnIndexOrThrow(
892-
Telephony.Carriers.ROAMING_PROTOCOL)));
892+
Telephony.Carriers.ROAMING_PROTOCOL)),
893+
cursor.getInt(cursor.getColumnIndexOrThrow(
894+
Telephony.Carriers.CARRIER_ENABLED)) == 1,
895+
cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.BEARER)));
893896
result.add(apn);
894897
} while (cursor.moveToNext());
895898
}
@@ -1982,6 +1985,9 @@ private void createAllApnList() {
19821985
String operator = mPhone.mIccRecords.getOperatorNumeric();
19831986
if (operator != null) {
19841987
String selection = "numeric = '" + operator + "'";
1988+
// query only enabled apn.
1989+
// carrier_enabled : 1 means enabled apn, 0 disabled apn.
1990+
selection += " and carrier_enabled = 1";
19851991
if (DBG) log("createAllApnList: selection=" + selection);
19861992

19871993
Cursor cursor = mPhone.getContext().getContentResolver().query(
@@ -2068,6 +2074,18 @@ private void destroyDataConnections() {
20682074
}
20692075
}
20702076

2077+
/**
2078+
* Check current radio access technology is LTE or EHRPD.
2079+
*
2080+
* @param integer value of radio access technology
2081+
* @return true when current radio access technology is LTE or EHRPD
2082+
* @ false when current radio access technology is not LTE or EHRPD
2083+
*/
2084+
private boolean needToCheckApnBearer(int radioTech) {
2085+
return (radioTech == ServiceState.RADIO_TECHNOLOGY_LTE ||
2086+
radioTech == ServiceState.RADIO_TECHNOLOGY_EHRPD);
2087+
}
2088+
20712089
/**
20722090
* Build a list of APNs to be used to create PDP's.
20732091
*
@@ -2088,16 +2106,25 @@ private ArrayList<ApnSetting> buildWaitingApns(String requestedApnType) {
20882106
}
20892107

20902108
String operator = mPhone.mIccRecords.getOperatorNumeric();
2109+
int radioTech = mPhone.getServiceState().getRadioTechnology();
2110+
boolean needToCheckApnBearer = needToCheckApnBearer(radioTech);
2111+
20912112
if (requestedApnType.equals(Phone.APN_TYPE_DEFAULT)) {
20922113
if (canSetPreferApn && mPreferredApn != null) {
20932114
if (DBG) {
20942115
log("buildWaitingApns: Preferred APN:" + operator + ":"
20952116
+ mPreferredApn.numeric + ":" + mPreferredApn);
20962117
}
20972118
if (mPreferredApn.numeric.equals(operator)) {
2098-
apnList.add(mPreferredApn);
2099-
if (DBG) log("buildWaitingApns: X added preferred apnList=" + apnList);
2100-
return apnList;
2119+
if (!needToCheckApnBearer || mPreferredApn.bearer == radioTech) {
2120+
apnList.add(mPreferredApn);
2121+
if (DBG) log("buildWaitingApns: X added preferred apnList=" + apnList);
2122+
return apnList;
2123+
} else {
2124+
if (DBG) log("buildWaitingApns: no preferred APN");
2125+
setPreferredApn(-1);
2126+
mPreferredApn = null;
2127+
}
21012128
} else {
21022129
if (DBG) log("buildWaitingApns: no preferred APN");
21032130
setPreferredApn(-1);
@@ -2108,7 +2135,10 @@ private ArrayList<ApnSetting> buildWaitingApns(String requestedApnType) {
21082135
if (mAllApns != null) {
21092136
for (ApnSetting apn : mAllApns) {
21102137
if (apn.canHandleType(requestedApnType)) {
2111-
apnList.add(apn);
2138+
if (!needToCheckApnBearer || apn.bearer == radioTech) {
2139+
if (DBG) log("apn info : " +apn.toString());
2140+
apnList.add(apn);
2141+
}
21122142
}
21132143
}
21142144
} else {

telephony/tests/telephonytests/src/com/android/internal/telephony/ApnSettingTest.java

100644100755
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public static void assertApnSettingEqual(ApnSetting a1, ApnSetting a2) {
4444
for (i = 0; i < a1.types.length; i++) {
4545
assertEquals(a1.types[i], a2.types[i]);
4646
}
47+
assertEquals(a1.carrierEnabled, a2.carrierEnabled);
48+
assertEquals(a1.bearer, a2.bearer);
4749
}
4850

4951
@SmallTest
@@ -58,21 +60,21 @@ public void testFromString() throws Exception {
5860
testString = "Vodafone IT,web.omnitel.it,,,,,,,,,222,10,,DUN";
5961
expected_apn = new ApnSetting(
6062
-1, "22210", "Vodafone IT", "web.omnitel.it", "", "",
61-
"", "", "", "", "", 0, dunTypes, "IP", "IP");
63+
"", "", "", "", "", 0, dunTypes, "IP", "IP",true,0);
6264
assertApnSettingEqual(expected_apn, ApnSetting.fromString(testString));
6365

6466
// A v2 string.
65-
testString = "[ApnSettingV2] Name,apn,,,,,,,,,123,45,,mms|*,IPV6,IP";
67+
testString = "[ApnSettingV2] Name,apn,,,,,,,,,123,45,,mms|*,IPV6,IP,true,14";
6668
expected_apn = new ApnSetting(
6769
-1, "12345", "Name", "apn", "", "",
68-
"", "", "", "", "", 0, mmsTypes, "IPV6", "IP");
70+
"", "", "", "", "", 0, mmsTypes, "IPV6", "IP",true,14);
6971
assertApnSettingEqual(expected_apn, ApnSetting.fromString(testString));
7072

7173
// A v2 string with spaces.
72-
testString = "[ApnSettingV2] Name,apn, ,,,,,,,,123,45,,mms|*,IPV4V6, IP";
74+
testString = "[ApnSettingV2] Name,apn, ,,,,,,,,123,45,,mms|*,IPV4V6, IP,true,14";
7375
expected_apn = new ApnSetting(
7476
-1, "12345", "Name", "apn", "", "",
75-
"", "", "", "", "", 0, mmsTypes, "IPV4V6", "IP");
77+
"", "", "", "", "", 0, mmsTypes, "IPV4V6", "IP",true,14);
7678
assertApnSettingEqual(expected_apn, ApnSetting.fromString(testString));
7779

7880
// Return null if insufficient fields given.
@@ -83,11 +85,11 @@ public void testFromString() throws Exception {
8385
assertEquals(null, ApnSetting.fromString(testString));
8486

8587
// Parse (incorrect) V2 format without the tag as V1.
86-
testString = "Name,apn,,,,,,,,,123, 45,,mms|*,IPV6";
88+
testString = "Name,apn,,,,,,,,,123, 45,,mms|*,IPV6,true,14";
8789
String[] incorrectTypes = {"mms|*", "IPV6"};
8890
expected_apn = new ApnSetting(
8991
-1, "12345", "Name", "apn", "", "",
90-
"", "", "", "", "", 0, incorrectTypes, "IP", "IP");
92+
"", "", "", "", "", 0, incorrectTypes, "IP", "IP",true,14);
9193
assertApnSettingEqual(expected_apn, ApnSetting.fromString(testString));
9294
}
9395

@@ -98,11 +100,10 @@ public void testToString() throws Exception {
98100
ApnSetting apn = new ApnSetting(
99101
99, "12345", "Name", "apn", "proxy", "port",
100102
"mmsc", "mmsproxy", "mmsport", "user", "password", 0,
101-
types, "IPV4V6", "IP");
103+
types, "IPV4V6", "IP", true, 14);
102104
String expected = "[ApnSettingV2] Name, 99, 12345, apn, proxy, " +
103105
"mmsc, mmsproxy, mmsport, port, 0, default | *, " +
104-
"IPV4V6, IP";
106+
"IPV4V6, IP, true, 14";
105107
assertEquals(expected, apn.toString());
106108
}
107109
}
108-

0 commit comments

Comments
 (0)