mirror of
https://github.com/wgtunnel/android.git
synced 2026-07-03 14:07:49 +02:00
fix: auto tunnel service worker
This commit is contained in:
@@ -178,6 +178,7 @@ dependencies {
|
||||
implementation(libs.bundles.hilt.android)
|
||||
implementation(libs.bundles.androidx.work)
|
||||
ksp(libs.hilt.android.compiler)
|
||||
ksp(libs.androidx.hilt.compiler)
|
||||
|
||||
// Networking and serialization
|
||||
implementation(libs.bundles.ktor.client)
|
||||
|
||||
@@ -121,6 +121,8 @@ constructor(
|
||||
context.bindService(intent, autoTunnelServiceConnection, Context.BIND_AUTO_CREATE)
|
||||
}
|
||||
|
||||
suspend fun startAutoTunnelService() = autoTunnelMutex.withLock { startServiceInternal() }
|
||||
|
||||
private fun stopServiceInternal() {
|
||||
_autoTunnelService.value?.stop()
|
||||
try {
|
||||
|
||||
@@ -47,7 +47,6 @@ constructor(
|
||||
}
|
||||
}
|
||||
|
||||
// TODO this needs to be changed
|
||||
override suspend fun doWork(): Result =
|
||||
withContext(ioDispatcher) {
|
||||
Timber.i("Service worker started")
|
||||
@@ -55,7 +54,7 @@ constructor(
|
||||
Timber.i("Checking to see if auto-tunnel has been killed by system")
|
||||
if (isAutoTunnelEnabled && serviceManager.autoTunnelService.value == null) {
|
||||
Timber.i("Service has been killed by system, restoring.")
|
||||
autoTunnelSettingsRepository.updateAutoTunnelEnabled(true)
|
||||
serviceManager.startAutoTunnelService()
|
||||
}
|
||||
}
|
||||
Result.success()
|
||||
|
||||
Reference in New Issue
Block a user