diff options
author | Parménides GV <parmegv@sdf.org> | 2014-11-22 00:10:46 +0100 |
---|---|---|
committer | Parménides GV <parmegv@sdf.org> | 2014-11-27 17:49:56 +0100 |
commit | e4d4c07be386f809a8ac028df8146916fc0f7597 (patch) | |
tree | 201e711ed102580587c8c934bf1acecd1c6db842 /app/src/main/java/se/leap/bitmaskclient/eip | |
parent | 2681e877c6c2e871247cf5e42269d1b867422f1f (diff) |
EipStatus detects and notifies changes by itself.
Initial status message is "not connected", rather than "unknown".
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/eip')
3 files changed, 26 insertions, 10 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java index 577f42a3..379fb246 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java @@ -47,6 +47,9 @@ public final class EIP extends IntentService { public final static String TAG = EIP.class.getSimpleName(); public final static String SERVICE_API_PATH = "config/eip-service.json"; + + + public static final int DISCONNECT = 15; private static Context context; private static ResultReceiver mReceiver; @@ -95,13 +98,13 @@ public final class EIP extends IntentService { * It also sets up early routes. */ private void startEIP() { - earlyRoutes(); GatewaySelector gateway_selector = new GatewaySelector(gateways); activeGateway = gateway_selector.select(); if(activeGateway != null && activeGateway.getProfile() != null) { mReceiver = EipServiceFragment.getReceiver(); launchActiveGateway(); } + earlyRoutes(); } /** diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java b/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java index ee14f2db..82c3ceb8 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java @@ -29,7 +29,6 @@ public class EipStatus extends Observable implements VpnStatus.StateListener { private static VpnStatus.ConnectionStatus level = VpnStatus.ConnectionStatus.LEVEL_NOTCONNECTED; private static boolean wants_to_disconnect = false; private static boolean is_disconnecting = false; - private static boolean is_connecting = false; private String state, log_message; private int localized_res_id; @@ -55,6 +54,8 @@ public class EipStatus extends Observable implements VpnStatus.StateListener { current_status.setChanged(); if(isConnected() || isDisconnected()) setConnectedOrDisconnected(); + else if(isConnecting()) + setConnecting(); Log.d(TAG, "update state with level " + level); current_status.notifyObservers(); } @@ -63,14 +64,17 @@ public class EipStatus extends Observable implements VpnStatus.StateListener { return is_disconnecting; } - public boolean isConnecting() { - return is_connecting; - } - public boolean wantsToDisconnect() { return wants_to_disconnect; } + public boolean isConnecting() { + return + !isConnected() && + !isDisconnected() && + !isPaused(); + } + public boolean isConnected() { return level == VpnStatus.ConnectionStatus.LEVEL_CONNECTED; } @@ -79,14 +83,19 @@ public class EipStatus extends Observable implements VpnStatus.StateListener { return level == VpnStatus.ConnectionStatus.LEVEL_NOTCONNECTED; } + public boolean isPaused() { + return level == VpnStatus.ConnectionStatus.LEVEL_VPNPAUSED; + } + public void setConnecting() { - is_connecting = true; is_disconnecting = false; wants_to_disconnect = false; + current_status.setChanged(); + current_status.notifyObservers(); } public void setConnectedOrDisconnected() { - is_connecting = false; + Log.d(TAG, "setConnectedOrDisconnected()"); is_disconnecting = false; wants_to_disconnect = false; current_status.setChanged(); @@ -95,7 +104,6 @@ public class EipStatus extends Observable implements VpnStatus.StateListener { public void setDisconnecting() { is_disconnecting = true; - is_connecting = false; wants_to_disconnect = false; } @@ -139,4 +147,9 @@ public class EipStatus extends Observable implements VpnStatus.StateListener { this.level = level; } + @Override + public String toString() { + return "State: " + state + " Level: " + level.toString(); + } + } diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnLauncher.java b/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnLauncher.java index 9814c167..d79d8003 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnLauncher.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnLauncher.java @@ -8,7 +8,7 @@ import android.os.Bundle; public class VoidVpnLauncher extends Activity { private static final int VPN_USER_PERMISSION = 71; - + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); |