Save the date! Android Dev Summit is coming to Sunnyvale, CA on Oct 23-24, 2019.

LinkProperties

public final class LinkProperties
extends Object implements Parcelable

java.lang.Object
   ↳ 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

Fields

public static final Creator<LinkProperties> CREATOR

Implement the Parcelable interface.

Public methods

int describeContents()

Implement the Parcelable interface

boolean equals(Object obj)

Compares this LinkProperties instance against the target LinkProperties in obj.

List<InetAddress> getDnsServers()

Returns all the InetAddress for DNS servers on this link.

String getDomains()

Get the DNS domains search path set for this link.

ProxyInfo getHttpProxy()

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

String getInterfaceName()

Gets the interface name for this link.

List<LinkAddress> getLinkAddresses()

Returns all the LinkAddress on this link.

int getMtu()

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

String getPrivateDnsServerName()

Returns the private DNS server name that is in use.

List<RouteInfo> getRoutes()

Returns all the RouteInfo set on this link.

int hashCode()

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

boolean isPrivateDnsActive()

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

String toString()

Returns a string representation of the object.

void writeToParcel(Parcel dest, int flags)

Implement the Parcelable interface.

Inherited methods

Fields

CREATOR

Added in API level 21
public static final Creator<LinkProperties> CREATOR

Implement the Parcelable interface.

Public methods

describeContents

Added in API level 21
public int describeContents ()

Implement the Parcelable interface

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or CONTENTS_FILE_DESCRIPTOR

equals

Added in API level 21
public boolean equals (Object obj)

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 Object: the object to be tested for equality.

Returns
boolean true if both objects are equal, false otherwise.

getDnsServers

Added in API level 21
public List<InetAddress> getDnsServers ()

Returns all the InetAddress for DNS servers on this link.

Returns
List<InetAddress> An unmodifiable List of InetAddress for DNS servers on this link.

getDomains

Added in API level 21
public String getDomains ()

Get the DNS domains search path set for this link.

Returns
String A String containing the comma separated domains to search when resolving host names on this link.

getHttpProxy

Added in API level 21
public ProxyInfo getHttpProxy ()

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

Returns
ProxyInfo The ProxyInfo set on this link

getInterfaceName

Added in API level 21
public String getInterfaceName ()

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

Returns
String The interface name set for this link or null.

getLinkAddresses

Added in API level 21
public List<LinkAddress> getLinkAddresses ()

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

Returns
List<LinkAddress> An unmodifiable List of LinkAddress for this link.

getMtu

public int getMtu ()

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

Returns
int The mtu value set for this link.

getPrivateDnsServerName

Added in API level 28
public String getPrivateDnsServerName ()

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.

Returns
String The private DNS server name.

getRoutes

Added in API level 21
public List<RouteInfo> getRoutes ()

Returns all the RouteInfo set on this link.

Returns
List<RouteInfo> An unmodifiable List of RouteInfo for this link.

hashCode

Added in API level 21
public int hashCode ()

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

Returns
int a hash code value for this object.

isPrivateDnsActive

Added in API level 28
public boolean isPrivateDnsActive ()

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.

Returns
boolean true if private DNS is in use, false otherwise.

toString

Added in API level 21
public String toString ()

Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Returns
String a string representation of the object.

writeToParcel

Added in API level 21
public void writeToParcel (Parcel dest, 
                int flags)

Implement the Parcelable interface.

Parameters
dest Parcel: The Parcel in which the object should be written.

flags int: Additional flags about how the object should be written. May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES