Merge "Have all connections disconnected before turning off radio." into ics-factoryrom
This commit is contained in:
@@ -154,6 +154,12 @@ public class ApnContext {
|
|||||||
return mState;
|
return mState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDisconnected() {
|
||||||
|
DataConnectionTracker.State currentState = getState();
|
||||||
|
return ((currentState == DataConnectionTracker.State.IDLE) ||
|
||||||
|
currentState == DataConnectionTracker.State.FAILED);
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized void setReason(String reason) {
|
public synchronized void setReason(String reason) {
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
log("set reason as " + reason + ", for type " + mApnType + ",current state " + mState);
|
log("set reason as " + reason + ", for type " + mApnType + ",current state " + mState);
|
||||||
|
|||||||
@@ -787,9 +787,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
}
|
}
|
||||||
DataConnectionAc dcac = apnContext.getDataConnectionAc();
|
DataConnectionAc dcac = apnContext.getDataConnectionAc();
|
||||||
if (tearDown) {
|
if (tearDown) {
|
||||||
boolean isConnected = (apnContext.getState() != State.IDLE
|
if (apnContext.isDisconnected()) {
|
||||||
&& apnContext.getState() != State.FAILED);
|
|
||||||
if (!isConnected) {
|
|
||||||
// The request is tearDown and but ApnContext is not connected.
|
// The request is tearDown and but ApnContext is not connected.
|
||||||
// If apnContext is not enabled anymore, break the linkage to the DCAC/DC.
|
// If apnContext is not enabled anymore, break the linkage to the DCAC/DC.
|
||||||
apnContext.setState(State.IDLE);
|
apnContext.setState(State.IDLE);
|
||||||
@@ -1019,11 +1017,9 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
*/
|
*/
|
||||||
private void onApnChanged() {
|
private void onApnChanged() {
|
||||||
// TODO: How to handle when multiple APNs are active?
|
// TODO: How to handle when multiple APNs are active?
|
||||||
boolean isConnected;
|
|
||||||
|
|
||||||
ApnContext defaultApnContext = mApnContexts.get(Phone.APN_TYPE_DEFAULT);
|
ApnContext defaultApnContext = mApnContexts.get(Phone.APN_TYPE_DEFAULT);
|
||||||
isConnected = (defaultApnContext.getState() != State.IDLE
|
boolean defaultApnIsDisconnected = defaultApnContext.isDisconnected();
|
||||||
&& defaultApnContext.getState() != State.FAILED);
|
|
||||||
|
|
||||||
if (mPhone instanceof GSMPhone) {
|
if (mPhone instanceof GSMPhone) {
|
||||||
// The "current" may no longer be valid. MMS depends on this to send properly. TBD
|
// The "current" may no longer be valid. MMS depends on this to send properly. TBD
|
||||||
@@ -1034,8 +1030,8 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
// match the current operator.
|
// match the current operator.
|
||||||
if (DBG) log("onApnChanged: createAllApnList and cleanUpAllConnections");
|
if (DBG) log("onApnChanged: createAllApnList and cleanUpAllConnections");
|
||||||
createAllApnList();
|
createAllApnList();
|
||||||
cleanUpAllConnections(isConnected, Phone.REASON_APN_CHANGED);
|
cleanUpAllConnections(!defaultApnIsDisconnected, Phone.REASON_APN_CHANGED);
|
||||||
if (!isConnected) {
|
if (defaultApnIsDisconnected) {
|
||||||
setupDataOnReadyApns(Phone.REASON_APN_CHANGED);
|
setupDataOnReadyApns(Phone.REASON_APN_CHANGED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1885,7 +1881,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
|
|
||||||
// if all data connection are gone, check whether Airplane mode request was
|
// if all data connection are gone, check whether Airplane mode request was
|
||||||
// pending.
|
// pending.
|
||||||
if (!isConnected()) {
|
if (isDisconnected()) {
|
||||||
if (mPhone.getServiceStateTracker().processPendingRadioPowerOffAfterDataOff()) {
|
if (mPhone.getServiceStateTracker().processPendingRadioPowerOffAfterDataOff()) {
|
||||||
// Radio will be turned off. No need to retry data setup
|
// Radio will be turned off. No need to retry data setup
|
||||||
apnContext.setApnSetting(null);
|
apnContext.setApnSetting(null);
|
||||||
@@ -1957,12 +1953,25 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
protected boolean isConnected() {
|
protected boolean isConnected() {
|
||||||
for (ApnContext apnContext : mApnContexts.values()) {
|
for (ApnContext apnContext : mApnContexts.values()) {
|
||||||
if (apnContext.getState() == State.CONNECTED) {
|
if (apnContext.getState() == State.CONNECTED) {
|
||||||
return true;
|
// At least one context is connected, return true
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// There are not any contexts connected, return false
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean isDisconnected() {
|
||||||
|
for (ApnContext apnContext : mApnContexts.values()) {
|
||||||
|
if (!apnContext.isDisconnected()) {
|
||||||
|
// At least one context was not disconnected return false
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// All contexts were disconnected so return true
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void notifyDataConnection(String reason) {
|
protected void notifyDataConnection(String reason) {
|
||||||
if (DBG) log("notifyDataConnection: reason=" + reason);
|
if (DBG) log("notifyDataConnection: reason=" + reason);
|
||||||
|
|||||||
Reference in New Issue
Block a user