summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2017-02-02 09:53:35 +0100
committerArne Schwabe <arne@rfc2549.org>2017-02-02 09:53:35 +0100
commitc6d7fcd124b62ac62960ae0c5a701bf7a886379d (patch)
tree06710fc160fc4520d85c0ac20bb41dc2c4df3836
parent39f9fffbc600205e2360549bf7a3ca22d60dccbc (diff)
Fetch initial network state for seriously broken devices.
-rw-r--r--main/src/main/java/de/blinkt/openvpn/core/DeviceStateReceiver.java6
-rw-r--r--main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java4
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<Datapoint> trafficdata = new LinkedList<DeviceStateReceiver.Datapoint>();
+ private LinkedList<Datapoint> 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);