Skip to content

feat(downloads): add durable Android and Apple transfers - #1678

Merged
houko merged 2 commits into
nsgo-dev:mainfrom
houko:feat/android-background-downloads-452
Nov 22, 2026
Merged

houko merged 2 commits into
nsgo-dev:mainfrom
houko:feat/android-background-downloads-452

Conversation

@houko

@houko houko commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

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.

Refs #452.

Verification

  • 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.

@github-actions github-actions Bot added size/XL enhancement New feature or request conflict Conflicts with the base branch; resolve it first documentation Improvements or additions to documentation Android core cli and removed enhancement New feature or request conflict Conflicts with the base branch; resolve it first labels Nov 21, 2026
@houko
houko force-pushed the feat/android-background-downloads-452 branch from fd334ca to 5f88698 Compare November 21, 2026 14:54
@github-actions github-actions Bot added enhancement New feature or request conflict Conflicts with the base branch; resolve it first and removed conflict Conflicts with the base branch; resolve it first labels Nov 21, 2026
@houko
houko force-pushed the feat/android-background-downloads-452 branch from 5f88698 to d1aa09a Compare November 22, 2026 00:51
@github-actions github-actions Bot added macOS iOS tvOS and removed conflict Conflicts with the base branch; resolve it first labels Nov 22, 2026
@houko houko changed the title feat(android): stream background downloads with pinned TLS feat(downloads): add durable Android and Apple transfers Nov 22, 2026
@houko
houko force-pushed the feat/android-background-downloads-452 branch from 351c3ac to fe3ad50 Compare November 22, 2026 05:05
@github-actions github-actions Bot added the conflict Conflicts with the base branch; resolve it first label Nov 22, 2026
@houko
houko force-pushed the feat/android-background-downloads-452 branch from fe3ad50 to b08d1d3 Compare November 22, 2026 08:21
@github-actions github-actions Bot added conflict Conflicts with the base branch; resolve it first and removed conflict Conflicts with the base branch; resolve it first labels Nov 22, 2026
@houko
houko force-pushed the feat/android-background-downloads-452 branch from 84d478a to 06364e0 Compare November 22, 2026 14:13
@houko
houko enabled auto-merge November 22, 2026 14:13
@houko
houko force-pushed the feat/android-background-downloads-452 branch from 06364e0 to a276324 Compare November 22, 2026 16:42
@houko

houko commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator Author

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.

@houko
houko merged commit 47763ff into nsgo-dev:main Nov 22, 2026
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Android cli conflict Conflicts with the base branch; resolve it first core documentation Improvements or additions to documentation enhancement New feature or request iOS macOS size/XL tvOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant