Loading api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -28888,6 +28888,7 @@ package android.net { method public boolean addRoute(@NonNull android.net.RouteInfo); method public void clear(); method public int describeContents(); method @Nullable public java.net.Inet4Address getDhcpServerAddress(); method @NonNull public java.util.List<java.net.InetAddress> getDnsServers(); method @Nullable public String getDomains(); method @Nullable public android.net.ProxyInfo getHttpProxy(); Loading @@ -28899,6 +28900,7 @@ package android.net { method @NonNull public java.util.List<android.net.RouteInfo> getRoutes(); method public boolean isPrivateDnsActive(); method public boolean isWakeOnLanSupported(); method public void setDhcpServerAddress(@Nullable java.net.Inet4Address); method public void setDnsServers(@NonNull java.util.Collection<java.net.InetAddress>); method public void setDomains(@Nullable String); method public void setHttpProxy(@Nullable android.net.ProxyInfo); core/java/android/net/LinkProperties.java +50 −3 Original line number Diff line number Diff line Loading @@ -63,6 +63,7 @@ public final class LinkProperties implements Parcelable { private String mPrivateDnsServerName; private String mDomains; private ArrayList<RouteInfo> mRoutes = new ArrayList<>(); private Inet4Address mDhcpServerAddress; private ProxyInfo mHttpProxy; private int mMtu; // in the format "rmem_min,rmem_def,rmem_max,wmem_min,wmem_def,wmem_max" Loading Loading @@ -196,6 +197,7 @@ public final class LinkProperties implements Parcelable { addStackedLink(l); } setMtu(source.mMtu); setDhcpServerAddress(source.getDhcpServerAddress()); mTcpBufferSizes = source.mTcpBufferSizes; mNat64Prefix = source.mNat64Prefix; mWakeOnLanSupported = source.mWakeOnLanSupported; Loading Loading @@ -459,6 +461,24 @@ public final class LinkProperties implements Parcelable { mPrivateDnsServerName = privateDnsServerName; } /** * Set DHCP server address. * * @param serverAddress the server address to set. */ public void setDhcpServerAddress(@Nullable Inet4Address serverAddress) { mDhcpServerAddress = serverAddress; } /** * Get DHCP server address * * @return The current DHCP server address. */ public @Nullable Inet4Address getDhcpServerAddress() { return mDhcpServerAddress; } /** * Returns the private DNS server name that is in use. If not {@code null}, * private DNS is in strict mode. In this mode, applications should ensure Loading Loading @@ -851,6 +871,7 @@ public final class LinkProperties implements Parcelable { mHttpProxy = null; mStackedLinks.clear(); mMtu = 0; mDhcpServerAddress = null; mTcpBufferSizes = null; mNat64Prefix = null; mWakeOnLanSupported = false; Loading Loading @@ -919,6 +940,11 @@ public final class LinkProperties implements Parcelable { resultJoiner.add("WakeOnLanSupported: true"); } if (mDhcpServerAddress != null) { resultJoiner.add("ServerAddress:"); resultJoiner.add(mDhcpServerAddress.toString()); } if (mTcpBufferSizes != null) { resultJoiner.add("TcpBufferSizes:"); resultJoiner.add(mTcpBufferSizes); Loading Loading @@ -1272,6 +1298,17 @@ public final class LinkProperties implements Parcelable { return TextUtils.equals(getInterfaceName(), target.getInterfaceName()); } /** * Compares this {@code LinkProperties} DHCP server address against the target * * @param target LinkProperties to compare. * @return {@code true} if both are identical, {@code false} otherwise. * @hide */ public boolean isIdenticalDhcpServerAddress(@NonNull LinkProperties target) { return Objects.equals(mDhcpServerAddress, target.mDhcpServerAddress); } /** * Compares this {@code LinkProperties} interface addresses against the target * Loading Loading @@ -1489,6 +1526,7 @@ public final class LinkProperties implements Parcelable { */ return isIdenticalInterfaceName(target) && isIdenticalAddresses(target) && isIdenticalDhcpServerAddress(target) && isIdenticalDnses(target) && isIdenticalPrivateDns(target) && isIdenticalValidatedPrivateDnses(target) Loading Loading @@ -1613,6 +1651,7 @@ public final class LinkProperties implements Parcelable { + mMtu * 51 + ((null == mTcpBufferSizes) ? 0 : mTcpBufferSizes.hashCode()) + (mUsePrivateDns ? 57 : 0) + ((null == mDhcpServerAddress) ? 0 : mDhcpServerAddress.hashCode()) + mPcscfs.size() * 67 + ((null == mPrivateDnsServerName) ? 0 : mPrivateDnsServerName.hashCode()) + Objects.hash(mNat64Prefix) Loading @@ -1635,6 +1674,7 @@ public final class LinkProperties implements Parcelable { dest.writeString(mPrivateDnsServerName); writeAddresses(dest, mPcscfs); dest.writeString(mDomains); writeAddress(dest, mDhcpServerAddress); dest.writeInt(mMtu); dest.writeString(mTcpBufferSizes); dest.writeInt(mRoutes.size()); Loading Loading @@ -1663,8 +1703,9 @@ public final class LinkProperties implements Parcelable { } } private static void writeAddress(@NonNull Parcel dest, @NonNull InetAddress addr) { dest.writeByteArray(addr.getAddress()); private static void writeAddress(@NonNull Parcel dest, @Nullable InetAddress addr) { byte[] addressBytes = (addr == null ? null : addr.getAddress()); dest.writeByteArray(addressBytes); if (addr instanceof Inet6Address) { final Inet6Address v6Addr = (Inet6Address) addr; final boolean hasScopeId = v6Addr.getScopeId() != 0; Loading @@ -1673,9 +1714,11 @@ public final class LinkProperties implements Parcelable { } } @NonNull @Nullable private static InetAddress readAddress(@NonNull Parcel p) throws UnknownHostException { final byte[] addr = p.createByteArray(); if (addr == null) return null; if (addr.length == INET6_ADDR_LENGTH) { final boolean hasScopeId = p.readBoolean(); final int scopeId = hasScopeId ? p.readInt() : 0; Loading Loading @@ -1722,6 +1765,10 @@ public final class LinkProperties implements Parcelable { } catch (UnknownHostException e) { } } netProp.setDomains(in.readString()); try { netProp.setDhcpServerAddress((Inet4Address) InetAddress .getByAddress(in.createByteArray())); } catch (UnknownHostException e) { } netProp.setMtu(in.readInt()); netProp.setTcpBufferSizes(in.readString()); addressCount = in.readInt(); Loading tests/net/common/java/android/net/LinkPropertiesTest.java +16 −1 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import androidx.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import java.net.Inet4Address; import java.net.InetAddress; import java.util.ArrayList; import java.util.Arrays; Loading Loading @@ -65,6 +66,7 @@ public class LinkPropertiesTest { private static final InetAddress GATEWAY62 = address("fe80::6:22%lo"); private static final InetAddress TESTIPV4ADDR = address("192.168.47.42"); private static final InetAddress TESTIPV6ADDR = address("fe80::7:33%43"); private static final Inet4Address DHCPSERVER = (Inet4Address) address("192.0.2.1"); private static final String NAME = "qmi0"; private static final String DOMAINS = "google.com"; private static final String PRIV_DNS_SERVER_NAME = "private.dns.com"; Loading Loading @@ -93,6 +95,7 @@ public class LinkPropertiesTest { assertNull(lp.getHttpProxy()); assertNull(lp.getTcpBufferSizes()); assertNull(lp.getNat64Prefix()); assertNull(lp.getDhcpServerAddress()); assertFalse(lp.isProvisioned()); assertFalse(lp.isIpv4Provisioned()); assertFalse(lp.isIpv6Provisioned()); Loading @@ -119,6 +122,7 @@ public class LinkPropertiesTest { lp.setMtu(MTU); lp.setTcpBufferSizes(TCP_BUFFER_SIZES); lp.setNat64Prefix(new IpPrefix("2001:db8:0:64::/96")); lp.setDhcpServerAddress(DHCPSERVER); lp.setWakeOnLanSupported(true); return lp; } Loading Loading @@ -960,11 +964,13 @@ public class LinkPropertiesTest { source.setWakeOnLanSupported(true); source.setDhcpServerAddress((Inet4Address) GATEWAY1); final LinkProperties stacked = new LinkProperties(); stacked.setInterfaceName("test-stacked"); source.addStackedLink(stacked); assertParcelSane(source, 15 /* fieldCount */); assertParcelSane(source, 16 /* fieldCount */); } @Test Loading Loading @@ -1090,6 +1096,15 @@ public class LinkPropertiesTest { assertFalse(lp.isPrivateDnsActive()); } @Test public void testDhcpServerAddress() { final LinkProperties lp = makeTestObject(); assertEquals(DHCPSERVER, lp.getDhcpServerAddress()); lp.clear(); assertNull(lp.getDhcpServerAddress()); } @Test public void testWakeOnLanSupported() { final LinkProperties lp = makeTestObject(); Loading Loading
api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -28888,6 +28888,7 @@ package android.net { method public boolean addRoute(@NonNull android.net.RouteInfo); method public void clear(); method public int describeContents(); method @Nullable public java.net.Inet4Address getDhcpServerAddress(); method @NonNull public java.util.List<java.net.InetAddress> getDnsServers(); method @Nullable public String getDomains(); method @Nullable public android.net.ProxyInfo getHttpProxy(); Loading @@ -28899,6 +28900,7 @@ package android.net { method @NonNull public java.util.List<android.net.RouteInfo> getRoutes(); method public boolean isPrivateDnsActive(); method public boolean isWakeOnLanSupported(); method public void setDhcpServerAddress(@Nullable java.net.Inet4Address); method public void setDnsServers(@NonNull java.util.Collection<java.net.InetAddress>); method public void setDomains(@Nullable String); method public void setHttpProxy(@Nullable android.net.ProxyInfo);
core/java/android/net/LinkProperties.java +50 −3 Original line number Diff line number Diff line Loading @@ -63,6 +63,7 @@ public final class LinkProperties implements Parcelable { private String mPrivateDnsServerName; private String mDomains; private ArrayList<RouteInfo> mRoutes = new ArrayList<>(); private Inet4Address mDhcpServerAddress; private ProxyInfo mHttpProxy; private int mMtu; // in the format "rmem_min,rmem_def,rmem_max,wmem_min,wmem_def,wmem_max" Loading Loading @@ -196,6 +197,7 @@ public final class LinkProperties implements Parcelable { addStackedLink(l); } setMtu(source.mMtu); setDhcpServerAddress(source.getDhcpServerAddress()); mTcpBufferSizes = source.mTcpBufferSizes; mNat64Prefix = source.mNat64Prefix; mWakeOnLanSupported = source.mWakeOnLanSupported; Loading Loading @@ -459,6 +461,24 @@ public final class LinkProperties implements Parcelable { mPrivateDnsServerName = privateDnsServerName; } /** * Set DHCP server address. * * @param serverAddress the server address to set. */ public void setDhcpServerAddress(@Nullable Inet4Address serverAddress) { mDhcpServerAddress = serverAddress; } /** * Get DHCP server address * * @return The current DHCP server address. */ public @Nullable Inet4Address getDhcpServerAddress() { return mDhcpServerAddress; } /** * Returns the private DNS server name that is in use. If not {@code null}, * private DNS is in strict mode. In this mode, applications should ensure Loading Loading @@ -851,6 +871,7 @@ public final class LinkProperties implements Parcelable { mHttpProxy = null; mStackedLinks.clear(); mMtu = 0; mDhcpServerAddress = null; mTcpBufferSizes = null; mNat64Prefix = null; mWakeOnLanSupported = false; Loading Loading @@ -919,6 +940,11 @@ public final class LinkProperties implements Parcelable { resultJoiner.add("WakeOnLanSupported: true"); } if (mDhcpServerAddress != null) { resultJoiner.add("ServerAddress:"); resultJoiner.add(mDhcpServerAddress.toString()); } if (mTcpBufferSizes != null) { resultJoiner.add("TcpBufferSizes:"); resultJoiner.add(mTcpBufferSizes); Loading Loading @@ -1272,6 +1298,17 @@ public final class LinkProperties implements Parcelable { return TextUtils.equals(getInterfaceName(), target.getInterfaceName()); } /** * Compares this {@code LinkProperties} DHCP server address against the target * * @param target LinkProperties to compare. * @return {@code true} if both are identical, {@code false} otherwise. * @hide */ public boolean isIdenticalDhcpServerAddress(@NonNull LinkProperties target) { return Objects.equals(mDhcpServerAddress, target.mDhcpServerAddress); } /** * Compares this {@code LinkProperties} interface addresses against the target * Loading Loading @@ -1489,6 +1526,7 @@ public final class LinkProperties implements Parcelable { */ return isIdenticalInterfaceName(target) && isIdenticalAddresses(target) && isIdenticalDhcpServerAddress(target) && isIdenticalDnses(target) && isIdenticalPrivateDns(target) && isIdenticalValidatedPrivateDnses(target) Loading Loading @@ -1613,6 +1651,7 @@ public final class LinkProperties implements Parcelable { + mMtu * 51 + ((null == mTcpBufferSizes) ? 0 : mTcpBufferSizes.hashCode()) + (mUsePrivateDns ? 57 : 0) + ((null == mDhcpServerAddress) ? 0 : mDhcpServerAddress.hashCode()) + mPcscfs.size() * 67 + ((null == mPrivateDnsServerName) ? 0 : mPrivateDnsServerName.hashCode()) + Objects.hash(mNat64Prefix) Loading @@ -1635,6 +1674,7 @@ public final class LinkProperties implements Parcelable { dest.writeString(mPrivateDnsServerName); writeAddresses(dest, mPcscfs); dest.writeString(mDomains); writeAddress(dest, mDhcpServerAddress); dest.writeInt(mMtu); dest.writeString(mTcpBufferSizes); dest.writeInt(mRoutes.size()); Loading Loading @@ -1663,8 +1703,9 @@ public final class LinkProperties implements Parcelable { } } private static void writeAddress(@NonNull Parcel dest, @NonNull InetAddress addr) { dest.writeByteArray(addr.getAddress()); private static void writeAddress(@NonNull Parcel dest, @Nullable InetAddress addr) { byte[] addressBytes = (addr == null ? null : addr.getAddress()); dest.writeByteArray(addressBytes); if (addr instanceof Inet6Address) { final Inet6Address v6Addr = (Inet6Address) addr; final boolean hasScopeId = v6Addr.getScopeId() != 0; Loading @@ -1673,9 +1714,11 @@ public final class LinkProperties implements Parcelable { } } @NonNull @Nullable private static InetAddress readAddress(@NonNull Parcel p) throws UnknownHostException { final byte[] addr = p.createByteArray(); if (addr == null) return null; if (addr.length == INET6_ADDR_LENGTH) { final boolean hasScopeId = p.readBoolean(); final int scopeId = hasScopeId ? p.readInt() : 0; Loading Loading @@ -1722,6 +1765,10 @@ public final class LinkProperties implements Parcelable { } catch (UnknownHostException e) { } } netProp.setDomains(in.readString()); try { netProp.setDhcpServerAddress((Inet4Address) InetAddress .getByAddress(in.createByteArray())); } catch (UnknownHostException e) { } netProp.setMtu(in.readInt()); netProp.setTcpBufferSizes(in.readString()); addressCount = in.readInt(); Loading
tests/net/common/java/android/net/LinkPropertiesTest.java +16 −1 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import androidx.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import java.net.Inet4Address; import java.net.InetAddress; import java.util.ArrayList; import java.util.Arrays; Loading Loading @@ -65,6 +66,7 @@ public class LinkPropertiesTest { private static final InetAddress GATEWAY62 = address("fe80::6:22%lo"); private static final InetAddress TESTIPV4ADDR = address("192.168.47.42"); private static final InetAddress TESTIPV6ADDR = address("fe80::7:33%43"); private static final Inet4Address DHCPSERVER = (Inet4Address) address("192.0.2.1"); private static final String NAME = "qmi0"; private static final String DOMAINS = "google.com"; private static final String PRIV_DNS_SERVER_NAME = "private.dns.com"; Loading Loading @@ -93,6 +95,7 @@ public class LinkPropertiesTest { assertNull(lp.getHttpProxy()); assertNull(lp.getTcpBufferSizes()); assertNull(lp.getNat64Prefix()); assertNull(lp.getDhcpServerAddress()); assertFalse(lp.isProvisioned()); assertFalse(lp.isIpv4Provisioned()); assertFalse(lp.isIpv6Provisioned()); Loading @@ -119,6 +122,7 @@ public class LinkPropertiesTest { lp.setMtu(MTU); lp.setTcpBufferSizes(TCP_BUFFER_SIZES); lp.setNat64Prefix(new IpPrefix("2001:db8:0:64::/96")); lp.setDhcpServerAddress(DHCPSERVER); lp.setWakeOnLanSupported(true); return lp; } Loading Loading @@ -960,11 +964,13 @@ public class LinkPropertiesTest { source.setWakeOnLanSupported(true); source.setDhcpServerAddress((Inet4Address) GATEWAY1); final LinkProperties stacked = new LinkProperties(); stacked.setInterfaceName("test-stacked"); source.addStackedLink(stacked); assertParcelSane(source, 15 /* fieldCount */); assertParcelSane(source, 16 /* fieldCount */); } @Test Loading Loading @@ -1090,6 +1096,15 @@ public class LinkPropertiesTest { assertFalse(lp.isPrivateDnsActive()); } @Test public void testDhcpServerAddress() { final LinkProperties lp = makeTestObject(); assertEquals(DHCPSERVER, lp.getDhcpServerAddress()); lp.clear(); assertNull(lp.getDhcpServerAddress()); } @Test public void testWakeOnLanSupported() { final LinkProperties lp = makeTestObject(); Loading