diff options
author | Parménides GV <parmegv@sdf.org> | 2014-08-03 21:48:32 +0200 |
---|---|---|
committer | Parménides GV <parmegv@sdf.org> | 2014-08-03 21:48:32 +0200 |
commit | 9521dbc9e5e37e49618f013acae0ede3690d8c72 (patch) | |
tree | a396c4903387b88d8618a78b86244744747c7582 /app/src/main/java/se/leap/bitmaskclient/EIP.java | |
parent | 4aedacdf92ab2fc08a1e39618761bc1eb96427d6 (diff) | |
parent | 55c57e6c2856a453e042e2e68284fa2cf3a98a89 (diff) |
Merge branch 'bug/EIP-button-doesn't-always-reflect-the-real-EIP-status-#5935' into develop
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/EIP.java')
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/EIP.java | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/EIP.java b/app/src/main/java/se/leap/bitmaskclient/EIP.java index 7374d5ed..7b2a6d95 100644 --- a/app/src/main/java/se/leap/bitmaskclient/EIP.java +++ b/app/src/main/java/se/leap/bitmaskclient/EIP.java @@ -41,6 +41,7 @@ import de.blinkt.openvpn.core.OpenVpnManagementThread; import de.blinkt.openvpn.core.OpenVpnService.LocalBinder; import de.blinkt.openvpn.core.OpenVpnService; import de.blinkt.openvpn.core.ProfileManager; +import de.blinkt.openvpn.core.VpnStatus.ConnectionStatus; import java.io.IOException; import java.io.StringReader; import java.security.cert.CertificateExpiredException; @@ -109,6 +110,10 @@ public final class EIP extends IntentService { private static JSONObject eipDefinition = null; private static OVPNGateway activeGateway = null; + + protected static ConnectionStatus lastConnectionStatusLevel; + protected static boolean mIsDisconnecting = false; + protected static boolean mIsStarting = false; public EIP(){ super("LEAPEIP"); @@ -169,10 +174,6 @@ public final class EIP extends IntentService { Log.d(TAG, "isRunning() = " + is_connected); } - - private boolean isConnected() { - return getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE).getString(STATUS, "").equalsIgnoreCase("LEVEL_CONNECTED"); - } /** * Initiates an EIP connection by selecting a gateway and preparing and sending an @@ -207,6 +208,9 @@ public final class EIP extends IntentService { Intent disconnect_vpn = new Intent(this, DisconnectVPN.class); disconnect_vpn.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(disconnect_vpn); + mIsDisconnecting = true; + lastConnectionStatusLevel = ConnectionStatus.UNKNOWN_LEVEL; // Wait for the decision of the user + Log.d(TAG, "mIsDisconnecting = true"); } if (mReceiver != null){ @@ -216,6 +220,10 @@ public final class EIP extends IntentService { } } + protected static boolean isConnected() { + return lastConnectionStatusLevel != null && lastConnectionStatusLevel.equals(ConnectionStatus.LEVEL_CONNECTED) && !mIsDisconnecting; + } + /** * Loads eip-service.json from SharedPreferences and calls {@link updateGateways()} * to parse gateway definitions. |