summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap/bitmaskclient/eip
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2014-12-15 11:30:28 +0100
committerParménides GV <parmegv@sdf.org>2014-12-15 11:30:28 +0100
commit582758a34f6fd82ad1071bf9a196f0fa048689e8 (patch)
tree4df139d81922e4d3eebd5191996e27ff2c203673 /app/src/main/java/se/leap/bitmaskclient/eip
parent97aded26654ede8204a313dd6967b678a72a2a10 (diff)
Working on Android 5.
Beware! https://code.google.com/p/android/issues/detail?id=80074: Wrong VpnService.prepare() behavior after re-installation of the VPN app on Android 5.0 "The following steps will cause incorrect behavior of the VpnService.prepare(): 1. Establish VPN connection using any VPN app. VpnService.prepare() will return an intent for the "Connection request" system activity. Once user accepts it, VPN connection can be established successfully. 2. Uninstall VPN app. 3. Re-install the same VPN app. 4. Now VpnService.prepare() returns null, as if the VPN service has been already prepared. 5. Now VpnService.protect() returns false and VPN connection fails. Device reboot is needed in order to be able to establish VPN connection again."
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/eip')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/Constants.java1
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/EIP.java28
2 files changed, 12 insertions, 17 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/Constants.java b/app/src/main/java/se/leap/bitmaskclient/eip/Constants.java
index 01a83d5f..12c2e015 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/Constants.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/Constants.java
@@ -39,7 +39,6 @@ public interface Constants {
public final static String CERTIFICATE = "cert";
public final static String PRIVATE_KEY = TAG + ".PRIVATE_KEY";
public final static String KEY = TAG + ".KEY";
- public final static String PARSED_SERIAL = TAG + ".PARSED_SERIAL";
public final static String RECEIVER_TAG = TAG + ".RECEIVER_TAG";
public final static String REQUEST_TAG = TAG + ".REQUEST_TAG";
public final static String START_BLOCKING_VPN_PROFILE = TAG + ".START_BLOCKING_VPN_PROFILE";
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 4363dd13..0713e521 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java
@@ -22,6 +22,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
+import android.os.Handler;
import android.os.ResultReceiver;
import android.util.Log;
@@ -38,7 +39,6 @@ import de.blinkt.openvpn.VpnProfile;
import de.blinkt.openvpn.core.ProfileManager;
import se.leap.bitmaskclient.Dashboard;
import se.leap.bitmaskclient.EipServiceFragment;
-import se.leap.bitmaskclient.Provider;
import static se.leap.bitmaskclient.eip.Constants.ACTION_CHECK_CERT_VALIDITY;
import static se.leap.bitmaskclient.eip.Constants.ACTION_IS_EIP_RUNNING;
@@ -65,20 +65,19 @@ 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;
private static SharedPreferences preferences;
- private static JSONObject eip_definition = null;
+ private static JSONObject eip_definition;
private static List<Gateway> gateways = new ArrayList<Gateway>();
private static ProfileManager profile_manager;
- private static Gateway activeGateway = null;
+ private static Gateway gateway;
public EIP(){
- super("LEAPEIP");
+ super(TAG);
}
@Override
@@ -117,13 +116,15 @@ public final class EIP extends IntentService {
private void startEIP() {
if(gateways.isEmpty())
updateEIPService();
- GatewaySelector gateway_selector = new GatewaySelector(gateways);
- activeGateway = gateway_selector.select();
- if(activeGateway != null && activeGateway.getProfile() != null) {
+ earlyRoutes();
+
+ GatewaySelector gateway_selector = new GatewaySelector(gateways);
+ gateway = gateway_selector.select();
+ if(gateway != null && gateway.getProfile() != null) {
mReceiver = EipServiceFragment.getReceiver();
launchActiveGateway();
}
- earlyRoutes();
+ tellToReceiver(ACTION_START_EIP, Activity.RESULT_OK);
}
/**
@@ -140,16 +141,11 @@ public final class EIP extends IntentService {
Intent intent = new Intent(this,LaunchVPN.class);
intent.setAction(Intent.ACTION_MAIN);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.putExtra(LaunchVPN.EXTRA_NAME, activeGateway.getProfile().getName() );
+ intent.putExtra(LaunchVPN.EXTRA_NAME, gateway.getProfile().getName());
intent.putExtra(LaunchVPN.EXTRA_HIDELOG, true);
- intent.putExtra(RECEIVER_TAG, mReceiver);
startActivity(intent);
}
-
- /**
- * Disconnects the EIP connection gracefully through the bound service or forcefully
- * if there is no bound service. Sends a message to the requesting ResultReceiver.
- */
+
private void stopEIP() {
EipStatus eip_status = EipStatus.getInstance();
Log.d(TAG, "stopEip(): eip is connected? " + eip_status.isConnected());