Merge "[Mainline Migration] Migrate NetworkUtils" am: a086c295e7 am: 6f3c1295e9
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1498168 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I4f91f6de3af919fff42383ba86617112624c8292
This commit is contained in:
@@ -31,6 +31,7 @@ import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.IIpSecService;
|
||||
import android.net.INetd;
|
||||
import android.net.InetAddresses;
|
||||
import android.net.IpSecAlgorithm;
|
||||
import android.net.IpSecConfig;
|
||||
import android.net.IpSecManager;
|
||||
@@ -41,7 +42,6 @@ import android.net.IpSecTunnelInterfaceResponse;
|
||||
import android.net.IpSecUdpEncapResponse;
|
||||
import android.net.LinkAddress;
|
||||
import android.net.Network;
|
||||
import android.net.NetworkUtils;
|
||||
import android.net.TrafficStats;
|
||||
import android.net.util.NetdService;
|
||||
import android.os.Binder;
|
||||
@@ -1083,7 +1083,7 @@ public class IpSecService extends IIpSecService.Stub {
|
||||
throw new IllegalArgumentException("Unspecified address");
|
||||
}
|
||||
|
||||
InetAddress checkAddr = NetworkUtils.numericToInetAddress(inetAddress);
|
||||
InetAddress checkAddr = InetAddresses.parseNumericAddress(inetAddress);
|
||||
|
||||
if (checkAddr.isAnyLocalAddress()) {
|
||||
throw new IllegalArgumentException("Inappropriate wildcard address: " + inetAddress);
|
||||
@@ -1467,7 +1467,7 @@ public class IpSecService extends IIpSecService.Stub {
|
||||
|
||||
private int getFamily(String inetAddress) {
|
||||
int family = AF_UNSPEC;
|
||||
InetAddress checkAddress = NetworkUtils.numericToInetAddress(inetAddress);
|
||||
InetAddress checkAddress = InetAddresses.parseNumericAddress(inetAddress);
|
||||
if (checkAddress instanceof Inet4Address) {
|
||||
family = AF_INET;
|
||||
} else if (checkAddress instanceof Inet6Address) {
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
|
||||
package com.android.server.net;
|
||||
|
||||
import android.net.InetAddresses;
|
||||
import android.net.IpConfiguration;
|
||||
import android.net.IpConfiguration.IpAssignment;
|
||||
import android.net.IpConfiguration.ProxySettings;
|
||||
import android.net.LinkAddress;
|
||||
import android.net.NetworkUtils;
|
||||
import android.net.ProxyInfo;
|
||||
import android.net.RouteInfo;
|
||||
import android.net.StaticIpConfiguration;
|
||||
@@ -284,8 +284,10 @@ public class IpConfigStore {
|
||||
} else if (key.equals(IP_ASSIGNMENT_KEY)) {
|
||||
ipAssignment = IpAssignment.valueOf(in.readUTF());
|
||||
} else if (key.equals(LINK_ADDRESS_KEY)) {
|
||||
LinkAddress linkAddr = new LinkAddress(
|
||||
NetworkUtils.numericToInetAddress(in.readUTF()), in.readInt());
|
||||
LinkAddress linkAddr =
|
||||
new LinkAddress(
|
||||
InetAddresses.parseNumericAddress(in.readUTF()),
|
||||
in.readInt());
|
||||
if (linkAddr.getAddress() instanceof Inet4Address &&
|
||||
staticIpConfiguration.ipAddress == null) {
|
||||
staticIpConfiguration.ipAddress = linkAddr;
|
||||
@@ -297,7 +299,7 @@ public class IpConfigStore {
|
||||
InetAddress gateway = null;
|
||||
if (version == 1) {
|
||||
// only supported default gateways - leave the dest/prefix empty
|
||||
gateway = NetworkUtils.numericToInetAddress(in.readUTF());
|
||||
gateway = InetAddresses.parseNumericAddress(in.readUTF());
|
||||
if (staticIpConfiguration.gateway == null) {
|
||||
staticIpConfiguration.gateway = gateway;
|
||||
} else {
|
||||
@@ -305,12 +307,13 @@ public class IpConfigStore {
|
||||
}
|
||||
} else {
|
||||
if (in.readInt() == 1) {
|
||||
dest = new LinkAddress(
|
||||
NetworkUtils.numericToInetAddress(in.readUTF()),
|
||||
in.readInt());
|
||||
dest =
|
||||
new LinkAddress(
|
||||
InetAddresses.parseNumericAddress(in.readUTF()),
|
||||
in.readInt());
|
||||
}
|
||||
if (in.readInt() == 1) {
|
||||
gateway = NetworkUtils.numericToInetAddress(in.readUTF());
|
||||
gateway = InetAddresses.parseNumericAddress(in.readUTF());
|
||||
}
|
||||
RouteInfo route = new RouteInfo(dest, gateway);
|
||||
if (route.isIPv4Default() &&
|
||||
@@ -322,7 +325,7 @@ public class IpConfigStore {
|
||||
}
|
||||
} else if (key.equals(DNS_KEY)) {
|
||||
staticIpConfiguration.dnsServers.add(
|
||||
NetworkUtils.numericToInetAddress(in.readUTF()));
|
||||
InetAddresses.parseNumericAddress(in.readUTF()));
|
||||
} else if (key.equals(PROXY_SETTINGS_KEY)) {
|
||||
proxySettings = ProxySettings.valueOf(in.readUTF());
|
||||
} else if (key.equals(PROXY_HOST_KEY)) {
|
||||
|
||||
@@ -20,11 +20,11 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import android.net.InetAddresses;
|
||||
import android.net.IpConfiguration;
|
||||
import android.net.IpConfiguration.IpAssignment;
|
||||
import android.net.IpConfiguration.ProxySettings;
|
||||
import android.net.LinkAddress;
|
||||
import android.net.NetworkUtils;
|
||||
import android.net.ProxyInfo;
|
||||
import android.net.StaticIpConfiguration;
|
||||
import android.util.ArrayMap;
|
||||
@@ -79,8 +79,8 @@ public class IpConfigStoreTest {
|
||||
|
||||
StaticIpConfiguration staticIpConfiguration = new StaticIpConfiguration();
|
||||
staticIpConfiguration.ipAddress = new LinkAddress(IP_ADDR_1);
|
||||
staticIpConfiguration.dnsServers.add(NetworkUtils.numericToInetAddress(DNS_IP_ADDR_1));
|
||||
staticIpConfiguration.dnsServers.add(NetworkUtils.numericToInetAddress(DNS_IP_ADDR_2));
|
||||
staticIpConfiguration.dnsServers.add(InetAddresses.parseNumericAddress(DNS_IP_ADDR_1));
|
||||
staticIpConfiguration.dnsServers.add(InetAddresses.parseNumericAddress(DNS_IP_ADDR_2));
|
||||
|
||||
ProxyInfo proxyInfo = new ProxyInfo("10.10.10.10", 88, "host1,host2");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user