summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorcyberta <cyberta@riseup.net>2021-12-11 16:30:36 +0000
committercyberta <cyberta@riseup.net>2021-12-11 16:30:36 +0000
commit42a3735356881633004dfb6ed3c60fe8b7d26689 (patch)
tree9f54e737b24f9877938e79dd5726cb084be02d7e /app
parent5aaa3bb1c83d486e300eb98876eab26ad4325b82 (diff)
parente7c09efba8a06bc7a000d525aff5ac027339023e (diff)
Merge branch 'bugfixes' into 'master'
bug fixes See merge request leap/bitmask_android!153
Diffstat (limited to 'app')
-rw-r--r--app/src/main/AndroidManifest.xml2
-rw-r--r--app/src/main/java/de/blinkt/openvpn/core/DeviceStateReceiver.java9
-rw-r--r--app/src/main/java/de/blinkt/openvpn/core/NetworkUtils.java36
-rw-r--r--app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java2
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/BitmaskTileService.java4
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/MainActivity.java6
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/StartActivity.java6
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java6
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/fragments/GatewaySelectionFragment.java12
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/EIP.java2
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/EipCommand.java4
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/EipSetupObserver.java12
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnLauncher.java4
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderAPI.java2
14 files changed, 58 insertions, 49 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 2e9d2ade..75b166d9 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -35,7 +35,7 @@
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
- android:extractNativeLibs="false"
+ android:extractNativeLibs="true"
android:appCategory="productivity"
android:logo="@mipmap/ic_launcher"
android:theme="@style/BitmaskTheme">
diff --git a/app/src/main/java/de/blinkt/openvpn/core/DeviceStateReceiver.java b/app/src/main/java/de/blinkt/openvpn/core/DeviceStateReceiver.java
index 13417a5a..2b0c785e 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/DeviceStateReceiver.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/DeviceStateReceiver.java
@@ -45,7 +45,7 @@ public class DeviceStateReceiver extends BroadcastReceiver implements ByteCountL
connectState userpause = connectState.SHOULDBECONNECTED;
private String lastStateMsg = null;
- private java.lang.Runnable mDelayDisconnectRunnable = new Runnable() {
+ private final java.lang.Runnable mDelayDisconnectRunnable = new Runnable() {
@Override
public void run() {
if (!(network == connectState.PENDINGDISCONNECT))
@@ -83,7 +83,7 @@ public class DeviceStateReceiver extends BroadcastReceiver implements ByteCountL
long data;
}
- private LinkedList<Datapoint> trafficdata = new LinkedList<>();
+ private final LinkedList<Datapoint> trafficdata;
@Override
@@ -128,9 +128,10 @@ public class DeviceStateReceiver extends BroadcastReceiver implements ByteCountL
}
}
- public DeviceStateReceiver(OpenVPNManagement magnagement) {
+ public DeviceStateReceiver(OpenVPNManagement management) {
super();
- mManagement = magnagement;
+ trafficdata = new LinkedList<>();
+ mManagement = management;
mManagement.setPauseCallback(this);
mDisconnectHandler = new Handler();
}
diff --git a/app/src/main/java/de/blinkt/openvpn/core/NetworkUtils.java b/app/src/main/java/de/blinkt/openvpn/core/NetworkUtils.java
index a4f09806..5b11c0a0 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/NetworkUtils.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/NetworkUtils.java
@@ -27,28 +27,32 @@ public class NetworkUtils {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Network[] networks = conn.getAllNetworks();
for (Network network : networks) {
- NetworkInfo ni = conn.getNetworkInfo(network);
- LinkProperties li = conn.getLinkProperties(network);
+ try {
+ NetworkInfo ni = conn.getNetworkInfo(network);
+ LinkProperties li = conn.getLinkProperties(network);
- NetworkCapabilities nc = conn.getNetworkCapabilities(network);
+ NetworkCapabilities nc = conn.getNetworkCapabilities(network);
- if (nc == null) {
- continue;
- }
+ if (nc == null) {
+ continue;
+ }
- // Skip VPN networks like ourselves
- if (nc.hasTransport(NetworkCapabilities.TRANSPORT_VPN))
- continue;
+ // Skip VPN networks like ourselves
+ if (nc.hasTransport(NetworkCapabilities.TRANSPORT_VPN))
+ continue;
- // Also skip mobile networks
- if (nc.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR))
- continue;
+ // Also skip mobile networks
+ if (nc.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR))
+ continue;
- for (LinkAddress la : li.getLinkAddresses()) {
- if ((la.getAddress() instanceof Inet4Address && !ipv6) ||
- (la.getAddress() instanceof Inet6Address && ipv6))
- nets.add(la.toString());
+ for (LinkAddress la : li.getLinkAddresses()) {
+ if ((la.getAddress() instanceof Inet4Address && !ipv6) ||
+ (la.getAddress() instanceof Inet6Address && ipv6))
+ nets.add(la.toString());
+ }
+ } catch (SecurityException se) {
+ se.printStackTrace();
}
}
} else {
diff --git a/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java b/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java
index ae38a59b..d624af80 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java
@@ -410,7 +410,7 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac
// An old running VPN should now be exited
mStarting = false;
- if (mProfile.mUsePluggableTransports) {
+ if (mProfile.mUsePluggableTransports && connection instanceof Obfs4Connection) {
Obfs4Connection obfs4Connection = (Obfs4Connection) connection;
if (shapeshifter == null) {
shapeshifter = new Shapeshifter(obfs4Connection.getDispatcherOptions());
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/BitmaskTileService.java b/app/src/main/java/se/leap/bitmaskclient/base/BitmaskTileService.java
index 4a8b1236..65355a67 100644
--- a/app/src/main/java/se/leap/bitmaskclient/base/BitmaskTileService.java
+++ b/app/src/main/java/se/leap/bitmaskclient/base/BitmaskTileService.java
@@ -43,9 +43,9 @@ public class BitmaskTileService extends TileService implements Observer {
private void onTileTap() {
EipStatus eipStatus = EipStatus.getInstance();
if (eipStatus.isConnecting() || eipStatus.isBlocking() || eipStatus.isConnected() || eipStatus.isReconnecting()) {
- EipCommand.stopVPN(getApplicationContext());
+ EipCommand.stopVPN(this);
} else {
- EipCommand.startVPN(getApplicationContext(), false);
+ EipCommand.startVPN(this, false);
}
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/MainActivity.java b/app/src/main/java/se/leap/bitmaskclient/base/MainActivity.java
index 77743eac..aea397fb 100644
--- a/app/src/main/java/se/leap/bitmaskclient/base/MainActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/base/MainActivity.java
@@ -217,14 +217,14 @@ public class MainActivity extends AppCompatActivity implements EipSetupListener,
switch (requestCode) {
case REQUEST_CODE_SWITCH_PROVIDER:
- EipCommand.stopVPN(this.getApplicationContext());
- EipCommand.startVPN(this.getApplicationContext(), false);
+ EipCommand.stopVPN(this);
+ EipCommand.startVPN(this, false);
break;
case REQUEST_CODE_CONFIGURE_LEAP:
Log.d(TAG, "REQUEST_CODE_CONFIGURE_LEAP - onActivityResult - MainActivity");
break;
case REQUEST_CODE_LOG_IN:
- EipCommand.startVPN(this.getApplicationContext(), true);
+ EipCommand.startVPN(this, true);
break;
}
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/StartActivity.java b/app/src/main/java/se/leap/bitmaskclient/base/StartActivity.java
index 9d689e5d..1ea574ff 100644
--- a/app/src/main/java/se/leap/bitmaskclient/base/StartActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/base/StartActivity.java
@@ -189,11 +189,11 @@ public class StartActivity extends Activity{
} else {
Log.d(TAG, "vpn provider is configured");
if (getIntent() != null && getIntent().getBooleanExtra(EIP_RESTART_ON_BOOT, false)) {
- EipCommand.startVPN(this.getApplicationContext(), true);
+ EipCommand.startVPN(this, true);
finish();
} else if (PreferenceHelper.getRestartOnUpdate(this.getApplicationContext())) {
PreferenceHelper.restartOnUpdate(this.getApplicationContext(), false);
- EipCommand.startVPN(this.getApplicationContext(), false);
+ EipCommand.startVPN(this, false);
showMainActivity();
finish();
} else {
@@ -224,7 +224,7 @@ public class StartActivity extends Activity{
Provider provider = data.getParcelableExtra(Provider.KEY);
storeProviderInPreferences(preferences, provider);
ProviderObservable.getInstance().updateProvider(provider);
- EipCommand.startVPN(this.getApplicationContext(), false);
+ EipCommand.startVPN(this, false);
showMainActivity();
} else if (resultCode == RESULT_CANCELED) {
finish();
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 14673874..07057d6e 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
@@ -336,9 +336,9 @@ public class EipFragment extends Fragment implements Observer {
Bundle bundle = new Bundle();
bundle.putBoolean(EIP_ACTION_START, true);
bundle.putBoolean(EIP_EARLY_ROUTES, false);
- ProviderAPICommand.execute(getContext().getApplicationContext(), DOWNLOAD_GEOIP_JSON, bundle, provider);
+ ProviderAPICommand.execute(context, DOWNLOAD_GEOIP_JSON, bundle, provider);
} else {
- EipCommand.startVPN(context.getApplicationContext(), false);
+ EipCommand.startVPN(context, false);
}
EipStatus.getInstance().updateState("UI_CONNECTING", "", 0, ConnectionStatus.LEVEL_START);
}
@@ -349,7 +349,7 @@ public class EipFragment extends Fragment implements Observer {
Log.e(TAG, "context is null when trying to stop EIP");
return;
}
- EipCommand.stopVPN(context.getApplicationContext());
+ EipCommand.stopVPN(context);
}
private void askPendingStartCancellation() {
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/fragments/GatewaySelectionFragment.java b/app/src/main/java/se/leap/bitmaskclient/base/fragments/GatewaySelectionFragment.java
index 4e7bb6ab..f2c3b2d6 100644
--- a/app/src/main/java/se/leap/bitmaskclient/base/fragments/GatewaySelectionFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/base/fragments/GatewaySelectionFragment.java
@@ -176,10 +176,14 @@ public class GatewaySelectionFragment extends Fragment implements Observer, Loca
}
PreferenceHelper.setPreferredCity(context, preferredCity);
EipCommand.startVPN(context, false);
- Intent intent = new Intent(getContext(), MainActivity.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
- intent.setAction(ACTION_SHOW_VPN_FRAGMENT);
- startActivity(intent);
+ try {
+ Intent intent = new Intent(context, MainActivity.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ intent.setAction(ACTION_SHOW_VPN_FRAGMENT);
+ context.startActivity(intent);
+ } catch (NullPointerException npe) {
+ npe.printStackTrace();
+ }
}).start();
}
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 4db8f0c2..cf4dc9bf 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java
@@ -136,7 +136,7 @@ public final class EIP extends JobIntentService implements Observer {
static void enqueueWork(Context context, Intent work) {
try {
enqueueWork(context, EIP.class, JOB_ID, work);
- } catch (IllegalStateException e) {
+ } catch (IllegalStateException | IllegalArgumentException e) {
e.printStackTrace();
}
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/EipCommand.java b/app/src/main/java/se/leap/bitmaskclient/eip/EipCommand.java
index 46704419..b5229b0a 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/EipCommand.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/EipCommand.java
@@ -28,7 +28,7 @@ import static se.leap.bitmaskclient.base.models.Constants.PROVIDER_PROFILE;
public class EipCommand {
private static void execute(@NonNull Context context, @NonNull String action) {
- execute(context.getApplicationContext(), action, null, null);
+ execute(context, action, null, null);
}
/**
@@ -46,7 +46,7 @@ public class EipCommand {
vpnIntent.setAction(action);
if (resultReceiver != null)
vpnIntent.putExtra(EIP_RECEIVER, resultReceiver);
- EIP.enqueueWork(context, vpnIntent);
+ EIP.enqueueWork(context.getApplicationContext(), vpnIntent);
}
public static void startVPN(@NonNull Context context, boolean earlyRoutes) {
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 4e5016f0..beed35d1 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/EipSetupObserver.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/EipSetupObserver.java
@@ -193,14 +193,14 @@ public class EipSetupObserver extends BroadcastReceiver implements VpnStatus.Sta
ProviderObservable.getInstance().updateProvider(provider);
PreferenceHelper.storeProviderInPreferences(preferences, provider);
if (EipStatus.getInstance().isDisconnected()) {
- EipCommand.startVPN(context.getApplicationContext(), false);
+ EipCommand.startVPN(context, false);
}
break;
case CORRECTLY_UPDATED_INVALID_VPN_CERTIFICATE:
provider = resultData.getParcelable(PROVIDER_KEY);
ProviderObservable.getInstance().updateProvider(provider);
PreferenceHelper.storeProviderInPreferences(preferences, provider);
- EipCommand.startVPN(context.getApplicationContext(), false);
+ EipCommand.startVPN(context, false);
break;
case CORRECTLY_DOWNLOADED_GEOIP_JSON:
provider = resultData.getParcelable(PROVIDER_KEY);
@@ -235,7 +235,7 @@ public class EipSetupObserver extends BroadcastReceiver implements VpnStatus.Sta
private void maybeStartEipService(Bundle resultData) {
if (resultData.getBoolean(EIP_ACTION_START)) {
boolean earlyRoutes = resultData.getBoolean(EIP_EARLY_ROUTES);
- EipCommand.startVPN(context.getApplicationContext(), earlyRoutes);
+ EipCommand.startVPN(context, earlyRoutes);
}
}
@@ -262,7 +262,7 @@ public class EipSetupObserver extends BroadcastReceiver implements VpnStatus.Sta
switch (error) {
case NO_MORE_GATEWAYS:
finishGatewaySetup(false);
- EipCommand.startBlockingVPN(context.getApplicationContext());
+ EipCommand.startBlockingVPN(context);
break;
case ERROR_INVALID_PROFILE:
selectNextGateway();
@@ -364,7 +364,7 @@ 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);
+ EipCommand.startVPN(context, false, setupNClosestGateway.get() + 1);
}
private void finishGatewaySetup(boolean changingGateway) {
@@ -396,7 +396,7 @@ public class EipSetupObserver extends BroadcastReceiver implements VpnStatus.Sta
case SHAPESHIFTER:
VpnProfile profile = VpnStatus.getLastConnectedVpnProfile();
if (profile == null) {
- EipCommand.startVPN(context.getApplicationContext(), false, 0);
+ EipCommand.startVPN(context, false, 0);
} else {
GatewaysManager gatewaysManager = new GatewaysManager(context.getApplicationContext());
int position = gatewaysManager.getPosition(profile);
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 e2cd86b9..a8494e2b 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnLauncher.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnLauncher.java
@@ -30,14 +30,14 @@ public class VoidVpnLauncher extends Activity {
startActivityForResult(blockingIntent, VPN_USER_PERMISSION);
}
else {
- EipCommand.startBlockingVPN(getApplicationContext());
+ EipCommand.startBlockingVPN(this);
}
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == VPN_USER_PERMISSION) {
if (resultCode == RESULT_OK) {
- EipCommand.launchVoidVPN(getApplicationContext());
+ EipCommand.launchVoidVPN(this);
}
}
finish();
diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderAPI.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderAPI.java
index 709ca651..022ad040 100644
--- a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderAPI.java
+++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderAPI.java
@@ -117,7 +117,7 @@ public class ProviderAPI extends JobIntentService implements ProviderApiManagerB
static void enqueueWork(Context context, Intent work) {
try {
ProviderAPI.enqueueWork(context, ProviderAPI.class, JOB_ID, work);
- } catch (IllegalStateException e) {
+ } catch (IllegalStateException | IllegalArgumentException e) {
e.printStackTrace();
}
}