From ffcd37e623136697da66e0c23bddc92b01ff0e41 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Mon, 6 May 2013 23:27:26 +0200 Subject: Fix spelling of sate to state --HG-- rename : src/de/blinkt/openvpn/core/NetworkSateReceiver.java => src/de/blinkt/openvpn/core/NetworkStateReceiver.java extra : rebase_source : 5a23bc869e5631048de0e0df2a56702e01fad9df --- .../blinkt/openvpn/core/NetworkSateReceiver.java | 90 ---------------------- .../blinkt/openvpn/core/NetworkStateReceiver.java | 90 ++++++++++++++++++++++ src/de/blinkt/openvpn/core/OpenVpnService.java | 4 +- 3 files changed, 92 insertions(+), 92 deletions(-) delete mode 100644 src/de/blinkt/openvpn/core/NetworkSateReceiver.java create mode 100644 src/de/blinkt/openvpn/core/NetworkStateReceiver.java (limited to 'src') diff --git a/src/de/blinkt/openvpn/core/NetworkSateReceiver.java b/src/de/blinkt/openvpn/core/NetworkSateReceiver.java deleted file mode 100644 index aa828495..00000000 --- a/src/de/blinkt/openvpn/core/NetworkSateReceiver.java +++ /dev/null @@ -1,90 +0,0 @@ -package de.blinkt.openvpn.core; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; -import android.net.ConnectivityManager; -import android.net.NetworkInfo; -import android.net.NetworkInfo.State; -import android.preference.PreferenceManager; -import de.blinkt.openvpn.R; - -public class NetworkSateReceiver extends BroadcastReceiver { - private int lastNetwork=-1; - private OpenVPNMangement mManangement; - - private String lastStateMsg=null; - - public NetworkSateReceiver(OpenVPNMangement magnagement) { - super(); - mManangement = magnagement; - } - - @Override - public void onReceive(Context context, Intent intent) { - NetworkInfo networkInfo = getCurrentNetworkInfo(context); - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); - boolean sendusr1 = prefs.getBoolean("netchangereconnect", true); - - String netstatestring; - if(networkInfo==null) - netstatestring = "not connected"; - else { - String subtype = networkInfo.getSubtypeName(); - if(subtype==null) - subtype = ""; - String extrainfo = networkInfo.getExtraInfo(); - 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(); - - if(sendusr1 && lastNetwork!=newnet) { - if (lastNetwork==-1) - mManangement.resume(); - else - mManangement.reconnect(); - } - - lastNetwork = newnet; - } else if (networkInfo==null) { - // Not connected, stop openvpn, set last connected network to no network - lastNetwork=-1; - if(sendusr1) - mManangement.pause(); - } - - if(!netstatestring.equals(lastStateMsg)) - OpenVPN.logInfo(R.string.netstatus, netstatestring); - lastStateMsg=netstatestring; - - } - - private NetworkInfo getCurrentNetworkInfo(Context context) { - ConnectivityManager conn = (ConnectivityManager) - context.getSystemService(Context.CONNECTIVITY_SERVICE); - - NetworkInfo networkInfo = conn.getActiveNetworkInfo(); - return networkInfo; - } - -} diff --git a/src/de/blinkt/openvpn/core/NetworkStateReceiver.java b/src/de/blinkt/openvpn/core/NetworkStateReceiver.java new file mode 100644 index 00000000..092de92d --- /dev/null +++ b/src/de/blinkt/openvpn/core/NetworkStateReceiver.java @@ -0,0 +1,90 @@ +package de.blinkt.openvpn.core; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; +import android.net.NetworkInfo.State; +import android.preference.PreferenceManager; +import de.blinkt.openvpn.R; + +public class NetworkStateReceiver extends BroadcastReceiver { + private int lastNetwork=-1; + private OpenVPNMangement mManangement; + + private String lastStateMsg=null; + + public NetworkStateReceiver(OpenVPNMangement magnagement) { + super(); + mManangement = magnagement; + } + + @Override + public void onReceive(Context context, Intent intent) { + NetworkInfo networkInfo = getCurrentNetworkInfo(context); + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + boolean sendusr1 = prefs.getBoolean("netchangereconnect", true); + + String netstatestring; + if(networkInfo==null) + netstatestring = "not connected"; + else { + String subtype = networkInfo.getSubtypeName(); + if(subtype==null) + subtype = ""; + String extrainfo = networkInfo.getExtraInfo(); + 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(); + + if(sendusr1 && lastNetwork!=newnet) { + if (lastNetwork==-1) + mManangement.resume(); + else + mManangement.reconnect(); + } + + lastNetwork = newnet; + } else if (networkInfo==null) { + // Not connected, stop openvpn, set last connected network to no network + lastNetwork=-1; + if(sendusr1) + mManangement.pause(); + } + + if(!netstatestring.equals(lastStateMsg)) + OpenVPN.logInfo(R.string.netstatus, netstatestring); + lastStateMsg=netstatestring; + + } + + private NetworkInfo getCurrentNetworkInfo(Context context) { + ConnectivityManager conn = (ConnectivityManager) + context.getSystemService(Context.CONNECTIVITY_SERVICE); + + NetworkInfo networkInfo = conn.getActiveNetworkInfo(); + return networkInfo; + } + +} diff --git a/src/de/blinkt/openvpn/core/OpenVpnService.java b/src/de/blinkt/openvpn/core/OpenVpnService.java index 103be071..dcf53d16 100644 --- a/src/de/blinkt/openvpn/core/OpenVpnService.java +++ b/src/de/blinkt/openvpn/core/OpenVpnService.java @@ -59,7 +59,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac private int mMtu; private String mLocalIPv6=null; - private NetworkSateReceiver mNetworkStateReceiver; + private NetworkStateReceiver mNetworkStateReceiver; private boolean mDisplayBytecount=false; @@ -229,7 +229,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac synchronized void registerNetworkStateReceiver(OpenVPNMangement magnagement) { // Registers BroadcastReceiver to track network connection changes. IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); - mNetworkStateReceiver = new NetworkSateReceiver(magnagement); + mNetworkStateReceiver = new NetworkStateReceiver(magnagement); registerReceiver(mNetworkStateReceiver, filter); } -- cgit v1.2.3