summaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'app/src')
-rw-r--r--app/src/androidTest/java/se/leap/bitmaskclient/test/TestEIP.java8
-rw-r--r--app/src/androidTest/java/se/leap/bitmaskclient/test/TestGatewaysManager.java4
-rw-r--r--app/src/insecure/java/se/leap/bitmaskclient/ProviderAPI.java9
-rw-r--r--app/src/insecure/java/se/leap/bitmaskclient/ProviderDetailFragment.java9
-rw-r--r--app/src/main/AndroidManifest.xml16
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java7
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Constants.java43
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Dashboard.java47
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/FeatureVersionCode.java5
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java3
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java18
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderApiBase.java7
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/StartActivity.java135
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/VpnFragment.java46
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/Constants.java48
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/EIP.java47
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java5
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnLauncher.java13
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java20
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java4
-rw-r--r--app/src/main/res/drawable-hdpi/ic_splash_background.pngbin0 -> 39702 bytes
-rw-r--r--app/src/main/res/drawable-ldpi/mask.pngbin0 -> 8743 bytes
-rw-r--r--app/src/main/res/drawable-mdpi/mask.pngbin0 -> 6324 bytes
-rw-r--r--app/src/main/res/drawable-xhdpi/ic_splash_background.pngbin0 -> 64868 bytes
-rw-r--r--app/src/main/res/drawable-xxxhdpi/ic_splash_background.pngbin0 -> 131879 bytes
-rw-r--r--app/src/main/res/drawable-xxxhdpi/mask.pngbin0 -> 43251 bytes
-rw-r--r--app/src/main/res/drawable/ic_colorsquare.xml52
-rw-r--r--app/src/main/res/drawable/splash_page.xml13
-rw-r--r--app/src/main/res/values/attrs.xml8
-rw-r--r--app/src/main/res/values/colors.xml23
-rw-r--r--app/src/main/res/values/themes.xml12
-rw-r--r--app/src/production/java/se/leap/bitmaskclient/ProviderAPI.java9
-rw-r--r--app/src/production/java/se/leap/bitmaskclient/ProviderDetailFragment.java10
-rw-r--r--app/src/test/java/se/leap/bitmaskclient/eip/GatewaysManagerTest.java5
34 files changed, 427 insertions, 199 deletions
diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestEIP.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/TestEIP.java
index 15bb53e1..c5a6e809 100644
--- a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestEIP.java
+++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/TestEIP.java
@@ -59,14 +59,14 @@ public class TestEIP extends ServiceTestCase<EIP> {
}
private void testEmptyCertificate() {
- preferences.edit().putString(Constants.VPN_CERTIFICATE, "").apply();
- startService(Constants.ACTION_CHECK_CERT_VALIDITY);
+ preferences.edit().putString(Constants.PROVIDER_VPN_CERTIFICATE, "").apply();
+ startService(Constants.EIP_ACTION_CHECK_CERT_VALIDITY);
}
private void testExpiredCertificate() {
String expired_certificate = "expired certificate";
- preferences.edit().putString(Constants.VPN_CERTIFICATE, expired_certificate).apply();
- startService(Constants.ACTION_CHECK_CERT_VALIDITY);
+ preferences.edit().putString(Constants.PROVIDER_VPN_CERTIFICATE, expired_certificate).apply();
+ startService(Constants.EIP_ACTION_CHECK_CERT_VALIDITY);
}
private void startService(String action) {
diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestGatewaysManager.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/TestGatewaysManager.java
index 0a76638f..b8cc9715 100644
--- a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestGatewaysManager.java
+++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/TestGatewaysManager.java
@@ -25,7 +25,7 @@ import org.json.*;
import java.io.IOException;
import java.util.Arrays;
-import se.leap.bitmaskclient.*;
+import se.leap.bitmaskclient.Constants;
import se.leap.bitmaskclient.eip.*;
/**
@@ -109,7 +109,7 @@ public class TestGatewaysManager extends InstrumentationTestCase {
private void mockGatewaysManager() {
context = getInstrumentation().getContext();
- preferences = context.getSharedPreferences(Dashboard.SHARED_PREFERENCES, Activity.MODE_PRIVATE);
+ preferences = context.getSharedPreferences(Constants.SHARED_PREFERENCES, Activity.MODE_PRIVATE);
gateways_manager = new GatewaysManager(context, preferences);
}
diff --git a/app/src/insecure/java/se/leap/bitmaskclient/ProviderAPI.java b/app/src/insecure/java/se/leap/bitmaskclient/ProviderAPI.java
index 87fff283..7689c343 100644
--- a/app/src/insecure/java/se/leap/bitmaskclient/ProviderAPI.java
+++ b/app/src/insecure/java/se/leap/bitmaskclient/ProviderAPI.java
@@ -45,7 +45,6 @@ import javax.net.ssl.X509TrustManager;
import okhttp3.OkHttpClient;
import se.leap.bitmaskclient.ProviderListContent.ProviderItem;
-import se.leap.bitmaskclient.eip.Constants;
import se.leap.bitmaskclient.eip.EIP;
import static se.leap.bitmaskclient.R.string.certificate_error;
@@ -138,8 +137,8 @@ public class ProviderAPI extends ProviderApiBase {
//TODO setProviderName(name);
preferences.edit().putString(Provider.KEY, provider_json.toString()).commit();
- preferences.edit().putBoolean(Constants.ALLOWED_ANON, provider_json.getJSONObject(Provider.SERVICE).getBoolean(Constants.ALLOWED_ANON)).commit();
- preferences.edit().putBoolean(Constants.ALLOWED_REGISTERED, provider_json.getJSONObject(Provider.SERVICE).getBoolean(Constants.ALLOWED_REGISTERED)).commit();
+ preferences.edit().putBoolean(Constants.PROVIDER_ALLOW_ANONYMOUS, provider_json.getJSONObject(Provider.SERVICE).getBoolean(Constants.PROVIDER_ALLOW_ANONYMOUS)).commit();
+ preferences.edit().putBoolean(Constants.PROVIDER_ALLOWED_REGISTERED, provider_json.getJSONObject(Provider.SERVICE).getBoolean(Constants.PROVIDER_ALLOWED_REGISTERED)).commit();
result.putBoolean(RESULT_KEY, true);
} catch (JSONException e) {
@@ -168,7 +167,7 @@ public class ProviderAPI extends ProviderApiBase {
JSONObject eip_service_json = new JSONObject(eip_service_json_string);
eip_service_json.getInt(Provider.API_RETURN_SERIAL);
- preferences.edit().putString(Constants.KEY, eip_service_json.toString()).commit();
+ preferences.edit().putString(Constants.PROVIDER_KEY, eip_service_json.toString()).commit();
result.putBoolean(RESULT_KEY, true);
} catch (NullPointerException | JSONException e) {
@@ -191,7 +190,7 @@ public class ProviderAPI extends ProviderApiBase {
JSONObject provider_json = new JSONObject(preferences.getString(Provider.KEY, ""));
String provider_main_url = provider_json.getString(Provider.API_URL);
- URL new_cert_string_url = new URL(provider_main_url + "/" + provider_json.getString(Provider.API_VERSION) + "/" + Constants.VPN_CERTIFICATE);
+ URL new_cert_string_url = new URL(provider_main_url + "/" + provider_json.getString(Provider.API_VERSION) + "/" + Constants.PROVIDER_VPN_CERTIFICATE);
String cert_string = downloadWithProviderCA(new_cert_string_url.toString(), last_danger_on);
diff --git a/app/src/insecure/java/se/leap/bitmaskclient/ProviderDetailFragment.java b/app/src/insecure/java/se/leap/bitmaskclient/ProviderDetailFragment.java
index 629867e6..390d4aeb 100644
--- a/app/src/insecure/java/se/leap/bitmaskclient/ProviderDetailFragment.java
+++ b/app/src/insecure/java/se/leap/bitmaskclient/ProviderDetailFragment.java
@@ -2,7 +2,6 @@ package se.leap.bitmaskclient;
import org.json.*;
-import se.leap.bitmaskclient.eip.*;
import se.leap.bitmaskclient.ProviderListContent.ProviderItem;
import android.app.*;
@@ -23,7 +22,7 @@ public class ProviderDetailFragment extends DialogFragment {
LayoutInflater inflater = getActivity().getLayoutInflater();
View provider_detail_view = inflater.inflate(R.layout.provider_detail_fragment, null);
- JSONObject provider_json = new JSONObject(getActivity().getSharedPreferences(Dashboard.SHARED_PREFERENCES, getActivity().MODE_PRIVATE).getString(Provider.KEY, ""));
+ JSONObject provider_json = new JSONObject(getActivity().getSharedPreferences(Constants.SHARED_PREFERENCES, getActivity().MODE_PRIVATE).getString(Provider.KEY, ""));
final TextView domain = (TextView) provider_detail_view.findViewById(R.id.provider_detail_domain);
domain.setText(provider_json.getString(Provider.DOMAIN));
@@ -60,7 +59,7 @@ public class ProviderDetailFragment extends DialogFragment {
private boolean anon_allowed(JSONObject provider_json) {
try {
JSONObject service_description = provider_json.getJSONObject(Provider.SERVICE);
- return service_description.has(Constants.ALLOWED_ANON) && service_description.getBoolean(Constants.ALLOWED_ANON);
+ return service_description.has(Constants.PROVIDER_ALLOW_ANONYMOUS) && service_description.getBoolean(Constants.PROVIDER_ALLOW_ANONYMOUS);
} catch (JSONException e) {
return false;
}
@@ -78,8 +77,8 @@ public class ProviderDetailFragment extends DialogFragment {
@Override
public void onCancel(DialogInterface dialog) {
super.onCancel(dialog);
- SharedPreferences.Editor editor = getActivity().getSharedPreferences(Dashboard.SHARED_PREFERENCES, Activity.MODE_PRIVATE).edit();
- editor.remove(Provider.KEY).remove(ProviderItem.DANGER_ON).remove(Constants.ALLOWED_ANON).remove(Constants.KEY).commit();
+ SharedPreferences.Editor editor = getActivity().getSharedPreferences(Constants.SHARED_PREFERENCES, Activity.MODE_PRIVATE).edit();
+ editor.remove(Provider.KEY).remove(ProviderItem.DANGER_ON).remove(Constants.PROVIDER_ALLOW_ANONYMOUS).remove(Constants.PROVIDER_KEY).commit();
interface_with_configuration_wizard.cancelAndShowAllProviders();
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 8c6b25d5..4dd11143 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -88,6 +88,14 @@
android:uiOptions="splitActionBarWhenNarrow"
android:launchMode="singleTop"
>
+ </activity>
+ <activity
+ android:name="se.leap.bitmaskclient.StartActivity"
+ android:label="@string/app_name"
+ android:launchMode="singleTop"
+ android:noHistory="true"
+ android:theme="@style/SplashTheme"
+ >
<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.MAIN" />
@@ -107,9 +115,11 @@
<service android:name="se.leap.bitmaskclient.eip.EIP" android:exported="false">
<intent-filter>
- <action android:name="se.leap.bitmaskclient.eip.UPDATE_EIP_SERVICE"/>
- <action android:name="se.leap.bitmaskclient.eip.START_EIP"/>
- <action android:name="se.leap.bitmaskclient.eip.STOP_EIP"/>
+ <action android:name="se.leap.bitmaskclient.EIP.UPDATE"/>
+ <action android:name="se.leap.bitmaskclient.EIP.START"/>
+ <action android:name="se.leap.bitmaskclient.EIP.STOP"/>
+ <action android:name="se.leap.bitmaskclient.START_ALWAYS_ON_EIP"/>
+ <action android:name="se.leap.bitmaskclient.EIP.IS_RUNNING"/>
</intent-filter>
</service>
</application>
diff --git a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java
index 4f6163bc..21520dc4 100644
--- a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java
@@ -51,7 +51,6 @@ import javax.inject.Inject;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnItemClick;
-import se.leap.bitmaskclient.eip.Constants;
import se.leap.bitmaskclient.userstatus.SessionDialog;
import static android.view.View.GONE;
@@ -134,7 +133,7 @@ public abstract class BaseConfigurationWizard extends Activity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- preferences = getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE);
+ preferences = getSharedPreferences(Constants.SHARED_PREFERENCES, MODE_PRIVATE);
fragment_manager = new FragmentManagerEnhanced(getFragmentManager());
provider_manager = ProviderManager.getInstance(getAssets(), getExternalFilesDir(null));
@@ -220,7 +219,7 @@ public abstract class BaseConfigurationWizard extends Activity
e.printStackTrace();
}
- if (preferences.getBoolean(Constants.ALLOWED_ANON, false)) {
+ if (preferences.getBoolean(Constants.PROVIDER_ALLOW_ANONYMOUS, false)) {
mConfigState.putExtra(SERVICES_RETRIEVED, true);
downloadVpnCertificate();
@@ -297,7 +296,7 @@ public abstract class BaseConfigurationWizard extends Activity
public void cancelSettingUpProvider() {
mConfigState.setAction(PROVIDER_NOT_SET);
adapter.showAllProviders();
- preferences.edit().remove(Provider.KEY).remove(Constants.ALLOWED_ANON).remove(Constants.KEY).apply();
+ preferences.edit().remove(Provider.KEY).remove(Constants.PROVIDER_ALLOW_ANONYMOUS).remove(Constants.PROVIDER_KEY).apply();
}
private void askDashboardToQuitApp() {
diff --git a/app/src/main/java/se/leap/bitmaskclient/Constants.java b/app/src/main/java/se/leap/bitmaskclient/Constants.java
new file mode 100644
index 00000000..a7ab56fd
--- /dev/null
+++ b/app/src/main/java/se/leap/bitmaskclient/Constants.java
@@ -0,0 +1,43 @@
+package se.leap.bitmaskclient;
+
+public interface Constants {
+
+ //////////////////////////////////////////////
+ // PREFERENCES CONSTANTS
+ /////////////////////////////////////////////
+
+ String SHARED_PREFERENCES = "LEAPPreferences";
+ String PREFERENCES_APP_VERSION = "bitmask version";
+
+
+ //////////////////////////////////////////////
+ // EIP CONSTANTS
+ /////////////////////////////////////////////
+
+ String EIP_ACTION_CHECK_CERT_VALIDITY = "EIP.CHECK_CERT_VALIDITY";
+ String EIP_ACTION_START = "se.leap.bitmaskclient.EIP.START";
+ String EIP_ACTION_STOP = "se.leap.bitmaskclient.EIP.STOP";
+ String EIP_ACTION_UPDATE = "se.leap.bitmaskclient.EIP.UPDATE";
+ String EIP_ACTION_IS_RUNNING = "se.leap.bitmaskclient.EIP.IS_RUNNING";
+ String EIP_ACTION_START_ALWAYS_ON_EIP = "se.leap.bitmaskclient.START_ALWAYS_ON_EIP";
+ String EIP_ACTION_START_BLOCKING_VPN = "se.leap.bitmaskclient.EIP_ACTION_START_BLOCKING_VPN";
+ String EIP_ACTION_STOP_BLOCKING_VPN = "se.leap.bitmaskclient.EIP_ACTION_STOP_BLOCKING_VPN";
+
+ String EIP_NOTIFICATION = "EIP.NOTIFICATION";
+ String EIP_RECEIVER = "EIP.RECEIVER";
+ String EIP_REQUEST = "EIP.REQUEST";
+ String EIP_RESTART_ON_BOOT = "EIP.RESTART_ON_BOOT";
+ String EIP_IS_ALWAYS_ON = "EIP.EIP_IS_ALWAYS_ON";
+
+
+
+ //////////////////////////////////////////////
+ // PROVIDER CONSTANTS
+ /////////////////////////////////////////////
+ String PROVIDER_ALLOW_ANONYMOUS = "allow_anonymous";
+ String PROVIDER_ALLOWED_REGISTERED = "allow_registration";
+ String PROVIDER_VPN_CERTIFICATE = "cert";
+ String PROVIDER_PRIVATE_KEY = "Constants.PROVIDER_PRIVATE_KEY";
+ String PROVIDER_KEY = "Constants.PROVIDER_KEY";
+ String PROVIDER_CONFIGURED = "Constants.PROVIDER_CONFIGURED";
+}
diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
index 1a4adc1d..f1e7b3bd 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
@@ -1,20 +1,4 @@
-/**
- * Copyright (c) 2013 LEAP Encryption Access Project and contributers
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-/**
+/*
* Copyright (c) 2013 LEAP Encryption Access Project and contributers
*
* This program is free software: you can redistribute it and/or modify
@@ -57,14 +41,12 @@ import java.net.URL;
import butterknife.ButterKnife;
import butterknife.InjectView;
-import de.blinkt.openvpn.core.VpnStatus;
-import se.leap.bitmaskclient.eip.Constants;
import se.leap.bitmaskclient.userstatus.SessionDialog;
import se.leap.bitmaskclient.userstatus.User;
import se.leap.bitmaskclient.userstatus.UserStatusFragment;
-import static se.leap.bitmaskclient.eip.Constants.IS_ALWAYS_ON;
-import static se.leap.bitmaskclient.eip.Constants.RESTART_ON_BOOT;
+import static se.leap.bitmaskclient.Constants.EIP_IS_ALWAYS_ON;
+import static se.leap.bitmaskclient.Constants.EIP_RESTART_ON_BOOT;
/**
* The main user facing Activity of Bitmask Android, consisting of status, controls,
@@ -79,7 +61,6 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec
protected static final int SWITCH_PROVIDER = 1;
public static final String TAG = Dashboard.class.getSimpleName();
- public static final String SHARED_PREFERENCES = "LEAPPreferences";
public static final String ACTION_QUIT = "quit";
/**
@@ -113,18 +94,14 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE);
+ preferences = getSharedPreferences(Constants.SHARED_PREFERENCES, MODE_PRIVATE);
fragment_manager = new FragmentManagerEnhanced(getFragmentManager());
- ProviderAPICommand.initialize(this);
providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler(), this);
if (dashboardContext == null) {
dashboardContext = this;
-
- VpnStatus.initLogCache(getApplicationContext().getCacheDir());
handleVersion();
- User.init(getString(R.string.default_username));
}
prepareEIP(savedInstanceState);
@@ -180,13 +157,11 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec
private void handleVersion() {
try {
int versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
- int lastDetectedVersion = preferences.getInt(APP_VERSION, 0);
- preferences.edit().putInt(APP_VERSION, versionCode).apply();
switch (versionCode) {
case 91: // 0.6.0 without Bug #5999
case 101: // 0.8.0
- if (!preferences.getString(Constants.KEY, "").isEmpty())
+ if (!preferences.getString(Constants.PROVIDER_KEY, "").isEmpty())
eip_fragment.updateEipService();
break;
}
@@ -205,8 +180,8 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec
private void handleIntentExtras(Intent intent) {
if (intent.hasExtra(ACTION_ASK_TO_CANCEL_VPN)) {
handleVpnCancellation(intent);
- } else if (intent.hasExtra(RESTART_ON_BOOT)) {
- Log.d(TAG, "Dashboard: RESTART_ON_BOOT");
+ } else if (intent.hasExtra(EIP_RESTART_ON_BOOT)) {
+ Log.d(TAG, "Dashboard: EIP_RESTART_ON_BOOT");
prepareEIP(null);
} else if (intent.hasExtra(ACTION_CONFIGURE_ALWAYS_ON_PROFILE)) {
Log.d(TAG, "Dashboard: ACTION_CONFIGURE_ALWAYS_ON_PROFILE");
@@ -255,7 +230,7 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec
configureLeapProvider();
} else {
Log.d(TAG, "vpn provider is configured");
- buildDashboard(getIntent().getBooleanExtra(RESTART_ON_BOOT, false));
+ buildDashboard(getIntent().getBooleanExtra(EIP_RESTART_ON_BOOT, false));
user_status_fragment.restoreSessionStatus(savedInstanceState);
}
} else {
@@ -338,7 +313,7 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec
VpnFragment eip_fragment = new VpnFragment();
if (hideAndTurnOnEipOnBoot && !isAlwaysOn()) {
- preferences.edit().remove(Constants.RESTART_ON_BOOT).apply();
+ preferences.edit().remove(EIP_RESTART_ON_BOOT).apply();
Bundle arguments = new Bundle();
arguments.putBoolean(VpnFragment.START_EIP_ON_BOOT, true);
Log.d(TAG, "set START_EIP_ON_BOOT argument for eip_fragment");
@@ -353,7 +328,7 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec
* @return
*/
private boolean isAlwaysOn() {
- return preferences.getBoolean(IS_ALWAYS_ON, false);
+ return preferences.getBoolean(EIP_IS_ALWAYS_ON, false);
}
@@ -405,7 +380,7 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec
public void downloadVpnCertificate() {
boolean is_authenticated = User.loggedIn();
- boolean allowed_anon = preferences.getBoolean(Constants.ALLOWED_ANON, false);
+ boolean allowed_anon = preferences.getBoolean(Constants.PROVIDER_ALLOW_ANONYMOUS, false);
if (allowed_anon || is_authenticated)
ProviderAPICommand.execute(Bundle.EMPTY, ProviderAPI.DOWNLOAD_CERTIFICATE, providerAPI_result_receiver);
else
diff --git a/app/src/main/java/se/leap/bitmaskclient/FeatureVersionCode.java b/app/src/main/java/se/leap/bitmaskclient/FeatureVersionCode.java
new file mode 100644
index 00000000..b2a39c1a
--- /dev/null
+++ b/app/src/main/java/se/leap/bitmaskclient/FeatureVersionCode.java
@@ -0,0 +1,5 @@
+package se.leap.bitmaskclient;
+
+public interface FeatureVersionCode {
+ int MULTIPLE_PROFILES = 132;
+}
diff --git a/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java b/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java
index 49cf3774..3a1fd6e0 100644
--- a/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java
+++ b/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java
@@ -72,7 +72,6 @@ public class LeapSRPSession {
*
* @param username, the user ID
* @param password, the user clear text password
- * @param params, the SRP parameters for the session
*/
public LeapSRPSession(String username, String password) {
this(username, password, null);
@@ -84,7 +83,6 @@ public class LeapSRPSession {
*
* @param username, the user ID
* @param password, the user clear text password
- * @param params, the SRP parameters for the session
* @param abytes, the random exponent used in the A public key
*/
public LeapSRPSession(String username, String password, byte[] abytes) {
@@ -187,7 +185,6 @@ public class LeapSRPSession {
*
* @param b1 the positive source to build first BigInteger
* @param b2 the positive source to build second BigInteger
- * @param length
* @return
*/
public byte[] xor(byte[] b1, byte[] b2) {
diff --git a/app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java b/app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java
index b151f40a..f9aa2660 100644
--- a/app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java
+++ b/app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java
@@ -7,25 +7,25 @@ import android.content.SharedPreferences;
import android.util.Log;
import static android.content.Intent.ACTION_BOOT_COMPLETED;
-import static se.leap.bitmaskclient.eip.Constants.IS_ALWAYS_ON;
-import static se.leap.bitmaskclient.eip.Constants.RESTART_ON_BOOT;
-import static se.leap.bitmaskclient.eip.Constants.VPN_CERTIFICATE;
+import static se.leap.bitmaskclient.Constants.EIP_IS_ALWAYS_ON;
+import static se.leap.bitmaskclient.Constants.EIP_RESTART_ON_BOOT;
+import static se.leap.bitmaskclient.Constants.PROVIDER_VPN_CERTIFICATE;
public class OnBootReceiver extends BroadcastReceiver {
SharedPreferences preferences;
- // Debug: su && am broadcast -a android.intent.action.BOOT_COMPLETED
+ // Debug: am broadcast -a android.intent.action.BOOT_COMPLETED
@Override
public void onReceive(Context context, Intent intent) {
//Lint complains if we're not checking the intent action
if (intent == null || !ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
return;
}
- preferences = context.getSharedPreferences(Dashboard.SHARED_PREFERENCES, Context.MODE_PRIVATE);
- boolean providerConfigured = !preferences.getString(VPN_CERTIFICATE, "").isEmpty();
- boolean startOnBoot = preferences.getBoolean(RESTART_ON_BOOT, false);
- boolean isAlwaysOnConfigured = preferences.getBoolean(IS_ALWAYS_ON, false);
+ preferences = context.getSharedPreferences(Constants.SHARED_PREFERENCES, Context.MODE_PRIVATE);
+ boolean providerConfigured = !preferences.getString(PROVIDER_VPN_CERTIFICATE, "").isEmpty();
+ boolean startOnBoot = preferences.getBoolean(EIP_RESTART_ON_BOOT, false);
+ boolean isAlwaysOnConfigured = preferences.getBoolean(EIP_IS_ALWAYS_ON, false);
Log.d("OpenVPN", "OpenVPN onBoot intent received. Provider configured? " + providerConfigured + " Start on boot? " + startOnBoot + " isAlwaysOn feature configured: " + isAlwaysOnConfigured);
if (providerConfigured) {
if (isAlwaysOnConfigured) {
@@ -34,7 +34,7 @@ public class OnBootReceiver extends BroadcastReceiver {
}
if (startOnBoot) {
Intent dashboard_intent = new Intent(context, Dashboard.class);
- dashboard_intent.putExtra(RESTART_ON_BOOT, true);
+ dashboard_intent.putExtra(EIP_RESTART_ON_BOOT, true);
dashboard_intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(dashboard_intent);
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderApiBase.java b/app/src/main/java/se/leap/bitmaskclient/ProviderApiBase.java
index acac607c..6e3b8b08 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ProviderApiBase.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ProviderApiBase.java
@@ -67,7 +67,6 @@ import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.TlsVersion;
-import se.leap.bitmaskclient.eip.Constants;
import se.leap.bitmaskclient.userstatus.SessionDialog;
import se.leap.bitmaskclient.userstatus.User;
import se.leap.bitmaskclient.userstatus.UserStatus;
@@ -151,7 +150,7 @@ public abstract class ProviderApiBase extends IntentService {
public void onCreate() {
super.onCreate();
- preferences = getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE);
+ preferences = getSharedPreferences(Constants.SHARED_PREFERENCES, MODE_PRIVATE);
resources = getResources();
}
@@ -817,11 +816,11 @@ public abstract class ProviderApiBase extends IntentService {
RSAPrivateKey key = ConfigHelper.parseRsaKeyFromString(keyString);
keyString = Base64.encodeToString(key.getEncoded(), Base64.DEFAULT);
- preferences.edit().putString(Constants.PRIVATE_KEY, "-----BEGIN RSA PRIVATE KEY-----\n" + keyString + "-----END RSA PRIVATE KEY-----").commit();
+ preferences.edit().putString(Constants.PROVIDER_PRIVATE_KEY, "-----BEGIN RSA PRIVATE KEY-----\n" + keyString + "-----END RSA PRIVATE KEY-----").commit();
X509Certificate certificate = ConfigHelper.parseX509CertificateFromString(certificateString);
certificateString = Base64.encodeToString(certificate.getEncoded(), Base64.DEFAULT);
- preferences.edit().putString(Constants.VPN_CERTIFICATE, "-----BEGIN CERTIFICATE-----\n" + certificateString + "-----END CERTIFICATE-----").commit();
+ preferences.edit().putString(Constants.PROVIDER_VPN_CERTIFICATE, "-----BEGIN CERTIFICATE-----\n" + certificateString + "-----END CERTIFICATE-----").commit();
return true;
} catch (CertificateException e) {
// TODO Auto-generated catch block
diff --git a/app/src/main/java/se/leap/bitmaskclient/StartActivity.java b/app/src/main/java/se/leap/bitmaskclient/StartActivity.java
new file mode 100644
index 00000000..dd2be212
--- /dev/null
+++ b/app/src/main/java/se/leap/bitmaskclient/StartActivity.java
@@ -0,0 +1,135 @@
+package se.leap.bitmaskclient;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.pm.PackageManager;
+import android.os.Bundle;
+import android.support.annotation.IntDef;
+import android.support.annotation.Nullable;
+import android.util.Log;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+import de.blinkt.openvpn.core.VpnStatus;
+import se.leap.bitmaskclient.userstatus.User;
+
+/**
+ * Activity shown at startup. Evaluates if App is started for the first time or has been upgraded
+ * and acts and calls another activity accordingly.
+ *
+ */
+public class StartActivity extends Activity {
+ public static final String TAG = Dashboard.class.getSimpleName();
+
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef({FIRST, NORMAL, UPGRADE, DOWNGRADE})
+ private @interface StartupMode {}
+ private static final int FIRST = 0;
+ private static final int NORMAL = 1;
+ private static final int UPGRADE = 2;
+ private static final int DOWNGRADE = 3;
+
+ private int versionCode;
+ private int previousVersionCode;
+
+ private SharedPreferences preferences;
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ preferences = getSharedPreferences(Constants.SHARED_PREFERENCES, MODE_PRIVATE);
+
+ Log.d(TAG, "Started");
+
+ switch (checkAppStart()) {
+ case NORMAL:
+ break;
+
+ case FIRST:
+ // TODO start ProfileCreation & replace below code
+ break;
+
+ case UPGRADE:
+ executeUpgrade();
+ // TODO show donation dialog
+ break;
+
+ case DOWNGRADE:
+ // TODO think how and why this should happen and what todo
+ break;
+ }
+
+ // initialize app necessities
+ ProviderAPICommand.initialize(this);
+ VpnStatus.initLogCache(getApplicationContext().getCacheDir());
+ User.init(getString(R.string.default_username));
+
+ // go to Dashboard
+ Intent intent = new Intent(this, Dashboard.class);
+ startActivity(intent);
+ }
+
+ /**
+ * check if normal start, first run, up or downgrade
+ * @return @StartupMode
+ */
+ @StartupMode
+ private int checkAppStart() {
+ try {
+ versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
+ previousVersionCode = preferences.getInt(Constants.PREFERENCES_APP_VERSION, -1);
+
+ // versions do match -> normal start
+ if (versionCode == previousVersionCode) {
+ Log.d(TAG, "App start was: NORMAL START");
+ return NORMAL;
+ }
+
+ // no previous app version -> first start
+ if (previousVersionCode == -1 ) {
+ Log.d(TAG, "FIRST START");
+ return FIRST;
+ }
+
+ // version has increased -> upgrade
+ if (versionCode > previousVersionCode) {
+ Log.d(TAG, "UPGRADE");
+ return UPGRADE;
+ }
+ // version has decreased -> downgrade
+ if (versionCode < previousVersionCode) {
+ Log.d(TAG, "DOWNGRADE");
+ return DOWNGRADE;
+ }
+
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.d(TAG, "Splash screen didn't find any " + getPackageName() + " package");
+ }
+
+ return NORMAL;
+ }
+
+ /**
+ * execute necessary upgrades for version change
+ */
+ private void executeUpgrade() {
+ if (hasNewFeature(FeatureVersionCode.MULTIPLE_PROFILES)) {
+ // TODO prepare usage of multiple profiles
+ }
+
+ // ensure all upgrades have passed before storing new information
+ preferences.edit().putInt(Constants.PREFERENCES_APP_VERSION, versionCode).apply();
+ }
+
+ /**
+ * check if an upgrade passed or moved to given milestone
+ * @param featureVersionCode Version code of the Milestone FeatureVersionCode.MILE_STONE
+ * @return true if milestone is reached - false otherwise
+ */
+ private boolean hasNewFeature(int featureVersionCode) {
+ return previousVersionCode < featureVersionCode && versionCode >= featureVersionCode;
+ }
+
+}
diff --git a/app/src/main/java/se/leap/bitmaskclient/VpnFragment.java b/app/src/main/java/se/leap/bitmaskclient/VpnFragment.java
index a8a9ac67..f1a15efd 100644
--- a/app/src/main/java/se/leap/bitmaskclient/VpnFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/VpnFragment.java
@@ -46,13 +46,23 @@ import de.blinkt.openvpn.core.OpenVPNService;
import de.blinkt.openvpn.core.ProfileManager;
import de.blinkt.openvpn.core.VpnStatus;
import mbanje.kurt.fabbutton.FabButton;
-import se.leap.bitmaskclient.eip.Constants;
import se.leap.bitmaskclient.eip.EIP;
import se.leap.bitmaskclient.eip.EipStatus;
import se.leap.bitmaskclient.eip.VoidVpnService;
import static de.blinkt.openvpn.core.ConnectionStatus.LEVEL_NONETWORK;
-import static se.leap.bitmaskclient.eip.Constants.ACTION_STOP_BLOCKING_VPN;
+import static se.leap.bitmaskclient.Constants.EIP_ACTION_CHECK_CERT_VALIDITY;
+import static se.leap.bitmaskclient.Constants.EIP_ACTION_START;
+import static se.leap.bitmaskclient.Constants.EIP_ACTION_STOP;
+import static se.leap.bitmaskclient.Constants.EIP_ACTION_STOP_BLOCKING_VPN;
+import static se.leap.bitmaskclient.Constants.EIP_ACTION_UPDATE;
+import static se.leap.bitmaskclient.Constants.EIP_NOTIFICATION;
+import static se.leap.bitmaskclient.Constants.EIP_RECEIVER;
+import static se.leap.bitmaskclient.Constants.EIP_REQUEST;
+import static se.leap.bitmaskclient.Constants.EIP_RESTART_ON_BOOT;
+import static se.leap.bitmaskclient.Constants.PROVIDER_ALLOWED_REGISTERED;
+import static se.leap.bitmaskclient.Constants.PROVIDER_ALLOW_ANONYMOUS;
+import static se.leap.bitmaskclient.Constants.PROVIDER_VPN_CERTIFICATE;
public class VpnFragment extends Fragment implements Observer {
@@ -124,7 +134,7 @@ public class VpnFragment extends Fragment implements Observer {
public void onResume() {
super.onResume();
//FIXME: avoid race conditions while checking certificate an logging in at about the same time
- //eipCommand(Constants.ACTION_CHECK_CERT_VALIDITY);
+ //eipCommand(Constants.EIP_ACTION_CHECK_CERT_VALIDITY);
handleNewState();
bindOpenVpnService();
}
@@ -142,7 +152,7 @@ public class VpnFragment extends Fragment implements Observer {
}
private void saveStatus(boolean restartOnBoot) {
- Dashboard.preferences.edit().putBoolean(Constants.RESTART_ON_BOOT, restartOnBoot).apply();
+ Dashboard.preferences.edit().putBoolean(EIP_RESTART_ON_BOOT, restartOnBoot).apply();
}
@OnClick(R.id.vpn_main_button)
@@ -168,13 +178,13 @@ public class VpnFragment extends Fragment implements Observer {
}
private boolean canStartEIP() {
- boolean certificateExists = !Dashboard.preferences.getString(Constants.VPN_CERTIFICATE, "").isEmpty();
- boolean isAllowedAnon = Dashboard.preferences.getBoolean(Constants.ALLOWED_ANON, false);
+ boolean certificateExists = !Dashboard.preferences.getString(PROVIDER_VPN_CERTIFICATE, "").isEmpty();
+ boolean isAllowedAnon = Dashboard.preferences.getBoolean(PROVIDER_ALLOW_ANONYMOUS, false);
return (isAllowedAnon || certificateExists) && !eip_status.isConnected() && !eip_status.isConnecting();
}
private boolean canLogInToStartEIP() {
- boolean isAllowedRegistered = Dashboard.preferences.getBoolean(Constants.ALLOWED_REGISTERED, false);
+ boolean isAllowedRegistered = Dashboard.preferences.getBoolean(PROVIDER_ALLOWED_REGISTERED, false);
boolean isLoggedIn = !LeapSRPSession.getToken().isEmpty();
return isAllowedRegistered && !isLoggedIn && !eip_status.isConnecting() && !eip_status.isConnected();
}
@@ -210,7 +220,7 @@ public class VpnFragment extends Fragment implements Observer {
public void startEipFromScratch() {
wants_to_connect = false;
saveStatus(true);
- eipCommand(Constants.ACTION_START_EIP);
+ eipCommand(EIP_ACTION_START);
}
private void stop() {
@@ -224,7 +234,7 @@ public class VpnFragment extends Fragment implements Observer {
private void stopBlockingVpn() {
Log.d(TAG, "stop VoidVpn!");
Intent stopVoidVpnIntent = new Intent(dashboard, VoidVpnService.class);
- stopVoidVpnIntent.setAction(ACTION_STOP_BLOCKING_VPN);
+ stopVoidVpnIntent.setAction(EIP_ACTION_STOP_BLOCKING_VPN);
dashboard.startService(stopVoidVpnIntent);
}
@@ -241,7 +251,7 @@ public class VpnFragment extends Fragment implements Observer {
protected void stopEipIfPossible() {
//FIXME: no need to start a service here!
- eipCommand(Constants.ACTION_STOP_EIP);
+ eipCommand(EIP_ACTION_STOP);
}
private void downloadEIPServiceConfig() {
@@ -269,7 +279,7 @@ public class VpnFragment extends Fragment implements Observer {
}
protected void updateEipService() {
- eipCommand(Constants.ACTION_UPDATE_EIP_SERVICE);
+ eipCommand(EIP_ACTION_UPDATE);
}
/**
@@ -282,7 +292,7 @@ public class VpnFragment extends Fragment implements Observer {
// TODO validate "action"...how do we get the list of intent-filters for a class via Android API?
Intent vpn_intent = new Intent(dashboard.getApplicationContext(), EIP.class);
vpn_intent.setAction(action);
- vpn_intent.putExtra(Constants.RECEIVER_TAG, eip_receiver);
+ vpn_intent.putExtra(EIP_RECEIVER, eip_receiver);
dashboard.startService(vpn_intent);
}
@@ -363,9 +373,9 @@ public class VpnFragment extends Fragment implements Observer {
protected void onReceiveResult(int resultCode, Bundle resultData) {
super.onReceiveResult(resultCode, resultData);
- String request = resultData.getString(Constants.REQUEST_TAG);
+ String request = resultData.getString(EIP_REQUEST);
- if (request.equals(Constants.ACTION_START_EIP)) {
+ if (request.equals(EIP_ACTION_START)) {
switch (resultCode) {
case Activity.RESULT_OK:
break;
@@ -373,7 +383,7 @@ public class VpnFragment extends Fragment implements Observer {
break;
}
- } else if (request.equals(Constants.ACTION_STOP_EIP)) {
+ } else if (request.equals(EIP_ACTION_STOP)) {
switch (resultCode) {
case Activity.RESULT_OK:
stop();
@@ -381,14 +391,14 @@ public class VpnFragment extends Fragment implements Observer {
case Activity.RESULT_CANCELED:
break;
}
- } else if (request.equals(Constants.EIP_NOTIFICATION)) {
+ } else if (request.equals(EIP_NOTIFICATION)) {
switch (resultCode) {
case Activity.RESULT_OK:
break;
case Activity.RESULT_CANCELED:
break;
}
- } else if (request.equals(Constants.ACTION_CHECK_CERT_VALIDITY)) {
+ } else if (request.equals(EIP_ACTION_CHECK_CERT_VALIDITY)) {
switch (resultCode) {
case Activity.RESULT_OK:
break;
@@ -396,7 +406,7 @@ public class VpnFragment extends Fragment implements Observer {
dashboard.downloadVpnCertificate();
break;
}
- } else if (request.equals(Constants.ACTION_UPDATE_EIP_SERVICE)) {
+ } else if (request.equals(EIP_ACTION_UPDATE)) {
switch (resultCode) {
case Activity.RESULT_OK:
if (wants_to_connect)
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/Constants.java b/app/src/main/java/se/leap/bitmaskclient/eip/Constants.java
deleted file mode 100644
index 449c111d..00000000
--- a/app/src/main/java/se/leap/bitmaskclient/eip/Constants.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Copyright (c) 2013 LEAP Encryption Access Project and contributers
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package se.leap.bitmaskclient.eip;
-
-/**
- * Constants for intent passing, shared preferences
- *
- * @author Parménides GV <parmegv@sdf.org>
- */
-public interface Constants {
-
- public final static String TAG = Constants.class.getSimpleName();
-
- public final static String ACTION_CHECK_CERT_VALIDITY = TAG + ".CHECK_CERT_VALIDITY";
- public final static String ACTION_START_EIP = TAG + ".START_EIP";
- public final static String ACTION_START_ALWAYS_ON_EIP = TAG + ".START_ALWAYS_ON_EIP";
- public final static String ACTION_STOP_EIP = TAG + ".STOP_EIP";
- 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 ACTION_START_BLOCKING_VPN = TAG + ".ACTION_START_BLOCKING_VPN";
- public final static String ACTION_STOP_BLOCKING_VPN = TAG + ".ACTION_STOP_BLOCKING_VPN";
- public final static String EIP_NOTIFICATION = TAG + ".EIP_NOTIFICATION";
- public final static String ALLOWED_ANON = "allow_anonymous";
- public final static String ALLOWED_REGISTERED = "allow_registration";
- public final static String VPN_CERTIFICATE = "cert";
- public final static String PRIVATE_KEY = TAG + ".PRIVATE_KEY";
- public final static String KEY = TAG + ".KEY";
- public final static String RECEIVER_TAG = TAG + ".RECEIVER_TAG";
- public final static String REQUEST_TAG = TAG + ".REQUEST_TAG";
- public final static String PROVIDER_CONFIGURED = TAG + ".PROVIDER_CONFIGURED";
- public final static String IS_ALWAYS_ON = TAG + ".IS_ALWAYS_ON";
- public final static String RESTART_ON_BOOT = TAG + ".RESTART_ON_BOOT";
-
-}
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 39dd133f..a84ab941 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java
@@ -26,7 +26,17 @@ import org.json.*;
import de.blinkt.openvpn.*;
import se.leap.bitmaskclient.*;
-import static se.leap.bitmaskclient.eip.Constants.*;
+import static se.leap.bitmaskclient.Constants.EIP_ACTION_CHECK_CERT_VALIDITY;
+import static se.leap.bitmaskclient.Constants.EIP_ACTION_IS_RUNNING;
+import static se.leap.bitmaskclient.Constants.EIP_ACTION_START;
+import static se.leap.bitmaskclient.Constants.EIP_ACTION_START_ALWAYS_ON_EIP;
+import static se.leap.bitmaskclient.Constants.EIP_ACTION_STOP;
+import static se.leap.bitmaskclient.Constants.EIP_ACTION_UPDATE;
+import static se.leap.bitmaskclient.Constants.EIP_RECEIVER;
+import static se.leap.bitmaskclient.Constants.EIP_REQUEST;
+import static se.leap.bitmaskclient.Constants.PROVIDER_KEY;
+import static se.leap.bitmaskclient.Constants.PROVIDER_VPN_CERTIFICATE;
+import static se.leap.bitmaskclient.Constants.SHARED_PREFERENCES;
/**
* EIP is the abstract base class for interacting with and managing the Encrypted
@@ -59,7 +69,7 @@ public final class EIP extends IntentService {
public void onCreate() {
super.onCreate();
context = getApplicationContext();
- preferences = getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE);
+ preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE);
eip_definition = eipDefinitionFromPreferences();
if (gateways_manager.isEmpty())
gatewaysFromPreferences();
@@ -68,19 +78,19 @@ public final class EIP extends IntentService {
@Override
protected void onHandleIntent(Intent intent) {
String action = intent.getAction();
- mReceiver = intent.getParcelableExtra(RECEIVER_TAG);
+ mReceiver = intent.getParcelableExtra(EIP_RECEIVER);
- if (action.equals(ACTION_START_EIP))
+ if (action.equals(EIP_ACTION_START))
startEIP();
- else if (action.equals(ACTION_START_ALWAYS_ON_EIP))
+ else if (action.equals(EIP_ACTION_START_ALWAYS_ON_EIP))
startAlwaysOnEIP();
- else if (action.equals(ACTION_STOP_EIP))
+ else if (action.equals(EIP_ACTION_STOP))
stopEIP();
- else if (action.equals(ACTION_IS_EIP_RUNNING))
+ else if (action.equals(EIP_ACTION_IS_RUNNING))
isRunning();
- else if (action.equals(ACTION_UPDATE_EIP_SERVICE))
+ else if (action.equals(EIP_ACTION_UPDATE))
updateEIPService();
- else if (action.equals(ACTION_CHECK_CERT_VALIDITY))
+ else if (action.equals(EIP_ACTION_CHECK_CERT_VALIDITY))
checkCertValidity();
}
@@ -90,7 +100,6 @@ 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();
if (!EipStatus.getInstance().isBlockingVpnEstablished()) {
@@ -101,9 +110,9 @@ public final class EIP extends IntentService {
if (gateway != null && gateway.getProfile() != null) {
mReceiver = VpnFragment.getReceiver();
launchActiveGateway();
- tellToReceiver(ACTION_START_EIP, Activity.RESULT_OK);
+ tellToReceiver(EIP_ACTION_START, Activity.RESULT_OK);
} else
- tellToReceiver(ACTION_START_EIP, Activity.RESULT_CANCELED);
+ tellToReceiver(EIP_ACTION_START, Activity.RESULT_CANCELED);
}
/**
@@ -152,7 +161,7 @@ public final class EIP extends IntentService {
if (eip_status.isConnected() || eip_status.isConnecting())
result_code = Activity.RESULT_OK;
- tellToReceiver(ACTION_STOP_EIP, result_code);
+ tellToReceiver(EIP_ACTION_STOP, result_code);
}
/**
@@ -165,7 +174,7 @@ public final class EIP extends IntentService {
int resultCode = (eip_status.isConnected()) ?
Activity.RESULT_OK :
Activity.RESULT_CANCELED;
- tellToReceiver(ACTION_IS_EIP_RUNNING, resultCode);
+ tellToReceiver(EIP_ACTION_IS_RUNNING, resultCode);
}
/**
@@ -176,13 +185,13 @@ public final class EIP extends IntentService {
eip_definition = eipDefinitionFromPreferences();
if (eip_definition.length() > 0)
updateGateways();
- tellToReceiver(ACTION_UPDATE_EIP_SERVICE, Activity.RESULT_OK);
+ tellToReceiver(EIP_ACTION_UPDATE, Activity.RESULT_OK);
}
private JSONObject eipDefinitionFromPreferences() {
JSONObject result = new JSONObject();
try {
- String eip_definition_string = preferences.getString(KEY, "");
+ String eip_definition_string = preferences.getString(PROVIDER_KEY, "");
if (!eip_definition_string.isEmpty()) {
result = new JSONObject(eip_definition_string);
}
@@ -212,17 +221,17 @@ public final class EIP extends IntentService {
}
private void checkCertValidity() {
- VpnCertificateValidator validator = new VpnCertificateValidator(preferences.getString(VPN_CERTIFICATE, ""));
+ VpnCertificateValidator validator = new VpnCertificateValidator(preferences.getString(PROVIDER_VPN_CERTIFICATE, ""));
int resultCode = validator.isValid() ?
Activity.RESULT_OK :
Activity.RESULT_CANCELED;
- tellToReceiver(ACTION_CHECK_CERT_VALIDITY, resultCode);
+ tellToReceiver(EIP_ACTION_CHECK_CERT_VALIDITY, resultCode);
}
private void tellToReceiver(String action, int resultCode) {
if (mReceiver != null) {
Bundle resultData = new Bundle();
- resultData.putString(REQUEST_TAG, action);
+ resultData.putString(EIP_REQUEST, action);
mReceiver.send(resultCode, resultData);
}
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java b/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java
index 177f553e..43c16d00 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java
@@ -36,6 +36,7 @@ import java.util.List;
import de.blinkt.openvpn.VpnProfile;
import de.blinkt.openvpn.core.Connection;
import de.blinkt.openvpn.core.ProfileManager;
+import se.leap.bitmaskclient.Constants;
import se.leap.bitmaskclient.Provider;
/**
@@ -123,8 +124,8 @@ public class GatewaysManager {
JSONObject result = new JSONObject();
try {
result.put(Provider.CA_CERT, preferences.getString(Provider.CA_CERT, ""));
- result.put(Constants.PRIVATE_KEY, preferences.getString(Constants.PRIVATE_KEY, ""));
- result.put(Constants.VPN_CERTIFICATE, preferences.getString(Constants.VPN_CERTIFICATE, ""));
+ result.put(Constants.PROVIDER_PRIVATE_KEY, preferences.getString(Constants.PROVIDER_PRIVATE_KEY, ""));
+ result.put(Constants.PROVIDER_VPN_CERTIFICATE, preferences.getString(Constants.PROVIDER_VPN_CERTIFICATE, ""));
} catch (JSONException e) {
e.printStackTrace();
}
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 27e2d95e..9a3c8f85 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnLauncher.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnLauncher.java
@@ -1,9 +1,12 @@
package se.leap.bitmaskclient.eip;
-import android.app.*;
-import android.content.*;
-import android.net.*;
-import android.os.*;
+import android.app.Activity;
+import android.content.Intent;
+import android.net.VpnService;
+import android.os.Build;
+import android.os.Bundle;
+
+import static se.leap.bitmaskclient.Constants.EIP_ACTION_START_BLOCKING_VPN;
public class VoidVpnLauncher extends Activity {
@@ -28,7 +31,7 @@ public class VoidVpnLauncher extends Activity {
if (requestCode == VPN_USER_PERMISSION) {
if (resultCode == RESULT_OK) {
Intent void_vpn_service = new Intent(getApplicationContext(), VoidVpnService.class);
- void_vpn_service.setAction(Constants.ACTION_START_BLOCKING_VPN);
+ void_vpn_service.setAction(EIP_ACTION_START_BLOCKING_VPN);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(void_vpn_service);
} else {
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 e5e50f6e..792de2cb 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java
@@ -26,9 +26,11 @@ import se.leap.bitmaskclient.Dashboard;
import se.leap.bitmaskclient.R;
import static android.os.Build.VERSION_CODES.O;
-import static se.leap.bitmaskclient.Dashboard.SHARED_PREFERENCES;
-import static se.leap.bitmaskclient.eip.Constants.ACTION_START_ALWAYS_ON_EIP;
-import static se.leap.bitmaskclient.eip.Constants.ACTION_STOP_BLOCKING_VPN;
+import static se.leap.bitmaskclient.Constants.EIP_ACTION_START_ALWAYS_ON_EIP;
+import static se.leap.bitmaskclient.Constants.EIP_ACTION_START_BLOCKING_VPN;
+import static se.leap.bitmaskclient.Constants.EIP_ACTION_STOP_BLOCKING_VPN;
+import static se.leap.bitmaskclient.Constants.EIP_IS_ALWAYS_ON;
+import static se.leap.bitmaskclient.Constants.SHARED_PREFERENCES;
public class VoidVpnService extends VpnService implements Observer {
@@ -55,12 +57,12 @@ public class VoidVpnService extends VpnService implements Observer {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
String action = intent != null ? intent.getAction() : "";
- if (action.equals(Constants.ACTION_START_BLOCKING_VPN)) {
+ if (action.equals(EIP_ACTION_START_BLOCKING_VPN)) {
thread = new Thread(new Runnable() {
public void run() {
establishBlockingVpn();
SharedPreferences preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE);
- preferences.edit().putBoolean(Constants.IS_ALWAYS_ON, false).commit();
+ preferences.edit().putBoolean(EIP_IS_ALWAYS_ON, false).commit();
Log.d(TAG, "start blocking vpn profile - always on = false");
}
});
@@ -71,13 +73,13 @@ public class VoidVpnService extends VpnService implements Observer {
public void run() {
establishBlockingVpn();
SharedPreferences preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE);
- preferences.edit().putBoolean(Constants.IS_ALWAYS_ON, true).commit();
+ preferences.edit().putBoolean(EIP_IS_ALWAYS_ON, true).commit();
requestVpnWithLastSelectedProfile();
Log.d(TAG, "start blocking vpn profile - always on = true");
}
});
thread.run();
- } else if (action.equals(ACTION_STOP_BLOCKING_VPN)) {
+ } else if (action.equals(EIP_ACTION_STOP_BLOCKING_VPN)) {
stop();
}
return START_STICKY;
@@ -157,7 +159,7 @@ public class VoidVpnService extends VpnService implements Observer {
private void requestVpnWithLastSelectedProfile() {
Intent startEIP = new Intent(getApplicationContext(), EIP.class);
- startEIP.setAction(ACTION_START_ALWAYS_ON_EIP);
+ startEIP.setAction(EIP_ACTION_START_ALWAYS_ON_EIP);
getApplicationContext().startService(startEIP);
}
@@ -231,7 +233,7 @@ public class VoidVpnService extends VpnService implements Observer {
private PendingIntent getStopVoidVpnIntent() {
Intent stopVoidVpnIntent = new Intent (this, VoidVpnService.class);
- stopVoidVpnIntent.setAction(Constants.ACTION_STOP_BLOCKING_VPN);
+ stopVoidVpnIntent.setAction(EIP_ACTION_STOP_BLOCKING_VPN);
return PendingIntent.getService(this, 0, stopVoidVpnIntent, PendingIntent.FLAG_CANCEL_CURRENT);
}
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 f428099e..54563ec4 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java
@@ -118,14 +118,14 @@ public class VpnConfigGenerator {
String key =
"<key>"
+ new_line
- + secrets.getString(Constants.PRIVATE_KEY)
+ + secrets.getString(Constants.PROVIDER_PRIVATE_KEY)
+ new_line
+ "</key>";
String openvpn_cert =
"<cert>"
+ new_line
- + secrets.getString(Constants.VPN_CERTIFICATE)
+ + secrets.getString(Constants.PROVIDER_VPN_CERTIFICATE)
+ new_line
+ "</cert>";
diff --git a/app/src/main/res/drawable-hdpi/ic_splash_background.png b/app/src/main/res/drawable-hdpi/ic_splash_background.png
new file mode 100644
index 00000000..3e5f7871
--- /dev/null
+++ b/app/src/main/res/drawable-hdpi/ic_splash_background.png
Binary files differ
diff --git a/app/src/main/res/drawable-ldpi/mask.png b/app/src/main/res/drawable-ldpi/mask.png
new file mode 100644
index 00000000..4e22d99f
--- /dev/null
+++ b/app/src/main/res/drawable-ldpi/mask.png
Binary files differ
diff --git a/app/src/main/res/drawable-mdpi/mask.png b/app/src/main/res/drawable-mdpi/mask.png
new file mode 100644
index 00000000..e53cb15c
--- /dev/null
+++ b/app/src/main/res/drawable-mdpi/mask.png
Binary files differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_splash_background.png b/app/src/main/res/drawable-xhdpi/ic_splash_background.png
new file mode 100644
index 00000000..c2135c04
--- /dev/null
+++ b/app/src/main/res/drawable-xhdpi/ic_splash_background.png
Binary files differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_splash_background.png b/app/src/main/res/drawable-xxxhdpi/ic_splash_background.png
new file mode 100644
index 00000000..1b8046fa
--- /dev/null
+++ b/app/src/main/res/drawable-xxxhdpi/ic_splash_background.png
Binary files differ
diff --git a/app/src/main/res/drawable-xxxhdpi/mask.png b/app/src/main/res/drawable-xxxhdpi/mask.png
new file mode 100644
index 00000000..4297d90c
--- /dev/null
+++ b/app/src/main/res/drawable-xxxhdpi/mask.png
Binary files differ
diff --git a/app/src/main/res/drawable/ic_colorsquare.xml b/app/src/main/res/drawable/ic_colorsquare.xml
new file mode 100644
index 00000000..4b60e9dc
--- /dev/null
+++ b/app/src/main/res/drawable/ic_colorsquare.xml
@@ -0,0 +1,52 @@
+<vector android:height="24dp" android:viewportHeight="100.0"
+ android:viewportWidth="100.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:pathData="M50,50m-82000,0a82000,82000 0,1 1,164000 0a82000,82000 0,1 1,-164000 0"/>
+ <path android:fillAlpha="1" android:fillColor="#e6ee9c"
+ android:pathData="M50,50 L30664.67,-73860.37A80000,80000 0,0 0,50 -79950Z"
+ android:strokeColor="#e6ee9c" android:strokeWidth="0"/>
+ <path android:fillAlpha="1" android:fillColor="#fff59d"
+ android:pathData="m50,50 l56568.54,-56568.54a80000,80000 0,0 0,-25953.87 -17341.82z"
+ android:strokeColor="#fff59d" android:strokeWidth="0"/>
+ <path android:fillAlpha="1" android:fillColor="#ffe082"
+ android:pathData="m50,50 l73910.37,-30614.67a80000,80000 0,0 0,-17341.82 -25953.87z"
+ android:strokeColor="#ffe082" android:strokeWidth="0"/>
+ <path android:fillAlpha="1" android:fillColor="#ffcc80"
+ android:pathData="M50,50L80050,50A80000,80000 0,0 0,73960.37 -30564.67Z"
+ android:strokeColor="#ffcc80" android:strokeWidth="0"/>
+ <path android:fillAlpha="1" android:fillColor="#ffab91"
+ android:pathData="M50,50 L73960.37,30664.67A80000,80000 0,0 0,80050 50Z"
+ android:strokeColor="#ffab91" android:strokeWidth="0"/>
+ <path android:fillAlpha="1" android:fillColor="#ef9a9a"
+ android:pathData="m50,50 l56568.54,56568.54a80000,80000 0,0 0,17341.82 -25953.87z"
+ android:strokeColor="#ef9a9a" android:strokeWidth="0"/>
+ <path android:fillAlpha="1" android:fillColor="#f48fb1"
+ android:pathData="m50,50 l30614.67,73910.37a80000,80000 0,0 0,25953.87 -17341.82z"
+ android:strokeColor="#f48fb1" android:strokeWidth="0"/>
+ <path android:fillAlpha="1" android:fillColor="#ce93d8"
+ android:pathData="M50,50L50,80050A80000,80000 0,0 0,30664.67 73960.37Z"
+ android:strokeColor="#ce93d8" android:strokeWidth="0"/>
+ <path android:fillAlpha="1" android:fillColor="#b39ddb"
+ android:pathData="M50,50 L-30564.67,73960.37A80000,80000 0,0 0,50 80050Z"
+ android:strokeColor="#b39ddb" android:strokeWidth="0"/>
+ <path android:fillAlpha="1" android:fillColor="#9fa8da"
+ android:pathData="m50,50 l-56568.54,56568.54a80000,80000 0,0 0,25953.87 17341.82z"
+ android:strokeColor="#9fa8da" android:strokeWidth="0"/>
+ <path android:fillAlpha="1" android:fillColor="#90caf9"
+ android:pathData="m50,50 l-73910.37,30614.67a80000,80000 0,0 0,17341.82 25953.87z"
+ android:strokeColor="#90caf9" android:strokeWidth="0"/>
+ <path android:fillAlpha="1" android:fillColor="#81d4fa"
+ android:pathData="m50,50l-80000,0a80000,80000 0,0 0,6089.64 30614.67z"
+ android:strokeColor="#81d4fa" android:strokeWidth="0"/>
+ <path android:fillAlpha="1" android:fillColor="#80deea"
+ android:pathData="M50,50 L-73860.37,-30564.67A80000,80000 0,0 0,-79950 50Z"
+ android:strokeColor="#80deea" android:strokeWidth="0"/>
+ <path android:fillAlpha="1" android:fillColor="#80cbc4"
+ android:pathData="m50,50 l-56568.54,-56568.54a80000,80000 0,0 0,-17341.82 25953.87z"
+ android:strokeColor="#80cbc4" android:strokeWidth="0"/>
+ <path android:fillAlpha="1" android:fillColor="#a5d6a7"
+ android:pathData="m50,50 l-30614.67,-73910.37a80000,80000 0,0 0,-25953.87 17341.82z"
+ android:strokeColor="#a5d6a7" android:strokeWidth="0"/>
+ <path android:fillAlpha="1" android:fillColor="#c5e1a5"
+ android:pathData="m50,50l0,-80000a80000,80000 0,0 0,-30614.67 6089.64z"
+ android:strokeColor="#c5e1a5" android:strokeWidth="0"/>
+</vector>
diff --git a/app/src/main/res/drawable/splash_page.xml b/app/src/main/res/drawable/splash_page.xml
new file mode 100644
index 00000000..44112f06
--- /dev/null
+++ b/app/src/main/res/drawable/splash_page.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+ <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item android:drawable="@drawable/ic_splash_background"
+ android:gravity="fill_horizontal|fill_vertical"/>
+
+ <item>
+ <bitmap
+ android:src="@drawable/mask"
+ android:gravity="center" />
+ </item>
+
+</layer-list> \ No newline at end of file
diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml
deleted file mode 100644
index cb503b86..00000000
--- a/app/src/main/res/values/attrs.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<resources>
- <declare-styleable name="FileSelectLayout">
- <attr name="title" format="string|reference" />
-<!-- <attr name="taskid" format="integer" /> -->
- </declare-styleable>
-</resources> \ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
new file mode 100644
index 00000000..1818312e
--- /dev/null
+++ b/app/src/main/res/values/colors.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <color name="colorPrimary">#b39ddb</color>
+ <color name="colorPrimaryDark">#ac97d2</color>
+
+ <color name="red200">#ef9a9a</color>
+ <color name="pink200">#f48fb1</color>
+ <color name="purple200">#ce93d8</color>
+ <color name="deepPurple200">#b39ddb</color>
+ <color name="indigo200">#9fa8da</color>
+ <color name="blue200">#90caf9</color>
+ <color name="lightBlue200">#81d4fa</color>
+ <color name="cyan200">#80deea</color>
+ <color name="teal200">#80cbc4</color>
+ <color name="green200">#a5d6a7</color>
+ <color name="lightGreen200">#c5e1a5</color>
+ <color name="lime200">#e6ee9c</color>
+ <color name="yellow200">#fff59d</color>
+ <color name="amber200">#ffe082</color>
+ <color name="orange200">#ffcc80</color>
+ <color name="deepOrange200">#ffab91</color>
+
+</resources>
diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml
new file mode 100644
index 00000000..80607409
--- /dev/null
+++ b/app/src/main/res/values/themes.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
+ <item name="colorPrimary">@color/colorPrimary</item>
+ <item name="colorPrimaryDark">@color/colorPrimary</item>
+ </style>
+ <style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
+ <item name="colorPrimary">@color/colorPrimary</item>
+ <item name="colorPrimaryDark">@color/colorPrimary</item>
+ <item name="android:windowBackground">@drawable/splash_page</item>
+ </style>
+</resources>
diff --git a/app/src/production/java/se/leap/bitmaskclient/ProviderAPI.java b/app/src/production/java/se/leap/bitmaskclient/ProviderAPI.java
index 70a2c27c..fadb03c3 100644
--- a/app/src/production/java/se/leap/bitmaskclient/ProviderAPI.java
+++ b/app/src/production/java/se/leap/bitmaskclient/ProviderAPI.java
@@ -33,7 +33,6 @@ import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLHandshakeException;
import okhttp3.OkHttpClient;
-import se.leap.bitmaskclient.eip.Constants;
import se.leap.bitmaskclient.eip.EIP;
import static se.leap.bitmaskclient.R.string.error_io_exception_user_message;
@@ -120,8 +119,8 @@ public class ProviderAPI extends ProviderApiBase {
//TODO setProviderName(name);
preferences.edit().putString(Provider.KEY, provider_json.toString()).commit();
- preferences.edit().putBoolean(Constants.ALLOWED_ANON, provider_json.getJSONObject(Provider.SERVICE).getBoolean(Constants.ALLOWED_ANON)).commit();
- preferences.edit().putBoolean(Constants.ALLOWED_REGISTERED, provider_json.getJSONObject(Provider.SERVICE).getBoolean(Constants.ALLOWED_REGISTERED)).commit();
+ preferences.edit().putBoolean(Constants.PROVIDER_ALLOW_ANONYMOUS, provider_json.getJSONObject(Provider.SERVICE).getBoolean(Constants.PROVIDER_ALLOW_ANONYMOUS)).commit();
+ preferences.edit().putBoolean(Constants.PROVIDER_ALLOWED_REGISTERED, provider_json.getJSONObject(Provider.SERVICE).getBoolean(Constants.PROVIDER_ALLOWED_REGISTERED)).commit();
result.putBoolean(RESULT_KEY, true);
} catch (JSONException e) {
@@ -150,7 +149,7 @@ public class ProviderAPI extends ProviderApiBase {
JSONObject eip_service_json = new JSONObject(eip_service_json_string);
eip_service_json.getInt(Provider.API_RETURN_SERIAL);
- preferences.edit().putString(Constants.KEY, eip_service_json.toString()).commit();
+ preferences.edit().putString(Constants.PROVIDER_KEY, eip_service_json.toString()).commit();
result.putBoolean(RESULT_KEY, true);
} catch (NullPointerException | JSONException e) {
@@ -173,7 +172,7 @@ public class ProviderAPI extends ProviderApiBase {
JSONObject provider_json = new JSONObject(preferences.getString(Provider.KEY, ""));
String provider_main_url = provider_json.getString(Provider.API_URL);
- URL new_cert_string_url = new URL(provider_main_url + "/" + provider_json.getString(Provider.API_VERSION) + "/" + Constants.VPN_CERTIFICATE);
+ URL new_cert_string_url = new URL(provider_main_url + "/" + provider_json.getString(Provider.API_VERSION) + "/" + Constants.PROVIDER_VPN_CERTIFICATE);
String cert_string = downloadWithProviderCA(new_cert_string_url.toString());
diff --git a/app/src/production/java/se/leap/bitmaskclient/ProviderDetailFragment.java b/app/src/production/java/se/leap/bitmaskclient/ProviderDetailFragment.java
index da7f8763..c7224ede 100644
--- a/app/src/production/java/se/leap/bitmaskclient/ProviderDetailFragment.java
+++ b/app/src/production/java/se/leap/bitmaskclient/ProviderDetailFragment.java
@@ -2,8 +2,6 @@ package se.leap.bitmaskclient;
import org.json.*;
-import se.leap.bitmaskclient.eip.*;
-
import android.app.*;
import android.content.*;
import android.os.*;
@@ -22,7 +20,7 @@ public class ProviderDetailFragment extends DialogFragment {
LayoutInflater inflater = getActivity().getLayoutInflater();
View provider_detail_view = inflater.inflate(R.layout.provider_detail_fragment, null);
- JSONObject provider_json = new JSONObject(getActivity().getSharedPreferences(Dashboard.SHARED_PREFERENCES, getActivity().MODE_PRIVATE).getString(Provider.KEY, ""));
+ JSONObject provider_json = new JSONObject(getActivity().getSharedPreferences(Constants.SHARED_PREFERENCES, getActivity().MODE_PRIVATE).getString(Provider.KEY, ""));
final TextView domain = (TextView) provider_detail_view.findViewById(R.id.provider_detail_domain);
domain.setText(provider_json.getString(Provider.DOMAIN));
@@ -59,7 +57,7 @@ public class ProviderDetailFragment extends DialogFragment {
private boolean anon_allowed(JSONObject provider_json) {
try {
JSONObject service_description = provider_json.getJSONObject(Provider.SERVICE);
- return service_description.has(Constants.ALLOWED_ANON) && service_description.getBoolean(Constants.ALLOWED_ANON);
+ return service_description.has(Constants.PROVIDER_ALLOW_ANONYMOUS) && service_description.getBoolean(Constants.PROVIDER_ALLOW_ANONYMOUS);
} catch (JSONException e) {
return false;
}
@@ -77,8 +75,8 @@ public class ProviderDetailFragment extends DialogFragment {
@Override
public void onCancel(DialogInterface dialog) {
super.onCancel(dialog);
- SharedPreferences.Editor editor = getActivity().getSharedPreferences(Dashboard.SHARED_PREFERENCES, Activity.MODE_PRIVATE).edit();
- editor.remove(Provider.KEY).remove(Constants.ALLOWED_ANON).remove(Constants.KEY).commit();
+ SharedPreferences.Editor editor = getActivity().getSharedPreferences(Constants.SHARED_PREFERENCES, Activity.MODE_PRIVATE).edit();
+ editor.remove(Provider.KEY).remove(Constants.PROVIDER_ALLOW_ANONYMOUS).remove(Constants.PROVIDER_KEY).commit();
interface_with_configuration_wizard.cancelAndShowAllProviders();
}
diff --git a/app/src/test/java/se/leap/bitmaskclient/eip/GatewaysManagerTest.java b/app/src/test/java/se/leap/bitmaskclient/eip/GatewaysManagerTest.java
index 833346fa..ea212480 100644
--- a/app/src/test/java/se/leap/bitmaskclient/eip/GatewaysManagerTest.java
+++ b/app/src/test/java/se/leap/bitmaskclient/eip/GatewaysManagerTest.java
@@ -14,6 +14,7 @@ import org.mockito.junit.MockitoJUnitRunner;
import java.io.IOException;
+import se.leap.bitmaskclient.Constants;
import se.leap.bitmaskclient.Provider;
import se.leap.bitmaskclient.TestUtils;
@@ -42,9 +43,9 @@ public class GatewaysManagerTest {
JSONObject secrets = new JSONObject(getJsonStringFor("secrets.json"));
- when(sharedPreferences.getString(eq(Constants.PRIVATE_KEY), anyString())).thenReturn(secrets.getString(Constants.PRIVATE_KEY));
+ when(sharedPreferences.getString(eq(Constants.PROVIDER_PRIVATE_KEY), anyString())).thenReturn(secrets.getString(Constants.PROVIDER_PRIVATE_KEY));
when(sharedPreferences.getString(eq(Provider.CA_CERT), anyString())).thenReturn(secrets.getString(Provider.CA_CERT));
- when(sharedPreferences.getString(eq(Constants.VPN_CERTIFICATE), anyString())).thenReturn(secrets.getString(Constants.VPN_CERTIFICATE));
+ when(sharedPreferences.getString(eq(Constants.PROVIDER_VPN_CERTIFICATE), anyString())).thenReturn(secrets.getString(Constants.PROVIDER_VPN_CERTIFICATE));
when(mockContext.getSharedPreferences(anyString(), anyInt())).thenReturn(sharedPreferences);