From 9b832c4386f0f839006df68dd75d98fc173344d0 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Fri, 7 Dec 2018 16:50:41 +0100 Subject: first shot gatewayselection --- .../main/java/de/blinkt/openvpn/core/VpnStatus.java | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'app/src/main/java/de') diff --git a/app/src/main/java/de/blinkt/openvpn/core/VpnStatus.java b/app/src/main/java/de/blinkt/openvpn/core/VpnStatus.java index 5fbb440b..e7576bb5 100644 --- a/app/src/main/java/de/blinkt/openvpn/core/VpnStatus.java +++ b/app/src/main/java/de/blinkt/openvpn/core/VpnStatus.java @@ -214,6 +214,7 @@ public class VpnStatus { } public interface StateListener { + String STATE_CONNECTRETRY = "CONNECTRETRY"; void updateState(String state, String logmessage, int localizedResId, ConnectionStatus level); void setConnectedVPN(String uuid); @@ -267,10 +268,12 @@ public class VpnStatus { public synchronized static void addStateListener(StateListener sl) { - if (!stateListener.contains(sl)) { - stateListener.add(sl); - if (mLaststate != null) - sl.updateState(mLaststate, mLaststatemsg, mLastStateresid, mLastLevel); + synchronized (stateListener) { + if (!stateListener.contains(sl)) { + stateListener.add(sl); + if (mLaststate != null) + sl.updateState(mLaststate, mLaststatemsg, mLastStateresid, mLastLevel); + } } } @@ -351,7 +354,9 @@ public class VpnStatus { public synchronized static void removeStateListener(StateListener sl) { - stateListener.remove(sl); + synchronized (stateListener) { + stateListener.remove(sl); + } } @@ -384,8 +389,10 @@ public class VpnStatus { mLastLevel = level; - for (StateListener sl : stateListener) { - sl.updateState(state, msg, resid, level); + synchronized (stateListener) { + for (StateListener sl : stateListener) { + sl.updateState(state, msg, resid, level); + } } //newLogItem(new LogItem((LogLevel.DEBUG), String.format("New OpenVPN Status (%s->%s): %s",state,level.toString(),msg))); } -- cgit v1.2.3