(re)define the definition of "provisioned"

Specifically:

    [1] provide a hasIPv4(), and
    [2] a hasIPv6()

each of which requires an IP address, a default route, and
address-family-specific DNS servers to evaluate to true.

Additionally:

    [3] redefine isProvisioned() to return the logical OR
        of [1] and [2] above.

Any external caller can still use any of the has*() methods to
construct its own, different definition of "provisioned".

Bug: 17769720
Change-Id: Ia692fb8508484ff403d3920c94d0e1db4563f807
This commit is contained in:
Erik Kline 2014-10-24 21:50:20 +09:00
commit 8b02307fd5

View file

@ -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());
}
/**