From 44fa929579f9d801de9b62269f80310f3405ba4a Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Mon, 30 Apr 2012 02:53:12 +0200 Subject: version 0.4.2 --HG-- rename : src/de/blinkt/openvpn/BasicSettings.java => src/de/blinkt/openvpn/Settings_Basic.java --- src/de/blinkt/openvpn/OpenVPNThread.java | 61 ++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/de/blinkt/openvpn/OpenVPNThread.java (limited to 'src/de/blinkt/openvpn/OpenVPNThread.java') diff --git a/src/de/blinkt/openvpn/OpenVPNThread.java b/src/de/blinkt/openvpn/OpenVPNThread.java new file mode 100644 index 00000000..124179e5 --- /dev/null +++ b/src/de/blinkt/openvpn/OpenVPNThread.java @@ -0,0 +1,61 @@ +package de.blinkt.openvpn; + +import java.util.Arrays; + +import android.util.Log; + +public class OpenVPNThread implements Runnable { + private static final String TAG = "OpenVPN"; + private OpenVpnService mService; + private String[] mArgv; + + public OpenVPNThread(OpenVpnService service,String[] argv) + { + mService = service; + mArgv = argv; + } + + @Override + public void run() { + try { + Log.i(TAG, "Starting o"); + + + OpenVPN.setCallback(mService); + + + // We try to create the tunnel for several times. The better way + // is to work with ConnectivityManager, such as trying only when + // the network is avaiable. Here we just use a counter to keep + // things simple. + //for (int attempt = 0; attempt < 10; ++attempt) { + mService.getHandler().sendEmptyMessage(R.string.connecting); + + // Log argv + + OpenVPN.logMessage(0, "argv:" , Arrays.toString(mArgv)); + + OpenVPN.startOpenVPNThreadArgs(mArgv); + + + + // Sleep for a while. This also checks if we got interrupted. + Thread.sleep(3000); + //} + Log.i(TAG, "Giving up"); + } catch (Exception e) { + Log.e(TAG, "Got " + e.toString()); + } finally { + try { + /// mInterface.close(); + } catch (Exception e) { + // ignore + } + //mInterface = null; + + + mService.getHandler().sendEmptyMessage(R.string.disconnected); + Log.i(TAG, "Exiting"); + } + } +} -- cgit v1.2.3