diff options
author | Kazuhiro Ondo <kazuhiro.ondo@motorola.com> | 2011-05-24 02:56:15 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-05-24 02:56:15 -0700 |
commit | 3dbc571e62d8c63a55f5e2e58ea22aa6ebf0df39 (patch) | |
tree | 9a5c708514e448d5bf392088930e496a04b77d6d | |
parent | eb1fbf7a4516dcb44bf5acb2e17ae5955db2afdb (diff) | |
parent | 6056e3268a0aa114ad99e3e6ddaebe0ebfa6035e (diff) | |
download | frameworks_base-3dbc571e62d8c63a55f5e2e58ea22aa6ebf0df39.zip frameworks_base-3dbc571e62d8c63a55f5e2e58ea22aa6ebf0df39.tar.gz frameworks_base-3dbc571e62d8c63a55f5e2e58ea22aa6ebf0df39.tar.bz2 |
am 6056e326: am f96a6150: Data reconnection issue after airplane mode
* commit '6056e3268a0aa114ad99e3e6ddaebe0ebfa6035e':
Data reconnection issue after airplane mode
-rw-r--r-- | telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java | 65 |
1 files changed, 40 insertions, 25 deletions
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java index ec37b68..a48202f 100644 --- a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java +++ b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java @@ -127,10 +127,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { if (apnContext != null) { apnContext.setReason(reason); if (apnContext.getState() == State.FAILED) { - Message msg = obtainMessage(EVENT_CLEAN_UP_CONNECTION); - msg.arg1 = 0; // tearDown is false - msg.obj = (ApnContext)apnContext; - sendMessage(msg); + apnContext.setState(State.IDLE); } sendMessage(obtainMessage(EVENT_TRY_SETUP_DATA, apnContext)); } @@ -644,7 +641,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { for (ApnContext apnContext : mApnContexts.values()) { if (apnContext.isReady()) { if (apnContext.getState() == State.FAILED) { - cleanUpConnection(false, apnContext); + cleanApnContextBeforeRestart(apnContext); if (apnContext.getDataConnection() != null) { apnContext.getDataConnection().resetRetryCount(); } @@ -800,6 +797,39 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { if (DBG) { log("cleanUpConnection: tearDown=" + tearDown + " reason=" + apnContext.getReason()); } + if (tearDown && cleanApnContextBeforeRestart(apnContext)) { + // if the request is tearDown and ApnContext does not hold an active connection, + // we're ok to return here. + return; + } + + DataConnectionAc dcac = apnContext.getDataConnectionAc(); + if (dcac != null) { + if (tearDown) { + apnContext.setState(State.DISCONNECTING); + releaseApnContext(apnContext, tearDown); + } else { + // STOPSHIP: Reference counting logic in GDCT still have issue. + // Need to be cleaned up in later patch + dcac.resetSync(); + if (apnContext.getDataConnection() != null) { + apnContext.getDataConnection().setRefCount(0); + } + apnContext.setState(State.IDLE); + mPhone.notifyDataConnection(apnContext.getReason(), apnContext.getApnType()); + apnContext.setDataConnection(null); + apnContext.setDataConnectionAc(null); + } + } + } + + /** + * @param APNContext to clean + * @return true if ApnContext is not connected anymore. + * false if ApnContext still holds a connection. + */ + private boolean cleanApnContextBeforeRestart(ApnContext apnContext) { + if (apnContext == null) return true; // Clear the reconnect alarm, if set. if (apnContext.getReconnectIntent() != null) { @@ -811,32 +841,16 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { if (apnContext.getState() == State.IDLE || apnContext.getState() == State.DISCONNECTING) { if (DBG) log("cleanUpConnection: state= " + apnContext.getState()); - return; + return true; } if (apnContext.getState() == State.FAILED) { - if (DBG) log("cleanUpConnection: state is in FAILED"); apnContext.setState(State.IDLE); - return; - } - - DataConnection conn = apnContext.getDataConnection(); - if (conn != null) { - DataConnectionAc dcac = mDataConnectionAsyncChannels.get(conn.getDataConnectionId()); - apnContext.setState(State.DISCONNECTING); - if (tearDown) { - releaseApnContext(apnContext, tearDown); - } else { - if (dcac != null) { - dcac.resetSync(); - } - apnContext.setState(State.IDLE); - mPhone.notifyDataConnection(apnContext.getReason(), apnContext.getApnType()); - } + return true; } + return false; } - /** * @param types comma delimited list of APN types * @return array of APN types @@ -1371,7 +1385,8 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { loge("reconnectAfterFail: apnContext == null, impossible"); return; } - if (apnContext.getState() == State.FAILED) { + if ((apnContext.getState() == State.FAILED) && + (apnContext.getDataConnection() != null)) { if (!apnContext.getDataConnection().isRetryNeeded()) { if (!apnContext.getApnType().equals(Phone.APN_TYPE_DEFAULT)) { mPhone.notifyDataConnection(Phone.REASON_APN_FAILED, apnContext.getApnType()); |