@@ -134,6 +134,8 @@ public void putRecoveryAction(int action) {
134134 private static final String INTENT_RECONNECT_ALARM =
135135 "com.android.internal.telephony.gprs-reconnect" ;
136136 private static final String INTENT_RECONNECT_ALARM_EXTRA_TYPE = "reconnect_alarm_extra_type" ;
137+ private static final String INTENT_RECONNECT_ALARM_EXTRA_RETRY_COUNT =
138+ "reconnect_alaram_extra_retry_count" ;
137139
138140 private static final String INTENT_DATA_STALL_ALARM =
139141 "com.android.internal.telephony.gprs-data-stall" ;
@@ -148,18 +150,23 @@ public void putRecoveryAction(int action) {
148150
149151 @ Override
150152 protected void onActionIntentReconnectAlarm (Intent intent ) {
151- if (DBG ) log ("GPRS reconnect alarm. Previous state was " + mState );
152-
153153 String reason = intent .getStringExtra (INTENT_RECONNECT_ALARM_EXTRA_REASON );
154154 int connectionId = intent .getIntExtra (INTENT_RECONNECT_ALARM_EXTRA_TYPE , -1 );
155+ int retryCount = intent .getIntExtra (INTENT_RECONNECT_ALARM_EXTRA_RETRY_COUNT , 0 );
155156
156157 DataConnectionAc dcac = mDataConnectionAsyncChannels .get (connectionId );
157158
159+ if (DBG ) {
160+ log ("onActionIntentReconnectAlarm: mState=" + mState + " reason=" + reason +
161+ " connectionId=" + connectionId + " retryCount=" + retryCount );
162+ }
163+
158164 if (dcac != null ) {
159165 for (ApnContext apnContext : dcac .getApnListSync ()) {
160166 apnContext .setDataConnectionAc (null );
161167 apnContext .setDataConnection (null );
162168 apnContext .setReason (reason );
169+ apnContext .setRetryCount (retryCount );
163170 if (apnContext .getState () == State .FAILED ) {
164171 apnContext .setState (State .IDLE );
165172 }
@@ -207,7 +214,6 @@ public GsmDataConnectionTracker(PhoneBase p) {
207214 p .getContext ().getContentResolver ().registerContentObserver (
208215 Telephony .Carriers .CONTENT_URI , true , mApnObserver );
209216
210- mApnContexts = new ConcurrentHashMap <String , ApnContext >();
211217 initApnContextsAndDataConnection ();
212218 broadcastMessenger ();
213219 }
@@ -674,10 +680,15 @@ private void setupDataOnReadyApns(String reason) {
674680 break ;
675681 }
676682 }
677- configureRetry (dcac .dataConnection , hasDefault );
683+ configureRetry (dcac .dataConnection , hasDefault , 0 );
678684 }
679685 }
680686
687+ // Be sure retry counts for Apncontexts and DC's are sync'd.
688+ // When DCT/ApnContexts are refactored and we cleanup retrying
689+ // this won't be needed.
690+ resetAllRetryCounts ();
691+
681692 // Only check for default APN state
682693 for (ApnContext apnContext : mApnContexts .values ()) {
683694 if (apnContext .getState () == State .FAILED ) {
@@ -1078,7 +1089,8 @@ private boolean setupData(ApnContext apnContext) {
10781089
10791090 // configure retry count if no other Apn is using the same connection.
10801091 if (refCount == 0 ) {
1081- configureRetry (dc , apn .canHandleType (Phone .APN_TYPE_DEFAULT ));
1092+ configureRetry (dc , apn .canHandleType (Phone .APN_TYPE_DEFAULT ),
1093+ apnContext .getRetryCount ());
10821094 }
10831095 apnContext .setDataConnectionAc (dcac );
10841096 apnContext .setDataConnection (dc );
@@ -1330,7 +1342,7 @@ private void notifyDefaultData(ApnContext apnContext) {
13301342 startNetStatPoll ();
13311343 startDataStallAlarm (DATA_STALL_NOT_SUSPECTED );
13321344 // reset reconnect timer
1333- apnContext .getDataConnection (). resetRetryCount ( );
1345+ apnContext .setRetryCount ( 0 );
13341346 }
13351347
13361348 // TODO: For multiple Active APNs not exactly sure how to do this.
@@ -1601,6 +1613,10 @@ private void reconnectAfterFail(FailCause lastFailCauseCode,
16011613 loge ("reconnectAfterFail: apnContext == null, impossible" );
16021614 return ;
16031615 }
1616+ if (DBG ) {
1617+ log ("reconnectAfterFail: lastFailCause=" + lastFailCauseCode +
1618+ " retryOverride=" + retryOverride + " apnContext=" + apnContext );
1619+ }
16041620 if ((apnContext .getState () == State .FAILED ) &&
16051621 (apnContext .getDataConnection () != null )) {
16061622 if (!apnContext .getDataConnection ().isRetryNeeded ()) {
@@ -1616,7 +1632,7 @@ private void reconnectAfterFail(FailCause lastFailCauseCode,
16161632 if (DBG ) log ("reconnectAfterFail: activate failed, Reregistering to network" );
16171633 mReregisterOnReconnectFailure = true ;
16181634 mPhone .getServiceStateTracker ().reRegisterNetwork (null );
1619- apnContext .getDataConnection (). resetRetryCount ( );
1635+ apnContext .setRetryCount ( 0 );
16201636 return ;
16211637 }
16221638 }
@@ -1627,6 +1643,11 @@ private void reconnectAfterFail(FailCause lastFailCauseCode,
16271643 if (nextReconnectDelay < 0 ) {
16281644 nextReconnectDelay = apnContext .getDataConnection ().getRetryTimer ();
16291645 apnContext .getDataConnection ().increaseRetryCount ();
1646+ if (DBG ) {
1647+ log ("reconnectAfterFail: increaseRetryCount=" +
1648+ apnContext .getDataConnection ().getRetryCount () +
1649+ " nextReconnectDelay=" + nextReconnectDelay );
1650+ }
16301651 }
16311652 startAlarmForReconnect (nextReconnectDelay , apnContext );
16321653
@@ -1643,16 +1664,11 @@ private void reconnectAfterFail(FailCause lastFailCauseCode,
16431664
16441665 private void startAlarmForReconnect (int delay , ApnContext apnContext ) {
16451666
1646- if (DBG ) {
1647- log ("Schedule alarm for reconnect: activate failed. Scheduling next attempt for "
1648- + (delay / 1000 ) + "s" );
1649- }
1650-
16511667 DataConnectionAc dcac = apnContext .getDataConnectionAc ();
16521668
16531669 if ((dcac == null ) || (dcac .dataConnection == null )) {
16541670 // should not happen, but just in case.
1655- loge ("null dcac or dc." );
1671+ loge ("startAlarmForReconnect: null dcac or dc." );
16561672 return ;
16571673 }
16581674
@@ -1661,12 +1677,29 @@ private void startAlarmForReconnect(int delay, ApnContext apnContext) {
16611677
16621678 Intent intent = new Intent (INTENT_RECONNECT_ALARM + '.' +
16631679 dcac .dataConnection .getDataConnectionId ());
1664- intent .putExtra (INTENT_RECONNECT_ALARM_EXTRA_REASON , apnContext .getReason ());
1665- intent .putExtra (INTENT_RECONNECT_ALARM_EXTRA_TYPE ,
1666- dcac .dataConnection .getDataConnectionId ());
1680+ String reason = apnContext .getReason ();
1681+ intent .putExtra (INTENT_RECONNECT_ALARM_EXTRA_REASON , reason );
1682+ int connectionId = dcac .dataConnection .getDataConnectionId ();
1683+ intent .putExtra (INTENT_RECONNECT_ALARM_EXTRA_TYPE , connectionId );
1684+
1685+ // TODO: Until a real fix is created, which probably entails pushing
1686+ // retires into the DC itself, this fix gets the retry count and
1687+ // puts it in the reconnect alarm. When the reconnect alarm fires
1688+ // onActionIntentReconnectAlarm is called which will use the value saved
1689+ // here and save it in the ApnContext and send the EVENT_CONNECT message
1690+ // which invokes setupData. Then setupData will use the value in the ApnContext
1691+ // and to tell the DC to set the retry count in the retry manager.
1692+ int retryCount = dcac .dataConnection .getRetryCount ();
1693+ intent .putExtra (INTENT_RECONNECT_ALARM_EXTRA_RETRY_COUNT , retryCount );
1694+
1695+ if (DBG ) {
1696+ log ("startAlarmForReconnect: next attempt in " + (delay / 1000 ) + "s" +
1697+ " reason='" + reason + "' connectionId=" + connectionId +
1698+ " retryCount=" + retryCount );
1699+ }
16671700
16681701 PendingIntent alarmIntent = PendingIntent .getBroadcast (mPhone .getContext (), 0 ,
1669- intent , 0 );
1702+ intent , PendingIntent . FLAG_UPDATE_CURRENT );
16701703 dcac .setReconnectIntentSync (alarmIntent );
16711704 am .set (AlarmManager .ELAPSED_REALTIME_WAKEUP ,
16721705 SystemClock .elapsedRealtime () + delay , alarmIntent );
@@ -1942,9 +1975,7 @@ protected void onRadioOffOrNotAvailable() {
19421975 // Make sure our reconnect delay starts at the initial value
19431976 // next time the radio comes on
19441977
1945- for (DataConnection dc : mDataConnections .values ()) {
1946- dc .resetRetryCount ();
1947- }
1978+ resetAllRetryCounts ();
19481979 mReregisterOnReconnectFailure = false ;
19491980
19501981 if (mPhone .getSimulatedRadioControl () != null ) {
@@ -2287,7 +2318,11 @@ private GsmDataConnection createDataConnection() {
22872318 return conn ;
22882319 }
22892320
2290- private void configureRetry (DataConnection dc , boolean forDefault ) {
2321+ private void configureRetry (DataConnection dc , boolean forDefault , int retryCount ) {
2322+ if (DBG ) {
2323+ log ("configureRetry: forDefault=" + forDefault + " retryCount=" + retryCount +
2324+ " dc=" + dc );
2325+ }
22912326 if (dc == null ) return ;
22922327
22932328 if (!dc .configureRetry (getReryConfig (forDefault ))) {
@@ -2307,6 +2342,7 @@ private void configureRetry(DataConnection dc, boolean forDefault) {
23072342 }
23082343 }
23092344 }
2345+ dc .setRetryCount (retryCount );
23102346 }
23112347
23122348 private void destroyDataConnections () {
0 commit comments