Bug 42251: Wired TorConnect status updates
Merge Info
Related Issues
- #42251
- mullvad-browser#xxxxx
- tor-browser-build#xxxxx
Backporting
Timeline
-
Immediate: patchset needed as soon as possible -
Next Minor Stable Release: patchset that needs to be verified in nightly before backport -
Eventually: patchset that needs to be verified in alpha before backport -
No Backport (preferred): patchset for the next major stable
(Optional) Justification
-
Emergency security update: patchset fixes CVEs, 0-days, etc -
Censorship event: patchset enables censorship circumvention -
Critical bug-fix: patchset fixes a bug in core-functionality -
Consistency: patchset which would make development easier if it were in both the alpha and release branches; developer tools, build system changes, etc -
Sponsor required: patchset required for sponsor -
Localization: typos and other localization changes that should be also in the release branch -
Other: please explain
Merging
-
Merge to tor-browser
-!fixups
totor-browser
-specific commits, new features, security backports -
Merge to base-browser
-!fixups
tobase-browser
-specific commits, new features to be shared withmullvad-browser
, and security backports-
NOTE: if your changeset includes patches to both
base-browser
andtor-browser
please clearly label in the change description which commits should be cherry-picked tobase-browser
after merging
-
NOTE: if your changeset includes patches to both
Issue Tracking
-
Link resolved issues with appropriate Release Prep issue for changelog generation
Review
Request Reviewer
-
Request review from an applications developer depending on modified system: -
NOTE: if the MR modifies multiple areas, please
/cc
all the relevant reviewers (since gitlab only allows 1 reviewer) - accessibility : henry
- android : @clairehurst, @dan
- build system : boklm
- extensions : ma1
- firefox internals (XUL/JS/XPCOM) : ma1
- fonts : pierov
- frontend (implementation) : henry
- frontend (review) : donuts, richard
- localization : henry, pierov
- macos : clairehurst, dan
- nightly builds : boklm
- rebases/release-prep : dan, ma1, pierov, richard
- security : ma1
- signing : boklm, richard
- updater : pierov
- misc/other : pierov, richard
-
NOTE: if the MR modifies multiple areas, please
Additional cc: @richard
Change Description
With this patch we send some TorConnect events to Android.
We might need to tweak them a little bit to include additional information (like we do in TorConnectParent
), but so far they're what TorConnect
emits.
This would be important to restore the tab bar after the bootstrap ends.
Also, added a temporary message to open settings from the HTML page, otherwise users risk to be trapped in it.
How Tested
I've added an observer to the events in TorController.kt
(because I knew it was a place where I could add stuff that is launched early).
However, something similar should be added to the UI section, or somewhere else at least to open the settings.
I bootstrapped and checked that I got notifications in logcat.
Also, I checked that I got a log entry for clicking in the open settings button.
Finally, checked that "Configure Connection" still works on desktop
Diff for firefox-android
diff --git a/android-components/components/browser/engine-gecko/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngine.kt b/android-components/components/browser/engine-gecko/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngine.kt
index c0e7026edf..74b9b1a7ff 100644
--- a/android-components/components/browser/engine-gecko/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngine.kt
+++ b/android-components/components/browser/engine-gecko/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngine.kt
@@ -939,6 +939,8 @@ class GeckoEngine(
unBlockedBySmartBlock = this.blockingData.any { it.unBlockedBySmartBlock() },
)
}
+
+ fun getTorIntegrationController() = runtime.getTorIntegrationController()
}
internal fun ContentBlockingController.LogEntry.BlockingData.hasBlockedCookies(): Boolean {
diff --git a/fenix/app/src/main/java/org/mozilla/fenix/FenixApplication.kt b/fenix/app/src/main/java/org/mozilla/fenix/FenixApplication.kt
index a880724aa8..0b926226d5 100644
--- a/fenix/app/src/main/java/org/mozilla/fenix/FenixApplication.kt
+++ b/fenix/app/src/main/java/org/mozilla/fenix/FenixApplication.kt
@@ -303,7 +303,7 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
downloadWallpapers()
- components.torController.start()
+ components.torController.start(components.core.engine)
}
@OptIn(DelicateCoroutinesApi::class) // GlobalScope usage
diff --git a/fenix/app/src/main/java/org/mozilla/fenix/tor/TorController.kt b/fenix/app/src/main/java/org/mozilla/fenix/tor/TorController.kt
index 6ab6dbcee2..0dc51dd670 100644
--- a/fenix/app/src/main/java/org/mozilla/fenix/tor/TorController.kt
+++ b/fenix/app/src/main/java/org/mozilla/fenix/tor/TorController.kt
@@ -8,6 +8,7 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
+import android.util.Log
import androidx.lifecycle.LifecycleCoroutineScope
import androidx.localbroadcastmanager.content.LocalBroadcastManager
@@ -15,7 +16,11 @@ import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.launch
import kotlinx.coroutines.withTimeoutOrNull
+import mozilla.components.browser.engine.gecko.GeckoEngine
+import mozilla.components.concept.engine.Engine
+
import org.mozilla.fenix.BuildConfig
+import org.mozilla.geckoview.TorIntegrationAndroid;
import org.torproject.android.service.TorService
import org.torproject.android.service.TorServiceConstants
@@ -119,7 +124,7 @@ class TorController(
Prefs.setBridgesList(value)
}
- fun start() {
+ fun start(engine: Engine) {
// Register receiver
lbm.registerReceiver(
persistentBroadcastReceiver,
@@ -129,6 +134,27 @@ class TorController(
persistentBroadcastReceiver,
IntentFilter(TorServiceConstants.LOCAL_ACTION_LOG)
)
+
+ if (engine is GeckoEngine) {
+ val torIntegration = engine.getTorIntegrationController()
+ torIntegration.registerBootstrapStateChangeListener(object: TorIntegrationAndroid.BootstrapStateChangeListener {
+ override fun onBootstrapStateChange(state: String) {
+ Log.i("BootstrapChange", "Observed state change " + state)
+ }
+ override fun onBootstrapProgress(progress: Double, status: String, hasWarnings: Boolean) {
+ Log.i("BootstrapChange", "Observed progress " + progress + " " + status + " " + hasWarnings)
+ }
+ override fun onBootstrapComplete() {
+ Log.i("BootstrapChange", "Bootstrap complete!!!")
+ }
+ override fun onBootstrapError(message: String, details: String) {
+ Log.e("BootstrapChange", "Bootstrap error :( " + message + " " + details)
+ }
+ override fun onSettingsRequested() {
+ Log.i("BootstrapChange", "Plz open settings")
+ }
+ })
+ }
}
fun stop() {