Skip to content

Commit d986c60

Browse files
author
Wink Saville
committed
Remove isAnyActiveDataConnection and promote isDisconnected.
As Yoonsung Nam pointed out in the bug using isDisconnected is more precise here and this was the only place isAnyActiveDataConnection was used. So I've removed it and promoted isDisconnected to DataConnectionTracker. It should also be noted that although the Framework should be as graceful as possible, it is still a requirement that the radio must be turned off/on anytime the Framework issues the appropriate command. Bug: 5306201 Change-Id: I95130451e11c51e43406b57eb538d01f8dde61be
1 parent 31f971b commit d986c60

4 files changed

Lines changed: 13 additions & 14 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ public void cleanUpAllConnections(String cause) {
10191019
sendMessage(msg);
10201020
}
10211021

1022-
public abstract boolean isAnyActiveDataConnections();
1022+
public abstract boolean isDisconnected();
10231023

10241024
protected void onSetUserDataEnabled(boolean enabled) {
10251025
synchronized (mDataEnabledLock) {

telephony/java/com/android/internal/telephony/ServiceStateTracker.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,14 @@ public void unregisterForPsRestrictedDisabled(Handler h) {
403403
public void powerOffRadioSafely(DataConnectionTracker dcTracker) {
404404
synchronized (this) {
405405
if (!mPendingRadioPowerOffAfterDataOff) {
406-
if (dcTracker.isAnyActiveDataConnections()) {
406+
// To minimize race conditions we call cleanUpAllConnections on
407+
// both if else paths instead of before this isDisconnected test.
408+
if (dcTracker.isDisconnected()) {
409+
// To minimize race conditions we do this after isDisconnected
410+
dcTracker.cleanUpAllConnections(Phone.REASON_RADIO_TURNED_OFF);
411+
if (DBG) log("Data disconnected, turn off radio right away.");
412+
hangupAndPowerOff();
413+
} else {
407414
dcTracker.cleanUpAllConnections(Phone.REASON_RADIO_TURNED_OFF);
408415
Message msg = Message.obtain(this);
409416
msg.what = EVENT_SET_RADIO_POWER_OFF;
@@ -415,10 +422,6 @@ public void powerOffRadioSafely(DataConnectionTracker dcTracker) {
415422
log("Cannot send delayed Msg, turn off radio right away.");
416423
hangupAndPowerOff();
417424
}
418-
} else {
419-
dcTracker.cleanUpAllConnections(Phone.REASON_RADIO_TURNED_OFF);
420-
if (DBG) log("Data disconnected, turn off radio right away.");
421-
hangupAndPowerOff();
422425
}
423426
}
424427
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -946,8 +946,8 @@ public void handleMessage (Message msg) {
946946
}
947947

948948
@Override
949-
public boolean isAnyActiveDataConnections() {
950-
return (mState != State.IDLE);
949+
public boolean isDisconnected() {
950+
return ((mState == State.IDLE) || (mState == State.FAILED));
951951
}
952952

953953
@Override

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1961,7 +1961,8 @@ protected boolean isConnected() {
19611961
return false;
19621962
}
19631963

1964-
protected boolean isDisconnected() {
1964+
@Override
1965+
public boolean isDisconnected() {
19651966
for (ApnContext apnContext : mApnContexts.values()) {
19661967
if (!apnContext.isDisconnected()) {
19671968
// At least one context was not disconnected return false
@@ -2347,11 +2348,6 @@ private int getCellLocationId() {
23472348
return cid;
23482349
}
23492350

2350-
@Override
2351-
public boolean isAnyActiveDataConnections() {
2352-
return isConnected();
2353-
}
2354-
23552351
@Override
23562352
protected void log(String s) {
23572353
Log.d(LOG_TAG, "[GsmDCT] "+ s);

0 commit comments

Comments
 (0)