Search in sources :

Example 1 with ApnSetting

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

the class DcTrackerTest method testFetchDunApnWithPreferredApnSet.

// Test for fetchDunApns() with apn set id
@Test
@SmallTest
public void testFetchDunApnWithPreferredApnSet() {
    sendCarrierConfigChanged("testFetchDunApnWithPreferredApnSet: ");
    // apnSetId=1
    String dunApnString1 = "[ApnSettingV5]HOT mobile PC,pc.hotm,,,,,,,,,440,10,,DUN,,,true," + "0,,,,,,,,,,1";
    // apnSetId=0
    String dunApnString2 = "[ApnSettingV5]HOT mobile PC,pc.coldm,,,,,,,,,440,10,,DUN,,,true," + "0,,,,,,,,,,2";
    ApnSetting dunApnExpected = ApnSetting.fromString(dunApnString1);
    ContentResolver cr = mContext.getContentResolver();
    Settings.Global.putString(cr, Settings.Global.TETHER_DUN_APN, dunApnString1 + ";" + dunApnString2);
    // set that we prefer apn set 1
    ContentValues values = new ContentValues();
    values.put(Telephony.Carriers.APN_SET_ID, 1);
    cr.update(PREFERAPN_URI, values, null, null);
    // return APN from Setting with apnSetId=1
    ArrayList<ApnSetting> dunApns = mDct.fetchDunApns();
    assertEquals(1, dunApns.size());
    assertEquals(1, dunApns.get(0).getApnSetId());
    assertTrue(dunApnExpected.equals(dunApns.get(0)));
    // set that we prefer apn set 2
    values = new ContentValues();
    values.put(Telephony.Carriers.APN_SET_ID, 2);
    cr.update(PREFERAPN_URI, values, null, null);
    // return APN from Setting with apnSetId=2
    dunApns = mDct.fetchDunApns();
    assertEquals(1, dunApns.size());
    assertEquals(2, dunApns.get(0).getApnSetId());
    dunApnExpected = ApnSetting.fromString(dunApnString2);
    assertTrue(dunApnExpected.equals(dunApns.get(0)));
}
Also used : ContentValues(android.content.ContentValues) Matchers.anyString(org.mockito.Matchers.anyString) ApnSetting(android.telephony.data.ApnSetting) ApnSettingTest.createApnSetting(com.android.internal.telephony.dataconnection.ApnSettingTest.createApnSetting) ContentResolver(android.content.ContentResolver) MockContentResolver(android.test.mock.MockContentResolver) FlakyTest(androidx.test.filters.FlakyTest) TelephonyTest(com.android.internal.telephony.TelephonyTest) MediumTest(android.test.suitebuilder.annotation.MediumTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 2 with ApnSetting

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

the class RetryManagerTest method testRetryManagerTwoMmsApnsTwoRetries.

/**
 * Test the basic retry scenario where two mms APNs with two retries configured.
 */
@Test
@SmallTest
public void testRetryManagerTwoMmsApnsTwoRetries() throws Exception {
    mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_DATA_CALL_RETRY_CONFIG_STRINGS, new String[] { "mms:      3000,6000" });
    ArrayList<ApnSetting> waitingApns = new ArrayList<ApnSetting>();
    waitingApns.add(ApnSetting.makeApnSetting(mApn1));
    waitingApns.add(ApnSetting.makeApnSetting(mApn2));
    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(3000, 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(6000, 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 3 with ApnSetting

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

the class RetryManagerTest method testRetryManagerFailFast.

/**
 * Test the fail fast scenario.
 */
@Test
@SmallTest
public void testRetryManagerFailFast() throws Exception {
    mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_DATA_CALL_RETRY_CONFIG_STRINGS, new String[] { "default:1000,5000" });
    mBundle.putLong(CarrierConfigManager.KEY_CARRIER_DATA_CALL_APN_DELAY_FASTER_LONG, 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(true);
    assertEquals(2000, delay);
    nextApn = rm.getNextApnSetting();
    assertTrue(nextApn.equals(mApn2));
    delay = rm.getDelayForNextApn(true);
    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(true);
    assertEquals(2000, delay);
    nextApn = rm.getNextApnSetting();
    assertTrue(nextApn.equals(mApn1));
    delay = rm.getDelayForNextApn(true);
    assertEquals(2000, delay);
    nextApn = rm.getNextApnSetting();
    assertTrue(nextApn.equals(mApn2));
    delay = rm.getDelayForNextApn(true);
    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 4 with ApnSetting

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

the class RetryManagerTest method testRetryManagerTwoApnsOneRetry.

/**
 * Test the basic retry scenario where two waiting APNs with one retry configured.
 */
@Test
@SmallTest
public void testRetryManagerTwoApnsOneRetry() throws Exception {
    mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_DATA_CALL_RETRY_CONFIG_STRINGS, new String[] { "others: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(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 5 with ApnSetting

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

the class ApnSettingTest method testEqualsRoamingProtocol.

@Test
@SmallTest
public void testEqualsRoamingProtocol() throws Exception {
    ApnSetting apn1 = ApnSetting.makeApnSetting(1234, "310260", "", "ims", null, -1, null, null, -1, "", "", -1, ApnSetting.TYPE_IMS, ApnSetting.PROTOCOL_IPV6, -1, true, ServiceState.convertBearerBitmaskToNetworkTypeBitmask(131071), 0, false, 0, 0, 0, 1440, -1, "");
    ApnSetting apn2 = ApnSetting.makeApnSetting(1235, "310260", "", "ims", null, -1, null, null, -1, "", "", -1, ApnSetting.TYPE_IMS, ApnSetting.PROTOCOL_IPV6, ApnSetting.PROTOCOL_IPV6, true, ServiceState.convertBearerBitmaskToNetworkTypeBitmask(131072), 0, false, 0, 0, 0, 1440, -1, "");
    assertTrue(apn1.equals(apn2, false));
    assertFalse(apn1.equals(apn2, true));
}
Also used : 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