From 8e67e4d2167f2508d7f069af4d69f0f2931844a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Sat, 6 Feb 2016 13:57:50 +0100 Subject: Pause icon, init log file in Dashboard --- app/src/main/java/se/leap/bitmaskclient/Dashboard.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'app/src/main/java/se/leap') diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java index bdc36e89..218b22a7 100644 --- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java +++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java @@ -1,3 +1,19 @@ +/** + * 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 . + */ /** * Copyright (c) 2013 LEAP Encryption Access Project and contributers * @@ -31,6 +47,7 @@ import org.json.*; import java.net.*; import butterknife.*; +import de.blinkt.openvpn.core.VpnStatus; import se.leap.bitmaskclient.eip.*; import se.leap.bitmaskclient.userstatus.*; @@ -75,6 +92,7 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec app = this; PRNGFixes.apply(); + VpnStatus.initLogCache(getApplicationContext().getCacheDir()); preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE); fragment_manager = new FragmentManagerEnhanced(getFragmentManager()); -- cgit v1.2.3 From 48948e1231a91c86e5a3e7b535a44eff62bacb6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Sat, 2 Apr 2016 15:04:35 +0200 Subject: VpnStatus.initLogCache must be called only once. onCreate gets called when the activity is back on the screen. If the app was already launched, we should not set everything up again. --- .../main/java/se/leap/bitmaskclient/Dashboard.java | 57 ++++++++++++++-------- 1 file changed, 38 insertions(+), 19 deletions(-) (limited to 'app/src/main/java/se/leap') diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java index 218b22a7..dbdf0a51 100644 --- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java +++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java @@ -88,36 +88,55 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - - app = this; - - PRNGFixes.apply(); - VpnStatus.initLogCache(getApplicationContext().getCacheDir()); - preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE); fragment_manager = new FragmentManagerEnhanced(getFragmentManager()); - handleVersion(); - User.init(getString(R.string.default_username)); ProviderAPICommand.initialize(this); providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler(), this); - restoreProvider(savedInstanceState); - if (!provider.isConfigured()) + if (app == null) { + app = this; + + PRNGFixes.apply(); + VpnStatus.initLogCache(getApplicationContext().getCacheDir()); + handleVersion(); + User.init(getString(R.string.default_username)); + } + boolean provider_exists = previousProviderExists(savedInstanceState); + if (provider_exists) { + provider = getProvider(savedInstanceState); + if(!provider.isConfigured()) + startActivityForResult(new Intent(this, ConfigurationWizard.class), CONFIGURE_LEAP); + else { + buildDashboard(getIntent().getBooleanExtra(ON_BOOT, false)); + user_status_fragment.restoreSessionStatus(savedInstanceState); + } + } else { startActivityForResult(new Intent(this, ConfigurationWizard.class), CONFIGURE_LEAP); - else { - buildDashboard(getIntent().getBooleanExtra(ON_BOOT, false)); - user_status_fragment.restoreSessionStatus(savedInstanceState); } } - private void restoreProvider(Bundle savedInstanceState) { - if (savedInstanceState != null) { - if (savedInstanceState.containsKey(Provider.KEY)) - provider = savedInstanceState.getParcelable(Provider.KEY); - } - if (!provider.isConfigured() && preferences.getBoolean(Constants.PROVIDER_CONFIGURED, false)) + private boolean previousProviderExists(Bundle savedInstanceState) { + return providerInSavedInstance(savedInstanceState) || providerInSharedPreferences(); + } + + private Provider getProvider(Bundle savedInstanceState) { + if(providerInSavedInstance(savedInstanceState)) + provider = savedInstanceState.getParcelable(Provider.KEY); + else if (providerInSharedPreferences()) provider = getSavedProviderFromSharedPreferences(); + return provider; + } + + private boolean providerInSavedInstance(Bundle savedInstanceState) { + return savedInstanceState != null && + savedInstanceState.containsKey(Provider.KEY); + } + + private boolean providerInSharedPreferences() { + return preferences != null && + preferences.getBoolean(Constants.PROVIDER_CONFIGURED, false); + } @Override -- cgit v1.2.3 From 2daac1d12c4784443a872492b7f29d02c429d19f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Sun, 3 Apr 2016 17:19:04 +0200 Subject: Bitmask does not show the log if an error happens. ics-openvpn already shows it if necessary. Our heuristic (just looking for an "error" keyword in the past N messages of the log) is very weak, and it returns an annoying false positive: turning off the VPN triggers the show log error. --- app/src/main/java/se/leap/bitmaskclient/VpnFragment.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'app/src/main/java/se/leap') diff --git a/app/src/main/java/se/leap/bitmaskclient/VpnFragment.java b/app/src/main/java/se/leap/bitmaskclient/VpnFragment.java index 2e3d7524..9210c6ec 100644 --- a/app/src/main/java/se/leap/bitmaskclient/VpnFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/VpnFragment.java @@ -244,10 +244,7 @@ public class VpnFragment extends Fragment implements Observer { Context context = dashboard.getApplicationContext(); String error = eip_status.lastError(5, context); - if (!error.isEmpty()) { - dashboard.showLog(); - VoidVpnService.stop(); - } + if (!error.isEmpty()) VoidVpnService.stop(); updateIcon(); updateButton(); } -- cgit v1.2.3