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