From 88decce426a0ef9e24db42ce0385cb9d66b01bfb Mon Sep 17 00:00:00 2001 From: Jens Date: Fri, 7 May 2021 23:11:43 +0200 Subject: [PATCH] Wireguard integration --- .idea/runConfigurations.xml | 10 ++++++++++ app/src/apkFlavor/AndroidManifest.xml | 1 + app/src/fdroidFlavor/AndroidManifest.xml | 2 ++ app/src/googlePlayFlavor/AndroidManifest.xml | 2 ++ app/src/main/java/com/jens/automation2/Actions.java | 4 ++++ .../java/com/jens/automation2/ActivityPermissions.java | 9 +++++++++ app/src/main/res/values/strings.xml | 1 + build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 9 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 .idea/runConfigurations.xml diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 00000000..797acea5 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/app/src/apkFlavor/AndroidManifest.xml b/app/src/apkFlavor/AndroidManifest.xml index 8137dc3d..b82e81ff 100644 --- a/app/src/apkFlavor/AndroidManifest.xml +++ b/app/src/apkFlavor/AndroidManifest.xml @@ -63,6 +63,7 @@ + diff --git a/app/src/fdroidFlavor/AndroidManifest.xml b/app/src/fdroidFlavor/AndroidManifest.xml index d3a0df13..aa9a26b0 100644 --- a/app/src/fdroidFlavor/AndroidManifest.xml +++ b/app/src/fdroidFlavor/AndroidManifest.xml @@ -60,6 +60,8 @@ + + + + suResult = null; final static String smsSeparator = "&sms&"; + public static final String wireguard_tunnel_up = "com.wireguard.android.action.SET_TUNNEL_UP"; + public static final String wireguard_tunnel_down = "com.wireguard.android.action.SET_TUNNEL_DOWN"; + public static final String wireguard_tunnel_refresh = "com.wireguard.android.action.REFRESH_TUNNEL_STATES"; + public static Boolean setWifi(Context context, Boolean desiredState, boolean toggleActionIfPossible) { Miscellaneous.logEvent("i", "Wifi", "Changing Wifi to " + String.valueOf(desiredState), 4); diff --git a/app/src/main/java/com/jens/automation2/ActivityPermissions.java b/app/src/main/java/com/jens/automation2/ActivityPermissions.java index cbf27490..a6297219 100644 --- a/app/src/main/java/com/jens/automation2/ActivityPermissions.java +++ b/app/src/main/java/com/jens/automation2/ActivityPermissions.java @@ -55,6 +55,7 @@ public class ActivityPermissions extends Activity public static final String permissionNameCall = "android.permission.PROCESS_OUTGOING_CALLS"; public static final String permissionNameStartService = "android.permission.FOREGROUND_SERVICE"; public static final String permissionNameReadNotifications = "android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"; + public static final String permissionNameWireguard = "com.wireguard.android.permission.CONTROL_TUNNELS"; public static ActivityPermissions getInstance() { @@ -534,6 +535,14 @@ public class ActivityPermissions extends Activity case speakText: break; case startOtherActivity: + if( + action.getParameter2().contains(Actions.wireguard_tunnel_up) + || + action.getParameter2().contains(Actions.wireguard_tunnel_down) + || + action.getParameter2().contains(Actions.wireguard_tunnel_refresh) + ) + addToArrayListUnique(ActivityPermissions.permissionNameWireguard, requiredPermissions); break; case triggerUrl: addToArrayListUnique("android.permission.INTERNET", requiredPermissions); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 72a8ca45..944ef599 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -639,4 +639,5 @@ There was an error running a rule. Cannot find sound file %1$s and therefore not play it. Add parameters + Control tunnels of the wireguard app \ No newline at end of file diff --git a/build.gradle b/build.gradle index 0363d651..ea1cd531 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:4.1.3' + classpath 'com.android.tools.build:gradle:4.2.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index adf5e450..e5240a57 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip