summaryrefslogtreecommitdiff
path: root/app/src/main/java/de
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2019-10-25 17:10:13 +0200
committercyBerta <cyberta@riseup.net>2019-10-25 17:10:13 +0200
commit761b604e14b14a86a357816b266e77d458137c83 (patch)
treef3dfefaeee6b71738fd1ae1d670d6392c38a8f2b /app/src/main/java/de
parent6b4f3597733ced8d312ed263d53b9669d6274d65 (diff)
implement error handling for edge case when Android
throws an nullpointer exception while it tries to prepare the VpnService
Diffstat (limited to 'app/src/main/java/de')
-rw-r--r--app/src/main/java/de/blinkt/openvpn/LaunchVPN.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/app/src/main/java/de/blinkt/openvpn/LaunchVPN.java b/app/src/main/java/de/blinkt/openvpn/LaunchVPN.java
index 60e4abb6..70f8e445 100644
--- a/app/src/main/java/de/blinkt/openvpn/LaunchVPN.java
+++ b/app/src/main/java/de/blinkt/openvpn/LaunchVPN.java
@@ -26,7 +26,9 @@ import de.blinkt.openvpn.core.VpnStatus;
import se.leap.bitmaskclient.MainActivity;
import se.leap.bitmaskclient.R;
+import static se.leap.bitmaskclient.Constants.EIP_ACTION_PREPARE_VPN;
import static se.leap.bitmaskclient.Constants.PROVIDER_PROFILE;
+import static se.leap.bitmaskclient.eip.EipResultBroadcast.tellToReceiverOrBroadcast;
/**
* This Activity actually handles two stages of a launcher shortcut's life cycle.
@@ -62,6 +64,7 @@ public class LaunchVPN extends Activity {
private static final int START_VPN_PROFILE = 70;
+ private static final String TAG = LaunchVPN.class.getName();
private VpnProfile mSelectedProfile;
@@ -180,7 +183,15 @@ public class LaunchVPN extends Activity {
return;
}
- Intent intent = VpnService.prepare(this);
+ Intent intent = null;
+ try {
+ intent = VpnService.prepare(this.getApplicationContext());
+ } catch (NullPointerException npe) {
+ tellToReceiverOrBroadcast(this.getApplicationContext(), EIP_ACTION_PREPARE_VPN, RESULT_CANCELED);
+ finish();
+ return;
+ }
+
// Check if we want to fix /dev/tun
SharedPreferences prefs = Preferences.getDefaultSharedPreferences(this);
boolean usecm9fix = prefs.getBoolean("useCM9Fix", false);