summaryrefslogtreecommitdiff
path: root/src/de/blinkt/openvpn/OpenVpnService.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/de/blinkt/openvpn/OpenVpnService.java')
-rw-r--r--src/de/blinkt/openvpn/OpenVpnService.java44
1 files changed, 28 insertions, 16 deletions
diff --git a/src/de/blinkt/openvpn/OpenVpnService.java b/src/de/blinkt/openvpn/OpenVpnService.java
index d5d75589..34f612c3 100644
--- a/src/de/blinkt/openvpn/OpenVpnService.java
+++ b/src/de/blinkt/openvpn/OpenVpnService.java
@@ -86,10 +86,10 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
private final IBinder mBinder = new LocalBinder();
private boolean mOvpn3;
- private OpenVPNThreadv3 mOpenVPN3;
private Thread mSocketManagerThread;
private OpenVPNMangement mManagement;
+
public class LocalBinder extends Binder {
public OpenVpnService getService() {
// Return this instance of LocalService so clients can call public methods
@@ -249,8 +249,8 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
this.unregisterReceiver(mNetworkStateReceiver);
mNetworkStateReceiver=null;
}
-
-
+
+
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
@@ -288,16 +288,6 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
}
- if(mOpenVPN3!=null) {
- mOpenVPN3.stopVPN();
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- }
-
- }
-
-
if (mProcessThread!=null) {
mProcessThread.interrupt();
try {
@@ -330,10 +320,11 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
Runnable processThread;
if(mOvpn3) {
- mOpenVPN3 = new OpenVPNThreadv3(this,mProfile);
- processThread = mOpenVPN3;
+
+ OpenVPNMangement mOpenVPN3 = instantiateOpenVPN3Core();
+ processThread = (Runnable) mOpenVPN3;
mManagement = mOpenVPN3;
-
+
} else {
processThread = new OpenVPNThread(this, argv,nativelibdir);
@@ -350,6 +341,27 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
return START_NOT_STICKY;
}
+ private OpenVPNMangement instantiateOpenVPN3Core() {
+ //new OpenVPNThreadv3(this,mProfile);
+ try {
+ Class cl = Class.forName("Lde/blinkt/openvpn/OpenVPNThreadv3;");
+ return (OpenVPNMangement) cl.getConstructor(OpenVpnService.class,VpnProfile.class).newInstance(this,mProfile);
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ } catch (InstantiationException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
@Override
public void onDestroy() {
if (mProcessThread != null) {