Lorry
Lorry

Reputation:

android vpn connection programmatically

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.

Upvotes: 7

Views: 3666

Answers (1)

John Brown
John Brown

Reputation: 19

First suggestion - check permissions in your manifest. At least android.permission.INTERNET should be listed there.

Upvotes: 1

Related Questions