diff options
author | cyBerta <cyberta@riseup.net> | 2019-02-16 14:41:57 +0100 |
---|---|---|
committer | cyBerta <cyberta@riseup.net> | 2019-03-09 13:56:58 +0100 |
commit | 5087fa81221937259f9275d6efa0cc1c7fad1454 (patch) | |
tree | 036cbac1212ac012abfc6760b1ba36939c461272 /app/src/main/java/se/leap/bitmaskclient | |
parent | 210332df1df91ce626ebd332c973a1a246a04f6a (diff) |
improve vpn shutdown regarding the new gateway selection
(cherry picked from commit fcc04ae)
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient')
4 files changed, 9 insertions, 19 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java index a535b0cb..2af455f8 100644 --- a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java @@ -350,7 +350,7 @@ public class EipFragment extends Fragment implements Observer { eipStatus = (EipStatus) observable; Activity activity = getActivity(); if (activity != null) { - activity.runOnUiThread(() -> handleNewState()); + activity.runOnUiThread(this::handleNewState); } else { Log.e("EipFragment", "activity is null"); } diff --git a/app/src/main/java/se/leap/bitmaskclient/EipSetupObserver.java b/app/src/main/java/se/leap/bitmaskclient/EipSetupObserver.java index 037a6952..16b8c240 100644 --- a/app/src/main/java/se/leap/bitmaskclient/EipSetupObserver.java +++ b/app/src/main/java/se/leap/bitmaskclient/EipSetupObserver.java @@ -102,8 +102,6 @@ class EipSetupObserver extends BroadcastReceiver implements VpnStatus.StateListe @Override public void onReceive(Context context, Intent intent) { - Log.d(TAG, "received Broadcast"); - String action = intent.getAction(); if (action == null) { return; @@ -125,8 +123,6 @@ class EipSetupObserver extends BroadcastReceiver implements VpnStatus.StateListe } private void handleProviderApiEvent(Intent intent) { - - int resultCode = intent.getIntExtra(BROADCAST_RESULT_CODE, RESULT_CANCELED); Bundle resultData = intent.getParcelableExtra(BROADCAST_RESULT_KEY); if (resultData == null) { @@ -152,12 +148,9 @@ class EipSetupObserver extends BroadcastReceiver implements VpnStatus.StateListe break; } - - for (EipSetupListener listener : listeners) { listener.handleProviderApiEvent(intent); } - } @@ -176,10 +169,6 @@ class EipSetupObserver extends BroadcastReceiver implements VpnStatus.StateListe finishGatewaySetup(false); } break; - case EIP_ACTION_STOP: - //setup was manually cancelled - finishGatewaySetup(false); - break; default: break; } @@ -234,9 +223,10 @@ class EipSetupObserver extends BroadcastReceiver implements VpnStatus.StateListe return; } - Log.d(TAG, "trying gateway: " + setupVpnProfile.getName()); - - if ("CONNECTRETRY".equals(state) && LEVEL_CONNECTING_NO_SERVER_REPLY_YET.equals(level)) { + if (ConnectionStatus.LEVEL_STOPPING == level) { + finishGatewaySetup(false); + } else if ("CONNECTRETRY".equals(state) && LEVEL_CONNECTING_NO_SERVER_REPLY_YET.equals(level)) { + Log.d(TAG, "trying gateway: " + setupVpnProfile.getName()); if (TIMEOUT.equals(logmessage)) { Log.e(TAG, "Timeout reached! Try next gateway!"); VpnStatus.logError("Timeout reached! Try next gateway!"); 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 0779c69d..29e2199f 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java @@ -43,12 +43,13 @@ import java.util.Observer; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; -import de.blinkt.openvpn.LaunchVPN; +import de.blinkt.openvpn.core.ConnectionStatus; import de.blinkt.openvpn.core.IOpenVPNServiceInternal; import de.blinkt.openvpn.core.OpenVPNService; import de.blinkt.openvpn.core.ProfileManager; import de.blinkt.openvpn.core.VpnStatus; import se.leap.bitmaskclient.OnBootReceiver; +import se.leap.bitmaskclient.R; import static android.app.Activity.RESULT_CANCELED; import static android.app.Activity.RESULT_OK; @@ -215,13 +216,10 @@ public final class EIP extends JobIntentService implements Observer { * The {@link OnBootReceiver} will care if there is no profile. */ private void startEIPAlwaysOnVpn() { - Log.d(TAG, "startEIPAlwaysOnVpn vpn"); - GatewaysManager gatewaysManager = gatewaysFromPreferences(); Gateway gateway = gatewaysManager.select(0); if (gateway != null && gateway.getProfile() != null) { - Log.d(TAG, "startEIPAlwaysOnVpn eip launch closest gateway."); launchActiveGateway(gateway, 0); } else { Log.d(TAG, "startEIPAlwaysOnVpn no active profile available!"); @@ -257,6 +255,7 @@ public final class EIP extends JobIntentService implements Observer { * terminates EIP if currently connected or connecting */ private void stopEIP() { + VpnStatus.updateStateString("STOPPING", "STOPPING VPN", R.string.state_exiting, ConnectionStatus.LEVEL_STOPPING); int resultCode = stop() ? RESULT_OK : RESULT_CANCELED; tellToReceiverOrBroadcast(EIP_ACTION_STOP, resultCode); } diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java b/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java index 861f5fd3..20154ac1 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java @@ -115,6 +115,7 @@ public class EipStatus extends Observable implements VpnStatus.StateListener { break; case LEVEL_AUTH_FAILED: case LEVEL_NOTCONNECTED: + case LEVEL_STOPPING: currentEipLevel = EipLevel.DISCONNECTED; break; case LEVEL_NONETWORK: |