summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorErik Kline <ek@google.com>2014-10-28 08:54:03 +0000
committerandroid-build-merger <android-build-merger@google.com>2014-10-28 08:54:03 +0000
commite9810e8d532d87d23d3824d6165824a2da0cfee9 (patch)
treebae0261489cb8bc5225fab74d4d27fb23fc7c538 /core
parent9d6f408ab5a3fc12a1cae2ffba928c79df74739c (diff)
parent8fc600d1a8fc4f9cedceee185d129a19b06001c5 (diff)
downloadframeworks_base-e9810e8d532d87d23d3824d6165824a2da0cfee9.zip
frameworks_base-e9810e8d532d87d23d3824d6165824a2da0cfee9.tar.gz
frameworks_base-e9810e8d532d87d23d3824d6165824a2da0cfee9.tar.bz2
Merge "(re)define the definition of "provisioned"" into lmp-mr1-dev automerge: dd91fb4
automerge: 8fc600d * commit '8fc600d1a8fc4f9cedceee185d129a19b06001c5': (re)define the definition of "provisioned"
Diffstat (limited to 'core')
-rw-r--r--core/java/android/net/LinkProperties.java33
-rw-r--r--core/tests/coretests/src/android/net/LinkPropertiesTest.java45
2 files changed, 72 insertions, 6 deletions
diff --git a/core/java/android/net/LinkProperties.java b/core/java/android/net/LinkProperties.java
index ef731b6..8b0dfc9 100644
--- a/core/java/android/net/LinkProperties.java
+++ b/core/java/android/net/LinkProperties.java
@@ -675,17 +675,38 @@ public final class LinkProperties implements Parcelable {
}
/**
- * Returns true if this link is provisioned for global connectivity. For IPv6, this requires an
- * IP address, default route, and DNS server. For IPv4, this requires only an IPv4 address,
- * because WifiStateMachine accepts static configurations that only specify an address but not
- * DNS servers or a default route.
+ * Returns true if this link is provisioned for global IPv4 connectivity.
+ * This requires an IP address, default route, and DNS server.
+ *
+ * @return {@code true} if the link is provisioned, {@code false} otherwise.
+ */
+ private boolean hasIPv4() {
+ return (hasIPv4Address() &&
+ hasIPv4DefaultRoute() &&
+ hasIPv4DnsServer());
+ }
+
+ /**
+ * Returns true if this link is provisioned for global IPv6 connectivity.
+ * This requires an IP address, default route, and DNS server.
+ *
+ * @return {@code true} if the link is provisioned, {@code false} otherwise.
+ */
+ private boolean hasIPv6() {
+ return (hasGlobalIPv6Address() &&
+ hasIPv6DefaultRoute() &&
+ hasIPv6DnsServer());
+ }
+
+ /**
+ * Returns true if this link is provisioned for global connectivity,
+ * for at least one Internet Protocol family.
*
* @return {@code true} if the link is provisioned, {@code false} otherwise.
* @hide
*/
public boolean isProvisioned() {
- return (hasIPv4Address() ||
- (hasGlobalIPv6Address() && hasIPv6DefaultRoute() && hasIPv6DnsServer()));
+ return (hasIPv4() || hasIPv6());
}
/**
diff --git a/core/tests/coretests/src/android/net/LinkPropertiesTest.java b/core/tests/coretests/src/android/net/LinkPropertiesTest.java
index 5b1a59c..abfed6e 100644
--- a/core/tests/coretests/src/android/net/LinkPropertiesTest.java
+++ b/core/tests/coretests/src/android/net/LinkPropertiesTest.java
@@ -31,8 +31,10 @@ public class LinkPropertiesTest extends TestCase {
"2001:0db8:85a3:0000:0000:8a2e:0370:7334");
private static InetAddress DNS1 = NetworkUtils.numericToInetAddress("75.208.7.1");
private static InetAddress DNS2 = NetworkUtils.numericToInetAddress("69.78.7.1");
+ private static InetAddress DNS6 = NetworkUtils.numericToInetAddress("2001:4860:4860::8888");
private static InetAddress GATEWAY1 = NetworkUtils.numericToInetAddress("75.208.8.1");
private static InetAddress GATEWAY2 = NetworkUtils.numericToInetAddress("69.78.8.1");
+ private static InetAddress GATEWAY6 = NetworkUtils.numericToInetAddress("fe80::6:0000:613");
private static String NAME = "qmi0";
private static int MTU = 1500;
@@ -453,4 +455,47 @@ public class LinkPropertiesTest extends TestCase {
lp2.setLinkAddresses(lp.getLinkAddresses());
assertTrue(lp.equals(lp));
}
+
+ @SmallTest
+ public void testIsProvisioned() {
+ LinkProperties lp4 = new LinkProperties();
+ assertFalse("v4only:empty", lp4.isProvisioned());
+ lp4.addLinkAddress(LINKADDRV4);
+ assertFalse("v4only:addr-only", lp4.isProvisioned());
+ lp4.addDnsServer(DNS1);
+ assertFalse("v4only:addr+dns", lp4.isProvisioned());
+ lp4.addRoute(new RouteInfo(GATEWAY1));
+ assertTrue("v4only:addr+dns+route", lp4.isProvisioned());
+
+ LinkProperties lp6 = new LinkProperties();
+ assertFalse("v6only:empty", lp6.isProvisioned());
+ lp6.addLinkAddress(LINKADDRV6LINKLOCAL);
+ assertFalse("v6only:fe80-only", lp6.isProvisioned());
+ lp6.addDnsServer(DNS6);
+ assertFalse("v6only:fe80+dns", lp6.isProvisioned());
+ lp6.addRoute(new RouteInfo(GATEWAY6));
+ assertFalse("v6only:fe80+dns+route", lp6.isProvisioned());
+ lp6.addLinkAddress(LINKADDRV6);
+ assertTrue("v6only:fe80+global+dns+route", lp6.isProvisioned());
+ lp6.removeLinkAddress(LINKADDRV6LINKLOCAL);
+ assertTrue("v6only:global+dns+route", lp6.isProvisioned());
+
+ LinkProperties lp46 = new LinkProperties();
+ lp46.addLinkAddress(LINKADDRV4);
+ lp46.addLinkAddress(LINKADDRV6);
+ lp46.addDnsServer(DNS1);
+ lp46.addDnsServer(DNS6);
+ assertFalse("dualstack:missing-routes", lp46.isProvisioned());
+ lp46.addRoute(new RouteInfo(GATEWAY1));
+ assertTrue("dualstack:v4-provisioned", lp46.isProvisioned());
+ lp6.addRoute(new RouteInfo(GATEWAY6));
+ assertTrue("dualstack:both-provisioned", lp46.isProvisioned());
+
+ // A link with an IPv6 address and default route, but IPv4 DNS server.
+ LinkProperties mixed = new LinkProperties();
+ mixed.addLinkAddress(LINKADDRV6);
+ mixed.addDnsServer(DNS1);
+ mixed.addRoute(new RouteInfo(GATEWAY6));
+ assertFalse("mixed:addr6+route6+dns4", mixed.isProvisioned());
+ }
}