# 5G Network Slicing

Android provides support for [5G network slicing](https://source.android.com/docs/core/connect/5g-slicing), the use of network
virtualization to divide single network connections into multiple distinct
virtual connections that provide different amounts of resources to different
types of traffic.

The [`deviceConnectivityManagement.preferentialNetworkServiceSettings`](https://developers.google.com/android/management/reference/rest/v1/enterprises.policies#PreferentialNetworkServiceSettings) and
[`preferentialNetworkService`](https://developers.google.com/android/management/reference/rest/v1/enterprises.policies#PreferentialNetworkService) settings configure 5G network slicing.

> [!IMPORTANT]
> **Key Point:** On devices with a work profile, applications installed on the personal profile are unaffected by these policy settings and they cannot use enterprise slices.

## Set up

You can use [`preferentialNetworkServiceSettings`](https://developers.google.com/android/management/reference/rest/v1/enterprises.policies#deviceconnectivitymanagement) to configure the
[5 enterprise slices](https://developers.google.com/android/management/reference/rest/v1/enterprises.policies#PreferentialNetworkId). Add networks you want to enable to
[`preferentialNetworkConfigs`](https://developers.google.com/android/management/reference/rest/v1/enterprises.policies#PreferentialNetworkServiceSettings).

Each [`ApplicationPolicy`](https://developers.google.com/android/management/reference/rest/v1/enterprises.policies#ApplicationPolicy) can specify a [`preferentialNetworkId`](https://developers.google.com/android/management/reference/rest/v1/enterprises.policies#ApplicationPolicy.FIELDS.preferential_network_id) to route
traffic to a specific slice. If no value is specified, the
[`defaultPreferentialNetworkId`](https://developers.google.com/android/management/reference/rest/v1/enterprises.policies#PreferentialNetworkServiceSettings) will be used instead.
[`fallbackToDefaultConnection`](https://developers.google.com/android/management/reference/rest/v1/enterprises.policies#FallbackToDefaultConnection) configures whether the default connection (e.g.
general cell network or wifi) is used if no preferential network service
connection is available.

You can configure apps not to use preferential network by setting
[`preferentialNetworkId`](https://developers.google.com/android/management/reference/rest/v1/enterprises.policies#ApplicationPolicy.FIELDS.preferential_network_id) to [`NO_PREFERENTIAL_NETWORK`](https://developers.google.com/android/management/reference/rest/v1/enterprises.policies#PreferentialNetworkId).

### Application support

5G network slicing does not require application support, network traffic will be
routed based on the configuration. Applications can still explicitly select a
different network, unless [`NON_MATCHING_NETWORKS_DISALLOWED`](https://developers.google.com/android/management/reference/rest/v1/enterprises.policies#NonMatchingNetworks) is set.

Enterprise preferential networks map to [`NetworkCapabilities`](https://developer.android.com/reference/android/net/NetworkCapabilities); Specifically
[`NET_ENTERPRISE_ID_1`](https://developer.android.com/reference/android/net/NetworkCapabilities#NET_ENTERPRISE_ID_1) through [`NET_ENTERPRISE_ID_5`](https://developer.android.com/reference/android/net/NetworkCapabilities#NET_ENTERPRISE_ID_5) map to
[`PREFERENTIAL_NETWORK_ID_ONE`](https://developers.google.com/android/management/reference/rest/v1/enterprises.policies#PreferentialNetworkId) through [`PREFERENTIAL_NETWORK_ID_FIVE`](https://developers.google.com/android/management/reference/rest/v1/enterprises.policies#PreferentialNetworkId).

> [!IMPORTANT]
> **Key Point:** The default network applies to all installed applications on work profile or all applications on fully managed devices, not just the ones specified in the policy.

### Version support

Starting from Android 12, IT Admins can use [`preferentialNetworkService`](https://developers.google.com/android/management/reference/rest/v1/enterprises.policies#PreferentialNetworkService) to
route traffic for all applications running in the Work Profile to a fixed
enterprise network slice. Starting with Android 13, IT Admins can use
[`preferentialNetworkService`](https://developers.google.com/android/management/reference/rest/v1/enterprises.policies#PreferentialNetworkService) on fully managed devices as well.

On Android 13 and later, IT Admins can use
[`preferentialNetworkServiceSettings`](https://developers.google.com/android/management/reference/rest/v1/enterprises.policies#deviceconnectivitymanagement) to enable up to 5 preferential networks
and assign applications to a specific network.

> [!IMPORTANT]
> **Important:** If both `preferentialNetworkServiceSettings` and `preferentialNetworkService` are set, `preferentialNetworkServiceSettings` takes precedence on Android 13 and later.

## Example policy

    {
      "applications": [
        {
          "packageName": "com.example.one",
          "installType": "AVAILABLE",
          "preferentialNetworkId": "PREFERENTIAL_NETWORK_ID_TWO"
        },
        {
          "packageName": "com.example.two",
          "installType": "AVAILABLE",
          "preferentialNetworkId": "PREFERENTIAL_NETWORK_ID_THREE"
        }
      ],
      "deviceConnectivityManagement": {
        "preferentialNetworkServiceSettings": {
          "defaultPreferentialNetworkId": "PREFERENTIAL_NETWORK_ID_TWO",
          "preferentialNetworkServiceConfigs": [
            {
              "preferentialNetworkId": "PREFERENTIAL_NETWORK_ID_TWO",
            },
            {
              "preferentialNetworkId": "PREFERENTIAL_NETWORK_ID_THREE",
            }
          ]
        }
      }
    }

> [!IMPORTANT]
> **Important:** Critical applications are excluded from [`defaultPreferentialNetworkId`](https://developers.google.com/android/management/reference/rest/v1/enterprises.policies#PreferentialNetworkServiceSettings), check the documentation for more details. You can still configure their network by using the [`Application.preferentialNetworkId`](https://developers.google.com/android/management/reference/rest/v1/enterprises.policies#ApplicationPolicy.FIELDS.preferential_network_id) setting.

> [!TIP]
> **Tip:** Networks that have no installed applications assigned to them will be silently ignored on the device.