From 7610bc70ede0b729887fc8e2acc3aa7c61ec6211 Mon Sep 17 00:00:00 2001 From: paulhu Date: Wed, 12 Dec 2018 17:52:57 +0800 Subject: Unhide LinkProperties, NetworkCapabilities, NetworkRequest APIs These methods are marked to @UnsupportedAppUsage APIs since Android Q. But some system apps still need them to set/get necessary network or request information. Hence, make them to be public or system APIs. Bug: 120448492 Test: atest FrameworksNetTests Change-Id: I95a44daef5615e290b40d0796ca183b88ad8a63f --- api/current.txt | 1 + api/system-current.txt | 17 +++++++++++++++++ core/java/android/net/LinkProperties.java | 21 ++++++++++----------- core/java/android/net/NetworkCapabilities.java | 2 +- core/java/android/net/NetworkRequest.java | 3 ++- 5 files changed, 31 insertions(+), 13 deletions(-) diff --git a/api/current.txt b/api/current.txt index 31a5443a4e84..a95a9e27eee8 100755 --- a/api/current.txt +++ b/api/current.txt @@ -27424,6 +27424,7 @@ package android.net { method public android.net.ProxyInfo getHttpProxy(); method public java.lang.String getInterfaceName(); method public java.util.List getLinkAddresses(); + method public int getMtu(); method public java.lang.String getPrivateDnsServerName(); method public java.util.List getRoutes(); method public boolean isPrivateDnsActive(); diff --git a/api/system-current.txt b/api/system-current.txt index 966cb328723c..190b9888f9a5 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -3095,7 +3095,20 @@ package android.net { ctor public LinkAddress(java.lang.String); } + public final class LinkProperties implements android.os.Parcelable { + ctor public LinkProperties(); + method public boolean addRoute(android.net.RouteInfo); + method public void clear(); + method public void setDnsServers(java.util.Collection); + method public void setDomains(java.lang.String); + method public void setHttpProxy(android.net.ProxyInfo); + method public void setInterfaceName(java.lang.String); + method public void setLinkAddresses(java.util.Collection); + method public void setMtu(int); + } + public final class NetworkCapabilities implements android.os.Parcelable { + method public int getSignalStrength(); field public static final int NET_CAPABILITY_OEM_PAID = 22; // 0x16 } @@ -3115,6 +3128,10 @@ package android.net { method public abstract void onRequestScores(android.net.NetworkKey[]); } + public static class NetworkRequest.Builder { + method public android.net.NetworkRequest.Builder setSignalStrength(int); + } + public class NetworkScoreManager { method public boolean clearScores() throws java.lang.SecurityException; method public void disableScoring() throws java.lang.SecurityException; diff --git a/core/java/android/net/LinkProperties.java b/core/java/android/net/LinkProperties.java index 1b9a66cd6ea7..80517ce28cda 100644 --- a/core/java/android/net/LinkProperties.java +++ b/core/java/android/net/LinkProperties.java @@ -18,6 +18,7 @@ package android.net; import android.annotation.NonNull; import android.annotation.Nullable; +import android.annotation.SystemApi; import android.annotation.UnsupportedAppUsage; import android.os.Parcel; import android.os.Parcelable; @@ -161,7 +162,7 @@ public final class LinkProperties implements Parcelable { /** * @hide */ - @UnsupportedAppUsage + @SystemApi public LinkProperties() { } @@ -195,7 +196,7 @@ public final class LinkProperties implements Parcelable { * @param iface The name of the network interface used for this link. * @hide */ - @UnsupportedAppUsage + @SystemApi public void setInterfaceName(String iface) { mIfaceName = iface; ArrayList newRoutes = new ArrayList<>(mRoutes.size()); @@ -346,7 +347,7 @@ public final class LinkProperties implements Parcelable { * object. * @hide */ - @UnsupportedAppUsage + @SystemApi public void setLinkAddresses(Collection addresses) { mLinkAddresses.clear(); for (LinkAddress address: addresses) { @@ -392,7 +393,7 @@ public final class LinkProperties implements Parcelable { * @param dnsServers The {@link Collection} of DNS servers to set in this object. * @hide */ - @UnsupportedAppUsage + @SystemApi public void setDnsServers(Collection dnsServers) { mDnses.clear(); for (InetAddress dnsServer: dnsServers) { @@ -529,7 +530,7 @@ public final class LinkProperties implements Parcelable { * domains to search when resolving host names on this link. * @hide */ - @UnsupportedAppUsage + @SystemApi public void setDomains(String domains) { mDomains = domains; } @@ -552,7 +553,7 @@ public final class LinkProperties implements Parcelable { * @param mtu The MTU to use for this link. * @hide */ - @UnsupportedAppUsage + @SystemApi public void setMtu(int mtu) { mMtu = mtu; } @@ -562,9 +563,7 @@ public final class LinkProperties implements Parcelable { * this will return 0. * * @return The mtu value set for this link. - * @hide */ - @UnsupportedAppUsage public int getMtu() { return mMtu; } @@ -613,7 +612,7 @@ public final class LinkProperties implements Parcelable { * * @hide */ - @UnsupportedAppUsage + @SystemApi public boolean addRoute(RouteInfo route) { if (route != null) { String routeIface = route.getInterface(); @@ -688,7 +687,7 @@ public final class LinkProperties implements Parcelable { * @param proxy A {@link ProxyInfo} defining the HTTP Proxy to use on this link. * @hide */ - @UnsupportedAppUsage + @SystemApi public void setHttpProxy(ProxyInfo proxy) { mHttpProxy = proxy; } @@ -760,7 +759,7 @@ public final class LinkProperties implements Parcelable { * Clears this object to its initial state. * @hide */ - @UnsupportedAppUsage + @SystemApi public void clear() { mIfaceName = null; mLinkAddresses.clear(); diff --git a/core/java/android/net/NetworkCapabilities.java b/core/java/android/net/NetworkCapabilities.java index 0bdfca7f5025..9acb6769c277 100644 --- a/core/java/android/net/NetworkCapabilities.java +++ b/core/java/android/net/NetworkCapabilities.java @@ -976,7 +976,7 @@ public final class NetworkCapabilities implements Parcelable { * @return The bearer-specific signal strength. * @hide */ - @UnsupportedAppUsage + @SystemApi public int getSignalStrength() { return mSignalStrength; } diff --git a/core/java/android/net/NetworkRequest.java b/core/java/android/net/NetworkRequest.java index 04b6b44013b9..3b01b03edd4e 100644 --- a/core/java/android/net/NetworkRequest.java +++ b/core/java/android/net/NetworkRequest.java @@ -17,6 +17,7 @@ package android.net; import android.annotation.NonNull; +import android.annotation.SystemApi; import android.annotation.UnsupportedAppUsage; import android.net.NetworkCapabilities.NetCapability; import android.net.NetworkCapabilities.Transport; @@ -344,7 +345,7 @@ public class NetworkRequest implements Parcelable { * @param signalStrength the bearer-specific signal strength. * @hide */ - @UnsupportedAppUsage + @SystemApi public Builder setSignalStrength(int signalStrength) { mNetworkCapabilities.setSignalStrength(signalStrength); return this; -- cgit v1.2.3-59-g8ed1b