fix: improve auto-tunnel reliability

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
This commit is contained in:
Zane Schepke 2024-04-06 10:33:21 -04:00
parent 2a8895ffbc
commit e37777e662
20 changed files with 102 additions and 29 deletions

View File

@ -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:

View File

@ -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:

View File

@ -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"

View File

@ -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)
@ -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?) {
@ -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)

View File

@ -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)
@ -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,

View File

@ -1,6 +0,0 @@
package com.zaneschepke.wireguardautotunnel.service.foreground
enum class ServiceState {
STARTED,
STOPPED,
}

View File

@ -74,6 +74,11 @@ class WireGuardConnectivityWatcherService : ForegroundService() {
}
}
override fun onDestroy() {
super.onDestroy()
stopService()
}
override fun startService(extras: Bundle?) {
super.startService(extras)
try {
@ -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()

View File

@ -49,6 +49,11 @@ class WireGuardTunnelService : ForegroundService() {
}
}
override fun onDestroy() {
super.onDestroy()
}
override fun startService(extras: Bundle?) {
super.startService(extras)
cancelJob()
@ -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

View File

@ -53,6 +53,11 @@ class AutoTunnelControlTile : TileService() {
}
}
override fun onTileAdded() {
super.onTileAdded()
onStartListening()
}
override fun onDestroy() {
super.onDestroy()
scope.cancel()

View File

@ -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,

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@ -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 not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_channel_background">#1D1A20</color>
</resources>

View File

@ -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"

View File

@ -0,0 +1,5 @@
What's new:
- Improved auto tunnel reliability
- Improved tile sync
- Added AndroidTV assets
- Added apk fingerprint

View File

@ -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"

View File

@ -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