summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/eip/EIP.java')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/EIP.java30
1 files changed, 28 insertions, 2 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 28a9bb50..39dd133f 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java
@@ -19,6 +19,7 @@ package se.leap.bitmaskclient.eip;
import android.app.*;
import android.content.*;
import android.os.*;
+import android.util.Log;
import org.json.*;
@@ -57,7 +58,6 @@ public final class EIP extends IntentService {
@Override
public void onCreate() {
super.onCreate();
-
context = getApplicationContext();
preferences = getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE);
eip_definition = eipDefinitionFromPreferences();
@@ -72,6 +72,8 @@ public final class EIP extends IntentService {
if (action.equals(ACTION_START_EIP))
startEIP();
+ else if (action.equals(ACTION_START_ALWAYS_ON_EIP))
+ startAlwaysOnEIP();
else if (action.equals(ACTION_STOP_EIP))
stopEIP();
else if (action.equals(ACTION_IS_EIP_RUNNING))
@@ -88,9 +90,12 @@ public final class EIP extends IntentService {
* It also sets up early routes.
*/
private void startEIP() {
+ Log.d(TAG, "startEIP vpn");
if (gateways_manager.isEmpty())
updateEIPService();
- earlyRoutes();
+ if (!EipStatus.getInstance().isBlockingVpnEstablished()) {
+ earlyRoutes();
+ }
gateway = gateways_manager.select();
if (gateway != null && gateway.getProfile() != null) {
@@ -102,6 +107,27 @@ public final class EIP extends IntentService {
}
/**
+ * Tries to start the last used vpn profile when the OS was rebooted and always-on-VPN is enabled.
+ * The {@link OnBootReceiver} will care if there is no profile.
+ */
+ private void startAlwaysOnEIP() {
+ Log.d(TAG, "startAlwaysOnEIP vpn");
+
+ if (gateways_manager.isEmpty())
+ updateEIPService();
+
+ gateway = gateways_manager.select();
+
+ if (gateway != null && gateway.getProfile() != null) {
+ //mReceiver = VpnFragment.getReceiver();
+ Log.d(TAG, "startAlwaysOnEIP eip launch avtive gateway vpn");
+ launchActiveGateway();
+ } else {
+ Log.d(TAG, "startAlwaysOnEIP no active profile available!");
+ }
+ }
+
+ /**
* Early routes are routes that block traffic until a new
* VpnService is started properly.
*/