Skip to content

Commit 26ee989

Browse files
author
Robert Greenwalt
committed
Fix some apn settings issues.
Correct some logging that was misleading and be more precise in our removal of things from the waiting list. bug:6445253 Change-Id: I97b20b851617149a24303276392de403dbde2a8f
1 parent bad417d commit 26ee989

File tree

2 files changed

+11
-24
lines changed

2 files changed

+11
-24
lines changed

telephony/java/com/android/internal/telephony/ApnContext.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ public synchronized ApnSetting getNextWaitingApn() {
129129
return apn;
130130
}
131131

132-
public synchronized void removeNextWaitingApn() {
133-
if ((mWaitingApns != null) && (!mWaitingApns.isEmpty())) {
134-
mWaitingApns.remove(0);
132+
public synchronized void removeWaitingApn(ApnSetting apn) {
133+
if (mWaitingApns != null) {
134+
mWaitingApns.remove(apn);
135135
}
136136
}
137137

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

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,19 +1970,11 @@ protected void onDataSetupComplete(AsyncResult ar) {
19701970
handleError = true;
19711971
} else {
19721972
DataConnection dc = apnContext.getDataConnection();
1973-
1973+
ApnSetting apn = apnContext.getApnSetting();
19741974
if (DBG) {
1975-
// TODO We may use apnContext.getApnSetting() directly
1976-
// instead of getWaitingApns().get(0)
1977-
String apnStr = "<unknown>";
1978-
if (apnContext.getWaitingApns() != null
1979-
&& !apnContext.getWaitingApns().isEmpty()){
1980-
apnStr = apnContext.getWaitingApns().get(0).apn;
1981-
}
1982-
log("onDataSetupComplete: success apn=" + apnStr);
1975+
log("onDataSetupComplete: success apn=" + (apn == null ? "unknown" : apn.apn));
19831976
}
1984-
ApnSetting apn = apnContext.getApnSetting();
1985-
if (apn.proxy != null && apn.proxy.length() != 0) {
1977+
if (apn != null && apn.proxy != null && apn.proxy.length() != 0) {
19861978
try {
19871979
String port = apn.port;
19881980
if (TextUtils.isEmpty(port)) port = "8080";
@@ -2000,7 +1992,7 @@ protected void onDataSetupComplete(AsyncResult ar) {
20001992
SystemProperties.set("gsm.defaultpdpcontext.active", "true");
20011993
if (canSetPreferApn && mPreferredApn == null) {
20021994
if (DBG) log("onDataSetupComplete: PREFERED APN is null");
2003-
mPreferredApn = apnContext.getApnSetting();
1995+
mPreferredApn = apn;
20041996
if (mPreferredApn != null) {
20051997
setPreferredApn(mPreferredApn.id);
20061998
}
@@ -2011,16 +2003,11 @@ protected void onDataSetupComplete(AsyncResult ar) {
20112003
notifyDefaultData(apnContext);
20122004
}
20132005
} else {
2014-
String apnString;
2015-
20162006
cause = (DataConnection.FailCause) (ar.result);
20172007
if (DBG) {
2018-
try {
2019-
apnString = apnContext.getWaitingApns().get(0).apn;
2020-
} catch (Exception e) {
2021-
apnString = "<unknown>";
2022-
}
2023-
log(String.format("onDataSetupComplete: error apn=%s cause=%s", apnString, cause));
2008+
ApnSetting apn = apnContext.getApnSetting();
2009+
log(String.format("onDataSetupComplete: error apn=%s cause=%s",
2010+
(apn == null ? "unknown" : apn.apn), cause));
20242011
}
20252012
if (cause.isEventLoggable()) {
20262013
// Log this failure to the Event Logs.
@@ -2032,7 +2019,7 @@ protected void onDataSetupComplete(AsyncResult ar) {
20322019
// Count permanent failures and remove the APN we just tried
20332020
if (cause.isPermanentFail()) apnContext.decWaitingApnsPermFailCount();
20342021

2035-
apnContext.removeNextWaitingApn();
2022+
apnContext.removeWaitingApn(apnContext.getApnSetting());
20362023
if (DBG) {
20372024
log(String.format("onDataSetupComplete: WaitingApns.size=%d" +
20382025
" WaitingApnsPermFailureCountDown=%d",

0 commit comments

Comments
 (0)