Fix public API of LinkProperties.
bug:15142362 Change-Id: I1457111da7d3bd09998f7e010febb8bb4c45c8bc
This commit is contained in:
@@ -30,6 +30,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Describes the properties of a network link.
|
* Describes the properties of a network link.
|
||||||
@@ -58,10 +59,12 @@ public class LinkProperties implements Parcelable {
|
|||||||
private Hashtable<String, LinkProperties> mStackedLinks =
|
private Hashtable<String, LinkProperties> mStackedLinks =
|
||||||
new Hashtable<String, LinkProperties>();
|
new Hashtable<String, LinkProperties>();
|
||||||
|
|
||||||
// @hide
|
/**
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
public static class CompareResult<T> {
|
public static class CompareResult<T> {
|
||||||
public Collection<T> removed = new ArrayList<T>();
|
public List<T> removed = new ArrayList<T>();
|
||||||
public Collection<T> added = new ArrayList<T>();
|
public List<T> added = new ArrayList<T>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
@@ -81,7 +84,7 @@ public class LinkProperties implements Parcelable {
|
|||||||
if (source != null) {
|
if (source != null) {
|
||||||
mIfaceName = source.getInterfaceName();
|
mIfaceName = source.getInterfaceName();
|
||||||
for (LinkAddress l : source.getLinkAddresses()) mLinkAddresses.add(l);
|
for (LinkAddress l : source.getLinkAddresses()) mLinkAddresses.add(l);
|
||||||
for (InetAddress i : source.getDnses()) mDnses.add(i);
|
for (InetAddress i : source.getDnsServers()) mDnses.add(i);
|
||||||
mDomains = source.getDomains();
|
mDomains = source.getDomains();
|
||||||
for (RouteInfo r : source.getRoutes()) mRoutes.add(r);
|
for (RouteInfo r : source.getRoutes()) mRoutes.add(r);
|
||||||
mHttpProxy = (source.getHttpProxy() == null) ?
|
mHttpProxy = (source.getHttpProxy() == null) ?
|
||||||
@@ -98,6 +101,7 @@ public class LinkProperties implements Parcelable {
|
|||||||
* will have their interface changed to match this new value.
|
* will have their interface changed to match this new value.
|
||||||
*
|
*
|
||||||
* @param iface The name of the network interface used for this link.
|
* @param iface The name of the network interface used for this link.
|
||||||
|
* @hide
|
||||||
*/
|
*/
|
||||||
public void setInterfaceName(String iface) {
|
public void setInterfaceName(String iface) {
|
||||||
mIfaceName = iface;
|
mIfaceName = iface;
|
||||||
@@ -117,9 +121,11 @@ public class LinkProperties implements Parcelable {
|
|||||||
return mIfaceName;
|
return mIfaceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @hide
|
/**
|
||||||
public Collection<String> getAllInterfaceNames() {
|
* @hide
|
||||||
Collection interfaceNames = new ArrayList<String>(mStackedLinks.size() + 1);
|
*/
|
||||||
|
public List<String> getAllInterfaceNames() {
|
||||||
|
List<String> interfaceNames = new ArrayList<String>(mStackedLinks.size() + 1);
|
||||||
if (mIfaceName != null) interfaceNames.add(new String(mIfaceName));
|
if (mIfaceName != null) interfaceNames.add(new String(mIfaceName));
|
||||||
for (LinkProperties stacked: mStackedLinks.values()) {
|
for (LinkProperties stacked: mStackedLinks.values()) {
|
||||||
interfaceNames.addAll(stacked.getAllInterfaceNames());
|
interfaceNames.addAll(stacked.getAllInterfaceNames());
|
||||||
@@ -134,23 +140,23 @@ public class LinkProperties implements Parcelable {
|
|||||||
* prefix lengths for each address. This is a simplified utility alternative to
|
* prefix lengths for each address. This is a simplified utility alternative to
|
||||||
* {@link LinkProperties#getLinkAddresses}.
|
* {@link LinkProperties#getLinkAddresses}.
|
||||||
*
|
*
|
||||||
* @return An umodifiable {@link Collection} of {@link InetAddress} for this link.
|
* @return An umodifiable {@link List} of {@link InetAddress} for this link.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public Collection<InetAddress> getAddresses() {
|
public List<InetAddress> getAddresses() {
|
||||||
Collection<InetAddress> addresses = new ArrayList<InetAddress>();
|
List<InetAddress> addresses = new ArrayList<InetAddress>();
|
||||||
for (LinkAddress linkAddress : mLinkAddresses) {
|
for (LinkAddress linkAddress : mLinkAddresses) {
|
||||||
addresses.add(linkAddress.getAddress());
|
addresses.add(linkAddress.getAddress());
|
||||||
}
|
}
|
||||||
return Collections.unmodifiableCollection(addresses);
|
return Collections.unmodifiableList(addresses);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all the addresses on this link and all the links stacked above it.
|
* Returns all the addresses on this link and all the links stacked above it.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public Collection<InetAddress> getAllAddresses() {
|
public List<InetAddress> getAllAddresses() {
|
||||||
Collection<InetAddress> addresses = new ArrayList<InetAddress>();
|
List<InetAddress> addresses = new ArrayList<InetAddress>();
|
||||||
for (LinkAddress linkAddress : mLinkAddresses) {
|
for (LinkAddress linkAddress : mLinkAddresses) {
|
||||||
addresses.add(linkAddress.getAddress());
|
addresses.add(linkAddress.getAddress());
|
||||||
}
|
}
|
||||||
@@ -174,6 +180,7 @@ public class LinkProperties implements Parcelable {
|
|||||||
* same address/prefix does not already exist. If it does exist it is replaced.
|
* same address/prefix does not already exist. If it does exist it is replaced.
|
||||||
* @param address The {@code LinkAddress} to add.
|
* @param address The {@code LinkAddress} to add.
|
||||||
* @return true if {@code address} was added or updated, false otherwise.
|
* @return true if {@code address} was added or updated, false otherwise.
|
||||||
|
* @hide
|
||||||
*/
|
*/
|
||||||
public boolean addLinkAddress(LinkAddress address) {
|
public boolean addLinkAddress(LinkAddress address) {
|
||||||
if (address == null) {
|
if (address == null) {
|
||||||
@@ -200,6 +207,7 @@ public class LinkProperties implements Parcelable {
|
|||||||
*
|
*
|
||||||
* @param toRemove A {@link LinkAddress} specifying the address to remove.
|
* @param toRemove A {@link LinkAddress} specifying the address to remove.
|
||||||
* @return true if the address was removed, false if it did not exist.
|
* @return true if the address was removed, false if it did not exist.
|
||||||
|
* @hide
|
||||||
*/
|
*/
|
||||||
public boolean removeLinkAddress(LinkAddress toRemove) {
|
public boolean removeLinkAddress(LinkAddress toRemove) {
|
||||||
int i = findLinkAddressIndex(toRemove);
|
int i = findLinkAddressIndex(toRemove);
|
||||||
@@ -214,18 +222,18 @@ public class LinkProperties implements Parcelable {
|
|||||||
* Returns all the {@link LinkAddress} on this link. Typically a link will have
|
* Returns all the {@link LinkAddress} on this link. Typically a link will have
|
||||||
* one IPv4 address and one or more IPv6 addresses.
|
* one IPv4 address and one or more IPv6 addresses.
|
||||||
*
|
*
|
||||||
* @return An unmodifiable {@link Collection} of {@link LinkAddress} for this link.
|
* @return An unmodifiable {@link List} of {@link LinkAddress} for this link.
|
||||||
*/
|
*/
|
||||||
public Collection<LinkAddress> getLinkAddresses() {
|
public List<LinkAddress> getLinkAddresses() {
|
||||||
return Collections.unmodifiableCollection(mLinkAddresses);
|
return Collections.unmodifiableList(mLinkAddresses);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all the addresses on this link and all the links stacked above it.
|
* Returns all the addresses on this link and all the links stacked above it.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public Collection<LinkAddress> getAllLinkAddresses() {
|
public List<LinkAddress> getAllLinkAddresses() {
|
||||||
Collection<LinkAddress> addresses = new ArrayList<LinkAddress>();
|
List<LinkAddress> addresses = new ArrayList<LinkAddress>();
|
||||||
addresses.addAll(mLinkAddresses);
|
addresses.addAll(mLinkAddresses);
|
||||||
for (LinkProperties stacked: mStackedLinks.values()) {
|
for (LinkProperties stacked: mStackedLinks.values()) {
|
||||||
addresses.addAll(stacked.getAllLinkAddresses());
|
addresses.addAll(stacked.getAllLinkAddresses());
|
||||||
@@ -239,6 +247,7 @@ public class LinkProperties implements Parcelable {
|
|||||||
*
|
*
|
||||||
* @param addresses The {@link Collection} of {@link LinkAddress} to set in this
|
* @param addresses The {@link Collection} of {@link LinkAddress} to set in this
|
||||||
* object.
|
* object.
|
||||||
|
* @hide
|
||||||
*/
|
*/
|
||||||
public void setLinkAddresses(Collection<LinkAddress> addresses) {
|
public void setLinkAddresses(Collection<LinkAddress> addresses) {
|
||||||
mLinkAddresses.clear();
|
mLinkAddresses.clear();
|
||||||
@@ -250,20 +259,21 @@ public class LinkProperties implements Parcelable {
|
|||||||
/**
|
/**
|
||||||
* Adds the given {@link InetAddress} to the list of DNS servers.
|
* Adds the given {@link InetAddress} to the list of DNS servers.
|
||||||
*
|
*
|
||||||
* @param dns The {@link InetAddress} to add to the list of DNS servers.
|
* @param dnsServer The {@link InetAddress} to add to the list of DNS servers.
|
||||||
|
* @hide
|
||||||
*/
|
*/
|
||||||
public void addDns(InetAddress dns) {
|
public void addDnsServer(InetAddress dnsServer) {
|
||||||
if (dns != null) mDnses.add(dns);
|
if (dnsServer != null) mDnses.add(dnsServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all the {@link LinkAddress} for DNS servers on this link.
|
* Returns all the {@link LinkAddress} for DNS servers on this link.
|
||||||
*
|
*
|
||||||
* @return An umodifiable {@link Collection} of {@link InetAddress} for DNS servers on
|
* @return An umodifiable {@link List} of {@link InetAddress} for DNS servers on
|
||||||
* this link.
|
* this link.
|
||||||
*/
|
*/
|
||||||
public Collection<InetAddress> getDnses() {
|
public List<InetAddress> getDnsServers() {
|
||||||
return Collections.unmodifiableCollection(mDnses);
|
return Collections.unmodifiableList(mDnses);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -271,6 +281,7 @@ public class LinkProperties implements Parcelable {
|
|||||||
*
|
*
|
||||||
* @param domains A {@link String} listing in priority order the comma separated
|
* @param domains A {@link String} listing in priority order the comma separated
|
||||||
* domains to search when resolving host names on this link.
|
* domains to search when resolving host names on this link.
|
||||||
|
* @hide
|
||||||
*/
|
*/
|
||||||
public void setDomains(String domains) {
|
public void setDomains(String domains) {
|
||||||
mDomains = domains;
|
mDomains = domains;
|
||||||
@@ -323,6 +334,7 @@ public class LinkProperties implements Parcelable {
|
|||||||
* proper course is to add either un-named or properly named {@link RouteInfo}.
|
* proper course is to add either un-named or properly named {@link RouteInfo}.
|
||||||
*
|
*
|
||||||
* @param route A {@link RouteInfo} to add to this object.
|
* @param route A {@link RouteInfo} to add to this object.
|
||||||
|
* @hide
|
||||||
*/
|
*/
|
||||||
public void addRoute(RouteInfo route) {
|
public void addRoute(RouteInfo route) {
|
||||||
if (route != null) {
|
if (route != null) {
|
||||||
@@ -339,18 +351,18 @@ public class LinkProperties implements Parcelable {
|
|||||||
/**
|
/**
|
||||||
* Returns all the {@link RouteInfo} set on this link.
|
* Returns all the {@link RouteInfo} set on this link.
|
||||||
*
|
*
|
||||||
* @return An unmodifiable {@link Collection} of {@link RouteInfo} for this link.
|
* @return An unmodifiable {@link List} of {@link RouteInfo} for this link.
|
||||||
*/
|
*/
|
||||||
public Collection<RouteInfo> getRoutes() {
|
public List<RouteInfo> getRoutes() {
|
||||||
return Collections.unmodifiableCollection(mRoutes);
|
return Collections.unmodifiableList(mRoutes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all the routes on this link and all the links stacked above it.
|
* Returns all the routes on this link and all the links stacked above it.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public Collection<RouteInfo> getAllRoutes() {
|
public List<RouteInfo> getAllRoutes() {
|
||||||
Collection<RouteInfo> routes = new ArrayList();
|
List<RouteInfo> routes = new ArrayList();
|
||||||
routes.addAll(mRoutes);
|
routes.addAll(mRoutes);
|
||||||
for (LinkProperties stacked: mStackedLinks.values()) {
|
for (LinkProperties stacked: mStackedLinks.values()) {
|
||||||
routes.addAll(stacked.getAllRoutes());
|
routes.addAll(stacked.getAllRoutes());
|
||||||
@@ -364,6 +376,7 @@ public class LinkProperties implements Parcelable {
|
|||||||
* not enforce it and applications may ignore them.
|
* not enforce it and applications may ignore them.
|
||||||
*
|
*
|
||||||
* @param proxy A {@link ProxyInfo} defining the Http Proxy to use on this link.
|
* @param proxy A {@link ProxyInfo} defining the Http Proxy to use on this link.
|
||||||
|
* @hide
|
||||||
*/
|
*/
|
||||||
public void setHttpProxy(ProxyInfo proxy) {
|
public void setHttpProxy(ProxyInfo proxy) {
|
||||||
mHttpProxy = proxy;
|
mHttpProxy = proxy;
|
||||||
@@ -419,16 +432,17 @@ public class LinkProperties implements Parcelable {
|
|||||||
* Returns all the links stacked on top of this link.
|
* Returns all the links stacked on top of this link.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public Collection<LinkProperties> getStackedLinks() {
|
public List<LinkProperties> getStackedLinks() {
|
||||||
Collection<LinkProperties> stacked = new ArrayList<LinkProperties>();
|
List<LinkProperties> stacked = new ArrayList<LinkProperties>();
|
||||||
for (LinkProperties link : mStackedLinks.values()) {
|
for (LinkProperties link : mStackedLinks.values()) {
|
||||||
stacked.add(new LinkProperties(link));
|
stacked.add(new LinkProperties(link));
|
||||||
}
|
}
|
||||||
return Collections.unmodifiableCollection(stacked);
|
return Collections.unmodifiableList(stacked);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears this object to its initial state.
|
* Clears this object to its initial state.
|
||||||
|
* @hide
|
||||||
*/
|
*/
|
||||||
public void clear() {
|
public void clear() {
|
||||||
mIfaceName = null;
|
mIfaceName = null;
|
||||||
@@ -486,6 +500,7 @@ public class LinkProperties implements Parcelable {
|
|||||||
* Returns true if this link has an IPv4 address.
|
* Returns true if this link has an IPv4 address.
|
||||||
*
|
*
|
||||||
* @return {@code true} if there is an IPv4 address, {@code false} otherwise.
|
* @return {@code true} if there is an IPv4 address, {@code false} otherwise.
|
||||||
|
* @hide
|
||||||
*/
|
*/
|
||||||
public boolean hasIPv4Address() {
|
public boolean hasIPv4Address() {
|
||||||
for (LinkAddress address : mLinkAddresses) {
|
for (LinkAddress address : mLinkAddresses) {
|
||||||
@@ -500,6 +515,7 @@ public class LinkProperties implements Parcelable {
|
|||||||
* Returns true if this link has an IPv6 address.
|
* Returns true if this link has an IPv6 address.
|
||||||
*
|
*
|
||||||
* @return {@code true} if there is an IPv6 address, {@code false} otherwise.
|
* @return {@code true} if there is an IPv6 address, {@code false} otherwise.
|
||||||
|
* @hide
|
||||||
*/
|
*/
|
||||||
public boolean hasIPv6Address() {
|
public boolean hasIPv6Address() {
|
||||||
for (LinkAddress address : mLinkAddresses) {
|
for (LinkAddress address : mLinkAddresses) {
|
||||||
@@ -543,7 +559,7 @@ public class LinkProperties implements Parcelable {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public boolean isIdenticalDnses(LinkProperties target) {
|
public boolean isIdenticalDnses(LinkProperties target) {
|
||||||
Collection<InetAddress> targetDnses = target.getDnses();
|
Collection<InetAddress> targetDnses = target.getDnsServers();
|
||||||
String targetDomains = target.getDomains();
|
String targetDomains = target.getDomains();
|
||||||
if (mDomains == null) {
|
if (mDomains == null) {
|
||||||
if (targetDomains != null) return false;
|
if (targetDomains != null) return false;
|
||||||
@@ -696,7 +712,7 @@ public class LinkProperties implements Parcelable {
|
|||||||
result.removed = new ArrayList<InetAddress>(mDnses);
|
result.removed = new ArrayList<InetAddress>(mDnses);
|
||||||
result.added.clear();
|
result.added.clear();
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
for (InetAddress newAddress : target.getDnses()) {
|
for (InetAddress newAddress : target.getDnsServers()) {
|
||||||
if (! result.removed.remove(newAddress)) {
|
if (! result.removed.remove(newAddress)) {
|
||||||
result.added.add(newAddress);
|
result.added.add(newAddress);
|
||||||
}
|
}
|
||||||
@@ -831,7 +847,7 @@ public class LinkProperties implements Parcelable {
|
|||||||
addressCount = in.readInt();
|
addressCount = in.readInt();
|
||||||
for (int i=0; i<addressCount; i++) {
|
for (int i=0; i<addressCount; i++) {
|
||||||
try {
|
try {
|
||||||
netProp.addDns(InetAddress.getByAddress(in.createByteArray()));
|
netProp.addDnsServer(InetAddress.getByAddress(in.createByteArray()));
|
||||||
} catch (UnknownHostException e) { }
|
} catch (UnknownHostException e) { }
|
||||||
}
|
}
|
||||||
netProp.setDomains(in.readString());
|
netProp.setDomains(in.readString());
|
||||||
|
|||||||
@@ -88,8 +88,8 @@ public class LinkPropertiesTest extends TestCase {
|
|||||||
source.addLinkAddress(LINKADDRV4);
|
source.addLinkAddress(LINKADDRV4);
|
||||||
source.addLinkAddress(LINKADDRV6);
|
source.addLinkAddress(LINKADDRV6);
|
||||||
// set 2 dnses
|
// set 2 dnses
|
||||||
source.addDns(DNS1);
|
source.addDnsServer(DNS1);
|
||||||
source.addDns(DNS2);
|
source.addDnsServer(DNS2);
|
||||||
// set 2 gateways
|
// set 2 gateways
|
||||||
source.addRoute(new RouteInfo(GATEWAY1));
|
source.addRoute(new RouteInfo(GATEWAY1));
|
||||||
source.addRoute(new RouteInfo(GATEWAY2));
|
source.addRoute(new RouteInfo(GATEWAY2));
|
||||||
@@ -101,8 +101,8 @@ public class LinkPropertiesTest extends TestCase {
|
|||||||
target.setInterfaceName(NAME);
|
target.setInterfaceName(NAME);
|
||||||
target.addLinkAddress(LINKADDRV4);
|
target.addLinkAddress(LINKADDRV4);
|
||||||
target.addLinkAddress(LINKADDRV6);
|
target.addLinkAddress(LINKADDRV6);
|
||||||
target.addDns(DNS1);
|
target.addDnsServer(DNS1);
|
||||||
target.addDns(DNS2);
|
target.addDnsServer(DNS2);
|
||||||
target.addRoute(new RouteInfo(GATEWAY1));
|
target.addRoute(new RouteInfo(GATEWAY1));
|
||||||
target.addRoute(new RouteInfo(GATEWAY2));
|
target.addRoute(new RouteInfo(GATEWAY2));
|
||||||
target.setMtu(MTU);
|
target.setMtu(MTU);
|
||||||
@@ -114,8 +114,8 @@ public class LinkPropertiesTest extends TestCase {
|
|||||||
target.setInterfaceName("qmi1");
|
target.setInterfaceName("qmi1");
|
||||||
target.addLinkAddress(LINKADDRV4);
|
target.addLinkAddress(LINKADDRV4);
|
||||||
target.addLinkAddress(LINKADDRV6);
|
target.addLinkAddress(LINKADDRV6);
|
||||||
target.addDns(DNS1);
|
target.addDnsServer(DNS1);
|
||||||
target.addDns(DNS2);
|
target.addDnsServer(DNS2);
|
||||||
target.addRoute(new RouteInfo(GATEWAY1));
|
target.addRoute(new RouteInfo(GATEWAY1));
|
||||||
target.addRoute(new RouteInfo(GATEWAY2));
|
target.addRoute(new RouteInfo(GATEWAY2));
|
||||||
target.setMtu(MTU);
|
target.setMtu(MTU);
|
||||||
@@ -127,8 +127,8 @@ public class LinkPropertiesTest extends TestCase {
|
|||||||
target.addLinkAddress(new LinkAddress(
|
target.addLinkAddress(new LinkAddress(
|
||||||
NetworkUtils.numericToInetAddress("75.208.6.2"), 32));
|
NetworkUtils.numericToInetAddress("75.208.6.2"), 32));
|
||||||
target.addLinkAddress(LINKADDRV6);
|
target.addLinkAddress(LINKADDRV6);
|
||||||
target.addDns(DNS1);
|
target.addDnsServer(DNS1);
|
||||||
target.addDns(DNS2);
|
target.addDnsServer(DNS2);
|
||||||
target.addRoute(new RouteInfo(GATEWAY1));
|
target.addRoute(new RouteInfo(GATEWAY1));
|
||||||
target.addRoute(new RouteInfo(GATEWAY2));
|
target.addRoute(new RouteInfo(GATEWAY2));
|
||||||
target.setMtu(MTU);
|
target.setMtu(MTU);
|
||||||
@@ -139,8 +139,8 @@ public class LinkPropertiesTest extends TestCase {
|
|||||||
target.addLinkAddress(LINKADDRV4);
|
target.addLinkAddress(LINKADDRV4);
|
||||||
target.addLinkAddress(LINKADDRV6);
|
target.addLinkAddress(LINKADDRV6);
|
||||||
// change dnses
|
// change dnses
|
||||||
target.addDns(NetworkUtils.numericToInetAddress("75.208.7.2"));
|
target.addDnsServer(NetworkUtils.numericToInetAddress("75.208.7.2"));
|
||||||
target.addDns(DNS2);
|
target.addDnsServer(DNS2);
|
||||||
target.addRoute(new RouteInfo(GATEWAY1));
|
target.addRoute(new RouteInfo(GATEWAY1));
|
||||||
target.addRoute(new RouteInfo(GATEWAY2));
|
target.addRoute(new RouteInfo(GATEWAY2));
|
||||||
target.setMtu(MTU);
|
target.setMtu(MTU);
|
||||||
@@ -150,8 +150,8 @@ public class LinkPropertiesTest extends TestCase {
|
|||||||
target.setInterfaceName(NAME);
|
target.setInterfaceName(NAME);
|
||||||
target.addLinkAddress(LINKADDRV4);
|
target.addLinkAddress(LINKADDRV4);
|
||||||
target.addLinkAddress(LINKADDRV6);
|
target.addLinkAddress(LINKADDRV6);
|
||||||
target.addDns(DNS1);
|
target.addDnsServer(DNS1);
|
||||||
target.addDns(DNS2);
|
target.addDnsServer(DNS2);
|
||||||
// change gateway
|
// change gateway
|
||||||
target.addRoute(new RouteInfo(NetworkUtils.numericToInetAddress("75.208.8.2")));
|
target.addRoute(new RouteInfo(NetworkUtils.numericToInetAddress("75.208.8.2")));
|
||||||
target.addRoute(new RouteInfo(GATEWAY2));
|
target.addRoute(new RouteInfo(GATEWAY2));
|
||||||
@@ -162,8 +162,8 @@ public class LinkPropertiesTest extends TestCase {
|
|||||||
target.setInterfaceName(NAME);
|
target.setInterfaceName(NAME);
|
||||||
target.addLinkAddress(LINKADDRV4);
|
target.addLinkAddress(LINKADDRV4);
|
||||||
target.addLinkAddress(LINKADDRV6);
|
target.addLinkAddress(LINKADDRV6);
|
||||||
target.addDns(DNS1);
|
target.addDnsServer(DNS1);
|
||||||
target.addDns(DNS2);
|
target.addDnsServer(DNS2);
|
||||||
target.addRoute(new RouteInfo(GATEWAY1));
|
target.addRoute(new RouteInfo(GATEWAY1));
|
||||||
target.addRoute(new RouteInfo(GATEWAY2));
|
target.addRoute(new RouteInfo(GATEWAY2));
|
||||||
// change mtu
|
// change mtu
|
||||||
@@ -185,8 +185,8 @@ public class LinkPropertiesTest extends TestCase {
|
|||||||
source.addLinkAddress(LINKADDRV4);
|
source.addLinkAddress(LINKADDRV4);
|
||||||
source.addLinkAddress(LINKADDRV6);
|
source.addLinkAddress(LINKADDRV6);
|
||||||
// set 2 dnses
|
// set 2 dnses
|
||||||
source.addDns(DNS1);
|
source.addDnsServer(DNS1);
|
||||||
source.addDns(DNS2);
|
source.addDnsServer(DNS2);
|
||||||
// set 2 gateways
|
// set 2 gateways
|
||||||
source.addRoute(new RouteInfo(GATEWAY1));
|
source.addRoute(new RouteInfo(GATEWAY1));
|
||||||
source.addRoute(new RouteInfo(GATEWAY2));
|
source.addRoute(new RouteInfo(GATEWAY2));
|
||||||
@@ -197,8 +197,8 @@ public class LinkPropertiesTest extends TestCase {
|
|||||||
target.setInterfaceName(NAME);
|
target.setInterfaceName(NAME);
|
||||||
target.addLinkAddress(LINKADDRV6);
|
target.addLinkAddress(LINKADDRV6);
|
||||||
target.addLinkAddress(LINKADDRV4);
|
target.addLinkAddress(LINKADDRV4);
|
||||||
target.addDns(DNS2);
|
target.addDnsServer(DNS2);
|
||||||
target.addDns(DNS1);
|
target.addDnsServer(DNS1);
|
||||||
target.addRoute(new RouteInfo(GATEWAY2));
|
target.addRoute(new RouteInfo(GATEWAY2));
|
||||||
target.addRoute(new RouteInfo(GATEWAY1));
|
target.addRoute(new RouteInfo(GATEWAY1));
|
||||||
target.setMtu(MTU);
|
target.setMtu(MTU);
|
||||||
|
|||||||
@@ -2691,7 +2691,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
dnsDiff = curLp.compareDnses(newLp);
|
dnsDiff = curLp.compareDnses(newLp);
|
||||||
} else if (newLp != null) {
|
} else if (newLp != null) {
|
||||||
routeDiff.added = newLp.getAllRoutes();
|
routeDiff.added = newLp.getAllRoutes();
|
||||||
dnsDiff.added = newLp.getDnses();
|
dnsDiff.added = newLp.getDnsServers();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean routesChanged = (routeDiff.removed.size() != 0 || routeDiff.added.size() != 0);
|
boolean routesChanged = (routeDiff.removed.size() != 0 || routeDiff.added.size() != 0);
|
||||||
@@ -2915,7 +2915,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
if (nt != null && nt.getNetworkInfo().isConnected() && !nt.isTeardownRequested()) {
|
if (nt != null && nt.getNetworkInfo().isConnected() && !nt.isTeardownRequested()) {
|
||||||
LinkProperties p = nt.getLinkProperties();
|
LinkProperties p = nt.getLinkProperties();
|
||||||
if (p == null) return;
|
if (p == null) return;
|
||||||
Collection<InetAddress> dnses = p.getDnses();
|
Collection<InetAddress> dnses = p.getDnsServers();
|
||||||
int netId = nt.getNetwork().netId;
|
int netId = nt.getNetwork().netId;
|
||||||
if (mNetConfigs[netType].isDefault()) {
|
if (mNetConfigs[netType].isDefault()) {
|
||||||
String network = nt.getNetworkInfo().getTypeName();
|
String network = nt.getNetworkInfo().getTypeName();
|
||||||
@@ -5625,7 +5625,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
}
|
}
|
||||||
private void updateDnses(LinkProperties newLp, LinkProperties oldLp, int netId) {
|
private void updateDnses(LinkProperties newLp, LinkProperties oldLp, int netId) {
|
||||||
if (oldLp == null || (newLp.isIdenticalDnses(oldLp) == false)) {
|
if (oldLp == null || (newLp.isIdenticalDnses(oldLp) == false)) {
|
||||||
Collection<InetAddress> dnses = newLp.getDnses();
|
Collection<InetAddress> dnses = newLp.getDnsServers();
|
||||||
if (dnses.size() == 0 && mDefaultDns != null) {
|
if (dnses.size() == 0 && mDefaultDns != null) {
|
||||||
dnses = new ArrayList();
|
dnses = new ArrayList();
|
||||||
dnses.add(mDefaultDns);
|
dnses.add(mDefaultDns);
|
||||||
@@ -5790,7 +5790,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
isNewDefault = true;
|
isNewDefault = true;
|
||||||
updateActiveDefaultNetwork(newNetwork);
|
updateActiveDefaultNetwork(newNetwork);
|
||||||
if (newNetwork.linkProperties != null) {
|
if (newNetwork.linkProperties != null) {
|
||||||
setDefaultDnsSystemProperties(newNetwork.linkProperties.getDnses());
|
setDefaultDnsSystemProperties(
|
||||||
|
newNetwork.linkProperties.getDnsServers());
|
||||||
} else {
|
} else {
|
||||||
setDefaultDnsSystemProperties(new ArrayList<InetAddress>());
|
setDefaultDnsSystemProperties(new ArrayList<InetAddress>());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user