From c7baf0994a529e6a350faa7ec421c33b1def08f1 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Sun, 12 Aug 2012 23:01:24 +0200 Subject: Accessing wifi state... (commented out, not as useful as I thought) --- src/de/blinkt/openvpn/NetworkSateReceiver.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/de/blinkt') diff --git a/src/de/blinkt/openvpn/NetworkSateReceiver.java b/src/de/blinkt/openvpn/NetworkSateReceiver.java index a649bd65..6c38a0cb 100644 --- a/src/de/blinkt/openvpn/NetworkSateReceiver.java +++ b/src/de/blinkt/openvpn/NetworkSateReceiver.java @@ -6,7 +6,11 @@ import android.content.Intent; import android.content.SharedPreferences; import android.net.ConnectivityManager; import android.net.NetworkInfo; +import android.net.NetworkInfo.DetailedState; import android.net.NetworkInfo.State; +import android.net.wifi.SupplicantState; +import android.net.wifi.WifiInfo; +import android.net.wifi.WifiManager; import android.preference.PreferenceManager; public class NetworkSateReceiver extends BroadcastReceiver { @@ -37,10 +41,23 @@ public class NetworkSateReceiver extends BroadcastReceiver { if(extrainfo==null) extrainfo=""; + /* + if(networkInfo.getType()==android.net.ConnectivityManager.TYPE_WIFI) { + WifiManager wifiMgr = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); + WifiInfo wifiinfo = wifiMgr.getConnectionInfo(); + extrainfo+=wifiinfo.getBSSID(); + + subtype += wifiinfo.getNetworkId(); + }*/ + + + netstatestring = String.format("%2$s %4$s to %1$s %3$s",networkInfo.getTypeName(), networkInfo.getDetailedState(),extrainfo,subtype ); } + + if(networkInfo!=null && networkInfo.getState() == State.CONNECTED) { int newnet = networkInfo.getType(); -- cgit v1.2.3 From fe605d2f75a20f212d64c26ca51c3112b4de2b76 Mon Sep 17 00:00:00 2001 From: arne Date: Tue, 25 Dec 2012 23:00:42 +0100 Subject: Move opening of Inputstream to Configconvert --- src/de/blinkt/openvpn/ConfigConverter.java | 5 ++++- src/de/blinkt/openvpn/ConfigParser.java | 9 ++++----- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src/de/blinkt') diff --git a/src/de/blinkt/openvpn/ConfigConverter.java b/src/de/blinkt/openvpn/ConfigConverter.java index 3f204368..d140a1a4 100644 --- a/src/de/blinkt/openvpn/ConfigConverter.java +++ b/src/de/blinkt/openvpn/ConfigConverter.java @@ -6,6 +6,7 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import java.util.List; import java.util.Vector; @@ -387,7 +388,9 @@ public class ConfigConverter extends ListActivity { private void doImport(InputStream is) { ConfigParser cp = new ConfigParser(); try { - cp.parseConfig(is); + InputStreamReader isr = new InputStreamReader(is); + + cp.parseConfig(isr); VpnProfile vp = cp.convertProfile(); mResult = vp; embedFiles(); diff --git a/src/de/blinkt/openvpn/ConfigParser.java b/src/de/blinkt/openvpn/ConfigParser.java index 3d20bc31..7501ed17 100644 --- a/src/de/blinkt/openvpn/ConfigParser.java +++ b/src/de/blinkt/openvpn/ConfigParser.java @@ -2,8 +2,7 @@ package de.blinkt.openvpn; import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; +import java.io.Reader; import java.util.HashMap; import java.util.Vector; @@ -17,11 +16,10 @@ public class ConfigParser { private HashMap>> options = new HashMap>>(); - public void parseConfig(InputStream inputStream) throws IOException, ConfigParseError { + public void parseConfig(Reader reader) throws IOException, ConfigParseError { - InputStreamReader fr = new InputStreamReader(inputStream); - BufferedReader br =new BufferedReader(fr); + BufferedReader br =new BufferedReader(reader); @SuppressWarnings("unused") int lineno=0; @@ -229,6 +227,7 @@ public class ConfigParser { "route-gateway", "route-metric", "route-method", + "status", "show-net-up", "suppress-timestamps", "tmp-dir", -- cgit v1.2.3 From e57c7dd4a792d02897140d0c5e2d014bcd1147c0 Mon Sep 17 00:00:00 2001 From: arne Date: Tue, 25 Dec 2012 23:02:10 +0100 Subject: Cleanups --- src/de/blinkt/openvpn/LaunchVPN.java | 4 ++-- src/de/blinkt/openvpn/NetworkSateReceiver.java | 4 ---- src/de/blinkt/openvpn/ProfileManager.java | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) (limited to 'src/de/blinkt') diff --git a/src/de/blinkt/openvpn/LaunchVPN.java b/src/de/blinkt/openvpn/LaunchVPN.java index c89704fa..bc0a4cf2 100644 --- a/src/de/blinkt/openvpn/LaunchVPN.java +++ b/src/de/blinkt/openvpn/LaunchVPN.java @@ -73,8 +73,8 @@ import android.widget.TextView; */ public class LaunchVPN extends ListActivity implements OnItemClickListener { - static final String EXTRA_KEY = "de.blinkt.openvpn.shortcutProfileUUID"; - static final String EXTRA_NAME = "de.blinkt.openvpn.shortcutProfileName"; + public static final String EXTRA_KEY = "de.blinkt.openvpn.shortcutProfileUUID"; + public static final String EXTRA_NAME = "de.blinkt.openvpn.shortcutProfileName"; public static final String EXTRA_HIDELOG = "de.blinkt.openvpn.showNoLogWindow";; private static final int START_VPN_PROFILE= 70; diff --git a/src/de/blinkt/openvpn/NetworkSateReceiver.java b/src/de/blinkt/openvpn/NetworkSateReceiver.java index 6c38a0cb..e20c8e52 100644 --- a/src/de/blinkt/openvpn/NetworkSateReceiver.java +++ b/src/de/blinkt/openvpn/NetworkSateReceiver.java @@ -6,11 +6,7 @@ import android.content.Intent; import android.content.SharedPreferences; import android.net.ConnectivityManager; import android.net.NetworkInfo; -import android.net.NetworkInfo.DetailedState; import android.net.NetworkInfo.State; -import android.net.wifi.SupplicantState; -import android.net.wifi.WifiInfo; -import android.net.wifi.WifiManager; import android.preference.PreferenceManager; public class NetworkSateReceiver extends BroadcastReceiver { diff --git a/src/de/blinkt/openvpn/ProfileManager.java b/src/de/blinkt/openvpn/ProfileManager.java index d2e08a97..9457b53f 100644 --- a/src/de/blinkt/openvpn/ProfileManager.java +++ b/src/de/blinkt/openvpn/ProfileManager.java @@ -51,7 +51,7 @@ public class ProfileManager { } } - public static ProfileManager getInstance(Context context) { + synchronized public static ProfileManager getInstance(Context context) { checkInstance(context); return instance; } -- cgit v1.2.3