Loading src/android/net/dhcp/DhcpServingParams.java +2 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import static com.android.net.module.util.NetworkStackConstants.IPV4_MIN_MTU; import static java.lang.Integer.toUnsignedLong; import android.annotation.SuppressLint; import android.net.IpPrefix; import android.net.LinkAddress; import android.util.ArraySet; Loading Loading @@ -411,6 +412,7 @@ public class DhcpServingParams { /** * Utility method to create an IpPrefix with the address and prefix length of a LinkAddress. */ @SuppressLint("NewApi") @NonNull static IpPrefix makeIpPrefix(@NonNull LinkAddress addr) { return new IpPrefix(addr.getAddress(), addr.getPrefixLength()); Loading tests/unit/src/android/net/dhcp/DhcpLeaseRepositoryTest.java +6 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import static java.util.stream.Collectors.toSet; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SuppressLint; import android.net.IpPrefix; import android.net.MacAddress; import android.net.dhcp.DhcpServer.Clock; Loading Loading @@ -84,6 +85,7 @@ public class DhcpLeaseRepositoryTest { private static final Inet4Address TEST_INETADDR_2 = parseAddr4("192.168.42.249"); private static final String TEST_HOSTNAME_1 = "hostname1"; private static final String TEST_HOSTNAME_2 = "hostname2"; @SuppressLint("NewApi") private static final IpPrefix TEST_IP_PREFIX = new IpPrefix(TEST_SERVER_ADDR, 22); private static final long TEST_TIME = 100L; private static final int TEST_LEASE_TIME_MS = 3_600_000; Loading Loading @@ -149,6 +151,7 @@ public class DhcpLeaseRepositoryTest { } } @SuppressLint("NewApi") @Test public void testAddressExhaustion() throws Exception { // Use a /28 to quickly run out of addresses Loading @@ -169,6 +172,7 @@ public class DhcpLeaseRepositoryTest { verifyNoMoreInteractions(mCallbacks); } @SuppressLint("NewApi") @Test public void testUpdateParams_LeaseCleanup() throws Exception { // Inside /28: Loading Loading @@ -229,6 +233,7 @@ public class DhcpLeaseRepositoryTest { } } @SuppressLint("NewApi") @Test public void testUpdateParams_UsesNewPrefix() throws Exception { final IpPrefix newPrefix = new IpPrefix(parseAddr4("192.168.123.0"), 24); Loading Loading @@ -538,6 +543,7 @@ public class DhcpLeaseRepositoryTest { assertNotEquals(lease.getNetAddr(), newLease.getNetAddr()); } @SuppressLint("NewApi") @Test public void testMarkLeaseDeclined_UsedIfOutOfAddresses() throws Exception { // Use a /28 to quickly run out of addresses Loading tests/unit/src/android/net/ip/IpClientTest.java +3 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import static org.mockito.Mockito.when; import static java.util.Collections.emptySet; import android.annotation.SuppressLint; import android.app.AlarmManager; import android.content.ContentResolver; import android.content.Context; Loading Loading @@ -296,6 +297,7 @@ public class IpClientTest { return ipc; } @SuppressLint("NewApi") private void addIPv4Provisioning(LinkProperties lp) { final LinkAddress la = new LinkAddress(TEST_IPV4_LINKADDRESS); final RouteInfo defaultRoute = new RouteInfo(new IpPrefix(Inet4Address.ANY, 0), Loading Loading @@ -625,6 +627,7 @@ public class IpClientTest { TEST_IFNAME)); } @SuppressLint("NewApi") static RouteInfo defaultIPV6Route(String gateway) { return new RouteInfo(new IpPrefix(Inet6Address.ANY, 0), InetAddresses.parseNumericAddress(gateway), TEST_IFNAME); Loading tests/unit/src/android/net/ip/IpReachabilityMonitorTest.kt +6 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ package android.net.ip import android.annotation.SuppressLint import android.content.Context import android.net.ip.IpNeighborMonitor.NeighborEventConsumer import android.net.INetd Loading Loading @@ -106,6 +107,8 @@ private val TEST_IPV6_DNS = parseNumericAddress("2001:db8::321") as Inet6Address private val TEST_IPV6_DNS2 = parseNumericAddress("2001:db8::456") as Inet6Address private val TEST_IFACE = InterfaceParams("fake0", 21, null) @SuppressLint("NewApi") private val TEST_LINK_PROPERTIES = LinkProperties().apply { interfaceName = TEST_IFACE.name addLinkAddress(TEST_IPV4_LINKADDR) Loading @@ -123,6 +126,7 @@ private val TEST_LINK_PROPERTIES = LinkProperties().apply { addDnsServer(TEST_IPV6_DNS) } @SuppressLint("NewApi") private val TEST_IPV4_ONLY_LINK_PROPERTIES = LinkProperties().apply { interfaceName = TEST_IFACE.name addLinkAddress(TEST_IPV4_LINKADDR) Loading @@ -136,6 +140,7 @@ private val TEST_IPV4_ONLY_LINK_PROPERTIES = LinkProperties().apply { addDnsServer(TEST_IPV4_GATEWAY_DNS) } @SuppressLint("NewApi") private val TEST_IPV6_LINKLOCAL_SCOPED_LINK_PROPERTIES = LinkProperties().apply { interfaceName = TEST_IFACE.name addLinkAddress(TEST_IPV6_LINKADDR) Loading @@ -151,6 +156,7 @@ private val TEST_IPV6_LINKLOCAL_SCOPED_LINK_PROPERTIES = LinkProperties().apply addDnsServer(TEST_IPV6_DNS) } @SuppressLint("NewApi") private val TEST_DUAL_LINK_PROPERTIES = LinkProperties().apply { interfaceName = TEST_IFACE.name addLinkAddress(TEST_IPV4_LINKADDR) Loading tests/unit/src/android/net/shared/InitialConfigurationTest.java +3 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import static com.android.testutils.MiscAsserts.assertFieldCountEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import android.annotation.SuppressLint; import android.net.IpPrefix; import android.net.LinkAddress; Loading @@ -44,6 +45,7 @@ import java.util.function.Consumer; public class InitialConfigurationTest { private InitialConfiguration mConfig; @SuppressLint("NewApi") @Before public void setUp() { mConfig = new InitialConfiguration(); Loading @@ -67,6 +69,7 @@ public class InitialConfigurationTest { assertEquals(mConfig, unparceled); } @SuppressLint("NewApi") @Test public void testEquals() { assertEquals(mConfig, InitialConfiguration.copy(mConfig)); Loading Loading
src/android/net/dhcp/DhcpServingParams.java +2 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import static com.android.net.module.util.NetworkStackConstants.IPV4_MIN_MTU; import static java.lang.Integer.toUnsignedLong; import android.annotation.SuppressLint; import android.net.IpPrefix; import android.net.LinkAddress; import android.util.ArraySet; Loading Loading @@ -411,6 +412,7 @@ public class DhcpServingParams { /** * Utility method to create an IpPrefix with the address and prefix length of a LinkAddress. */ @SuppressLint("NewApi") @NonNull static IpPrefix makeIpPrefix(@NonNull LinkAddress addr) { return new IpPrefix(addr.getAddress(), addr.getPrefixLength()); Loading
tests/unit/src/android/net/dhcp/DhcpLeaseRepositoryTest.java +6 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import static java.util.stream.Collectors.toSet; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SuppressLint; import android.net.IpPrefix; import android.net.MacAddress; import android.net.dhcp.DhcpServer.Clock; Loading Loading @@ -84,6 +85,7 @@ public class DhcpLeaseRepositoryTest { private static final Inet4Address TEST_INETADDR_2 = parseAddr4("192.168.42.249"); private static final String TEST_HOSTNAME_1 = "hostname1"; private static final String TEST_HOSTNAME_2 = "hostname2"; @SuppressLint("NewApi") private static final IpPrefix TEST_IP_PREFIX = new IpPrefix(TEST_SERVER_ADDR, 22); private static final long TEST_TIME = 100L; private static final int TEST_LEASE_TIME_MS = 3_600_000; Loading Loading @@ -149,6 +151,7 @@ public class DhcpLeaseRepositoryTest { } } @SuppressLint("NewApi") @Test public void testAddressExhaustion() throws Exception { // Use a /28 to quickly run out of addresses Loading @@ -169,6 +172,7 @@ public class DhcpLeaseRepositoryTest { verifyNoMoreInteractions(mCallbacks); } @SuppressLint("NewApi") @Test public void testUpdateParams_LeaseCleanup() throws Exception { // Inside /28: Loading Loading @@ -229,6 +233,7 @@ public class DhcpLeaseRepositoryTest { } } @SuppressLint("NewApi") @Test public void testUpdateParams_UsesNewPrefix() throws Exception { final IpPrefix newPrefix = new IpPrefix(parseAddr4("192.168.123.0"), 24); Loading Loading @@ -538,6 +543,7 @@ public class DhcpLeaseRepositoryTest { assertNotEquals(lease.getNetAddr(), newLease.getNetAddr()); } @SuppressLint("NewApi") @Test public void testMarkLeaseDeclined_UsedIfOutOfAddresses() throws Exception { // Use a /28 to quickly run out of addresses Loading
tests/unit/src/android/net/ip/IpClientTest.java +3 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import static org.mockito.Mockito.when; import static java.util.Collections.emptySet; import android.annotation.SuppressLint; import android.app.AlarmManager; import android.content.ContentResolver; import android.content.Context; Loading Loading @@ -296,6 +297,7 @@ public class IpClientTest { return ipc; } @SuppressLint("NewApi") private void addIPv4Provisioning(LinkProperties lp) { final LinkAddress la = new LinkAddress(TEST_IPV4_LINKADDRESS); final RouteInfo defaultRoute = new RouteInfo(new IpPrefix(Inet4Address.ANY, 0), Loading Loading @@ -625,6 +627,7 @@ public class IpClientTest { TEST_IFNAME)); } @SuppressLint("NewApi") static RouteInfo defaultIPV6Route(String gateway) { return new RouteInfo(new IpPrefix(Inet6Address.ANY, 0), InetAddresses.parseNumericAddress(gateway), TEST_IFNAME); Loading
tests/unit/src/android/net/ip/IpReachabilityMonitorTest.kt +6 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ package android.net.ip import android.annotation.SuppressLint import android.content.Context import android.net.ip.IpNeighborMonitor.NeighborEventConsumer import android.net.INetd Loading Loading @@ -106,6 +107,8 @@ private val TEST_IPV6_DNS = parseNumericAddress("2001:db8::321") as Inet6Address private val TEST_IPV6_DNS2 = parseNumericAddress("2001:db8::456") as Inet6Address private val TEST_IFACE = InterfaceParams("fake0", 21, null) @SuppressLint("NewApi") private val TEST_LINK_PROPERTIES = LinkProperties().apply { interfaceName = TEST_IFACE.name addLinkAddress(TEST_IPV4_LINKADDR) Loading @@ -123,6 +126,7 @@ private val TEST_LINK_PROPERTIES = LinkProperties().apply { addDnsServer(TEST_IPV6_DNS) } @SuppressLint("NewApi") private val TEST_IPV4_ONLY_LINK_PROPERTIES = LinkProperties().apply { interfaceName = TEST_IFACE.name addLinkAddress(TEST_IPV4_LINKADDR) Loading @@ -136,6 +140,7 @@ private val TEST_IPV4_ONLY_LINK_PROPERTIES = LinkProperties().apply { addDnsServer(TEST_IPV4_GATEWAY_DNS) } @SuppressLint("NewApi") private val TEST_IPV6_LINKLOCAL_SCOPED_LINK_PROPERTIES = LinkProperties().apply { interfaceName = TEST_IFACE.name addLinkAddress(TEST_IPV6_LINKADDR) Loading @@ -151,6 +156,7 @@ private val TEST_IPV6_LINKLOCAL_SCOPED_LINK_PROPERTIES = LinkProperties().apply addDnsServer(TEST_IPV6_DNS) } @SuppressLint("NewApi") private val TEST_DUAL_LINK_PROPERTIES = LinkProperties().apply { interfaceName = TEST_IFACE.name addLinkAddress(TEST_IPV4_LINKADDR) Loading
tests/unit/src/android/net/shared/InitialConfigurationTest.java +3 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import static com.android.testutils.MiscAsserts.assertFieldCountEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import android.annotation.SuppressLint; import android.net.IpPrefix; import android.net.LinkAddress; Loading @@ -44,6 +45,7 @@ import java.util.function.Consumer; public class InitialConfigurationTest { private InitialConfiguration mConfig; @SuppressLint("NewApi") @Before public void setUp() { mConfig = new InitialConfiguration(); Loading @@ -67,6 +69,7 @@ public class InitialConfigurationTest { assertEquals(mConfig, unparceled); } @SuppressLint("NewApi") @Test public void testEquals() { assertEquals(mConfig, InitialConfiguration.copy(mConfig)); Loading