安卓 VPN 连接
我正在尝试以编程方式启动 VPN 连接。我收到这个错误。我使用的是Android 2.1,我的测试手机内核版本是2.6.32.9。 当我手动连接时,我能够连接到 VPN。但以编程方式,我收到此错误。
java.io.IOException: cannot start service: mtpd
E/VpnService(11817): at com.android.vpn.DaemonProxy.start(DaemonProxy.java:75)
E/VpnService(11817): at com.android.vpn.VpnDaemons.startDaemon(VpnDaemons.java:106)
E/VpnService(11817): at com.android.vpn.VpnDaemons.startMtpd(VpnDaemons.java:127)
E/VpnService(11817): at com.android.vpn.VpnDaemons.startL2tp(VpnDaemons.java:50)
E/VpnService(11817): at com.android.vpn.L2tpService.connect(L2tpService.java:31)
E/VpnService(11817): at com.android.vpn.VpnService.onConnect(VpnService.java:135)
E/VpnService(11817): at com.android.vpn.VpnServiceBinder$2.run(VpnServiceBinder.java:130)
E/VpnService(11817): at java.lang.Thread.run(Thread.java:1096)
DeamonProxy: 75 指向以下方法。
private boolean blockUntil(String expectedState, int waitTime) {
String cmd = SVC_STATE_CMD_PREFIX + mName;
int sleepTime = 200; // ms
int n = waitTime * 1000 / sleepTime;
for (int i = 0; i < n; i++) {
if (expectedState.equals(SystemProperties.get(cmd))) {
if (DBG) {
Log.d(mTag, mName + " is " + expectedState + " after "
+ (i * sleepTime) + " msec");
}
break;
}
sleep(sleepTime);
}
return expectedState.equals(SystemProperties.get(cmd));
}
该方法超时并返回上述错误。
对此的任何帮助/建议都非常感谢。
提前致谢。
I am trying to launch a vpn connection programmatically. I am getting this error. I am using Android 2.1 and my test phone kernel version is 2.6.32.9.
I am able to connect to vpn when i do it manually. But programmatically, I am getting this error.
java.io.IOException: cannot start service: mtpd
E/VpnService(11817): at com.android.vpn.DaemonProxy.start(DaemonProxy.java:75)
E/VpnService(11817): at com.android.vpn.VpnDaemons.startDaemon(VpnDaemons.java:106)
E/VpnService(11817): at com.android.vpn.VpnDaemons.startMtpd(VpnDaemons.java:127)
E/VpnService(11817): at com.android.vpn.VpnDaemons.startL2tp(VpnDaemons.java:50)
E/VpnService(11817): at com.android.vpn.L2tpService.connect(L2tpService.java:31)
E/VpnService(11817): at com.android.vpn.VpnService.onConnect(VpnService.java:135)
E/VpnService(11817): at com.android.vpn.VpnServiceBinder$2.run(VpnServiceBinder.java:130)
E/VpnService(11817): at java.lang.Thread.run(Thread.java:1096)
DeamonProxy: 75 points to the following method.
private boolean blockUntil(String expectedState, int waitTime) {
String cmd = SVC_STATE_CMD_PREFIX + mName;
int sleepTime = 200; // ms
int n = waitTime * 1000 / sleepTime;
for (int i = 0; i < n; i++) {
if (expectedState.equals(SystemProperties.get(cmd))) {
if (DBG) {
Log.d(mTag, mName + " is " + expectedState + " after "
+ (i * sleepTime) + " msec");
}
break;
}
sleep(sleepTime);
}
return expectedState.equals(SystemProperties.get(cmd));
}
This method times out and return the above error.
Any help/suggestion on this is greatly appreciated.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试这个类
VpnService.java Android 示例源代码
http://alvinalexander.com/java/jwarehouse/android/packages/VpnServices/src/com/android/server/vpn/VpnService.java.shtml
try this class
The VpnService.java Android example source code
http://alvinalexander.com/java/jwarehouse/android/packages/VpnServices/src/com/android/server/vpn/VpnService.java.shtml