From 5458bd4a2728aa5265f3c14c3febe94fac853181 Mon Sep 17 00:00:00 2001 From: Guillaume Jacquart Date: Mon, 7 Nov 2022 20:23:05 +0100 Subject: [PATCH] 5651: fix stopping tor service cause random crashes. --- build.gradle | 2 +- .../ipscramblermodule/IpScramblerModule.kt | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index ec0443d..23001fb 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { ext.kotlin_version = "1.6.10" ext.orbot_version = "orbot-16.6.2" - ext.advanced_privacy_version = "1.3.0" + ext.advanced_privacy_version = "1.6.0-dev" repositories { google() diff --git a/privacymoduletor/src/main/java/foundation/e/privacymodules/ipscramblermodule/IpScramblerModule.kt b/privacymoduletor/src/main/java/foundation/e/privacymodules/ipscramblermodule/IpScramblerModule.kt index faabc8d..17b0cdf 100644 --- a/privacymoduletor/src/main/java/foundation/e/privacymodules/ipscramblermodule/IpScramblerModule.kt +++ b/privacymoduletor/src/main/java/foundation/e/privacymodules/ipscramblermodule/IpScramblerModule.kt @@ -239,9 +239,17 @@ class IpScramblerModule(private val context: Context): IIpScramblerModule { action = OrbotConstants.ACTION_STOP, extra = Bundle().apply { putBoolean(ACTION_STOP_FOREGROUND_TASK, true) } ) + stoppingWatchdog(5) + } + + private fun stoppingWatchdog(countDown: Int) { Handler(Looper.getMainLooper()).postDelayed({ - requestStatus() - }, 1000) + if (isServiceRunning() && countDown > 0) { + stoppingWatchdog(countDown - 1) + } else { + updateStatus(Status.OFF, force = true) + } + }, 500) } override fun requestStatus() { -- GitLab