tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 09c546f54e087f77b72a0764d21c779205810df4
parent 5a194359da8104fa7498e7a29e85d49aa91b7d76
Author: Beatriz Rizental <brizental@torproject.org>
Date:   Thu, 30 Jan 2025 19:12:00 +0100

TB 42669: [android] Use custom no-op app-services

Fetch the custom built no-op application services library
from tor-browser-build when building for Android.

Diffstat:
M.gitignore | 1+
Mbuild.gradle | 4++++
Mmobile/android/android-components/components/browser/engine-gecko/build.gradle | 2++
Mmobile/android/android-components/components/browser/storage-sync/src/main/java/mozilla/components/browser/storage/sync/RemoteTabsStorage.kt | 9+++++++++
Mmobile/android/android-components/components/concept/sync/src/main/java/mozilla/components/concept/sync/AccountEvent.kt | 3+++
Mmobile/android/android-components/components/feature/fxsuggest/build.gradle | 6++++++
Mmobile/android/android-components/components/service/firefox-accounts/src/main/java/mozilla/components/service/fxa/FxaDeviceConstellation.kt | 2++
Mmobile/android/android-components/components/service/firefox-accounts/src/main/java/mozilla/components/service/fxa/Types.kt | 7++++---
Mmobile/android/android-components/components/service/firefox-accounts/src/main/java/mozilla/components/service/fxa/sync/WorkManagerSyncManager.kt | 3+++
Mmobile/android/android-components/components/service/nimbus/build.gradle | 2++
Mmobile/android/android-components/components/support/appservices/src/main/java/mozilla/components/support/rustlog/RustLog.kt | 2+-
Mmobile/android/android-components/plugins/dependencies/src/main/java/ApplicationServices.kt | 4++--
Mmobile/android/autopublish-settings.gradle | 16++++++++++++++--
Mmobile/android/gradle/plugins/nimbus-gradle-plugin/src/main/groovy/org/mozilla/appservices/tooling/nimbus/NimbusAssembleToolsTask.groovy | 17+++++++++++++++++
Mmobile/android/gradle/plugins/nimbus-gradle-plugin/src/main/groovy/org/mozilla/appservices/tooling/nimbus/NimbusGradlePlugin.groovy | 2+-
15 files changed, 71 insertions(+), 9 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -408,6 +408,7 @@ CLAUDE.local.md mobile/android/.experimenter.json # Tor libraries for local builds +mobile/android/fenix/tools/nimbus-fml mobile/android/fenix/app/tor-expert-bundle.aar mobile/android/fenix/app/src/main/assets/extensions/{73a6fe31-595d-460b-a920-fcc0f8843232}.xpi diff --git a/build.gradle b/build.gradle @@ -5,6 +5,8 @@ import org.tomlj.TomlTable buildscript { repositories { + mavenLocal() + gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository -> maven { url = repository @@ -130,6 +132,8 @@ allprojects { } repositories { + mavenLocal() + gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository -> maven { url = repository diff --git a/mobile/android/android-components/components/browser/engine-gecko/build.gradle b/mobile/android/android-components/components/browser/engine-gecko/build.gradle @@ -4,6 +4,8 @@ buildscript { repositories { + mavenLocal() + gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository -> maven { url = repository diff --git a/mobile/android/android-components/components/browser/storage-sync/src/main/java/mozilla/components/browser/storage/sync/RemoteTabsStorage.kt b/mobile/android/android-components/components/browser/storage-sync/src/main/java/mozilla/components/browser/storage/sync/RemoteTabsStorage.kt @@ -162,6 +162,7 @@ class RemoteTabsCommandQueue( .groupBy { when (it.command) { is RemoteCommand.CloseTab -> PendingCommandGroup.Key.CloseTab(it.deviceId) + is RemoteCommand.__NOOP -> PendingCommandGroup.Key.Noop(it.deviceId) // Add `is ... ->` branches for future pending commands here... }.asAnyKey } @@ -185,6 +186,13 @@ class RemoteTabsCommandQueue( pendingCommands = pendingCommands, ) } + is PendingCommandGroup.Key.Noop -> { + PendingCommandGroup( + deviceId = key.deviceId, + command = DeviceCommandOutgoing.Noop(), + pendingCommands = pendingCommands, + ) + } // Add `is ... ->` branches for future pending command grouping keys here... }.asAnyGroup } @@ -280,6 +288,7 @@ class RemoteTabsCommandQueue( sealed interface Key { data class CloseTab(val deviceId: String) : Key + data class Noop(val deviceId: String) : Key // Add data classes for future pending command grouping keys here... /** Returns this grouping key as a type-erased [Key]. */ diff --git a/mobile/android/android-components/components/concept/sync/src/main/java/mozilla/components/concept/sync/AccountEvent.kt b/mobile/android/android-components/components/concept/sync/src/main/java/mozilla/components/concept/sync/AccountEvent.kt @@ -55,6 +55,9 @@ sealed class DeviceCommandIncoming { * Outgoing device commands (ie, targeted at other devices.) */ sealed class DeviceCommandOutgoing { + /** A command to do nothing */ + class Noop() : DeviceCommandOutgoing() + /** A command to open a tab on another device */ class SendTab(val title: String, val url: String) : DeviceCommandOutgoing() diff --git a/mobile/android/android-components/components/feature/fxsuggest/build.gradle b/mobile/android/android-components/components/feature/fxsuggest/build.gradle @@ -4,6 +4,12 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +buildscript { + repositories { + mavenLocal() + } +} + plugins { alias(libs.plugins.python.envs.plugin) id 'org.mozilla.nimbus-gradle-plugin' diff --git a/mobile/android/android-components/components/service/firefox-accounts/src/main/java/mozilla/components/service/fxa/FxaDeviceConstellation.kt b/mobile/android/android-components/components/service/firefox-accounts/src/main/java/mozilla/components/service/fxa/FxaDeviceConstellation.kt @@ -178,8 +178,10 @@ class FxaDeviceConstellation( is RustCloseTabsResult.Ok -> Result.success(true) is RustCloseTabsResult.TabsNotClosed -> Result.failure(SendCommandException.TabsNotClosed(closeTabsResult.urls)) + is RustCloseTabsResult.__NOOP -> Result.success(false) } } + is DeviceCommandOutgoing.Noop -> Result.success(false) } val errors: List<Throwable> = SyncTelemetry.processFxaTelemetry(account.gatherTelemetry()) for (error in errors) { diff --git a/mobile/android/android-components/components/service/firefox-accounts/src/main/java/mozilla/components/service/fxa/Types.kt b/mobile/android/android-components/components/service/firefox-accounts/src/main/java/mozilla/components/service/fxa/Types.kt @@ -128,7 +128,7 @@ internal fun RustDeviceType.into(): DeviceType { RustDeviceType.TABLET -> DeviceType.TABLET RustDeviceType.TV -> DeviceType.TV RustDeviceType.VR -> DeviceType.VR - RustDeviceType.UNKNOWN -> DeviceType.UNKNOWN + else-> DeviceType.UNKNOWN } } @@ -165,7 +165,7 @@ fun DeviceCapability.into(): RustDeviceCapability { fun RustDeviceCapability.into(): DeviceCapability { return when (this) { RustDeviceCapability.SEND_TAB -> DeviceCapability.SEND_TAB - RustDeviceCapability.CLOSE_TABS -> DeviceCapability.CLOSE_TABS + else -> DeviceCapability.CLOSE_TABS } } @@ -250,7 +250,7 @@ fun AccountEvent.into(): mozilla.components.concept.sync.AccountEvent { deviceId = this.deviceId, isLocalDevice = this.isLocalDevice, ) - is AccountEvent.Unknown -> mozilla.components.concept.sync.AccountEvent.Unknown + else -> mozilla.components.concept.sync.AccountEvent.Unknown } } @@ -258,6 +258,7 @@ fun IncomingDeviceCommand.into(): mozilla.components.concept.sync.DeviceCommandI return when (this) { is IncomingDeviceCommand.TabReceived -> this.into() is IncomingDeviceCommand.TabsClosed -> this.into() + is IncomingDeviceCommand.__NOOP -> this.into() } } diff --git a/mobile/android/android-components/components/service/firefox-accounts/src/main/java/mozilla/components/service/fxa/sync/WorkManagerSyncManager.kt b/mobile/android/android-components/components/service/firefox-accounts/src/main/java/mozilla/components/service/fxa/sync/WorkManagerSyncManager.kt @@ -473,6 +473,9 @@ internal class WorkManagerSyncWorker( // Finally, declare success, failure or request a retry based on 'sync status'. return when (syncResult.status) { + ServiceStatus.__NOOP -> { + Result.success() + } // Happy case. ServiceStatus.OK -> { // Worker should set the "last-synced" timestamp, and since we have a single timestamp, diff --git a/mobile/android/android-components/components/service/nimbus/build.gradle b/mobile/android/android-components/components/service/nimbus/build.gradle @@ -4,6 +4,8 @@ buildscript { repositories { + mavenLocal() + gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository -> maven { url = repository diff --git a/mobile/android/android-components/components/support/appservices/src/main/java/mozilla/components/support/rustlog/RustLog.kt b/mobile/android/android-components/components/support/appservices/src/main/java/mozilla/components/support/rustlog/RustLog.kt @@ -86,6 +86,6 @@ internal fun Level.asLogPriority(): Log.Priority { Level.DEBUG -> Log.Priority.DEBUG Level.INFO -> Log.Priority.INFO Level.WARN -> Log.Priority.WARN - Level.ERROR -> Log.Priority.ERROR + else -> Log.Priority.ERROR } } diff --git a/mobile/android/android-components/plugins/dependencies/src/main/java/ApplicationServices.kt b/mobile/android/android-components/plugins/dependencies/src/main/java/ApplicationServices.kt @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ // These lines are generated by android-components/automation/application-services-nightly-bump.py -val VERSION = "148.20260110050246" -val CHANNEL = ApplicationServicesChannel.NIGHTLY +val VERSION = "148.0-TORBROWSER" +val CHANNEL = ApplicationServicesChannel.RELEASE object ApplicationServicesConfig { val version = VERSION diff --git a/mobile/android/autopublish-settings.gradle b/mobile/android/autopublish-settings.gradle @@ -30,6 +30,7 @@ def rootLocalProperties = new File(gradle.mozconfig.topsrcdir, "local.properties [ "autoPublish.application-services.dir", "autoPublish.glean.dir", + "uniffiBindgenNoop.executable", ].each { key -> def relativeOrAbsolutePath = rootLocalProperties."$key" if (relativeOrAbsolutePath != null) { @@ -40,6 +41,10 @@ def rootLocalProperties = new File(gradle.mozconfig.topsrcdir, "local.properties gradle.settingsEvaluated { if (gradle.hasProperty("localProperties.autoPublish.application-services.dir")) { + if (!gradle.hasProperty("localProperties.uniffiBindgenNoop.executable")) { + throw new GradleException("Set uniffiBindgenNoop.executable to your local.properties in order to auto publish application-services.") + } + def appServicesLocalPath = gradle."localProperties.autoPublish.application-services.dir" logger.lifecycle("settings.gradle> Enabling automatic publication of application-services from: $appServicesLocalPath") // Windows can't execute .py files directly, so we assume a "manually installed" python, @@ -48,13 +53,17 @@ gradle.settingsEvaluated { if (System.properties["os.name"].toLowerCase().contains("windows")) { publishAppServicesCmd << "py"; } - publishAppServicesCmd << "./automation/publish_to_maven_local_if_modified.py"; + publishAppServicesCmd << "./automation/publish_to_maven_local_if_modified.py" << gradle."localProperties.uniffiBindgenNoop.executable"; runCmd(publishAppServicesCmd, appServicesLocalPath, "Published application-services for local development.", false) } else { logger.lifecycle("settings.gradle> Disabled auto-publication of application-services. Enable it by settings 'autoPublish.application-services.dir' in local.properties") } if (gradle.hasProperty("localProperties.autoPublish.glean.dir")) { + if (!gradle.hasProperty("localProperties.uniffiBindgenNoop.executable")) { + throw new GradleException("Set uniffiBindgenNoop.executable to your local.properties in order to auto publish glean.") + } + def gleanLocalPath = gradle."localProperties.autoPublish.glean.dir" logger.lifecycle("settings.gradle> Enabling automatic publication of Glean from: $gleanLocalPath") // As above, hacks to execute .py files on Windows. @@ -62,7 +71,10 @@ gradle.settingsEvaluated { if (System.properties["os.name"].toLowerCase().contains("windows")) { publishGleanCmd << "py"; } - publishGleanCmd << "./build-scripts/publish_to_maven_local_if_modified.py"; + + // We do not have a fork of Glean. In order for this to work, on your local + // copy of the Glean repo, modify this python script to accept and use the uniffi-bindgen path. + publishGleanCmd << "./build-scripts/publish_to_maven_local_if_modified.py" << gradle."localProperties.uniffiBindgenNoop.executable"; runCmd(publishGleanCmd, gleanLocalPath, "Published Glean for local development.", false) } else { logger.lifecycle("settings.gradle> Disabled auto-publication of Glean. Enable it by settings 'autoPublish.glean.dir' in local.properties") diff --git a/mobile/android/gradle/plugins/nimbus-gradle-plugin/src/main/groovy/org/mozilla/appservices/tooling/nimbus/NimbusAssembleToolsTask.groovy b/mobile/android/gradle/plugins/nimbus-gradle-plugin/src/main/groovy/org/mozilla/appservices/tooling/nimbus/NimbusAssembleToolsTask.groovy @@ -23,6 +23,12 @@ import org.gradle.api.tasks.Nested import org.gradle.api.tasks.OutputFile import org.gradle.api.tasks.TaskAction +import java.io.File +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.Paths +import java.nio.file.StandardCopyOption + import javax.inject.Inject import java.security.MessageDigest @@ -148,6 +154,17 @@ abstract class NimbusAssembleToolsTask extends DefaultTask { @TaskAction void assembleTools() { + String nimbusFml = System.getenv("NIMBUS_FML") + if (nimbusFml == null || "".equals(nimbusFml)) { + nimbusFml = System.getProperty("nimbusFml") + } + if (nimbusFml != null && !"".equals(nimbusFml)) { + Path source = (new File(nimbusFml)).toPath() + Path dest = fmlBinary.get().asFile.toPath() + Files.copy(source, dest, StandardCopyOption.REPLACE_EXISTING) + return + } + def binaryFile = fmlBinary.get().asFile def archiveFileObj = archiveFile.get().asFile def hashFileObj = hashFile.get().asFile diff --git a/mobile/android/gradle/plugins/nimbus-gradle-plugin/src/main/groovy/org/mozilla/appservices/tooling/nimbus/NimbusGradlePlugin.groovy b/mobile/android/gradle/plugins/nimbus-gradle-plugin/src/main/groovy/org/mozilla/appservices/tooling/nimbus/NimbusGradlePlugin.groovy @@ -34,7 +34,7 @@ abstract class ApplicationServicesVersionSource implements ValueSource<String, A def versionLine = appServicesFile.readLines().find { it.startsWith("val VERSION = ") } if (versionLine) { // Extract version from: val VERSION = "143.20250816050436" - return versionLine.split('"')[1] + return versionLine.split('"')[1].replace("-TORBROWSER", "") } throw new GradleException("Could not determine application-services version from ${appServicesFile.absolutePath}") }