Skip to content

Commit 723facc

Browse files
sinikangRobert Greenwalt
authored andcommitted
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. bug: 4991683 Change-Id: I9450c220009c3093b1e09e8ac9cd0faa0a975067
1 parent 96cbcbf commit 723facc

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

100644100755
Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,10 @@ private ArrayList<ApnSetting> createApnList(Cursor cursor) {
890890
types,
891891
cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.PROTOCOL)),
892892
cursor.getString(cursor.getColumnIndexOrThrow(
893-
Telephony.Carriers.ROAMING_PROTOCOL)));
893+
Telephony.Carriers.ROAMING_PROTOCOL)),
894+
cursor.getInt(cursor.getColumnIndexOrThrow(
895+
Telephony.Carriers.CARRIER_ENABLED)) == 1,
896+
cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.BEARER)));
894897
result.add(apn);
895898
} while (cursor.moveToNext());
896899
}
@@ -1985,6 +1988,9 @@ private void createAllApnList() {
19851988
String operator = mPhone.mIccRecords.getOperatorNumeric();
19861989
if (operator != null) {
19871990
String selection = "numeric = '" + operator + "'";
1991+
// query only enabled apn.
1992+
// carrier_enabled : 1 means enabled apn, 0 disabled apn.
1993+
selection += " and carrier_enabled = 1";
19881994
if (DBG) log("createAllApnList: selection=" + selection);
19891995

19901996
Cursor cursor = mPhone.getContext().getContentResolver().query(
@@ -2071,6 +2077,18 @@ private void destroyDataConnections() {
20712077
}
20722078
}
20732079

2080+
/**
2081+
* Check current radio access technology is LTE or EHRPD.
2082+
*
2083+
* @param integer value of radio access technology
2084+
* @return true when current radio access technology is LTE or EHRPD
2085+
* @ false when current radio access technology is not LTE or EHRPD
2086+
*/
2087+
private boolean needToCheckApnBearer(int radioTech) {
2088+
return (radioTech == ServiceState.RADIO_TECHNOLOGY_LTE ||
2089+
radioTech == ServiceState.RADIO_TECHNOLOGY_EHRPD);
2090+
}
2091+
20742092
/**
20752093
* Build a list of APNs to be used to create PDP's.
20762094
*
@@ -2091,16 +2109,25 @@ private ArrayList<ApnSetting> buildWaitingApns(String requestedApnType) {
20912109
}
20922110

20932111
String operator = mPhone.mIccRecords.getOperatorNumeric();
2112+
int radioTech = mPhone.getServiceState().getRadioTechnology();
2113+
boolean needToCheckApnBearer = needToCheckApnBearer(radioTech);
2114+
20942115
if (requestedApnType.equals(Phone.APN_TYPE_DEFAULT)) {
20952116
if (canSetPreferApn && mPreferredApn != null) {
20962117
if (DBG) {
20972118
log("buildWaitingApns: Preferred APN:" + operator + ":"
20982119
+ mPreferredApn.numeric + ":" + mPreferredApn);
20992120
}
21002121
if (mPreferredApn.numeric.equals(operator)) {
2101-
apnList.add(mPreferredApn);
2102-
if (DBG) log("buildWaitingApns: X added preferred apnList=" + apnList);
2103-
return apnList;
2122+
if (!needToCheckApnBearer || mPreferredApn.bearer == radioTech) {
2123+
apnList.add(mPreferredApn);
2124+
if (DBG) log("buildWaitingApns: X added preferred apnList=" + apnList);
2125+
return apnList;
2126+
} else {
2127+
if (DBG) log("buildWaitingApns: no preferred APN");
2128+
setPreferredApn(-1);
2129+
mPreferredApn = null;
2130+
}
21042131
} else {
21052132
if (DBG) log("buildWaitingApns: no preferred APN");
21062133
setPreferredApn(-1);
@@ -2111,7 +2138,10 @@ private ArrayList<ApnSetting> buildWaitingApns(String requestedApnType) {
21112138
if (mAllApns != null) {
21122139
for (ApnSetting apn : mAllApns) {
21132140
if (apn.canHandleType(requestedApnType)) {
2114-
apnList.add(apn);
2141+
if (!needToCheckApnBearer || apn.bearer == radioTech) {
2142+
if (DBG) log("apn info : " +apn.toString());
2143+
apnList.add(apn);
2144+
}
21152145
}
21162146
}
21172147
} 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)