From deb2cfdeb174822e5550924ac1000f30d948c1cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Mon, 22 Dec 2014 11:45:56 +0100 Subject: New SessionDialog if any argument previously --- app/src/main/java/se/leap/bitmaskclient/SessionDialog.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'app/src/main/java/se') diff --git a/app/src/main/java/se/leap/bitmaskclient/SessionDialog.java b/app/src/main/java/se/leap/bitmaskclient/SessionDialog.java index 22e0f128..a8226d30 100644 --- a/app/src/main/java/se/leap/bitmaskclient/SessionDialog.java +++ b/app/src/main/java/se/leap/bitmaskclient/SessionDialog.java @@ -129,15 +129,15 @@ public class SessionDialog extends DialogFragment{ SessionDialogInterface interface_with_Dashboard; - /** - * @return a new instance of this DialogFragment. - */ - public static DialogFragment newInstance() { - if(dialog == null) - dialog = new SessionDialog(); + /** + * @return a new instance of this DialogFragment. + */ + public static DialogFragment newInstance() { + if(dialog == null || dialog.getArguments() != null) + dialog = new SessionDialog(); return dialog; - } + } @Override public void onAttach(Activity activity) { -- cgit v1.2.3 From 58f4ae104c189cdf258bfb05e3795fbca8dac2cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Mon, 22 Dec 2014 12:10:01 +0100 Subject: Revert deb2cfd & avoid arguments if previous fragment != null --- app/src/main/java/se/leap/bitmaskclient/Dashboard.java | 4 ++-- app/src/main/java/se/leap/bitmaskclient/SessionDialog.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'app/src/main/java/se') diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java index e32dbdee..52b22695 100644 --- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java +++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java @@ -329,7 +329,7 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn FragmentTransaction transaction = fragment_manager.removePreviousFragment(SessionDialog.TAG); DialogFragment newFragment = SessionDialog.newInstance(); - if(resultData != null && !resultData.isEmpty()) + if(resultData != null && !resultData.isEmpty() && fragment_manager.findFragmentByTag(SessionDialog.TAG) == null) newFragment.setArguments(resultData); newFragment.show(transaction, SessionDialog.TAG); } @@ -378,7 +378,7 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn FragmentTransaction transaction = fragment_manager.removePreviousFragment(SessionDialog.TAG); DialogFragment newFragment = SessionDialog.newInstance(); - if(resultData != null && !resultData.isEmpty()) { + if(resultData != null && !resultData.isEmpty() && fragment_manager.findFragmentByTag(SessionDialog.TAG) == null) { newFragment.setArguments(resultData); } newFragment.show(transaction, SessionDialog.TAG); diff --git a/app/src/main/java/se/leap/bitmaskclient/SessionDialog.java b/app/src/main/java/se/leap/bitmaskclient/SessionDialog.java index a8226d30..fd9ca851 100644 --- a/app/src/main/java/se/leap/bitmaskclient/SessionDialog.java +++ b/app/src/main/java/se/leap/bitmaskclient/SessionDialog.java @@ -133,8 +133,8 @@ public class SessionDialog extends DialogFragment{ * @return a new instance of this DialogFragment. */ public static DialogFragment newInstance() { - if(dialog == null || dialog.getArguments() != null) - dialog = new SessionDialog(); + if(dialog == null) + dialog = new SessionDialog(); return dialog; } -- cgit v1.2.3 From a3e93c14fbd82d7f4229f30bbcb622e5ddb71983 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Thu, 18 Dec 2014 16:40:07 +0100 Subject: Log out before starting Configuration Wizard. --- .../main/java/se/leap/bitmaskclient/Dashboard.java | 28 +++++++++++++--------- .../java/se/leap/bitmaskclient/EipFragment.java | 1 + 2 files changed, 18 insertions(+), 11 deletions(-) (limited to 'app/src/main/java/se') diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java index 52b22695..cf65c9b8 100644 --- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java +++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java @@ -81,6 +81,7 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn private Provider provider; private static boolean authed_eip; public ProviderAPIResultReceiver providerAPI_result_receiver; + private boolean switching_provider; @Override protected void onSaveInstanceState(@NotNull Bundle outState) { @@ -288,15 +289,11 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn startActivity(startLW); return true; case R.id.switch_provider: - if (provider.hasEIP()){ - if (preferences.getBoolean(Constants.AUTHED_EIP, false)) { - logOut(); - } - eip_fragment.askToStopEIP(); - } - preferences.edit().clear().apply(); - startActivityForResult(new Intent(this,ConfigurationWizard.class), SWITCH_PROVIDER); - return true; + switching_provider = true; + if (preferences.getBoolean(Constants.AUTHED_EIP, false)) { + logOut(); + } else switchProvider(); + return true; case R.id.login_button: logInDialog(Bundle.EMPTY); return true; @@ -307,7 +304,7 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn signUpDialog(Bundle.EMPTY); return true; default: - return super.onOptionsItemSelected(item); + return super.onOptionsItemSelected(item); } } @@ -402,6 +399,13 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn startService(provider_API_command); } + private void switchProvider() { + if (provider.hasEIP()) eip_fragment.askToStopEIP(); + preferences.edit().clear().apply(); + switching_provider = false; + startActivityForResult(new Intent(this,ConfigurationWizard.class), SWITCH_PROVIDER); + } + /** * Asks ProviderAPI to download an authenticated OpenVPN certificate. */ @@ -456,7 +460,9 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn authed_eip = false; preferences.edit().putBoolean(Constants.AUTHED_EIP, authed_eip).apply(); - + + if(switching_provider) switchProvider(); + } else if(resultCode == ProviderAPI.LOGOUT_FAILED) { changeStatusMessage(resultCode); hideProgressBar(); diff --git a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java index 420da7a1..59e9ca5a 100644 --- a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java @@ -211,6 +211,7 @@ public class EipFragment extends Fragment implements Observer { String status = parent_activity.getString(R.string.eip_state_not_connected); status_message.setText(status); + eipCommand(Constants.ACTION_STOP_EIP); } -- cgit v1.2.3 From 20049d1dbca7c032f2f88824098d9b39c71712d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Tue, 23 Dec 2014 19:46:58 +0100 Subject: -100 lines on Dashboard, gradle fix. Gradle doesn't invoke updateIcsOpenVpn task unless the task is explicitly invoked. I needed to put all the related tasks into the configuration phase, rather than on the execution one. --- .../main/java/se/leap/bitmaskclient/Dashboard.java | 635 +++++++++------------ .../java/se/leap/bitmaskclient/EipFragment.java | 10 +- 2 files changed, 271 insertions(+), 374 deletions(-) (limited to 'app/src/main/java/se') diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java index cf65c9b8..659cd22c 100644 --- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java +++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java @@ -17,37 +17,21 @@ package se.leap.bitmaskclient; import android.annotation.SuppressLint; -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.app.*; +import android.content.*; import android.content.pm.PackageManager.NameNotFoundException; -import android.os.Bundle; -import android.os.Handler; -import android.os.ResultReceiver; +import android.os.*; import android.util.Log; -import android.view.Menu; -import android.view.MenuItem; -import android.widget.ProgressBar; -import android.widget.TextView; +import android.view.*; +import android.widget.*; import org.jetbrains.annotations.NotNull; -import org.json.JSONException; -import org.json.JSONObject; +import org.json.*; +import java.net.*; -import java.net.MalformedURLException; -import java.net.URL; - -import butterknife.ButterKnife; -import butterknife.InjectView; -import de.blinkt.openvpn.activities.LogWindow; -import se.leap.bitmaskclient.eip.Constants; -import se.leap.bitmaskclient.eip.EIP; -import se.leap.bitmaskclient.eip.EipStatus; +import butterknife.*; +import de.blinkt.openvpn.activities.*; +import se.leap.bitmaskclient.eip.*; /** * The main user facing Activity of Bitmask Android, consisting of status, controls, @@ -58,16 +42,16 @@ import se.leap.bitmaskclient.eip.EipStatus; */ public class Dashboard extends Activity implements SessionDialog.SessionDialogInterface, ProviderAPIResultReceiver.Receiver { - protected static final int CONFIGURE_LEAP = 0; - protected static final int SWITCH_PROVIDER = 1; + protected static final int CONFIGURE_LEAP = 0; + protected static final int SWITCH_PROVIDER = 1; - final public static String TAG = Dashboard.class.getSimpleName(); - final public static String SHARED_PREFERENCES = "LEAPPreferences"; - final public static String ACTION_QUIT = "quit"; + public static final String TAG = Dashboard.class.getSimpleName(); + public static final String SHARED_PREFERENCES = "LEAPPreferences"; + public static final String ACTION_QUIT = "quit"; public static final String REQUEST_CODE = "request_code"; public static final String PARAMETERS = "dashboard parameters"; public static final String START_ON_BOOT = "dashboard start on boot"; - final public static String ON_BOOT = "dashboard on boot"; + public static final String ON_BOOT = "dashboard on boot"; public static final String APP_VERSION = "bitmask version"; private static Context app; @@ -83,6 +67,25 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn public ProviderAPIResultReceiver providerAPI_result_receiver; private boolean switching_provider; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + app = this; + + PRNGFixes.apply(); + + preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE); + fragment_manager = new FragmentManagerEnhanced(getFragmentManager()); + handleVersion(); + + provider = getSavedProvider(savedInstanceState); + if (provider == null || provider.getName().isEmpty()) + startActivityForResult(new Intent(this,ConfigurationWizard.class),CONFIGURE_LEAP); + else + buildDashboard(getIntent().getBooleanExtra(ON_BOOT, false)); + } + @Override protected void onSaveInstanceState(@NotNull Bundle outState) { if(provider != null) @@ -90,25 +93,6 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn super.onSaveInstanceState(outState); } - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - app = this; - - PRNGFixes.apply(); - - preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE); - fragment_manager = new FragmentManagerEnhanced(getFragmentManager()); - handleVersion(); - - provider = getSavedProvider(savedInstanceState); - if (provider == null || provider.getName().isEmpty()) - startActivityForResult(new Intent(this,ConfigurationWizard.class),CONFIGURE_LEAP); - else - buildDashboard(getIntent().getBooleanExtra(ON_BOOT, false)); - } - private Provider getSavedProvider(Bundle savedInstanceState) { Provider provider = null; if(savedInstanceState != null) @@ -131,113 +115,100 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn return provider; } - 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(); - Log.d("Dashboard", "detected version code: " + versionCode); - Log.d("Dashboard", "last detected version code: " + lastDetectedVersion); switch(versionCode) { case 91: // 0.6.0 without Bug #5999 case 101: // 0.8.0 - if(!preferences.getString(Constants.KEY, "").isEmpty()) { - Intent rebuildVpnProfiles = new Intent(getApplicationContext(), EIP.class); - rebuildVpnProfiles.setAction(Constants.ACTION_UPDATE_EIP_SERVICE); - startService(rebuildVpnProfiles); - } + if(!preferences.getString(Constants.KEY, "").isEmpty()) + updateEipService(); break; } } catch (NameNotFoundException e) { - Log.d(TAG, "Handle version didn't find any " + getPackageName() + " package"); + Log.d(TAG, "Handle version didn't find any " + getPackageName() + " package"); } } @SuppressLint("CommitPrefEdits") @Override protected void onActivityResult(int requestCode, int resultCode, Intent data){ - Log.d(TAG, "onActivityResult: requestCode = " + requestCode); if ( requestCode == CONFIGURE_LEAP || requestCode == SWITCH_PROVIDER) { if ( resultCode == RESULT_OK ) { - preferences.edit().putBoolean(Constants.AUTHED_EIP, authed_eip).apply(); - updateEipService(); - - if (data.hasExtra(Provider.KEY)) { - provider = data.getParcelableExtra(Provider.KEY); - preferences.edit().putBoolean(Constants.PROVIDER_CONFIGURED, true).commit(); - preferences.edit().putString(Provider.MAIN_URL, provider.mainUrl().toString()).apply(); - preferences.edit().putString(Provider.KEY, provider.definition().toString()).apply(); - } - buildDashboard(false); - invalidateOptionsMenu(); - if (data.hasExtra(SessionDialog.TAG)) { - logInDialog(Bundle.EMPTY); - } - } else if (resultCode == RESULT_CANCELED && data.hasExtra(ACTION_QUIT)) { + preferences.edit().putBoolean(Constants.AUTHED_EIP, authed_eip).apply(); + updateEipService(); + + if (data.hasExtra(Provider.KEY)) { + provider = data.getParcelableExtra(Provider.KEY); + preferences.edit().putBoolean(Constants.PROVIDER_CONFIGURED, true).commit(); + preferences.edit().putString(Provider.MAIN_URL, provider.mainUrl().toString()).apply(); + preferences.edit().putString(Provider.KEY, provider.definition().toString()).apply(); + } + buildDashboard(false); + invalidateOptionsMenu(); + if (data.hasExtra(SessionDialog.TAG)) { + sessionDialog(Bundle.EMPTY); + } + } else if (resultCode == RESULT_CANCELED && data.hasExtra(ACTION_QUIT)) { finish(); - } else + } else configErrorDialog(); } else if(requestCode == EIP.DISCONNECT) { EipStatus.getInstance().setConnectedOrDisconnected(); } } - /** - * Dialog shown when encountering a configuration error. Such errors require - * reconfiguring LEAP or aborting the application. - */ - private void configErrorDialog() { - AlertDialog.Builder alertBuilder = new AlertDialog.Builder(getAppContext()); - alertBuilder.setTitle(getResources().getString(R.string.setup_error_title)); - alertBuilder - .setMessage(getResources().getString(R.string.setup_error_text)) - .setCancelable(false) - .setPositiveButton(getResources().getString(R.string.setup_error_configure_button), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - startActivityForResult(new Intent(getAppContext(),ConfigurationWizard.class),CONFIGURE_LEAP); - } - }) - .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).remove(Constants.PROVIDER_CONFIGURED).apply(); - finish(); - } - }) - .show(); - } + private void configErrorDialog() { + AlertDialog.Builder alertBuilder = new AlertDialog.Builder(getAppContext()); + alertBuilder.setTitle(getResources().getString(R.string.setup_error_title)); + alertBuilder + .setMessage(getResources().getString(R.string.setup_error_text)) + .setCancelable(false) + .setPositiveButton(getResources().getString(R.string.setup_error_configure_button), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + startActivityForResult(new Intent(getAppContext(),ConfigurationWizard.class),CONFIGURE_LEAP); + } + }) + .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).remove(Constants.PROVIDER_CONFIGURED).apply(); + finish(); + } + }) + .show(); + } - /** - * Inflates permanent UI elements of the View and contains logic for what - * service dependent UI elements to include. - */ - private void buildDashboard(boolean hide_and_turn_on_eip) { - setContentView(R.layout.dashboard); + /** + * Inflates permanent UI elements of the View and contains logic for what + * service dependent UI elements to include. + */ + private void buildDashboard(boolean hide_and_turn_on_eip) { + setContentView(R.layout.dashboard); ButterKnife.inject(this); - provider_name.setText(provider.getDomain()); - if ( provider.hasEIP()){ - + provider_name.setText(provider.getDomain()); + if ( provider.hasEIP()){ fragment_manager.removePreviousFragment(EipFragment.TAG); eip_fragment = new EipFragment(); - if (hide_and_turn_on_eip) { - preferences.edit().remove(Dashboard.START_ON_BOOT).apply(); - Bundle arguments = new Bundle(); - arguments.putBoolean(EipFragment.START_ON_BOOT, true); + if (hide_and_turn_on_eip) { + preferences.edit().remove(Dashboard.START_ON_BOOT).apply(); + Bundle arguments = new Bundle(); + arguments.putBoolean(EipFragment.START_ON_BOOT, true); if(eip_fragment != null) eip_fragment.setArguments(arguments); - } + } fragment_manager.replace(R.id.servicesCollection, eip_fragment, EipFragment.TAG); - - if (hide_and_turn_on_eip) { - onBackPressed(); - } - } + if (hide_and_turn_on_eip) { + onBackPressed(); + } } + } @Override public boolean onPrepareOptionsMenu(Menu menu) { @@ -268,110 +239,104 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn } return true; } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.client_dashboard, menu); + return true; + } - @Override - public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.client_dashboard, menu); - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item){ - Intent intent; - switch (item.getItemId()){ - case R.id.about_leap: - intent = new Intent(this, AboutActivity.class); - startActivity(intent); - return true; - case R.id.log_window: - Intent startLW = new Intent(getAppContext(), LogWindow.class); - startLW.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); - startActivity(startLW); - return true; - case R.id.switch_provider: - switching_provider = true; - if (preferences.getBoolean(Constants.AUTHED_EIP, false)) { - logOut(); - } else switchProvider(); - return true; - case R.id.login_button: - logInDialog(Bundle.EMPTY); - return true; - case R.id.logout_button: - logOut(); - return true; - case R.id.signup_button: - signUpDialog(Bundle.EMPTY); - return true; - default: - return super.onOptionsItemSelected(item); - } - + @Override + public boolean onOptionsItemSelected(MenuItem item){ + Intent intent; + switch (item.getItemId()){ + case R.id.about_leap: + intent = new Intent(this, AboutActivity.class); + startActivity(intent); + return true; + case R.id.log_window: + Intent startLW = new Intent(getAppContext(), LogWindow.class); + startLW.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + startActivity(startLW); + return true; + case R.id.switch_provider: + switching_provider = true; + if (preferences.getBoolean(Constants.AUTHED_EIP, false)) logOut(); + else switchProvider(); + return true; + case R.id.login_button: + sessionDialog(Bundle.EMPTY); + return true; + case R.id.logout_button: + logOut(); + return true; + case R.id.signup_button: + sessionDialog(Bundle.EMPTY); + return true; + default: + return super.onOptionsItemSelected(item); } - - protected Intent prepareProviderAPICommand() { - providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler()); - providerAPI_result_receiver.setReceiver(this); - - Intent command = new Intent(this, ProviderAPI.class); - - command.putExtra(ProviderAPI.RECEIVER_KEY, providerAPI_result_receiver); - return command; } - - /** - * Shows the log in dialog. - */ - public void logInDialog(Bundle resultData) { - FragmentTransaction transaction = fragment_manager.removePreviousFragment(SessionDialog.TAG); - DialogFragment newFragment = SessionDialog.newInstance(); - if(resultData != null && !resultData.isEmpty() && fragment_manager.findFragmentByTag(SessionDialog.TAG) == null) - newFragment.setArguments(resultData); - newFragment.show(transaction, SessionDialog.TAG); + @Override + public void signUp(String username, String password) { + Bundle parameters = bundleParameters(username, password); + providerApiCommand(parameters, R.string.signingup_message, ProviderAPI.SRP_REGISTER); } @Override public void logIn(String username, String password) { - Intent provider_API_command = prepareProviderAPICommand(); - Bundle parameters = provider_API_command.getExtras().getBundle(ProviderAPI.PARAMETERS); - if(parameters == null) - parameters = new Bundle(); - - parameters.putString(SessionDialog.USERNAME, username); - parameters.putString(SessionDialog.PASSWORD, password); + Bundle parameters = bundleParameters(username, password); + providerApiCommand(parameters, R.string.authenticating_message, ProviderAPI.SRP_AUTH); + } + + public void logOut() { + providerApiCommand(Bundle.EMPTY, R.string.logout_message, ProviderAPI.LOG_OUT); + } + + private void downloadAuthedUserCertificate() { + Bundle parameters = new Bundle(); + parameters.putString(ConfigurationWizard.TYPE_OF_CERTIFICATE, ConfigurationWizard.AUTHED_CERTIFICATE); + + providerApiCommand(parameters, R.string.downloading_certificate_message, ProviderAPI.DOWNLOAD_CERTIFICATE); + } + + private Bundle bundleParameters(String username, String password) { + Bundle parameters = new Bundle(); + if(!username.isEmpty() && !password.isEmpty()) { + parameters.putString(SessionDialog.USERNAME, username); + parameters.putString(SessionDialog.PASSWORD, password); + } + return parameters; + } + private void providerApiCommand(Bundle parameters, int progressbar_message_resId, String providerApi_action) { if(eip_fragment != null) { eip_fragment.progress_bar.setVisibility(ProgressBar.VISIBLE); - eip_fragment.status_message.setText(R.string.authenticating_message); + setStatusMessage(progressbar_message_resId); } - provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters); - provider_API_command.setAction(ProviderAPI.SRP_AUTH); - startService(provider_API_command); + + Intent command = prepareProviderAPICommand(parameters, providerApi_action); + startService(command); } - public void cancelLoginOrSignup() { - EipStatus.getInstance().setConnectedOrDisconnected(); - } + protected Intent prepareProviderAPICommand(Bundle parameters, String action) { + providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler()); + providerAPI_result_receiver.setReceiver(this); - /** - * Asks ProviderAPI to log out. - */ - public void logOut() { - Intent provider_API_command = prepareProviderAPICommand(); - if(eip_fragment != null) { + Intent command = new Intent(this, ProviderAPI.class); + + command.putExtra(ProviderAPI.PARAMETERS, parameters); + command.putExtra(ProviderAPI.RECEIVER_KEY, providerAPI_result_receiver); + command.setAction(action); + return command; + } - eip_fragment.progress_bar.setVisibility(ProgressBar.VISIBLE); - eip_fragment.status_message.setText(R.string.logout_message); - } - provider_API_command.setAction(ProviderAPI.LOG_OUT); - startService(provider_API_command); + public void cancelLoginOrSignup() { + EipStatus.getInstance().setConnectedOrDisconnected(); } - /** - * Shows the sign up dialog. - */ - public void signUpDialog(Bundle resultData) { + public void sessionDialog(Bundle resultData) { FragmentTransaction transaction = fragment_manager.removePreviousFragment(SessionDialog.TAG); DialogFragment newFragment = SessionDialog.newInstance(); @@ -381,169 +346,118 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn newFragment.show(transaction, SessionDialog.TAG); } - @Override - public void signUp(String username, String password) { - Intent provider_API_command = prepareProviderAPICommand(); - Bundle parameters = provider_API_command.getExtras().getBundle(ProviderAPI.PARAMETERS); - if(parameters == null) - parameters = new Bundle(); - - parameters.putString(SessionDialog.USERNAME, username); - parameters.putString(SessionDialog.PASSWORD, password); - if(eip_fragment != null) { - eip_fragment.progress_bar.setVisibility(ProgressBar.VISIBLE); - eip_fragment.status_message.setText(R.string.signingup_message); - } - provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters); - provider_API_command.setAction(ProviderAPI.SRP_REGISTER); - startService(provider_API_command); - } - private void switchProvider() { if (provider.hasEIP()) eip_fragment.askToStopEIP(); + preferences.edit().clear().apply(); switching_provider = false; - startActivityForResult(new Intent(this,ConfigurationWizard.class), SWITCH_PROVIDER); + startActivityForResult(new Intent(this, ConfigurationWizard.class), SWITCH_PROVIDER); } - /** - * Asks ProviderAPI to download an authenticated OpenVPN certificate. - */ - private void downloadAuthedUserCertificate() { - providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler()); - providerAPI_result_receiver.setReceiver(this); - - Intent provider_API_command = new Intent(this, ProviderAPI.class); - - Bundle parameters = new Bundle(); - parameters.putString(ConfigurationWizard.TYPE_OF_CERTIFICATE, ConfigurationWizard.AUTHED_CERTIFICATE); - - provider_API_command.setAction(ProviderAPI.DOWNLOAD_CERTIFICATE); - provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters); - provider_API_command.putExtra(ProviderAPI.RECEIVER_KEY, providerAPI_result_receiver); - - startService(provider_API_command); + @Override + public void onReceiveResult(int resultCode, Bundle resultData) { + Log.d(TAG, "onReceiveResult"); + if(resultCode == ProviderAPI.SUCCESSFUL_SIGNUP) { + String username = resultData.getString(SessionDialog.USERNAME); + String password = resultData.getString(SessionDialog.PASSWORD); + logIn(username, password); + } else if(resultCode == ProviderAPI.FAILED_SIGNUP) { + updateViewHidingProgressBar(resultCode); + sessionDialog(resultData); + } else if(resultCode == ProviderAPI.SUCCESSFUL_LOGIN) { + authed_eip = true; + preferences.edit().putBoolean(Constants.AUTHED_EIP, authed_eip).apply(); + + updateViewHidingProgressBar(resultCode); + downloadAuthedUserCertificate(); + } else if(resultCode == ProviderAPI.FAILED_LOGIN) { + updateViewHidingProgressBar(resultCode); + sessionDialog(resultData); + } else if(resultCode == ProviderAPI.SUCCESSFUL_LOGOUT) { + authed_eip = false; + preferences.edit().putBoolean(Constants.AUTHED_EIP, authed_eip).apply(); + + updateViewHidingProgressBar(resultCode); + if(switching_provider) switchProvider(); + } else if(resultCode == ProviderAPI.LOGOUT_FAILED) { + updateViewHidingProgressBar(resultCode); + setResult(RESULT_CANCELED); + } else if(resultCode == ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE) { + updateViewHidingProgressBar(resultCode); + updateEipService(); + setResult(RESULT_OK); + } else if(resultCode == ProviderAPI.INCORRECTLY_DOWNLOADED_CERTIFICATE) { + updateViewHidingProgressBar(resultCode); + setResult(RESULT_CANCELED); } + else if(resultCode == ProviderAPI.CORRECTLY_DOWNLOADED_EIP_SERVICE) { + setResult(RESULT_OK); - @Override - public void onReceiveResult(int resultCode, Bundle resultData) { - Log.d(TAG, "onReceiveResult"); - if(resultCode == ProviderAPI.SUCCESSFUL_SIGNUP) { - String username = resultData.getString(SessionDialog.USERNAME); - String password = resultData.getString(SessionDialog.PASSWORD); - logIn(username, password); - } else if(resultCode == ProviderAPI.FAILED_SIGNUP) { - changeStatusMessage(resultCode); - hideProgressBar(); - - signUpDialog(resultData); - } else if(resultCode == ProviderAPI.SUCCESSFUL_LOGIN) { - changeStatusMessage(resultCode); - hideProgressBar(); - - invalidateOptionsMenu(); - - authed_eip = true; - preferences.edit().putBoolean(Constants.AUTHED_EIP, authed_eip).apply(); - - downloadAuthedUserCertificate(); - } else if(resultCode == ProviderAPI.FAILED_LOGIN) { - changeStatusMessage(resultCode); - hideProgressBar(); - - logInDialog(resultData); - } else if(resultCode == ProviderAPI.SUCCESSFUL_LOGOUT) { - changeStatusMessage(resultCode); - hideProgressBar(); - - invalidateOptionsMenu(); - - authed_eip = false; - preferences.edit().putBoolean(Constants.AUTHED_EIP, authed_eip).apply(); - - if(switching_provider) switchProvider(); - - } else if(resultCode == ProviderAPI.LOGOUT_FAILED) { - changeStatusMessage(resultCode); - hideProgressBar(); - - setResult(RESULT_CANCELED); - } else if(resultCode == ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE) { - changeStatusMessage(resultCode); - hideProgressBar(); - - setResult(RESULT_OK); - - updateEipService(); - } else if(resultCode == ProviderAPI.INCORRECTLY_DOWNLOADED_CERTIFICATE) { - changeStatusMessage(resultCode); - hideProgressBar(); - setResult(RESULT_CANCELED); - } - else if(resultCode == ProviderAPI.CORRECTLY_DOWNLOADED_EIP_SERVICE) { - setResult(RESULT_OK); + updateEipService(); + } else if(resultCode == ProviderAPI.INCORRECTLY_DOWNLOADED_EIP_SERVICE) { + setResult(RESULT_CANCELED); + } + } - updateEipService(); - } else if(resultCode == ProviderAPI.INCORRECTLY_DOWNLOADED_EIP_SERVICE) { - setResult(RESULT_CANCELED); + private void updateViewHidingProgressBar(int resultCode) { + changeStatusMessage(resultCode); + hideProgressBar(); + invalidateOptionsMenu(); } - } private void updateEipService() { Intent updateEIP = new Intent(getApplicationContext(), EIP.class); updateEIP.setAction(Constants.ACTION_UPDATE_EIP_SERVICE); - ResultReceiver receiver = new ResultReceiver(new Handler()) { - protected void onReceiveResult(int resultCode, Bundle resultData) { + startService(updateEIP); + } + + private void changeStatusMessage(final int previous_result_code) { + ResultReceiver status_receiver = new ResultReceiver(new Handler()){ + protected void onReceiveResult(int resultCode, Bundle resultData){ + super.onReceiveResult(resultCode, resultData); String request = resultData.getString(Constants.REQUEST_TAG); - if(request.equalsIgnoreCase(Constants.ACTION_UPDATE_EIP_SERVICE)) { - if(resultCode == Activity.RESULT_OK) { - if(authed_eip && eip_fragment != null) eip_fragment.startEipFromScratch(); + if (request.equalsIgnoreCase(Constants.ACTION_IS_EIP_RUNNING)){ + if (resultCode == Activity.RESULT_OK){ + switch(previous_result_code){ + case ProviderAPI.SUCCESSFUL_LOGIN: setStatusMessage(R.string.succesful_authentication_message); break; + case ProviderAPI.FAILED_LOGIN: setStatusMessage(R.string.authentication_failed_message); break; + case ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE: setStatusMessage(R.string.authed_secured_status); break; + case ProviderAPI.INCORRECTLY_DOWNLOADED_CERTIFICATE: setStatusMessage(R.string.incorrectly_downloaded_certificate_message); break; + case ProviderAPI.SUCCESSFUL_LOGOUT: setStatusMessage(R.string.logged_out_message); break; + case ProviderAPI.LOGOUT_FAILED: setStatusMessage(R.string.log_out_failed_message); break; + + } + } + else if(resultCode == Activity.RESULT_CANCELED){ + switch(previous_result_code){ + case ProviderAPI.SUCCESSFUL_LOGIN: setStatusMessage(R.string.succesful_authentication_message); break; + case ProviderAPI.FAILED_LOGIN: setStatusMessage(R.string.authentication_failed_message); break; + case ProviderAPI.FAILED_SIGNUP: setStatusMessage(R.string.registration_failed_message); break; + case ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE: break; + case ProviderAPI.INCORRECTLY_DOWNLOADED_CERTIFICATE: setStatusMessage(R.string.incorrectly_downloaded_certificate_message); break; + case ProviderAPI.SUCCESSFUL_LOGOUT: setStatusMessage(R.string.logged_out_message); break; + case ProviderAPI.LOGOUT_FAILED: setStatusMessage(R.string.log_out_failed_message); break; + } } } + } }; - //updateEIP.putExtra(Constants.RECEIVER_TAG, receiver); - startService(updateEIP); + eipIsRunning(status_receiver); } - private void changeStatusMessage(final int previous_result_code) { - // TODO Auto-generated method stub - ResultReceiver eip_status_receiver = new ResultReceiver(new Handler()){ - protected void onReceiveResult(int resultCode, Bundle resultData){ - super.onReceiveResult(resultCode, resultData); - String request = resultData.getString(Constants.REQUEST_TAG); - if (request.equalsIgnoreCase(Constants.ACTION_IS_EIP_RUNNING)){ - if (resultCode == Activity.RESULT_OK){ - - switch(previous_result_code){ - case ProviderAPI.SUCCESSFUL_LOGIN: eip_fragment.status_message.setText(R.string.succesful_authentication_message); break; - case ProviderAPI.FAILED_LOGIN: eip_fragment.status_message.setText(R.string.authentication_failed_message); break; - case ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE: eip_fragment.status_message.setText(R.string.authed_secured_status); break; - case ProviderAPI.INCORRECTLY_DOWNLOADED_CERTIFICATE: eip_fragment.status_message.setText(R.string.incorrectly_downloaded_certificate_message); break; - case ProviderAPI.SUCCESSFUL_LOGOUT: eip_fragment.status_message.setText(R.string.logged_out_message); break; - case ProviderAPI.LOGOUT_FAILED: eip_fragment.status_message.setText(R.string.log_out_failed_message); break; - - } - } - else if(resultCode == Activity.RESULT_CANCELED){ - - switch(previous_result_code){ - - case ProviderAPI.SUCCESSFUL_LOGIN: eip_fragment.status_message.setText(R.string.succesful_authentication_message); break; - case ProviderAPI.FAILED_LOGIN: eip_fragment.status_message.setText(R.string.authentication_failed_message); break; - case ProviderAPI.FAILED_SIGNUP: eip_fragment.status_message.setText(R.string.registration_failed_message); break; - case ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE: break; - case ProviderAPI.INCORRECTLY_DOWNLOADED_CERTIFICATE: eip_fragment.status_message.setText(R.string.incorrectly_downloaded_certificate_message); break; - case ProviderAPI.SUCCESSFUL_LOGOUT: eip_fragment.status_message.setText(R.string.logged_out_message); break; - case ProviderAPI.LOGOUT_FAILED: eip_fragment.status_message.setText(R.string.log_out_failed_message); break; - } - } - } - - } - }; - eipIsRunning(eip_status_receiver); - } + private void setStatusMessage(int string_resId) { + if(eip_fragment != null && eip_fragment.status_message != null) + eip_fragment.status_message.setText(string_resId); + } + + private void eipIsRunning(ResultReceiver eip_receiver){ + // TODO validate "action"...how do we get the list of intent-filters for a class via Android API? + Intent intent = new Intent(this, EIP.class); + intent.setAction(Constants.ACTION_IS_EIP_RUNNING); + intent.putExtra(Constants.RECEIVER_TAG, eip_receiver); + startService(intent); + } private void hideProgressBar() { if(eip_fragment != null) { @@ -552,28 +466,13 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn } } - /** - * For retrieving the base application Context in classes that don't extend - * Android's Activity class - * - * @return Application Context as defined by this for Dashboard instance - */ - public static Context getAppContext() { - return app; - } - - + public static Context getAppContext() { + return app; + } + @Override public void startActivityForResult(Intent intent, int requestCode) { intent.putExtra(Dashboard.REQUEST_CODE, requestCode); super.startActivityForResult(intent, requestCode); } - - private void eipIsRunning(ResultReceiver eip_receiver){ - // TODO validate "action"...how do we get the list of intent-filters for a class via Android API? - Intent eip_intent = new Intent(this, EIP.class); - eip_intent.setAction(Constants.ACTION_IS_EIP_RUNNING); - eip_intent.putExtra(Constants.RECEIVER_TAG, eip_receiver); - startService(eip_intent); - } } diff --git a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java index 59e9ca5a..27c70c43 100644 --- a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java @@ -56,8 +56,7 @@ public class EipFragment extends Fragment implements Observer { parent_activity = activity; Dashboard dashboard = (Dashboard) parent_activity; - Intent provider_API_command = dashboard.prepareProviderAPICommand(); - provider_API_command.setAction(ProviderAPI.DOWNLOAD_EIP_SERVICE); + Intent provider_API_command = dashboard.prepareProviderAPICommand(Bundle.EMPTY, ProviderAPI.DOWNLOAD_EIP_SERVICE); parent_activity.startService(provider_API_command); } @@ -139,7 +138,7 @@ public class EipFragment extends Fragment implements Observer { Dashboard dashboard = (Dashboard) parent_activity; Bundle bundle = new Bundle(); bundle.putBoolean(IS_PENDING, true); - dashboard.logInDialog(bundle); + dashboard.sessionDialog(bundle); } } @@ -344,10 +343,9 @@ public class EipFragment extends Fragment implements Observer { progress_bar.setVisibility(View.VISIBLE); status_message.setText(getString(R.string.updating_certificate_message)); if(LeapSRPSession.getToken().isEmpty() && !Dashboard.preferences.getBoolean(Constants.ALLOWED_ANON, false)) { - dashboard.logInDialog(Bundle.EMPTY); + dashboard.sessionDialog(Bundle.EMPTY); } else { - Intent provider_API_command = dashboard.prepareProviderAPICommand(); - provider_API_command.setAction(ProviderAPI.DOWNLOAD_CERTIFICATE); + Intent provider_API_command = dashboard.prepareProviderAPICommand(Bundle.EMPTY, ProviderAPI.DOWNLOAD_CERTIFICATE); parent_activity.startService(provider_API_command); } break; -- cgit v1.2.3 From b1219330faf64b2cd4330d44390fdec137b659b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Wed, 17 Dec 2014 19:08:53 +0100 Subject: Add remotes for each port, udp before tcp in each. --- .../leap/bitmaskclient/eip/VpnConfigGenerator.java | 38 ++++++++++++---------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'app/src/main/java/se') 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 0c8e9a04..a320bee5 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java @@ -79,32 +79,36 @@ public class VpnConfigGenerator { private String gatewayConfiguration() { String remotes = ""; - String remote = "ip_address"; - String remote_openvpn_keyword = "remote"; - String ports = "ports"; - String protos = "protocols"; - String capabilities = "capabilities"; + String ip_address_keyword = "ip_address"; + String remote_keyword = "remote"; + String ports_keyword = "ports"; + String protocol_keyword = "protocols"; + String capabilities_keyword = "capabilities"; String udp = "udp"; try { - JSONArray protocolsJSON = gateway.getJSONObject(capabilities).getJSONArray(protos); - for ( int i=0; i profiles = vpl.getProfiles(); - for (Iterator it = profiles.iterator(); it.hasNext(); ){ - VpnProfile p = it.next(); - - if ( p.mName.equalsIgnoreCase( mName ) ) { - it.remove(); - vpl.removeProfile(context, p); - } - } - mVpnProfile = createVPNProfile(); mVpnProfile.mName = mName; - - vpl.addProfile(mVpnProfile); - vpl.saveProfile(context, mVpnProfile); - vpl.saveProfileList(context); } private JSONObject getGeneralConfiguration(JSONObject eip_definition) { @@ -153,4 +137,13 @@ public class Gateway { public int getTimezone() { return timezone; } + + @Override + public boolean equals(Object o) { + if(o instanceof Gateway) { + return ((Gateway) o).getProfile().mConnections.equals(mVpnProfile.mConnections); + } + else + return super.equals(o); + } } -- cgit v1.2.3 From 56e05aecf8430ddad776776e536583686555443a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Wed, 31 Dec 2014 17:11:58 +0100 Subject: Update gateway also if credentials changed. --- app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'app/src/main/java/se') 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 79239308..e23f67c7 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java @@ -141,7 +141,10 @@ public class Gateway { @Override public boolean equals(Object o) { if(o instanceof Gateway) { - return ((Gateway) o).getProfile().mConnections.equals(mVpnProfile.mConnections); + VpnProfile compared_profile = ((Gateway) o).getProfile(); + return compared_profile.mConnections.equals(mVpnProfile.mConnections) + && compared_profile.mClientCertFilename != mVpnProfile.mClientCertFilename + && compared_profile.mClientKeyFilename != mVpnProfile.mClientKeyFilename; } else return super.equals(o); -- cgit v1.2.3 From d23ec1613855f6582b0e79c1a9fc1538d6099944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Wed, 31 Dec 2014 20:50:51 +0100 Subject: Remove duplicated gateways when necessary. --- .../main/java/se/leap/bitmaskclient/eip/EIP.java | 71 +++++++++++++++++++--- 1 file changed, 64 insertions(+), 7 deletions(-) (limited to 'app/src/main/java/se') 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 77d0cd82..cf6006e5 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java @@ -31,10 +31,13 @@ import org.json.JSONObject; import java.util.ArrayList; import java.util.Collection; +import java.util.Iterator; import java.util.List; +import java.util.NoSuchElementException; import de.blinkt.openvpn.LaunchVPN; import de.blinkt.openvpn.VpnProfile; +import de.blinkt.openvpn.core.Connection; import de.blinkt.openvpn.core.ProfileManager; import se.leap.bitmaskclient.Dashboard; import se.leap.bitmaskclient.EipFragment; @@ -71,7 +74,7 @@ public final class EIP extends IntentService { private static SharedPreferences preferences; private static JSONObject eip_definition; - private static List gateways = new ArrayList(); + private static List gateways = new ArrayList<>(); private static ProfileManager profile_manager; private static Gateway gateway; @@ -190,12 +193,6 @@ public final class EIP extends IntentService { e.printStackTrace(); } } - - private void deleteAllVpnProfiles() { - Collection profiles = profile_manager.getProfiles(); - profiles.removeAll(profiles); - gateways.clear(); - } /** * Walk the list of gateways defined in eip-service.json and parse them into @@ -231,6 +228,8 @@ public final class EIP extends IntentService { private void addGateway(Gateway gateway) { VpnProfile profile = gateway.getProfile(); + removeGateway(gateway); + profile_manager.addProfile(profile); profile_manager.saveProfile(context, profile); profile_manager.saveProfileList(context); @@ -239,6 +238,64 @@ public final class EIP extends IntentService { Log.d(TAG, "Gateway added: " + gateway.getProfile().getUUIDString()); } + private void removeGateway(Gateway gateway) { + VpnProfile profile = gateway.getProfile(); + removeDuplicatedProfile(profile); + removeDuplicatedGateway(profile); + } + + private void removeDuplicatedProfile(VpnProfile remove) { + if(containsProfile(remove)) + profile_manager.removeProfile(context, duplicatedProfile(remove)); + if(containsProfile(remove)) removeDuplicatedProfile(remove); + } + + private boolean containsProfile(VpnProfile profile) { + Collection profiles = profile_manager.getProfiles(); + for(VpnProfile aux : profiles) { + if (sameConnections(profile.mConnections, aux.mConnections)) { + return true; + } + } + return false; + } + + private VpnProfile duplicatedProfile(VpnProfile profile) { + VpnProfile duplicated = null; + Collection profiles = profile_manager.getProfiles(); + for(VpnProfile aux : profiles) { + if (sameConnections(profile.mConnections, aux.mConnections)) { + duplicated = aux; + } + } + if(duplicated != null) return duplicated; + else throw new NoSuchElementException(profile.getName()); + } + + private boolean sameConnections(Connection[] c1, Connection[] c2) { + int same_connections = 0; + for(Connection c1_aux : c1) { + for(Connection c2_aux : c2) + if(c2_aux.mServerName.equals(c1_aux.mServerName)) { + same_connections++; + break; + } + } + return c1.length == c2.length && c1.length == same_connections; + + } + + private void removeDuplicatedGateway(VpnProfile profile) { + Iterator it = gateways.iterator(); + List gateways_to_remove = new ArrayList<>(); + while(it.hasNext()) { + Gateway aux = it.next(); + if(aux.getProfile().mConnections == profile.mConnections) + gateways_to_remove.add(aux); + } + gateways.removeAll(gateways_to_remove); + } + private void checkCertValidity() { VpnCertificateValidator validator = new VpnCertificateValidator(); int resultCode = validator.isValid(preferences.getString(CERTIFICATE, "")) ? -- cgit v1.2.3 From 407e3767744e39a59845423246a9ad427d933304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Fri, 2 Jan 2015 01:32:22 +0100 Subject: Update vpn profiles correctly. Before we add a new profile, we check if there are any duplicated ones with the same server IPs and ports. If they've the same credentials of the new one, we don't add anything; if not, we remove the old ones and add the new. --- .../main/java/se/leap/bitmaskclient/eip/EIP.java | 22 ++++++++++++++++++---- .../java/se/leap/bitmaskclient/eip/Gateway.java | 15 ++------------- 2 files changed, 20 insertions(+), 17 deletions(-) (limited to 'app/src/main/java/se') 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 cf6006e5..10d222c2 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java @@ -125,8 +125,9 @@ public final class EIP extends IntentService { if(gateway != null && gateway.getProfile() != null) { mReceiver = EipFragment.getReceiver(); launchActiveGateway(); - } - tellToReceiver(ACTION_START_EIP, Activity.RESULT_OK); + tellToReceiver(ACTION_START_EIP, Activity.RESULT_OK); + } else + tellToReceiver(ACTION_START_EIP, Activity.RESULT_CANCELED); } /** @@ -144,6 +145,8 @@ public final class EIP extends IntentService { intent.setAction(Intent.ACTION_MAIN); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(LaunchVPN.EXTRA_NAME, gateway.getProfile().getName()); + Log.d(TAG, gateway.getProfile().mClientCertFilename); + Log.d(TAG, gateway.getProfile().mClientKeyFilename); intent.putExtra(LaunchVPN.EXTRA_HIDELOG, true); startActivity(intent); } @@ -206,7 +209,7 @@ public final class EIP extends IntentService { JSONObject gw = gatewaysDefined.getJSONObject(i); if (isOpenVpnGateway(gw)) { Gateway gateway = new Gateway(eip_definition, context, gw); - if(!gateways.contains(gateway)) { + if(!containsProfileWithSecrets(gateway.getProfile())) { addGateway(gateway); } } @@ -260,6 +263,17 @@ public final class EIP extends IntentService { return false; } + private boolean containsProfileWithSecrets(VpnProfile profile) { + if(!containsProfile(profile)) return false; + + Collection profiles = profile_manager.getProfiles(); + for(VpnProfile aux : profiles) { + return profile.mClientCertFilename.equalsIgnoreCase(aux.mClientCertFilename) + && profile.mClientKeyFilename.equalsIgnoreCase(aux.mClientKeyFilename); + } + + return false; + } private VpnProfile duplicatedProfile(VpnProfile profile) { VpnProfile duplicated = null; Collection profiles = profile_manager.getProfiles(); @@ -290,7 +304,7 @@ public final class EIP extends IntentService { List gateways_to_remove = new ArrayList<>(); while(it.hasNext()) { Gateway aux = it.next(); - if(aux.getProfile().mConnections == profile.mConnections) + if(sameConnections(aux.getProfile().mConnections, profile.mConnections)) gateways_to_remove.add(aux); } gateways.removeAll(gateways_to_remove); 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 e23f67c7..005d0eec 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java @@ -25,6 +25,7 @@ import org.json.JSONException; import org.json.JSONObject; import java.io.IOException; +import java.io.Serializable; import java.io.StringReader; import java.util.Collection; import java.util.Iterator; @@ -42,7 +43,7 @@ import se.leap.bitmaskclient.Dashboard; * @author Sean Leonard * @author Parménides GV */ -public class Gateway { +public class Gateway implements Serializable { private String TAG = Gateway.class.getSimpleName(); @@ -137,16 +138,4 @@ public class Gateway { public int getTimezone() { return timezone; } - - @Override - public boolean equals(Object o) { - if(o instanceof Gateway) { - VpnProfile compared_profile = ((Gateway) o).getProfile(); - return compared_profile.mConnections.equals(mVpnProfile.mConnections) - && compared_profile.mClientCertFilename != mVpnProfile.mClientCertFilename - && compared_profile.mClientKeyFilename != mVpnProfile.mClientKeyFilename; - } - else - return super.equals(o); - } } -- cgit v1.2.3 From 38fdfbdacf414ab85fffd833f57e5fc93b03ad4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Fri, 2 Jan 2015 13:45:31 +0100 Subject: Serialized gateways and correctly updating profiles --- .../java/se/leap/bitmaskclient/EipFragment.java | 2 +- .../java/se/leap/bitmaskclient/OnBootReceiver.java | 3 + .../main/java/se/leap/bitmaskclient/eip/EIP.java | 104 ++++++++++++++++----- .../java/se/leap/bitmaskclient/eip/Gateway.java | 34 +++---- .../leap/bitmaskclient/eip/VpnConfigGenerator.java | 56 +++++------ 5 files changed, 126 insertions(+), 73 deletions(-) (limited to 'app/src/main/java/se') diff --git a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java index a21e0cd1..54432033 100644 --- a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java @@ -187,8 +187,8 @@ public class EipFragment extends Fragment implements Observer { if(!eip_switch.isChecked()) { eip_switch.setChecked(true); - saveStatus(); } + saveStatus(); eipCommand(Constants.ACTION_START_EIP); } diff --git a/app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java b/app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java index 3b1033bc..96b87085 100644 --- a/app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java +++ b/app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java @@ -4,6 +4,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.util.Log; import se.leap.bitmaskclient.eip.Constants; @@ -17,6 +18,8 @@ public class OnBootReceiver extends BroadcastReceiver { preferences = context.getSharedPreferences(Dashboard.SHARED_PREFERENCES, Context.MODE_PRIVATE); boolean provider_configured = !preferences.getString(Provider.KEY, "").isEmpty(); boolean start_on_boot = preferences.getBoolean(Dashboard.START_ON_BOOT, false); + Log.d("OnBootReceiver", "Provider configured " + String.valueOf(provider_configured)); + Log.d("OnBootReceiver", "Start on boot " + String.valueOf(start_on_boot)); if(provider_configured && start_on_boot) { Intent dashboard_intent = new Intent(context, Dashboard.class); dashboard_intent.setAction(Constants.ACTION_START_EIP); 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 10d222c2..dcf36a82 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java @@ -25,10 +25,14 @@ import android.os.Bundle; import android.os.ResultReceiver; import android.util.Log; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; + import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; +import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; @@ -41,6 +45,7 @@ import de.blinkt.openvpn.core.Connection; import de.blinkt.openvpn.core.ProfileManager; import se.leap.bitmaskclient.Dashboard; import se.leap.bitmaskclient.EipFragment; +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; @@ -87,12 +92,14 @@ public final class EIP extends IntentService { super.onCreate(); context = getApplicationContext(); - profile_manager = ProfileManager.getInstance(context); + preferences = getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE); - preferences = getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE); - refreshEipDefinition(); + profile_manager = ProfileManager.getInstance(context); + eip_definition = eipDefinitionFromPreferences(); + if(gateways.isEmpty()) + gateways = gatewaysFromPreferences(); } - + @Override protected void onHandleIntent(Intent intent) { String action = intent.getAction(); @@ -122,6 +129,7 @@ public final class EIP extends IntentService { GatewaySelector gateway_selector = new GatewaySelector(gateways); gateway = gateway_selector.select(); + Log.d(TAG, "Connecting to " + gateway.getProfile().getUUIDString()); if(gateway != null && gateway.getProfile() != null) { mReceiver = EipFragment.getReceiver(); launchActiveGateway(); @@ -179,28 +187,42 @@ public final class EIP extends IntentService { * TODO Implement API call to refresh eip-service.json from the provider */ private void updateEIPService() { - refreshEipDefinition(); + eip_definition = eipDefinitionFromPreferences(); if(eip_definition != null) updateGateways(); tellToReceiver(ACTION_UPDATE_EIP_SERVICE, Activity.RESULT_OK); } - private void refreshEipDefinition() { + private JSONObject eipDefinitionFromPreferences() { try { String eip_definition_string = preferences.getString(KEY, ""); if(!eip_definition_string.isEmpty()) { - eip_definition = new JSONObject(eip_definition_string); + return new JSONObject(eip_definition_string); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } + return null; + } + + private List gatewaysFromPreferences() { + List result; + + String gateways_string = preferences.getString(Gateway.TAG, ""); + Log.d(TAG, "Recovering gateways: " + gateways_string); + Type type_list_gateways = new TypeToken>() {}.getType(); + result = gateways_string.isEmpty() ? + new ArrayList() + : (List) new Gson().fromJson(gateways_string, type_list_gateways); + Log.d(TAG, "Gateways from preferences = " + result.size()); + preferences.edit().remove(Gateway.TAG); + return result; } /** * Walk the list of gateways defined in eip-service.json and parse them into * Gateway objects. - * TODO Store the Gateways (as Serializable) in SharedPreferences */ private void updateGateways(){ try { @@ -208,12 +230,15 @@ public final class EIP extends IntentService { for (int i = 0; i < gatewaysDefined.length(); i++) { JSONObject gw = gatewaysDefined.getJSONObject(i); if (isOpenVpnGateway(gw)) { - Gateway gateway = new Gateway(eip_definition, context, gw); - if(!containsProfileWithSecrets(gateway.getProfile())) { - addGateway(gateway); + JSONObject secrets = secretsConfiguration(); + Gateway aux = new Gateway(eip_definition, secrets, gw); + Log.d(TAG, "Possible new gateway: " + aux.getProfile().getUUIDString()); + if(!containsProfileWithSecrets(aux.getProfile())) { + addGateway(aux); } } } + gatewaysToPreferences(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -229,6 +254,19 @@ public final class EIP extends IntentService { } } + + private JSONObject secretsConfiguration() { + 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.CERTIFICATE, preferences.getString(Constants.CERTIFICATE, "")); + } catch (JSONException e) { + e.printStackTrace(); + } + return result; + } + private void addGateway(Gateway gateway) { VpnProfile profile = gateway.getProfile(); removeGateway(gateway); @@ -247,10 +285,12 @@ public final class EIP extends IntentService { removeDuplicatedGateway(profile); } - private void removeDuplicatedProfile(VpnProfile remove) { - if(containsProfile(remove)) - profile_manager.removeProfile(context, duplicatedProfile(remove)); - if(containsProfile(remove)) removeDuplicatedProfile(remove); + private void removeDuplicatedProfile(VpnProfile original) { + if(containsProfile(original)) { + VpnProfile remove = duplicatedProfile(original); + profile_manager.removeProfile(context, remove); + Log.d(TAG, "Removing profile " + remove.getUUIDString()); + }if(containsProfile(original)) removeDuplicatedProfile(original); } private boolean containsProfile(VpnProfile profile) { @@ -264,16 +304,21 @@ public final class EIP extends IntentService { } private boolean containsProfileWithSecrets(VpnProfile profile) { - if(!containsProfile(profile)) return false; - - Collection profiles = profile_manager.getProfiles(); - for(VpnProfile aux : profiles) { - return profile.mClientCertFilename.equalsIgnoreCase(aux.mClientCertFilename) - && profile.mClientKeyFilename.equalsIgnoreCase(aux.mClientKeyFilename); - } - - return false; + boolean result = false; + + if(containsProfile(profile)) { + Collection profiles = profile_manager.getProfiles(); + for(VpnProfile aux : profiles) { + result = result == false ? + sameConnections(profile.mConnections, aux.mConnections) + && profile.mClientCertFilename.equalsIgnoreCase(aux.mClientCertFilename) + && profile.mClientKeyFilename.equalsIgnoreCase(aux.mClientKeyFilename) + : true; + } + } + return result; } + private VpnProfile duplicatedProfile(VpnProfile profile) { VpnProfile duplicated = null; Collection profiles = profile_manager.getProfiles(); @@ -304,12 +349,21 @@ public final class EIP extends IntentService { List gateways_to_remove = new ArrayList<>(); while(it.hasNext()) { Gateway aux = it.next(); - if(sameConnections(aux.getProfile().mConnections, profile.mConnections)) + if(sameConnections(aux.getProfile().mConnections, profile.mConnections)) { gateways_to_remove.add(aux); + Log.d(TAG, "Removing gateway " + aux.getProfile().getUUIDString()); + } } gateways.removeAll(gateways_to_remove); } + private void gatewaysToPreferences() { + Type type_list_gateways = new TypeToken>() {}.getType(); + String gateways_string = new Gson().toJson(gateways, type_list_gateways); + Log.d(TAG, "Saving gateways: " + gateways_string); + preferences.edit().putString(Gateway.TAG, gateways_string).apply(); + } + private void checkCertValidity() { VpnCertificateValidator validator = new VpnCertificateValidator(); int resultCode = validator.isValid(preferences.getString(CERTIFICATE, "")) ? 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 005d0eec..daf7d4a7 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java @@ -17,7 +17,6 @@ package se.leap.bitmaskclient.eip; import android.app.Activity; -import android.content.Context; import android.content.SharedPreferences; import android.util.Log; @@ -25,14 +24,10 @@ import org.json.JSONException; import org.json.JSONObject; import java.io.IOException; -import java.io.Serializable; 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; /** @@ -43,28 +38,26 @@ import se.leap.bitmaskclient.Dashboard; * @author Sean Leonard * @author Parménides GV */ -public class Gateway implements Serializable { - - private String TAG = Gateway.class.getSimpleName(); +public class Gateway { + public static String TAG = Gateway.class.getSimpleName(); + + private JSONObject general_configuration; + private JSONObject secrets; + private JSONObject gateway; + private String mName; private int timezone; - private JSONObject general_configuration; - private Context context; private VpnProfile mVpnProfile; - private JSONObject mGateway; - /** * Build a gateway object from a JSON OpenVPN gateway definition in eip-service.json * and create a VpnProfile belonging to it. - * - * @param gateway The JSON OpenVPN gateway definition to parse */ - protected Gateway(JSONObject eip_definition, Context context, JSONObject gateway){ + protected Gateway(JSONObject eip_definition, JSONObject secrets, JSONObject gateway){ + + this.gateway = gateway; + this.secrets = secrets; - mGateway = gateway; - - this.context = context; general_configuration = getGeneralConfiguration(eip_definition); timezone = getTimezone(eip_definition); mName = locationAsName(eip_definition); @@ -95,7 +88,7 @@ public class Gateway implements Serializable { try { JSONObject locations = eip_definition.getJSONObject("locations"); - return locations.getJSONObject(mGateway.getString("location")); + return locations.getJSONObject(gateway.getString("location")); } catch (JSONException e) { return new JSONObject(); } @@ -108,8 +101,7 @@ public class Gateway implements Serializable { try { ConfigParser cp = new ConfigParser(); - SharedPreferences preferences = context.getSharedPreferences(Dashboard.SHARED_PREFERENCES, Activity.MODE_PRIVATE); - VpnConfigGenerator vpn_configuration_generator = new VpnConfigGenerator(preferences, general_configuration, mGateway); + VpnConfigGenerator vpn_configuration_generator = new VpnConfigGenerator(general_configuration, secrets, gateway); String configuration = vpn_configuration_generator.generate(); cp.parseConfig(new StringReader(configuration)); 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 a320bee5..6f260f55 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java @@ -31,15 +31,15 @@ public class VpnConfigGenerator { private JSONObject general_configuration; private JSONObject gateway; - - private static SharedPreferences preferences; + private JSONObject secrets; + public final static String TAG = VpnConfigGenerator.class.getSimpleName(); private final String new_line = System.getProperty("line.separator"); // Platform new line - public VpnConfigGenerator(SharedPreferences preferences, JSONObject general_configuration, JSONObject gateway) { + public VpnConfigGenerator(JSONObject general_configuration, JSONObject secrets, JSONObject gateway) { this.general_configuration = general_configuration; this.gateway = gateway; - VpnConfigGenerator.preferences = preferences; + this.secrets = secrets; } public String generate() { @@ -113,29 +113,33 @@ public class VpnConfigGenerator { } private String secretsConfiguration() { - - String ca = - "" - + new_line - + preferences.getString(Provider.CA_CERT, "") - + new_line - + ""; - - String key = - "" - + new_line - + preferences.getString(Constants.PRIVATE_KEY, "") - + new_line - + ""; - - String openvpn_cert = - "" - + new_line - + preferences.getString(Constants.CERTIFICATE, "") - + new_line - + ""; + try { + String ca = + "" + + new_line + + secrets.getString(Provider.CA_CERT) + + new_line + + ""; + + String key = + "" + + new_line + + secrets.getString(Constants.PRIVATE_KEY) + + new_line + + ""; + + String openvpn_cert = + "" + + new_line + + secrets.getString(Constants.CERTIFICATE) + + new_line + + ""; - return ca + new_line + key + new_line + openvpn_cert; + return ca + new_line + key + new_line + openvpn_cert; + } catch(JSONException e) { + e.printStackTrace(); + return ""; + } } private String androidCustomizations() { -- cgit v1.2.3 From 7ef5c878e754548ab6a854916799290b043ac8d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Fri, 2 Jan 2015 13:55:14 +0100 Subject: Don't print certificates on logcat! --- app/src/main/java/se/leap/bitmaskclient/eip/EIP.java | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'app/src/main/java/se') 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 dcf36a82..533b0281 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java @@ -129,7 +129,6 @@ public final class EIP extends IntentService { GatewaySelector gateway_selector = new GatewaySelector(gateways); gateway = gateway_selector.select(); - Log.d(TAG, "Connecting to " + gateway.getProfile().getUUIDString()); if(gateway != null && gateway.getProfile() != null) { mReceiver = EipFragment.getReceiver(); launchActiveGateway(); @@ -153,15 +152,12 @@ public final class EIP extends IntentService { intent.setAction(Intent.ACTION_MAIN); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(LaunchVPN.EXTRA_NAME, gateway.getProfile().getName()); - Log.d(TAG, gateway.getProfile().mClientCertFilename); - Log.d(TAG, gateway.getProfile().mClientKeyFilename); intent.putExtra(LaunchVPN.EXTRA_HIDELOG, true); startActivity(intent); } private void stopEIP() { EipStatus eip_status = EipStatus.getInstance(); - Log.d(TAG, "stopEip(): eip is connected? " + eip_status.isConnected()); int result_code = Activity.RESULT_CANCELED; if(eip_status.isConnected() || eip_status.isConnecting()) result_code = Activity.RESULT_OK; @@ -210,12 +206,10 @@ public final class EIP extends IntentService { List result; String gateways_string = preferences.getString(Gateway.TAG, ""); - Log.d(TAG, "Recovering gateways: " + gateways_string); Type type_list_gateways = new TypeToken>() {}.getType(); result = gateways_string.isEmpty() ? new ArrayList() : (List) new Gson().fromJson(gateways_string, type_list_gateways); - Log.d(TAG, "Gateways from preferences = " + result.size()); preferences.edit().remove(Gateway.TAG); return result; } @@ -232,7 +226,6 @@ public final class EIP extends IntentService { if (isOpenVpnGateway(gw)) { JSONObject secrets = secretsConfiguration(); Gateway aux = new Gateway(eip_definition, secrets, gw); - Log.d(TAG, "Possible new gateway: " + aux.getProfile().getUUIDString()); if(!containsProfileWithSecrets(aux.getProfile())) { addGateway(aux); } @@ -276,7 +269,6 @@ public final class EIP extends IntentService { profile_manager.saveProfileList(context); gateways.add(gateway); - Log.d(TAG, "Gateway added: " + gateway.getProfile().getUUIDString()); } private void removeGateway(Gateway gateway) { @@ -289,7 +281,6 @@ public final class EIP extends IntentService { if(containsProfile(original)) { VpnProfile remove = duplicatedProfile(original); profile_manager.removeProfile(context, remove); - Log.d(TAG, "Removing profile " + remove.getUUIDString()); }if(containsProfile(original)) removeDuplicatedProfile(original); } @@ -351,7 +342,6 @@ public final class EIP extends IntentService { Gateway aux = it.next(); if(sameConnections(aux.getProfile().mConnections, profile.mConnections)) { gateways_to_remove.add(aux); - Log.d(TAG, "Removing gateway " + aux.getProfile().getUUIDString()); } } gateways.removeAll(gateways_to_remove); @@ -360,7 +350,6 @@ public final class EIP extends IntentService { private void gatewaysToPreferences() { Type type_list_gateways = new TypeToken>() {}.getType(); String gateways_string = new Gson().toJson(gateways, type_list_gateways); - Log.d(TAG, "Saving gateways: " + gateways_string); preferences.edit().putString(Gateway.TAG, gateways_string).apply(); } -- cgit v1.2.3