VcnManager
public
class
VcnManager
extends Object
java.lang.Object | |
↳ | android.net.vcn.VcnManager |
VcnManager publishes APIs for applications to configure and manage Virtual Carrier Networks.
A VCN creates a virtualization layer to allow carriers to aggregate heterogeneous physical networks, unifying them as a single carrier network. This enables infrastructure flexibility on the part of carriers without impacting user connectivity, abstracting the physical network technologies as an implementation detail of their public network.
Each VCN virtualizes a carrier's network by building tunnels to a carrier's core network over
carrier-managed physical links and supports a IP mobility layer to ensure seamless transitions
between the underlying networks. Each VCN is configured based on a Subscription Group (see SubscriptionManager
) and aggregates all networks that are brought up based on
a profile or suggestion in the specified Subscription Group.
The VCN can be configured to expose one or more Network
(s), each with
different capabilities, allowing for APN virtualization.
If a tunnel fails to connect, or otherwise encounters a fatal error, the VCN will attempt to reestablish the connection. If the tunnel still has not reconnected after a system-determined timeout, the VCN Safe Mode (see below) will be entered.
The VCN Safe Mode ensures that users (and carriers) have a fallback to restore system connectivity to update profiles, diagnose issues, contact support, or perform other remediation tasks. In Safe Mode, the system will allow underlying cellular networks to be used as default. Additionally, during Safe Mode, the VCN will continue to retry the connections, and will automatically exit Safe Mode if all active tunnels connect successfully.
Apps targeting Android 15 or newer should check the existence of PackageManager.FEATURE_TELEPHONY_SUBSCRIPTION
before querying the service. If the feature is
absent, Context#getSystemService
may return null.
Requires the PackageManager#FEATURE_TELEPHONY_SUBSCRIPTION
feature which can be detected using PackageManager.hasSystemFeature(String)
.
Summary
Nested classes | |
---|---|
class |
VcnManager.VcnStatusCallback
VcnStatusCallback is the interface for Carrier apps to receive updates for their VCNs. |
Constants | |
---|---|
int |
VCN_ERROR_CODE_CONFIG_ERROR
Value indicating that an error with this Gateway Connection's configuration occurred. |
int |
VCN_ERROR_CODE_INTERNAL_ERROR
Value indicating that an internal failure occurred in this Gateway Connection. |
int |
VCN_ERROR_CODE_NETWORK_ERROR
Value indicating that a Network error occurred with this Gateway Connection. |
int |
VCN_STATUS_CODE_ACTIVE
Value indicating that the VCN for the subscription group is active. |
int |
VCN_STATUS_CODE_INACTIVE
Value indicating that the VCN for the subscription group is inactive. |
int |
VCN_STATUS_CODE_NOT_CONFIGURED
Value indicating that the VCN for the subscription group is not configured, or that the callback is not privileged for the subscription group. |
int |
VCN_STATUS_CODE_SAFE_MODE
Value indicating that the VCN for the subscription group is in Safe Mode. |
Public methods | |
---|---|
void
|
clearVcnConfig(ParcelUuid subscriptionGroup)
Clears the VCN configuration for a given subscription group. |
List<ParcelUuid>
|
getConfiguredSubscriptionGroups()
Retrieves the list of Subscription Groups for which a VCN Configuration has been set. |
void
|
registerVcnStatusCallback(ParcelUuid subscriptionGroup, Executor executor, VcnManager.VcnStatusCallback callback)
Registers the given callback to receive status updates for the specified subscription. |
void
|
setVcnConfig(ParcelUuid subscriptionGroup, VcnConfig config)
Sets the VCN configuration for a given subscription group. |
void
|
unregisterVcnStatusCallback(VcnManager.VcnStatusCallback callback)
Unregisters the given callback. |
Inherited methods | |
---|---|
Constants
VCN_ERROR_CODE_CONFIG_ERROR
public static final int VCN_ERROR_CODE_CONFIG_ERROR
Value indicating that an error with this Gateway Connection's configuration occurred.
For example, this error code will be returned after authentication failures.
Constant Value: 1 (0x00000001)
VCN_ERROR_CODE_INTERNAL_ERROR
public static final int VCN_ERROR_CODE_INTERNAL_ERROR
Value indicating that an internal failure occurred in this Gateway Connection.
Constant Value: 0 (0x00000000)
VCN_ERROR_CODE_NETWORK_ERROR
public static final int VCN_ERROR_CODE_NETWORK_ERROR
Value indicating that a Network error occurred with this Gateway Connection.
For example, this error code will be returned if an underlying Network
for this Gateway Connection is lost, or if an error occurs while resolving the connection
endpoint address.
Constant Value: 2 (0x00000002)
VCN_STATUS_CODE_ACTIVE
public static final int VCN_STATUS_CODE_ACTIVE
Value indicating that the VCN for the subscription group is active.
A VCN is active if a VcnConfig
is present for the subscription, the provisioning
package is privileged, and the VCN is not in Safe Mode. In other words, a VCN is considered
active while it is connecting, fully connected, and disconnecting.
Constant Value: 2 (0x00000002)
VCN_STATUS_CODE_INACTIVE
public static final int VCN_STATUS_CODE_INACTIVE
Value indicating that the VCN for the subscription group is inactive.
A VCN is inactive if a VcnConfig
is present for the subscription group, but the
provisioning package is not privileged.
Constant Value: 1 (0x00000001)
VCN_STATUS_CODE_NOT_CONFIGURED
public static final int VCN_STATUS_CODE_NOT_CONFIGURED
Value indicating that the VCN for the subscription group is not configured, or that the callback is not privileged for the subscription group.
Constant Value: 0 (0x00000000)
VCN_STATUS_CODE_SAFE_MODE
public static final int VCN_STATUS_CODE_SAFE_MODE
Value indicating that the VCN for the subscription group is in Safe Mode.
A VCN will be put into Safe Mode if any of the gateway connections were unable to establish a connection within a system-determined timeout (while underlying networks were available).
Constant Value: 3 (0x00000003)
Public methods
clearVcnConfig
public void clearVcnConfig (ParcelUuid subscriptionGroup)
Clears the VCN configuration for a given subscription group.
An app that has carrier privileges for any of the subscriptions in the given group may
clear a VCN configuration. This API is ONLY permitted for callers running as the primary
user. Any active VCN associated with this configuration will be torn down.
Requires carrier privileges
Parameters | |
---|---|
subscriptionGroup |
ParcelUuid : the subscription group that the configuration should be applied to
This value cannot be null . |
Throws | |
---|---|
SecurityException |
if the caller does not have carrier privileges, is not the owner of the associated configuration, or is not running as the primary user |
IOException |
if the configuration failed to be cleared from disk. This may occur due to temporary disk errors, or more permanent conditions such as a full disk. |
getConfiguredSubscriptionGroups
public List<ParcelUuid> getConfiguredSubscriptionGroups ()
Retrieves the list of Subscription Groups for which a VCN Configuration has been set.
The returned list will include only subscription groups for which an associated VcnConfig
exists, and the app is either:
- Carrier privileged for that subscription group, or
- Is the provisioning package of the config
Returns | |
---|---|
List<ParcelUuid> |
This value cannot be null . |
Throws | |
---|---|
SecurityException |
if the caller is not running as the primary user |
registerVcnStatusCallback
public void registerVcnStatusCallback (ParcelUuid subscriptionGroup, Executor executor, VcnManager.VcnStatusCallback callback)
Registers the given callback to receive status updates for the specified subscription.
Callbacks can be registered for a subscription before VcnConfig
s are set for it.
A VcnStatusCallback
may only be registered for one subscription at a time. VcnStatusCallback
s may be reused once unregistered.
A VcnStatusCallback
will only be invoked if the registering package has carrier
privileges for the specified subscription at the time of invocation.
A VcnStatusCallback
is eligible to begin receiving callbacks once it is registered
and there is a VCN active for its specified subscription group (this may happen after the
callback is registered).
VcnStatusCallback#onStatusChanged(int)
will be invoked on registration with the
current status for the specified subscription group's VCN. If the registrant is not
privileged for this subscription group, VCN_STATUS_CODE_NOT_CONFIGURED
will be
returned.
Parameters | |
---|---|
subscriptionGroup |
ParcelUuid : The subscription group to match for callbacks
This value cannot be null . |
executor |
Executor : The Executor to be used for invoking callbacks
This value cannot be null . |
callback |
VcnManager.VcnStatusCallback : The VcnStatusCallback to be registered
This value cannot be null . |
Throws | |
---|---|
IllegalStateException |
if callback is currently registered with VcnManager |
setVcnConfig
public void setVcnConfig (ParcelUuid subscriptionGroup, VcnConfig config)
Sets the VCN configuration for a given subscription group.
An app that has carrier privileges for any of the subscriptions in the given group may set a VCN configuration. If a configuration already exists for the given subscription group, it will be overridden. Any active VCN(s) may be forced to restart to use the new configuration.
This API is ONLY permitted for callers running as the primary user.
Requires carrier privileges
Parameters | |
---|---|
subscriptionGroup |
ParcelUuid : the subscription group that the configuration should be applied to
This value cannot be null . |
config |
VcnConfig : the configuration parameters for the VCN
This value cannot be null . |
Throws | |
---|---|
SecurityException |
if the caller does not have carrier privileges for the provided subscriptionGroup, or is not running as the primary user |
IOException |
if the configuration failed to be saved and persisted to disk. This may occur due to temporary disk errors, or more permanent conditions such as a full disk. |
unregisterVcnStatusCallback
public void unregisterVcnStatusCallback (VcnManager.VcnStatusCallback callback)
Unregisters the given callback.
Once unregistered, the callback will stop receiving status updates for the subscription it was registered with.
Parameters | |
---|---|
callback |
VcnManager.VcnStatusCallback : The callback to be unregistered
This value cannot be null . |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-04-11 UTC.