title: android vpn connection programmatically
body: <p>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.</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>DeamonProxy: 75 points to the following method. </p>
  
  <pre><code>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 &lt; 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));
      }
  </code></pre>
  
  <p>This method times out and return the above error.</p>
  
  <p>Any help/suggestion on this is greatly appreciated.</p>
  
  <p>Thanks in advance.</p>