Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8b322ed8 authored by Aaron Huang's avatar Aaron Huang
Browse files

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
parent 82001cf9
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -4150,12 +4150,20 @@ package android.net {
    ctor public LinkProperties(@Nullable android.net.LinkProperties);
    method public boolean addDnsServer(@NonNull java.net.InetAddress);
    method public boolean addLinkAddress(@NonNull android.net.LinkAddress);
    method public boolean addPcscfServer(@NonNull java.net.InetAddress);
    method @NonNull public java.util.List<java.net.InetAddress> getAddresses();
    method @NonNull public java.util.List<java.lang.String> getAllInterfaceNames();
    method @NonNull public java.util.List<android.net.LinkAddress> getAllLinkAddresses();
    method @NonNull public java.util.List<android.net.RouteInfo> getAllRoutes();
    method @NonNull public java.util.List<java.net.InetAddress> getPcscfServers();
    method @Nullable public String getTcpBufferSizes();
    method @NonNull public java.util.List<java.net.InetAddress> getValidatedPrivateDnsServers();
    method public boolean hasGlobalIpv6Address();
    method public boolean hasIpv4Address();
    method public boolean hasIpv4DefaultRoute();
    method public boolean hasIpv4DnsServer();
    method public boolean hasIpv6DefaultRoute();
    method public boolean hasIpv6DnsServer();
    method public boolean isIpv4Provisioned();
    method public boolean isIpv6Provisioned();
    method public boolean isProvisioned();
+9 −8
Original line number Diff line number Diff line
@@ -227,7 +227,7 @@ public final class LinkProperties implements Parcelable {
    /**
     * @hide
     */
    @UnsupportedAppUsage
    @SystemApi
    public @NonNull List<String> getAllInterfaceNames() {
        List<String> 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<InetAddress> getAddresses() {
        final List<InetAddress> 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<LinkAddress> getAllLinkAddresses() {
    @SystemApi
    public @NonNull List<LinkAddress> getAllLinkAddresses() {
        List<LinkAddress> 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<RouteInfo> getAllRoutes() {
        List<RouteInfo> 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) {