Skip to content

Commit 9eb5326

Browse files
committed
Initial commit
0 parents  commit 9eb5326

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1345
-0
lines changed

.gitignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx

LICENSE

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
This is free and unencumbered software released into the public domain.
2+
3+
Anyone is free to copy, modify, publish, use, compile, sell, or
4+
distribute this software, either in source code form or as a compiled
5+
binary, for any purpose, commercial or non-commercial, and by any
6+
means.
7+
8+
In jurisdictions that recognize copyright laws, the author or authors
9+
of this software dedicate any and all copyright interest in the
10+
software to the public domain. We make this dedication for the benefit
11+
of the public at large and to the detriment of our heirs and
12+
successors. We intend this dedication to be an overt act of
13+
relinquishment in perpetuity of all present and future rights to this
14+
software under copyright law.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.
23+
24+
For more information, please refer to <http://unlicense.org/>

README.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Tasker WireGuard Tunnel Automation
2+
3+
## About
4+
5+
Helper to Automate spinning up and shutting down WireGuard tunnel via Tasker Automation (or compatible API)
6+
7+
## Usage
8+
9+
This section needs to be updated. I use a [MacroDroid](https://www.macrodroid.com/) with Android QuickTile and with following config.
10+
11+
##### App Intend Config
12+
13+
`````net.evolution515.taskerwgtunnel/.MainActivity%IntentReceiver
14+
net.evolution515.taskerwgtunnel/.MainActivity$IntentReceiver
15+
`````
16+
17+
````
18+
com.wireguard.android.action.SET_TUNNEL_UP
19+
````
20+
21+
```
22+
tunnek="TunnelName"
23+
```
24+
25+
##### MacroDroid
26+
27+
- Connect [macro](Connect_to_Asgard.macro) [png](Connect_to_Asgard.png)
28+
- Disconnect [macro](Disconnect_Asgard.macro) [png](Disconnect_Asgard.png)
29+
30+
##### Termux
31+
32+
Additionally I use a [Termux](https://termux.com/) script (`.termux/tasker/sleep-asgard`).
33+
34+
```
35+
!#/bin/sh
36+
37+
ssh asgard "(sleep 1; sudo pm-suspend) & disown" &
38+
termux-toast -s "Asgard is now asleep"
39+
```
40+

SCRAPPAD

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
s what Tasker will need to do to allow this:
2+
3+
Add to the manifest XML:
4+
5+
<uses-permission android:name="com.wireguard.android.permission.CONTROL_TUNNELS"/>
6+
Add to your program:
7+
8+
ActivityCompat.requestPermissions(this, new String[]{"com.wireguard.android.permission.CONTROL_TUNNELS"}, someRequestNumber)
9+
https://developer.android.com/reference/androidx/core/app/ActivityCompat#requestPermissions(android.app.Activity,%20java.lang.String[],%20int)
10+
11+
After the permission is granted, you will be able to send tunnel up/down requests to WireGuard:
12+
13+
App: com.wireguard.android
14+
15+
Intent: com.wireguard.android.action.SET_TUNNEL_UP
16+
17+
Intent: com.wireguard.android.action.SET_TUNNEL_DOWN
18+
Intent extra: "tunnel" = "SOME_TUNNEL_NAME"
19+
20+
adb shell
21+
pm list packages | grep wire
22+
pm grant com.arlosoft.macrodroid android.permission.WRITE_SECURE_SETTINGS
23+
pm grant com.wireguard.android.permission.CONTROL_TUNNELS
24+
pm grant com.arlosoft.macrodroid android.permission.WRITE_SECURE_SETTINGS
25+
pm grant com.wireguard.android android.permission.CONTROL_TUNNELS
26+
pm grant --user 0 com.arlosoft.macrodroid com.wireguard.android.permission.CONTROL_TUNNELS
27+
pm grant com.wireguard.android com.wireguard.android.permission.CONTROL_TUNNELS
28+
29+
adb -d shell pm grant com.oasisfeng.greenify android.permission.DUMP
30+
Accessibility service run-on-demand:
31+
adb -d shell pm grant com.oasisfeng.greenify android.permission.WRITE_SECURE_SETTINGS
32+
Aggressive Doze on Android 7.0+ (non-root):
33+
adb -d shell pm grant com.oasisfeng.greenify android.permission.WRITE_SECURE_SETTINGS
34+
Doze on the Go:
35+
adb -d shell pm grant com.oasisfeng.greenify android.permission.DUMP
36+
Aggressive Doze (on device/ROM with Doze disabled):
37+
adb -d shell pm grant com.oasisfeng.greenify android.permission.DUMP
38+
Wake-up Tracker:
39+
adb -d shell pm grant com.oasisfeng.greenify android.permission.READ_LOGS
40+
Wake-up Cut-off: (Android 4.4~5.x)
41+
adb -d shell pm grant com.oasisfeng.greenify android.permission.READ_LOGS
42+
adb -d shell pm grant com.oasisfeng.greenify android.permission.WRITE_SECURE_SETTINGS
43+
Background-free enforcement on Android 8+ (non-root):
44+
adb -d shell pm grant com.oasisfeng.greenify android.permission.GET_APP_OPS_STATS
45+
46+
adb shell "pm list packages"|cut -f 2 -d ":"
47+
48+
pm grant net.jroot3d.joneplustools android.permission.WRITE_SECURE_SETTINGS
49+
50+
pm grant com.arlosoft.macrodroid android.permission.WRITE_SECURE_SETTINGS
51+
52+
App: com.wireguard.android
53+
54+
Intent: com.wireguard.android.action.SET_TUNNEL_UP
55+
56+
Intent: com.wireguard.android.action.SET_TUNNEL_DOWN
57+
58+
Intent extra: "tunnel" = "SOME_TUNNEL_NAME"
59+
60+
61+
am broadcast -a com.wireguard.android.action.SET_TUNNEL_UP -n com.wireguard.android/.TunnelToggleActivity --es tunnel Asgard
62+
63+
am broadcast -a com.wireguard.android.action.SET_TUNNEL_UP -n .model.TunnelManager$IntentReceiver --es tunner Asgard
64+
adb shell am broadcast -a com.whereismywifeserver.intent.TEST
65+
--es sms_body "test from adb"
66+

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
apply plugin: 'com.android.application'
2+
apply plugin: 'kotlin-android'
3+
apply plugin: 'kotlin-android-extensions'
4+
5+
android {
6+
compileSdkVersion 29
7+
buildToolsVersion "29.0.3"
8+
9+
defaultConfig {
10+
applicationId "net.evolution515.taskerwgtunnel"
11+
minSdkVersion 16
12+
targetSdkVersion 29
13+
versionCode 1
14+
versionName "1.0"
15+
16+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17+
}
18+
19+
buildTypes {
20+
release {
21+
minifyEnabled false
22+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23+
}
24+
}
25+
}
26+
27+
dependencies {
28+
implementation fileTree(dir: "libs", include: ["*.jar"])
29+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
30+
implementation 'androidx.core:core-ktx:1.3.0'
31+
implementation 'androidx.appcompat:appcompat:1.1.0'
32+
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
33+
implementation 'com.google.android.material:material:1.1.0'
34+
implementation 'com.google.code.gson:gson:2.8.6'
35+
testImplementation 'junit:junit:4.12'
36+
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
37+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
38+
}

app/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile

app/release/app-release.apk

2.71 MB
Binary file not shown.

app/release/output.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"version": 1,
3+
"artifactType": {
4+
"type": "APK",
5+
"kind": "Directory"
6+
},
7+
"applicationId": "net.evolution515.taskerwgtunnel",
8+
"variantName": "release",
9+
"elements": [
10+
{
11+
"type": "SINGLE",
12+
"filters": [],
13+
"properties": [],
14+
"versionCode": 1,
15+
"versionName": "1",
16+
"enabled": true,
17+
"outputFile": "app-release.apk"
18+
}
19+
]
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package net.evolution515.taskerwgtunnel
2+
3+
import androidx.test.platform.app.InstrumentationRegistry
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("net.evolution515.taskerwgtunnel", appContext.packageName)
23+
}
24+
}

app/src/main/AndroidManifest.xml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="net.evolution515.taskerwgtunnel">
4+
5+
<uses-permission android:name="com.wireguard.android.permission.CONTROL_TUNNELS"/>
6+
7+
<application
8+
android:allowBackup="true"
9+
android:icon="@mipmap/ic_launcher"
10+
android:label="@string/app_name"
11+
android:roundIcon="@mipmap/ic_launcher_round"
12+
android:supportsRtl="true"
13+
android:theme="@style/AppTheme">
14+
15+
<receiver
16+
android:name=".MainActivity$IntentReceiver">
17+
<intent-filter>
18+
<action android:name="net.evolution515.taskerwgtunnel.action.SET_TUNNEL_UP" />
19+
<action android:name="net.evolution515.taskerwgtunnel.action.SET_TUNNEL_DOWN" />
20+
<action android:name="com.wireguard.android.action.SET_TUNNEL_UP" />
21+
<action android:name="com.wireguard.android.action.SET_TUNNEL_DOWN" />
22+
</intent-filter>
23+
</receiver>
24+
<!--
25+
<activity
26+
android:name=".activity.TunnelToggleActivity"
27+
android:theme="@style/NoBackgroundTheme" />
28+
-->
29+
<activity android:name=".MainActivity">
30+
<intent-filter>
31+
<action android:name="android.intent.action.MAIN" />
32+
<category android:name="android.intent.category.LAUNCHER" />
33+
</intent-filter>
34+
</activity>
35+
</application>
36+
37+
</manifest>

0 commit comments

Comments
 (0)