Loading Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -851,6 +851,7 @@ filegroup { "core/java/android/annotation/UnsupportedAppUsage.java", "core/java/android/annotation/UnsupportedAppUsage.java", "core/java/android/net/DhcpResults.java", "core/java/android/net/DhcpResults.java", "core/java/android/util/LocalLog.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/annotations/VisibleForTesting.java", "core/java/com/android/internal/util/HexDump.java", "core/java/com/android/internal/util/HexDump.java", "core/java/com/android/internal/util/IndentingPrintWriter.java", "core/java/com/android/internal/util/IndentingPrintWriter.java", Loading core/java/android/net/DhcpResults.java +16 −13 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.net; package android.net; import android.annotation.UnsupportedAppUsage; import android.annotation.UnsupportedAppUsage; import android.net.shared.InetAddressUtils; import android.os.Parcel; import android.os.Parcel; import android.os.Parcelable; import android.os.Parcelable; import android.text.TextUtils; import android.text.TextUtils; Loading Loading @@ -73,19 +74,21 @@ public final class DhcpResults implements Parcelable { public StaticIpConfiguration toStaticIpConfiguration() { public StaticIpConfiguration toStaticIpConfiguration() { final StaticIpConfiguration s = new StaticIpConfiguration(); final StaticIpConfiguration s = new StaticIpConfiguration(); // All these except dnsServers are immutable, so no need to make copies. // All these except dnsServers are immutable, so no need to make copies. s.ipAddress = ipAddress; s.setIpAddress(ipAddress); s.gateway = gateway; s.setGateway(gateway); s.dnsServers.addAll(dnsServers); for (InetAddress addr : dnsServers) { s.domains = domains; s.addDnsServer(addr); } s.setDomains(domains); return s; return s; } } public DhcpResults(StaticIpConfiguration source) { public DhcpResults(StaticIpConfiguration source) { if (source != null) { if (source != null) { ipAddress = source.ipAddress; ipAddress = source.getIpAddress(); gateway = source.gateway; gateway = source.getGateway(); dnsServers.addAll(source.dnsServers); dnsServers.addAll(source.getDnsServers()); domains = source.domains; domains = source.getDomains(); } } } } Loading Loading @@ -177,7 +180,7 @@ public final class DhcpResults implements Parcelable { toStaticIpConfiguration().writeToParcel(dest, flags); toStaticIpConfiguration().writeToParcel(dest, flags); dest.writeInt(leaseDuration); dest.writeInt(leaseDuration); dest.writeInt(mtu); dest.writeInt(mtu); NetworkUtils.parcelInetAddress(dest, serverAddress, flags); InetAddressUtils.parcelInetAddress(dest, serverAddress, flags); dest.writeString(vendorInfo); dest.writeString(vendorInfo); } } Loading @@ -191,7 +194,7 @@ public final class DhcpResults implements Parcelable { final DhcpResults dhcpResults = new DhcpResults(s); final DhcpResults dhcpResults = new DhcpResults(s); dhcpResults.leaseDuration = in.readInt(); dhcpResults.leaseDuration = in.readInt(); dhcpResults.mtu = in.readInt(); dhcpResults.mtu = in.readInt(); dhcpResults.serverAddress = (Inet4Address) NetworkUtils.unparcelInetAddress(in); dhcpResults.serverAddress = (Inet4Address) InetAddressUtils.unparcelInetAddress(in); dhcpResults.vendorInfo = in.readString(); dhcpResults.vendorInfo = in.readString(); return dhcpResults; 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. // 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) { public boolean setIpAddress(String addrString, int prefixLength) { try { try { Inet4Address addr = (Inet4Address) NetworkUtils.numericToInetAddress(addrString); Inet4Address addr = (Inet4Address) InetAddresses.parseNumericAddress(addrString); ipAddress = new LinkAddress(addr, prefixLength); ipAddress = new LinkAddress(addr, prefixLength); } catch (IllegalArgumentException|ClassCastException e) { } catch (IllegalArgumentException|ClassCastException e) { Log.e(TAG, "setIpAddress failed with addrString " + addrString + "/" + prefixLength); 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) { public boolean setGateway(String addrString) { try { try { gateway = NetworkUtils.numericToInetAddress(addrString); gateway = InetAddresses.parseNumericAddress(addrString); } catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) { Log.e(TAG, "setGateway failed with addrString " + addrString); Log.e(TAG, "setGateway failed with addrString " + addrString); return true; return true; Loading @@ -222,7 +225,7 @@ public final class DhcpResults implements Parcelable { public boolean addDns(String addrString) { public boolean addDns(String addrString) { if (TextUtils.isEmpty(addrString) == false) { if (TextUtils.isEmpty(addrString) == false) { try { try { dnsServers.add(NetworkUtils.numericToInetAddress(addrString)); dnsServers.add(InetAddresses.parseNumericAddress(addrString)); } catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) { Log.e(TAG, "addDns failed with addrString " + addrString); Log.e(TAG, "addDns failed with addrString " + addrString); return true; return true; Loading core/java/android/net/INetworkStackConnector.aidl +3 −1 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.net; package android.net; import android.net.INetworkMonitorCallbacks; import android.net.INetworkMonitorCallbacks; import android.net.NetworkParcelable; import android.net.dhcp.DhcpServingParamsParcel; import android.net.dhcp.DhcpServingParamsParcel; import android.net.dhcp.IDhcpServerCallbacks; import android.net.dhcp.IDhcpServerCallbacks; import android.net.ip.IIpClientCallbacks; import android.net.ip.IIpClientCallbacks; Loading @@ -24,6 +25,7 @@ import android.net.ip.IIpClientCallbacks; oneway interface INetworkStackConnector { oneway interface INetworkStackConnector { void makeDhcpServer(in String ifName, in DhcpServingParamsParcel params, void makeDhcpServer(in String ifName, in DhcpServingParamsParcel params, in IDhcpServerCallbacks cb); 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); 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 Original line Diff line number Diff line Loading @@ -104,10 +104,11 @@ public class NetworkStack { * * * <p>The INetworkMonitor will be returned asynchronously through the provided callbacks. * <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 -> { requestConnector(connector -> { try { try { connector.makeNetworkMonitor(network.netId, name, cb); connector.makeNetworkMonitor(network, name, cb); } catch (RemoteException e) { } catch (RemoteException e) { e.rethrowFromSystemServer(); e.rethrowFromSystemServer(); } } Loading core/java/android/net/NetworkUtils.java +0 −27 Original line number Original line Diff line number Diff line Loading @@ -19,7 +19,6 @@ package android.net; import android.annotation.UnsupportedAppUsage; import android.annotation.UnsupportedAppUsage; import android.net.shared.Inet4AddressUtils; import android.net.shared.Inet4AddressUtils; import android.os.Build; import android.os.Build; import android.os.Parcel; import android.system.ErrnoException; import android.system.ErrnoException; import android.util.Log; import android.util.Log; import android.util.Pair; import android.util.Pair; Loading Loading @@ -246,32 +245,6 @@ public class NetworkUtils { return InetAddress.parseNumericAddress(addrString); 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. * Masks a raw IP address byte array with the specified prefix length. */ */ Loading Loading
Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -851,6 +851,7 @@ filegroup { "core/java/android/annotation/UnsupportedAppUsage.java", "core/java/android/annotation/UnsupportedAppUsage.java", "core/java/android/net/DhcpResults.java", "core/java/android/net/DhcpResults.java", "core/java/android/util/LocalLog.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/annotations/VisibleForTesting.java", "core/java/com/android/internal/util/HexDump.java", "core/java/com/android/internal/util/HexDump.java", "core/java/com/android/internal/util/IndentingPrintWriter.java", "core/java/com/android/internal/util/IndentingPrintWriter.java", Loading
core/java/android/net/DhcpResults.java +16 −13 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.net; package android.net; import android.annotation.UnsupportedAppUsage; import android.annotation.UnsupportedAppUsage; import android.net.shared.InetAddressUtils; import android.os.Parcel; import android.os.Parcel; import android.os.Parcelable; import android.os.Parcelable; import android.text.TextUtils; import android.text.TextUtils; Loading Loading @@ -73,19 +74,21 @@ public final class DhcpResults implements Parcelable { public StaticIpConfiguration toStaticIpConfiguration() { public StaticIpConfiguration toStaticIpConfiguration() { final StaticIpConfiguration s = new StaticIpConfiguration(); final StaticIpConfiguration s = new StaticIpConfiguration(); // All these except dnsServers are immutable, so no need to make copies. // All these except dnsServers are immutable, so no need to make copies. s.ipAddress = ipAddress; s.setIpAddress(ipAddress); s.gateway = gateway; s.setGateway(gateway); s.dnsServers.addAll(dnsServers); for (InetAddress addr : dnsServers) { s.domains = domains; s.addDnsServer(addr); } s.setDomains(domains); return s; return s; } } public DhcpResults(StaticIpConfiguration source) { public DhcpResults(StaticIpConfiguration source) { if (source != null) { if (source != null) { ipAddress = source.ipAddress; ipAddress = source.getIpAddress(); gateway = source.gateway; gateway = source.getGateway(); dnsServers.addAll(source.dnsServers); dnsServers.addAll(source.getDnsServers()); domains = source.domains; domains = source.getDomains(); } } } } Loading Loading @@ -177,7 +180,7 @@ public final class DhcpResults implements Parcelable { toStaticIpConfiguration().writeToParcel(dest, flags); toStaticIpConfiguration().writeToParcel(dest, flags); dest.writeInt(leaseDuration); dest.writeInt(leaseDuration); dest.writeInt(mtu); dest.writeInt(mtu); NetworkUtils.parcelInetAddress(dest, serverAddress, flags); InetAddressUtils.parcelInetAddress(dest, serverAddress, flags); dest.writeString(vendorInfo); dest.writeString(vendorInfo); } } Loading @@ -191,7 +194,7 @@ public final class DhcpResults implements Parcelable { final DhcpResults dhcpResults = new DhcpResults(s); final DhcpResults dhcpResults = new DhcpResults(s); dhcpResults.leaseDuration = in.readInt(); dhcpResults.leaseDuration = in.readInt(); dhcpResults.mtu = in.readInt(); dhcpResults.mtu = in.readInt(); dhcpResults.serverAddress = (Inet4Address) NetworkUtils.unparcelInetAddress(in); dhcpResults.serverAddress = (Inet4Address) InetAddressUtils.unparcelInetAddress(in); dhcpResults.vendorInfo = in.readString(); dhcpResults.vendorInfo = in.readString(); return dhcpResults; 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. // 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) { public boolean setIpAddress(String addrString, int prefixLength) { try { try { Inet4Address addr = (Inet4Address) NetworkUtils.numericToInetAddress(addrString); Inet4Address addr = (Inet4Address) InetAddresses.parseNumericAddress(addrString); ipAddress = new LinkAddress(addr, prefixLength); ipAddress = new LinkAddress(addr, prefixLength); } catch (IllegalArgumentException|ClassCastException e) { } catch (IllegalArgumentException|ClassCastException e) { Log.e(TAG, "setIpAddress failed with addrString " + addrString + "/" + prefixLength); 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) { public boolean setGateway(String addrString) { try { try { gateway = NetworkUtils.numericToInetAddress(addrString); gateway = InetAddresses.parseNumericAddress(addrString); } catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) { Log.e(TAG, "setGateway failed with addrString " + addrString); Log.e(TAG, "setGateway failed with addrString " + addrString); return true; return true; Loading @@ -222,7 +225,7 @@ public final class DhcpResults implements Parcelable { public boolean addDns(String addrString) { public boolean addDns(String addrString) { if (TextUtils.isEmpty(addrString) == false) { if (TextUtils.isEmpty(addrString) == false) { try { try { dnsServers.add(NetworkUtils.numericToInetAddress(addrString)); dnsServers.add(InetAddresses.parseNumericAddress(addrString)); } catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) { Log.e(TAG, "addDns failed with addrString " + addrString); Log.e(TAG, "addDns failed with addrString " + addrString); return true; return true; Loading
core/java/android/net/INetworkStackConnector.aidl +3 −1 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.net; package android.net; import android.net.INetworkMonitorCallbacks; import android.net.INetworkMonitorCallbacks; import android.net.NetworkParcelable; import android.net.dhcp.DhcpServingParamsParcel; import android.net.dhcp.DhcpServingParamsParcel; import android.net.dhcp.IDhcpServerCallbacks; import android.net.dhcp.IDhcpServerCallbacks; import android.net.ip.IIpClientCallbacks; import android.net.ip.IIpClientCallbacks; Loading @@ -24,6 +25,7 @@ import android.net.ip.IIpClientCallbacks; oneway interface INetworkStackConnector { oneway interface INetworkStackConnector { void makeDhcpServer(in String ifName, in DhcpServingParamsParcel params, void makeDhcpServer(in String ifName, in DhcpServingParamsParcel params, in IDhcpServerCallbacks cb); 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); 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 Original line Diff line number Diff line Loading @@ -104,10 +104,11 @@ public class NetworkStack { * * * <p>The INetworkMonitor will be returned asynchronously through the provided callbacks. * <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 -> { requestConnector(connector -> { try { try { connector.makeNetworkMonitor(network.netId, name, cb); connector.makeNetworkMonitor(network, name, cb); } catch (RemoteException e) { } catch (RemoteException e) { e.rethrowFromSystemServer(); e.rethrowFromSystemServer(); } } Loading
core/java/android/net/NetworkUtils.java +0 −27 Original line number Original line Diff line number Diff line Loading @@ -19,7 +19,6 @@ package android.net; import android.annotation.UnsupportedAppUsage; import android.annotation.UnsupportedAppUsage; import android.net.shared.Inet4AddressUtils; import android.net.shared.Inet4AddressUtils; import android.os.Build; import android.os.Build; import android.os.Parcel; import android.system.ErrnoException; import android.system.ErrnoException; import android.util.Log; import android.util.Log; import android.util.Pair; import android.util.Pair; Loading Loading @@ -246,32 +245,6 @@ public class NetworkUtils { return InetAddress.parseNumericAddress(addrString); 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. * Masks a raw IP address byte array with the specified prefix length. */ */ Loading