summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2014-11-05 11:31:26 +0100
committerArne Schwabe <arne@rfc2549.org>2014-11-05 11:31:26 +0100
commit0b63f8d6a3d662be4c88c9d04740da3e8f1816e6 (patch)
tree79f19efd0d41bc6e225a63514ede2d58d8fb1fd3 /main
parent77d86701ef8e2c018e627fd2eb6f9abe73026940 (diff)
Fix starting VPN without permission when called from external servicev0.6.20
Diffstat (limited to 'main')
-rw-r--r--main/build.gradle4
-rw-r--r--main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java25
2 files changed, 24 insertions, 5 deletions
diff --git a/main/build.gradle b/main/build.gradle
index 750c3eb9..58565e73 100644
--- a/main/build.gradle
+++ b/main/build.gradle
@@ -20,8 +20,8 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
- versionCode = 100
- versionName = "0.6.19"
+ versionCode = 101
+ versionName = "0.6.20"
}
sourceSets {
diff --git a/main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java b/main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java
index d1cdafc7..4b07c7ab 100644
--- a/main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java
+++ b/main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java
@@ -22,6 +22,8 @@ import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.VpnService;
import android.os.*;
+
+import de.blinkt.openvpn.LaunchVPN;
import de.blinkt.openvpn.R;
import de.blinkt.openvpn.VpnProfile;
import de.blinkt.openvpn.core.ConfigParser;
@@ -112,12 +114,30 @@ public class ExternalOpenVPNService extends Service implements StateListener {
return profiles;
}
+
+ private void startProfile(VpnProfile vp)
+ {
+ Intent vpnPermissionIntent = VpnService.prepare(ExternalOpenVPNService.this);
+ /* Check if we need to show the confirmation dialog */
+ if(vpnPermissionIntent != null){
+ Intent shortVPNIntent = new Intent(Intent.ACTION_MAIN);
+ shortVPNIntent.setClass(getBaseContext(), de.blinkt.openvpn.LaunchVPN.class);
+ shortVPNIntent.putExtra(de.blinkt.openvpn.LaunchVPN.EXTRA_KEY, vp.getUUIDString());
+ shortVPNIntent.putExtra(de.blinkt.openvpn.LaunchVPN.EXTRA_HIDELOG, true);
+ shortVPNIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ startActivity(shortVPNIntent);
+ } else {
+ VPNLaunchHelper.startOpenVpn(vp, getBaseContext());
+ }
+
+ }
+
@Override
public void startProfile(String profileUUID) throws RemoteException {
checkOpenVPNPermission();
VpnProfile vp = ProfileManager.get(getBaseContext(), profileUUID);
- VPNLaunchHelper.startOpenVpn(vp, getBaseContext());
+ startProfile(vp);
}
public void startVPN(String inlineconfig) throws RemoteException {
@@ -132,8 +152,7 @@ public class ExternalOpenVPNService extends Service implements StateListener {
ProfileManager.setTemporaryProfile(vp);
- VPNLaunchHelper.startOpenVpn(vp, getBaseContext());
-
+ startProfile(vp);
} catch (IOException e) {
throw new RemoteException(e.getMessage());