Skip to content

Commit

Permalink
fix: improve auto-tunnel reliability
Browse files Browse the repository at this point in the history
Improved service manager stop service command to improve reliability
Closes #148

Added assets required by Google Play for AndroidTV to fix Google Play release

Added apk fingerprint hash to release to allow verification of apk signature via apksigner

Improve tile sync when tiles are first added

Bump versions
  • Loading branch information
zaneschepke committed Apr 6, 2024
1 parent 2a8895f commit e37777e
Show file tree
Hide file tree
Showing 20 changed files with 102 additions and 29 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,30 @@ jobs:
draft: false
prerelease: true
files: ${{ github.workspace }}/${{ steps.apk-path.outputs.path }}

- name: Install apksigner
run: |
sudo apt-get update
sudo apt-get install -y apksigner
- name: Get checksum
id: checksum
run: echo "checksum=$(apksigner verify -print-certs ${{ steps.apk-path.outputs.path }} | grep -Po "(?<=SHA-256 digest:) .*")" | awk '{$1=$1};1' >> $GITHUB_OUTPUT

- name: Append checksum
id: append_checksum
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body: >
<br /> SHA256 Checksum: <br /> ```${{ steps.checksum.outputs.checksum }}```
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
draft: false
prerelease: true
append_body: true

- name: Deploy with fastlane
uses: ruby/setup-ruby@v1
with:
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,30 @@ jobs:
draft: false
prerelease: false
files: ${{ github.workspace }}/${{ steps.apk-path.outputs.path }}

- name: Install apksigner
run: |
sudo apt-get update
sudo apt-get install -y apksigner
- name: Get checksum
id: checksum
run: echo "checksum=$(apksigner verify -print-certs ${{ steps.apk-path.outputs.path }} | grep -Po "(?<=SHA-256 digest:) .*")" | awk '{$1=$1};1' >> $GITHUB_OUTPUT

- name: Append checksum
id: append_checksum
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body: >
<br /> SHA256 Checksum: <br /> ```${{ steps.checksum.outputs.checksum }}```
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
draft: false
prerelease: false
append_body: true

- name: Deploy with fastlane
uses: ruby/setup-ruby@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<application
android:name=".WireGuardAutoTunnel"
android:allowBackup="true"
android:banner="@mipmap/ic_banner"
android:banner="@drawable/ic_banner"
android:dataExtractionRules="@xml/data_extraction_rules"
android:enableOnBackInvokedCallback="true"
android:fullBackupContent="@xml/backup_rules"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ open class ForegroundService : LifecycleService() {
Action.START.name,
Action.START_FOREGROUND.name -> startService(intent.extras)

Action.STOP.name -> stopService(intent.extras)
Constants.ALWAYS_ON_VPN_ACTION -> {
Timber.i("Always-on VPN starting service")
startService(intent.extras)
Expand All @@ -45,6 +44,7 @@ open class ForegroundService : LifecycleService() {
override fun onDestroy() {
super.onDestroy()
Timber.d("The service has been destroyed")
stopService()
}

protected open fun startService(extras: Bundle?) {
Expand All @@ -53,7 +53,7 @@ open class ForegroundService : LifecycleService() {
isServiceStarted = true
}

protected open fun stopService(extras: Bundle?) {
protected open fun stopService() {
Timber.d("Stopping ${this.javaClass.simpleName}")
try {
stopForeground(STOP_FOREGROUND_REMOVE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,9 @@ class ServiceManager(private val appDataRepository: AppDataRepository) {
intent.component?.javaClass
try {
when (action) {
Action.START_FOREGROUND -> {
context.startForegroundService(intent)
}

Action.START -> {
context.startService(intent)
}

Action.STOP -> context.startService(intent)
Action.START_FOREGROUND -> context.startForegroundService(intent)
Action.START -> context.startService(intent)
Action.STOP -> context.stopService(intent)
}
} catch (e: Exception) {
Timber.e(e.message)
Expand All @@ -54,7 +48,7 @@ class ServiceManager(private val appDataRepository: AppDataRepository) {

suspend fun stopVpnService(context: Context, isManualStop: Boolean = false) {
if (isManualStop) onManualStop()
Timber.d("Stopping vpn service action")
Timber.i("Stopping vpn service")
actionOnService(
Action.STOP,
context,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ class WireGuardConnectivityWatcherService : ForegroundService() {
}
}

override fun onDestroy() {
super.onDestroy()
stopService()
}

override fun startService(extras: Bundle?) {
super.startService(extras)
try {
Expand All @@ -86,8 +91,8 @@ class WireGuardConnectivityWatcherService : ForegroundService() {
}
}

override fun stopService(extras: Bundle?) {
super.stopService(extras)
override fun stopService() {
super.stopService()
wakeLock?.let {
if (it.isHeld) {
it.release()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ class WireGuardTunnelService : ForegroundService() {
}
}

override fun onDestroy() {
super.onDestroy()

}

override fun startService(extras: Bundle?) {
super.startService(extras)
cancelJob()
Expand Down Expand Up @@ -117,8 +122,8 @@ class WireGuardTunnelService : ForegroundService() {
)
}

override fun stopService(extras: Bundle?) {
super.stopService(extras)
override fun stopService() {
super.stopService()
lifecycleScope.launch(Dispatchers.IO) {
vpnService.stopTunnel()
didShowConnected = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ class AutoTunnelControlTile : TileService() {
}
}

override fun onTileAdded() {
super.onTileAdded()
onStartListening()
}

override fun onDestroy() {
super.onDestroy()
scope.cancel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,21 @@ class TunnelControlTile : TileService() {
scope.cancel()
}

override fun onTileAdded() {
super.onTileAdded()
onStartListening()
}

override fun onClick() {
super.onClick()
unlockAndRun {
scope.launch {
try {
if (vpnService.getState() == Tunnel.State.UP) {
serviceManager.stopVpnService(this@TunnelControlTile, isManualStop = true)
serviceManager.stopVpnService(
this@TunnelControlTile,
isManualStop = true,
)
} else {
serviceManager.startVpnServiceForeground(
this@TunnelControlTile, manualStartConfig?.id, isManualStart = true,
Expand Down
Binary file added app/src/main/res/drawable-xhdpi/ic_banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions app/src/main/res/mipmap-anydpi-v26/ic_channel.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_channel_background" />
<foreground android:drawable="@mipmap/ic_channel_foreground" />
</adaptive-icon>
Binary file added app/src/main/res/mipmap-xhdpi/ic_channel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions app/src/main/res/values/ic_channel_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_channel_background">#1D1A20</color>
</resources>
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Constants.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
object Constants {
const val VERSION_NAME = "3.4.0"
const val VERSION_NAME = "3.4.1"
const val JVM_TARGET = "17"
const val VERSION_CODE = 34000
const val VERSION_CODE = 34100
const val TARGET_SDK = 34
const val MIN_SDK = 26
const val APP_ID = "com.zaneschepke.wireguardautotunnel"
Expand Down
5 changes: 5 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/34100.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
What's new:
- Improved auto tunnel reliability
- Improved tile sync
- Added AndroidTV assets
- Added apk fingerprint
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pinLockCompose = "1.0.3"
roomVersion = "2.6.1"
timber = "5.0.1"
tunnel = "1.0.20230706"
androidGradlePlugin = "8.3.1"
androidGradlePlugin = "8.4.0-rc01"
kotlin = "1.9.23"
ksp = "1.9.23-1.0.19"
composeBom = "2024.03.00"
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#Wed Oct 11 22:39:21 EDT 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionSha256Sum=3e1af3ae886920c3ac87f7a91f816c0c7c436f276a6eefdb3da152100fef72ae
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionSha256Sum=9631d53cf3e74bfa726893aee1f8994fee4e060c401335946dba2156f440f24c
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit e37777e

Please sign in to comment.