Added in API level 21

LinkProperties


class LinkProperties : Parcelable
kotlin.Any
   ↳ android.net.LinkProperties

Describes the properties of a network link. A link represents a connection to a network. It may have multiple addresses and multiple gateways, multiple dns servers but only one http proxy and one network interface. Note that this is just a holder of data. Modifying it does not affect live networks.

Summary

Inherited constants
Public constructors

Constructs a new LinkProperties with default values.

Public methods
Boolean

Adds a RouteInfo to this LinkProperties.

Unit

Clears this object to its initial state.

Int

Implement the Parcelable interface

Boolean
equals(other: Any?)

Compares this LinkProperties instance against the target LinkProperties in obj.

Inet4Address?

Get DHCP server address

MutableList<InetAddress!>

Returns all the InetAddress for DNS servers on this link.

String?

Get the DNS domains search path set for this link.

ProxyInfo?

Gets the recommended ProxyInfo (or null) set on this link.

String?

Gets the interface name for this link.

MutableList<LinkAddress!>

Returns all the LinkAddress on this link.

Int

Gets any non-default MTU size set for this link.

IpPrefix?

Returns the NAT64 prefix in use on this link, if any.

String?

Returns the private DNS server name that is in use.

MutableList<RouteInfo!>

Returns all the RouteInfo set on this link.

Int

Generate hashcode based on significant fields Equal objects must produce the same hash code, while unequal objects may have the same hash codes.

Boolean

Returns whether private DNS is currently in use on this network.

Boolean

Returns whether the network interface supports WakeOnLAN

Unit

Set DHCP server address.

Unit

Replaces the DNS servers in this LinkProperties with the given Collection of InetAddress objects.

Unit
setDomains(domains: String?)

Sets the DNS domain search path used on this link.

Unit

Sets the recommended ProxyInfo to use on this link, or null for none.

Unit

Sets the interface name for this link.

Unit

Replaces the LinkAddress in this LinkProperties with the given Collection of LinkAddress.

Unit
setMtu(mtu: Int)

Sets the Maximum Transmission Unit size to use on this link.

Unit

Sets the NAT64 prefix in use on this link.

String

Unit
writeToParcel(dest: Parcel, flags: Int)

Implement the Parcelable interface.

Properties
static Parcelable.Creator<LinkProperties!>

Implement the Parcelable interface.

Public constructors

LinkProperties

Added in API level 29
LinkProperties()

Constructs a new LinkProperties with default values.

Public methods

addRoute

Added in API level 29
fun addRoute(route: RouteInfo): Boolean

Adds a RouteInfo to this LinkProperties. If there is a RouteInfo with the same destination, gateway and interface with different properties (e.g., different MTU), it will be updated. If the RouteInfo had an interface name set and that differs from the interface set for this LinkProperties an IllegalArgumentException will be thrown. The proper course is to add either un-named or properly named RouteInfo.

Parameters
route RouteInfo: A RouteInfo to add to this object. This value cannot be null.
Return
Boolean true was added or updated, false otherwise.

clear

Added in API level 29
fun clear(): Unit

Clears this object to its initial state.

describeContents

Added in API level 21
fun describeContents(): Int

Implement the Parcelable interface

Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

equals

Added in API level 21
fun equals(other: Any?): Boolean

Compares this LinkProperties instance against the target LinkProperties in obj. Two LinkPropertieses are equal if all their fields are equal in values. For collection fields, such as mDnses, containsAll() is used to check if two collections contains the same elements, independent of order. There are two thoughts regarding containsAll() 1. Duplicated elements. eg, (A, B, B) and (A, A, B) are equal. 2. Worst case performance is O(n^2).

Parameters
obj the object to be tested for equality. This value may be null.
Return
Boolean true if both objects are equal, false otherwise.

getDhcpServerAddress

Added in API level 30
fun getDhcpServerAddress(): Inet4Address?

Get DHCP server address

Return
Inet4Address? The current DHCP server address. This value may be null.

getDnsServers

Added in API level 21
fun getDnsServers(): MutableList<InetAddress!>

Returns all the InetAddress for DNS servers on this link.

Return
MutableList<InetAddress!> An unmodifiable List of InetAddress for DNS servers on this link. This value cannot be null.

getDomains

Added in API level 21
fun getDomains(): String?

Get the DNS domains search path set for this link. May be null if not set.

Return
String? A String containing the comma separated domains to search when resolving host names on this link or null.

getHttpProxy

Added in API level 21
fun getHttpProxy(): ProxyInfo?

Gets the recommended ProxyInfo (or null) set on this link.

Return
ProxyInfo? The ProxyInfo set on this link or null.

getInterfaceName

Added in API level 21
fun getInterfaceName(): String?

Gets the interface name for this link. May be null if not set.

Return
String? The interface name set for this link or null.

getLinkAddresses

Added in API level 21
fun getLinkAddresses(): MutableList<LinkAddress!>

Returns all the LinkAddress on this link. Typically a link will have one IPv4 address and one or more IPv6 addresses.

Return
MutableList<LinkAddress!> An unmodifiable List of LinkAddress for this link. This value cannot be null.

getMtu

Added in API level 29
fun getMtu(): Int

Gets any non-default MTU size set for this link. Note that if the default is being used this will return 0.

Return
Int The mtu value set for this link.

getNat64Prefix

Added in API level 30
fun getNat64Prefix(): IpPrefix?

Returns the NAT64 prefix in use on this link, if any.

Return
IpPrefix? the NAT64 prefix or null.

getPrivateDnsServerName

Added in API level 28
fun getPrivateDnsServerName(): String?

Returns the private DNS server name that is in use. If not null, private DNS is in strict mode. In this mode, applications should ensure that all DNS queries are encrypted and sent to this hostname and that queries are only sent if the hostname's certificate is valid. If null and isPrivateDnsActive is true, private DNS is in opportunistic mode, and applications should ensure that DNS queries are encrypted and sent to a DNS server returned by getDnsServers. System DNS will handle each of these cases correctly, but applications implementing their own DNS lookups must make sure to follow these requirements.

Return
String? The private DNS server name.

getRoutes

Added in API level 21
fun getRoutes(): MutableList<RouteInfo!>

Returns all the RouteInfo set on this link. Only unicast routes are returned for apps targeting Android S or below.

Return
MutableList<RouteInfo!> An unmodifiable List of RouteInfo for this link. This value cannot be null.

hashCode

Added in API level 21
fun hashCode(): Int

Generate hashcode based on significant fields Equal objects must produce the same hash code, while unequal objects may have the same hash codes.

Return
Int a hash code value for this object.

isPrivateDnsActive

Added in API level 28
fun isPrivateDnsActive(): Boolean

Returns whether private DNS is currently in use on this network. When private DNS is in use, applications must not send unencrypted DNS queries as doing so could reveal private user information. Furthermore, if private DNS is in use and getPrivateDnsServerName is not null, DNS queries must be sent to the specified DNS server.

Return
Boolean true if private DNS is in use, false otherwise.

isWakeOnLanSupported

Added in API level 30
fun isWakeOnLanSupported(): Boolean

Returns whether the network interface supports WakeOnLAN

Return
Boolean true if interface supports WakeOnLAN, false otherwise.

setDhcpServerAddress

Added in API level 30
fun setDhcpServerAddress(serverAddress: Inet4Address?): Unit

Set DHCP server address.

Parameters
serverAddress Inet4Address?: the server address to set. This value may be null.

setDnsServers

Added in API level 29
fun setDnsServers(dnsServers: MutableCollection<InetAddress!>): Unit

Replaces the DNS servers in this LinkProperties with the given Collection of InetAddress objects.

Parameters
dnsServers MutableCollection<InetAddress!>: The Collection of DNS servers to set in this object. This value cannot be null.

setDomains

Added in API level 29
fun setDomains(domains: String?): Unit

Sets the DNS domain search path used on this link.

Parameters
domains String?: A String listing in priority order the comma separated domains to search when resolving host names on this link. This value may be null.

setHttpProxy

Added in API level 29
fun setHttpProxy(proxy: ProxyInfo?): Unit

Sets the recommended ProxyInfo to use on this link, or null for none. Note that Http Proxies are only a hint - the system recommends their use, but it does not enforce it and applications may ignore them.

Parameters
proxy ProxyInfo?: A ProxyInfo defining the HTTP Proxy to use on this link. This value may be null.

setInterfaceName

Added in API level 29
fun setInterfaceName(iface: String?): Unit

Sets the interface name for this link. All RouteInfo already set for this will have their interface changed to match this new value.

Parameters
iface String?: The name of the network interface used for this link. This value may be null.

setLinkAddresses

Added in API level 29
fun setLinkAddresses(addresses: MutableCollection<LinkAddress!>): Unit

Replaces the LinkAddress in this LinkProperties with the given Collection of LinkAddress.

Parameters
addresses MutableCollection<LinkAddress!>: The Collection of LinkAddress to set in this object. This value cannot be null.

setMtu

Added in API level 29
fun setMtu(mtu: Int): Unit

Sets the Maximum Transmission Unit size to use on this link. This should not be used unless the system default (1500) is incorrect. Values less than 68 or greater than 10000 will be ignored.

Parameters
mtu Int: The MTU to use for this link.

setNat64Prefix

Added in API level 30
fun setNat64Prefix(prefix: IpPrefix?): Unit

Sets the NAT64 prefix in use on this link. Currently, only 96-bit prefixes (i.e., where the 32-bit IPv4 address is at the end of the 128-bit IPv6 address) are supported or null for no prefix.

Parameters
prefix IpPrefix?: the NAT64 prefix. This value may be null.

toString

Added in API level 21
fun toString(): String
Return
String a string representation of the object.

writeToParcel

Added in API level 21
fun writeToParcel(
    dest: Parcel,
    flags: Int
): Unit

Implement the Parcelable interface.

Parameters
dest Parcel: The Parcel in which the object should be written. This value cannot be null.
flags Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES

Properties

CREATOR

Added in API level 21
static val CREATOR: Parcelable.Creator<LinkProperties!>

Implement the Parcelable interface.