use of android.telephony.data.ApnSetting in project android_frameworks_opt_telephony by LineageOS.
the class RetryManagerTest method testRetryManagerResetBeforeModemSuggestedRetry.
/**
* Test the scenario where reset happens before modem suggests retry.
*/
@Test
@SmallTest
public void testRetryManagerResetBeforeModemSuggestedRetry() throws Exception {
mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_DATA_CALL_RETRY_CONFIG_STRINGS, new String[] { "others:1000,4000,7000,9000" });
ArrayList<ApnSetting> waitingApns = new ArrayList<ApnSetting>();
ApnSetting myApn1 = ApnSetting.makeApnSetting(mApn1);
ApnSetting myApn2 = ApnSetting.makeApnSetting(mApn2);
waitingApns.add(myApn1);
waitingApns.add(myApn2);
RetryManager rm = new RetryManager(mPhone, "mms");
rm.setWaitingApns(waitingApns);
rm.setModemSuggestedDelay(10);
ApnSetting nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn1));
long delay = rm.getDelayForNextApn(false);
assertEquals(20000, delay);
}
use of android.telephony.data.ApnSetting in project android_frameworks_opt_telephony by LineageOS.
the class RetryManagerTest method testRetryManagerExplicitMaxRetry.
/**
* Test the explicit max retry scenario.
*/
@Test
@SmallTest
public void testRetryManagerExplicitMaxRetry() throws Exception {
mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_DATA_CALL_RETRY_CONFIG_STRINGS, new String[] { "hipri: max_retries=4,1000,2000" });
ArrayList<ApnSetting> waitingApns = new ArrayList<ApnSetting>();
waitingApns.add(ApnSetting.makeApnSetting(mApn1));
waitingApns.add(ApnSetting.makeApnSetting(mApn2));
RetryManager rm = new RetryManager(mPhone, "hipri");
rm.setWaitingApns(waitingApns);
ApnSetting nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn1));
long delay = rm.getDelayForNextApn(false);
assertEquals(20000, delay);
nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn2));
delay = rm.getDelayForNextApn(false);
assertEquals(1000, delay);
nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn1));
delay = rm.getDelayForNextApn(false);
assertEquals(20000, delay);
nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn2));
delay = rm.getDelayForNextApn(false);
assertEquals(2000, delay);
nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn1));
delay = rm.getDelayForNextApn(false);
assertEquals(20000, delay);
nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn2));
delay = rm.getDelayForNextApn(false);
assertEquals(2000, delay);
nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn1));
delay = rm.getDelayForNextApn(false);
assertEquals(20000, delay);
nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn2));
delay = rm.getDelayForNextApn(false);
assertEquals(2000, delay);
nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn1));
delay = rm.getDelayForNextApn(false);
assertEquals(20000, delay);
nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn2));
delay = rm.getDelayForNextApn(false);
assertEquals(RetryManager.NO_RETRY, delay);
}
use of android.telephony.data.ApnSetting in project android_frameworks_opt_telephony by LineageOS.
the class RetryManagerTest method testRetryManagerModemSuggestedRetryTooManyTimes.
/**
* Test the scenario where modem suggests the same retry for too many times
*/
@Test
@SmallTest
public void testRetryManagerModemSuggestedRetryTooManyTimes() throws Exception {
mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_DATA_CALL_RETRY_CONFIG_STRINGS, new String[] { "mms:2000,3000", "default:1000,4000,7000,9000" });
ArrayList<ApnSetting> waitingApns = new ArrayList<ApnSetting>();
ApnSetting myApn1 = ApnSetting.makeApnSetting(mApn1);
ApnSetting myApn2 = ApnSetting.makeApnSetting(mApn2);
waitingApns.add(myApn1);
waitingApns.add(myApn2);
RetryManager rm = new RetryManager(mPhone, "default");
rm.setWaitingApns(waitingApns);
ApnSetting nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn1));
long delay = rm.getDelayForNextApn(false);
assertEquals(20000, delay);
nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn2));
delay = rm.getDelayForNextApn(false);
assertEquals(1000, delay);
nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn1));
rm.setModemSuggestedDelay(2500);
delay = rm.getDelayForNextApn(false);
assertEquals(2500, delay);
nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn1));
rm.setModemSuggestedDelay(2500);
delay = rm.getDelayForNextApn(false);
assertEquals(2500, delay);
nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn1));
rm.setModemSuggestedDelay(2500);
delay = rm.getDelayForNextApn(false);
assertEquals(2500, delay);
nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn1));
rm.setModemSuggestedDelay(2500);
delay = rm.getDelayForNextApn(false);
assertEquals(20000, delay);
nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn2));
rm.setModemSuggestedDelay(RetryManager.NO_SUGGESTED_RETRY_DELAY);
delay = rm.getDelayForNextApn(false);
assertEquals(4000, delay);
}
use of android.telephony.data.ApnSetting in project android_frameworks_opt_telephony by LineageOS.
the class RetryManagerTest method testRetryManagerApnPermanentFailedAllAndThenReset.
/**
* Test the permanent fail scenario with two APN all failed and then reset
*/
@Test
@SmallTest
public void testRetryManagerApnPermanentFailedAllAndThenReset() throws Exception {
mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_DATA_CALL_RETRY_CONFIG_STRINGS, new String[] { "dun:1000,4000,7000,9000" });
ArrayList<ApnSetting> waitingApns = new ArrayList<ApnSetting>();
ApnSetting myApn1 = ApnSetting.makeApnSetting(mApn1);
ApnSetting myApn2 = ApnSetting.makeApnSetting(mApn2);
waitingApns.add(myApn1);
waitingApns.add(myApn2);
RetryManager rm = new RetryManager(mPhone, "dun");
rm.setWaitingApns(waitingApns);
ApnSetting nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn1));
long delay = rm.getDelayForNextApn(false);
assertEquals(20000, delay);
nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn2));
delay = rm.getDelayForNextApn(false);
assertEquals(1000, delay);
nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn1));
delay = rm.getDelayForNextApn(false);
assertEquals(20000, delay);
rm.markApnPermanentFailed(myApn1);
nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn2));
delay = rm.getDelayForNextApn(false);
assertEquals(4000, delay);
nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn2));
delay = rm.getDelayForNextApn(false);
assertEquals(7000, delay);
rm.markApnPermanentFailed(myApn2);
nextApn = rm.getNextApnSetting();
assertTrue(nextApn == null);
nextApn = rm.getNextApnSetting();
assertTrue(nextApn == null);
// reset the retry manager
ApnSetting myApn3 = ApnSetting.makeApnSetting(mApn3);
waitingApns.clear();
waitingApns.add(myApn3);
mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_DATA_CALL_RETRY_CONFIG_STRINGS, new String[] { "dun:3000,8000" });
rm.setWaitingApns(waitingApns);
nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn3));
delay = rm.getDelayForNextApn(false);
assertEquals(3000, delay);
nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn3));
delay = rm.getDelayForNextApn(false);
assertEquals(8000, delay);
nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn3));
delay = rm.getDelayForNextApn(false);
assertEquals(RetryManager.NO_RETRY, delay);
}
use of android.telephony.data.ApnSetting in project android_frameworks_opt_telephony by LineageOS.
the class RetryManagerTest method testRetryManagerModemSuggestedRetryOnce.
/**
* Test the scenario where modem suggests retry the current APN once
*/
@Test
@SmallTest
public void testRetryManagerModemSuggestedRetryOnce() throws Exception {
mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_DATA_CALL_RETRY_CONFIG_STRINGS, new String[] { "others:1000,4000,7000,9000" });
ArrayList<ApnSetting> waitingApns = new ArrayList<ApnSetting>();
ApnSetting myApn1 = ApnSetting.makeApnSetting(mApn1);
ApnSetting myApn2 = ApnSetting.makeApnSetting(mApn2);
waitingApns.add(myApn1);
waitingApns.add(myApn2);
RetryManager rm = new RetryManager(mPhone, "mms");
rm.setWaitingApns(waitingApns);
ApnSetting nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn1));
long delay = rm.getDelayForNextApn(false);
assertEquals(20000, delay);
nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn2));
delay = rm.getDelayForNextApn(false);
assertEquals(1000, delay);
nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn1));
// Modem suggests retrying the current APN
rm.setModemSuggestedDelay(2500);
delay = rm.getDelayForNextApn(false);
assertEquals(2500, delay);
nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn1));
rm.setModemSuggestedDelay(RetryManager.NO_SUGGESTED_RETRY_DELAY);
delay = rm.getDelayForNextApn(false);
assertEquals(20000, delay);
nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn2));
// Modem suggests retrying the current APN
rm.setModemSuggestedDelay(30000);
delay = rm.getDelayForNextApn(false);
assertEquals(30000, delay);
nextApn = rm.getNextApnSetting();
assertTrue(nextApn.equals(mApn2));
rm.setModemSuggestedDelay(RetryManager.NO_SUGGESTED_RETRY_DELAY);
delay = rm.getDelayForNextApn(false);
assertEquals(4000, delay);
}
Aggregations