0
0
mirror of https://github.com/schwabe/ics-openvpn.git synced 2024-09-20 12:02:28 +02:00

Fetch initial network state for seriously broken devices.

This commit is contained in:
Arne Schwabe 2017-02-02 09:53:35 +01:00
parent 39f9fffbc6
commit c6d7fcd124
2 changed files with 7 additions and 3 deletions

View File

@ -65,13 +65,13 @@ public class DeviceStateReceiver extends BroadcastReceiver implements ByteCountL
return shouldBeConnected(); return shouldBeConnected();
} }
enum connectState { private enum connectState {
SHOULDBECONNECTED, SHOULDBECONNECTED,
PENDINGDISCONNECT, PENDINGDISCONNECT,
DISCONNECTED DISCONNECTED
} }
static class Datapoint { private static class Datapoint {
private Datapoint(long t, long d) { private Datapoint(long t, long d) {
timestamp = t; timestamp = t;
data = d; data = d;
@ -81,7 +81,7 @@ public class DeviceStateReceiver extends BroadcastReceiver implements ByteCountL
long data; long data;
} }
LinkedList<Datapoint> trafficdata = new LinkedList<DeviceStateReceiver.Datapoint>(); private LinkedList<Datapoint> trafficdata = new LinkedList<>();
@Override @Override

View File

@ -349,6 +349,10 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac
filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_ON);
mDeviceStateReceiver = new DeviceStateReceiver(magnagement); mDeviceStateReceiver = new DeviceStateReceiver(magnagement);
// Fetch initial network state
mDeviceStateReceiver.networkStateChange(this);
registerReceiver(mDeviceStateReceiver, filter); registerReceiver(mDeviceStateReceiver, filter);
VpnStatus.addByteCountListener(mDeviceStateReceiver); VpnStatus.addByteCountListener(mDeviceStateReceiver);