From 787c024cb5b1401e20fb11e876a74973208c2c55 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Mon, 11 Mar 2013 23:12:58 +0100 Subject: Add broadcast sent when VPN Status changes, still needs to tested (closes issue #150) --- src/de/blinkt/openvpn/OpenVpnService.java | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/de/blinkt') diff --git a/src/de/blinkt/openvpn/OpenVpnService.java b/src/de/blinkt/openvpn/OpenVpnService.java index e580089f..9f6da4c3 100644 --- a/src/de/blinkt/openvpn/OpenVpnService.java +++ b/src/de/blinkt/openvpn/OpenVpnService.java @@ -20,6 +20,7 @@ import java.lang.reflect.Method; import java.util.Locale; import java.util.Vector; +import android.Manifest.permission; import android.annotation.TargetApi; import android.app.Notification; import android.app.NotificationManager; @@ -542,6 +543,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac public void updateState(String state,String logmessage, int resid, ConnectionStatus level) { // If the process is not running, ignore any state, // Notification should be invisible in this state + doSendBroadcast(state, level); if(mProcessThread==null && !mNotificationalwaysVisible) return; @@ -564,6 +566,14 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac } } + private void doSendBroadcast(String state, ConnectionStatus level) { + Intent vpnstatus = new Intent(); + vpnstatus.setAction("de.blinkt.openvpn.VPN_STATUS"); + vpnstatus.putExtra("status", level.toString()); + vpnstatus.putExtra("detailstatus", state); + sendBroadcast(vpnstatus, permission.ACCESS_NETWORK_STATE); + } + @Override public void updateByteCount(long in, long out, long diffin, long diffout) { if(mDisplayBytecount) { -- cgit v1.2.3