use of android.net.LinkProperties in project android_frameworks_base by DirtyUnicorns.
the class NetworkStatsServiceTest method expectNetworkState.
private void expectNetworkState(NetworkState... state) throws Exception {
expect(mConnManager.getAllNetworkState()).andReturn(state).atLeastOnce();
final LinkProperties linkProp = state.length > 0 ? state[0].linkProperties : null;
expect(mConnManager.getActiveLinkProperties()).andReturn(linkProp).atLeastOnce();
}
use of android.net.LinkProperties in project android_frameworks_base by DirtyUnicorns.
the class NetworkStatsServiceTest method buildMobile4gState.
private static NetworkState buildMobile4gState(String iface) {
final NetworkInfo info = new NetworkInfo(TYPE_WIMAX, 0, null, null);
info.setDetailedState(DetailedState.CONNECTED, null, null);
final LinkProperties prop = new LinkProperties();
prop.setInterfaceName(iface);
return new NetworkState(info, prop, null, null, null, null);
}
use of android.net.LinkProperties in project android_frameworks_base by DirtyUnicorns.
the class LinkPropertiesTest method testIsProvisioned.
@SmallTest
public void testIsProvisioned() {
LinkProperties lp4 = new LinkProperties();
assertFalse("v4only:empty", lp4.isProvisioned());
lp4.addLinkAddress(LINKADDRV4);
assertFalse("v4only:addr-only", lp4.isProvisioned());
lp4.addDnsServer(DNS1);
assertFalse("v4only:addr+dns", lp4.isProvisioned());
lp4.addRoute(new RouteInfo(GATEWAY1));
assertTrue("v4only:addr+dns+route", lp4.isProvisioned());
assertTrue("v4only:addr+dns+route", lp4.isIPv4Provisioned());
assertFalse("v4only:addr+dns+route", lp4.isIPv6Provisioned());
LinkProperties lp6 = new LinkProperties();
assertFalse("v6only:empty", lp6.isProvisioned());
lp6.addLinkAddress(LINKADDRV6LINKLOCAL);
assertFalse("v6only:fe80-only", lp6.isProvisioned());
lp6.addDnsServer(DNS6);
assertFalse("v6only:fe80+dns", lp6.isProvisioned());
lp6.addRoute(new RouteInfo(GATEWAY61));
assertFalse("v6only:fe80+dns+route", lp6.isProvisioned());
lp6.addLinkAddress(LINKADDRV6);
assertTrue("v6only:fe80+global+dns+route", lp6.isIPv6Provisioned());
assertTrue("v6only:fe80+global+dns+route", lp6.isProvisioned());
lp6.removeLinkAddress(LINKADDRV6LINKLOCAL);
assertFalse("v6only:global+dns+route", lp6.isIPv4Provisioned());
assertTrue("v6only:global+dns+route", lp6.isIPv6Provisioned());
assertTrue("v6only:global+dns+route", lp6.isProvisioned());
LinkProperties lp46 = new LinkProperties();
lp46.addLinkAddress(LINKADDRV4);
lp46.addLinkAddress(LINKADDRV6);
lp46.addDnsServer(DNS1);
lp46.addDnsServer(DNS6);
assertFalse("dualstack:missing-routes", lp46.isProvisioned());
lp46.addRoute(new RouteInfo(GATEWAY1));
assertTrue("dualstack:v4-provisioned", lp46.isIPv4Provisioned());
assertFalse("dualstack:v4-provisioned", lp46.isIPv6Provisioned());
assertTrue("dualstack:v4-provisioned", lp46.isProvisioned());
lp46.addRoute(new RouteInfo(GATEWAY61));
assertTrue("dualstack:both-provisioned", lp46.isIPv4Provisioned());
assertTrue("dualstack:both-provisioned", lp46.isIPv6Provisioned());
assertTrue("dualstack:both-provisioned", lp46.isProvisioned());
// A link with an IPv6 address and default route, but IPv4 DNS server.
LinkProperties mixed = new LinkProperties();
mixed.addLinkAddress(LINKADDRV6);
mixed.addDnsServer(DNS1);
mixed.addRoute(new RouteInfo(GATEWAY61));
assertFalse("mixed:addr6+route6+dns4", mixed.isIPv4Provisioned());
assertFalse("mixed:addr6+route6+dns4", mixed.isIPv6Provisioned());
assertFalse("mixed:addr6+route6+dns4", mixed.isProvisioned());
}
use of android.net.LinkProperties in project android_frameworks_base by DirtyUnicorns.
the class LinkPropertiesTest method testCompareProvisioning.
@SmallTest
public void testCompareProvisioning() {
LinkProperties v4lp = new LinkProperties();
v4lp.addLinkAddress(LINKADDRV4);
v4lp.addRoute(new RouteInfo(GATEWAY1));
v4lp.addDnsServer(DNS1);
assertTrue(v4lp.isProvisioned());
LinkProperties v4r = new LinkProperties(v4lp);
v4r.removeDnsServer(DNS1);
assertFalse(v4r.isProvisioned());
assertEquals(ProvisioningChange.STILL_NOT_PROVISIONED, LinkProperties.compareProvisioning(v4r, v4r));
assertEquals(ProvisioningChange.LOST_PROVISIONING, LinkProperties.compareProvisioning(v4lp, v4r));
assertEquals(ProvisioningChange.GAINED_PROVISIONING, LinkProperties.compareProvisioning(v4r, v4lp));
assertEquals(ProvisioningChange.STILL_PROVISIONED, LinkProperties.compareProvisioning(v4lp, v4lp));
// Check that losing IPv4 provisioning on a dualstack network is
// seen as a total loss of provisioning.
LinkProperties v6lp = new LinkProperties();
v6lp.addLinkAddress(LINKADDRV6);
v6lp.addRoute(new RouteInfo(GATEWAY61));
v6lp.addDnsServer(DNS6);
assertFalse(v6lp.isIPv4Provisioned());
assertTrue(v6lp.isIPv6Provisioned());
assertTrue(v6lp.isProvisioned());
LinkProperties v46lp = new LinkProperties(v6lp);
v46lp.addLinkAddress(LINKADDRV4);
v46lp.addRoute(new RouteInfo(GATEWAY1));
v46lp.addDnsServer(DNS1);
assertTrue(v46lp.isIPv4Provisioned());
assertTrue(v46lp.isIPv6Provisioned());
assertTrue(v46lp.isProvisioned());
assertEquals(ProvisioningChange.STILL_PROVISIONED, LinkProperties.compareProvisioning(v4lp, v46lp));
assertEquals(ProvisioningChange.STILL_PROVISIONED, LinkProperties.compareProvisioning(v6lp, v46lp));
assertEquals(ProvisioningChange.LOST_PROVISIONING, LinkProperties.compareProvisioning(v46lp, v6lp));
assertEquals(ProvisioningChange.LOST_PROVISIONING, LinkProperties.compareProvisioning(v46lp, v4lp));
// Check that losing and gaining a secondary router does not change
// the provisioning status.
LinkProperties v6lp2 = new LinkProperties(v6lp);
v6lp2.addRoute(new RouteInfo(GATEWAY62));
assertTrue(v6lp2.isProvisioned());
assertEquals(ProvisioningChange.STILL_PROVISIONED, LinkProperties.compareProvisioning(v6lp2, v6lp));
assertEquals(ProvisioningChange.STILL_PROVISIONED, LinkProperties.compareProvisioning(v6lp, v6lp2));
}
use of android.net.LinkProperties in project android_frameworks_base by DirtyUnicorns.
the class LinkPropertiesTest method testEqualsDuplicated.
@SmallTest
public void testEqualsDuplicated() {
try {
LinkProperties source = new LinkProperties();
// set 3 link addresses, eg, [A, A, B]
source.addLinkAddress(LINKADDRV4);
source.addLinkAddress(LINKADDRV4);
source.addLinkAddress(LINKADDRV6);
LinkProperties target = new LinkProperties();
// set 3 link addresses, eg, [A, B, B]
target.addLinkAddress(LINKADDRV4);
target.addLinkAddress(LINKADDRV6);
target.addLinkAddress(LINKADDRV6);
assertLinkPropertiesEqual(source, target);
} catch (Exception e) {
fail();
}
}
Aggregations