| java.lang.Object | |||
| ↳ | android.content.Context | ||
| ↳ | android.content.ContextWrapper | ||
| ↳ | com.samsung.android.knox.net.vpn.serviceprovider.GenericVpnContext | ||
GenericVpnContext is a class for applications to create custom VPN context object
and achieve Knox VPN functionality.
GenericVpnContext class is basically extended from ContextWrapper class and
accepts a context in its constructor. In general, this custom context creates a type matched
object to pass context to Android`s prepare()
API. This custom context facilitates passing extra parameters to achieve per-application VPN and
meta-data passing with VPN traffic.
Please refer to Android`s VpnService documentation for further details on VPN solution creation.
Following are some key points:
GenericVpnContext) or by using
GenericVpnService.GenericVpnContext, APIs available in
VpnService.Builder
class from API level 21 are not supported.GenericVpnContext.
GenericVpnContext vpnContext = new GenericVpnContext(this); vpnContext.setGenericVpnParams(profileName, GenericVpnContext.CONNECTING); VpnService.prepare(vpnContext);
GenericVpnContext.
GenericVpnContext vpnContext = new GenericVpnContext(this); vpnContext.setGenericVpnParams(profileName, GenericVpnContext.CONNECTING); vpnContext.enableMetaHeader(true); VpnService.prepare(vpnContext);
null by default.| API level 13 |
| KNOX 2.2.0 |
| Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| boolean | CONNECTING | This field indicates that the connection is starting. | |||||||||
| boolean | DISCONNECTING | This field indicates that the connection is stopping. | |||||||||
| boolean | META_DISABLED | This field indicates that the meta-data (UID/PID of application generating the packet) passing is disabled. | |||||||||
| boolean | META_ENABLED | This field indicates that the meta-data (UID/PID of application generating the packet) passing is enabled. | |||||||||
|
[Expand]
Inherited Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.content.Context
| |||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Constructor of
GenericVpnContext class. | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Function used to enable/disable meta-data passing with Knox VPN traffic.
| |||||||||||
Function to get profile name set in
setGenericVpnParams(String, boolean). | |||||||||||
Function to get VPN state set in
setGenericVpnParams(String, boolean). | |||||||||||
Function to get the status of meta-data appending for profile set in
setGenericVpnParams(String, boolean). | |||||||||||
Set the parameters required to achieve Knox VPN.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.content.ContextWrapper
| |||||||||||
From class
android.content.Context
| |||||||||||
From class
java.lang.Object
| |||||||||||
This field indicates that the connection is starting.
| API level 13 |
| KNOX 2.2.0 |
This field indicates that the connection is stopping.
| API level 13 |
| KNOX 2.2.0 |
This field indicates that the meta-data (UID/PID of application generating the packet) passing is disabled.
| API level 13 |
| KNOX 2.2.0 |
This field indicates that the meta-data (UID/PID of application generating the packet) passing is enabled.
| API level 13 |
| KNOX 2.2.0 |
Constructor of GenericVpnContext class.
| API level 13 |
| KNOX 2.2.0 |
Function used to enable/disable meta-data passing with Knox VPN traffic. If the VPN client
does not have privilege in enabling meta-data along with network traffic, VPN client will
receive a SecurityException when invoking prepare API.
| enable | Specifies whether to enable or disable meta-data passing along with VPN traffic. |
|---|
| API level 13 |
| KNOX 2.2.0 |
Function to get profile name set in setGenericVpnParams(String, boolean).
String with the Knox VPN profile name.| API level 13 |
| KNOX 2.2.0 |
Function to get VPN state set in setGenericVpnParams(String, boolean).
true for Connecting and false for
Disconnecting.| API level 13 |
| KNOX 2.2.0 |
Function to get the status of meta-data appending for profile set in
setGenericVpnParams(String, boolean).
True if meta-data passing is enable, false otherwise.| API level 13 |
| KNOX 2.2.0 |
Set the parameters required to achieve Knox VPN.
| profile | Specifies the profile name for which Knox VPN has to be set. |
|---|---|
| isConnecting | Specifies the state of connection - Connecting or Disconnecting. |
| API level 13 |
| KNOX 2.2.0 |