docs(android): rewrite Android docs to match the tree
All checks were successful
android-ci / android (pull_request) Successful in 10m14s
All checks were successful
android-ci / android (pull_request) Successful in 10m14s
android/README.md, CUPRATE_DAEMON.md and MONERO_BINARIES.md were the half PR #133 left out. Releases are two manual dispatches, not a push to main; the APK version comes from the tag android-release checks out; the layout now includes wallet/ and keepalive/; the status line's sync h/t is documented; the APK poller still calls wallet_status, not wallet_child_refresh.
This commit is contained in:
parent
fa0e4b2f6c
commit
c65946bfd5
3 changed files with 308 additions and 78 deletions
|
|
@ -11,6 +11,14 @@ The Linux TUI in the repository root is a **separate product** with a separate
|
|||
Cargo workspace. Nothing here turns it into a WebView, and nothing here imports
|
||||
its TUI code. Same wire protocol: [docs/PROTOCOL.md](../docs/PROTOCOL.md).
|
||||
|
||||
Companion records (not duplicated here):
|
||||
|
||||
* in-process chain daemon in the APK — [CUPRATE_DAEMON.md](CUPRATE_DAEMON.md)
|
||||
* bundled `monero-wallet-rpc` blob — [MONERO_BINARIES.md](MONERO_BINARIES.md)
|
||||
* wallet / chain-source behaviour (core + SDK) — [docs/WALLET.md](../docs/WALLET.md)
|
||||
* consuming the AAR — [crates/onionwire-sdk/README.md](../crates/onionwire-sdk/README.md)
|
||||
* how a maintainer actually cuts a release — [docs/RELEASING.md](../docs/RELEASING.md)
|
||||
|
||||
## Requirements
|
||||
|
||||
* JDK 17+ (built and tested on JDK 21)
|
||||
|
|
@ -36,7 +44,8 @@ cd android
|
|||
```
|
||||
|
||||
The Rust cross-compile and the UniFFI Kotlin bindings are wired into the Gradle
|
||||
tasks — there is no manual codegen step. `:sdk:preBuild` depends on them.
|
||||
tasks — there is no manual codegen step. `:sdk:preBuild` depends on
|
||||
`cargoBuildAndroid`, `uniffiBindgen`, and `verifyDynamicLibc`.
|
||||
|
||||
Emulator / x86_64 slice:
|
||||
|
||||
|
|
@ -44,13 +53,20 @@ Emulator / x86_64 slice:
|
|||
./gradlew :app:assembleDebug -Ponionwire.abis=arm64-v8a,x86_64
|
||||
```
|
||||
|
||||
That extra ABI does **not** ship `libmonerowalletrpc.so` for x86_64. The wallet
|
||||
screen says so (`NO_WALLET_RPC_MESSAGE`) instead of offering a Start that cannot
|
||||
work. See [MONERO_BINARIES.md](MONERO_BINARIES.md).
|
||||
|
||||
Or from the repo root, with checksums and an optional publish step:
|
||||
|
||||
```bash
|
||||
scripts/build-android-local.sh # -> dist/onionwire-<v>-android-arm64-v8a.apk
|
||||
PUBLISH_TAG=v0.1.0 scripts/build-android-local.sh
|
||||
PUBLISH_TAG=v0.14.0 scripts/build-android-local.sh
|
||||
```
|
||||
|
||||
The script re-verifies `android/monero-binaries.sha256` before Gradle, then
|
||||
again against the bytes inside the APK. It does not create tags.
|
||||
|
||||
## Decisions you should know about
|
||||
|
||||
### `minSdk = 26` (Android 8.0)
|
||||
|
|
@ -79,12 +95,24 @@ readelf -l android/sdk/build/rustJniLibs/arm64-v8a/libonionwire_sdk.so | grep LO
|
|||
|
||||
### Permissions
|
||||
|
||||
`INTERNET` only, declared at first launch. No camera (invites are pasted, not
|
||||
scanned), no contacts, no storage permission — the data directory is
|
||||
`context.filesDir`, which is already app-private. There is **no**
|
||||
`FOREGROUND_SERVICE` and no keep-alive notification in v1: the node lives only
|
||||
while the process does, and the UI says so. Adding one is a product decision
|
||||
(battery, Play's FGS type declarations), not a silent fix.
|
||||
`INTERNET` is the only permission requested at first launch. No camera (invites
|
||||
are pasted, not scanned), no contacts, no storage permission — the data
|
||||
directory is `context.filesDir`, which is already app-private.
|
||||
|
||||
The node is **not** process-lifetime-only. After unlock, `KeepAliveService` is
|
||||
a foreground service (`specialUse`, not `dataSync`) with an ongoing
|
||||
notification so the onion stays published across Doze and backgrounding. The
|
||||
manifest therefore also declares:
|
||||
|
||||
* `FOREGROUND_SERVICE`
|
||||
* `FOREGROUND_SERVICE_SPECIAL_USE`
|
||||
* `POST_NOTIFICATIONS` (API 33+; denial hides the drawer notification, it does
|
||||
not stop the service)
|
||||
|
||||
`NodeHost` owns the single `Wire` handle. The service never does. Lock, or the
|
||||
notification's Stop action, drops the keep-alive anchor; the node stays up
|
||||
only while another owner (the UI) still holds it. `START_NOT_STICKY`: a
|
||||
restarted empty service would show "reachable" over a dead onion.
|
||||
|
||||
### Data at rest
|
||||
|
||||
|
|
@ -148,9 +176,11 @@ Release APKs are signed with a **repo-owned keystore**, not the debug key.
|
|||
present (`~/.android/onionwire-release.jks` + `.env`, mode 600). Local and
|
||||
CI APKs then verify as the same cert and can upgrade in place.
|
||||
* If the env file is missing, Gradle **warns** and signs with the debug
|
||||
keystore so a laptop build still installs. CI sets
|
||||
keystore so a laptop build still installs. CI's `android-release.yml` sets
|
||||
`ONIONWIRE_REQUIRE_RELEASE_KEY=true` and **fails closed** instead — a
|
||||
per-machine debug key would make every CI APK uninstallable over the last.
|
||||
`android-ci.yml` deliberately does **not** set that: it is a verification
|
||||
build and `apksigner` reporting the debug cert there is expected.
|
||||
* Never commit a keystore, password, or `android/local.properties`. This is
|
||||
not a Play upload key; nothing here should be uploaded to Play.
|
||||
|
||||
|
|
@ -162,23 +192,148 @@ path and an on-device test of the JNI surface is how you ship an
|
|||
`UnsatisfiedLinkError` nobody can read. Turn it on together with crash
|
||||
deobfuscation, not before.
|
||||
|
||||
## CI
|
||||
## Wallet child and chain sources (as Android sees them)
|
||||
|
||||
`.forgejo/workflows/android-release.yml` runs on `docker-amd64` (T480 dind).
|
||||
The job image is `node:20-bullseye` (EOL) — **do not apt-get there**. The
|
||||
toolchain runs in a sibling `debian:bookworm` container
|
||||
(stdin-tar + `docker cp`, same pattern as the Rust CI job).
|
||||
Any push to `main` that touches Android **sources or build config**
|
||||
(`android/app/**`, `android/sdk/**`, Gradle files — not `android/README.md`)
|
||||
workflow) builds `onionwire-<version>-android-arm64-v8a.apk` and
|
||||
`onionwire-sdk-<version>.aar`, verifies them, and attaches them to the Forgejo
|
||||
release for that tag. Version is the latest `v*.*.*` tag plus patch, or
|
||||
**v0.1.0** when there are no tags. `versionName` matches the tag;
|
||||
`versionCode` is `major*10000 + minor*100 + patch` (so 0.1.0 → 100).
|
||||
Chain traffic is **off** until the user opens Wallet, picks a source, and
|
||||
presses Start. Receive-only is the default: no `monero-wallet-rpc` child, no
|
||||
daemon, no P2P.
|
||||
|
||||
`workflow_dispatch` with `dry_run=true` builds and checksums without creating
|
||||
a tag or publishing. `scripts/build-android-local.sh` remains the offline
|
||||
fallback; it does not create tags.
|
||||
The app owns `monero-wallet-rpc` (issue #107). It is still a **child process**,
|
||||
exec'd from `applicationInfo.nativeLibraryDir/libmonerowalletrpc.so`. Cuprate
|
||||
has no wallet layer — an in-process node does not replace that binary.
|
||||
|
||||
Sources the screen offers:
|
||||
|
||||
1. **Receive-only** — no child, no chain.
|
||||
2. **A daemon address you type** — loopback or clearnet. Wallet RPC itself is
|
||||
loopback only. A `.onion` host is refused while `libarti.so` is absent
|
||||
(`ONION_NEEDS_ARTI_NOTICE`); this APK does not bundle `arti`.
|
||||
3. **On-device node (Cuprate)** — opt-in. Selecting it stores
|
||||
`ChainChoice.InProcessCuprate` with an empty `monerod_datadir`, which the
|
||||
SDK resolves to `$ONIONWIRE_HOME/chain`. Kotlin never invents an absolute
|
||||
path. The pre-production warning (`CUPRATE_PREPRODUCTION_WARNING`) sits
|
||||
**above Start**, not after. The screen can store testnet, mainnet-pruned, or
|
||||
mainnet-full (and applies the matching storage floor); **mainnet remains
|
||||
unvalidated** and the warning says so. Cross-compiled is not device-proven.
|
||||
See [CUPRATE_DAEMON.md](CUPRATE_DAEMON.md).
|
||||
|
||||
Start is gated on the bundled wallet-rpc binary, on the storage floor for the
|
||||
chosen Cuprate mode, and on the `.onion`/arti check. The floors are floors, not
|
||||
sync estimates — nothing in this stack exposes a chain size:
|
||||
|
||||
| Mode | Floor |
|
||||
|---|---|
|
||||
| testnet | 3 GiB |
|
||||
| mainnet pruned | 64 GiB |
|
||||
| mainnet full | 280 GiB |
|
||||
|
||||
Unreadable free space (`StatFs` failed) is fail-closed: Start stays blocked.
|
||||
|
||||
### Status line
|
||||
|
||||
`ui/WalletChildStatusText.kt` is the pure model. The line renders the core's
|
||||
words verbatim (`off` / `connecting` / `syncing` / `ready` / `exited`), then
|
||||
the chain-source label, then — for the in-process source only — `node <word>`
|
||||
from `WalletChildStatus.node_state`. An unrecognised word is never rendered as
|
||||
ready.
|
||||
|
||||
When the last probe reported a non-zero height or target, the line grows
|
||||
` · sync h/t`. That is the **daemon's** chain height, not the wallet's scan
|
||||
height. `0/0` is omitted (unknown), not printed as 0%. There is **no
|
||||
percentage, no progress bar, and no ETA** anywhere in the UI. The same string
|
||||
is the row's screen-reader `contentDescription`.
|
||||
|
||||
Honest limit of the in-process node word: a daemon that dies *after* the wallet
|
||||
child came up cannot be reported `exited` — there is no separate pid for the
|
||||
in-process daemon, the chain probe fails, and the state stays `syncing`.
|
||||
`exited` still means the `monero-wallet-rpc` child is gone. Details:
|
||||
[CUPRATE_DAEMON.md](CUPRATE_DAEMON.md#what-has-not-been-proven).
|
||||
|
||||
### What the APK refresh loop actually calls
|
||||
|
||||
`WireViewModel.openWalletChild()` polls every 2 s
|
||||
(`WALLET_CHILD_TICK_MS = 2_000`). Each tick is `Wire.walletStatus()` — the
|
||||
cached, non-dialing UniFFI read (`Wire::wallet_status`). It never spawns and
|
||||
it never probes the daemon, so `sync h/t` only moves when something else
|
||||
wrote a fresh snapshot (start, a previous live probe).
|
||||
|
||||
The SDK also exposes `Wire.walletChildRefresh()` (`Wire::wallet_child_refresh`):
|
||||
a live probe of the loopback wallet RPC, and of the local daemon's `get_info`
|
||||
when that RPC does not answer. The TUI uses it. **This APK's poller does not.**
|
||||
Do not read the moving `sync h/t` docs in [docs/WALLET.md](../docs/WALLET.md)
|
||||
as a description of the Android loop on this tree.
|
||||
|
||||
## CI and releases
|
||||
|
||||
A merge to `main` does **not** publish an APK. Neither does a tag push.
|
||||
Releases are manual and batched: two dispatches. Full procedure:
|
||||
[docs/RELEASING.md](../docs/RELEASING.md).
|
||||
|
||||
### `android-ci.yml` (verification, not a release)
|
||||
|
||||
Runs on `docker-amd64` (T480 dind) for every `push`/`pull_request` whose paths
|
||||
include `android/**`, `src/**`, `crates/**`, `Cargo.toml`, `Cargo.lock`,
|
||||
`scripts/build-android-local.sh`, or the workflow itself — plus
|
||||
`workflow_dispatch`. Job image is `node:20-bullseye` (EOL) — **do not apt-get
|
||||
there**. The toolchain runs in a sibling `debian:bookworm` container
|
||||
(stdin-tar + `docker cp`). Both Android workflows install `cmake` in that
|
||||
container (RandomX).
|
||||
|
||||
It calls `scripts/build-android-local.sh` with the **debug** key
|
||||
(`ONIONWIRE_REQUIRE_RELEASE_KEY` unset). Nothing is published. After the APK
|
||||
is built it greps `lib/arm64-v8a/libonionwire_sdk.so` for `target_max_memory`
|
||||
and **fails** if that cuprated-only string is missing.
|
||||
|
||||
### `android-release.yml` (the APK that lands on a tag)
|
||||
|
||||
`on:` is `workflow_dispatch` (and a declared `workflow_call` that this Forgejo
|
||||
10.0.3 instance cannot invoke). **No `push` trigger.** Inputs:
|
||||
|
||||
| Input | Default | Meaning |
|
||||
|---|---|---|
|
||||
| `tag` | empty | Existing tag to check out, build, and attach. |
|
||||
| `dry_run` | `false` | Build and checksum; skip the Pi publish job. |
|
||||
|
||||
Operator path, after `release.yml` has minted the tag (`dry_run=true` on that
|
||||
workflow first):
|
||||
|
||||
1. Actions → **android-release** → Run workflow, `tag=vX.Y.Z` (the tag core
|
||||
just created), `dry_run=false`.
|
||||
2. The Android job **checks out that tag** (`ref:` is the tag, not `main`) and
|
||||
stamps `versionName` / `versionCode` from it.
|
||||
3. `versionCode` is `major*10000 + minor*100 + patch` (so 0.14.0 → 1400).
|
||||
4. Publish is a second job on the Pi runner (`docker`). It attaches
|
||||
`onionwire-<version>-android-arm64-v8a.apk`, `onionwire-sdk-<version>.aar`,
|
||||
and both `.sha256` files to **that same tag**.
|
||||
|
||||
The APK is built from **the tag's tree**. Building from `main` and stamping a
|
||||
tag you did not check out is how you ship a binary that does not match the
|
||||
tag.
|
||||
|
||||
**Empty `tag` is the foot-gun.** Checkout then falls back to `github.sha`
|
||||
(usually `main` HEAD). Version is *not* "latest `v*.*.*` plus patch" as a
|
||||
rule:
|
||||
|
||||
* no tags at all → `0.1.0`;
|
||||
* latest `v*.*.*` release is **missing** the Android APK (or the job cannot
|
||||
inspect the release) → **join** that version: same `versionName` restamped
|
||||
onto whatever tree was checked out. Android will refuse to install that APK
|
||||
over an already-installed build of the same `versionName`/`versionCode`;
|
||||
* latest tag already has an Android APK → `patch+1` of that version, still
|
||||
built from `github.sha`, and this workflow may then **create** that new tag
|
||||
at publish time if it does not exist.
|
||||
|
||||
Do not dispatch `android-release` with an empty `tag` to ship a release. Core
|
||||
owns minting (`release.yml`, default `bump=minor`). This workflow attaches.
|
||||
|
||||
`workflow_dispatch` with `dry_run=true` builds and checksums without
|
||||
publishing. `scripts/build-android-local.sh` remains the offline fallback; it
|
||||
does not create tags.
|
||||
|
||||
The Android job image / bookworm-container story is the same as `android-ci.yml`.
|
||||
The cuprated graph is built with `RUST_TOOLCHAIN=1.98` here (workspace MSRV
|
||||
stays 1.91). Job timeout is **90** minutes on `android-release.yml` and **120**
|
||||
on `android-ci.yml`.
|
||||
|
||||
## Layout
|
||||
|
||||
|
|
@ -187,17 +342,38 @@ android/
|
|||
settings.gradle.kts
|
||||
build.gradle.kts # plugin aliases only
|
||||
gradle/libs.versions.toml # version catalog
|
||||
gradle/wrapper/
|
||||
monero-binaries.sha256 # provenance of the bundled wallet-rpc blob
|
||||
CUPRATE_DAEMON.md
|
||||
MONERO_BINARIES.md
|
||||
sdk/ # -> AAR
|
||||
build.gradle.kts # cargo-ndk + uniffi-bindgen wiring
|
||||
consumer-rules.pro
|
||||
src/main/AndroidManifest.xml
|
||||
app/ # -> APK
|
||||
build.gradle.kts
|
||||
src/main/AndroidManifest.xml
|
||||
src/main/java/com/siriusdevops/onionwire/
|
||||
MainActivity.kt # NavHost
|
||||
WireViewModel.kt # owns the single Wire node
|
||||
WireViewModel.kt # UI-side Wire handle; wallet-child poller
|
||||
crypto/ # Keystore-wrapped store passphrase
|
||||
keepalive/ # NodeHost, KeepAliveService, policy, lifetime
|
||||
wallet/ # ChainStorage, WalletChildBinaries
|
||||
ui/ # Compose screens (M3)
|
||||
src/test/ # JVM tests (envelope, store, invite flow)
|
||||
WalletScreen.kt
|
||||
WalletChildStatusText.kt
|
||||
ChatScreen.kt
|
||||
RosterScreen.kt
|
||||
InviteScreens.kt
|
||||
InviteAddFlow.kt
|
||||
OutboxDetail.kt
|
||||
MessageDelivery.kt
|
||||
UnlockScreen.kt
|
||||
UnlockSubmit.kt
|
||||
RotateScreen.kt
|
||||
Insets.kt
|
||||
Theme.kt
|
||||
src/test/ # JVM: envelope, store, invite, outbox, keepalive, wallet line
|
||||
src/androidTest/ # device-only: AndroidKeyStore
|
||||
src/main/jniLibs/arm64-v8a/libmonerowalletrpc.so
|
||||
```
|
||||
|
|
|
|||
Loading…
Reference in a new issue