From c6d7fcd124b62ac62960ae0c5a701bf7a886379d Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Thu, 2 Feb 2017 09:53:35 +0100 Subject: Fetch initial network state for seriously broken devices. --- main/src/main/java/de/blinkt/openvpn/core/DeviceStateReceiver.java | 6 +++--- main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/main/src/main/java/de/blinkt/openvpn/core/DeviceStateReceiver.java b/main/src/main/java/de/blinkt/openvpn/core/DeviceStateReceiver.java index 4260ea8f..c7760a0e 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/DeviceStateReceiver.java +++ b/main/src/main/java/de/blinkt/openvpn/core/DeviceStateReceiver.java @@ -65,13 +65,13 @@ public class DeviceStateReceiver extends BroadcastReceiver implements ByteCountL return shouldBeConnected(); } - enum connectState { + private enum connectState { SHOULDBECONNECTED, PENDINGDISCONNECT, DISCONNECTED } - static class Datapoint { + private static class Datapoint { private Datapoint(long t, long d) { timestamp = t; data = d; @@ -81,7 +81,7 @@ public class DeviceStateReceiver extends BroadcastReceiver implements ByteCountL long data; } - LinkedList trafficdata = new LinkedList(); + private LinkedList trafficdata = new LinkedList<>(); @Override diff --git a/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java b/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java index f5778d1a..3237f256 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java +++ b/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java @@ -349,6 +349,10 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_SCREEN_ON); mDeviceStateReceiver = new DeviceStateReceiver(magnagement); + + // Fetch initial network state + mDeviceStateReceiver.networkStateChange(this); + registerReceiver(mDeviceStateReceiver, filter); VpnStatus.addByteCountListener(mDeviceStateReceiver); -- cgit v1.2.3