summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnLauncher.java
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2021-02-26 13:13:29 +0100
committercyBerta <cyberta@riseup.net>2021-02-26 13:13:29 +0100
commit704bdf92e6265ee4bdb7e177c7d09284ebc29868 (patch)
treec2adecb59abc4fd344272d55e1829ad03d5e07fd /app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnLauncher.java
parente1b6c1a9c4e9cf9849ceb37bf775ba28cc539bff (diff)
Bigger refactoring:
* always use a bound service connection to start a vpn service as foreground service to fix remote excptions. These appeared if the system wasn't able to set the service as forground shortly after it was started * move vpn start logic from LaunchVPN activity to EIP service. LaunchVPN/VoidVPNLauncher is only used in case we need to ask the user for a permission. It reduces visual glitches when the transparent LaunchVPN activity appears and disappears
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnLauncher.java')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnLauncher.java13
1 files changed, 2 insertions, 11 deletions
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 e6905448..6d6b24c8 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnLauncher.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnLauncher.java
@@ -3,11 +3,8 @@ package se.leap.bitmaskclient.eip;
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.base.models.Constants.EIP_ACTION_START_BLOCKING_VPN;
-
public class VoidVpnLauncher extends Activity {
private static final int VPN_USER_PERMISSION = 71;
@@ -23,20 +20,14 @@ public class VoidVpnLauncher extends Activity {
if (blocking_intent != null)
startActivityForResult(blocking_intent, VPN_USER_PERMISSION);
else {
- onActivityResult(VPN_USER_PERMISSION, RESULT_OK, null);
+ EipCommand.startBlockingVPN(getApplicationContext());
}
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == VPN_USER_PERMISSION) {
if (resultCode == RESULT_OK) {
- Intent void_vpn_service = new Intent(getApplicationContext(), VoidVpnService.class);
- void_vpn_service.setAction(EIP_ACTION_START_BLOCKING_VPN);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- startForegroundService(void_vpn_service);
- } else {
- startService(void_vpn_service);
- }
+ EipCommand.launchVoidVPN(getApplicationContext());
}
}
finish();