summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--telephony/java/com/android/internal/telephony/DataConnection.java94
-rw-r--r--telephony/java/com/android/internal/telephony/DataConnectionTracker.java17
-rw-r--r--telephony/java/com/android/internal/telephony/cdma/CdmaDataConnection.java9
-rw-r--r--telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java16
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/GsmDataConnection.java9
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java32
6 files changed, 125 insertions, 52 deletions
diff --git a/telephony/java/com/android/internal/telephony/DataConnection.java b/telephony/java/com/android/internal/telephony/DataConnection.java
index 89513fd76613..1f5fc05ee5fc 100644
--- a/telephony/java/com/android/internal/telephony/DataConnection.java
+++ b/telephony/java/com/android/internal/telephony/DataConnection.java
@@ -219,10 +219,8 @@ public abstract class DataConnection extends HierarchicalStateMachine {
protected static final int EVENT_LOG_BAD_DNS_ADDRESS = 50100;
//***** Member Variables
- protected int mId;
protected int mTag;
protected PhoneBase phone;
- protected RetryManager mRetryMgr;
protected int cid;
protected LinkProperties mLinkProperties = new LinkProperties();
protected LinkCapabilities mCapabilities = new LinkCapabilities();
@@ -244,10 +242,11 @@ public abstract class DataConnection extends HierarchicalStateMachine {
//***** Constructor
- protected DataConnection(PhoneBase phone, String name, RetryManager rm) {
+ protected DataConnection(PhoneBase phone, String name, int id, RetryManager rm) {
super(name);
if (DBG) log("DataConnection constructor E");
this.phone = phone;
+ mId = id;
mRetryMgr = rm;
this.cid = -1;
clearSettings();
@@ -342,10 +341,88 @@ public abstract class DataConnection extends HierarchicalStateMachine {
clearSettings();
}
- public RetryManager getRetryMgr() {
- return mRetryMgr;
+ /*
+ * **************************************************************************
+ * Begin Members and methods owned by DataConnectionTracker but stored
+ * in a DataConnection because there is one per connection.
+ * **************************************************************************
+ */
+
+ /*
+ * The id is owned by DataConnectionTracker.
+ */
+ private int mId;
+
+ /**
+ * Get the DataConnection ID
+ */
+ public int getDataConnectionId() {
+ return mId;
+ }
+
+ /*
+ * The retry manager is currently owned by the DataConnectionTracker but is stored
+ * in the DataConnection because there is one per connection. These methods
+ * should only be used by the DataConnectionTracker although someday the retrying
+ * maybe managed by the DataConnection itself and these methods could disappear.
+ */
+ private RetryManager mRetryMgr;
+
+ /**
+ * @return retry manager retryCount
+ */
+ public int getRetryCount() {
+ return mRetryMgr.getRetryCount();
+ }
+
+ /**
+ * @return retry manager retryTimer
+ */
+ public int getRetryTimer() {
+ return mRetryMgr.getRetryTimer();
+ }
+
+ /**
+ * increaseRetryCount of retry manager
+ */
+ public void increaseRetryCount() {
+ mRetryMgr.increaseRetryCount();
+ }
+
+ /**
+ * @return retry manager isRetryNeeded
+ */
+ public boolean isRetryNeeded() {
+ return mRetryMgr.isRetryNeeded();
+ }
+
+ /**
+ * resetRetryCount of retry manager
+ */
+ public void resetRetryCount() {
+ mRetryMgr.resetRetryCount();
+ }
+
+ /**
+ * set retryForeverUsingLasttimeout of retry manager
+ */
+ public void retryForeverUsingLastTimeout() {
+ mRetryMgr.retryForeverUsingLastTimeout();
+ }
+
+ /**
+ * @return retry manager isRetryForever
+ */
+ public boolean isRetryForever() {
+ return mRetryMgr.isRetryForever();
}
+ /*
+ * **************************************************************************
+ * End members owned by DataConnectionTracker
+ * **************************************************************************
+ */
+
/**
* Clear all settings called when entering mInactiveState.
*/
@@ -964,13 +1041,6 @@ public abstract class DataConnection extends HierarchicalStateMachine {
}
/**
- * Get the DataConnection ID
- */
- public int getDataConnectionId() {
- return mId;
- }
-
- /**
* Return the LinkProperties for the connection.
*
* @return a copy of the LinkProperties, is never null.
diff --git a/telephony/java/com/android/internal/telephony/DataConnectionTracker.java b/telephony/java/com/android/internal/telephony/DataConnectionTracker.java
index 460b553d6c73..7f0c7c7d8b80 100644
--- a/telephony/java/com/android/internal/telephony/DataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/DataConnectionTracker.java
@@ -211,9 +211,6 @@ public abstract class DataConnectionTracker extends Handler {
protected int mNoRecvPollCount = 0;
protected boolean mNetStatPollEnabled = false;
- /** Manage the behavior of data retry after failure (TODO: One per connection in the future?) */
- protected RetryManager mRetryMgr = new RetryManager();
-
// wifi connection status will be updated by sticky intent
protected boolean mIsWifiConnected = false;
@@ -416,7 +413,7 @@ public abstract class DataConnectionTracker extends Handler {
Settings.Secure.DATA_ROAMING, enabled ? 1 : 0);
if (mPhone.getServiceState().getRoaming()) {
if (enabled) {
- mRetryMgr.resetRetryCount();
+ resetAllRetryCounts();
}
sendMessage(obtainMessage(EVENT_ROAMING_ON));
}
@@ -468,7 +465,7 @@ public abstract class DataConnectionTracker extends Handler {
case EVENT_ROAMING_OFF:
if (getDataOnRoamingEnabled() == false) {
- mRetryMgr.resetRetryCount();
+ resetAllRetryCounts();
}
onRoamingOff();
break;
@@ -902,7 +899,7 @@ public abstract class DataConnectionTracker extends Handler {
}
if (prevEnabled != getAnyDataEnabled()) {
if (!prevEnabled) {
- mRetryMgr.resetRetryCount();
+ resetAllRetryCounts();
onTrySetupData(Phone.REASON_DATA_ENABLED);
} else {
cleanUpAllConnections();
@@ -936,7 +933,7 @@ public abstract class DataConnectionTracker extends Handler {
Settings.Secure.MOBILE_DATA, enable ? 1 : 0);
if (prevEnabled != getAnyDataEnabled()) {
if (!prevEnabled) {
- mRetryMgr.resetRetryCount();
+ resetAllRetryCounts();
onTrySetupData(Phone.REASON_DATA_ENABLED);
} else {
onCleanUpConnection(true, APN_DEFAULT_ID, Phone.REASON_DATA_DISABLED);
@@ -944,4 +941,10 @@ public abstract class DataConnectionTracker extends Handler {
}
}
}
+
+ protected void resetAllRetryCounts() {
+ for (DataConnection dc : mDataConnections.values()) {
+ dc.resetRetryCount();
+ }
+ }
}
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnection.java b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnection.java
index 1a0dbc2f0ca3..4f27e7fcdcb5 100644
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnection.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnection.java
@@ -33,8 +33,8 @@ public class CdmaDataConnection extends DataConnection {
private static final String LOG_TAG = "CDMA";
// ***** Constructor
- private CdmaDataConnection(CDMAPhone phone, String name, RetryManager rm) {
- super(phone, name, rm);
+ private CdmaDataConnection(CDMAPhone phone, String name, int id, RetryManager rm) {
+ super(phone, name, id, rm);
}
/**
@@ -49,11 +49,10 @@ public class CdmaDataConnection extends DataConnection {
synchronized (mCountLock) {
mCount += 1;
}
- CdmaDataConnection cdmaDc = new CdmaDataConnection(phone,
- "CdmaDataConnection-" + mCount, rm);
+ CdmaDataConnection cdmaDc = new CdmaDataConnection(phone, "CdmaDataConnection-" + mCount,
+ id, rm);
cdmaDc.start();
if (DBG) cdmaDc.log("Made " + cdmaDc.getName());
- cdmaDc.mId = id;
return cdmaDc;
}
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
index 81cfeadb7672..f2409e5dd8c4 100644
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
@@ -328,7 +328,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
setState(State.CONNECTED);
notifyDataConnection(reason);
startNetStatPoll();
- mRetryMgr.resetRetryCount();
+ mDataConnections.get(0).resetRetryCount();
}
private void resetPollStats() {
@@ -478,7 +478,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
* at the last time until the state is changed.
* TODO: Make this configurable?
*/
- int nextReconnectDelay = mRetryMgr.getRetryTimer();
+ int nextReconnectDelay = mDataConnections.get(0).getRetryTimer();
log("Data Connection activate failed. Scheduling next attempt for "
+ (nextReconnectDelay / 1000) + "s");
@@ -492,7 +492,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
SystemClock.elapsedRealtime() + nextReconnectDelay,
mReconnectIntent);
- mRetryMgr.increaseRetryCount();
+ mDataConnections.get(0).increaseRetryCount();
if (!shouldPostNotification(lastFailCauseCode)) {
log("NOT Posting Data Connection Unavailable notification "
@@ -593,7 +593,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
*/
@Override
protected void onRadioOffOrNotAvailable() {
- mRetryMgr.resetRetryCount();
+ mDataConnections.get(0).resetRetryCount();
if (mPhone.getSimulatedRadioControl() != null) {
// Assume data is connected on the simulator
@@ -708,7 +708,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
}
notifyDataAvailability(Phone.REASON_VOICE_CALL_ENDED);
} else {
- mRetryMgr.resetRetryCount();
+ mDataConnections.get(0).resetRetryCount();
// in case data setup was attempted when we were on a voice call
trySetupData(Phone.REASON_VOICE_CALL_ENDED);
}
@@ -730,7 +730,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
CdmaDataConnection dataConn;
/** TODO: Use one retry manager for all connections for now */
- RetryManager rm = mRetryMgr;
+ RetryManager rm = new RetryManager();
if (!rm.configure(SystemProperties.get("ro.cdma.data_retry_config"))) {
if (!rm.configure(DEFAULT_DATA_RETRY_CONFIG)) {
// Should never happen, log an error and default to a simple linear sequence.
@@ -761,7 +761,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
} else {
if (mState == State.FAILED) {
cleanUpConnection(false, Phone.REASON_CDMA_DATA_DETACHED);
- mRetryMgr.resetRetryCount();
+ mDataConnections.get(0).resetRetryCount();
CdmaCellLocation loc = (CdmaCellLocation)(mPhone.getCellLocation());
EventLog.writeEvent(EventLogTags.CDMA_DATA_SETUP_FAILED,
@@ -779,7 +779,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
switch (otaPrivision[0]) {
case Phone.CDMA_OTA_PROVISION_STATUS_COMMITTED:
case Phone.CDMA_OTA_PROVISION_STATUS_OTAPA_STOPPED:
- mRetryMgr.resetRetryCount();
+ mDataConnections.get(0).resetRetryCount();
break;
default:
break;
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnection.java b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnection.java
index 9f7673c75cdb..344486a13c38 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnection.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnection.java
@@ -41,8 +41,8 @@ public class GsmDataConnection extends DataConnection {
protected int mProfileId = RILConstants.DATA_PROFILE_DEFAULT;
protected String mActiveApnType = Phone.APN_TYPE_DEFAULT;
//***** Constructor
- private GsmDataConnection(PhoneBase phone, String name, RetryManager rm) {
- super(phone, name, rm);
+ private GsmDataConnection(PhoneBase phone, String name, int id, RetryManager rm) {
+ super(phone, name, id, rm);
}
/**
@@ -57,11 +57,10 @@ public class GsmDataConnection extends DataConnection {
synchronized (mCountLock) {
mCount += 1;
}
- GsmDataConnection gsmDc = new GsmDataConnection(phone, "GsmDataConnection-" + mCount, rm);
+ GsmDataConnection gsmDc = new GsmDataConnection(phone, "GsmDataConnection-" + mCount,
+ id, rm);
gsmDc.start();
if (DBG) gsmDc.log("Made " + gsmDc.getName());
- gsmDc.mId = id;
- gsmDc.mRetryMgr = rm;
return gsmDc;
}
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
index 58f89346379e..0f629077e268 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
@@ -546,7 +546,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
ApnContext defaultApnContext = mApnContexts.get(Phone.APN_TYPE_DEFAULT);
if (defaultApnContext.getState() == State.FAILED) {
cleanUpConnection(false, defaultApnContext);
- mRetryMgr.resetRetryCount();
+ defaultApnContext.getDataConnection().resetRetryCount();
}
trySetupData(Phone.REASON_GPRS_ATTACHED, Phone.APN_TYPE_DEFAULT);
}
@@ -934,7 +934,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
cleanUpAllConnections(isConnected, Phone.REASON_APN_CHANGED);
if (!isConnected) {
// TODO: Won't work for multiple connections!!!!
- mRetryMgr.resetRetryCount();
+ defaultApnContext.getDataConnection().resetRetryCount();
defaultApnContext.setReason(Phone.REASON_APN_CHANGED);
trySetupData(defaultApnContext);
}
@@ -1032,7 +1032,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
mPhone.notifyDataConnection(apnContext.getReason(), apnContext.getApnType());
startNetStatPoll();
// reset reconnect timer
- mRetryMgr.resetRetryCount();
+ apnContext.getDataConnection().resetRetryCount();
}
// TODO: For multiple Active APNs not exactly sure how to do this.
@@ -1233,7 +1233,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
return;
}
if (apnContext.getState() == State.FAILED) {
- if (!mRetryMgr.isRetryNeeded()) {
+ if (!apnContext.getDataConnection().isRetryNeeded()) {
if (!apnContext.getApnType().equals(Phone.APN_TYPE_DEFAULT)){
// if no more retries on a secondary APN attempt, tell the world and revert.
notifyDataConnection(Phone.REASON_APN_FAILED);
@@ -1241,18 +1241,18 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
}
if (mReregisterOnReconnectFailure) {
// We've re-registerd once now just retry forever.
- mRetryMgr.retryForeverUsingLastTimeout();
+ apnContext.getDataConnection().retryForeverUsingLastTimeout();
} else {
// Try to Re-register to the network.
log("PDP activate failed, Reregistering to the network");
mReregisterOnReconnectFailure = true;
mPhone.getServiceStateTracker().reRegisterNetwork(null);
- mRetryMgr.resetRetryCount();
+ apnContext.getDataConnection().resetRetryCount();
return;
}
}
- int nextReconnectDelay = mRetryMgr.getRetryTimer();
+ int nextReconnectDelay = apnContext.getDataConnection().getRetryTimer();
log("PDP activate failed. Scheduling next attempt for "
+ (nextReconnectDelay / 1000) + "s");
@@ -1268,7 +1268,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
SystemClock.elapsedRealtime() + nextReconnectDelay,
apnContext.getReconnectIntent());
- mRetryMgr.increaseRetryCount();
+ apnContext.getDataConnection().increaseRetryCount();
if (!shouldPostNotification(lastFailCauseCode)) {
Log.d(LOG_TAG, "NOT Posting GPRS Unavailable notification "
@@ -1308,14 +1308,12 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
if (apnContext.getApnType().equals(Phone.APN_TYPE_DEFAULT)) {
log("onEnableNewApn default type");
ApnContext defaultApnContext = mApnContexts.get(Phone.APN_TYPE_DEFAULT);
- mRetryMgr = defaultApnContext.getDataConnection().getRetryMgr();
- mRetryMgr.resetRetryCount();
+ defaultApnContext.getDataConnection().resetRetryCount();
} else if (mApnToDataConnectionId.get(apnContext.getApnType()) == null) {
log("onEnableNewApn ApnType=" + apnContext.getApnType() +
" missing, make a new connection");
int id = createDataConnection(apnContext.getApnType());
- mRetryMgr = mDataConnections.get(id).getRetryMgr();
- mRetryMgr.resetRetryCount();
+ mDataConnections.get(id).resetRetryCount();
} else {
log("oneEnableNewApn connection already exists, nothing to setup");
}
@@ -1378,7 +1376,10 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
protected void onRadioOffOrNotAvailable() {
// Make sure our reconnect delay starts at the initial value
// next time the radio comes on
- mRetryMgr.resetRetryCount();
+
+ for (DataConnection dc : mDataConnections.values()) {
+ dc.resetRetryCount();
+ }
mReregisterOnReconnectFailure = false;
if (mPhone.getSimulatedRadioControl() != null) {
@@ -1568,7 +1569,8 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
}
} else {
// reset reconnect timer
- mRetryMgr.resetRetryCount();
+ ApnContext defaultApnContext = mApnContexts.get(Phone.APN_TYPE_DEFAULT);
+ defaultApnContext.getDataConnection().resetRetryCount();
mReregisterOnReconnectFailure = false;
// in case data setup was attempted when we were on a voice call
trySetupData(Phone.REASON_VOICE_CALL_ENDED, Phone.APN_TYPE_DEFAULT);
@@ -1872,7 +1874,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
// TODO: Should all PDN states be checked to fail?
if (mState == State.FAILED) {
cleanUpAllConnections(false, Phone.REASON_PS_RESTRICT_ENABLED);
- mRetryMgr.resetRetryCount();
+ resetAllRetryCounts();
mReregisterOnReconnectFailure = false;
}
trySetupData(Phone.REASON_PS_RESTRICT_ENABLED, Phone.APN_TYPE_DEFAULT);