Engineering AARE Cockpit: Building an Open-Source Android Auto Projection Host with Live OBD-II Telemetry
The Motivation Behind the Project
Automotive infotainment systems frequently lock drivers into rigid, proprietary walled gardens with poor customizability and zero real-time telemetry. While Google's official Android Auto requires Google Play Services and restricts non-approved applications, open-source projection hosts allow the phone to drive the car's screen directly. AARE Cockpit takes this further: a complete reimagining of the phone-side projection host, combining hardware-accelerated video encoding, custom Jetpack Compose UI shells, real-time Bluetooth ELM327 OBD-II vehicle instrumentation, smart ambient light theme adaptation, and robust wireless adapter negotiation.
Core Features and Design Goals
- Live OBD-II Vehicle Instrumentation: Continuously queries engine telemetry (RPM, Speed, Coolant Temperature, Battery Voltage) via Bluetooth RFCOMM without dropping audio or navigation frames.
- Custom Automotive UI Shells: Designed the 'Dusk' floating glass dock and 'Hybrid' responsive layout engineered specifically for aftermarket 7-inch 1024×600 and widescreen head units.
- Phone Ambient Lux Auto-Night Switching: Solves illumination trigger wiring issues on aftermarket Chinese head units by coupling phone ambient light sensor readings with astronomical solar twilight calculations.
- Bitrate & Video Encoder Overrides: Hardware H.264/H.265 encoder controls up to 20 Mbps with keyframe flow control, eliminating compression artifacts and blurriness.
- Steering Wheel & Rotary Remapping: Intercepts physical automotive CAN bus/rotary keys and maps them to custom actions (shell toggle, home, maps, mute).
- Universal Wireless Adapter Handshake: Dual-handshake fallback with version echo, allowing instant pairing with Carlinkit, Ottocast, and aftermarket wireless dongles.
- Dynamic Rhythm Visualizer: Multi-bar real-time audio spectrum visualizer integrated into the car dashboard alongside now-playing metadata.
Deep Dive: How It Works Under the Hood
The Android Auto Protocol (AAP) operates over framed TLS 1.2 channels for video, audio, input, and sensors. In typical aftermarket units, video artifacts arise when wireless links jitter or when encoders target conservative 4 Mbps bitrates. By introducing adaptive bitrate stepping and user overrides up to 20 Mbps alongside hardware MediaCodec encoding, AARE Cockpit achieves crisp 60fps rendering even on low-DPI displays.
Technical Implementation
- Implemented
ObdManager.ktusing non-blocking coroutines and Bluetooth RFCOMM sockets to stream Mode 01 PIDs (0x0C RPM, 0x0D Speed, 0x05 Coolant Temp, 0x42 Voltage) into StateFlow reactive models. - Authored
HybridShell.ktandDuskUIShell.ktin Jetpack Compose, computing dynamic UI scale factors (carDimensFor) to prevent clipping on 160 DPI 1024×600 displays. - Created
AmbientLightDetector.ktblending phone light sensor measurements with solar altitude angle estimation to guarantee flicker-free automatic night theme transitions. - Wired bitrate configuration through
VideoEncoder.ktandSessionOptions.kt, adding runtime keyframe re-requests to immediately recover from wireless packet loss. - Overhauled
MainActivity.ktinto a modern 4-tab companion application (Home, Customize, My Cars, Settings) for rapid in-vehicle profile configuration.
Challenges I Faced Along the Way
Bridging real-time ELM327 OBD-II AT-command parsing with the projection rendering loop required careful concurrency isolation. Slow or unresponsive vehicle ECUs can stall serial responses; wrapping all OBD requests in bounded timeouts and decoupled coroutine channels ensured that automotive instrumentation queries never introduce UI stutter on the car screen.
The Technology Stack
Engineered in 100% Kotlin with Jetpack Compose, Android MediaCodec hardware video encoding, AndroidX Car App Library host protocols, Shizuku rootless APIs, and Bluetooth RFCOMM communications.
Final Reflections
By decoupling automotive projection from closed commercial ecosystems, open-source software can turn any car screen into an extensible, high-performance telemetry cockpit.