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

Commit bf3e6f5e authored by Paul Hu's avatar Paul Hu Committed by android-build-merger
Browse files

Merge "Fix ApfCapabilities, LinkAddress, RouteInfo, IpPrefix API issues." am: f9d61f1c

am: 96f34c31

Change-Id: I171e667dd279e008708fbc84972f63cbd5b55625
parents 8724b66c 96f34c31
Loading
Loading
Loading
Loading
+8 −8
Original line number Original line Diff line number Diff line
@@ -27264,11 +27264,11 @@ package android.net {
  }
  }
  public final class IpPrefix implements android.os.Parcelable {
  public final class IpPrefix implements android.os.Parcelable {
    method public boolean contains(java.net.InetAddress);
    method public boolean contains(@NonNull java.net.InetAddress);
    method public int describeContents();
    method public int describeContents();
    method public java.net.InetAddress getAddress();
    method @NonNull public java.net.InetAddress getAddress();
    method public int getPrefixLength();
    method @IntRange(from=0, to=128) public int getPrefixLength();
    method public byte[] getRawAddress();
    method @NonNull public byte[] getRawAddress();
    method public void writeToParcel(android.os.Parcel, int);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.net.IpPrefix> CREATOR;
    field public static final android.os.Parcelable.Creator<android.net.IpPrefix> CREATOR;
  }
  }
@@ -27341,7 +27341,7 @@ package android.net {
    method public int describeContents();
    method public int describeContents();
    method public java.net.InetAddress getAddress();
    method public java.net.InetAddress getAddress();
    method public int getFlags();
    method public int getFlags();
    method public int getPrefixLength();
    method @IntRange(from=0, to=128) public int getPrefixLength();
    method public int getScope();
    method public int getScope();
    method public void writeToParcel(android.os.Parcel, int);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.net.LinkAddress> CREATOR;
    field public static final android.os.Parcelable.Creator<android.net.LinkAddress> CREATOR;
@@ -27610,9 +27610,9 @@ package android.net {
  public final class RouteInfo implements android.os.Parcelable {
  public final class RouteInfo implements android.os.Parcelable {
    method public int describeContents();
    method public int describeContents();
    method public android.net.IpPrefix getDestination();
    method @NonNull public android.net.IpPrefix getDestination();
    method public java.net.InetAddress getGateway();
    method @Nullable public java.net.InetAddress getGateway();
    method public String getInterface();
    method @Nullable public String getInterface();
    method public boolean hasGateway();
    method public boolean hasGateway();
    method public boolean isDefaultRoute();
    method public boolean isDefaultRoute();
    method public boolean matches(java.net.InetAddress);
    method public boolean matches(java.net.InetAddress);
+5 −5
Original line number Original line Diff line number Diff line
@@ -3132,13 +3132,13 @@ package android.net {
  }
  }
  public final class IpPrefix implements android.os.Parcelable {
  public final class IpPrefix implements android.os.Parcelable {
    ctor public IpPrefix(@NonNull java.net.InetAddress, int);
    ctor public IpPrefix(@NonNull java.net.InetAddress, @IntRange(from=0, to=128) int);
    ctor public IpPrefix(@NonNull String);
    ctor public IpPrefix(@NonNull String);
  }
  }
  public class LinkAddress implements android.os.Parcelable {
  public class LinkAddress implements android.os.Parcelable {
    ctor public LinkAddress(java.net.InetAddress, int, int, int);
    ctor public LinkAddress(@NonNull java.net.InetAddress, @IntRange(from=0, to=128) int, int, int);
    ctor public LinkAddress(@NonNull java.net.InetAddress, int);
    ctor public LinkAddress(@NonNull java.net.InetAddress, @IntRange(from=0, to=128) int);
    ctor public LinkAddress(@NonNull String);
    ctor public LinkAddress(@NonNull String);
    ctor public LinkAddress(@NonNull String, int, int);
    ctor public LinkAddress(@NonNull String, int, int);
    method public boolean isGlobalPreferred();
    method public boolean isGlobalPreferred();
@@ -3315,8 +3315,8 @@ package android.net.apf {
  public final class ApfCapabilities implements android.os.Parcelable {
  public final class ApfCapabilities implements android.os.Parcelable {
    ctor public ApfCapabilities(int, int, int);
    ctor public ApfCapabilities(int, int, int);
    method public int describeContents();
    method public int describeContents();
    method public static boolean getApfDrop8023Frames(@NonNull android.content.Context);
    method public static boolean getApfDrop8023Frames();
    method @NonNull public static int[] getApfEthTypeBlackList(@NonNull android.content.Context);
    method @NonNull public static int[] getApfEtherTypeBlackList();
    method public boolean hasDataAccess();
    method public boolean hasDataAccess();
    method public void writeToParcel(android.os.Parcel, int);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.net.apf.ApfCapabilities> CREATOR;
    field public static final android.os.Parcelable.Creator<android.net.apf.ApfCapabilities> CREATOR;
+5 −5
Original line number Original line Diff line number Diff line
@@ -616,7 +616,7 @@ package android.net {
  }
  }


  public final class IpPrefix implements android.os.Parcelable {
  public final class IpPrefix implements android.os.Parcelable {
    ctor public IpPrefix(@NonNull java.net.InetAddress, int);
    ctor public IpPrefix(@NonNull java.net.InetAddress, @IntRange(from=0, to=128) int);
    ctor public IpPrefix(@NonNull String);
    ctor public IpPrefix(@NonNull String);
  }
  }


@@ -625,8 +625,8 @@ package android.net {
  }
  }


  public class LinkAddress implements android.os.Parcelable {
  public class LinkAddress implements android.os.Parcelable {
    ctor public LinkAddress(java.net.InetAddress, int, int, int);
    ctor public LinkAddress(@NonNull java.net.InetAddress, @IntRange(from=0, to=128) int, int, int);
    ctor public LinkAddress(@NonNull java.net.InetAddress, int);
    ctor public LinkAddress(@NonNull java.net.InetAddress, @IntRange(from=0, to=128) int);
    ctor public LinkAddress(@NonNull String);
    ctor public LinkAddress(@NonNull String);
    ctor public LinkAddress(@NonNull String, int, int);
    ctor public LinkAddress(@NonNull String, int, int);
    method public boolean isGlobalPreferred();
    method public boolean isGlobalPreferred();
@@ -735,8 +735,8 @@ package android.net.apf {
  public final class ApfCapabilities implements android.os.Parcelable {
  public final class ApfCapabilities implements android.os.Parcelable {
    ctor public ApfCapabilities(int, int, int);
    ctor public ApfCapabilities(int, int, int);
    method public int describeContents();
    method public int describeContents();
    method public static boolean getApfDrop8023Frames(@NonNull android.content.Context);
    method public static boolean getApfDrop8023Frames();
    method @NonNull public static int[] getApfEthTypeBlackList(@NonNull android.content.Context);
    method @NonNull public static int[] getApfEtherTypeBlackList();
    method public boolean hasDataAccess();
    method public boolean hasDataAccess();
    method public void writeToParcel(android.os.Parcel, int);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.net.apf.ApfCapabilities> CREATOR;
    field public static final android.os.Parcelable.Creator<android.net.apf.ApfCapabilities> CREATOR;
+11 −9
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package android.net;
package android.net;


import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.annotation.TestApi;
@@ -71,7 +72,7 @@ public final class IpPrefix implements Parcelable {
     *
     *
     * @hide
     * @hide
     */
     */
    public IpPrefix(@NonNull byte[] address, int prefixLength) {
    public IpPrefix(@NonNull byte[] address, @IntRange(from = 0, to = 128) int prefixLength) {
        this.address = address.clone();
        this.address = address.clone();
        this.prefixLength = prefixLength;
        this.prefixLength = prefixLength;
        checkAndMaskAddressAndPrefixLength();
        checkAndMaskAddressAndPrefixLength();
@@ -88,7 +89,7 @@ public final class IpPrefix implements Parcelable {
     */
     */
    @SystemApi
    @SystemApi
    @TestApi
    @TestApi
    public IpPrefix(@NonNull InetAddress address, int prefixLength) {
    public IpPrefix(@NonNull InetAddress address, @IntRange(from = 0, to = 128) int prefixLength) {
        // We don't reuse the (byte[], int) constructor because it calls clone() on the byte array,
        // We don't reuse the (byte[], int) constructor because it calls clone() on the byte array,
        // which is unnecessary because getAddress() already returns a clone.
        // which is unnecessary because getAddress() already returns a clone.
        this.address = address.getAddress();
        this.address = address.getAddress();
@@ -150,13 +151,13 @@ public final class IpPrefix implements Parcelable {
     *
     *
     * @return the address in the form of a byte array.
     * @return the address in the form of a byte array.
     */
     */
    public InetAddress getAddress() {
    public @NonNull InetAddress getAddress() {
        try {
        try {
            return InetAddress.getByAddress(address);
            return InetAddress.getByAddress(address);
        } catch (UnknownHostException e) {
        } catch (UnknownHostException e) {
            // Cannot happen. InetAddress.getByAddress can only throw an exception if the byte
            // Cannot happen. InetAddress.getByAddress can only throw an exception if the byte
            // array is the wrong length, but we check that in the constructor.
            // array is the wrong length, but we check that in the constructor.
            return null;
            throw new IllegalArgumentException("Address is invalid");
        }
        }
    }
    }


@@ -166,7 +167,7 @@ public final class IpPrefix implements Parcelable {
     *
     *
     * @return the address in the form of a byte array.
     * @return the address in the form of a byte array.
     */
     */
    public byte[] getRawAddress() {
    public @NonNull byte[] getRawAddress() {
        return address.clone();
        return address.clone();
    }
    }


@@ -175,6 +176,7 @@ public final class IpPrefix implements Parcelable {
     *
     *
     * @return the prefix length.
     * @return the prefix length.
     */
     */
    @IntRange(from = 0, to = 128)
    public int getPrefixLength() {
    public int getPrefixLength() {
        return prefixLength;
        return prefixLength;
    }
    }
@@ -183,10 +185,10 @@ public final class IpPrefix implements Parcelable {
     * Determines whether the prefix contains the specified address.
     * Determines whether the prefix contains the specified address.
     *
     *
     * @param address An {@link InetAddress} to test.
     * @param address An {@link InetAddress} to test.
     * @return {@code true} if the prefix covers the given address.
     * @return {@code true} if the prefix covers the given address. {@code false} otherwise.
     */
     */
    public boolean contains(InetAddress address) {
    public boolean contains(@NonNull InetAddress address) {
        byte[] addrBytes = (address == null) ? null : address.getAddress();
        byte[] addrBytes = address.getAddress();
        if (addrBytes == null || addrBytes.length != this.address.length) {
        if (addrBytes == null || addrBytes.length != this.address.length) {
            return false;
            return false;
        }
        }
@@ -201,7 +203,7 @@ public final class IpPrefix implements Parcelable {
     * @param otherPrefix the prefix to test
     * @param otherPrefix the prefix to test
     * @hide
     * @hide
     */
     */
    public boolean containsPrefix(IpPrefix otherPrefix) {
    public boolean containsPrefix(@NonNull IpPrefix otherPrefix) {
        if (otherPrefix.getPrefixLength() < prefixLength) return false;
        if (otherPrefix.getPrefixLength() < prefixLength) return false;
        final byte[] otherAddress = otherPrefix.getRawAddress();
        final byte[] otherAddress = otherPrefix.getRawAddress();
        NetworkUtils.maskRawAddress(otherAddress, prefixLength);
        NetworkUtils.maskRawAddress(otherAddress, prefixLength);
+10 −5
Original line number Original line Diff line number Diff line
@@ -25,6 +25,7 @@ import static android.system.OsConstants.RT_SCOPE_LINK;
import static android.system.OsConstants.RT_SCOPE_SITE;
import static android.system.OsConstants.RT_SCOPE_SITE;
import static android.system.OsConstants.RT_SCOPE_UNIVERSE;
import static android.system.OsConstants.RT_SCOPE_UNIVERSE;


import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.annotation.SystemApi;
@@ -170,7 +171,7 @@ public class LinkAddress implements Parcelable {
     * Constructs a new {@code LinkAddress} from an {@code InetAddress} and prefix length, with
     * Constructs a new {@code LinkAddress} from an {@code InetAddress} and prefix length, with
     * the specified flags and scope. Flags and scope are not checked for validity.
     * the specified flags and scope. Flags and scope are not checked for validity.
     * @param address The IP address.
     * @param address The IP address.
     * @param prefixLength The prefix length.
     * @param prefixLength The prefix length. Must be &gt;= 0 and &lt;= (32 or 128) (IPv4 or IPv6).
     * @param flags A bitmask of {@code IFA_F_*} values representing properties of the address.
     * @param flags A bitmask of {@code IFA_F_*} values representing properties of the address.
     * @param scope An integer defining the scope in which the address is unique (e.g.,
     * @param scope An integer defining the scope in which the address is unique (e.g.,
     *              {@link OsConstants#RT_SCOPE_LINK} or {@link OsConstants#RT_SCOPE_SITE}).
     *              {@link OsConstants#RT_SCOPE_LINK} or {@link OsConstants#RT_SCOPE_SITE}).
@@ -178,7 +179,8 @@ public class LinkAddress implements Parcelable {
     */
     */
    @SystemApi
    @SystemApi
    @TestApi
    @TestApi
    public LinkAddress(InetAddress address, int prefixLength, int flags, int scope) {
    public LinkAddress(@NonNull InetAddress address, @IntRange(from = 0, to = 128) int prefixLength,
            int flags, int scope) {
        init(address, prefixLength, flags, scope);
        init(address, prefixLength, flags, scope);
    }
    }


@@ -186,12 +188,13 @@ public class LinkAddress implements Parcelable {
     * Constructs a new {@code LinkAddress} from an {@code InetAddress} and a prefix length.
     * Constructs a new {@code LinkAddress} from an {@code InetAddress} and a prefix length.
     * The flags are set to zero and the scope is determined from the address.
     * The flags are set to zero and the scope is determined from the address.
     * @param address The IP address.
     * @param address The IP address.
     * @param prefixLength The prefix length.
     * @param prefixLength The prefix length. Must be &gt;= 0 and &lt;= (32 or 128) (IPv4 or IPv6).
     * @hide
     * @hide
     */
     */
    @SystemApi
    @SystemApi
    @TestApi
    @TestApi
    public LinkAddress(@NonNull InetAddress address, int prefixLength) {
    public LinkAddress(@NonNull InetAddress address,
            @IntRange(from = 0, to = 128) int prefixLength) {
        this(address, prefixLength, 0, 0);
        this(address, prefixLength, 0, 0);
        this.scope = scopeForUnicastAddress(address);
        this.scope = scopeForUnicastAddress(address);
    }
    }
@@ -202,7 +205,7 @@ public class LinkAddress implements Parcelable {
     * @param interfaceAddress The interface address.
     * @param interfaceAddress The interface address.
     * @hide
     * @hide
     */
     */
    public LinkAddress(InterfaceAddress interfaceAddress) {
    public LinkAddress(@NonNull InterfaceAddress interfaceAddress) {
        this(interfaceAddress.getAddress(),
        this(interfaceAddress.getAddress(),
             interfaceAddress.getNetworkPrefixLength());
             interfaceAddress.getNetworkPrefixLength());
    }
    }
@@ -306,6 +309,7 @@ public class LinkAddress implements Parcelable {
    /**
    /**
     * Returns the prefix length of this {@code LinkAddress}.
     * Returns the prefix length of this {@code LinkAddress}.
     */
     */
    @IntRange(from = 0, to = 128)
    public int getPrefixLength() {
    public int getPrefixLength() {
        return prefixLength;
        return prefixLength;
    }
    }
@@ -316,6 +320,7 @@ public class LinkAddress implements Parcelable {
     * @hide
     * @hide
     */
     */
    @UnsupportedAppUsage
    @UnsupportedAppUsage
    @IntRange(from = 0, to = 128)
    public int getNetworkPrefixLength() {
    public int getNetworkPrefixLength() {
        return getPrefixLength();
        return getPrefixLength();
    }
    }
Loading