Merge "Add LinkProps and NetworkCaps methods to SystemApi" am: 4bde11491b
am: d16b91fddd
Change-Id: Ic15474fe0b7da8062114367ec4f692e30e73d549
This commit is contained in:
@@ -19,6 +19,7 @@ package android.net;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SystemApi;
|
||||
import android.annotation.TestApi;
|
||||
import android.annotation.UnsupportedAppUsage;
|
||||
import android.os.Build;
|
||||
import android.os.Parcel;
|
||||
@@ -368,7 +369,8 @@ public final class LinkProperties implements Parcelable {
|
||||
* @return true if the DNS server was added, false if it was already present.
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public boolean addDnsServer(InetAddress dnsServer) {
|
||||
if (dnsServer != null && !mDnses.contains(dnsServer)) {
|
||||
mDnses.add(dnsServer);
|
||||
@@ -384,7 +386,8 @@ public final class LinkProperties implements Parcelable {
|
||||
* @return true if the DNS server was removed, false if it did not exist.
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public boolean removeDnsServer(InetAddress dnsServer) {
|
||||
if (dnsServer != null) {
|
||||
return mDnses.remove(dnsServer);
|
||||
@@ -423,6 +426,8 @@ public final class LinkProperties implements Parcelable {
|
||||
* @param usePrivateDns The private DNS state.
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public void setUsePrivateDns(boolean usePrivateDns) {
|
||||
mUsePrivateDns = usePrivateDns;
|
||||
}
|
||||
@@ -448,6 +453,8 @@ public final class LinkProperties implements Parcelable {
|
||||
* @param privateDnsServerName The private DNS server name.
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public void setPrivateDnsServerName(@Nullable String privateDnsServerName) {
|
||||
mPrivateDnsServerName = privateDnsServerName;
|
||||
}
|
||||
@@ -510,6 +517,8 @@ public final class LinkProperties implements Parcelable {
|
||||
* object.
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public void setValidatedPrivateDnsServers(Collection<InetAddress> dnsServers) {
|
||||
mValidatedPrivateDnses.clear();
|
||||
for (InetAddress dnsServer: dnsServers) {
|
||||
@@ -525,6 +534,8 @@ public final class LinkProperties implements Parcelable {
|
||||
* DNS servers on this link.
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public List<InetAddress> getValidatedPrivateDnsServers() {
|
||||
return Collections.unmodifiableList(mValidatedPrivateDnses);
|
||||
}
|
||||
@@ -636,7 +647,8 @@ public final class LinkProperties implements Parcelable {
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public void setTcpBufferSizes(String tcpBufferSizes) {
|
||||
mTcpBufferSizes = tcpBufferSizes;
|
||||
}
|
||||
@@ -648,7 +660,8 @@ public final class LinkProperties implements Parcelable {
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public String getTcpBufferSizes() {
|
||||
return mTcpBufferSizes;
|
||||
}
|
||||
@@ -699,7 +712,8 @@ public final class LinkProperties implements Parcelable {
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public boolean removeRoute(RouteInfo route) {
|
||||
return route != null &&
|
||||
Objects.equals(mIfaceName, route.getInterface()) &&
|
||||
@@ -960,7 +974,8 @@ public final class LinkProperties implements Parcelable {
|
||||
* @return {@code true} if there is an IPv4 address, {@code false} otherwise.
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public boolean hasIPv4Address() {
|
||||
for (LinkAddress address : mLinkAddresses) {
|
||||
if (address.getAddress() instanceof Inet4Address) {
|
||||
@@ -988,7 +1003,8 @@ public final class LinkProperties implements Parcelable {
|
||||
* @return {@code true} if there is a global preferred IPv6 address, {@code false} otherwise.
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public boolean hasGlobalIPv6Address() {
|
||||
for (LinkAddress address : mLinkAddresses) {
|
||||
if (address.getAddress() instanceof Inet6Address && address.isGlobalPreferred()) {
|
||||
@@ -1020,7 +1036,8 @@ public final class LinkProperties implements Parcelable {
|
||||
* @return {@code true} if there is an IPv6 default route, {@code false} otherwise.
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public boolean hasIPv6DefaultRoute() {
|
||||
for (RouteInfo r : mRoutes) {
|
||||
if (r.isIPv6Default()) {
|
||||
@@ -1099,6 +1116,8 @@ public final class LinkProperties implements Parcelable {
|
||||
* @return {@code true} if the link is provisioned, {@code false} otherwise.
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public boolean isIPv4Provisioned() {
|
||||
return (hasIPv4Address() &&
|
||||
hasIPv4DefaultRoute() &&
|
||||
@@ -1112,7 +1131,8 @@ public final class LinkProperties implements Parcelable {
|
||||
* @return {@code true} if the link is provisioned, {@code false} otherwise.
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public boolean isIPv6Provisioned() {
|
||||
return (hasGlobalIPv6Address() &&
|
||||
hasIPv6DefaultRoute() &&
|
||||
@@ -1126,7 +1146,8 @@ public final class LinkProperties implements Parcelable {
|
||||
* @return {@code true} if the link is provisioned, {@code false} otherwise.
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public boolean isProvisioned() {
|
||||
return (isIPv4Provisioned() || isIPv6Provisioned());
|
||||
}
|
||||
@@ -1138,7 +1159,8 @@ public final class LinkProperties implements Parcelable {
|
||||
* {@code false} otherwise.
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public boolean isReachable(InetAddress ip) {
|
||||
final List<RouteInfo> allRoutes = getAllRoutes();
|
||||
// If we don't have a route to this IP address, it's not reachable.
|
||||
|
||||
@@ -712,6 +712,7 @@ public final class NetworkCapabilities implements Parcelable {
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public @Transport int[] getTransportTypes() {
|
||||
return BitUtils.unpackBits(mTransportTypes);
|
||||
}
|
||||
@@ -1312,6 +1313,8 @@ public final class NetworkCapabilities implements Parcelable {
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public boolean satisfiedByNetworkCapabilities(NetworkCapabilities nc) {
|
||||
return satisfiedByNetworkCapabilities(nc, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user