summaryrefslogtreecommitdiffstats
path: root/core/java/android/net/LinkProperties.java
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2013-07-31 23:23:21 +0900
committerLorenzo Colitti <lorenzo@google.com>2013-08-01 00:21:24 +0900
commitd1e0fae2bc5c98b1f00b185d7be7219dc7e1d0f7 (patch)
treefeef126920387019ec91d149ba91ead0ceb8b96b /core/java/android/net/LinkProperties.java
parenta1510c9849d527021b9f14ed3d451bfa8d5f1506 (diff)
downloadframeworks_base-d1e0fae2bc5c98b1f00b185d7be7219dc7e1d0f7.zip
frameworks_base-d1e0fae2bc5c98b1f00b185d7be7219dc7e1d0f7.tar.gz
frameworks_base-d1e0fae2bc5c98b1f00b185d7be7219dc7e1d0f7.tar.bz2
Add accessors for all addresses and clarify compare* methods
1. Add a method to return all addresses and all LinkAddresses on all links (both base links and stacked links). We already had one for routes, but did not yet have any for addresses. 2. Rename compareRoutes to compareAllRoutes, because unlike the other compare* methods, it looks at all interfaces. Update what appears to be its only caller. 3. Update the documentation of the compare* methods to match reality (they don't return lists) and clarify whether they look at all links or only the base link. Change-Id: Ie22e6c7f163d5de8e407248b45171dc28382d2d3
Diffstat (limited to 'core/java/android/net/LinkProperties.java')
-rw-r--r--core/java/android/net/LinkProperties.java64
1 files changed, 45 insertions, 19 deletions
diff --git a/core/java/android/net/LinkProperties.java b/core/java/android/net/LinkProperties.java
index 75f8b59..6ab810c 100644
--- a/core/java/android/net/LinkProperties.java
+++ b/core/java/android/net/LinkProperties.java
@@ -128,6 +128,9 @@ public class LinkProperties implements Parcelable {
return interfaceNames;
}
+ /**
+ * Returns all the addresses on this link.
+ */
public Collection<InetAddress> getAddresses() {
Collection<InetAddress> addresses = new ArrayList<InetAddress>();
for (LinkAddress linkAddress : mLinkAddresses) {
@@ -136,14 +139,43 @@ public class LinkProperties implements Parcelable {
return Collections.unmodifiableCollection(addresses);
}
+ /**
+ * Returns all the addresses on this link and all the links stacked above it.
+ */
+ public Collection<InetAddress> getAllAddresses() {
+ Collection<InetAddress> addresses = new ArrayList<InetAddress>();
+ for (LinkAddress linkAddress : mLinkAddresses) {
+ addresses.add(linkAddress.getAddress());
+ }
+ for (LinkProperties stacked: mStackedLinks.values()) {
+ addresses.addAll(stacked.getAllAddresses());
+ }
+ return addresses;
+ }
+
public void addLinkAddress(LinkAddress address) {
if (address != null) mLinkAddresses.add(address);
}
+ /**
+ * Returns all the addresses on this link.
+ */
public Collection<LinkAddress> getLinkAddresses() {
return Collections.unmodifiableCollection(mLinkAddresses);
}
+ /**
+ * Returns all the addresses on this link and all the links stacked above it.
+ */
+ public Collection<LinkAddress> getAllLinkAddresses() {
+ Collection<LinkAddress> addresses = new ArrayList<LinkAddress>();
+ addresses.addAll(mLinkAddresses);
+ for (LinkProperties stacked: mStackedLinks.values()) {
+ addresses.addAll(stacked.getAllLinkAddresses());
+ }
+ return addresses;
+ }
+
public void addDns(InetAddress dns) {
if (dns != null) mDnses.add(dns);
}
@@ -426,13 +458,11 @@ public class LinkProperties implements Parcelable {
}
/**
- * Return two lists, a list of addresses that would be removed from
- * mLinkAddresses and a list of addresses that would be added to
- * mLinkAddress which would then result in target and mLinkAddresses
- * being the same list.
+ * Compares the addresses in this LinkProperties with another
+ * LinkProperties, examining only addresses on the base link.
*
- * @param target is a LinkProperties with the new list of addresses
- * @return the removed and added lists.
+ * @param target a LinkProperties with the new list of addresses
+ * @return the differences between the addresses.
*/
public CompareResult<LinkAddress> compareAddresses(LinkProperties target) {
/*
@@ -456,13 +486,11 @@ public class LinkProperties implements Parcelable {
}
/**
- * Return two lists, a list of dns addresses that would be removed from
- * mDnses and a list of addresses that would be added to
- * mDnses which would then result in target and mDnses
- * being the same list.
+ * Compares the DNS addresses in this LinkProperties with another
+ * LinkProperties, examining only DNS addresses on the base link.
*
- * @param target is a LinkProperties with the new list of dns addresses
- * @return the removed and added lists.
+ * @param target a LinkProperties with the new list of dns addresses
+ * @return the differences between the DNS addresses.
*/
public CompareResult<InetAddress> compareDnses(LinkProperties target) {
/*
@@ -487,15 +515,13 @@ public class LinkProperties implements Parcelable {
}
/**
- * Return two lists, a list of routes that would be removed from
- * mRoutes and a list of routes that would be added to
- * mRoutes which would then result in target and mRoutes
- * being the same list.
+ * Compares all routes in this LinkProperties with another LinkProperties,
+ * examining both the the base link and all stacked links.
*
- * @param target is a LinkProperties with the new list of routes
- * @return the removed and added lists.
+ * @param target a LinkProperties with the new list of routes
+ * @return the differences between the routes.
*/
- public CompareResult<RouteInfo> compareRoutes(LinkProperties target) {
+ public CompareResult<RouteInfo> compareAllRoutes(LinkProperties target) {
/*
* Duplicate the RouteInfos into removed, we will be removing
* routes which are common between mRoutes and target