Skip to content

Commit 02a43d3

Browse files
Wink SavilleAndroid (Google) Code Review
authored andcommitted
Merge "Add debug for tracking down connectivity issues." into jb-dev
2 parents 94328c3 + f19540a commit 02a43d3

File tree

6 files changed

+75
-44
lines changed

6 files changed

+75
-44
lines changed

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

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,11 @@ public synchronized DataConnection getDataConnection() {
7878
return mDataConnection;
7979
}
8080

81-
public synchronized void setDataConnection(DataConnection dataConnection) {
82-
mDataConnection = dataConnection;
81+
public synchronized void setDataConnection(DataConnection dc) {
82+
if (DBG) {
83+
log("setDataConnection: old dc=" + mDataConnection + " new dc=" + dc + " this=" + this);
84+
}
85+
mDataConnection = dc;
8386
}
8487

8588

@@ -88,10 +91,15 @@ public synchronized DataConnectionAc getDataConnectionAc() {
8891
}
8992

9093
public synchronized void setDataConnectionAc(DataConnectionAc dcac) {
94+
if (DBG) {
95+
log("setDataConnectionAc: old dcac=" + mDataConnectionAc + " new dcac=" + dcac);
96+
}
9197
if (dcac != null) {
9298
dcac.addApnContextSync(this);
9399
} else {
94-
if (mDataConnectionAc != null) mDataConnectionAc.removeApnContextSync(this);
100+
if (mDataConnectionAc != null) {
101+
mDataConnectionAc.removeApnContextSync(this);
102+
}
95103
}
96104
mDataConnectionAc = dcac;
97105
}
@@ -141,7 +149,7 @@ public synchronized ArrayList<ApnSetting> getWaitingApns() {
141149

142150
public synchronized void setState(DataConnectionTracker.State s) {
143151
if (DBG) {
144-
log("setState: " + s + " for type " + mApnType + ", previous state:" + mState);
152+
log("setState: " + s + ", previous state:" + mState);
145153
}
146154

147155
mState = s;
@@ -165,7 +173,7 @@ public boolean isDisconnected() {
165173

166174
public synchronized void setReason(String reason) {
167175
if (DBG) {
168-
log("set reason as " + reason + ", for type " + mApnType + ",current state " + mState);
176+
log("set reason as " + reason + ",current state " + mState);
169177
}
170178
mReason = reason;
171179
}
@@ -180,8 +188,7 @@ public boolean isReady() {
180188

181189
public void setEnabled(boolean enabled) {
182190
if (DBG) {
183-
log("set enabled as " + enabled + ", for type " +
184-
mApnType + ", current state is " + mDataEnabled.get());
191+
log("set enabled as " + enabled + ", current state is " + mDataEnabled.get());
185192
}
186193
mDataEnabled.set(enabled);
187194
}
@@ -192,8 +199,7 @@ public boolean isEnabled() {
192199

193200
public void setDependencyMet(boolean met) {
194201
if (DBG) {
195-
log("set mDependencyMet as " + met + ", for type " + mApnType +
196-
", current state is " + mDependencyMet.get());
202+
log("set mDependencyMet as " + met + " current state is " + mDependencyMet.get());
197203
}
198204
mDependencyMet.set(met);
199205
}
@@ -204,25 +210,19 @@ public boolean getDependencyMet() {
204210

205211
@Override
206212
public String toString() {
207-
return "state=" + getState() + " apnType=" + mApnType;
213+
// We don't print mDataConnection because its recursive.
214+
return "{mApnType=" + mApnType + " mState=" + getState() + " mWaitingApns=" + mWaitingApns +
215+
" mWaitingApnsPermanentFailureCountDown=" + mWaitingApnsPermanentFailureCountDown +
216+
" mApnSetting=" + mApnSetting + " mDataConnectionAc=" + mDataConnectionAc +
217+
" mReason=" + mReason + " mDataEnabled=" + mDataEnabled +
218+
" mDependencyMet=" + mDependencyMet + "}";
208219
}
209220

210221
protected void log(String s) {
211-
Log.d(LOG_TAG, "[ApnContext] " + s);
222+
Log.d(LOG_TAG, "[ApnContext:" + mApnType + "] " + s);
212223
}
213224

214225
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
215-
pw.println("ApnContext:");
216-
pw.println(" mApnType=" + mApnType);
217-
pw.println(" mState=" + mState);
218-
pw.println(" mWaitingApns=" + mWaitingApns);
219-
pw.println(" mWaitingApnsPermanentFailureCountDown=" +
220-
mWaitingApnsPermanentFailureCountDown);
221-
pw.println(" mApnSetting=" + mApnSetting);
222-
pw.println(" mDataConnection=" + mDataConnection);
223-
pw.println(" mDataConnectionAc=" + mDataConnectionAc);
224-
pw.println(" mReason=" + mReason);
225-
pw.println(" mDataEnabled=" + mDataEnabled);
226-
pw.println(" mDependencyMet=" + mDependencyMet);
226+
pw.println("ApnContext: " + this.toString());
227227
}
228228
}

telephony/java/com/android/internal/telephony/DataConnection.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public abstract class DataConnection extends StateMachine {
6969
protected static int mCount;
7070
protected AsyncChannel mAc;
7171

72-
private List<ApnContext> mApnList = null;
72+
protected List<ApnContext> mApnList = null;
7373
PendingIntent mReconnectIntent = null;
7474

7575
private DataConnectionTracker mDataConnectionTracker = null;
@@ -247,7 +247,7 @@ protected static String cmdToString(int cmd) {
247247
protected FailCause lastFailCause;
248248
protected int mRetryOverride = -1;
249249
protected static final String NULL_IP = "0.0.0.0";
250-
private int mRefCount;
250+
protected int mRefCount;
251251
Object userData;
252252

253253
//***** Abstract methods
@@ -600,9 +600,8 @@ private UpdateLinkPropertyResult updateLinkProperty(DataCallState newState) {
600600
result.newLp.setHttpProxy(mLinkProperties.getHttpProxy());
601601

602602
if (DBG && (! result.oldLp.equals(result.newLp))) {
603-
if (DBG) log("updateLinkProperty old != new");
604-
if (VDBG) log("updateLinkProperty old LP=" + result.oldLp);
605-
if (VDBG) log("updateLinkProperty new LP=" + result.newLp);
603+
log("updateLinkProperty old LP=" + result.oldLp);
604+
log("updateLinkProperty new LP=" + result.newLp);
606605
}
607606
mLinkProperties = result.newLp;
608607

telephony/java/com/android/internal/telephony/DataConnectionAc.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,11 @@ public PendingIntent getReconnectIntentSync() {
580580
}
581581
}
582582

583+
@Override
584+
public String toString() {
585+
return dataConnection.getName();
586+
}
587+
583588
private void log(String s) {
584589
android.util.Log.d(mLogTag, "DataConnectionAc " + s);
585590
}

telephony/java/com/android/internal/telephony/DataConnectionTracker.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ protected void onActionIntentDataStallAlarm(Intent intent) {
499499
*/
500500
protected DataConnectionTracker(PhoneBase phone) {
501501
super();
502+
if (DBG) log("DCT.constructor");
502503
mPhone = phone;
503504

504505
IntentFilter filter = new IntentFilter();
@@ -534,6 +535,7 @@ protected DataConnectionTracker(PhoneBase phone) {
534535
}
535536

536537
public void dispose() {
538+
if (DBG) log("DCT.dispose");
537539
for (DataConnectionAc dcac : mDataConnectionAsyncChannels.values()) {
538540
dcac.disconnect();
539541
}
@@ -1256,7 +1258,6 @@ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
12561258
Set<Entry<String, ApnContext>> mApnContextsSet = mApnContexts.entrySet();
12571259
pw.println(" mApnContexts size=" + mApnContextsSet.size());
12581260
for (Entry<String, ApnContext> entry : mApnContextsSet) {
1259-
pw.printf(" *** mApnContexts[%s]:\n", entry.getKey());
12601261
entry.getValue().dump(fd, pw, args);
12611262
}
12621263
pw.println(" ***************************************");

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,10 @@ public int getProfileId() {
120120

121121
@Override
122122
public String toString() {
123-
return "State=" + getCurrentState().getName() + " Apn=" + mApn +
124-
" create=" + createTime + " lastFail=" + lastFailTime +
125-
" lastFailCause=" + lastFailCause;
123+
return "{" + getName() + ": State=" + getCurrentState().getName() +
124+
" apnSetting=" + mApn + " apnList= " + mApnList + " RefCount=" + mRefCount +
125+
" cid=" + cid + " create=" + createTime + " lastFail=" + lastFailTime +
126+
" lastFailCause=" + lastFailCause + "}";
126127
}
127128

128129
@Override

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

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ protected void onActionIntentReconnectAlarm(Intent intent) {
175175

176176
public GsmDataConnectionTracker(PhoneBase p) {
177177
super(p);
178-
178+
if (DBG) log("GsmDCT.constructor");
179179
p.mCM.registerForAvailable (this, EVENT_RADIO_AVAILABLE, null);
180180
p.mCM.registerForOffOrNotAvailable(this, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null);
181181
p.mIccRecords.registerForRecordsLoaded(this, EVENT_RECORDS_LOADED, null);
@@ -212,6 +212,7 @@ public GsmDataConnectionTracker(PhoneBase p) {
212212

213213
@Override
214214
public void dispose() {
215+
if (DBG) log("GsmDCT.dispose");
215216
cleanUpAllConnections(false, null);
216217

217218
super.dispose();
@@ -835,10 +836,11 @@ private void cleanUpConnection(boolean tearDown, ApnContext apnContext) {
835836
return;
836837
}
837838

839+
DataConnectionAc dcac = apnContext.getDataConnectionAc();
838840
if (DBG) {
839-
log("cleanUpConnection: tearDown=" + tearDown + " reason=" + apnContext.getReason());
841+
log("cleanUpConnection: E tearDown=" + tearDown + " reason=" + apnContext.getReason() +
842+
" apnContext=" + apnContext);
840843
}
841-
DataConnectionAc dcac = apnContext.getDataConnectionAc();
842844
if (tearDown) {
843845
if (apnContext.isDisconnected()) {
844846
// The request is tearDown and but ApnContext is not connected.
@@ -901,6 +903,10 @@ private void cleanUpConnection(boolean tearDown, ApnContext apnContext) {
901903
cancelReconnectAlarm(dcac);
902904
}
903905
}
906+
if (DBG) {
907+
log("cleanUpConnection: X tearDown=" + tearDown + " reason=" + apnContext.getReason() +
908+
" apnContext=" + apnContext + " dc=" + apnContext.getDataConnection());
909+
}
904910
}
905911

906912
/**
@@ -986,29 +992,39 @@ private boolean dataConnectionNotInUse(DataConnectionAc dcac) {
986992
private GsmDataConnection findFreeDataConnection() {
987993
for (DataConnectionAc dcac : mDataConnectionAsyncChannels.values()) {
988994
if (dcac.isInactiveSync() && dataConnectionNotInUse(dcac)) {
989-
log("findFreeDataConnection: found free GsmDataConnection");
990-
return (GsmDataConnection) dcac.dataConnection;
995+
DataConnection dc = dcac.dataConnection;
996+
if (DBG) {
997+
log("findFreeDataConnection: found free GsmDataConnection=" +
998+
" dcac=" + dcac + " dc=" + dc);
999+
}
1000+
return (GsmDataConnection) dc;
9911001
}
9921002
}
9931003
log("findFreeDataConnection: NO free GsmDataConnection");
9941004
return null;
9951005
}
9961006

9971007
protected GsmDataConnection findReadyDataConnection(ApnSetting apn) {
998-
if (DBG)
999-
log("findReadyDataConnection: apn string <" +
1000-
(apn!=null?(apn.toString()):"null") +">");
10011008
if (apn == null) {
10021009
return null;
10031010
}
1011+
if (DBG) {
1012+
log("findReadyDataConnection: apn string <" + apn + ">" +
1013+
" dcacs.size=" + mDataConnectionAsyncChannels.size());
1014+
}
10041015
for (DataConnectionAc dcac : mDataConnectionAsyncChannels.values()) {
10051016
ApnSetting apnSetting = dcac.getApnSettingSync();
10061017
if (DBG) {
10071018
log("findReadyDataConnection: dc apn string <" +
10081019
(apnSetting != null ? (apnSetting.toString()) : "null") + ">");
10091020
}
10101021
if ((apnSetting != null) && TextUtils.equals(apnSetting.toString(), apn.toString())) {
1011-
return (GsmDataConnection) dcac.dataConnection;
1022+
DataConnection dc = dcac.dataConnection;
1023+
if (DBG) {
1024+
log("findReadyDataConnection: found ready GsmDataConnection=" +
1025+
" dcac=" + dcac + " dc=" + dc);
1026+
}
1027+
return (GsmDataConnection) dc;
10121028
}
10131029
}
10141030
return null;
@@ -1129,6 +1145,8 @@ private DataConnectionAc findDataConnectionAcByCid(int cid) {
11291145
private List<ApnContext> findApnContextToClean(Collection<DataConnectionAc> dcacs) {
11301146
if (dcacs == null) return null;
11311147

1148+
if (DBG) log("findApnContextToClean(ar): E dcacs=" + dcacs);
1149+
11321150
ArrayList<ApnContext> list = new ArrayList<ApnContext>();
11331151
for (ApnContext apnContext : mApnContexts.values()) {
11341152
if (apnContext.getState() == State.CONNECTED) {
@@ -1144,7 +1162,7 @@ private List<ApnContext> findApnContextToClean(Collection<DataConnectionAc> dcac
11441162
// ApnContext does not have dcac reported in data call list.
11451163
// Fetch all the ApnContexts that map to this dcac which are in
11461164
// INITING state too.
1147-
if (DBG) log("onDataStateChanged(ar): Connected apn not found in the list (" +
1165+
if (DBG) log("findApnContextToClean(ar): Connected apn not found in the list (" +
11481166
apnContext.toString() + ")");
11491167
if (apnContext.getDataConnectionAc() != null) {
11501168
list.addAll(apnContext.getDataConnectionAc().getApnListSync());
@@ -1154,6 +1172,7 @@ private List<ApnContext> findApnContextToClean(Collection<DataConnectionAc> dcac
11541172
}
11551173
}
11561174
}
1175+
if (DBG) log("findApnContextToClean(ar): X list=" + list);
11571176
return list;
11581177
}
11591178

@@ -1236,6 +1255,10 @@ private void onDataStateChanged (AsyncResult ar) {
12361255
// If the same address type was removed and added we need to cleanup
12371256
CompareResult<LinkAddress> car =
12381257
result.oldLp.compareAddresses(result.newLp);
1258+
if (DBG) {
1259+
log("onDataStateChanged: oldLp=" + result.oldLp +
1260+
" newLp=" + result.newLp + " car=" + car);
1261+
}
12391262
boolean needToClean = false;
12401263
for (LinkAddress added : car.added) {
12411264
for (LinkAddress removed : car.removed) {
@@ -1249,7 +1272,8 @@ private void onDataStateChanged (AsyncResult ar) {
12491272
if (needToClean) {
12501273
if (DBG) {
12511274
log("onDataStateChanged(ar): addr change, cleanup apns=" +
1252-
connectedApns);
1275+
connectedApns + " oldLp=" + result.oldLp +
1276+
" newLp=" + result.newLp);
12531277
}
12541278
apnsToCleanup.addAll(connectedApns);
12551279
} else {
@@ -1285,6 +1309,7 @@ private void onDataStateChanged (AsyncResult ar) {
12851309
}
12861310

12871311
// Cleanup those dropped connections
1312+
if (DBG) log("onDataStateChange(ar): apnsToCleanup=" + apnsToCleanup);
12881313
for (ApnContext apnContext : apnsToCleanup) {
12891314
cleanUpConnection(true, apnContext);
12901315
}
@@ -2256,7 +2281,7 @@ private GsmDataConnection createDataConnection() {
22562281
filter.addAction(INTENT_RECONNECT_ALARM + '.' + id);
22572282
mPhone.getContext().registerReceiver(mIntentReceiver, filter, null, mPhone);
22582283

2259-
if (DBG) log("createDataConnection() X id=" + id);
2284+
if (DBG) log("createDataConnection() X id=" + id + " dc=" + conn);
22602285
return conn;
22612286
}
22622287

0 commit comments

Comments
 (0)