
Pier Angelo Vendrame pushed to branch tor-browser-128.2.0esr-14.0-1 at The Tor Project / Applications / Tor Browser Commits: 9d554099 by Pier Angelo Vendrame at 2024-09-11T22:29:36+02:00 fixup! Bug 42247: Android helpers for the TorProvider Bug 42628: Remove browser.tor_android.use_new_bootstrap. - - - - - 37d0aa1a by Pier Angelo Vendrame at 2024-09-11T22:29:36+02:00 fixup! [android] Enable the connect assist experiments on alpha Bug 42628: Remove browser.tor_android.use_new_bootstrap. - - - - - 40f8455d by Pier Angelo Vendrame at 2024-09-11T22:29:37+02:00 fixup! Bug 42027: Base Browser migration procedures. Bug 43124: Implement a migration procedure for Android. - - - - - 5 changed files: - mobile/android/android-components/components/browser/engine-gecko/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngine.kt - mobile/android/android-components/components/concept/engine/src/main/java/mozilla/components/concept/engine/Settings.kt - mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java - mobile/shared/components/geckoview/GeckoViewStartup.sys.mjs - toolkit/modules/TorAndroidIntegration.sys.mjs Changes: ===================================== mobile/android/android-components/components/browser/engine-gecko/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngine.kt ===================================== @@ -1347,11 +1347,6 @@ class GeckoEngine( localeUpdater.updateValue() } } - override var useNewBootstrap: Boolean - get() = runtime.settings.useNewBootstrap - set(value) { - runtime.settings.useNewBootstrap = value - } }.apply { defaultSettings?.let { this.javascriptEnabled = it.javascriptEnabled @@ -1380,7 +1375,6 @@ class GeckoEngine( this.emailTrackerBlockingPrivateBrowsing = it.emailTrackerBlockingPrivateBrowsing this.torSecurityLevel = it.torSecurityLevel this.spoofEnglish = it.spoofEnglish - this.useNewBootstrap = it.useNewBootstrap } } ===================================== mobile/android/android-components/components/concept/engine/src/main/java/mozilla/components/concept/engine/Settings.kt ===================================== @@ -259,7 +259,6 @@ abstract class Settings { open var spoofEnglish: Boolean by UnsupportedSetting() - open var useNewBootstrap: Boolean by UnsupportedSetting() } /** @@ -312,7 +311,6 @@ data class DefaultSettings( override var emailTrackerBlockingPrivateBrowsing: Boolean = false, override var torSecurityLevel: Int = 4, override var spoofEnglish: Boolean = false, - override var useNewBootstrap: Boolean = true, ) : Settings() class UnsupportedSetting<T> { ===================================== mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java ===================================== @@ -598,11 +598,6 @@ public final class GeckoRuntimeSettings extends RuntimeSettings { getSettings().mSecurityLevel.set(level); return this; } - - public @NonNull Builder useNewBootstrap(final boolean flag) { - getSettings().mUseNewBootstrap.set(flag); - return this; - } } private GeckoRuntime mRuntime; @@ -675,8 +670,6 @@ public final class GeckoRuntimeSettings extends RuntimeSettings { /* package */ final Pref<Integer> mSpoofEnglish = new Pref<>("privacy.spoof_english", 0); /* package */ final Pref<Integer> mSecurityLevel = new Pref<>("browser.security_level.security_slider", 4); - /* package */ final Pref<Boolean> mUseNewBootstrap = - new Pref<>("browser.tor_android.use_new_bootstrap", false); /* package */ int mPreferredColorScheme = COLOR_SCHEME_SYSTEM; @@ -1725,15 +1718,6 @@ public final class GeckoRuntimeSettings extends RuntimeSettings { return this; } - public boolean getUseNewBootstrap() { - return mUseNewBootstrap.get(); - } - - public @NonNull GeckoRuntimeSettings setUseNewBootstrap(final boolean flag) { - mUseNewBootstrap.commit(flag); - return this; - } - @Override // Parcelable public void writeToParcel(final Parcel out, final int flags) { super.writeToParcel(out, flags); ===================================== mobile/shared/components/geckoview/GeckoViewStartup.sys.mjs ===================================== @@ -261,6 +261,8 @@ export class GeckoViewStartup { "GeckoView:InitialForeground", ]); + this.#migratePreferences(); + lazy.TorAndroidIntegration.init(); lazy.TorDomainIsolator.init(); @@ -370,6 +372,50 @@ export class GeckoViewStartup { break; } } + + /** + * This is the equivalent of BrowserGlue._migrateUITBB. + */ + #migratePreferences() { + const MIGRATION_VERSION = 1; + const MIGRATION_PREF = "torbrowser.migration_android.version"; + + // We do not have a way to check for new profiles on Android. + // However, the first version is harmless for new installs, so run it + // anyway. + const currentVersion = Services.prefs.getIntPref(MIGRATION_PREF, 0); + if (currentVersion < 1) { + // First implementation of the migration on Android (tor-browser#43124, + // 14.0a5, September 2024). + const prefToClear = [ + // Old torbutton preferences not used anymore. + // Some of them should have never been set on Android, as on Android we + // force PBM... But who knows about very old profiles. + "browser.cache.disk.enable", + "places.history.enabled", + "security.nocertdb", + "permissions.memory_only", + "extensions.torbutton.loglevel", + "extensions.torbutton.logmethod", + "extensions.torbutton.pref_fixup_version", + "extensions.torbutton.resize_new_windows", + "extensions.torbutton.startup", + "extensions.torlauncher.prompt_for_locale", + "extensions.torlauncher.loglevel", + "extensions.torlauncher.logmethod", + "extensions.torlauncher.torrc_fixup_version", + // tor-browser#42149: Do not change HTTPS-Only settings in the security + // level. + "dom.security.https_only_mode_send_http_background_request", + ]; + for (const pref of prefToClear) { + if (Services.prefs.prefHasUserValue(pref)) { + Services.prefs.clearUserPref(pref); + } + } + } + Services.prefs.setIntPref(MIGRATION_PREF, MIGRATION_VERSION); + } } GeckoViewStartup.prototype.classID = Components.ID( ===================================== toolkit/modules/TorAndroidIntegration.sys.mjs ===================================== @@ -14,7 +14,6 @@ ChromeUtils.defineESModuleGetters(lazy, { }); const Prefs = Object.freeze({ - useNewBootstrap: "browser.tor_android.use_new_bootstrap", logLevel: "browser.tor_android.log_level", }); @@ -49,15 +48,18 @@ const ListenedEvents = Object.freeze({ class TorAndroidIntegrationImpl { #initialized = false; - init() { + async init() { + if (this.#initialized) { + logger.warn("Something tried to initilize us again."); + return; + } + this.#initialized = true; + lazy.EventDispatcher.instance.registerListener( this, Object.values(ListenedEvents) ); - this.#bootstrapMethodReset(); - Services.prefs.addObserver(Prefs.useNewBootstrap, this); - Services.obs.addObserver(this, lazy.TorProviderTopics.TorLog); for (const topic in lazy.TorConnectTopics) { @@ -67,13 +69,6 @@ class TorAndroidIntegrationImpl { for (const topic in lazy.TorSettingsTopics) { Services.obs.addObserver(this, lazy.TorSettingsTopics[topic]); } - } - - async #initNewBootstrap() { - if (this.#initialized) { - return; - } - this.#initialized = true; lazy.TorProviderBuilder.init().finally(() => { lazy.TorProviderBuilder.firstWindowLoaded(); @@ -86,13 +81,8 @@ class TorAndroidIntegrationImpl { } } - observe(subj, topic, data) { + observe(subj, topic) { switch (topic) { - case "nsPref:changed": - if (data === Prefs.useNewBootstrap) { - this.#bootstrapMethodReset(); - } - break; case lazy.TorConnectTopics.StateChange: lazy.EventDispatcher.instance.sendRequest({ type: EmittedEvents.connectStateChanged, @@ -187,15 +177,6 @@ class TorAndroidIntegrationImpl { callback?.onError(e); } } - - #bootstrapMethodReset() { - if (Services.prefs.getBoolPref(Prefs.useNewBootstrap, false)) { - this.#initNewBootstrap(); - } else { - Services.prefs.clearUserPref("network.proxy.socks"); - Services.prefs.clearUserPref("network.proxy.socks_port"); - } - } } export const TorAndroidIntegration = new TorAndroidIntegrationImpl(); View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/4eb9b64... -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/4eb9b64... You're receiving this email because of your account on gitlab.torproject.org.
participants (1)
-
Pier Angelo Vendrame (@pierov)