Stay organized with collections Save and categorize content based on your preferences.

PreferentialNetworkServiceConfig.Builder

public static final class PreferentialNetworkServiceConfig.Builder
extends Object

java.lang.Object
   ↳ 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 created from the fields set on this builder.

PreferentialNetworkServiceConfig.Builder setEnabled(boolean isEnabled)

Set the preferential network service enabled state.

PreferentialNetworkServiceConfig.Builder setExcludedUids(int[] uids)

Set the array of uids who are not allowed through this preferential network service.

PreferentialNetworkServiceConfig.Builder setFallbackToDefaultConnectionAllowed(boolean allowFallbackToDefaultConnection)

Set whether the default connection should be used as fallback.

PreferentialNetworkServiceConfig.Builder setIncludedUids(int[] uids)

Set the array of uids whose network access will go through this preferential network service.

PreferentialNetworkServiceConfig.Builder setNetworkId(int preferenceId)

Set the preferential network identifier.

Inherited methods

Public constructors

Builder

Added in API level 33
public Builder ()

Constructs an empty Builder with preferential network disabled by default.

Public methods

build

Added in API level 33
public PreferentialNetworkServiceConfig build ()

Returns an instance of PreferentialNetworkServiceConfig created from the fields set on this builder.

Returns
PreferentialNetworkServiceConfig This value cannot be null.

setEnabled

Added in API level 33
public PreferentialNetworkServiceConfig.Builder setEnabled (boolean isEnabled)

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

Returns
PreferentialNetworkServiceConfig.Builder The builder to facilitate chaining. This value cannot be null.

setExcludedUids

Added in API level 33
public PreferentialNetworkServiceConfig.Builder setExcludedUids (int[] uids)

Set the array of uids who are not allowed through this preferential network service. 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 int: array of excluded uids This value cannot be null.

Returns
PreferentialNetworkServiceConfig.Builder The builder to facilitate chaining. This value cannot be null.

setFallbackToDefaultConnectionAllowed

Added in API level 33
public PreferentialNetworkServiceConfig.Builder setFallbackToDefaultConnectionAllowed (boolean allowFallbackToDefaultConnection)

Set whether the default connection should be used as fallback. This boolean configures whether the default connection (default internet or wifi) should be used if a preferential network service connection is not available. Default value is true

Parameters
allowFallbackToDefaultConnection boolean: true if fallback is allowed else false

Returns
PreferentialNetworkServiceConfig.Builder The builder to facilitate chaining. This value cannot be null.

setIncludedUids

Added in API level 33
public PreferentialNetworkServiceConfig.Builder setIncludedUids (int[] uids)

Set the array of uids whose network access will go through this preferential network service. 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 int: array of included uids This value cannot be null.

Returns
PreferentialNetworkServiceConfig.Builder The builder to facilitate chaining. This value cannot be null.

setNetworkId

Added in API level 33
public PreferentialNetworkServiceConfig.Builder setNetworkId (int preferenceId)

Set the preferential network identifier. preference identifier is applicable only if preferential network service is enabled.

Parameters
preferenceId int: preference Id Value is PreferentialNetworkServiceConfig.PREFERENTIAL_NETWORK_ID_1, PreferentialNetworkServiceConfig.PREFERENTIAL_NETWORK_ID_2, PreferentialNetworkServiceConfig.PREFERENTIAL_NETWORK_ID_3, PreferentialNetworkServiceConfig.PREFERENTIAL_NETWORK_ID_4, or PreferentialNetworkServiceConfig.PREFERENTIAL_NETWORK_ID_5

Returns
PreferentialNetworkServiceConfig.Builder The builder to facilitate chaining. This value cannot be null.