# Android platform implementation — 2026-10-30
This working-tree milestone expands the NativeActivity host into an Android
application platform. Android remains experimental until physical device,
accessibility, input and release acceptance is recorded. Implemented capability
does not establish universal Flutter parity or a performance advantage.
## Implemented contracts
| Accessibility | Virtual AccessibilityNodeProvider, stable node IDs, role/state/bounds, actions, hover, live regions and ranges | Native UiAutomation fixture passes; physical TalkBack traversal pending |
| Autofill | Explicit field-purpose hints, virtual structures and focus notifications, normal/secure fill dispatch | Fixture fills a password without exporting its text; real password-manager matrix pending |
| Navigation | Enabled app back handler, modal dismissal, keyboard dismissal, API 33 back and API 34 animation callbacks | Back fixture passes; physical predictive gesture matrix pending |
| Restoration | Versioned opt-in signals, bounded JSON checkpoints, saved-task Bundle integration | Root roundtrip/schema/secret-exclusion tests and emulator process-kill restoration pass |
| Services | Native clipboard, permissions, intents, sharing, SAF/content I/O, assets, haptics, directories/device info, Keystore storage | Fixture covers noninteractive operations; pickers and denied permissions need device QA |
| Plugins | Explicit Java/Kotlin channels, async replies and events, detach on activity close | Echo call/event fixture passes |
| Rendering recovery | Cache release under memory pressure, bounded compositor/device recreation, graphics-restored event | Memory fixture passes; hardware device-loss injection pending |
| Packaging | Standalone API 36 Gradle/Rust generator, ARM64/x86_64, release APK/AAB, required signing environment | Built with local development certificate for verification; no store publication |
| Measurement | Optional native ATrace frame span, Flutter input/counter fixture, ABBA release comparison runner | ADB observations include capture overhead; physical performance/energy results pending |
The native platform report at
`target/android/runtime-smoke/platform-expanded-final/report.json` records
eight passing checks on the API 35 x86_64 test guest. These include real virtual
accessibility actions, Unicode SET_TEXT, redacted password semantics, explicit
autofill, back navigation, platform services and retained state after trim-memory.
The separate instrumentation APK is never included in application packaging.
Final regression records:
| Native views including restoration/back/semantic-focus regression | 35 passed | `cargo test --test native_views --locked` |
| Winit including virtual ID/action revision/redaction/decorative-child regression | 47 passed | `cargo test -p taim_winit --lib --features measurement --locked` |
| Host and ARM64 Android strict Clippy | Passed | Native views, android_counter and android_platform_probe, `-D warnings` |
| Three Home/resume cycles plus saved-task process kill | Passed; count 4 restored into a new PID, then incremented to 5 | `target/android/runtime-smoke/expanded-restoration-accepted/report.json` |
| Native editor protocol | 29 checks passed | `target/android/runtime-smoke/expanded-ime-accepted/report.json` |
| Release APK/AAB | Both built; APK signature/16 KiB ZIP alignment and AAB JAR signature verified | External full-counter project; development certificate only |
| Paired release harness | Four ABBA trials passed on the emulator; neither APK debuggable | `target/android/comparison/emulator-release-harness-final/report.json` |
Artifact hashes, source hashes, runtime reports and comparison provenance are
captured in [the acceptance manifest](acceptance-20261030.json). The AAB verifier
reports development-certificate trust/timestamp warnings and a ZIP stream-order
warning; it verifies the JAR signature. Production/store acceptance is not claimed.
The first process-recreation attempt exposed a test-harness task mismatch: its
initial explicit launch and launcher reopen used different intent flags. All
launches now use MAIN/LAUNCHER consistently, preserving the saved task. Failed
runs remain under `target/android/runtime-smoke/expanded-restoration-*`; only
passing records above count as acceptance. The native restoration getter also
logs a bridge failure rather than silently hiding a JNI read error. No state
contents or passwords are logged.
## State and navigation API
```rust,ignore
let count = cx.restorable("counter", 1, 0_u64)?;
let page_open = cx.signal(false);
let field = text_field("Password", password)
.secret()
.autofill(taim::semantics::Autofill::Password);
```
Restoration keys must be unique, nonempty and at most 128 bytes. A schema version
change, missing value or malformed/type-mismatched checkpoint uses the initial
value. The serialized checkpoint is limited to 1 MiB. Keep it small because
Android shares its saved-state transaction budget with the rest of the activity.
Checkpoint failure retains the last accepted host snapshot. Ordinary signals,
editor composition and passwords are not automatically persisted. This restores
a saved Android task; it is not a permanent database or a force-stop guarantee.
Register back handling ahead of time with a reactive enabled property. Android
can then decide whether the application consumes the gesture. Predictive
started/progressed/cancelled/invoked events are exposed through Services events;
application-specific navigation animations remain the app's responsibility.
## Platform services and extension API
Use `taim::android::services()` after the host attaches. It returns a weak
activity-scoped handle; cloning it does not keep an activity alive. Dispatch
requests asynchronously, for example inside `cx.tasks().spawn(...)`:
```rust,ignore
let client = taim::android::services()
.ok_or(taim::android::ServiceError::Unavailable)?;
let device = client.request(taim::android::Request::DeviceInfo).await?;
let bytes = taim::android::Services::bytes(&client.request(
taim::android::Request::ReadAsset { name: "config.json".into(), limit: 4096 }
).await?)?;
```
Requests return `serde_json::Value` with these response shapes:
| ClipboardRead | String or null; HTML is opt-in |
| ClipboardWrite, OpenUrl, ShareText, ShareDocument | null after dispatch; no delivery/read receipt |
| Permissions | Array of `{name, granted, canAskAgain}`; app must declare permissions in its manifest |
| OpenDocument, CreateDocument | `{uri, mime, persisted}`; cancellation is an error |
| ReadDocument, ReadAsset, SecureGet | Base64 string, decoded with `Services::bytes`; missing secure key is null |
| WriteDocument, SecurePut, SecureDelete | null |
| Haptic | Boolean indicating native feedback dispatch |
| DeviceInfo | `{sdk, manufacturer, model, locale, density, fontScale}` |
| Directories | `{files, cache, noBackup}` app-private paths |
| LaunchIntent | `{type, action, uri, mime}`; optional keys may be absent |
| Plugin | JSON-compatible value returned by the registered plugin |
`canAskAgain` reflects Android's current rationale flag, not a permanent-denial
oracle: the flag is also false before the first request. Treat all external
intents and content as untrusted application input.
Requests have a 120-second deadline, eight in-flight slots and bounded payloads.
Binary reads/writes are limited to 4 MiB; secure-store values to 64 KiB; wire
messages to 6 MiB. Large documents require app-specific streaming plugins.
Picker requests are serialized. Result codes are not reused during an activity's
lifetime; expired or stale replies cannot complete another request. I/O uses a
bounded background worker and cancellation signals. The deadline thread sleeps
on a condition variable when idle rather than polling.
`Services::events()` returns a bounded stream of lifecycle, cold/warm intent,
predictive-back, memory-pressure, graphics-restored and plugin events. Initial
intent/lifecycle are replayed to new subscribers; saturated subscribers disconnect.
Code must handle stream closure and reacquire a service handle after recreation.
For Java/Kotlin extensions, subclass TaimActivity and call
`registerTaimPlugin(channel, plugin)` after `super.onCreate`. Implement TaimPlugin
and reply through its Result callback. Send events through
`emitTaimPluginEvent(channel, JSONObject)`. Registration is explicit and plugins
detach on host destruction. The platform-probe example contains an echo plugin.
Camera, maps, billing, notifications, background work and other SDK integrations
are extension work, not built-in implementations implied by this bridge.
Secure fields export neither password text nor length. Autofill can populate
explicitly hinted fields, but this host does not export secret values for a
password-save flow. Keystore storage uses app-private AES-GCM encryption; it is
separate from password input and does not promise biometric authentication.
## Standalone release project
```bash
python3 scripts/android/project.py /path/to/new-app \
--package com.example.myapp --deep-link-scheme myapp
cd /path/to/new-app
./gradlew assembleDebug
# Supply your own signing environment before release tasks:
# TAIM_KEYSTORE, TAIM_KEY_ALIAS, TAIM_STORE_PASSWORD, TAIM_KEY_PASSWORD
./gradlew bundleRelease assembleRelease
```
Requires JDK 21, Python 3, SDK platform 36, build-tools 35.0.0, NDK
28.2.13676358 and Rust targets aarch64-linux-android/x86_64-linux-android.
The pinned Gradle bootstrap verifies its distribution checksum. Native build
tasks verify JNI exports, system dependencies and 16 KiB ELF segment alignment.
AGP packages uncompressed native libraries. Release tasks reject missing signing
configuration and never silently use a debug key. Java files are copied host
snapshots; update them when upgrading the framework. No task uploads an app.
The external full-counter fixture built both release APK and AAB with a local
development certificate. This proves the build/signing path, not ownership of a
production certificate, Play Console acceptance or physical runtime support.
## Reproduce verification
```bash
cargo test --test native_views --locked
cargo test -p taim_winit --lib --features measurement --locked
python3 scripts/android/counter.py build --app platform-probe --abi x86_64
python3 scripts/android/platform-probe.py --serial YOUR_TEST_DEVICE \
--apk target/android/x86_64/debug/platform-probe/taim-platform-probe.apk \
--output target/android/runtime-smoke/platform-new-run
```
The runtime smoke accepts `--process-recreation` to Home/background, kill the
process without force-stopping its saved task, reopen through the launcher,
require a different PID, compare retained counter pixels and increment the
restored value. All launches use identical MAIN/LAUNCHER task flags.
The Flutter fixture is in `examples/android_flutter_baseline`; analyze/build
instructions live in its README. `scripts/android/compare.py --help` documents
explicit serial, release APKs, packages, activities, tap positions and count
crops. It refuses debuggable APKs by default and retains ABBA trial observations,
artifact hashes, device metadata, memory dumps and optional Perfetto traces.
This workload compares counter/input behavior. It does not represent every
framework feature, identical rendering, battery consumption or photon latency.
## Remaining acceptance
Physical ARM64 devices, API 26 through current releases, 4/16 KiB pages, multiple
GPU vendors, actual device loss, TalkBack, password managers, stock/third-party
IMEs, gesture navigation, rotation/window modes, denied permissions, SAF picker
cancellation, sustained scrolling/animation and energy traces need recorded runs.
Native plugin infrastructure does not supply Flutter's entire plugin ecosystem,
hot reload, tooling or every Android SDK feature. Do not label this milestone
complete Flutter equivalence or production support.