summaryrefslogtreecommitdiffstats
path: root/telephony
diff options
context:
space:
mode:
authorWink Saville <wink@google.com>2010-03-12 15:31:56 -0800
committerWink Saville <wink@google.com>2010-03-12 15:31:56 -0800
commitabeff9479fae6b0b92e56bd7bd9d043cdfd9317a (patch)
tree40858c1d20758149a21562b6370dfd7c0020230a /telephony
parente1748c67143f3bd2187cdafa8788790c8e33dbe5 (diff)
downloadframeworks_base-abeff9479fae6b0b92e56bd7bd9d043cdfd9317a.zip
frameworks_base-abeff9479fae6b0b92e56bd7bd9d043cdfd9317a.tar.gz
frameworks_base-abeff9479fae6b0b92e56bd7bd9d043cdfd9317a.tar.bz2
Fix data error handling.
In change I5776324a I made DataConnection.reset asynchronous. That was a mistake as callers to cleanUpConnection assumed it was synchronous. Added DataConnection.resetSynchronously as a fix, someday the trackers will become asynchronous and this won't be necessary. Change-Id: I4669901e5c47a712212bb388c35fbb9f9ff603a7
Diffstat (limited to 'telephony')
-rw-r--r--telephony/java/com/android/internal/telephony/DataConnection.java45
-rw-r--r--telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java9
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java9
3 files changed, 50 insertions, 13 deletions
diff --git a/telephony/java/com/android/internal/telephony/DataConnection.java b/telephony/java/com/android/internal/telephony/DataConnection.java
index 521072e..70fdadf 100644
--- a/telephony/java/com/android/internal/telephony/DataConnection.java
+++ b/telephony/java/com/android/internal/telephony/DataConnection.java
@@ -135,15 +135,26 @@ public abstract class DataConnection extends HierarchicalStateMachine {
}
/**
+ * An instance used for notification of blockingReset.
+ * TODO: Remove when blockingReset is removed.
+ */
+ class ResetSynchronouslyLock {
+ }
+
+ /**
* Used internally for saving disconnecting parameters.
*/
protected static class DisconnectParams {
public DisconnectParams(Message onCompletedMsg) {
this.onCompletedMsg = onCompletedMsg;
}
+ public DisconnectParams(ResetSynchronouslyLock lockObj) {
+ this.lockObj = lockObj;
+ }
public int tag;
public Message onCompletedMsg;
+ public ResetSynchronouslyLock lockObj;
}
/**
@@ -339,11 +350,18 @@ public abstract class DataConnection extends HierarchicalStateMachine {
private void notifyDisconnectCompleted(DisconnectParams dp) {
if (DBG) log("NotifyDisconnectCompleted");
- Message msg = dp.onCompletedMsg;
- log(String.format("msg.what=%d msg.obj=%s",
- msg.what, ((msg.obj instanceof String) ? (String) msg.obj : "<no-reason>")));
- AsyncResult.forMessage(msg);
- msg.sendToTarget();
+ if (dp.onCompletedMsg != null) {
+ Message msg = dp.onCompletedMsg;
+ log(String.format("msg.what=%d msg.obj=%s",
+ msg.what, ((msg.obj instanceof String) ? (String) msg.obj : "<no-reason>")));
+ AsyncResult.forMessage(msg);
+ msg.sendToTarget();
+ }
+ if (dp.lockObj != null) {
+ synchronized(dp.lockObj) {
+ dp.lockObj.notify();
+ }
+ }
clearSettings();
}
@@ -778,6 +796,23 @@ public abstract class DataConnection extends HierarchicalStateMachine {
}
/**
+ * Reset the connection and wait for it to complete.
+ * TODO: Remove when all callers only need the asynchronous
+ * reset defined above.
+ */
+ public void resetSynchronously() {
+ ResetSynchronouslyLock lockObj = new ResetSynchronouslyLock();
+ synchronized(lockObj) {
+ sendMessage(obtainMessage(EVENT_RESET, new DisconnectParams(lockObj)));
+ try {
+ lockObj.wait();
+ } catch (InterruptedException e) {
+ log("blockingReset: unexpected interrupted of wait()");
+ }
+ }
+ }
+
+ /**
* Connect to the apn and return an AsyncResult in onCompletedMsg.
* Used for cellular networks that use Acess Point Names (APN) such
* as GSM networks.
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
index 9218715..af9c652 100644
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
@@ -386,18 +386,19 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
if (tearDown) {
if (DBG) log("cleanUpConnection: teardown, call conn.disconnect");
conn.disconnect(obtainMessage(EVENT_DISCONNECT_DONE, reason));
+ notificationDeferred = true;
} else {
- if (DBG) log("cleanUpConnection: !tearDown, call conn.reset");
- conn.reset(obtainMessage(EVENT_RESET_DONE, reason));
+ if (DBG) log("cleanUpConnection: !tearDown, call conn.resetSynchronously");
+ conn.resetSynchronously();
+ notificationDeferred = false;
}
- notificationDeferred = true;
}
}
stopNetStatPoll();
if (!notificationDeferred) {
- if (DBG) log("cleanupConnection: !tearDown && !resettingConn");
+ if (DBG) log("cleanupConnection: !notificationDeferred");
gotoIdleAndNotifyDataConnection(reason);
}
}
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
index f26e54e..f968652 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
@@ -507,16 +507,17 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
if (tearDown) {
if (DBG) log("cleanUpConnection: teardown, call conn.disconnect");
conn.disconnect(obtainMessage(EVENT_DISCONNECT_DONE, reason));
+ notificationDeferred = true;
} else {
- if (DBG) log("cleanUpConnection: !tearDown, call conn.reset");
- conn.reset(obtainMessage(EVENT_RESET_DONE, reason));
+ if (DBG) log("cleanUpConnection: !tearDown, call conn.resetSynchronously");
+ conn.resetSynchronously();
+ notificationDeferred = false;
}
- notificationDeferred = true;
}
stopNetStatPoll();
if (!notificationDeferred) {
- if (DBG) log("cleanupConnection: !tearDown && !resettingConn");
+ if (DBG) log("cleanupConnection: !notificationDeferred");
gotoIdleAndNotifyDataConnection(reason);
}
}