diff options
-rw-r--r-- | telephony/java/com/android/internal/telephony/RetryManager.java | 21 | ||||
-rw-r--r-- | tests/CoreTests/com/android/internal/telephony/TelephonyUtilsTest.java | 23 |
2 files changed, 38 insertions, 6 deletions
diff --git a/telephony/java/com/android/internal/telephony/RetryManager.java b/telephony/java/com/android/internal/telephony/RetryManager.java index 242b2cd..385b191 100644 --- a/telephony/java/com/android/internal/telephony/RetryManager.java +++ b/telephony/java/com/android/internal/telephony/RetryManager.java @@ -41,7 +41,8 @@ import java.util.ArrayList; *</ul> *<p> * max_retries is the number of times that incrementRetryCount - * maybe called before isRetryNeeded will return false. + * maybe called before isRetryNeeded will return false. if value + * is infinite then isRetryNeeded will always return true. * * default_randomizationTime will be used as the randomizationTime * for delay times which have no supplied randomizationTime. If @@ -60,9 +61,13 @@ import java.util.ArrayList; * the 4..10 retries all using 3000 as the delay: * <ul><li><code>"max_retries=10, default_randomization=500, 1000, 2000, 3000"</code></ul> * - * <li>4 retires with a 100ms default randomization value for the first 2 values and - * the other two having specified values of 500ms: + * <li>4 retires with a 100 as the default randomization value for the first 2 values and + * the other two having specified values of 500: * <ul><li><code>"default_randomization=100, 1000, 2000, 4000:500, 5000:500"</code></ul> + * + * <li>Infinite number of retires with the first one at 1000, the second at 2000 all + * others will be at 3000. + * <ul><li><code>"max_retries=infinite,1000,2000,3000</code></ul> * </ul> * * {@hide} @@ -181,9 +186,13 @@ public class RetryManager { if (!value.first) return false; defaultRandomization = value.second; } else if (TextUtils.equals(splitStr[0], "max_retries")) { - value = parseNonNegativeInt(splitStr[0], splitStr[1]); - if (!value.first) return false; - mMaxRetryCount = value.second; + if (TextUtils.equals("infinite",splitStr[1])) { + mRetryForever = true; + } else { + value = parseNonNegativeInt(splitStr[0], splitStr[1]); + if (!value.first) return false; + mMaxRetryCount = value.second; + } } else { Log.e(LOG_TAG, "Unrecognized configuration name value pair: " + strArray[i]); diff --git a/tests/CoreTests/com/android/internal/telephony/TelephonyUtilsTest.java b/tests/CoreTests/com/android/internal/telephony/TelephonyUtilsTest.java index e4cf1e8..bf0c88b 100644 --- a/tests/CoreTests/com/android/internal/telephony/TelephonyUtilsTest.java +++ b/tests/CoreTests/com/android/internal/telephony/TelephonyUtilsTest.java @@ -123,6 +123,29 @@ public class TelephonyUtilsTest extends TestCase { } /** + * Test infinite retires + */ + @SmallTest + public void testRetryManageInfinite() throws Exception { + RetryManager rm = new RetryManager(); + + assertTrue(rm.configure("1000,2000,3000,max_retries=infinite")); + assertTrue(rm.isRetryNeeded()); + assertEquals(1000, rm.getRetryTimer()); + rm.increaseRetryCount(); + assertTrue(rm.isRetryNeeded()); + assertEquals(2000, rm.getRetryTimer()); + rm.increaseRetryCount(); + assertTrue(rm.isRetryNeeded()); + // All others are 3000 and isRetryNeeded is always true + for (int i=0; i < 100; i++) { + assertEquals(3000, rm.getRetryTimer()); + rm.increaseRetryCount(); + assertTrue(rm.isRetryNeeded()); + } + } + + /** * Test string configuration using all options. */ @SmallTest |