From 9a9823f7e5bf0e46e360ba327ac6514ecd4bb320 Mon Sep 17 00:00:00 2001 From: Sean Leonard Date: Sun, 9 Jun 2013 02:08:52 -0600 Subject: Introducing the EIP class! Parses eip-service.json for OpenVPN gateways and builds VpnProfiles out of them --- src/se/leap/openvpn/OpenVpnService.java | 1 - 1 file changed, 1 deletion(-) (limited to 'src/se/leap/openvpn/OpenVpnService.java') diff --git a/src/se/leap/openvpn/OpenVpnService.java b/src/se/leap/openvpn/OpenVpnService.java index c745ee3b..42c1de8a 100644 --- a/src/se/leap/openvpn/OpenVpnService.java +++ b/src/se/leap/openvpn/OpenVpnService.java @@ -35,7 +35,6 @@ import android.net.LocalSocket; import android.net.LocalSocketAddress; import android.net.VpnService; import android.os.Binder; -import android.os.Handler; import android.os.Handler.Callback; import android.os.Build; import android.os.IBinder; -- cgit v1.2.3 From 389dfcdfad555feb1cf212ef9b42626633d5eade Mon Sep 17 00:00:00 2001 From: Sean Leonard Date: Sun, 9 Jun 2013 04:31:27 -0600 Subject: Better control and UI feedback for VPN --- src/se/leap/openvpn/OpenVpnService.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/se/leap/openvpn/OpenVpnService.java') diff --git a/src/se/leap/openvpn/OpenVpnService.java b/src/se/leap/openvpn/OpenVpnService.java index 42c1de8a..2408483d 100644 --- a/src/se/leap/openvpn/OpenVpnService.java +++ b/src/se/leap/openvpn/OpenVpnService.java @@ -20,6 +20,8 @@ import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Vector; + +import se.leap.leapclient.Dashboard; import se.leap.leapclient.R; import android.annotation.TargetApi; @@ -44,6 +46,7 @@ import se.leap.openvpn.OpenVPN.StateListener; public class OpenVpnService extends VpnService implements StateListener, Callback { public static final String START_SERVICE = "se.leap.openvpn.START_SERVICE"; + public static final String RETRIEVE_SERVICE = "se.leap.openvpn.RETRIEVE_SERVICE"; private Thread mProcessThread=null; @@ -88,7 +91,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac @Override public IBinder onBind(Intent intent) { String action = intent.getAction(); - if( action !=null && action.equals(START_SERVICE)) + if( action !=null && (action.equals(START_SERVICE) || action.equals(RETRIEVE_SERVICE)) ) return mBinder; else return super.onBind(intent); @@ -222,7 +225,8 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac @Override public int onStartCommand(Intent intent, int flags, int startId) { - if(intent != null && intent.getAction() !=null &&intent.getAction().equals(START_SERVICE)) + if( intent != null && intent.getAction() !=null && + (intent.getAction().equals(START_SERVICE) || intent.getAction().equals(RETRIEVE_SERVICE)) ) return START_NOT_STICKY; @@ -465,6 +469,13 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac mLocalIPv6 = ipv6addr; } + public boolean isRunning() { + if (mStarting == true || mProcessThread != null) + return true; + else + return false; + } + @Override public void updateState(String state,String logmessage, int resid) { // If the process is not running, ignore any state, -- cgit v1.2.3 From 276b8f7dbc7763e284f246a1c538bd06dd8be756 Mon Sep 17 00:00:00 2001 From: Sean Leonard Date: Sun, 9 Jun 2013 04:36:08 -0600 Subject: Bring up VPN connection log on status line click. Also show it on click of "Configure" button on system notification popup. Also allow toggling of status line. --- src/se/leap/openvpn/OpenVpnService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/se/leap/openvpn/OpenVpnService.java') diff --git a/src/se/leap/openvpn/OpenVpnService.java b/src/se/leap/openvpn/OpenVpnService.java index 2408483d..a4aa8a32 100644 --- a/src/se/leap/openvpn/OpenVpnService.java +++ b/src/se/leap/openvpn/OpenVpnService.java @@ -175,10 +175,10 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac } PendingIntent getLogPendingIntent() { - // Let the configure Button show the Log - Intent intent = new Intent(getBaseContext(),LogWindow.class); + // Let the configure Button show the Dashboard + Intent intent = new Intent(Dashboard.getAppContext(),Dashboard.class); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); - PendingIntent startLW = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0); + PendingIntent startLW = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); return startLW; -- cgit v1.2.3 From 3fb8205af4d58a5fec930440fe05f766271eec2f Mon Sep 17 00:00:00 2001 From: Sean Leonard Date: Sun, 9 Jun 2013 04:37:41 -0600 Subject: Get rid of app's own notification. Only commented out. May want to try showing it until connection success. --- src/se/leap/openvpn/OpenVpnService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/se/leap/openvpn/OpenVpnService.java') diff --git a/src/se/leap/openvpn/OpenVpnService.java b/src/se/leap/openvpn/OpenVpnService.java index a4aa8a32..08a5d62e 100644 --- a/src/se/leap/openvpn/OpenVpnService.java +++ b/src/se/leap/openvpn/OpenVpnService.java @@ -238,7 +238,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac mProfile = ProfileManager.get(profileUUID); - showNotification("Starting VPN " + mProfile.mName,"Starting VPN " + mProfile.mName, false,0); + //showNotification("Starting VPN " + mProfile.mName,"Starting VPN " + mProfile.mName, false,0); OpenVPN.addStateListener(this); @@ -487,7 +487,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac if("BYTECOUNT".equals(state)) { if(mDisplayBytecount) { - showNotification(logmessage,null,true,mConnecttime); + //showNotification(logmessage,null,true,mConnecttime); } } else { if("CONNECTED".equals(state)) { @@ -501,7 +501,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac // This also mean we are no longer connected, ignore bytecount messages until next // CONNECTED String ticker = getString(resid); - showNotification(getString(resid) +" " + logmessage,ticker,false,0); + //showNotification(getString(resid) +" " + logmessage,ticker,false,0); } } -- cgit v1.2.3 From c3a9d580a8428809aa001129ce78c93ed3ee72a8 Mon Sep 17 00:00:00 2001 From: Sean Leonard Date: Wed, 10 Jul 2013 11:10:10 -0600 Subject: Show notification while VPN connection in progress and when VPN connection lost --- src/se/leap/openvpn/OpenVpnService.java | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'src/se/leap/openvpn/OpenVpnService.java') diff --git a/src/se/leap/openvpn/OpenVpnService.java b/src/se/leap/openvpn/OpenVpnService.java index 08a5d62e..b5653d4d 100644 --- a/src/se/leap/openvpn/OpenVpnService.java +++ b/src/se/leap/openvpn/OpenVpnService.java @@ -67,6 +67,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac private int mMtu; private String mLocalIPv6=null; private NetworkSateReceiver mNetworkStateReceiver; + private NotificationManager mNotificationManager; private boolean mDisplayBytecount=false; @@ -118,9 +119,9 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac } } - private void showNotification(String msg, String tickerText, boolean lowpriority, long when) { + private void showNotification(String msg, String tickerText, boolean lowpriority, long when, boolean persistant) { String ns = Context.NOTIFICATION_SERVICE; - NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns); + mNotificationManager = (NotificationManager) getSystemService(ns); int icon = R.drawable.ic_stat_vpn; @@ -129,7 +130,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac nbuilder.setContentTitle(getString(R.string.notifcation_title,mProfile.mName)); nbuilder.setContentText(msg); nbuilder.setOnlyAlertOnce(true); - nbuilder.setOngoing(true); + nbuilder.setOngoing(persistant); nbuilder.setContentIntent(getLogPendingIntent()); nbuilder.setSmallIcon(icon); if(when !=0) @@ -146,7 +147,6 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac mNotificationManager.notify(OPENVPN_STATUS, notification); - startForeground(OPENVPN_STATUS, notification); } @TargetApi(Build.VERSION_CODES.JELLY_BEAN) @@ -483,26 +483,16 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac if(mProcessThread==null) return; - // Display byte count only after being connected - - if("BYTECOUNT".equals(state)) { - if(mDisplayBytecount) { - //showNotification(logmessage,null,true,mConnecttime); - } - } else { - if("CONNECTED".equals(state)) { - mDisplayBytecount = true; - mConnecttime = System.currentTimeMillis(); - } else { - mDisplayBytecount = false; - } + if("CONNECTED".equals(state)) { + mNotificationManager.cancel(OPENVPN_STATUS); + } else if(!"BYTECOUNT".equals(state)) { // Other notifications are shown, // This also mean we are no longer connected, ignore bytecount messages until next // CONNECTED String ticker = getString(resid); - //showNotification(getString(resid) +" " + logmessage,ticker,false,0); - + boolean persist = ("NOPROCESS".equals(state)) ? false : true; + showNotification(getString(resid) +" " + logmessage,ticker,false,0,persist); } } -- cgit v1.2.3 From 1faa1e6432b0b01fb129eb5d0ae057f5415673b6 Mon Sep 17 00:00:00 2001 From: Sean Leonard Date: Fri, 12 Jul 2013 21:03:48 -0600 Subject: Include ics-openvpn license file in se.leap.openvpn package Clean erroneous copyright text (Consulted Arne) ics-openvpn uses GPLv2+ --- src/se/leap/openvpn/OpenVpnService.java | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'src/se/leap/openvpn/OpenVpnService.java') diff --git a/src/se/leap/openvpn/OpenVpnService.java b/src/se/leap/openvpn/OpenVpnService.java index b5653d4d..3ac80497 100644 --- a/src/se/leap/openvpn/OpenVpnService.java +++ b/src/se/leap/openvpn/OpenVpnService.java @@ -1,19 +1,3 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - package se.leap.openvpn; import java.io.IOException; -- cgit v1.2.3