How tomasz-grobelny/aacs works
1. What this repository is
AACS is a multi-process Android Auto integration stack for Linux. It sits between an Android Auto head unit, an Android Auto-capable mobile side, and local desktop/media components. The codebase is split into separate binaries so the protocol bridge, USB gadget logic, and optional input injection can be deployed independently.
2. Top-level runtime shape
The main runtime boundaries are:
- USB/Android Auto side: talks to the car headunit over USB OTG.
- Local IPC boundary: a Unix socket used to bridge AAServer and AAClient.
- Desktop integration boundary: optional tools such as GetEvents that inject input into X11 applications.
3. AAServer: headunit-facing core
AAServer is the most hardware-specific component. It owns the Android Auto session with the headunit, sets up USB gadget mode, and exposes a local socket for the companion client. Its source tree includes gadget management (Udc, Gadget, Function, MassStorageFunction, FfsFunction), Android Auto message handling, and socket transport.
4. AAClient: companion proxy
AAClient is the protocol peer on the other side of the bridge. Per the README, it connects to AAServer to obtain service descriptions and forwards Android Auto traffic. Architecturally, it is the abstraction layer that lets the Android Auto session be split from the USB-facing server and extended with other transports or clients later.
5. Shared Android Auto protocol model
The proto/ directory contains the schema for the Android Auto messages and channels: discovery, ping, input, touch, video, media, navigation, Bluetooth, sensor, and vendor extension messages. These definitions are central to the architecture because both AAServer and AAClient build their channel negotiation and payload handling around them.
6. Channel-based processing model
Both server and client use a ChannelHandler hierarchy with specialized handlers such as InputChannelHandler, VideoChannelHandler, and DefaultChannelHandler. This indicates the protocol is treated as a set of independently routed logical channels rather than a single monolithic stream. That separation is important for the diagram: one transport, multiple typed channels.
7. USB gadget and function stack in AAServer
The server-side USB path is not a generic socket server; it actively configures Linux gadget mode through low-level components like Udc, Gadget, descriptors, and USB functions. This is where the project interfaces with kernel-level USB OTG support and libusbgx-style gadget configuration. This is the boundary where the software becomes the “device” the headunit sees.
8. Video and input integration
Video is treated as a distinct path from control input. The README says AACS can stream arbitrary video to the headunit and depends on Snowmix for video mixing. Input is handled separately through touch and event channel types, with server/client handlers designed to carry touch and button events alongside media/video traffic.
9. GetEvents: desktop input bridge
GetEvents is a small standalone utility that listens for touch events from AAServer and replays them into a selected application using XTest. This is a clean integration boundary with X11: Android Auto touch events become desktop mouse/touch-like events without being embedded into the main server/client binaries.
10. Certificates and session identity
The ssl/ directories contain headunit and Android Auto certificate/key pairs. This is architecturally relevant because the Android Auto session is secured, and the repo treats certificates as part of the runtime identity of each side of the bridge.
11. Build and packaging structure
The repo is organized as multiple CMake targets: AAServer, AAClient, GetEvents, and shared protobuf generation under proto/. There is also a small root-level utility layer plus scripts and docs for boot/runtime setup. The build structure mirrors the runtime decomposition, which is useful for drawing component boundaries.
12. Operational context
The project is tuned for an Odroid N2 running Linux with USB OTG support and a modern kernel. The scripts and docs in scripts/ and doc/ support system startup, autologin, X session setup, and related environment preparation. These are deployment concerns rather than core logic, but they matter because the architecture depends on kernel gadget support and a graphics/input session for integration.
Main entry points: AAServer/main.cpp AAServer · AAClient/main.cpp AAClient · proto proto · CMakeLists.txt Root build
Components 17
Runtime components
Main binaries and the live protocol bridge between headunit, client, and desktop input.
- AAServer · Headunit-facing server that owns the USB gadget side and local socket bridge.
AAServer/main.cpp - USB gadget · Configures Linux gadget mode and the functions exposed to the Android Auto headunit.
AAServer/include/Gadget.h - Socket bridge · Local Unix-socket transport used to communicate with the companion client.
AAServer/include/SocketCommunicator.h - Channel handlers · Server-side routing for input, video, and default protocol channels.
AAServer/include/ChannelHandler.h - AA message core · Server-side packet/message handling around Android Auto channel traffic.
AAServer/include/Message.h - AAClient · Companion protocol peer that connects to AAServer and forwards Android Auto traffic.
AAClient/main.cpp - Client comm · Client-side communicator that connects to the server and exchanges service descriptions and traffic.
AAClient/include/AaCommunicator.h - Client handlers · Client-side handler hierarchy for input, video, and default channel behavior.
AAClient/include/ChannelHandler.h - Client messages · Client-side message and device abstractions for the Android Auto session.
AAClient/include/Message.h - GetEvents · Standalone X11 input bridge that replays touch events into desktop applications.
GetEvents/main.cpp
Shared protocol
Android Auto message model and common utility types used by both sides.
Deployment support
Certificates, scripts, docs, and environment setup for running on target hardware.
- Server certs · Android Auto-side certificate and key pair used by the server runtime.
AAServer/ssl/android_auto.crt - Headunit certs · Headunit-side certificate and key pair used by the client runtime.
AAClient/ssl/headunit.crt - Scripts · Startup, X session, video, and environment setup helpers for the target system.
scripts - Docs · Build, kernel, and installation notes supporting target deployment.
doc - Root build · Top-level CMake entry point that ties the binaries and shared schemas together.
CMakeLists.txt
Connections 22
- AAServer → USB gadget: configures · AAServer sets up the Linux USB gadget and its functions.
- AAServer → Socket bridge: exports · AAServer exposes a local socket boundary for the companion client.
- AAServer → Channel handlers: routes · AAServer dispatches protocol traffic through specialized channel handlers.
- AAServer → AA message core: parses · AAServer builds and consumes Android Auto packets and messages.
- AAClient → Client comm: connects · AAClient uses its communicator to attach to AAServer.
- AAClient → Client handlers: routes · AAClient uses channel handlers for typed protocol processing.
- AAClient → Client messages: serializes · AAClient uses its local message model for protocol exchange.
- AAServer → proto: shares · Server-side handlers are defined by the shared protobuf schemas.
- AAClient → proto: shares · Client-side handlers are defined by the shared protobuf schemas.
- Channel handlers → proto: implements · Channel handlers specialize the schema-defined Android Auto channels.
- Client handlers → proto: implements · Client handlers specialize the schema-defined Android Auto channels.
- AAServer → Server certs: uses · AAServer carries its Android Auto certificate identity at runtime.
- AAClient → Headunit certs: uses · AAClient carries its headunit certificate identity at runtime.
- GetEvents → AAServer: receives input from · GetEvents consumes touch events emitted by the server-side bridge.
- GetEvents → Scripts: fits into · Desktop input bridging is supported by the runtime setup scripts.
- AAServer → utils: uses · Server code uses the shared utility layer.
- AAClient → utils: uses · Client code uses the shared utility layer.
- AAServer → Root build: built by · AAServer is one of the main top-level build targets.
- AAClient → Root build: built by · AAClient is one of the main top-level build targets.
- GetEvents → Root build: built by · GetEvents is one of the main top-level build targets.
- proto → Root build: generated by · Protobuf schemas are integrated into the overall build.
- Docs → Scripts: documents · Documentation explains the runtime and setup scripts.