Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically start / launch VPN connection

Tags:

android

I am developing Enterprise applications that need to connect to servers behind the firewall. Can my app start VPN connection programmatically?

On 2.0+ platforms, VPN is supported by the platform. Assuming user has already setup VPN parameters, can my app start the VPN connection? Suppose user has not setup any VPN parameters, can my app supply those parameters? and start VPN connection?

like image 717
user270740 Avatar asked Feb 11 '10 00:02

user270740


1 Answers

We're facing this problem at our shop. For now our best shot is trying to use Android internal API to connect to the VPN the same way that the system preferences app does.

First, you need to set up an environment that allows you to access internal API: http://devmaze.wordpress.com/2011/01/18/using-com-android-internal-part-1-introduction/

Then we can implement something like this http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android-apps/4.4.4_r1/com/android/settings/vpn2/VpnSettings.java#258

I don't know if we will have any permission issues with this, but IMHO this is the best option we have right now

EDIT: this need root privileges in order to avoid java.lang.SecurityException: Unauthorized Caller errors.

like image 72
isalgueiro Avatar answered Nov 17 '22 17:11

isalgueiro