use of android.telephony.data.DataCallResponse in project android_frameworks_opt_telephony by LineageOS.
the class DataConnectionTest method testModemNotSuggestRetry.
@Test
@SmallTest
public void testModemNotSuggestRetry() throws Exception {
DataCallResponse response = new DataCallResponse.Builder().setCause(0).setSuggestedRetryTime(-1).setId(1).setLinkStatus(2).setProtocolType(ApnSetting.PROTOCOL_IP).setInterfaceName(FAKE_IFNAME).setAddresses(Arrays.asList(new LinkAddress(InetAddresses.parseNumericAddress(FAKE_ADDRESS), 0))).setDnsAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_DNS))).setGatewayAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_GATEWAY))).setPcscfAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_PCSCF_ADDRESS))).setMtuV4(1440).setMtuV6(1440).build();
assertEquals(RetryManager.NO_SUGGESTED_RETRY_DELAY, getSuggestedRetryDelay(response));
response = new DataCallResponse.Builder().setCause(0).setSuggestedRetryTime(-5).setId(1).setLinkStatus(2).setProtocolType(ApnSetting.PROTOCOL_IP).setInterfaceName(FAKE_IFNAME).setAddresses(Arrays.asList(new LinkAddress(InetAddresses.parseNumericAddress(FAKE_ADDRESS), 0))).setDnsAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_DNS))).setGatewayAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_GATEWAY))).setPcscfAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_PCSCF_ADDRESS))).setMtuV4(1440).setMtuV6(1440).build();
assertEquals(RetryManager.NO_SUGGESTED_RETRY_DELAY, getSuggestedRetryDelay(response));
response = new DataCallResponse.Builder().setCause(0).setSuggestedRetryTime(Integer.MIN_VALUE).setId(1).setLinkStatus(2).setProtocolType(ApnSetting.PROTOCOL_IP).setInterfaceName(FAKE_IFNAME).setAddresses(Arrays.asList(new LinkAddress(InetAddresses.parseNumericAddress(FAKE_ADDRESS), 0))).setDnsAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_DNS))).setGatewayAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_GATEWAY))).setPcscfAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_PCSCF_ADDRESS))).setMtuV4(1440).setMtuV6(1440).build();
assertEquals(RetryManager.NO_SUGGESTED_RETRY_DELAY, getSuggestedRetryDelay(response));
}
use of android.telephony.data.DataCallResponse in project android_frameworks_opt_telephony by LineageOS.
the class DataConnectionTest method testSetLinkPropertiesEmptyDns.
@Test
@SmallTest
public void testSetLinkPropertiesEmptyDns() throws Exception {
// Empty dns entry.
DataCallResponse response = new DataCallResponse.Builder().setCause(0).setSuggestedRetryTime(-1).setId(1).setLinkStatus(2).setProtocolType(ApnSetting.PROTOCOL_IP).setInterfaceName(FAKE_IFNAME).setAddresses(Arrays.asList(new LinkAddress(InetAddresses.parseNumericAddress(FAKE_ADDRESS), 0))).setGatewayAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_GATEWAY))).setPcscfAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_PCSCF_ADDRESS))).setMtuV4(1440).setMtuV6(1440).build();
// Make sure no exception was thrown
LinkProperties linkProperties = new LinkProperties();
assertEquals(SetupResult.SUCCESS, setLinkProperties(response, linkProperties));
}
use of android.telephony.data.DataCallResponse in project android_frameworks_opt_telephony by LineageOS.
the class DataConnectionTest method testModemSuggestNoRetry.
@Test
@SmallTest
public void testModemSuggestNoRetry() throws Exception {
DataCallResponse response = new DataCallResponse.Builder().setCause(0).setSuggestedRetryTime(Integer.MAX_VALUE).setId(1).setLinkStatus(2).setProtocolType(ApnSetting.PROTOCOL_IP).setInterfaceName(FAKE_IFNAME).setAddresses(Arrays.asList(new LinkAddress(InetAddresses.parseNumericAddress(FAKE_ADDRESS), 0))).setDnsAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_DNS))).setGatewayAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_GATEWAY))).setPcscfAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_PCSCF_ADDRESS))).setMtuV4(1440).setMtuV6(1440).build();
assertEquals(RetryManager.NO_RETRY, getSuggestedRetryDelay(response));
}
use of android.telephony.data.DataCallResponse in project android_frameworks_opt_telephony by LineageOS.
the class DataConnectionTest method testSetLinkProperties.
@Test
@SmallTest
public void testSetLinkProperties() throws Exception {
DataCallResponse response = new DataCallResponse.Builder().setCause(0).setSuggestedRetryTime(-1).setId(1).setLinkStatus(2).setProtocolType(ApnSetting.PROTOCOL_IP).setInterfaceName(FAKE_IFNAME).setAddresses(Arrays.asList(new LinkAddress(InetAddresses.parseNumericAddress(FAKE_ADDRESS), 0))).setDnsAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_DNS))).setGatewayAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_GATEWAY))).setPcscfAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_PCSCF_ADDRESS))).setMtuV4(1440).setMtuV6(1440).build();
LinkProperties linkProperties = new LinkProperties();
assertEquals(SetupResult.SUCCESS, setLinkProperties(response, linkProperties));
logd(linkProperties.toString());
assertEquals(response.getInterfaceName(), linkProperties.getInterfaceName());
assertEquals(response.getAddresses().size(), linkProperties.getAddresses().size());
for (int i = 0; i < response.getAddresses().size(); ++i) {
assertEquals(response.getAddresses().get(i).getAddress(), InetAddresses.parseNumericAddress(linkProperties.getLinkAddresses().get(i).getAddress().getHostAddress()));
}
assertEquals(response.getDnsAddresses().size(), linkProperties.getDnsServers().size());
for (int i = 0; i < response.getDnsAddresses().size(); ++i) {
assertEquals("i = " + i, response.getDnsAddresses().get(i), InetAddresses.parseNumericAddress(linkProperties.getDnsServers().get(i).getHostAddress()));
}
assertEquals(response.getGatewayAddresses().size(), linkProperties.getRoutes().size());
for (int i = 0; i < response.getGatewayAddresses().size(); ++i) {
assertEquals("i = " + i, response.getGatewayAddresses().get(i), InetAddresses.parseNumericAddress(linkProperties.getRoutes().get(i).getGateway().getHostAddress()));
}
assertEquals(response.getPcscfAddresses().size(), linkProperties.getPcscfServers().size());
for (int i = 0; i < response.getPcscfAddresses().size(); ++i) {
assertEquals("i = " + i, response.getPcscfAddresses().get(i), InetAddresses.parseNumericAddress(linkProperties.getPcscfServers().get(i).getHostAddress()));
}
assertEquals(response.getMtu(), linkProperties.getMtu());
}
use of android.telephony.data.DataCallResponse in project android_frameworks_opt_telephony by LineageOS.
the class DataConnectionTest method testSetLinkPropertiesEmptyAddress.
@Test
@SmallTest
public void testSetLinkPropertiesEmptyAddress() throws Exception {
// 224.224.224.224 is an invalid address.
DataCallResponse response = new DataCallResponse.Builder().setCause(0).setSuggestedRetryTime(-1).setId(1).setLinkStatus(2).setProtocolType(ApnSetting.PROTOCOL_IP).setInterfaceName(FAKE_IFNAME).setDnsAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_DNS))).setGatewayAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_GATEWAY))).setPcscfAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_PCSCF_ADDRESS))).setMtuV4(1440).setMtuV6(1440).build();
LinkProperties linkProperties = new LinkProperties();
assertEquals(SetupResult.ERROR_INVALID_ARG, setLinkProperties(response, linkProperties));
}
Aggregations