NetworkCapabilities
public
final
class
NetworkCapabilities
extends Object
implements
Parcelable
java.lang.Object | |
↳ | android.net.NetworkCapabilities |
Representation of the capabilities of an active network.
@see hasCapability(int). See the list of capabilities and each capability for a description of what it means.
Some prime examples include NET_CAPABILITY_MMS
, which means that the
network is capable of sending MMS. A network without this capability
is not capable of sending MMS.
The NET_CAPABILITY_INTERNET
capability means that the network is
configured to reach the general Internet. It may or may not actually
provide connectivity ; the NET_CAPABILITY_VALIDATED
bit indicates that
the system found actual connectivity to the general Internet the last
time it checked. Apps interested in actual connectivity should usually
look at both these capabilities.
The NET_CAPABILITY_NOT_METERED
capability is set for networks that
do not bill the user for consumption of bytes. Applications are
encouraged to consult this to determine appropriate usage, and to
limit usage of metered network where possible, including deferring
big downloads until such a time that an unmetered network is connected.
Also see JobScheduler
to help with scheduling such
downloads, in particular
JobInfo.Builder.setRequiredNetwork(NetworkRequest)
.
NetworkCapabilities contain a number of other capabilities that represent what modern networks can and can't do. Look up the individual capabilities in this class to learn about each of them.
NetworkCapabilities typically represent attributes that can apply to
any network. The attributes that apply only to specific transports like
cellular or Wi-Fi can be found in the specifier (for requestable attributes)
or in the transport info (for non-requestable ones). See
getNetworkSpecifier()
and getTransportInfo()
. An app would
downcast these to the specific class for the transport they need if they
are interested in transport-specific attributes. Also see
WifiNetworkSpecifier
or
WifiInfo
for some examples of each of these.
NetworkCapabilities also contains other attributes like the estimated
upstream and downstream bandwidth and the specific transport of that
network (e.g. TRANSPORT_CELLULAR
). Generally, apps should normally
have little reason to check for the type of transport ; for example, to
query whether a network costs money to the user, do not look at the
transport, but instead look at the absence or presence of
NET_CAPABILITY_NOT_METERED
which will correctly account for
metered Wi-Fis and free of charge cell connections.
The system communicates with apps about connected networks and uses
NetworkCapabilities to express these capabilities about these networks.
Apps should register callbacks with the ConnectivityManager.requestNetwork
or ConnectivityManager.registerNetworkCallback
family of methods
to learn about the capabilities of a network on a continuous basis
and be able to react to changes to capabilities. For quick debugging Android also
provides ConnectivityManager.getNetworkCapabilities(Network)
,
but the dynamic nature of networking makes this ill-suited to production
code since capabilities obtained in this way can go stale immediately.
Also see NetworkRequest
which uses the same capabilities
together with ConnectivityManager.requestNetwork
for how to
request the system brings up the kind of network your application needs.
Summary
Constants | |
---|---|
int |
NET_CAPABILITY_CAPTIVE_PORTAL
Indicates that this network was found to have a captive portal in place last time it was probed. |
int |
NET_CAPABILITY_CBS
Indicates this is a network that has the ability to reach the carrier's CBS servers, used for carrier specific services. |
int |
NET_CAPABILITY_DUN
Indicates this is a network that has the ability to reach the carrier's DUN or tethering gateway. |
int |
NET_CAPABILITY_EIMS
Indicates this is a network that has the ability to reach a carrier's Emergency IMS servers or other services, used for network signaling during emergency calls. |
int |
NET_CAPABILITY_ENTERPRISE
Indicates that this network is intended for enterprise use. |
int |
NET_CAPABILITY_FOREGROUND
Indicates that this network is available for use by apps, and not a network that is being kept up in the background to facilitate fast network switching. |
int |
NET_CAPABILITY_FOTA
Indicates this is a network that has the ability to reach the carrier's FOTA portal, used for over the air updates. |
int |
NET_CAPABILITY_HEAD_UNIT
Indicates that this network is connected to an automotive head unit. |
int |
NET_CAPABILITY_IA
Indicates this is a network that has the ability to reach a carrier's Initial Attach servers. |
int |
NET_CAPABILITY_IMS
Indicates this is a network that has the ability to reach the carrier's IMS servers, used for network registration and signaling. |
int |
NET_CAPABILITY_INTERNET
Indicates that this network should be able to reach the internet. |
int |
NET_CAPABILITY_LOCAL_NETWORK
Indicates that this network is a local network. |
int |
NET_CAPABILITY_MCX
Indicates this is a network that has the ability to reach a carrier's Mission Critical servers. |
int |
NET_CAPABILITY_MMS
Indicates this is a network that has the ability to reach the carrier's MMSC for sending and receiving MMS messages. |
int |
NET_CAPABILITY_MMTEL
Indicates that this network has ability to support MMTEL (Multimedia Telephony service). |
int |
NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED
Indicates that this is not a bandwidth-constrained network. |
int |
NET_CAPABILITY_NOT_CONGESTED
Indicates that this network is not congested. |
int |
NET_CAPABILITY_NOT_METERED
Indicates that this network is unmetered. |
int |
NET_CAPABILITY_NOT_RESTRICTED
Indicates that this network is available for general use. |
int |
NET_CAPABILITY_NOT_ROAMING
Indicates that this network is not roaming. |
int |
NET_CAPABILITY_NOT_SUSPENDED
Indicates that this network is not currently suspended. |
int |
NET_CAPABILITY_NOT_VPN
Indicates that this network is not a VPN. |
int |
NET_CAPABILITY_PRIORITIZE_BANDWIDTH
Indicates that this network should be able to prioritize bandwidth for the internet. |
int |
NET_CAPABILITY_PRIORITIZE_LATENCY
Indicates that this network should be able to prioritize latency for the internet. |
int |
NET_CAPABILITY_RCS
Indicates this is a network that has the ability to reach a carrier's RCS servers, used for Rich Communication Services. |
int |
NET_CAPABILITY_SUPL
Indicates this is a network that has the ability to reach the carrier's SUPL server, used to retrieve GPS information. |
int |
NET_CAPABILITY_TEMPORARILY_NOT_METERED
Indicates that this network is temporarily unmetered. |
int |
NET_CAPABILITY_TRUSTED
Indicates that the user has indicated implicit trust of this network. |
int |
NET_CAPABILITY_VALIDATED
Indicates that connectivity on this network was successfully validated. |
int |
NET_CAPABILITY_WIFI_P2P
Indicates this is a network that has the ability to reach a Wi-Fi direct peer. |
int |
NET_CAPABILITY_XCAP
Indicates this is a network that has the ability to reach a carrier's XCAP servers, used for configuration and control. |
int |
NET_ENTERPRISE_ID_1
Enterprise capability identifier 1. |
int |
NET_ENTERPRISE_ID_2
Enterprise capability identifier 2. |
int |
NET_ENTERPRISE_ID_3
Enterprise capability identifier 3. |
int |
NET_ENTERPRISE_ID_4
Enterprise capability identifier 4. |
int |
NET_ENTERPRISE_ID_5
Enterprise capability identifier 5. |
int |
SIGNAL_STRENGTH_UNSPECIFIED
Magic value that indicates no signal strength provided. |
int |
TRANSPORT_BLUETOOTH
Indicates this network uses a Bluetooth transport. |
int |
TRANSPORT_CELLULAR
Indicates this network uses a Cellular transport. |
int |
TRANSPORT_ETHERNET
Indicates this network uses an Ethernet transport. |
int |
TRANSPORT_LOWPAN
Indicates this network uses a LoWPAN transport. |
int |
TRANSPORT_SATELLITE
Indicates this network uses a Satellite transport. |
int |
TRANSPORT_THREAD
Indicates this network uses a Thread transport. |
int |
TRANSPORT_USB
Indicates this network uses a USB transport. |
int |
TRANSPORT_VPN
Indicates this network uses a VPN transport. |
int |
TRANSPORT_WIFI
Indicates this network uses a Wi-Fi transport. |
int |
TRANSPORT_WIFI_AWARE
Indicates this network uses a Wi-Fi Aware transport. |
Inherited constants |
---|
Fields | |
---|---|
public
static
final
Creator<NetworkCapabilities> |
CREATOR
|
Public constructors | |
---|---|
NetworkCapabilities()
|
|
NetworkCapabilities(NetworkCapabilities nc)
|
Public methods | |
---|---|
int
|
describeContents()
Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one. |
int[]
|
getCapabilities()
Gets all the capabilities set on this |
int[]
|
getEnterpriseIds()
Get enteprise identifiers set. |
int
|
getLinkDownstreamBandwidthKbps()
Retrieves the downstream bandwidth for this network in Kbps. |
int
|
getLinkUpstreamBandwidthKbps()
Retrieves the upstream bandwidth for this network in Kbps. |
NetworkSpecifier
|
getNetworkSpecifier()
Gets the optional bearer specific network specifier. |
int
|
getOwnerUid()
Retrieves the UID of the app that owns this network. |
int
|
getSignalStrength()
Retrieves the signal strength. |
Set<Integer>
|
getSubscriptionIds()
Gets the subscription ID set that associated to this network or request. |
TransportInfo
|
getTransportInfo()
Returns a transport-specific information container. |
boolean
|
hasCapability(int capability)
Tests for the presence of a capability on this instance. |
boolean
|
hasEnterpriseId(int enterpriseId)
Tests for the presence of an enterprise capability identifier on this instance. |
boolean
|
hasTransport(int transportType)
Tests for the presence of a transport on this instance. |
int
|
hashCode()
Returns a hash code value for the object. |
String
|
toString()
Returns a string representation of the object. |
void
|
writeToParcel(Parcel dest, int flags)
Flatten this object in to a Parcel. |
Inherited methods | |
---|---|
Constants
NET_CAPABILITY_CAPTIVE_PORTAL
public static final int NET_CAPABILITY_CAPTIVE_PORTAL
Indicates that this network was found to have a captive portal in place last time it was probed.
Constant Value: 17 (0x00000011)
NET_CAPABILITY_CBS
public static final int NET_CAPABILITY_CBS
Indicates this is a network that has the ability to reach the carrier's CBS servers, used for carrier specific services.
Constant Value: 5 (0x00000005)
NET_CAPABILITY_DUN
public static final int NET_CAPABILITY_DUN
Indicates this is a network that has the ability to reach the carrier's DUN or tethering gateway.
Constant Value: 2 (0x00000002)
NET_CAPABILITY_EIMS
public static final int NET_CAPABILITY_EIMS
Indicates this is a network that has the ability to reach a carrier's Emergency IMS servers or other services, used for network signaling during emergency calls.
Constant Value: 10 (0x0000000a)
NET_CAPABILITY_ENTERPRISE
public static final int NET_CAPABILITY_ENTERPRISE
Indicates that this network is intended for enterprise use.
5G URSP rules may indicate that all data should use a connection dedicated for enterprise use. If the enterprise capability is requested, all enterprise traffic will be routed over the connection with this capability.
Constant Value: 29 (0x0000001d)
NET_CAPABILITY_FOREGROUND
public static final int NET_CAPABILITY_FOREGROUND
Indicates that this network is available for use by apps, and not a network that is being kept up in the background to facilitate fast network switching.
Constant Value: 19 (0x00000013)
NET_CAPABILITY_FOTA
public static final int NET_CAPABILITY_FOTA
Indicates this is a network that has the ability to reach the carrier's FOTA portal, used for over the air updates.
Constant Value: 3 (0x00000003)
NET_CAPABILITY_HEAD_UNIT
public static final int NET_CAPABILITY_HEAD_UNIT
Indicates that this network is connected to an automotive head unit.
Constant Value: 32 (0x00000020)
NET_CAPABILITY_IA
public static final int NET_CAPABILITY_IA
Indicates this is a network that has the ability to reach a carrier's Initial Attach servers.
Constant Value: 7 (0x00000007)
NET_CAPABILITY_IMS
public static final int NET_CAPABILITY_IMS
Indicates this is a network that has the ability to reach the carrier's IMS servers, used for network registration and signaling.
Constant Value: 4 (0x00000004)
NET_CAPABILITY_INTERNET
public static final int NET_CAPABILITY_INTERNET
Indicates that this network should be able to reach the internet.
Constant Value: 12 (0x0000000c)
NET_CAPABILITY_LOCAL_NETWORK
public static final int NET_CAPABILITY_LOCAL_NETWORK
Indicates that this network is a local network. Local networks are networks where the device is not obtaining IP addresses from the network, but advertising IP addresses itself. Examples of local networks are:
- USB tethering or Wi-Fi hotspot networks to which the device is sharing its Internet connectivity.
- Thread networks where the current device is the Thread Border Router.
- Wi-Fi P2P networks where the current device is the Group Owner.
ERROR(/Build.VERSION_CODES.VANILLA_ICE_CREAM)
will not see
networks with this capability unless they explicitly set the NET_CAPABILITY_LOCAL_NETWORK
in their NetworkRequests.
Constant Value: 36 (0x00000024)
NET_CAPABILITY_MCX
public static final int NET_CAPABILITY_MCX
Indicates this is a network that has the ability to reach a carrier's Mission Critical servers.
Constant Value: 23 (0x00000017)
NET_CAPABILITY_MMS
public static final int NET_CAPABILITY_MMS
Indicates this is a network that has the ability to reach the carrier's MMSC for sending and receiving MMS messages.
Constant Value: 0 (0x00000000)
NET_CAPABILITY_MMTEL
public static final int NET_CAPABILITY_MMTEL
Indicates that this network has ability to support MMTEL (Multimedia Telephony service).
Constant Value: 33 (0x00000021)
NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED
public static final int NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED
Indicates that this is not a bandwidth-constrained network.
Starting from ERROR(/Build.VERSION_CODES.VANILLA_ICE_CREAM)
, this capability is by default
set in NetworkRequest
s and true for most networks.
If a network lacks this capability, it is bandwidth-constrained. Bandwidth constrained
networks cannot support high-bandwidth data transfers and applications that request and use
them must ensure that they limit bandwidth usage to below the values returned by
getLinkDownstreamBandwidthKbps()
and getLinkUpstreamBandwidthKbps()
and
limit the frequency of their network usage. If applications perform high-bandwidth data
transfers on constrained networks or perform network access too frequently, the system may
block the app's access to the network. The system may take other measures to reduce network
usage on constrained networks, such as disabling network access to apps that are not in the
foreground.
Constant Value: 37 (0x00000025)
NET_CAPABILITY_NOT_CONGESTED
public static final int NET_CAPABILITY_NOT_CONGESTED
Indicates that this network is not congested.
When a network is congested, applications should defer network traffic that can be done at a later time, such as uploading analytics.
Constant Value: 20 (0x00000014)
NET_CAPABILITY_NOT_METERED
public static final int NET_CAPABILITY_NOT_METERED
Indicates that this network is unmetered.
Constant Value: 11 (0x0000000b)
NET_CAPABILITY_NOT_RESTRICTED
public static final int NET_CAPABILITY_NOT_RESTRICTED
Indicates that this network is available for general use. If this is not set applications should not attempt to communicate on this network. Note that this is simply informative and not enforcement - enforcement is handled via other means. Set by default.
Constant Value: 13 (0x0000000d)
NET_CAPABILITY_NOT_ROAMING
public static final int NET_CAPABILITY_NOT_ROAMING
Indicates that this network is not roaming.
Constant Value: 18 (0x00000012)
NET_CAPABILITY_NOT_SUSPENDED
public static final int NET_CAPABILITY_NOT_SUSPENDED
Indicates that this network is not currently suspended.
When a network is suspended, the network's IP addresses and any connections established on the network remain valid, but the network is temporarily unable to transfer data. This can happen, for example, if a cellular network experiences a temporary loss of signal, such as when driving through a tunnel, etc. A network with this capability is not suspended, so is expected to be able to transfer data.
Constant Value: 21 (0x00000015)
NET_CAPABILITY_NOT_VPN
public static final int NET_CAPABILITY_NOT_VPN
Indicates that this network is not a VPN. This capability is set by default and should be explicitly cleared for VPN networks.
Constant Value: 15 (0x0000000f)
NET_CAPABILITY_PRIORITIZE_BANDWIDTH
public static final int NET_CAPABILITY_PRIORITIZE_BANDWIDTH
Indicates that this network should be able to prioritize bandwidth for the internet.
Starting with Build.VERSION_CODES.UPSIDE_DOWN_CAKE
, requesting this capability with
ConnectivityManager.requestNetwork
requires declaration in the self-certified
network capabilities. See NetworkRequest
for the self-certification documentation.
Constant Value: 35 (0x00000023)
NET_CAPABILITY_PRIORITIZE_LATENCY
public static final int NET_CAPABILITY_PRIORITIZE_LATENCY
Indicates that this network should be able to prioritize latency for the internet.
Starting with Build.VERSION_CODES.UPSIDE_DOWN_CAKE
, requesting this capability with
ConnectivityManager.requestNetwork
requires declaration in the self-certified
network capabilities. See NetworkRequest
for the self-certification documentation.
Constant Value: 34 (0x00000022)
NET_CAPABILITY_RCS
public static final int NET_CAPABILITY_RCS
Indicates this is a network that has the ability to reach a carrier's RCS servers, used for Rich Communication Services.
Constant Value: 8 (0x00000008)
NET_CAPABILITY_SUPL
public static final int NET_CAPABILITY_SUPL
Indicates this is a network that has the ability to reach the carrier's SUPL server, used to retrieve GPS information.
Constant Value: 1 (0x00000001)
NET_CAPABILITY_TEMPORARILY_NOT_METERED
public static final int NET_CAPABILITY_TEMPORARILY_NOT_METERED
Indicates that this network is temporarily unmetered.
This capability will be set for networks that are generally metered, but are currently
unmetered, e.g., because the user is in a particular area. This capability can be changed at
any time. When it is removed, applications are responsible for stopping any data transfer
that should not occur on a metered network.
Note that most apps should use NET_CAPABILITY_NOT_METERED
instead. For more
information, see https://developer.android.com/about/versions/11/features/5g#meteredness.
Constant Value: 25 (0x00000019)
NET_CAPABILITY_TRUSTED
public static final int NET_CAPABILITY_TRUSTED
Indicates that the user has indicated implicit trust of this network. This generally means it's a sim-selected carrier, a plugged in ethernet, a paired BT device or a wifi the user asked to connect to. Untrusted networks are probably limited to unknown wifi AP. Set by default.
Constant Value: 14 (0x0000000e)
NET_CAPABILITY_VALIDATED
public static final int NET_CAPABILITY_VALIDATED
Indicates that connectivity on this network was successfully validated. For example, for a network with NET_CAPABILITY_INTERNET, it means that Internet connectivity was successfully detected.
Constant Value: 16 (0x00000010)
NET_CAPABILITY_WIFI_P2P
public static final int NET_CAPABILITY_WIFI_P2P
Indicates this is a network that has the ability to reach a Wi-Fi direct peer.
Constant Value: 6 (0x00000006)
NET_CAPABILITY_XCAP
public static final int NET_CAPABILITY_XCAP
Indicates this is a network that has the ability to reach a carrier's XCAP servers, used for configuration and control.
Constant Value: 9 (0x00000009)
NET_ENTERPRISE_ID_1
public static final int NET_ENTERPRISE_ID_1
Enterprise capability identifier 1. It will be used to uniquely identify specific enterprise network.
Constant Value: 1 (0x00000001)
NET_ENTERPRISE_ID_2
public static final int NET_ENTERPRISE_ID_2
Enterprise capability identifier 2. It will be used to uniquely identify specific enterprise network.
Constant Value: 2 (0x00000002)
NET_ENTERPRISE_ID_3
public static final int NET_ENTERPRISE_ID_3
Enterprise capability identifier 3. It will be used to uniquely identify specific enterprise network.
Constant Value: 3 (0x00000003)
NET_ENTERPRISE_ID_4
public static final int NET_ENTERPRISE_ID_4
Enterprise capability identifier 4. It will be used to uniquely identify specific enterprise network.
Constant Value: 4 (0x00000004)
NET_ENTERPRISE_ID_5
public static final int NET_ENTERPRISE_ID_5
Enterprise capability identifier 5. It will be used to uniquely identify specific enterprise network.
Constant Value: 5 (0x00000005)
SIGNAL_STRENGTH_UNSPECIFIED
public static final int SIGNAL_STRENGTH_UNSPECIFIED
Magic value that indicates no signal strength provided. A request specifying this value is always satisfied.
Constant Value: -2147483648 (0x80000000)
TRANSPORT_BLUETOOTH
public static final int TRANSPORT_BLUETOOTH
Indicates this network uses a Bluetooth transport.
Constant Value: 2 (0x00000002)
TRANSPORT_CELLULAR
public static final int TRANSPORT_CELLULAR
Indicates this network uses a Cellular transport.
Constant Value: 0 (0x00000000)
TRANSPORT_ETHERNET
public static final int TRANSPORT_ETHERNET
Indicates this network uses an Ethernet transport.
Constant Value: 3 (0x00000003)
TRANSPORT_LOWPAN
public static final int TRANSPORT_LOWPAN
Indicates this network uses a LoWPAN transport.
Constant Value: 6 (0x00000006)
TRANSPORT_SATELLITE
public static final int TRANSPORT_SATELLITE
Indicates this network uses a Satellite transport.
Constant Value: 10 (0x0000000a)
TRANSPORT_THREAD
public static final int TRANSPORT_THREAD
Indicates this network uses a Thread transport.
Constant Value: 9 (0x00000009)
TRANSPORT_USB
public static final int TRANSPORT_USB
Indicates this network uses a USB transport.
Constant Value: 8 (0x00000008)
TRANSPORT_VPN
public static final int TRANSPORT_VPN
Indicates this network uses a VPN transport.
Constant Value: 4 (0x00000004)
TRANSPORT_WIFI
public static final int TRANSPORT_WIFI
Indicates this network uses a Wi-Fi transport.
Constant Value: 1 (0x00000001)
TRANSPORT_WIFI_AWARE
public static final int TRANSPORT_WIFI_AWARE
Indicates this network uses a Wi-Fi Aware transport.
Constant Value: 5 (0x00000005)
Fields
Public constructors
NetworkCapabilities
public NetworkCapabilities (NetworkCapabilities nc)
Parameters | |
---|---|
nc |
NetworkCapabilities |
Public methods
describeContents
public int describeContents ()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation. For example, if the object will
include a file descriptor in the output of writeToParcel(android.os.Parcel, int)
,
the return value of this method must include the
CONTENTS_FILE_DESCRIPTOR
bit.
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
public boolean equals (Object obj)
Indicates whether some other object is "equal to" this one.
The equals
method implements an equivalence relation
on non-null object references:
- It is reflexive: for any non-null reference value
x
,x.equals(x)
should returntrue
. - It is symmetric: for any non-null reference values
x
andy
,x.equals(y)
should returntrue
if and only ify.equals(x)
returnstrue
. - It is transitive: for any non-null reference values
x
,y
, andz
, ifx.equals(y)
returnstrue
andy.equals(z)
returnstrue
, thenx.equals(z)
should returntrue
. - It is consistent: for any non-null reference values
x
andy
, multiple invocations ofx.equals(y)
consistently returntrue
or consistently returnfalse
, provided no information used inequals
comparisons on the objects is modified. - For any non-null reference value
x
,x.equals(null)
should returnfalse
.
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
Parameters | |
---|---|
obj |
Object : This value may be null . |
Returns | |
---|---|
boolean |
true if this object is the same as the obj
argument; false otherwise. |
getCapabilities
public int[] getCapabilities ()
Gets all the capabilities set on this NetworkCapability
instance.
getEnterpriseIds
public int[] getEnterpriseIds ()
Get enteprise identifiers set.
Get all the enterprise capabilities identifier set on this NetworkCapability
If NET_CAPABILITY_ENTERPRISE is set and no enterprise ID is set, it is
considered to have NET_CAPABILITY_ENTERPRISE by default.
Returns | |
---|---|
int[] |
all the enterprise capabilities identifier set.
This value cannot be null .
Value is NET_ENTERPRISE_ID_1 , NET_ENTERPRISE_ID_2 , NET_ENTERPRISE_ID_3 , NET_ENTERPRISE_ID_4 , or NET_ENTERPRISE_ID_5 |
getLinkDownstreamBandwidthKbps
public int getLinkDownstreamBandwidthKbps ()
Retrieves the downstream bandwidth for this network in Kbps. This always only refers to the estimated first hop transport bandwidth.
Returns | |
---|---|
int |
The estimated first hop downstream (network to device) bandwidth. |
getLinkUpstreamBandwidthKbps
public int getLinkUpstreamBandwidthKbps ()
Retrieves the upstream bandwidth for this network in Kbps. This always only refers to the estimated first hop transport bandwidth.
Returns | |
---|---|
int |
The estimated first hop upstream (device to network) bandwidth. |
getNetworkSpecifier
public NetworkSpecifier getNetworkSpecifier ()
Gets the optional bearer specific network specifier. May be null
if not set.
Returns | |
---|---|
NetworkSpecifier |
The optional NetworkSpecifier specifying the bearer specific network
specifier or null . |
getOwnerUid
public int getOwnerUid ()
Retrieves the UID of the app that owns this network.
For user privacy reasons, this field will only be populated if the following conditions are met:
The caller is the network owner, AND one of the following sets of requirements is met:
- The described Network is a VPN
OR:
- The calling app is the network owner
- The calling app has the ACCESS_FINE_LOCATION permission granted
- The user's location toggle is on
This field will only be populated for VPN and wifi network suggestor apps (i.e using
WifiNetworkSuggestion
), and only for the
network they own. In the case of wifi network suggestors apps, this field is also location
sensitive, so the app needs to hold Manifest.permission.ACCESS_FINE_LOCATION
permission. If the app targets SDK version greater than or equal to
Build.VERSION_CODES.S
, then they also need to use
NetworkCallback.FLAG_INCLUDE_LOCATION_INFO
to get the info in their callback. If the
apps targets SDK version equal to {Build.VERSION_CODES.R
, this field will always be
included. The app will be blamed for location access if this field is included.
Returns | |
---|---|
int |
getSignalStrength
public int getSignalStrength ()
Retrieves the signal strength.
Returns | |
---|---|
int |
The bearer-specific signal strength. |
getSubscriptionIds
public Set<Integer> getSubscriptionIds ()
Gets the subscription ID set that associated to this network or request.
Instances of NetworkCapabilities will only have this field populated by the system if the receiver holds the NETWORK_FACTORY permission. In all other cases, it will be the empty set.
Returns | |
---|---|
Set<Integer> |
This value cannot be null . |
getTransportInfo
public TransportInfo getTransportInfo ()
Returns a transport-specific information container. The application may cast this
container to a concrete sub-class based on its knowledge of the network request. The
application should be able to deal with a null
return value or an invalid case,
e.g. use instanceof
operator to verify expected type.
Returns | |
---|---|
TransportInfo |
A concrete implementation of the TransportInfo class or null if not
available for the network. |
hasCapability
public boolean hasCapability (int capability)
Tests for the presence of a capability on this instance.
Returns | |
---|---|
boolean |
true if set on this instance. |
hasEnterpriseId
public boolean hasEnterpriseId (int enterpriseId)
Tests for the presence of an enterprise capability identifier on this instance. If NET_CAPABILITY_ENTERPRISE is set and no enterprise ID is set, it is considered to have NET_CAPABILITY_ENTERPRISE by default.
Parameters | |
---|---|
enterpriseId |
int : the enterprise capability identifier to be tested for.
Value is NET_ENTERPRISE_ID_1 , NET_ENTERPRISE_ID_2 , NET_ENTERPRISE_ID_3 , NET_ENTERPRISE_ID_4 , or NET_ENTERPRISE_ID_5 |
Returns | |
---|---|
boolean |
true if set on this instance. |
hasTransport
public boolean hasTransport (int transportType)
Tests for the presence of a transport on this instance.
Parameters | |
---|---|
transportType |
int : the transport type to be tested for.
Value is TRANSPORT_CELLULAR , TRANSPORT_WIFI , TRANSPORT_BLUETOOTH , TRANSPORT_ETHERNET , TRANSPORT_VPN , TRANSPORT_WIFI_AWARE , TRANSPORT_LOWPAN , android.net.NetworkCapabilities.TRANSPORT_TEST, TRANSPORT_USB , TRANSPORT_THREAD , or TRANSPORT_SATELLITE |
Returns | |
---|---|
boolean |
true if set on this instance. |
hashCode
public int hashCode ()
Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
HashMap
.
The general contract of hashCode
is:
- Whenever it is invoked on the same object more than once during
an execution of a Java application, the
hashCode
method must consistently return the same integer, provided no information used inequals
comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application. - If two objects are equal according to the
equals
method, then calling thehashCode
method on each of the two objects must produce the same integer result. - It is not required that if two objects are unequal
according to the
equals
method, then calling thehashCode
method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns | |
---|---|
int |
a hash code value for this object. |
toString
public String toString ()
Returns a string representation of the object.
Returns | |
---|---|
String |
This value cannot be null . |
writeToParcel
public void writeToParcel (Parcel dest, int flags)
Flatten this object in to a Parcel.
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.PARCELABLE_WRITE_RETURN_VALUE .
Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE , and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES |