summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap
diff options
context:
space:
mode:
authorcyberta <cyberta@riseup.net>2021-02-15 21:38:33 +0000
committercyberta <cyberta@riseup.net>2021-02-15 21:38:33 +0000
commitefd90a35caf042d7955727e4a5d9a12927714ca8 (patch)
tree8a429d2cc592cc093802c237d633556233cb4a7b /app/src/main/java/se/leap
parent50588d08d77529eb84686220cfe3c8816195d46b (diff)
parent4aad61b74f67a025e46fb1d5b4b96d916104912f (diff)
Merge branch 'faster_gateway_switch' into 'master'
switch faster to next gateway during eip setup if current one is not responsive Closes #9022 See merge request leap/bitmask_android!124
Diffstat (limited to 'app/src/main/java/se/leap')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java7
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/EipSetupObserver.java21
2 files changed, 4 insertions, 24 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java b/app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java
index d8501a92..4ff80ea6 100644
--- a/app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java
@@ -55,7 +55,6 @@ import butterknife.Unbinder;
import de.blinkt.openvpn.core.IOpenVPNServiceInternal;
import de.blinkt.openvpn.core.OpenVPNService;
import de.blinkt.openvpn.core.VpnStatus;
-import se.leap.bitmaskclient.providersetup.ProviderListActivity;
import se.leap.bitmaskclient.R;
import se.leap.bitmaskclient.base.FragmentManagerEnhanced;
import se.leap.bitmaskclient.base.models.Provider;
@@ -64,6 +63,7 @@ import se.leap.bitmaskclient.base.views.VpnStateImage;
import se.leap.bitmaskclient.eip.EipCommand;
import se.leap.bitmaskclient.eip.EipStatus;
import se.leap.bitmaskclient.providersetup.ProviderAPICommand;
+import se.leap.bitmaskclient.providersetup.ProviderListActivity;
import se.leap.bitmaskclient.providersetup.activities.CustomProviderSetupActivity;
import se.leap.bitmaskclient.providersetup.activities.LoginActivity;
import se.leap.bitmaskclient.providersetup.models.LeapSRPSession;
@@ -83,7 +83,6 @@ import static se.leap.bitmaskclient.base.models.Constants.REQUEST_CODE_SWITCH_PR
import static se.leap.bitmaskclient.base.models.Constants.SHARED_PREFERENCES;
import static se.leap.bitmaskclient.base.utils.ConfigHelper.isDefaultBitmask;
import static se.leap.bitmaskclient.base.utils.ViewHelper.convertDimensionToPx;
-import static se.leap.bitmaskclient.eip.EipSetupObserver.connectionRetry;
import static se.leap.bitmaskclient.eip.EipSetupObserver.gatewayOrder;
import static se.leap.bitmaskclient.eip.EipSetupObserver.reconnectingWithDifferentGateway;
import static se.leap.bitmaskclient.providersetup.ProviderAPI.DOWNLOAD_GEOIP_JSON;
@@ -475,10 +474,6 @@ public class EipFragment extends Fragment implements Observer {
toast.setView(layout);
toast.show();
}
- private void showReconnectToast(Activity activity) {
- String message = (String.format("Retry %d of %d before the next closest gateway will be selected.", connectionRetry()+1, 5));
- showToast(activity, message, false);
- }
private void showRetryToast(Activity activity) {
int nClosestGateway = gatewayOrder();
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/EipSetupObserver.java b/app/src/main/java/se/leap/bitmaskclient/eip/EipSetupObserver.java
index 1c101e2d..f35e5e30 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/EipSetupObserver.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/EipSetupObserver.java
@@ -74,15 +74,12 @@ public class EipSetupObserver extends BroadcastReceiver implements VpnStatus.Sta
private static final String TAG = EipSetupObserver.class.getName();
- //The real timout is 4*2s + 1*4s + 1*8s + 1*16s + 1*32s + 1*64s = 132 s;
- private static final String TIMEOUT = "4";
private static final int UPDATE_CHECK_TIMEOUT = 1000*60*60*24*7;
private Context context;
private VpnProfile setupVpnProfile;
private String observedProfileFromVpnStatus;
AtomicBoolean changingGateway = new AtomicBoolean(false);
AtomicInteger setupNClosestGateway = new AtomicInteger();
- AtomicInteger reconnectTry = new AtomicInteger();
private Vector<EipSetupListener> listeners = new Vector<>();
private SharedPreferences preferences;
private static EipSetupObserver instance;
@@ -109,10 +106,6 @@ public class EipSetupObserver extends BroadcastReceiver implements VpnStatus.Sta
return instance.setupNClosestGateway.get() > 0;
}
- public static int connectionRetry() {
- return instance.reconnectTry.get();
- }
-
public static int gatewayOrder() {
return instance.setupNClosestGateway.get();
}
@@ -293,15 +286,9 @@ public class EipSetupObserver extends BroadcastReceiver implements VpnStatus.Sta
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!");
- selectNextGateway();
- return;
- }
- int current = reconnectTry.get();
- reconnectTry.set(current + 1);
+ Log.e(TAG, "Timeout reached! Try next gateway!");
+ VpnStatus.logError("Timeout reached! Try next gateway!");
+ selectNextGateway();
} else if ("NOPROCESS".equals(state) && LEVEL_NOTCONNECTED == level) {
//??
} else if ("CONNECTED".equals(state)) {
@@ -327,7 +314,6 @@ public class EipSetupObserver extends BroadcastReceiver implements VpnStatus.Sta
private void selectNextGateway() {
changingGateway.set(true);
- reconnectTry.set(0);
EipCommand.startVPN(context.getApplicationContext(), false, setupNClosestGateway.get() + 1);
}
@@ -337,7 +323,6 @@ public class EipSetupObserver extends BroadcastReceiver implements VpnStatus.Sta
setupNClosestGateway.set(0);
observedProfileFromVpnStatus = null;
this.changingGateway.set(changingGateway);
- this.reconnectTry.set(0);
}
/**