summaryrefslogtreecommitdiffstats
path: root/telephony
diff options
context:
space:
mode:
authorKazuhiro Ondo <kazuhiro.ondo@motorola.com>2011-05-21 02:15:20 -0500
committerWink Saville <wink@google.com>2011-05-21 12:49:41 -0700
commitf96a6150e4e6c37f8952456bf9f84714f622713d (patch)
tree8eaf4b232dcfb30c3186b41ba865473701ec08f8 /telephony
parent4c88be655e387011c6d57c6d68b5deb94f6ce601 (diff)
downloadframeworks_base-f96a6150e4e6c37f8952456bf9f84714f622713d.zip
frameworks_base-f96a6150e4e6c37f8952456bf9f84714f622713d.tar.gz
frameworks_base-f96a6150e4e6c37f8952456bf9f84714f622713d.tar.bz2
Data reconnection issue after airplane mode
ApnContext and DC were not disassociated when force "cleanUpConnection" was called. Causing the setup request was not happening if applyNewStatus() was the trigger. Change-Id: I6d73a53edb72bb9ab4ebb92fffd06e6fe1f0c4aa
Diffstat (limited to 'telephony')
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java65
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());