Fix ApfCapabilities, LinkAddress, RouteInfo, IpPrefix API issues.
Fix: 129362082 Fix: 129361362 Fix: 129360330 Fix: 129362379 Test: atest FrameworksNetTests NetworkStackTests Change-Id: I05fbc6f98207d5cf002e3cbc5829040af7d6be52
This commit is contained in:
parent
539821c978
commit
895a741bf1
1 changed files with 85 additions and 35 deletions
|
|
@ -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 >= 0 and <= (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 >= 0 and <= (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…
Reference in a new issue