You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(downloads): add durable Android and Apple transfers - #1678
Android and standalone iOS and macOS apps can now start durable background downloads through core.Scope.Download. Each transfer has progress, pause/resume, cancellation, atomic publication and terminal replay after a restart.
Android uses the existing dataSync foreground service and keeps its current runtime protocol, manifest metadata and Java-only PR rule. iOS uses grouped background URLSession sessions. System-trusted requests and each exact certificate pin use separate sessions so authenticated connections cannot cross trust policies. The host reconnects stable session identifiers on launch, stages files, journals state and resumes after the Go process exits. macOS uses the same host with an in-process URLSession. App-container path migration is handled when iOS recreates its container.
The public API lives in core.Scope, which is shared by phone and desktop targets. The old unmerged mobile wrapper was removed. Windows and Linux transfer hosts and embedded Apple lifecycle integration remain in the roadmap. Apple certificate checks use the native Security framework so the host does not add Go's certificate parser to minimal apps.
Android core, Java, protocol and manifest regressions passed. The rebased Java runtime was rebuilt temporarily and the checked-in DEX/JAR files were left out of the branch.
go tool nsgo check -target macos,ios,ios_simulator,tvos,tvos_simulator,watchos,watchos_simulator -jobs 1 passed for the Apple targets touched by this change. Android checks from the earlier revision passed for arm64 and x64.
Apple native tests passed for transfer publication, recovery, pause/resume and range continuation, exact certificate pins, hostname and expiry checks, trust rejection without destination changes, journal recovery after an app-container move and delayed background completion. The macOS app-host integration passed through core.Scope.Download.
An earlier signed iPhone build passed a 2 GiB self-signed HTTPS transfer over a temporary LAN server. The transfer continued after the Go process exited at 16 MiB, resumed in a later process and finished with the expected SHA-256 382045c648d7c2a42a01bb3132186a0397d40e2e4e85a99377dbc79c20e6671e.
The signed device run also completed a 128 MiB grouped-session transfer after trust isolation was added. System-trust, wrong-host and wrong-pin requests failed and preserved their previous destination files. Replay exposed an old absolute destination after the app container moved. The container migration fix and subsequent native Security validation passed macOS tests; neither final change has been re-deployed to the physical phone. Terminal replay passed the macOS native fixture and app-host integration.
The iOS 18.4 simulator could not connect to its nsurlsessiond background daemon and returned NSCocoaErrorDomain 4097 before any network request. The physical-device result above is the acceptance evidence for background URLSession behavior.
git diff --check passed. The fixture app, temporary TLS server and device installation were removed after verification.
The iOS and Android OS policies still apply. Apple self-signed endpoints require a per-domain ATS exception in apple.info, while the download host continues to enforce the exact leaf pin, hostname and validity.
CI at 351c3ac58 fails TestPublicAPINamesNoInternalType for the inherited driver.ImageSampling allowlist gap and TestMinimalAppLinks for inherited macOS/Linux video networking dependencies. Failed job. Both checks passed when the separate baseline fix from #1797 was applied temporarily; that fix is excluded from this PR.
houko
changed the title
feat(android): stream background downloads with pinned TLS
feat(downloads): add durable Android and Apple transfers
Nov 22, 2026
Reviewed. cx.Download validates the URL (http/https, no user info; a pin requires HTTPS), the destination and the managed headers, and refuses confined owners. Tasks are app-wide and outlive the scope. Android runs them in a dataSync foreground service with optional pinned TLS, sent under extDownload (5), and returns ErrDownloadUnavailable when the runtime reads no extended messages. Reports come back on msgDownloadReport (36, free on main). Apple uses a background URLSession on iOS with in-process transfers on macOS and native Security pin checks. I rebased onto main as one squashed commit (the seven commits each replayed the same conflicts): the Android message and ext constants join main's, the manifest literal keeps main's androidDebuggable/Cleartext, the gate test keeps both entries, and the CHANGELOG.md line moved to changelog.d/background-downloads-452.md. Comments are unwrapped. Vet passes (host, android, apple, macos) and nsgo check passes for ios/tvos simulators. The core, driver, apk, cmd/nsgo, Android JVM (JDK 21) and Apple/macOS download tests pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Android and standalone iOS and macOS apps can now start durable background downloads through
core.Scope.Download. Each transfer has progress, pause/resume, cancellation, atomic publication and terminal replay after a restart.Android uses the existing
dataSyncforeground service and keeps its current runtime protocol, manifest metadata and Java-only PR rule. iOS uses grouped backgroundURLSessionsessions. System-trusted requests and each exact certificate pin use separate sessions so authenticated connections cannot cross trust policies. The host reconnects stable session identifiers on launch, stages files, journals state and resumes after the Go process exits. macOS uses the same host with an in-processURLSession. App-container path migration is handled when iOS recreates its container.The public API lives in
core.Scope, which is shared by phone and desktop targets. The old unmerged mobile wrapper was removed. Windows and Linux transfer hosts and embedded Apple lifecycle integration remain in the roadmap. Apple certificate checks use the native Security framework so the host does not add Go's certificate parser to minimal apps.Refs #452.
Verification
go tool nsgo check -target macos,ios,ios_simulator,tvos,tvos_simulator,watchos,watchos_simulator -jobs 1passed for the Apple targets touched by this change. Android checks from the earlier revision passed for arm64 and x64.core.Scope.Download.382045c648d7c2a42a01bb3132186a0397d40e2e4e85a99377dbc79c20e6671e.nsurlsessiondbackground daemon and returnedNSCocoaErrorDomain4097 before any network request. The physical-device result above is the acceptance evidence for background URLSession behavior.git diff --checkpassed. The fixture app, temporary TLS server and device installation were removed after verification.The iOS and Android OS policies still apply. Apple self-signed endpoints require a per-domain ATS exception in
apple.info, while the download host continues to enforce the exact leaf pin, hostname and validity.CI at
351c3ac58failsTestPublicAPINamesNoInternalTypefor the inheriteddriver.ImageSamplingallowlist gap andTestMinimalAppLinksfor inherited macOS/Linux video networking dependencies. Failed job. Both checks passed when the separate baseline fix from #1797 was applied temporarily; that fix is excluded from this PR.