I started PandaWave to explore the parts of an automotive media system that sit underneath the screen — process boundaries, state ownership, platform integration, native code and backend policy. Kotlin owns the HMI and Android integration, PandaEngine owns client-side domain state in Rust, and Canopy owns durable backend policy and media resolution.
The experience is on screen.
The architecture supports a real automotive media experience. These screens come from the project’s AAOS captures.
The question
An automotive media experience crosses more boundaries than its interface reveals. A tap can become a playback request, a service call, a native state transition and a backend operation. Android also has lifecycle and playback state of its own to report.
What if playback state, backend interaction and domain rules lived outside the Android UI process boundary?
PandaWave is my exploration of that question. Compose presents state. Android adapts platform capabilities. PandaEngine owns the client-side domain model.
Architecture
| Layer | Owns |
|---|---|
| Android / Compose | Presentation, lifecycle and AAOS integration |
| Media3 | Platform playback execution and system media surfaces |
| Binder / AIDL | The Android process boundary |
| JNI / FFI | Kotlin ↔ Rust native transport |
| PandaEngine | Client state and domain policy |
| canopy-api | The canonical wire contract |
| Canopy | Durable state, backend policy and media resolution |
Binder/AIDL, JNI/FFI and gRPC are not interchangeable. The native host contract spells out what each layer owns — and what must stay outside it.
Engineering decisions
Rust owns domain state
- Problem
- UI, player and backend can each maintain competing versions of queue, authentication and playback state.
- Decision
- PandaEngine owns client-side domain state and policy.
- Result
- Android presents state and adapts platform capabilities through one engine boundary.
A deliberate service boundary
- Problem
- A screen lifetime is different from a media-session lifetime.
- Decision
- Host the engine behind MediaEngineService with an explicit Binder/AIDL contract.
- Result
- Connection, reconnection, failure and state materialization become explicit concerns.
Intent and observation
- Problem
- Requesting playback does not mean the platform is already playing.
- Decision
- PandaEngine owns intent; Media3 reports the state actually observed on Android.
- Result
- Buffering, interruption, audio focus and late events are handled as asynchronous behavior.
A narrow native interface
- Problem
- A broad native API spreads lifetime, error and conversion concerns through the application.
- Decision
- Keep JNI/FFI focused on intentional commands and state exchange.
- Result
- A smaller set of cross-language concepts to maintain and debug.
Domain sessions, platform cryptography
- Problem
- Session policy belongs to the domain; protected key storage is an Android capability.
- Decision
- Keep session meaning in Rust and provide a Keystore-backed cryptographic primitive from Kotlin.
- Result
- Android supplies protected key access without taking ownership of authentication semantics.
Intent is not observation.
PandaEngine owns what playback should do. Media3 reports what the platform actually did.
- User / system command Play, pause, seek or skip
- PandaEngine Intent + queue policy
- Typed playback effect Explicit platform work
- Media3 / ExoPlayer Execute on Android
- Observed player event Report actual state
- PandaEngine → snapshot Update authoritative state
- Compose + AAOS Project the same snapshot
Each load carries an engine-created playback instance identity, allowing stale events from superseded loads to be rejected.
Media3 observations are therefore correlated with the active engine load instead of being treated as authoritative simply because they arrived last. The surrounding command/event loop is documented under Playback ownership →.
Built for automotive
Touch is only one input. Rotary, DPAD and controller navigation need predictable focus, useful disabled states and consistent behavior as driving conditions change. These are platform integration concerns, not just styling choices.
Media3 and the AAOS boundary
- AAOS system controls Browse + transport commands
- MediaLibraryService / Session Android media integration
- EngineGateway Shared command contract
- Binder → PandaEngine Domain decision + snapshot
System media controls and the in-app HMI enter the same engine boundary. The Android adapter projects engine catalog/state into framework media items and executes platform effects through Media3.
OEM customization through RRO
overlayable resources
89 color · 99 dimen · 5 drawable · 6 fraction · 17 integer
The matched captures use the same emulator, theme, density and scroll position. Playback progress differs between the frames and is not an overlay effect.
ResourceDesignTokenProvider bridges Android resources into Compose. Public resource names let an OEM overlay adjust colors, spacing, typography, focus treatment and sizing without rewriting UI code. Runtime user themes remain an app preference; RRO is a platform customization boundary.
The RRO guide documents the inventory and a built, installed, enabled and rolled-back two-resource canary. That is a targeted contract validation, not a claim that every possible OEM overlay has been exercised.
Native Android and Rust
Build and package deliberately
Gradle builds the Rust/JNI artifacts and synchronizes them into Android packaging. A missing native toolchain is a hard prerequisite failure, not a silent fake-engine fallback.
Four Android ABIs
arm64-v8a · armeabi-v7a · x86 · x86_64. Native packaging smoke tests complement Kotlin-only checks; a build with native work disabled is not a runtime-validation artifact.
Bound ownership at the ABI
The Rust FFI facade uses explicit handles, ABI-safe values and panic containment. JNI converts values; the Kotlin host owns native handle lifetime and dispatch.
Keep snapshots compact
Numeric state travels in compact snapshots. String-heavy metadata is queried and cached by revision, avoiding repeated cross-JNI work when metadata has not changed.
Native host source and contract · Android build integration
Secure sessions
- Rust session coordinator Session semantics + rotation
- Kotlin crypto bridge Narrow seal / open operation
- Android Keystore Non-exportable AES-GCM key
- Encrypted Rust envelope Persist without exposing keys
Rust owns the envelope and session lifecycle. Android provides the platform-protected cryptographic operation. Raw tokens, capabilities and deployment secrets do not become UI state. Secure-storage boundary →
Performance questions
The useful artifact is a trace that answers a question. These are investigation areas and available tools, not published benchmark results.
| Area | Question | Evidence to inspect |
|---|---|---|
| Startup | What is on the path to a usable surface? | Macrobenchmark, Perfetto, startup sections |
| Rendering | Which work misses a frame deadline? | Frame timeline, Compose/rendering traces |
| Binder | Where does process-boundary latency accumulate? | ATrace / Perfetto slices and dispatch timing |
| JNI | Are unchanged values repeatedly crossing the boundary? | Native-host traces, metadata revision behavior |
| Playback | Where does request-to-observation time go? | Engine effects, Media3 events and state transitions |
Performance infrastructure · CI performance workflow
Testing the boundaries
Rust / domain
Deterministic state transitions, queue behavior, effect routing and backend adapters can be exercised outside an Android screen.
Android instrumentation
Device/runtime integration and native packaging smoke paths sit in a separate lane from host-side Kotlin tests.
Engine-process recovery
The recovery test binds the real AIDL service, kills the instrumented :engine PID, observes reconnect, verifies a replacement PID and dispatches an event through recovered Binder.
MediaBrowser smoke
A framework MediaBrowser connects to the MediaLibraryService and verifies the published library root. The emulator workflow is an explicit CI lane.
Backend round trip
Canopy integration exercises real transport, session and policy behavior across the Android / Rust / backend boundary.
Test lanes and runnable commands · Backend integration
Observability
Typed diagnostic events and redacted sinks make boundary failures inspectable without treating tokens, capability URLs, profile data or configuration as harmless log text. Diagnostics should explain state and timing while preserving the same ownership boundaries as the runtime.
Current state and next questions
- Compose HMI and AAOS media integration
- Service-hosted Rust engine with Binder/AIDL and JNI/FFI
- Canopy adapters and protected session persistence
- RRO resource contract and emulator canary
- Process-recovery and platform smoke tests
- Deeper AOSP / platform integration
- Longer-running recovery and lifecycle validation
- Measurement-driven performance improvements
- System-image experiments as future work
The wider system continues in Canopy, which owns durable backend policy, and canopy-api, which makes the wire contract explicit. The cards below connect those case studies.