summaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/AboutActivity.java5
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java13
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Dashboard.java68
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/DownloadFailedDialog.java3
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java67
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java3
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/LogInDialog.java14
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java5
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Provider.java12
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderListAdapter.java4
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderListFragment.java11
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/SessionDialogInterface.java2
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/SignUpDialog.java12
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/Constants.java2
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/EIP.java61
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java25
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java25
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/GatewaySelector.java8
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java4
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/VpnCertificateValidator.java9
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java12
21 files changed, 177 insertions, 188 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/AboutActivity.java b/app/src/main/java/se/leap/bitmaskclient/AboutActivity.java
index 6d025422..6c4e517b 100644
--- a/app/src/main/java/se/leap/bitmaskclient/AboutActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/AboutActivity.java
@@ -1,15 +1,10 @@
package se.leap.bitmaskclient;
import android.app.Activity;
-import android.app.Fragment;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
import android.widget.TextView;
-import se.leap.bitmaskclient.R;
public class AboutActivity extends Activity {
diff --git a/app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java b/app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java
index c95d0c8b..c0f0b0c3 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java
@@ -16,11 +16,15 @@
*/
package se.leap.bitmaskclient;
+import android.util.Base64;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
-import java.lang.IllegalArgumentException;
import java.security.KeyFactory;
import java.security.KeyStore;
import java.security.KeyStoreException;
@@ -33,13 +37,6 @@ import java.security.interfaces.RSAPrivateKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.util.Base64;
-
/**
* Stores constants, and implements auxiliary methods used across all LEAP Android classes.
*
diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
index 4f6c6285..6288fd1f 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
@@ -16,19 +16,31 @@
*/
package se.leap.bitmaskclient;
-import se.leap.bitmaskclient.*;
-import se.leap.bitmaskclient.eip.*;
-
-import de.blinkt.openvpn.activities.LogWindow;
-
-import android.app.*;
-import android.content.*;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.DialogFragment;
+import android.app.FragmentTransaction;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
import android.content.pm.PackageManager.NameNotFoundException;
-import android.os.*;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.ResultReceiver;
import android.util.Log;
-import android.view.*;
-import android.widget.*;
-import org.json.*;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.widget.ProgressBar;
+import android.widget.TextView;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import de.blinkt.openvpn.activities.LogWindow;
+import se.leap.bitmaskclient.eip.Constants;
+import se.leap.bitmaskclient.eip.EIP;
+import se.leap.bitmaskclient.eip.EipStatus;
/**
* The main user facing Activity of LEAP Android, consisting of status, controls,
@@ -59,7 +71,6 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
private TextView status_message;
public ProviderAPIResultReceiver providerAPI_result_receiver;
- private static Provider provider;
private static boolean authed_eip;
@Override
@@ -87,7 +98,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
try {
int versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
int lastDetectedVersion = preferences.getInt(APP_VERSION, 0);
- preferences.edit().putInt(APP_VERSION, versionCode);
+ preferences.edit().putInt(APP_VERSION, versionCode).apply();
Log.d("Dashboard", "detected version code: " + versionCode);
Log.d("Dashboard", "last detected version code: " + lastDetectedVersion);
@@ -102,6 +113,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
break;
}
} catch (NameNotFoundException e) {
+ Log.d(TAG, "Handle version didn't find any " + getPackageName() + " package");
}
}
@@ -121,13 +133,12 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
if ( requestCode == CONFIGURE_LEAP || requestCode == SWITCH_PROVIDER) {
// It should be equivalent: if ( (requestCode == CONFIGURE_LEAP) || (data!= null && data.hasExtra(STOP_FIRST))) {
if ( resultCode == RESULT_OK ){
- preferences.edit().putInt(Constants.PARSED_SERIAL, 0).commit();
- preferences.edit().putBoolean(Constants.AUTHED_EIP, authed_eip).commit();
+ preferences.edit().putInt(Constants.PARSED_SERIAL, 0).apply();
+ preferences.edit().putBoolean(Constants.AUTHED_EIP, authed_eip).apply();
updateEipService();
buildDashboard(false);
invalidateOptionsMenu();
if(data != null && data.hasExtra(LogInDialog.TAG)) {
- View view = ((ViewGroup)findViewById(android.R.id.content)).getChildAt(0);
logInDialog(Bundle.EMPTY);
}
} else if(resultCode == RESULT_CANCELED && (data == null || data.hasExtra(ACTION_QUIT))) {
@@ -158,7 +169,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
.setNegativeButton(getResources().getString(R.string.setup_error_close_button), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- preferences.edit().remove(Provider.KEY).commit();
+ preferences.edit().remove(Provider.KEY).apply();
finish();
}
})
@@ -170,7 +181,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
* service dependent UI elements to include.
*/
private void buildDashboard(boolean hide_and_turn_on_eip) {
- provider = Provider.getInstance();
+ Provider provider = Provider.getInstance();
provider.init( this );
setContentView(R.layout.client_dashboard);
@@ -183,16 +194,17 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
if ( provider.hasEIP()){
- EipServiceFragment previous_eip_fragment = (EipServiceFragment)fragment_manager.findFragmentByTag(EipServiceFragment.TAG);
- EipServiceFragment eipFragment = previous_eip_fragment == null ?
- new EipServiceFragment() : previous_eip_fragment;
+ EipServiceFragment eipFragment = new EipServiceFragment();
+
if (hide_and_turn_on_eip) {
- preferences.edit().remove(Dashboard.START_ON_BOOT).commit();
+ preferences.edit().remove(Dashboard.START_ON_BOOT).apply();
Bundle arguments = new Bundle();
arguments.putBoolean(EipServiceFragment.START_ON_BOOT, true);
eipFragment.setArguments(arguments);
}
- fragment_manager.replace(R.id.servicesCollection, eipFragment, EipServiceFragment.TAG);
+
+ fragment_manager.removePreviousFragment(EipServiceFragment.TAG);
+ fragment_manager.replace(R.id.servicesCollection, eipFragment, EipServiceFragment.TAG);
if (hide_and_turn_on_eip) {
onBackPressed();
@@ -205,12 +217,12 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
JSONObject provider_json;
try {
String provider_json_string = preferences.getString(Provider.KEY, "");
- if(provider_json_string.isEmpty() == false) {
+ if(!provider_json_string.isEmpty()) {
provider_json = new JSONObject(provider_json_string);
JSONObject service_description = provider_json.getJSONObject(Provider.SERVICE);
boolean authed_eip = !LeapSRPSession.getToken().isEmpty();
boolean allow_registered_eip = service_description.getBoolean(Provider.ALLOW_REGISTRATION);
- preferences.edit().putBoolean(Constants.ALLOWED_REGISTERED, allow_registered_eip);
+ preferences.edit().putBoolean(Constants.ALLOWED_REGISTERED, allow_registered_eip).apply();
if(allow_registered_eip) {
if(authed_eip) {
@@ -256,7 +268,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
}
eipStop();
}
- preferences.edit().clear().commit();
+ preferences.edit().clear().apply();
startActivityForResult(new Intent(this,ConfigurationWizard.class), SWITCH_PROVIDER);
return true;
case R.id.login_button:
@@ -405,7 +417,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
invalidateOptionsMenu();
authed_eip = true;
- preferences.edit().putBoolean(Constants.AUTHED_EIP, authed_eip).commit();
+ preferences.edit().putBoolean(Constants.AUTHED_EIP, authed_eip).apply();
downloadAuthedUserCertificate();
} else if(resultCode == ProviderAPI.SRP_AUTHENTICATION_FAILED) {
@@ -420,7 +432,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
invalidateOptionsMenu();
authed_eip = false;
- preferences.edit().putBoolean(Constants.AUTHED_EIP, authed_eip).commit();
+ preferences.edit().putBoolean(Constants.AUTHED_EIP, authed_eip).apply();
} else if(resultCode == ProviderAPI.LOGOUT_FAILED) {
changeStatusMessage(resultCode);
diff --git a/app/src/main/java/se/leap/bitmaskclient/DownloadFailedDialog.java b/app/src/main/java/se/leap/bitmaskclient/DownloadFailedDialog.java
index f78002b0..a44253c6 100644
--- a/app/src/main/java/se/leap/bitmaskclient/DownloadFailedDialog.java
+++ b/app/src/main/java/se/leap/bitmaskclient/DownloadFailedDialog.java
@@ -16,9 +16,6 @@
*/
package se.leap.bitmaskclient;
-import se.leap.bitmaskclient.R;
-import se.leap.bitmaskclient.NewProviderDialog.NewProviderDialogInterface;
-import se.leap.bitmaskclient.ProviderListContent.ProviderItem;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
diff --git a/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java
index f29d1338..b896c00f 100644
--- a/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java
@@ -1,19 +1,28 @@
package se.leap.bitmaskclient;
-import se.leap.bitmaskclient.R;
-import se.leap.bitmaskclient.ProviderAPIResultReceiver;
-import se.leap.bitmaskclient.ProviderAPIResultReceiver.Receiver;
-import se.leap.bitmaskclient.eip.*;
-
-import de.blinkt.openvpn.activities.*;
-import de.blinkt.openvpn.core.*;
-import android.app.*;
-import android.content.*;
-import android.os.*;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Fragment;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.ResultReceiver;
import android.util.Log;
-import android.view.*;
-import android.widget.*;
-import java.util.*;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.CompoundButton;
+import android.widget.Switch;
+import android.widget.TextView;
+
+import java.util.Observable;
+import java.util.Observer;
+
+import de.blinkt.openvpn.activities.DisconnectVPN;
+import se.leap.bitmaskclient.eip.Constants;
+import se.leap.bitmaskclient.eip.EIP;
+import se.leap.bitmaskclient.eip.EipStatus;
public class EipServiceFragment extends Fragment implements Observer, CompoundButton.OnCheckedChangeListener {
@@ -26,7 +35,6 @@ public class EipServiceFragment extends Fragment implements Observer, CompoundBu
private View eipFragment;
private static Switch eipSwitch;
- private View eipDetail;
private TextView status_message;
private static Activity parent_activity;
@@ -50,8 +58,8 @@ public class EipServiceFragment extends Fragment implements Observer, CompoundBu
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- eipFragment = inflater.inflate(R.layout.eip_service_fragment, container, false);
- eipDetail = ((RelativeLayout) eipFragment.findViewById(R.id.eipDetail));
+ eipFragment = inflater.inflate(R.layout.eip_service_fragment, container, false);
+ View eipDetail = eipFragment.findViewById(R.id.eipDetail);
eipDetail.setVisibility(View.VISIBLE);
View eipSettings = eipFragment.findViewById(R.id.eipSettings);
@@ -213,7 +221,7 @@ public class EipServiceFragment extends Fragment implements Observer, CompoundBu
public void update (Observable observable, Object data) {
Log.d(TAG, "handleNewState?");
if(observable instanceof EipStatus) {
- this.eip_status = (EipStatus) observable;
+ eip_status = (EipStatus) observable;
final EipStatus eip_status = (EipStatus) observable;
parent_activity.runOnUiThread(new Runnable() {
@Override
@@ -284,14 +292,6 @@ public class EipServiceFragment extends Fragment implements Observer, CompoundBu
parent_activity.findViewById(R.id.eipProgress).setVisibility(View.GONE);
}
- public static EipStatus getEipStatus() {
- return eip_status;
- }
-
- public void checkEipSwitch(boolean activated) {
- eipSwitch.setChecked(activated);
- }
-
protected class EIPReceiver extends ResultReceiver {
protected EIPReceiver(Handler handler){
@@ -303,21 +303,18 @@ public class EipServiceFragment extends Fragment implements Observer, CompoundBu
super.onReceiveResult(resultCode, resultData);
String request = resultData.getString(Constants.REQUEST_TAG);
- boolean checked = false;
-
- if (request == Constants.ACTION_START_EIP) {
+
+ if (request.equals(Constants.ACTION_START_EIP)) {
switch (resultCode){
case Activity.RESULT_OK:
Log.d(TAG, "Action start eip = Result OK");
- checked = true;
eipFragment.findViewById(R.id.eipProgress).setVisibility(View.VISIBLE);
break;
case Activity.RESULT_CANCELED:
- checked = false;
eipFragment.findViewById(R.id.eipProgress).setVisibility(View.GONE);
break;
}
- } else if (request == Constants.ACTION_STOP_EIP) {
+ } else if (request.equals(Constants.ACTION_STOP_EIP)) {
switch (resultCode){
case Activity.RESULT_OK:
Intent disconnect_vpn = new Intent(parent_activity, DisconnectVPN.class);
@@ -325,20 +322,16 @@ public class EipServiceFragment extends Fragment implements Observer, CompoundBu
eip_status.setDisconnecting();
break;
case Activity.RESULT_CANCELED:
- checked = true;
break;
}
- } else if (request == Constants.EIP_NOTIFICATION) {
+ } else if (request.equals(Constants.EIP_NOTIFICATION)) {
switch (resultCode){
case Activity.RESULT_OK:
- checked = true;
break;
case Activity.RESULT_CANCELED:
- checked = false;
break;
}
- } else if (request == Constants.ACTION_CHECK_CERT_VALIDITY) {
- checked = eipSwitch.isChecked();
+ } else if (request.equals(Constants.ACTION_CHECK_CERT_VALIDITY)) {
switch (resultCode) {
case Activity.RESULT_OK:
break;
diff --git a/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java b/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java
index a953a710..989dc395 100644
--- a/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java
+++ b/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java
@@ -17,13 +17,14 @@
package se.leap.bitmaskclient;
+import org.jboss.security.srp.SRPParameters;
+
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Arrays;
-import org.jboss.security.srp.SRPParameters;
/**
* Implements all SRP algorithm logic.
diff --git a/app/src/main/java/se/leap/bitmaskclient/LogInDialog.java b/app/src/main/java/se/leap/bitmaskclient/LogInDialog.java
index 97a9aecc..5263392e 100644
--- a/app/src/main/java/se/leap/bitmaskclient/LogInDialog.java
+++ b/app/src/main/java/se/leap/bitmaskclient/LogInDialog.java
@@ -16,19 +16,13 @@
*/
package se.leap.bitmaskclient;
-import se.leap.bitmaskclient.R;
-import android.R.color;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
-import android.content.res.ColorStateList;
import android.os.Bundle;
-import android.provider.CalendarContract.Colors;
import android.view.LayoutInflater;
import android.view.View;
-import android.view.animation.AlphaAnimation;
-import android.view.animation.BounceInterpolator;
import android.widget.EditText;
import android.widget.TextView;
@@ -47,6 +41,8 @@ public class LogInDialog extends SessionDialogInterface {
final public static String TAG = LogInDialog.class.getSimpleName();
+ private static LogInDialog dialog;
+
private static boolean is_eip_pending = false;
public AlertDialog onCreateDialog(Bundle savedInstanceState) {
@@ -122,8 +118,10 @@ public class LogInDialog extends SessionDialogInterface {
* @return a new instance of this DialogFragment.
*/
public static DialogFragment newInstance() {
- LogInDialog dialog_fragment = new LogInDialog();
- return dialog_fragment;
+ if(dialog == null)
+ dialog = new LogInDialog();
+
+ return dialog;
}
@Override
diff --git a/app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java b/app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java
index 74f89ab8..07ed6c8f 100644
--- a/app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java
+++ b/app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java
@@ -1,7 +1,8 @@
package se.leap.bitmaskclient;
-import android.content.*;
-import android.util.Log;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
import se.leap.bitmaskclient.eip.Constants;
diff --git a/app/src/main/java/se/leap/bitmaskclient/Provider.java b/app/src/main/java/se/leap/bitmaskclient/Provider.java
index 8d6385e0..fa1a4fb5 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Provider.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Provider.java
@@ -16,17 +16,17 @@
*/
package se.leap.bitmaskclient;
-import java.io.Serializable;
-import java.util.Arrays;
-import java.util.Locale;
+import android.app.Activity;
+import android.content.Context;
+import android.content.SharedPreferences;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
-import android.content.Context;
-import android.app.Activity;
-import android.content.SharedPreferences;
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.Locale;
/**
* @author Sean Leonard <meanderingcode@aetherislands.net>
diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderListAdapter.java b/app/src/main/java/se/leap/bitmaskclient/ProviderListAdapter.java
index 43bba085..1148e65e 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ProviderListAdapter.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ProviderListAdapter.java
@@ -1,7 +1,5 @@
package se.leap.bitmaskclient;
-import java.util.List;
-
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
@@ -9,6 +7,8 @@ import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TwoLineListItem;
+import java.util.List;
+
public class ProviderListAdapter<T> extends ArrayAdapter<T> {
private static boolean[] hidden = null;
diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderListFragment.java b/app/src/main/java/se/leap/bitmaskclient/ProviderListFragment.java
index db414d87..e5baebc0 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ProviderListFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ProviderListFragment.java
@@ -16,8 +16,6 @@
*/
package se.leap.bitmaskclient;
-import se.leap.bitmaskclient.R;
-import se.leap.bitmaskclient.ProviderListContent.ProviderItem;
import android.app.Activity;
import android.app.ListFragment;
import android.os.Bundle;
@@ -26,11 +24,12 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
+import se.leap.bitmaskclient.ProviderListContent.ProviderItem;
+
/**
* A list fragment representing a list of Providers. This fragment
* also supports tablet devices by allowing list items to be given an
- * 'activated' state upon selection. This helps indicate which item is
- * currently being viewed in a {@link DashboardFragment}.
+ * 'activated' state upon selection.
* <p>
* Activities containing this fragment MUST implement the {@link Callbacks}
* interface.
@@ -123,7 +122,7 @@ public class ProviderListFragment extends ListFragment {
if(getArguments() != null && getArguments().containsKey(TOP_PADDING)) {
int topPadding = getArguments().getInt(TOP_PADDING);
View current_view = getView();
- getView().setPadding(current_view.getPaddingLeft(), topPadding, current_view.getPaddingRight(), current_view.getPaddingBottom());
+ current_view.setPadding(current_view.getPaddingLeft(), topPadding, current_view.getPaddingRight(), current_view.getPaddingBottom());
}
}
@@ -215,7 +214,7 @@ public class ProviderListFragment extends ListFragment {
real_count--;
} else {
i++;
- }
+ }
}
public void unhideAll() {
diff --git a/app/src/main/java/se/leap/bitmaskclient/SessionDialogInterface.java b/app/src/main/java/se/leap/bitmaskclient/SessionDialogInterface.java
index 7b08a4d1..66b86ccd 100644
--- a/app/src/main/java/se/leap/bitmaskclient/SessionDialogInterface.java
+++ b/app/src/main/java/se/leap/bitmaskclient/SessionDialogInterface.java
@@ -17,10 +17,8 @@
package se.leap.bitmaskclient;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
-import android.os.Bundle;
/**
* @author parmegv
diff --git a/app/src/main/java/se/leap/bitmaskclient/SignUpDialog.java b/app/src/main/java/se/leap/bitmaskclient/SignUpDialog.java
index d197e589..f6d6cc3f 100644
--- a/app/src/main/java/se/leap/bitmaskclient/SignUpDialog.java
+++ b/app/src/main/java/se/leap/bitmaskclient/SignUpDialog.java
@@ -16,19 +16,13 @@
*/
package se.leap.bitmaskclient;
-import se.leap.bitmaskclient.R;
-import android.R.color;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
-import android.content.res.ColorStateList;
import android.os.Bundle;
-import android.provider.CalendarContract.Colors;
import android.view.LayoutInflater;
import android.view.View;
-import android.view.animation.AlphaAnimation;
-import android.view.animation.BounceInterpolator;
import android.widget.EditText;
import android.widget.TextView;
@@ -46,6 +40,7 @@ public class SignUpDialog extends SessionDialogInterface {
final public static String TAG = SignUpDialog.class.getSimpleName();
+ private static SignUpDialog dialog;
private static boolean is_eip_pending = false;
public AlertDialog onCreateDialog(Bundle savedInstanceState) {
@@ -112,8 +107,9 @@ public class SignUpDialog extends SessionDialogInterface {
* @return a new instance of this DialogFragment.
*/
public static DialogFragment newInstance() {
- SignUpDialog dialog_fragment = new SignUpDialog();
- return dialog_fragment;
+ if(dialog == null)
+ dialog = new SignUpDialog();
+ return dialog;
}
@Override
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 b710d780..e1a7e616 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/Constants.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/Constants.java
@@ -34,8 +34,6 @@ public interface Constants {
public final static String ACTION_UPDATE_EIP_SERVICE = TAG + ".UPDATE_EIP_SERVICE";
public final static String ACTION_IS_EIP_RUNNING = TAG + ".IS_RUNNING";
public final static String EIP_NOTIFICATION = TAG + ".EIP_NOTIFICATION";
- public final static String STATUS = TAG + ".STATUS";
- public final static String DATE_FROM_CERTIFICATE = TAG + ".DATE_FROM_CERTIFICATE";
public final static String ALLOWED_ANON = "allow_anonymous";
public final static String ALLOWED_REGISTERED = "allow_registration";
public final static String CERTIFICATE = "cert";
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 379fb246..5169ef62 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java
@@ -16,22 +16,40 @@
*/
package se.leap.bitmaskclient.eip;
-import android.app.*;
-import android.content.*;
-import android.os.*;
+import android.app.Activity;
+import android.app.IntentService;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.os.ResultReceiver;
import android.util.Log;
-import java.io.*;
-import java.security.cert.*;
-import java.text.*;
-import java.util.*;
-import org.json.*;
-import de.blinkt.openvpn.*;
-import de.blinkt.openvpn.activities.*;
-import de.blinkt.openvpn.core.*;
-import se.leap.bitmaskclient.*;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
-import static se.leap.bitmaskclient.eip.Constants.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import de.blinkt.openvpn.LaunchVPN;
+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;
+import static se.leap.bitmaskclient.eip.Constants.ACTION_START_EIP;
+import static se.leap.bitmaskclient.eip.Constants.ACTION_STOP_EIP;
+import static se.leap.bitmaskclient.eip.Constants.ACTION_UPDATE_EIP_SERVICE;
+import static se.leap.bitmaskclient.eip.Constants.CERTIFICATE;
+import static se.leap.bitmaskclient.eip.Constants.KEY;
+import static se.leap.bitmaskclient.eip.Constants.PARSED_SERIAL;
+import static se.leap.bitmaskclient.eip.Constants.RECEIVER_TAG;
+import static se.leap.bitmaskclient.eip.Constants.REQUEST_TAG;
/**
* EIP is the abstract base class for interacting with and managing the Encrypted
@@ -80,21 +98,21 @@ public final class EIP extends IntentService {
String action = intent.getAction();
mReceiver = intent.getParcelableExtra(RECEIVER_TAG);
- if ( action == ACTION_START_EIP )
+ if ( action.equals(ACTION_START_EIP))
startEIP();
- else if ( action == ACTION_STOP_EIP )
+ else if (action.equals(ACTION_STOP_EIP))
stopEIP();
- else if ( action == ACTION_IS_EIP_RUNNING )
+ else if (action.equals(ACTION_IS_EIP_RUNNING))
isRunning();
- else if ( action == ACTION_UPDATE_EIP_SERVICE )
+ else if (action.equals(ACTION_UPDATE_EIP_SERVICE))
updateEIPService();
- else if ( action == ACTION_CHECK_CERT_VALIDITY )
+ else if (action.equals(ACTION_CHECK_CERT_VALIDITY))
checkCertValidity();
}
/**
* Initiates an EIP connection by selecting a gateway and preparing and sending an
- * Intent to {@link se.leap.openvpn.LaunchVPN}.
+ * Intent to {@link de.blinkt.openvpn.LaunchVPN}.
* It also sets up early routes.
*/
private void startEIP() {
@@ -164,8 +182,7 @@ public final class EIP extends IntentService {
}
/**
- * Loads eip-service.json from SharedPreferences and calls {@link updateGateways()}
- * to parse gateway definitions.
+ * Loads eip-service.json from SharedPreferences, delete previous vpn profiles and add new gateways.
* TODO Implement API call to refresh eip-service.json from the provider
*/
private void updateEIPService() {
@@ -210,7 +227,7 @@ public final class EIP extends IntentService {
// TODO Auto-generated catch block
e.printStackTrace();
}
- preferences.edit().putInt(PARSED_SERIAL, eip_definition.optInt(Provider.API_RETURN_SERIAL)).commit();
+ preferences.edit().putInt(PARSED_SERIAL, eip_definition.optInt(Provider.API_RETURN_SERIAL)).apply();
}
private boolean isOpenVpnGateway(JSONObject gateway) {
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 82c3ceb8..4ac3bd6a 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java
@@ -17,18 +17,17 @@
package se.leap.bitmaskclient.eip;
import android.util.Log;
-import java.util.*;
-import de.blinkt.openvpn.core.*;
+import java.util.Observable;
+
+import de.blinkt.openvpn.core.VpnStatus;
public class EipStatus extends Observable implements VpnStatus.StateListener {
public static String TAG = EipStatus.class.getSimpleName();
private static EipStatus current_status;
- private static EipStatus previous_status;
private static VpnStatus.ConnectionStatus level = VpnStatus.ConnectionStatus.LEVEL_NOTCONNECTED;
private static boolean wants_to_disconnect = false;
- private static boolean is_disconnecting = false;
private String state, log_message;
private int localized_res_id;
@@ -46,7 +45,6 @@ public class EipStatus extends Observable implements VpnStatus.StateListener {
@Override
public void updateState(final String state, final String logmessage, final int localizedResId, final VpnStatus.ConnectionStatus level) {
current_status = getInstance();
- previous_status = current_status;
current_status.setState(state);
current_status.setLogMessage(logmessage);
current_status.setLocalizedResId(localizedResId);
@@ -60,10 +58,6 @@ public class EipStatus extends Observable implements VpnStatus.StateListener {
current_status.notifyObservers();
}
- public boolean isDisconnecting() {
- return is_disconnecting;
- }
-
public boolean wantsToDisconnect() {
return wants_to_disconnect;
}
@@ -88,7 +82,6 @@ public class EipStatus extends Observable implements VpnStatus.StateListener {
}
public void setConnecting() {
- is_disconnecting = false;
wants_to_disconnect = false;
current_status.setChanged();
current_status.notifyObservers();
@@ -96,21 +89,15 @@ public class EipStatus extends Observable implements VpnStatus.StateListener {
public void setConnectedOrDisconnected() {
Log.d(TAG, "setConnectedOrDisconnected()");
- is_disconnecting = false;
wants_to_disconnect = false;
current_status.setChanged();
current_status.notifyObservers();
}
public void setDisconnecting() {
- is_disconnecting = true;
wants_to_disconnect = false;
}
- public void setWantsToDisconnect() {
- wants_to_disconnect = true;
- }
-
public String getState() {
return state;
}
@@ -127,10 +114,6 @@ public class EipStatus extends Observable implements VpnStatus.StateListener {
return level;
}
- public EipStatus getPreviousStatus() {
- return previous_status;
- }
-
private void setState(String state) {
this.state = state;
}
@@ -144,7 +127,7 @@ public class EipStatus extends Observable implements VpnStatus.StateListener {
}
private void setLevel(VpnStatus.ConnectionStatus level) {
- this.level = level;
+ EipStatus.level = level;
}
@Override
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java b/app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java
index 6aa66ac0..3ee9443c 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java
@@ -17,16 +17,22 @@
package se.leap.bitmaskclient.eip;
import android.app.Activity;
-import android.content.*;
+import android.content.Context;
+import android.content.SharedPreferences;
import android.util.Log;
-import java.io.*;
-import java.util.*;
-import org.json.*;
-import de.blinkt.openvpn.*;
-import de.blinkt.openvpn.activities.*;
-import de.blinkt.openvpn.core.*;
-import se.leap.bitmaskclient.*;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.Collection;
+import java.util.Iterator;
+
+import de.blinkt.openvpn.VpnProfile;
+import de.blinkt.openvpn.core.ConfigParser;
+import de.blinkt.openvpn.core.ProfileManager;
+import se.leap.bitmaskclient.Dashboard;
/**
* Gateway provides objects defining gateways and their metadata.
@@ -103,9 +109,8 @@ public class Gateway {
private JSONObject getLocationInfo(JSONObject eip_definition) {
try {
JSONObject locations = eip_definition.getJSONObject("locations");
- JSONObject location = locations.getJSONObject(mGateway.getString("location"));
- return location;
+ return locations.getJSONObject(mGateway.getString("location"));
} catch (JSONException e) {
return new JSONObject();
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/GatewaySelector.java b/app/src/main/java/se/leap/bitmaskclient/eip/GatewaySelector.java
index 36b5fb41..39ae7ca6 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/GatewaySelector.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/GatewaySelector.java
@@ -1,8 +1,10 @@
package se.leap.bitmaskclient.eip;
-import java.security.cert.*;
-import java.util.*;
-import org.json.*;
+import java.util.Calendar;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeMap;
public class GatewaySelector {
List<Gateway> gateways;
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java b/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java
index 224e3bd4..a6f9fe76 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java
@@ -1,11 +1,7 @@
package se.leap.bitmaskclient.eip;
import android.content.Intent;
-import android.os.Process;
import android.net.VpnService;
-import android.util.Log;
-
-import static se.leap.bitmaskclient.eip.Constants.*;
public class VoidVpnService extends VpnService {
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/VpnCertificateValidator.java b/app/src/main/java/se/leap/bitmaskclient/eip/VpnCertificateValidator.java
index 16ae6a85..6487f6c1 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/VpnCertificateValidator.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/VpnCertificateValidator.java
@@ -17,12 +17,13 @@
package se.leap.bitmaskclient.eip;
import android.util.Log;
-import java.util.*;
-import java.security.cert.*;
-import java.text.*;
+
+import java.security.cert.CertificateExpiredException;
+import java.security.cert.CertificateNotYetValidException;
+import java.security.cert.X509Certificate;
+import java.util.Calendar;
import se.leap.bitmaskclient.ConfigHelper;
-import static se.leap.bitmaskclient.eip.Constants.*;
public class VpnCertificateValidator {
public final static String TAG = VpnCertificateValidator.class.getSimpleName();
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java b/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java
index 8e36f53c..0c8e9a04 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java
@@ -18,13 +18,14 @@ package se.leap.bitmaskclient.eip;
import android.content.SharedPreferences;
import android.util.Log;
-import java.util.Iterator;
-import java.util.Vector;
+
import org.json.JSONArray;
-import org.json.JSONObject;
import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Iterator;
-import se.leap.bitmaskclient.*;
+import se.leap.bitmaskclient.Provider;
public class VpnConfigGenerator {
@@ -38,7 +39,7 @@ public class VpnConfigGenerator {
public VpnConfigGenerator(SharedPreferences preferences, JSONObject general_configuration, JSONObject gateway) {
this.general_configuration = general_configuration;
this.gateway = gateway;
- this.preferences = preferences;
+ VpnConfigGenerator.preferences = preferences;
}
public String generate() {
@@ -56,7 +57,6 @@ public class VpnConfigGenerator {
String common_options = "";
try {
Iterator keys = general_configuration.keys();
- Vector<Vector<String>> value = new Vector<Vector<String>>();
while ( keys.hasNext() ){
String key = keys.next().toString();