Search in sources :

Example 11 with ApnSetting

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);
}
Also used : RetryManager(com.android.internal.telephony.RetryManager) ArrayList(java.util.ArrayList) ApnSetting(android.telephony.data.ApnSetting) SmallTest(android.test.suitebuilder.annotation.SmallTest) TelephonyTest(com.android.internal.telephony.TelephonyTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 12 with ApnSetting

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);
}
Also used : RetryManager(com.android.internal.telephony.RetryManager) ArrayList(java.util.ArrayList) ApnSetting(android.telephony.data.ApnSetting) SmallTest(android.test.suitebuilder.annotation.SmallTest) TelephonyTest(com.android.internal.telephony.TelephonyTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 13 with ApnSetting

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);
}
Also used : RetryManager(com.android.internal.telephony.RetryManager) ArrayList(java.util.ArrayList) ApnSetting(android.telephony.data.ApnSetting) SmallTest(android.test.suitebuilder.annotation.SmallTest) TelephonyTest(com.android.internal.telephony.TelephonyTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 14 with ApnSetting

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);
}
Also used : RetryManager(com.android.internal.telephony.RetryManager) ArrayList(java.util.ArrayList) ApnSetting(android.telephony.data.ApnSetting) SmallTest(android.test.suitebuilder.annotation.SmallTest) TelephonyTest(com.android.internal.telephony.TelephonyTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 15 with ApnSetting

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);
}
Also used : RetryManager(com.android.internal.telephony.RetryManager) ArrayList(java.util.ArrayList) ApnSetting(android.telephony.data.ApnSetting) SmallTest(android.test.suitebuilder.annotation.SmallTest) TelephonyTest(com.android.internal.telephony.TelephonyTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

ApnSetting (android.telephony.data.ApnSetting)50 Test (org.junit.Test)30 SmallTest (android.test.suitebuilder.annotation.SmallTest)28 TelephonyTest (com.android.internal.telephony.TelephonyTest)28 ArrayList (java.util.ArrayList)23 RetryManager (com.android.internal.telephony.RetryManager)19 Cursor (android.database.Cursor)5 FlakyTest (androidx.test.filters.FlakyTest)4 ApnSettingTest.createApnSetting (com.android.internal.telephony.dataconnection.ApnSettingTest.createApnSetting)4 ContentResolver (android.content.ContentResolver)3 Uri (android.net.Uri)3 Message (android.os.Message)3 DataProfile (android.telephony.data.DataProfile)3 MediumTest (android.test.suitebuilder.annotation.MediumTest)3 Matchers.anyString (org.mockito.Matchers.anyString)3 NonNull (android.annotation.NonNull)2 PendingIntent (android.app.PendingIntent)2 ContentValues (android.content.ContentValues)2 Intent (android.content.Intent)2 IntentFilter (android.content.IntentFilter)2