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)));
}
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);
}
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);
}
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);
}
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));
}
Aggregations