java.lang.Object | ||||
↳ | android.content.Context | |||
↳ | android.content.ContextWrapper | |||
↳ | android.app.Service | |||
↳ | com.samsung.android.knox.net.vpn.serviceprovider.GenericVpnService |
The class provides APIs to create and establish multiple virtual interface tunnels per user. Please refer to Android`s VpnService documentation for further details on VPN solution creation. Following are some key points:
GenericVpnContext
) or by using
GenericVpnService
.null
by default.GenericVpnService
is almost replica of Android`s
VpnService and
it facilitates to create multiple interfaces.API level 9 |
KNOX 1.1.0 |
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
GenericVpnService.Builder | Helper class to create a VPN interface. |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | SERVICE_INTERFACE | The action must be matched by the IntentFilter of this service. |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.app.Service
| |||||||||||
From class
android.content.Context
| |||||||||||
From interface
android.content.ComponentCallbacks2
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Return the communication interface to the service.
| |||||||||||
Invoked when the application is revoked.
| |||||||||||
Prepare to establish a VPN connection.
| |||||||||||
Convenience method to protect a
Socket from VPN
connections.
| |||||||||||
Protect a socket from VPN connections.
| |||||||||||
Convenience method to protect a DatagramSocket
from VPN connections.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.app.Service
| |||||||||||
From class
android.content.ContextWrapper
| |||||||||||
From class
android.content.Context
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
android.content.ComponentCallbacks
| |||||||||||
From interface
android.content.ComponentCallbacks2
|
The action must be matched by the IntentFilter of this service. It also needs to require BIND_VPN_SERVICE permission so that other applications cannot abuse it.
Return the communication interface to the service. This method returns null
on
Intents
other than SERVICE_INTERFACE
action. Applications overriding this method must
identify the Intent and return the corresponding interface accordingly.
intent | The Intent that was used to bind to this service. |
---|
API level 9 |
KNOX 1.1.0 |
Invoked when the application is revoked. At this moment, the VPN interface is already
deactivated by the system. The application should close the file descriptor and shut down
gracefully. The default implementation of this method is calling stopSelf()
.
Calls to this method may not happen on the main thread of the process.
API level 9 |
KNOX 1.1.0 |
Prepare to establish a VPN connection. Following is the explanation of prepare API in context
of system VPN. This method returns null
if the VPN application is already
prepared. Otherwise, it returns an Intent
to a system activity. The application
should launch the activity using startActivityForResult to get itself prepared. The activity may pop up a dialog to
require user action, and the result will come back via its onActivityResult. If the result is RESULT_OK,
the application becomes prepared and is granted to use other methods in this class.
Only one application can be granted at the same time. The right is revoked when another
application is granted. The application losing the right will be notified via its
onRevoke()
. Unless it becomes prepared again, subsequent calls to other methods in
this class will fail. In case of per application VPN, the function can be called before
establish and can be called at the end to destroy the connection based on profile name.
context | Context of the VPN Application trying to bind to Knox Framework. |
---|---|
profile | Name of the VPN Connection. |
type | True : if the profile is system VPN; false : if the
profile is per-app VPN. |
isConnecting | True : for starting the VPN connection; false :
for stopping a VPN connection. |
Null
if the VPN application is already prepared. Otherwise, it returns
an Intent
to a system activity.API level 9 |
KNOX 1.1.0 |
Convenience method to protect a Socket from VPN connections.
socket | The socket that will be protected from VPN connections. |
---|
True
on success.API level 9 |
KNOX 1.1.0 |
Protect a socket from VPN connections. The socket will be bound to the current default network interface, so its traffic will not be forwarded through VPN. This method is useful if some connections need to be kept outside of VPN. For example, a VPN tunnel should protect itself if its destination is covered by VPN routes. Otherwise its outgoing packets will be sent back to the VPN interface and cause an infinite loop. This method will fail if the application is not prepared or is revoked.
The socket is NOT closed by this method.
socket | The socket that will be protected from VPN connections. |
---|
True
on success. Parameter required for protect.API level 9 |
KNOX 1.1.0 |
Convenience method to protect a DatagramSocket from VPN connections.
socket | The socket that will be protected from VPN connections. |
---|
True
on success.API level 9 |
KNOX 1.1.0 |