Search in sources :

Example 11 with DataCallResponse

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));
}
Also used : DataCallResponse(android.telephony.data.DataCallResponse) LinkAddress(android.net.LinkAddress) 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 12 with DataCallResponse

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));
}
Also used : DataCallResponse(android.telephony.data.DataCallResponse) LinkAddress(android.net.LinkAddress) LinkProperties(android.net.LinkProperties) 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 13 with DataCallResponse

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));
}
Also used : DataCallResponse(android.telephony.data.DataCallResponse) LinkAddress(android.net.LinkAddress) 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 14 with DataCallResponse

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());
}
Also used : DataCallResponse(android.telephony.data.DataCallResponse) LinkAddress(android.net.LinkAddress) LinkProperties(android.net.LinkProperties) 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 15 with DataCallResponse

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));
}
Also used : DataCallResponse(android.telephony.data.DataCallResponse) LinkProperties(android.net.LinkProperties) 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)

Aggregations

DataCallResponse (android.telephony.data.DataCallResponse)16 LinkAddress (android.net.LinkAddress)10 SmallTest (android.test.suitebuilder.annotation.SmallTest)10 Test (org.junit.Test)9 TelephonyTest (com.android.internal.telephony.TelephonyTest)8 MediumTest (android.test.suitebuilder.annotation.MediumTest)6 LinkProperties (android.net.LinkProperties)4 AsyncResult (android.os.AsyncResult)2 SetupDataCallResult (android.hardware.radio.V1_0.SetupDataCallResult)1 Message (android.os.Message)1 Parcel (android.os.Parcel)1 DataFailureCause (android.telephony.Annotation.DataFailureCause)1 DataProfile (android.telephony.data.DataProfile)1 FlakyTest (androidx.test.filters.FlakyTest)1 CommandException (com.android.internal.telephony.CommandException)1 SmsResponse (com.android.internal.telephony.SmsResponse)1 TelephonyEvent (com.android.internal.telephony.nano.TelephonyProto.TelephonyEvent)1 RilSetupDataCallResponse (com.android.internal.telephony.nano.TelephonyProto.TelephonyEvent.RilSetupDataCallResponse)1 TelephonyLog (com.android.internal.telephony.nano.TelephonyProto.TelephonyLog)1 ArrayList (java.util.ArrayList)1