diff options
author | Android (Google) Code Review <android-gerrit@google.com> | 2009-06-26 19:29:55 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-06-26 19:29:55 -0700 |
commit | 4cb1276e143e175590c69ceefa58eb721aa52846 (patch) | |
tree | 3e0c29d0e84f8380c1615a79f97fb892170d5cb5 | |
parent | 05ebcb5172679a6c196cbf23d7174c04dd9f6ae0 (diff) | |
parent | e7e12b44bc37ba971507dde265bb999b63a580e8 (diff) | |
download | frameworks_base-4cb1276e143e175590c69ceefa58eb721aa52846.zip frameworks_base-4cb1276e143e175590c69ceefa58eb721aa52846.tar.gz frameworks_base-4cb1276e143e175590c69ceefa58eb721aa52846.tar.bz2 |
Merge change 4956 into donut
* changes:
Tune the Reconnect back off timer.
3 files changed, 67 insertions, 37 deletions
diff --git a/telephony/java/com/android/internal/telephony/DataConnectionTracker.java b/telephony/java/com/android/internal/telephony/DataConnectionTracker.java index af79404..c074cb8 100644 --- a/telephony/java/com/android/internal/telephony/DataConnectionTracker.java +++ b/telephony/java/com/android/internal/telephony/DataConnectionTracker.java @@ -98,8 +98,8 @@ public abstract class DataConnectionTracker extends Handler { //***** Constants protected static final int RECONNECT_DELAY_INITIAL_MILLIS = 5 * 1000; - /** Cap out with 1 hour retry interval. */ - protected static final int RECONNECT_DELAY_MAX_MILLIS = 60 * 60 * 1000; + /** Cap out with 30 min retry interval. */ + protected static final int RECONNECT_DELAY_MAX_MILLIS = 30 * 60 * 1000; /** Slow poll when attempting connection recovery. */ protected static final int POLL_NETSTAT_SLOW_MILLIS = 5000; diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java index 2a65de3..9d29272 100644 --- a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java +++ b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java @@ -26,22 +26,18 @@ import android.content.SharedPreferences; import android.net.NetworkInfo; import android.net.wifi.WifiManager; import android.os.AsyncResult; -import android.os.Handler; import android.os.INetStatService; import android.os.Message; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; -import android.os.SystemProperties; import android.preference.PreferenceManager; import android.provider.Checkin; -import android.provider.Settings; -import android.provider.Settings.SettingNotFoundException; import android.telephony.ServiceState; import android.telephony.TelephonyManager; import android.telephony.cdma.CdmaCellLocation; -import android.util.EventLog; import android.text.TextUtils; +import android.util.EventLog; import android.util.Log; import com.android.internal.telephony.CommandsInterface; @@ -50,7 +46,6 @@ import com.android.internal.telephony.DataConnection; import com.android.internal.telephony.DataConnection.FailCause; import com.android.internal.telephony.DataConnectionTracker; import com.android.internal.telephony.Phone; -import com.android.internal.telephony.PhoneProxy; import com.android.internal.telephony.TelephonyEventLog; import java.util.ArrayList; @@ -67,6 +62,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker { // Indicates baseband will not auto-attach private boolean noAutoAttach = false; long nextReconnectDelay = RECONNECT_DELAY_INITIAL_MILLIS; + private boolean mReregisterOnReconnectFailure = false; private boolean mIsScreenOn = true; //useful for debugging @@ -464,6 +460,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker { startNetStatPoll(); // reset reconnect timer nextReconnectDelay = RECONNECT_DELAY_INITIAL_MILLIS; + mReregisterOnReconnectFailure = false; } private void resetPollStats() { @@ -619,6 +616,21 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker { private void reconnectAfterFail(FailCause lastFailCauseCode, String reason) { if (state == State.FAILED) { + if (nextReconnectDelay > RECONNECT_DELAY_MAX_MILLIS) { + if (mReregisterOnReconnectFailure) { + // We have already tried to re-register to the network. + // This might be a problem with the data network. + nextReconnectDelay = RECONNECT_DELAY_MAX_MILLIS; + } else { + // Try to Re-register to the network. + Log.d(LOG_TAG, "PDP activate failed, Reregistering to the network"); + mReregisterOnReconnectFailure = true; + mCdmaPhone.mSST.reRegisterNetwork(null); + nextReconnectDelay = RECONNECT_DELAY_INITIAL_MILLIS; + return; + } + } + Log.d(LOG_TAG, "Data Connection activate failed. Scheduling next attempt for " + (nextReconnectDelay / 1000) + "s"); @@ -634,9 +646,6 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker { // double it for next time nextReconnectDelay *= 2; - if (nextReconnectDelay > RECONNECT_DELAY_MAX_MILLIS) { - nextReconnectDelay = RECONNECT_DELAY_MAX_MILLIS; - } if (!shouldPostNotification(lastFailCauseCode)) { Log.d(LOG_TAG,"NOT Posting Data Connection Unavailable notification " @@ -716,6 +725,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker { // Make sure our reconnect delay starts at the initial value // next time the radio comes on nextReconnectDelay = RECONNECT_DELAY_INITIAL_MILLIS; + mReregisterOnReconnectFailure = false; if (phone.getSimulatedRadioControl() != null) { // Assume data is connected on the simulator @@ -793,6 +803,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker { } else { // reset reconnect timer nextReconnectDelay = RECONNECT_DELAY_INITIAL_MILLIS; + mReregisterOnReconnectFailure = false; // in case data setup was attempted when we were on a voice call trySetupData(Phone.REASON_VOICE_CALL_ENDED); } diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java index 035c690..346944a 100644 --- a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java +++ b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java @@ -65,6 +65,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { private static final String LOG_TAG = "GSM"; private static final boolean DBG = true; + private GSMPhone mGsmPhone; /** * Handles changes to the APN db. */ @@ -85,6 +86,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { // Indicates baseband will not auto-attach private boolean noAutoAttach = false; long nextReconnectDelay = RECONNECT_DELAY_INITIAL_MILLIS; + private boolean mReregisterOnReconnectFailure = false; private ContentResolver mResolver; private boolean mPingTestActive = false; @@ -204,6 +206,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { GsmDataConnectionTracker(GSMPhone p) { super(p); + mGsmPhone = p; p.mCM.registerForAvailable (this, EVENT_RADIO_AVAILABLE, null); p.mCM.registerForOffOrNotAvailable(this, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null); @@ -250,16 +253,16 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { //Unregister for all events phone.mCM.unregisterForAvailable(this); phone.mCM.unregisterForOffOrNotAvailable(this); - ((GSMPhone) phone).mSIMRecords.unregisterForRecordsLoaded(this); + mGsmPhone.mSIMRecords.unregisterForRecordsLoaded(this); phone.mCM.unregisterForDataStateChanged(this); - ((GSMPhone) phone).mCT.unregisterForVoiceCallEnded(this); - ((GSMPhone) phone).mCT.unregisterForVoiceCallStarted(this); - ((GSMPhone) phone).mSST.unregisterForGprsAttached(this); - ((GSMPhone) phone).mSST.unregisterForGprsDetached(this); - ((GSMPhone) phone).mSST.unregisterForRoamingOn(this); - ((GSMPhone) phone).mSST.unregisterForRoamingOff(this); - ((GSMPhone) phone).mSST.unregisterForPsRestrictedEnabled(this); - ((GSMPhone) phone).mSST.unregisterForPsRestrictedDisabled(this); + mGsmPhone.mCT.unregisterForVoiceCallEnded(this); + mGsmPhone.mCT.unregisterForVoiceCallStarted(this); + mGsmPhone.mSST.unregisterForGprsAttached(this); + mGsmPhone.mSST.unregisterForGprsDetached(this); + mGsmPhone.mSST.unregisterForRoamingOn(this); + mGsmPhone.mSST.unregisterForRoamingOff(this); + mGsmPhone.mSST.unregisterForPsRestrictedEnabled(this); + mGsmPhone.mSST.unregisterForPsRestrictedDisabled(this); phone.getContext().unregisterReceiver(this.mIntentReceiver); phone.getContext().getContentResolver().unregisterContentObserver(this.apnObserver); @@ -407,8 +410,8 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { public boolean isDataConnectionAsDesired() { boolean roaming = phone.getServiceState().getRoaming(); - if (((GSMPhone) phone).mSIMRecords.getRecordsLoaded() && - ((GSMPhone) phone).mSST.getCurrentGprsState() == ServiceState.STATE_IN_SERVICE && + if (mGsmPhone.mSIMRecords.getRecordsLoaded() && + mGsmPhone.mSST.getCurrentGprsState() == ServiceState.STATE_IN_SERVICE && (!roaming || getDataOnRoamingEnabled()) && !mIsWifiConnected && !mIsPsRestricted ) { @@ -572,13 +575,13 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { return true; } - int gprsState = ((GSMPhone) phone).mSST.getCurrentGprsState(); + int gprsState = mGsmPhone.mSST.getCurrentGprsState(); boolean roaming = phone.getServiceState().getRoaming(); - boolean desiredPowerState = ((GSMPhone) phone).mSST.getDesiredPowerState(); + boolean desiredPowerState = mGsmPhone.mSST.getDesiredPowerState(); if ((state == State.IDLE || state == State.SCANNING) && (gprsState == ServiceState.STATE_IN_SERVICE || noAutoAttach) - && ((GSMPhone) phone).mSIMRecords.getRecordsLoaded() + && mGsmPhone.mSIMRecords.getRecordsLoaded() && phone.getState() == Phone.State.IDLE && isDataAllowed() && !mIsPsRestricted @@ -604,8 +607,8 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { log("trySetupData: Not ready for data: " + " dataState=" + state + " gprsState=" + gprsState + - " sim=" + ((GSMPhone) phone).mSIMRecords.getRecordsLoaded() + - " UMTS=" + ((GSMPhone) phone).mSST.isConcurrentVoiceAndData() + + " sim=" + mGsmPhone.mSIMRecords.getRecordsLoaded() + + " UMTS=" + mGsmPhone.mSST.isConcurrentVoiceAndData() + " phoneState=" + phone.getState() + " dataEnabled=" + getAnyDataEnabled() + " roaming=" + roaming + @@ -792,7 +795,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { isConnected = (state != State.IDLE && state != State.FAILED); // The "current" may no longer be valid. MMS depends on this to send properly. - ((GSMPhone) phone).updateCurrentCarrierInProvider(); + mGsmPhone.updateCurrentCarrierInProvider(); // TODO: It'd be nice to only do this if the changed entrie(s) // match the current operator. @@ -802,6 +805,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { if (!isConnected) { // reset reconnect timer nextReconnectDelay = RECONNECT_DELAY_INITIAL_MILLIS; + mReregisterOnReconnectFailure = false; trySetupData(Phone.REASON_APN_CHANGED); } } @@ -882,6 +886,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { startNetStatPoll(); // reset reconnect timer nextReconnectDelay = RECONNECT_DELAY_INITIAL_MILLIS; + mReregisterOnReconnectFailure = false; } private void setupDnsProperties() { @@ -952,7 +957,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { } else { mPdpResetCount = 0; EventLog.writeEvent(TelephonyEventLog.EVENT_LOG_REREGISTER_NETWORK, sentSinceLastRecv); - ((GSMPhone) phone).mSST.reRegisterNetwork(null); + mGsmPhone.mSST.reRegisterNetwork(null); } // TODO: Add increasingly drastic recovery steps, eg, // reset the radio, reset the device. @@ -1166,6 +1171,20 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { private void reconnectAfterFail(FailCause lastFailCauseCode, String reason) { if (state == State.FAILED) { + if (nextReconnectDelay > RECONNECT_DELAY_MAX_MILLIS) { + if (mReregisterOnReconnectFailure) { + // We have already tried to re-register to the network. + // This might be a problem with the data network. + nextReconnectDelay = RECONNECT_DELAY_MAX_MILLIS; + } else { + // Try to Re-register to the network. + Log.d(LOG_TAG, "PDP activate failed, Reregistering to the network"); + mReregisterOnReconnectFailure = true; + mGsmPhone.mSST.reRegisterNetwork(null); + nextReconnectDelay = RECONNECT_DELAY_INITIAL_MILLIS; + return; + } + } Log.d(LOG_TAG, "PDP activate failed. Scheduling next attempt for " + (nextReconnectDelay / 1000) + "s"); @@ -1181,9 +1200,6 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { // double it for next time nextReconnectDelay *= 2; - if (nextReconnectDelay > RECONNECT_DELAY_MAX_MILLIS) { - nextReconnectDelay = RECONNECT_DELAY_MAX_MILLIS; - } if (!shouldPostNotification(lastFailCauseCode)) { Log.d(LOG_TAG,"NOT Posting GPRS Unavailable notification " @@ -1258,6 +1274,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { // Make sure our reconnect delay starts at the initial value // next time the radio comes on nextReconnectDelay = RECONNECT_DELAY_INITIAL_MILLIS; + mReregisterOnReconnectFailure = false; if (phone.getSimulatedRadioControl() != null) { // Assume data is connected on the simulator @@ -1370,7 +1387,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { } protected void onVoiceCallStarted() { - if (state == State.CONNECTED && !((GSMPhone) phone).mSST.isConcurrentVoiceAndData()) { + if (state == State.CONNECTED && ! mGsmPhone.mSST.isConcurrentVoiceAndData()) { stopNetStatPoll(); phone.notifyDataConnection(Phone.REASON_VOICE_CALL_STARTED); } @@ -1378,7 +1395,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { protected void onVoiceCallEnded() { if (state == State.CONNECTED) { - if (!((GSMPhone) phone).mSST.isConcurrentVoiceAndData()) { + if (mGsmPhone.mSST.isConcurrentVoiceAndData()) { startNetStatPoll(); phone.notifyDataConnection(Phone.REASON_VOICE_CALL_ENDED); } else { @@ -1388,6 +1405,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { } else { // reset reconnect timer nextReconnectDelay = RECONNECT_DELAY_INITIAL_MILLIS; + mReregisterOnReconnectFailure = false; // in case data setup was attempted when we were on a voice call trySetupData(Phone.REASON_VOICE_CALL_ENDED); } @@ -1417,7 +1435,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { */ private void createAllApnList() { allApns = new ArrayList<ApnSetting>(); - String operator = ((GSMPhone) phone).mSIMRecords.getSIMOperatorNumeric(); + String operator = mGsmPhone.mSIMRecords.getSIMOperatorNumeric(); if (operator != null) { String selection = "numeric = '" + operator + "'"; @@ -1459,7 +1477,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { DataConnection pdp; for (int i = 0; i < PDP_CONNECTION_POOL_SIZE; i++) { - pdp = new PdpConnection((GSMPhone) phone); + pdp = new PdpConnection(mGsmPhone); pdpList.add(pdp); } } @@ -1478,7 +1496,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { */ private ArrayList<ApnSetting> buildWaitingApns() { ArrayList<ApnSetting> apnList = new ArrayList<ApnSetting>(); - String operator = ((GSMPhone )phone).mSIMRecords.getSIMOperatorNumeric(); + String operator = mGsmPhone.mSIMRecords.getSIMOperatorNumeric(); if (mRequestedApnType.equals(Phone.APN_TYPE_DEFAULT)) { if (canSetPreferApn && preferredApn != null) { @@ -1664,6 +1682,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { if (state == State.FAILED) { cleanUpConnection(false, Phone.REASON_PS_RESTRICT_ENABLED); nextReconnectDelay = RECONNECT_DELAY_INITIAL_MILLIS; + mReregisterOnReconnectFailure = false; } trySetupData(Phone.REASON_PS_RESTRICT_ENABLED); } |