Is it possible to programmatically create VPN profile on Android (assuming that I have a rooted device)?
If is possible, how?
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You should look at the com.android.settings.vpn2 package. There it uses the @hidden KeyStore methods to manipulate VPNs:
KeyStore.getInstance().saw(Credentials.VPN)returns an array of String VPN IDsVpnProfile.decode(KeyStore.getInstance().get(Credentials.VPN + vpn_id))gets the VPN configuration data for the given VPN ID and decodes it as a VpnProfile object.VpnProfile.put(Credentials.VPN + vpn_id, someVpnProfileInstance.encode())will create/update a VPN connection with the given ID using the settings in the VpnProfile instance.However, you will need to execute this as the system process — otherwise, the KeyStore instance you get will not be connected to the one that the OS uses.
If there is a way to do this without a rooted device, I’d be interested in knowing how…
P.S. – There’s a similar question here: How to programmatically create a new VPN interface with Android 4.0?