From 8d6ae5d59f6db1b1a1becb6a281b5b232bc1dd05 Mon Sep 17 00:00:00 2001 From: Aaron Huang Date: Wed, 2 Oct 2019 20:07:38 +0800 Subject: [PATCH] Add LinkProperties methods to system APIs The exposed methods are used by telephony, wifi and tethering. For mainline support, making the methods @SystemApi. Bug: 139268426 Bug: 135998869 Bug: 138306002 Test: atest FrameworksNetTests atest NetworkStackTests atest FrameworksTelephonyTests ./frameworks/opt/net/wifi/tests/wifitests/runtests.sh atest android.net.cts atest android.net.wifi.cts atest android.telephony.cts Change-Id: Ib16a838cf9f748e1c5b045d6c2f17678f16af28c --- core/java/android/net/LinkProperties.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/core/java/android/net/LinkProperties.java b/core/java/android/net/LinkProperties.java index 8e18341134..f8ded62186 100644 --- a/core/java/android/net/LinkProperties.java +++ b/core/java/android/net/LinkProperties.java @@ -227,7 +227,7 @@ public final class LinkProperties implements Parcelable { /** * @hide */ - @UnsupportedAppUsage + @SystemApi public @NonNull List getAllInterfaceNames() { List interfaceNames = new ArrayList<>(mStackedLinks.size() + 1); if (mIfaceName != null) interfaceNames.add(mIfaceName); @@ -247,7 +247,7 @@ public final class LinkProperties implements Parcelable { * @return An unmodifiable {@link List} of {@link InetAddress} for this link. * @hide */ - @UnsupportedAppUsage + @SystemApi public @NonNull List getAddresses() { final List addresses = new ArrayList<>(); for (LinkAddress linkAddress : mLinkAddresses) { @@ -342,8 +342,8 @@ public final class LinkProperties implements Parcelable { * Returns all the addresses on this link and all the links stacked above it. * @hide */ - @UnsupportedAppUsage - public List getAllLinkAddresses() { + @SystemApi + public @NonNull List getAllLinkAddresses() { List addresses = new ArrayList<>(mLinkAddresses); for (LinkProperties stacked: mStackedLinks.values()) { addresses.addAll(stacked.getAllLinkAddresses()); @@ -542,6 +542,7 @@ public final class LinkProperties implements Parcelable { * @return true if the PCSCF server was added, false otherwise. * @hide */ + @SystemApi public boolean addPcscfServer(@NonNull InetAddress pcscfServer) { if (pcscfServer != null && !mPcscfs.contains(pcscfServer)) { mPcscfs.add(pcscfServer); @@ -729,7 +730,7 @@ public final class LinkProperties implements Parcelable { * Returns all the routes on this link and all the links stacked above it. * @hide */ - @UnsupportedAppUsage + @SystemApi public @NonNull List getAllRoutes() { List routes = new ArrayList<>(mRoutes); for (LinkProperties stacked: mStackedLinks.values()) { @@ -1025,7 +1026,7 @@ public final class LinkProperties implements Parcelable { * @return {@code true} if there is an IPv4 default route, {@code false} otherwise. * @hide */ - @UnsupportedAppUsage + @SystemApi public boolean hasIpv4DefaultRoute() { for (RouteInfo r : mRoutes) { if (r.isIPv4Default()) { @@ -1082,7 +1083,7 @@ public final class LinkProperties implements Parcelable { * @return {@code true} if there is an IPv4 DNS server, {@code false} otherwise. * @hide */ - @UnsupportedAppUsage + @SystemApi public boolean hasIpv4DnsServer() { for (InetAddress ia : mDnses) { if (ia instanceof Inet4Address) { @@ -1110,7 +1111,7 @@ public final class LinkProperties implements Parcelable { * @return {@code true} if there is an IPv6 DNS server, {@code false} otherwise. * @hide */ - @UnsupportedAppUsage + @SystemApi public boolean hasIpv6DnsServer() { for (InetAddress ia : mDnses) { if (ia instanceof Inet6Address) {