Loading Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -851,6 +851,7 @@ filegroup { "core/java/android/annotation/UnsupportedAppUsage.java", "core/java/android/net/DhcpResults.java", "core/java/android/util/LocalLog.java", "core/java/com/android/internal/annotations/GuardedBy.java", "core/java/com/android/internal/annotations/VisibleForTesting.java", "core/java/com/android/internal/util/HexDump.java", "core/java/com/android/internal/util/IndentingPrintWriter.java", Loading core/java/android/net/DhcpResults.java +16 −13 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.net; import android.annotation.UnsupportedAppUsage; import android.net.shared.InetAddressUtils; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; Loading Loading @@ -73,19 +74,21 @@ public final class DhcpResults implements Parcelable { public StaticIpConfiguration toStaticIpConfiguration() { final StaticIpConfiguration s = new StaticIpConfiguration(); // All these except dnsServers are immutable, so no need to make copies. s.ipAddress = ipAddress; s.gateway = gateway; s.dnsServers.addAll(dnsServers); s.domains = domains; s.setIpAddress(ipAddress); s.setGateway(gateway); for (InetAddress addr : dnsServers) { s.addDnsServer(addr); } s.setDomains(domains); return s; } public DhcpResults(StaticIpConfiguration source) { if (source != null) { ipAddress = source.ipAddress; gateway = source.gateway; dnsServers.addAll(source.dnsServers); domains = source.domains; ipAddress = source.getIpAddress(); gateway = source.getGateway(); dnsServers.addAll(source.getDnsServers()); domains = source.getDomains(); } } Loading Loading @@ -177,7 +180,7 @@ public final class DhcpResults implements Parcelable { toStaticIpConfiguration().writeToParcel(dest, flags); dest.writeInt(leaseDuration); dest.writeInt(mtu); NetworkUtils.parcelInetAddress(dest, serverAddress, flags); InetAddressUtils.parcelInetAddress(dest, serverAddress, flags); dest.writeString(vendorInfo); } Loading @@ -191,7 +194,7 @@ public final class DhcpResults implements Parcelable { final DhcpResults dhcpResults = new DhcpResults(s); dhcpResults.leaseDuration = in.readInt(); dhcpResults.mtu = in.readInt(); dhcpResults.serverAddress = (Inet4Address) NetworkUtils.unparcelInetAddress(in); dhcpResults.serverAddress = (Inet4Address) InetAddressUtils.unparcelInetAddress(in); dhcpResults.vendorInfo = in.readString(); return dhcpResults; } Loading @@ -200,7 +203,7 @@ public final class DhcpResults implements Parcelable { // Not part of the superclass because they're only used by the JNI iterface to the DHCP daemon. public boolean setIpAddress(String addrString, int prefixLength) { try { Inet4Address addr = (Inet4Address) NetworkUtils.numericToInetAddress(addrString); Inet4Address addr = (Inet4Address) InetAddresses.parseNumericAddress(addrString); ipAddress = new LinkAddress(addr, prefixLength); } catch (IllegalArgumentException|ClassCastException e) { Log.e(TAG, "setIpAddress failed with addrString " + addrString + "/" + prefixLength); Loading @@ -211,7 +214,7 @@ public final class DhcpResults implements Parcelable { public boolean setGateway(String addrString) { try { gateway = NetworkUtils.numericToInetAddress(addrString); gateway = InetAddresses.parseNumericAddress(addrString); } catch (IllegalArgumentException e) { Log.e(TAG, "setGateway failed with addrString " + addrString); return true; Loading @@ -222,7 +225,7 @@ public final class DhcpResults implements Parcelable { public boolean addDns(String addrString) { if (TextUtils.isEmpty(addrString) == false) { try { dnsServers.add(NetworkUtils.numericToInetAddress(addrString)); dnsServers.add(InetAddresses.parseNumericAddress(addrString)); } catch (IllegalArgumentException e) { Log.e(TAG, "addDns failed with addrString " + addrString); return true; Loading core/java/android/net/INetworkStackConnector.aidl +3 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.net; import android.net.INetworkMonitorCallbacks; import android.net.NetworkParcelable; import android.net.dhcp.DhcpServingParamsParcel; import android.net.dhcp.IDhcpServerCallbacks; import android.net.ip.IIpClientCallbacks; Loading @@ -24,6 +25,7 @@ import android.net.ip.IIpClientCallbacks; oneway interface INetworkStackConnector { void makeDhcpServer(in String ifName, in DhcpServingParamsParcel params, in IDhcpServerCallbacks cb); void makeNetworkMonitor(int netId, String name, in INetworkMonitorCallbacks cb); void makeNetworkMonitor(in NetworkParcelable network, String name, in INetworkMonitorCallbacks cb); void makeIpClient(in String ifName, in IIpClientCallbacks callbacks); } No newline at end of file core/java/android/net/NetworkStack.java +3 −2 Original line number Diff line number Diff line Loading @@ -104,10 +104,11 @@ public class NetworkStack { * * <p>The INetworkMonitor will be returned asynchronously through the provided callbacks. */ public void makeNetworkMonitor(Network network, String name, INetworkMonitorCallbacks cb) { public void makeNetworkMonitor( NetworkParcelable network, String name, INetworkMonitorCallbacks cb) { requestConnector(connector -> { try { connector.makeNetworkMonitor(network.netId, name, cb); connector.makeNetworkMonitor(network, name, cb); } catch (RemoteException e) { e.rethrowFromSystemServer(); } Loading core/java/android/net/NetworkUtils.java +0 −27 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package android.net; import android.annotation.UnsupportedAppUsage; import android.net.shared.Inet4AddressUtils; import android.os.Build; import android.os.Parcel; import android.system.ErrnoException; import android.util.Log; import android.util.Pair; Loading Loading @@ -246,32 +245,6 @@ public class NetworkUtils { return InetAddress.parseNumericAddress(addrString); } /** * Writes an InetAddress to a parcel. The address may be null. This is likely faster than * calling writeSerializable. */ protected static void parcelInetAddress(Parcel parcel, InetAddress address, int flags) { byte[] addressArray = (address != null) ? address.getAddress() : null; parcel.writeByteArray(addressArray); } /** * Reads an InetAddress from a parcel. Returns null if the address that was written was null * or if the data is invalid. */ protected static InetAddress unparcelInetAddress(Parcel in) { byte[] addressArray = in.createByteArray(); if (addressArray == null) { return null; } try { return InetAddress.getByAddress(addressArray); } catch (UnknownHostException e) { return null; } } /** * Masks a raw IP address byte array with the specified prefix length. */ Loading Loading
Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -851,6 +851,7 @@ filegroup { "core/java/android/annotation/UnsupportedAppUsage.java", "core/java/android/net/DhcpResults.java", "core/java/android/util/LocalLog.java", "core/java/com/android/internal/annotations/GuardedBy.java", "core/java/com/android/internal/annotations/VisibleForTesting.java", "core/java/com/android/internal/util/HexDump.java", "core/java/com/android/internal/util/IndentingPrintWriter.java", Loading
core/java/android/net/DhcpResults.java +16 −13 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.net; import android.annotation.UnsupportedAppUsage; import android.net.shared.InetAddressUtils; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; Loading Loading @@ -73,19 +74,21 @@ public final class DhcpResults implements Parcelable { public StaticIpConfiguration toStaticIpConfiguration() { final StaticIpConfiguration s = new StaticIpConfiguration(); // All these except dnsServers are immutable, so no need to make copies. s.ipAddress = ipAddress; s.gateway = gateway; s.dnsServers.addAll(dnsServers); s.domains = domains; s.setIpAddress(ipAddress); s.setGateway(gateway); for (InetAddress addr : dnsServers) { s.addDnsServer(addr); } s.setDomains(domains); return s; } public DhcpResults(StaticIpConfiguration source) { if (source != null) { ipAddress = source.ipAddress; gateway = source.gateway; dnsServers.addAll(source.dnsServers); domains = source.domains; ipAddress = source.getIpAddress(); gateway = source.getGateway(); dnsServers.addAll(source.getDnsServers()); domains = source.getDomains(); } } Loading Loading @@ -177,7 +180,7 @@ public final class DhcpResults implements Parcelable { toStaticIpConfiguration().writeToParcel(dest, flags); dest.writeInt(leaseDuration); dest.writeInt(mtu); NetworkUtils.parcelInetAddress(dest, serverAddress, flags); InetAddressUtils.parcelInetAddress(dest, serverAddress, flags); dest.writeString(vendorInfo); } Loading @@ -191,7 +194,7 @@ public final class DhcpResults implements Parcelable { final DhcpResults dhcpResults = new DhcpResults(s); dhcpResults.leaseDuration = in.readInt(); dhcpResults.mtu = in.readInt(); dhcpResults.serverAddress = (Inet4Address) NetworkUtils.unparcelInetAddress(in); dhcpResults.serverAddress = (Inet4Address) InetAddressUtils.unparcelInetAddress(in); dhcpResults.vendorInfo = in.readString(); return dhcpResults; } Loading @@ -200,7 +203,7 @@ public final class DhcpResults implements Parcelable { // Not part of the superclass because they're only used by the JNI iterface to the DHCP daemon. public boolean setIpAddress(String addrString, int prefixLength) { try { Inet4Address addr = (Inet4Address) NetworkUtils.numericToInetAddress(addrString); Inet4Address addr = (Inet4Address) InetAddresses.parseNumericAddress(addrString); ipAddress = new LinkAddress(addr, prefixLength); } catch (IllegalArgumentException|ClassCastException e) { Log.e(TAG, "setIpAddress failed with addrString " + addrString + "/" + prefixLength); Loading @@ -211,7 +214,7 @@ public final class DhcpResults implements Parcelable { public boolean setGateway(String addrString) { try { gateway = NetworkUtils.numericToInetAddress(addrString); gateway = InetAddresses.parseNumericAddress(addrString); } catch (IllegalArgumentException e) { Log.e(TAG, "setGateway failed with addrString " + addrString); return true; Loading @@ -222,7 +225,7 @@ public final class DhcpResults implements Parcelable { public boolean addDns(String addrString) { if (TextUtils.isEmpty(addrString) == false) { try { dnsServers.add(NetworkUtils.numericToInetAddress(addrString)); dnsServers.add(InetAddresses.parseNumericAddress(addrString)); } catch (IllegalArgumentException e) { Log.e(TAG, "addDns failed with addrString " + addrString); return true; Loading
core/java/android/net/INetworkStackConnector.aidl +3 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.net; import android.net.INetworkMonitorCallbacks; import android.net.NetworkParcelable; import android.net.dhcp.DhcpServingParamsParcel; import android.net.dhcp.IDhcpServerCallbacks; import android.net.ip.IIpClientCallbacks; Loading @@ -24,6 +25,7 @@ import android.net.ip.IIpClientCallbacks; oneway interface INetworkStackConnector { void makeDhcpServer(in String ifName, in DhcpServingParamsParcel params, in IDhcpServerCallbacks cb); void makeNetworkMonitor(int netId, String name, in INetworkMonitorCallbacks cb); void makeNetworkMonitor(in NetworkParcelable network, String name, in INetworkMonitorCallbacks cb); void makeIpClient(in String ifName, in IIpClientCallbacks callbacks); } No newline at end of file
core/java/android/net/NetworkStack.java +3 −2 Original line number Diff line number Diff line Loading @@ -104,10 +104,11 @@ public class NetworkStack { * * <p>The INetworkMonitor will be returned asynchronously through the provided callbacks. */ public void makeNetworkMonitor(Network network, String name, INetworkMonitorCallbacks cb) { public void makeNetworkMonitor( NetworkParcelable network, String name, INetworkMonitorCallbacks cb) { requestConnector(connector -> { try { connector.makeNetworkMonitor(network.netId, name, cb); connector.makeNetworkMonitor(network, name, cb); } catch (RemoteException e) { e.rethrowFromSystemServer(); } Loading
core/java/android/net/NetworkUtils.java +0 −27 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package android.net; import android.annotation.UnsupportedAppUsage; import android.net.shared.Inet4AddressUtils; import android.os.Build; import android.os.Parcel; import android.system.ErrnoException; import android.util.Log; import android.util.Pair; Loading Loading @@ -246,32 +245,6 @@ public class NetworkUtils { return InetAddress.parseNumericAddress(addrString); } /** * Writes an InetAddress to a parcel. The address may be null. This is likely faster than * calling writeSerializable. */ protected static void parcelInetAddress(Parcel parcel, InetAddress address, int flags) { byte[] addressArray = (address != null) ? address.getAddress() : null; parcel.writeByteArray(addressArray); } /** * Reads an InetAddress from a parcel. Returns null if the address that was written was null * or if the data is invalid. */ protected static InetAddress unparcelInetAddress(Parcel in) { byte[] addressArray = in.createByteArray(); if (addressArray == null) { return null; } try { return InetAddress.getByAddress(addressArray); } catch (UnknownHostException e) { return null; } } /** * Masks a raw IP address byte array with the specified prefix length. */ Loading