Builder
class Builder
kotlin.Any | |
↳ | android.app.admin.PreferentialNetworkServiceConfig.Builder |
Builder used to create PreferentialNetworkServiceConfig
objects. Specify the preferred Network preference
Summary
Public constructors | |
---|---|
Builder() Constructs an empty Builder with preferential network disabled by default. |
Public methods | |
---|---|
PreferentialNetworkServiceConfig |
build() Returns an instance of |
PreferentialNetworkServiceConfig.Builder |
setEnabled(isEnabled: Boolean) Set the preferential network service enabled state. |
PreferentialNetworkServiceConfig.Builder |
setExcludedUids(uids: IntArray) Set the array of uids who are not allowed through this preferential network service. |
PreferentialNetworkServiceConfig.Builder |
setFallbackToDefaultConnectionAllowed(allowFallbackToDefaultConnection: Boolean) Set whether fallback to the device-wide default network is allowed. |
PreferentialNetworkServiceConfig.Builder |
setIncludedUids(uids: IntArray) Set the array of uids whose network access will go through this preferential network service. |
PreferentialNetworkServiceConfig.Builder |
setNetworkId(preferenceId: Int) Set the preferential network identifier. |
PreferentialNetworkServiceConfig.Builder |
setShouldBlockNonMatchingNetworks(blockNonMatchingNetworks: Boolean) Set whether to block UIDs from using other networks than the preferential service. |
Public constructors
Builder
Builder()
Constructs an empty Builder with preferential network disabled by default.
Public methods
build
fun build(): PreferentialNetworkServiceConfig
Returns an instance of PreferentialNetworkServiceConfig
created from the fields set on this builder.
Return | |
---|---|
PreferentialNetworkServiceConfig |
This value cannot be null . |
setEnabled
fun setEnabled(isEnabled: Boolean): PreferentialNetworkServiceConfig.Builder
Set the preferential network service enabled state. Default value is false.
Parameters | |
---|---|
isEnabled |
Boolean: the desired network preference to use, true to enable else false |
Return | |
---|---|
PreferentialNetworkServiceConfig.Builder |
The builder to facilitate chaining. This value cannot be null . |
setExcludedUids
fun setExcludedUids(uids: IntArray): PreferentialNetworkServiceConfig.Builder
Set the array of uids who are not allowed through this preferential network service. {@see #setIncludedUids(int[])} Included UIDs and Excluded UIDs can't both be non-empty. if both are empty, it means this request applies to all uids in the user profile. if included is not empty, then only included UIDs are applied. if excluded is not empty, then it is all uids in the user profile except these UIDs.
Parameters | |
---|---|
uids |
IntArray: array of excluded uids This value cannot be null . |
Return | |
---|---|
PreferentialNetworkServiceConfig.Builder |
The builder to facilitate chaining. This value cannot be null . |
setFallbackToDefaultConnectionAllowed
fun setFallbackToDefaultConnectionAllowed(allowFallbackToDefaultConnection: Boolean): PreferentialNetworkServiceConfig.Builder
Set whether fallback to the device-wide default network is allowed. This boolean configures whether the default connection (e.g. general cell network or wifi) should be used if no preferential network service connection is available. If true, the default connection will be used when no preferential service is available. If false, the UIDs subject to this configuration will have no default network. Note that while this boolean determines whether the UIDs subject to this configuration have a default network in the absence of a preferential service, apps can still explicitly decide to use another network than their default network by requesting them from the system. This boolean does not determine whether the UIDs are blocked from using such other networks. Use setShouldBlockNonMatchingNetworks(boolean)
to specify this. The default value is true.
Parameters | |
---|---|
allowFallbackToDefaultConnection |
Boolean: true if fallback is allowed else false |
Return | |
---|---|
PreferentialNetworkServiceConfig.Builder |
The builder to facilitate chaining. This value cannot be null . |
setIncludedUids
fun setIncludedUids(uids: IntArray): PreferentialNetworkServiceConfig.Builder
Set the array of uids whose network access will go through this preferential network service. {@see #setExcludedUids(int[])} Included UIDs and Excluded UIDs can't both be non-empty. if both are empty, it means this request applies to all uids in the user profile. if included is not empty, then only included UIDs are applied. if excluded is not empty, then it is all uids in the user profile except these UIDs.
Parameters | |
---|---|
uids |
IntArray: array of included uids This value cannot be null . |
Return | |
---|---|
PreferentialNetworkServiceConfig.Builder |
The builder to facilitate chaining. This value cannot be null . |
setNetworkId
fun setNetworkId(preferenceId: Int): PreferentialNetworkServiceConfig.Builder
Set the preferential network identifier. preference identifier is applicable only if preferential network service is enabled.
Return | |
---|---|
PreferentialNetworkServiceConfig.Builder |
The builder to facilitate chaining. This value cannot be null . |
setShouldBlockNonMatchingNetworks
fun setShouldBlockNonMatchingNetworks(blockNonMatchingNetworks: Boolean): PreferentialNetworkServiceConfig.Builder
Set whether to block UIDs from using other networks than the preferential service. Apps can inspect the list of available networks on the device and choose to use multiple of them concurrently for performance, privacy or other reasons. This boolean configures whether the concerned UIDs should be blocked from using networks that do not match the configured preferential network service even if these networks are otherwise open to all apps. The default value is false. This value can only be set to true
if setFallbackToDefaultConnectionAllowed(boolean)
is set to false
, because allowing fallback but blocking it does not make sense. Failure to comply with this constraint will throw when building the object.
Parameters | |
---|---|
blockNonMatchingNetworks |
Boolean: true if UIDs should be blocked from using non-matching networks. |
Return | |
---|---|
PreferentialNetworkServiceConfig.Builder |
The builder to facilitate chaining. This value cannot be null . |