Loading src/java/com/android/internal/telephony/RetryManager.java +5 −0 Original line number Diff line number Diff line Loading @@ -491,6 +491,11 @@ public class RetryManager { return NO_RETRY; } if (mModemSuggestedDelay == NO_RETRY) { log("Modem suggested not retrying."); return NO_RETRY; } if (mModemSuggestedDelay != NO_SUGGESTED_RETRY_DELAY && mSameApnRetryCount < MAX_SAME_APN_RETRY) { // If the modem explicitly suggests a retry delay, we should use it, even in fail fast Loading src/java/com/android/internal/telephony/dataconnection/DataConnection.java +13 −1 Original line number Diff line number Diff line Loading @@ -1823,10 +1823,22 @@ public class DataConnection extends StateMachine { DataCallResponse response = (DataCallResponse) ar.result; if (response.suggestedRetryTime == RILConstants.MAX_INT) { /** According to ril.h * The value < 0 means no value is suggested * The value 0 means retry should be done ASAP. * The value of Integer.MAX_VALUE(0x7fffffff) means no retry. */ // The value < 0 means no value is suggested if (response.suggestedRetryTime < 0) { if (DBG) log("No suggested retry delay."); return RetryManager.NO_SUGGESTED_RETRY_DELAY; } // The value of Integer.MAX_VALUE(0x7fffffff) means no retry. else if (response.suggestedRetryTime == Integer.MAX_VALUE) { if (DBG) log("Modem suggested not retrying."); return RetryManager.NO_RETRY; } // We need to cast it to long because the value returned from RIL is a 32-bit integer, // but the time values used in AlarmManager are all 64-bit long. Loading src/java/com/android/internal/telephony/dataconnection/DcFailBringUp.java +1 −3 Original line number Diff line number Diff line Loading @@ -19,8 +19,6 @@ package com.android.internal.telephony.dataconnection; import android.content.Intent; import android.telephony.Rlog; import com.android.internal.telephony.RILConstants; /** * A package visible class for supporting testing failing bringUp commands. This * saves the parameters from a action_fail_bringup intent. See Loading @@ -46,7 +44,7 @@ public class DcFailBringUp { // suggestedRetryTime with its --ei option name and default value static final String SUGGESTED_RETRY_TIME = "suggested_retry_time"; static final int DEFAULT_SUGGESTED_RETRY_TIME = RILConstants.MAX_INT; static final int DEFAULT_SUGGESTED_RETRY_TIME = -1; int mSuggestedRetryTime; // Get the Extra Intent parameters Loading src/java/com/android/internal/telephony/dataconnection/DcTracker.java +3 −1 Original line number Diff line number Diff line Loading @@ -2241,6 +2241,8 @@ public class DcTracker extends Handler { // Use the exact timer instead of the inexact one to provide better user experience. // In some extreme cases, we saw the retry was delayed for few minutes. // Note that if the stated trigger time is in the past, the alarm will be triggered // immediately. mAlarmManager.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + delay, alarmIntent); } Loading Loading @@ -2900,7 +2902,7 @@ public class DcTracker extends Handler { long delay = apnContext.getDelayForNextApn(mFailFast); // Check if we need to retry or not. if (delay > 0) { if (delay >= 0) { if (DBG) log("onDataSetupCompleteError: Try next APN. delay = " + delay); apnContext.setState(DctConstants.State.SCANNING); // Wait a bit before trying the next APN, so that Loading tests/telephonytests/src/com/android/internal/telephony/dataconnection/DataConnectionTest.java +50 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.internal.telephony.dataconnection; import android.os.AsyncResult; import android.os.Handler; import android.os.HandlerThread; import android.os.Message; Loading @@ -24,6 +25,7 @@ import android.test.suitebuilder.annotation.SmallTest; import com.android.internal.telephony.PhoneConstants; import com.android.internal.telephony.RILConstants; import com.android.internal.telephony.RetryManager; import com.android.internal.telephony.TelephonyTest; import com.android.internal.telephony.dataconnection.DataConnection.ConnectionParams; import com.android.internal.telephony.dataconnection.DataConnection.DisconnectParams; Loading Loading @@ -158,6 +160,14 @@ public class DataConnectionTest extends TelephonyTest { return (IState) method.invoke(mDc); } private long getSuggestedRetryDelay(AsyncResult ar) throws Exception { Class[] cArgs = new Class[1]; cArgs[0] = AsyncResult.class; Method method = DataConnection.class.getDeclaredMethod("getSuggestedRetryDelay", cArgs); method.setAccessible(true); return (long) method.invoke(mDc, ar); } @Test @SmallTest public void testSanity() throws Exception { Loading Loading @@ -197,4 +207,43 @@ public class DataConnectionTest extends TelephonyTest { assertEquals("DcInactiveState", getCurrentState().getName()); } @Test @SmallTest public void testModemSuggestRetry() throws Exception { DataCallResponse response = new DataCallResponse(); response.suggestedRetryTime = 0; AsyncResult ar = new AsyncResult(null, response, null); assertEquals(response.suggestedRetryTime, getSuggestedRetryDelay(ar)); response.suggestedRetryTime = 1000; assertEquals(response.suggestedRetryTime, getSuggestedRetryDelay(ar)); response.suggestedRetryTime = 9999; assertEquals(response.suggestedRetryTime, getSuggestedRetryDelay(ar)); } @Test @SmallTest public void testModemNotSuggestRetry() throws Exception { DataCallResponse response = new DataCallResponse(); response.suggestedRetryTime = -1; AsyncResult ar = new AsyncResult(null, response, null); assertEquals(RetryManager.NO_SUGGESTED_RETRY_DELAY, getSuggestedRetryDelay(ar)); response.suggestedRetryTime = -5; assertEquals(RetryManager.NO_SUGGESTED_RETRY_DELAY, getSuggestedRetryDelay(ar)); response.suggestedRetryTime = Integer.MIN_VALUE; assertEquals(RetryManager.NO_SUGGESTED_RETRY_DELAY, getSuggestedRetryDelay(ar)); } @Test @SmallTest public void testModemSuggestNoRetry() throws Exception { DataCallResponse response = new DataCallResponse(); response.suggestedRetryTime = Integer.MAX_VALUE; AsyncResult ar = new AsyncResult(null, response, null); assertEquals(RetryManager.NO_RETRY, getSuggestedRetryDelay(ar)); } } No newline at end of file Loading
src/java/com/android/internal/telephony/RetryManager.java +5 −0 Original line number Diff line number Diff line Loading @@ -491,6 +491,11 @@ public class RetryManager { return NO_RETRY; } if (mModemSuggestedDelay == NO_RETRY) { log("Modem suggested not retrying."); return NO_RETRY; } if (mModemSuggestedDelay != NO_SUGGESTED_RETRY_DELAY && mSameApnRetryCount < MAX_SAME_APN_RETRY) { // If the modem explicitly suggests a retry delay, we should use it, even in fail fast Loading
src/java/com/android/internal/telephony/dataconnection/DataConnection.java +13 −1 Original line number Diff line number Diff line Loading @@ -1823,10 +1823,22 @@ public class DataConnection extends StateMachine { DataCallResponse response = (DataCallResponse) ar.result; if (response.suggestedRetryTime == RILConstants.MAX_INT) { /** According to ril.h * The value < 0 means no value is suggested * The value 0 means retry should be done ASAP. * The value of Integer.MAX_VALUE(0x7fffffff) means no retry. */ // The value < 0 means no value is suggested if (response.suggestedRetryTime < 0) { if (DBG) log("No suggested retry delay."); return RetryManager.NO_SUGGESTED_RETRY_DELAY; } // The value of Integer.MAX_VALUE(0x7fffffff) means no retry. else if (response.suggestedRetryTime == Integer.MAX_VALUE) { if (DBG) log("Modem suggested not retrying."); return RetryManager.NO_RETRY; } // We need to cast it to long because the value returned from RIL is a 32-bit integer, // but the time values used in AlarmManager are all 64-bit long. Loading
src/java/com/android/internal/telephony/dataconnection/DcFailBringUp.java +1 −3 Original line number Diff line number Diff line Loading @@ -19,8 +19,6 @@ package com.android.internal.telephony.dataconnection; import android.content.Intent; import android.telephony.Rlog; import com.android.internal.telephony.RILConstants; /** * A package visible class for supporting testing failing bringUp commands. This * saves the parameters from a action_fail_bringup intent. See Loading @@ -46,7 +44,7 @@ public class DcFailBringUp { // suggestedRetryTime with its --ei option name and default value static final String SUGGESTED_RETRY_TIME = "suggested_retry_time"; static final int DEFAULT_SUGGESTED_RETRY_TIME = RILConstants.MAX_INT; static final int DEFAULT_SUGGESTED_RETRY_TIME = -1; int mSuggestedRetryTime; // Get the Extra Intent parameters Loading
src/java/com/android/internal/telephony/dataconnection/DcTracker.java +3 −1 Original line number Diff line number Diff line Loading @@ -2241,6 +2241,8 @@ public class DcTracker extends Handler { // Use the exact timer instead of the inexact one to provide better user experience. // In some extreme cases, we saw the retry was delayed for few minutes. // Note that if the stated trigger time is in the past, the alarm will be triggered // immediately. mAlarmManager.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + delay, alarmIntent); } Loading Loading @@ -2900,7 +2902,7 @@ public class DcTracker extends Handler { long delay = apnContext.getDelayForNextApn(mFailFast); // Check if we need to retry or not. if (delay > 0) { if (delay >= 0) { if (DBG) log("onDataSetupCompleteError: Try next APN. delay = " + delay); apnContext.setState(DctConstants.State.SCANNING); // Wait a bit before trying the next APN, so that Loading
tests/telephonytests/src/com/android/internal/telephony/dataconnection/DataConnectionTest.java +50 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.internal.telephony.dataconnection; import android.os.AsyncResult; import android.os.Handler; import android.os.HandlerThread; import android.os.Message; Loading @@ -24,6 +25,7 @@ import android.test.suitebuilder.annotation.SmallTest; import com.android.internal.telephony.PhoneConstants; import com.android.internal.telephony.RILConstants; import com.android.internal.telephony.RetryManager; import com.android.internal.telephony.TelephonyTest; import com.android.internal.telephony.dataconnection.DataConnection.ConnectionParams; import com.android.internal.telephony.dataconnection.DataConnection.DisconnectParams; Loading Loading @@ -158,6 +160,14 @@ public class DataConnectionTest extends TelephonyTest { return (IState) method.invoke(mDc); } private long getSuggestedRetryDelay(AsyncResult ar) throws Exception { Class[] cArgs = new Class[1]; cArgs[0] = AsyncResult.class; Method method = DataConnection.class.getDeclaredMethod("getSuggestedRetryDelay", cArgs); method.setAccessible(true); return (long) method.invoke(mDc, ar); } @Test @SmallTest public void testSanity() throws Exception { Loading Loading @@ -197,4 +207,43 @@ public class DataConnectionTest extends TelephonyTest { assertEquals("DcInactiveState", getCurrentState().getName()); } @Test @SmallTest public void testModemSuggestRetry() throws Exception { DataCallResponse response = new DataCallResponse(); response.suggestedRetryTime = 0; AsyncResult ar = new AsyncResult(null, response, null); assertEquals(response.suggestedRetryTime, getSuggestedRetryDelay(ar)); response.suggestedRetryTime = 1000; assertEquals(response.suggestedRetryTime, getSuggestedRetryDelay(ar)); response.suggestedRetryTime = 9999; assertEquals(response.suggestedRetryTime, getSuggestedRetryDelay(ar)); } @Test @SmallTest public void testModemNotSuggestRetry() throws Exception { DataCallResponse response = new DataCallResponse(); response.suggestedRetryTime = -1; AsyncResult ar = new AsyncResult(null, response, null); assertEquals(RetryManager.NO_SUGGESTED_RETRY_DELAY, getSuggestedRetryDelay(ar)); response.suggestedRetryTime = -5; assertEquals(RetryManager.NO_SUGGESTED_RETRY_DELAY, getSuggestedRetryDelay(ar)); response.suggestedRetryTime = Integer.MIN_VALUE; assertEquals(RetryManager.NO_SUGGESTED_RETRY_DELAY, getSuggestedRetryDelay(ar)); } @Test @SmallTest public void testModemSuggestNoRetry() throws Exception { DataCallResponse response = new DataCallResponse(); response.suggestedRetryTime = Integer.MAX_VALUE; AsyncResult ar = new AsyncResult(null, response, null); assertEquals(RetryManager.NO_RETRY, getSuggestedRetryDelay(ar)); } } No newline at end of file