diff options
Diffstat (limited to 'src/de/blinkt')
-rw-r--r-- | src/de/blinkt/openvpn/LogWindow.java | 14 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/OpenVPNMangement.java | 13 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/OpenVpnService.java | 44 |
3 files changed, 53 insertions, 18 deletions
diff --git a/src/de/blinkt/openvpn/LogWindow.java b/src/de/blinkt/openvpn/LogWindow.java index 69d1f859..4d2047f8 100644 --- a/src/de/blinkt/openvpn/LogWindow.java +++ b/src/de/blinkt/openvpn/LogWindow.java @@ -262,9 +262,18 @@ public class LogWindow extends ListActivity implements StateListener { Toast.makeText(this, R.string.log_no_last_vpn, Toast.LENGTH_LONG).show(); } + } else if(item.getItemId() == android.R.id.home) { + // This is called when the Home (Up) button is pressed + // in the Action Bar. + Intent parentActivityIntent = new Intent(this, MainActivity.class); + parentActivityIntent.addFlags( + Intent.FLAG_ACTIVITY_CLEAR_TOP | + Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(parentActivityIntent); + finish(); + return true; } - return super.onOptionsItemSelected(item); } @@ -350,7 +359,8 @@ public class LogWindow extends ListActivity implements StateListener { lv.setAdapter(ladapter); mSpeedView = (TextView) findViewById(R.id.speed); - + getActionBar().setDisplayHomeAsUpEnabled(true); + Intent intent = new Intent(getBaseContext(), OpenVpnService.class); intent.setAction(OpenVpnService.START_SERVICE); diff --git a/src/de/blinkt/openvpn/OpenVPNMangement.java b/src/de/blinkt/openvpn/OpenVPNMangement.java new file mode 100644 index 00000000..0c6d7163 --- /dev/null +++ b/src/de/blinkt/openvpn/OpenVPNMangement.java @@ -0,0 +1,13 @@ +package de.blinkt.openvpn; + +public interface OpenVPNMangement { + + void reconnect(); + + void pause(); + + void resume(); + + boolean stopVPN(); + +} 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) { |