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

Commit f9d61f1c authored by Paul Hu's avatar Paul Hu Committed by Gerrit Code Review
Browse files

Merge "Fix ApfCapabilities, LinkAddress, RouteInfo, IpPrefix API issues."

parents 9876efda 819e0aff
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -27266,11 +27266,11 @@ package android.net {
  }
  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 java.net.InetAddress getAddress();
    method public int getPrefixLength();
    method public byte[] getRawAddress();
    method @NonNull public java.net.InetAddress getAddress();
    method @IntRange(from=0, to=128) public int getPrefixLength();
    method @NonNull public byte[] getRawAddress();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.net.IpPrefix> CREATOR;
  }
@@ -27343,7 +27343,7 @@ package android.net {
    method public int describeContents();
    method public java.net.InetAddress getAddress();
    method public int getFlags();
    method public int getPrefixLength();
    method @IntRange(from=0, to=128) public int getPrefixLength();
    method public int getScope();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.net.LinkAddress> CREATOR;
@@ -27612,9 +27612,9 @@ package android.net {
  public final class RouteInfo implements android.os.Parcelable {
    method public int describeContents();
    method public android.net.IpPrefix getDestination();
    method public java.net.InetAddress getGateway();
    method public String getInterface();
    method @NonNull public android.net.IpPrefix getDestination();
    method @Nullable public java.net.InetAddress getGateway();
    method @Nullable public String getInterface();
    method public boolean hasGateway();
    method public boolean isDefaultRoute();
    method public boolean matches(java.net.InetAddress);
+5 −5
Original line number Diff line number Diff line
@@ -3132,13 +3132,13 @@ package android.net {
  }
  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);
  }
  public class LinkAddress implements android.os.Parcelable {
    ctor public LinkAddress(java.net.InetAddress, int, int, int);
    ctor public LinkAddress(@NonNull java.net.InetAddress, int);
    ctor public LinkAddress(@NonNull java.net.InetAddress, @IntRange(from=0, to=128) int, int, int);
    ctor public LinkAddress(@NonNull java.net.InetAddress, @IntRange(from=0, to=128) int);
    ctor public LinkAddress(@NonNull String);
    ctor public LinkAddress(@NonNull String, int, int);
    method public boolean isGlobalPreferred();
@@ -3315,8 +3315,8 @@ package android.net.apf {
  public final class ApfCapabilities implements android.os.Parcelable {
    ctor public ApfCapabilities(int, int, int);
    method public int describeContents();
    method public static boolean getApfDrop8023Frames(@NonNull android.content.Context);
    method @NonNull public static int[] getApfEthTypeBlackList(@NonNull android.content.Context);
    method public static boolean getApfDrop8023Frames();
    method @NonNull public static int[] getApfEtherTypeBlackList();
    method public boolean hasDataAccess();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.net.apf.ApfCapabilities> CREATOR;
+5 −5
Original line number Diff line number Diff line
@@ -616,7 +616,7 @@ package android.net {
  }

  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);
  }

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

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

package android.net;

import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.annotation.TestApi;
@@ -71,7 +72,7 @@ public final class IpPrefix implements Parcelable {
     *
     * @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.prefixLength = prefixLength;
        checkAndMaskAddressAndPrefixLength();
@@ -88,7 +89,7 @@ public final class IpPrefix implements Parcelable {
     */
    @SystemApi
    @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,
        // which is unnecessary because getAddress() already returns a clone.
        this.address = address.getAddress();
@@ -150,13 +151,13 @@ public final class IpPrefix implements Parcelable {
     *
     * @return the address in the form of a byte array.
     */
    public InetAddress getAddress() {
    public @NonNull InetAddress getAddress() {
        try {
            return InetAddress.getByAddress(address);
        } catch (UnknownHostException e) {
            // Cannot happen. InetAddress.getByAddress can only throw an exception if the byte
            // 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.
     */
    public byte[] getRawAddress() {
    public @NonNull byte[] getRawAddress() {
        return address.clone();
    }

@@ -175,6 +176,7 @@ public final class IpPrefix implements Parcelable {
     *
     * @return the prefix length.
     */
    @IntRange(from = 0, to = 128)
    public int getPrefixLength() {
        return prefixLength;
    }
@@ -183,10 +185,10 @@ public final class IpPrefix implements Parcelable {
     * Determines whether the prefix contains the specified address.
     *
     * @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) {
        byte[] addrBytes = (address == null) ? null : address.getAddress();
    public boolean contains(@NonNull InetAddress address) {
        byte[] addrBytes = address.getAddress();
        if (addrBytes == null || addrBytes.length != this.address.length) {
            return false;
        }
@@ -201,7 +203,7 @@ public final class IpPrefix implements Parcelable {
     * @param otherPrefix the prefix to test
     * @hide
     */
    public boolean containsPrefix(IpPrefix otherPrefix) {
    public boolean containsPrefix(@NonNull IpPrefix otherPrefix) {
        if (otherPrefix.getPrefixLength() < prefixLength) return false;
        final byte[] otherAddress = otherPrefix.getRawAddress();
        NetworkUtils.maskRawAddress(otherAddress, prefixLength);
+10 −5
Original line number 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_UNIVERSE;

import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
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
     * the specified flags and scope. Flags and scope are not checked for validity.
     * @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 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}).
@@ -178,7 +179,8 @@ public class LinkAddress implements Parcelable {
     */
    @SystemApi
    @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);
    }

@@ -186,12 +188,13 @@ public class LinkAddress implements Parcelable {
     * 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.
     * @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
     */
    @SystemApi
    @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.scope = scopeForUnicastAddress(address);
    }
@@ -202,7 +205,7 @@ public class LinkAddress implements Parcelable {
     * @param interfaceAddress The interface address.
     * @hide
     */
    public LinkAddress(InterfaceAddress interfaceAddress) {
    public LinkAddress(@NonNull InterfaceAddress interfaceAddress) {
        this(interfaceAddress.getAddress(),
             interfaceAddress.getNetworkPrefixLength());
    }
@@ -306,6 +309,7 @@ public class LinkAddress implements Parcelable {
    /**
     * Returns the prefix length of this {@code LinkAddress}.
     */
    @IntRange(from = 0, to = 128)
    public int getPrefixLength() {
        return prefixLength;
    }
@@ -316,6 +320,7 @@ public class LinkAddress implements Parcelable {
     * @hide
     */
    @UnsupportedAppUsage
    @IntRange(from = 0, to = 128)
    public int getNetworkPrefixLength() {
        return getPrefixLength();
    }
Loading