Search in sources :

Example 46 with ApnSetting

use of android.telephony.data.ApnSetting in project android_frameworks_opt_telephony by LineageOS.

the class RetryManagerTest method testRetryManagerModemSuggestedNoRetry.

/**
 * Test the scenario where modem suggests not retrying
 */
@Test
@SmallTest
public void testRetryManagerModemSuggestedNoRetry() throws Exception {
    mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_DATA_CALL_RETRY_CONFIG_STRINGS, new String[] { "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));
    // 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_RETRY);
    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 47 with ApnSetting

use of android.telephony.data.ApnSetting in project android_frameworks_opt_telephony by LineageOS.

the class RetryManagerTest method testRetryManagerRetryForever.

/**
 * Test the retry forever scenario
 */
@Test
@SmallTest
public void testRetryManagerRetryForever() throws Exception {
    mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_DATA_CALL_RETRY_CONFIG_STRINGS, new String[] { "default:max_retries=infinite,1000,2000" });
    ArrayList<ApnSetting> waitingApns = new ArrayList<ApnSetting>();
    waitingApns.add(ApnSetting.makeApnSetting(mApn1));
    waitingApns.add(ApnSetting.makeApnSetting(mApn2));
    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));
    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);
}
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 48 with ApnSetting

use of android.telephony.data.ApnSetting in project android_frameworks_opt_telephony by LineageOS.

the class RetryManagerTest method testRetryManagerApnPermanentFailed.

/**
 * Test the permanent fail scenario with one APN configured.
 */
@Test
@SmallTest
public void testRetryManagerApnPermanentFailed() throws Exception {
    mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_DATA_CALL_RETRY_CONFIG_STRINGS, new String[] { "fota:1000,4000,7000" });
    ArrayList<ApnSetting> waitingApns = new ArrayList<ApnSetting>();
    ApnSetting apn = ApnSetting.makeApnSetting(mApn1);
    waitingApns.add(apn);
    RetryManager rm = new RetryManager(mPhone, "fota");
    rm.setWaitingApns(waitingApns);
    ApnSetting nextApn = rm.getNextApnSetting();
    assertTrue(nextApn.equals(mApn1));
    long delay = rm.getDelayForNextApn(false);
    assertEquals(1000, delay);
    nextApn = rm.getNextApnSetting();
    assertTrue(nextApn.equals(mApn1));
    delay = rm.getDelayForNextApn(false);
    assertEquals(4000, delay);
    rm.markApnPermanentFailed(apn);
    nextApn = rm.getNextApnSetting();
    assertTrue(nextApn == null);
}
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 49 with ApnSetting

use of android.telephony.data.ApnSetting in project android_frameworks_opt_telephony by LineageOS.

the class RetryManagerTest method testRetryManagerApnPermanentFailedWithThreeApns.

/**
 * Test the permanent fail scenario with three APNs configured.
 */
@Test
@SmallTest
public void testRetryManagerApnPermanentFailedWithThreeApns() throws Exception {
    mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_DATA_CALL_RETRY_CONFIG_STRINGS, new String[] { "default:2000:2000,3000:3000", "ims:1000,4000" });
    ArrayList<ApnSetting> waitingApns = new ArrayList<ApnSetting>();
    ApnSetting myApn1 = ApnSetting.makeApnSetting(mApn1);
    ApnSetting myApn2 = ApnSetting.makeApnSetting(mApn2);
    ApnSetting myApn3 = ApnSetting.makeApnSetting(mApn3);
    waitingApns.add(myApn1);
    waitingApns.add(myApn2);
    waitingApns.add(myApn3);
    RetryManager rm = new RetryManager(mPhone, "ims");
    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(20000, delay);
    rm.markApnPermanentFailed(myApn2);
    nextApn = rm.getNextApnSetting();
    assertTrue(nextApn.equals(mApn3));
    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(mApn3));
    delay = rm.getDelayForNextApn(false);
    assertEquals(4000, delay);
    nextApn = rm.getNextApnSetting();
    assertTrue(nextApn.equals(mApn1));
    delay = rm.getDelayForNextApn(false);
    assertEquals(20000, 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 50 with ApnSetting

use of android.telephony.data.ApnSetting in project android_frameworks_opt_telephony by LineageOS.

the class RetryManagerTest method testRetryManagerOneApnNoRetry.

/**
 * Test the basic retry scenario where only one APN and no retry configured.
 */
@Test
@SmallTest
public void testRetryManagerOneApnNoRetry() throws Exception {
    mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_DATA_CALL_RETRY_CONFIG_STRINGS, new String[] { "default:" });
    ArrayList<ApnSetting> waitingApns = new ArrayList<ApnSetting>();
    waitingApns.add(ApnSetting.makeApnSetting(mApn1));
    RetryManager rm = new RetryManager(mPhone, "default");
    rm.setWaitingApns(waitingApns);
    ApnSetting nextApn = rm.getNextApnSetting();
    assertTrue(nextApn.equals(mApn1));
    long 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)

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