Skip to content

K2GO-376 feat(contentexchange): wireless Share receiver (scan + pull) - #697

Merged
luisguzman-adfa merged 7 commits into
mainfrom
feat/K2GO-376-share-receiver
Oct 27, 2026
Merged

luisguzman-adfa merged 7 commits into
mainfrom
feat/K2GO-376-share-receiver

Conversation

@luisguzman-adfa

@luisguzman-adfa luisguzman-adfa commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

What

Add the receiver half of wireless Share (K2GO-376): join the sender hotspot (or
the same Wi-Fi), scan the invite QR, then pull the sender-scoped items over the
LAN from its cx-core /v1/share gate and import them through the existing import
flow. Also lands the fixes found bringing the two-phone flow up: permit cleartext
HTTP on the LAN pull, a hotspot/Wi-Fi transport selector on the sender QR, a
single-phase per-item progress bar, a clean receive-to-finish navigation, and
autosizing the manager action buttons.

Why

Share is the network twin of the merged disk Import: the only sender-specific
part is where the bytes come from. The LAN pull is plain HTTP (QR pairing cannot
provision HTTPS) and the share token gates each request; the app denied cleartext
by default (ADFA-4714 scoped it to loopback), which blocked the pull, so the base
config now permits cleartext. The sender may be reachable over its hotspot or over
shared Wi-Fi with different addresses, so the sender picks which address the QR
advertises.

Scope

  • data/NetworkImportCarrier (HTTP GET of the manifest and each item, token in the
    X-Share-Token header never the URL, 409-staging retry, per-socket Wi-Fi pinning),
    data/ShareManifestReader, domain/ShareUrls, presentation/ContentReceiveFragment
    (scan, manifest summary, free-space preflight).
  • ContentShareFragment + ApAddressResolver: hotspot/Wi-Fi toggle, shown only when
    both addresses exist, with live QR refresh on network change (NetworkStateLiveData).
  • ExportJob/ImportSession: single-phase per-item bar for the import path.
  • xml/network_security_config: base-config cleartextTrafficPermitted=true, token-
    gated LAN Share. Reverses the loopback-only scope from ADFA-4714.
  • Reuses the ImportCarrier seam (mirrors SafImportCarrier), ContentImportService,
    ImportProgressFragment, the ZXing ScanContract, ShareHandshake.decode, WifiNetworkBinder.
  • No new Android permission or dependency.

UI changes

New user-facing strings (parked in strings_untranslated.xml; migration to 33
locales is the follow-up PR):

  • Receiver connects over | Hotspot | Wi-Fi
  • Receive over Wi-Fi | Receive | Scan the sender invite code | Try again
  • That code is not a Share invite. | Connecting to the sender... | The sender has
    nothing to receive.
  • Could not reach the sender. Join the sender Wi-Fi first, then try again.
  • %1$d items to receive : %2$s
  • This may not fit. The receive stops if the device runs out of space.
    New UI uses M3 tokens / MaterialButton styles (no hardcoded color), so both themes
    follow; the action bar and transport selector were checked light and dark on device.

Verification

assembleStandardDebug + testStandardDebugUnitTest green (+2 JVM test files:
ShareUrlsTest, ShareManifestReaderTest). Two-pass code review done. End-to-end
two-phone flow verified on device (Samsung A16 sender -> Oppo receiver over Wi-Fi,
full scoped set imported).

…rt carrier)

Pull the sender-scoped items over the hotspot and import them through the
existing flow. NetworkImportCarrier is the only sender-specific dependency (HTTP
to the sender gate, token in the X-Share-Token header, 409-staging retry,
per-connection Wi-Fi binding); stage and ingest are unchanged from the disk path.
Add ShareUrls and ShareManifestReader (pure, unit-tested), ContentReceiveFragment
(scan, fetch manifest, free-space preflight), ContentImportService.startNetwork,
and ImportCarrier.onAllDelivered (POST /complete on a clean finish). Wi-Fi join
uses the system invite QR (mirrors Clone); no new permission or dependency.
@luisguzman-adfa luisguzman-adfa added ui change or edit to UI strings changes or updates on xml strings files labels Oct 26, 2026
A receiver that is also hosting a hotspot owns 192.168.49.1 (the fixed
LocalOnlyHotspot AP IP, the same one the sender uses), so the kernel traps the
connection to the sender on loopback and the receiver reaches itself. Stop our
own hotspot when Receive starts and wait until the sender IP is no longer a local
interface (NetworkInterface sees p2p0; ConnectivityManager does not) before
connecting.
The receiver pulls each item over plain HTTP from the sender hotspot/Wi-Fi IP; the loopback-only policy (ADFA-4714) blocked it. Share is LAN-only and token-gated, and the ad-hoc QR pairing cannot provision HTTPS.
…efresh

Sender offers a selector when both a hotspot and a Wi-Fi address exist, so a peer on the same network pulls over Wi-Fi instead of the Wi-Fi Direct link. The QR re-renders on any network change (new DHCP IP) so it never carries a stale address.
Import has no box-prepare phase, so the export two-phase bar stayed at 0. Add a single-phase mode that fills 0..100 from the downloaded bytes.
Finish left the progress screen orphaned over the manager; show progress on its own back-stack entry so Finish pops cleanly. Also log the manifest-fetch exception that was silently swallowed.
Export/Share/Delete labels wrapped to two lines in their third-width slots; single line plus autosize (down to ~20%) keeps each on one line.
@luisguzman-adfa
luisguzman-adfa merged commit 9ab4bd9 into main Oct 27, 2026
3 checks passed
@luisguzman-adfa
luisguzman-adfa deleted the feat/K2GO-376-share-receiver branch October 27, 2026 03:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

strings changes or updates on xml strings files ui change or edit to UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant