From bad38091ecd4b5b9eb1311b07ca6eaec6bea4bfd Mon Sep 17 00:00:00 2001 From: Guillaume Jacquart Date: Fri, 21 Oct 2022 09:32:10 +0200 Subject: [PATCH 1/2] 5651: fix stop orbot service. --- build.gradle | 2 +- .../ipscramblermodule/IpScramblerModule.kt | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index a750949..ec0443d 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.2.0" + ext.advanced_privacy_version = "1.3.0" 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 2e9be19..5628725 100644 --- a/privacymoduletor/src/main/java/foundation/e/privacymodules/ipscramblermodule/IpScramblerModule.kt +++ b/privacymoduletor/src/main/java/foundation/e/privacymodules/ipscramblermodule/IpScramblerModule.kt @@ -32,8 +32,8 @@ import foundation.e.privacymodules.ipscramblermodule.IIpScramblerModule import foundation.e.privacymodules.ipscramblermodule.IIpScramblerModule.Listener import foundation.e.privacymodules.ipscramblermodule.IIpScramblerModule.Status import java.security.InvalidParameterException -import java.util.* import org.torproject.android.service.OrbotConstants +import org.torproject.android.service.OrbotConstants.ACTION_STOP_FOREGROUND_TASK import org.torproject.android.service.OrbotService import org.torproject.android.service.util.Prefs @@ -218,12 +218,19 @@ class IpScramblerModule(private val context: Context): IIpScramblerModule { } override fun stop() { + updateStatus(Status.STOPPING) + Prefs.putUseVpn(false) Prefs.putStartOnBoot(false) sendIntentToService(OrbotConstants.ACTION_STOP_VPN) - sendIntentToService(OrbotConstants.ACTION_STOP) - context.stopService(Intent(context, OrbotService::class.java)) + sendIntentToService( + action = OrbotConstants.ACTION_STOP, + extra = Bundle().apply { putBoolean(ACTION_STOP_FOREGROUND_TASK, true) } + ) + Handler(Looper.getMainLooper()).postDelayed({ + requestStatus() + }, 1000) } override fun requestStatus() { -- GitLab From d76e5af05afea29cb97758964d59714225b0136c Mon Sep 17 00:00:00 2001 From: Guillaume Jacquart Date: Sun, 23 Oct 2022 19:20:12 +0200 Subject: [PATCH 2/2] Fix app whitlist changes not applied while running. --- .../ipscramblermodule/IpScramblerModule.kt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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 5628725..faabc8d 100644 --- a/privacymoduletor/src/main/java/foundation/e/privacymodules/ipscramblermodule/IpScramblerModule.kt +++ b/privacymoduletor/src/main/java/foundation/e/privacymodules/ipscramblermodule/IpScramblerModule.kt @@ -56,6 +56,18 @@ class IpScramblerModule(private val context: Context): IIpScramblerModule { private val localBroadcastReceiver: BroadcastReceiver = object : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { val action = intent.action ?: return + if (action == OrbotConstants.ACTION_RUNNING_SYNC) { + try { + intent.getStringExtra(OrbotConstants.EXTRA_STATUS)?.let { + val newStatus = Status.valueOf(it) + currentStatus = newStatus + } + } catch (e: Exception) { + Log.e(TAG, "Can't parse Orbot service status.") + } + return + } + val msg = messageHandler.obtainMessage() msg.obj = action msg.data = intent.extras @@ -168,8 +180,7 @@ class IpScramblerModule(private val context: Context): IIpScramblerModule { ).commit() if (isServiceRunning()) { - sendIntentToService(OrbotConstants.ACTION_STOP_VPN) - sendIntentToService(OrbotConstants.ACTION_START_VPN) + sendIntentToService(OrbotConstants.ACTION_RESTART_VPN) } } -- GitLab