clairehurst pushed to branch tor-browser-158.0a1-17.0-2 at The Tor Project / Applications / Tor Browser Commits: 9f849c14 by clairehurst at 2026-11-24T10:38:54-07:00 fixup! TB 42247: Android helpers for the TorProvider Bug: 44637 circuit display - - - - - efc1b403 by clairehurst at 2026-11-24T10:38:54-07:00 fixup! TB 3455: Add DomainIsolator, for isolating circuit by domain. Bug 44637: circuit display - - - - - 5 changed files: - mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java - mobile/android/geckoview/src/main/java/org/mozilla/geckoview/TorAndroidIntegration.java - mobile/shared/modules/geckoview/GeckoViewContent.sys.mjs - toolkit/components/tor-launcher/TorDomainIsolator.sys.mjs - toolkit/modules/TorAndroidIntegration.sys.mjs Changes: ===================================== mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java ===================================== @@ -2874,8 +2874,13 @@ public class GeckoSession { * @return The circuit information as a {@link GeckoResult} object. */ @AnyThread - public @NonNull GeckoResult<GeckoBundle> getTorCircuits() { - return mEventDispatcher.queryBundle("GeckoView:GetTorCircuits"); + public @NonNull GeckoResult<JSONObject> getTorCircuits() { + return mEventDispatcher.queryString("GeckoView:GetTorCircuits").map(value -> { + if (value == null) { + return null; + } + return new JSONObject(value); + }); } /** ===================================== mobile/android/geckoview/src/main/java/org/mozilla/geckoview/TorAndroidIntegration.java ===================================== @@ -47,6 +47,7 @@ public class TorAndroidIntegration implements BundleEventListener { private static final String EVENT_SETTINGS_READY = "GeckoView:Tor:SettingsReady"; private static final String EVENT_SETTINGS_CHANGED = "GeckoView:Tor:SettingsChanged"; private static final String EVENT_SECURITY_LEVEL_CUSTOM = "GeckoView:Tor:SecurityLevelCustom"; + private static final String EVENT_TOR_CIRCUIT_CHANGE = "GeckoView:Tor:TorCircuitChange"; // Events we emit private static final String EVENT_SECURITY_LEVEL_GET = "GeckoView:Tor:SecurityLevelGet"; @@ -132,6 +133,7 @@ public class TorAndroidIntegration implements BundleEventListener { EVENT_SETTINGS_READY, EVENT_SETTINGS_CHANGED, EVENT_SECURITY_LEVEL_CUSTOM, + EVENT_TOR_CIRCUIT_CHANGE, EVENT_CONNECT_STAGE_CHANGED, EVENT_BOOTSTRAP_PROGRESS, EVENT_TOR_LOGS); @@ -176,6 +178,10 @@ public class TorAndroidIntegration implements BundleEventListener { } else { _isTorSecurityLevelCustom.setValue(new CustomSecurityLevelNotificationObject(false, null)); } + } else if (EVENT_TOR_CIRCUIT_CHANGE.equals(event)) { + for (TorCircuitChangeListener listener : new HashSet<TorCircuitChangeListener>(mTorCircuitChangeListeners)) { + listener.onTorCircuitChange(); + } } else if (EVENT_CONNECT_STAGE_CHANGED.equals(event)) { TorConnectStage stage = new TorConnectStage(message.getBundle("stage")); _lastKnownStage.setValue(stage); @@ -651,6 +657,10 @@ public class TorAndroidIntegration implements BundleEventListener { } } + public interface TorCircuitChangeListener { + void onTorCircuitChange(); + } + public interface BootstrapStateChangeListener { void onBootstrapStageChange(@NonNull TorConnectStage stage); // new upgrade @@ -781,6 +791,16 @@ public class TorAndroidIntegration implements BundleEventListener { return EventDispatcher.getInstance().queryVoid(EVENT_BOOTSTRAP_CANCEL); } + public synchronized void registerTorCircuitChangeListener(TorCircuitChangeListener listener) { + mTorCircuitChangeListeners.add(listener); + } + + public synchronized void unregisterTorCircuitChangeListener(TorCircuitChangeListener listener) { + mTorCircuitChangeListeners.remove(listener); + } + + private final HashSet<TorCircuitChangeListener> mTorCircuitChangeListeners = new HashSet<>(); + public synchronized void registerBootstrapStateChangeListener(BootstrapStateChangeListener listener) { mBootstrapStateListeners.add(listener); } ===================================== mobile/shared/modules/geckoview/GeckoViewContent.sys.mjs ===================================== @@ -32,7 +32,7 @@ export class GeckoViewContent extends GeckoViewModule { "GeckoView:GetWebCompatInfo", "GeckoView:SendGleanBrokenSiteReport", "GeckoView:SendMoreWebCompatInfo", - "GeckoView:GetTorCircuit", + "GeckoView:GetTorCircuits", "GeckoView:NewTorCircuit", ]); } @@ -509,7 +509,7 @@ export class GeckoViewContent extends GeckoViewModule { domain, this.browser.contentPrincipal.originAttributes.userContextId ); - aCallback?.onSuccess({ domain, circuits }); + aCallback?.onSuccess(JSON.stringify({ domain, circuits })); } else { aCallback?.onSuccess(null); } ===================================== toolkit/components/tor-launcher/TorDomainIsolator.sys.mjs ===================================== @@ -47,7 +47,7 @@ const NON_TOR_PROXY_PREF = "extensions.torbutton.use_nontor_proxy"; // The topic of new identity, to observe to cleanup all the nonces. const NEW_IDENTITY_TOPIC = "new-identity-requested"; -// The topic on which we broacast circuit change notifications. +// The topic on which we broadcast circuit change notifications. const TOR_CIRCUIT_TOPIC = "TorCircuitChange"; // We have an interval to delete circuits that are not reclaimed by any browser. ===================================== toolkit/modules/TorAndroidIntegration.sys.mjs ===================================== @@ -19,6 +19,13 @@ ChromeUtils.defineESModuleGetters(lazy, { "moz-src:///toolkit/components/securitylevel/SecurityLevel.sys.mjs", }); +/** + * The topic on which circuit changes are broadcast. + * + * @type {string} + */ +const TOR_CIRCUIT_TOPIC = "TorCircuitChange"; + const Prefs = Object.freeze({ logLevel: "browser.tor_android.log_level", }); @@ -31,6 +38,7 @@ const logger = console.createInstance({ const EmittedEvents = Object.freeze({ settingsReady: "GeckoView:Tor:SettingsReady", settingsChanged: "GeckoView:Tor:SettingsChanged", + torCircuitChange: "GeckoView:Tor:TorCircuitChange", connectStageChanged: "GeckoView:Tor:ConnectStageChanged", bootstrapProgress: "GeckoView:Tor:BootstrapProgress", bootstrapComplete: "GeckoView:Tor:BootstrapComplete", @@ -89,6 +97,8 @@ class TorAndroidIntegrationImpl { Services.obs.addObserver(this, lazy.TorSettingsTopics[topic]); } + Services.obs.addObserver(this, TOR_CIRCUIT_TOPIC); + // Match the initialisation order from desktop's TorStartupService. lazy.TorSettings.init().catch(error => { logger.error("Cannot initailize TorSettings", error); @@ -159,6 +169,12 @@ class TorAndroidIntegrationImpl { } ); break; + case TOR_CIRCUIT_TOPIC: + lazy.EventDispatcher.instance.sendRequest( + EmittedEvents.torCircuitChange, + {} + ); + break; } } View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/6f32756... -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/6f32756... You're receiving this email because of your account on gitlab.torproject.org. Manage all notifications: https://gitlab.torproject.org/-/profile/notifications | Help: https://gitlab.torproject.org/help