summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap/bitmaskclient/EIP.java
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2014-08-03 05:27:24 +0200
committerParménides GV <parmegv@sdf.org>2014-08-03 05:27:24 +0200
commit9b6f5499e6d5e9efd0b7b372c28b5c71d940e785 (patch)
tree6d8f9bf881b801282f89d2f263b6f35026ceb778 /app/src/main/java/se/leap/bitmaskclient/EIP.java
parent3790d1aef8feedd27ac7ca2a780b2475109315ed (diff)
Just a small glitch after cancelling a disconnect.
I don't use the eip status receiver because it wasn't reliable on timing: updated messages were arriving before the receiver was notifying a new state. Current and last ConnectionStatus is now managed at EIP. More refactoring on the eip fragment, now there are separate methods for setting up the UI depending on the message received.
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/EIP.java')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/EIP.java17
1 files changed, 12 insertions, 5 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/EIP.java b/app/src/main/java/se/leap/bitmaskclient/EIP.java
index 07bc7f9a..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,7 +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);
- // getSharedPreferences(Dashboard.SHARED_PREFERENCES, Activity.MODE_PRIVATE).edit().remove(EIP.STATUS).commit();
+ mIsDisconnecting = true;
+ lastConnectionStatusLevel = ConnectionStatus.UNKNOWN_LEVEL; // Wait for the decision of the user
+ Log.d(TAG, "mIsDisconnecting = true");
}
if (mReceiver != null){
@@ -217,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.