在Android上创建VPN配置文件

jor*_*jap 7 vpn android root

是否可以在Android上以编程方式创建VPN配置文件(假设我有一个root设备)?

如果可能,怎么样?

谢谢.

小智 9

你应该看看com.android.settings.vpn2包.它使用@hidden KeyStore方法来操纵VPN:

  • KeyStore.getInstance().saw(Credentials.VPN) 返回String VPN ID数组

  • VpnProfile.decode(KeyStore.getInstance().get(Credentials.VPN + vpn_id)) 获取给定VPN ID的VPN配置数据,并将其解码为VpnProfile对象.

  • VpnProfile.put(Credentials.VPN + vpn_id, someVpnProfileInstance.encode()) 将使用VpnProfile实例中的设置创建/更新具有给定ID的VPN连接.

但是,您需要将此作为系统进程执行 - 否则,您获得的KeyStore实例将不会连接到操作系统使用的实例.

如果有办法在没有 root设备的情况下做到这一点,我会有兴趣知道如何...

PS - 这里有一个类似的问题:如何以编程方式创建一个Android 4.0的新VPN接口?