# 674809/carlife architecture

> Architecture diagram of the GitHub repository 674809/carlife, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/674809/carlife
- Repository: https://github.com/674809/carlife

## Overview

#### Repository Scope
Apollo-DuerOS is a vehicle-telematics repository containing: an Android CarLife head-unit implementation, a portable C++ CarLife library, Android DuerOS launcher variants, DSP design documents, and DuerOS Auto integration specifications. It is a multi-deliverable source/documentation repository rather than one deployable application.

#### Android CarLife Head Unit
The primary Android vehicle-side client implements the CarLife smartphone-integration protocol. It is responsible for device connection, protocol handling, media presentation/playback, and vehicle input forwarding; phone-side applications retain business logic. Android startup is defined by `CarLife-Android-Vehicle/AndroidManifest.xml`, application initialization by `CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/CarLifeApplication.java`, and the main UI host by `CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/CarlifeActivity.java`.

#### CarLife Connection and Session Boundary
The connection subsystem abstracts multiple phone/head-unit transports: Android Open Accessory/USB, NCM, Wi-Fi, and iPhone USB multiplexing/tethering. `CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/connect/ConnectManager.java` coordinates transport lifecycle; `CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/connect/ConnectService.java` provides a service boundary; `CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/connect/ConnectSocket.java` represents socket transport. Connection setup includes heartbeat management and platform/device broadcasts, separating physical connectivity from protocol dispatch.

#### Protocol, Negotiation, and Security
Messages are serialized with Protocol Buffers, including protocol-version negotiation, device metadata, feature configuration, auth, media, touch, and vehicle telemetry. Android-generated schemas reside in `CarLife-Android-Vehicle/src/com/baidu/carlife/protobuf/`; protocol handlers are centralized through `CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/message/MsgHandlerCenter.java`. Encryption setup and AES/RSA operations form a security boundary around authentication/key exchange: `CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/encryption/EncryptSetupManager.java` and `CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/encryption/RSAManager.java`.

#### Vehicle I/O and Media Pipeline
Head-unit touch, hard keys, microphone input, GPS, speed, and other car data are converted into CarLife protocol events, while incoming media/control streams are rendered locally. Touch handling is routed through `CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/touch/TouchListenerManager.java`; vehicle telemetry reporting through `CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/vehicledata/CarDataManager.java`; audio packets flow through buffering, arbitration, and Android playback in `CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/audioplayer/VehiclePCMPlayer.java`. Bluetooth HFP pairing/call control is a separate Android/Binder-facing integration in `CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/bluetooth/BtHfpManager.java`.

#### CarLife UI and Recovery
The Android client is a fragment-based head-unit UI with launch, main, in-call, touch, settings, help, authorization, and exception states. Fragment navigation is coordinated by `CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/fragment/CarLifeFragmentManager.java`; the primary connected/disconnected UI is `CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/fragment/MainFragment.java`; recovery/diagnostic presentation is `CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/fragment/ExceptionFragment.java`. Layout resources support multiple head-unit resolutions under `CarLife-Android-Vehicle/res/`.

#### Cross-Platform CarLife Library
`CarLife-Vehicle-Lib` exposes equivalent CarLife HU capabilities as a C++ dynamic-library integration surface for Linux and QNX-oriented environments. Public embedding APIs are defined in `CarLife-Vehicle-Lib/LibSource/include/CCarLifeLib.h`; the wrapper implementation is `CarLife-Vehicle-Lib/LibSource/libwrapper/CCarLifeLib.cpp`; connection/channel setup is split across `CarLife-Vehicle-Lib/LibSource/modules/CConnectionSetupModule.cpp` and command, control, media, video, TTS, and VR channel modules. Its protobuf source schemas in `CarLife-Vehicle-Lib/LibSource/protobuf/proto/` are the cross-language protocol contract shared conceptually with the Android implementation.

#### DuerOS Launcher and Supporting Artifacts
`DuerOS-Launcher` is a separate Gradle Android launcher product with landscape head-unit, portrait head-unit, and mirror variants. Each variant has its own manifest and `HomeActivity`, for example `DuerOS-Launcher/app-headunit-open/src/main/java/com/baidu/che/codriverlauncher/ui/HomeActivity.java`. Shared runtime concerns—application base, HTTP, caching, device adaptation, and bundled CoDriver SDK—are in `DuerOS-Launcher/core/`; map access is isolated behind `DuerOS-Launcher/map-sdk/src/main/java/com/baidu/che/codriverlauncher.mapsdk/MapSdkWrapper.java` and Baidu LBS binaries. `DSP-Solution-For-DuerOS/` and `DuerOS-Auto-Spec/` are documentation deliverables describing DSP voice processing and OEM integration requirements, not executable runtime modules.

Main entry points: [`CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/message/MsgHandlerCenter.java`](https://github.com/674809/carlife/blob/master/CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/message/MsgHandlerCenter.java) (Protocol dispatch), [`CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/CarLifeApplication.java`](https://github.com/674809/carlife/blob/master/CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/CarLifeApplication.java) (CarLife application), [`DuerOS-Launcher/app-headunit-open/src/main/java/com/baidu/che/codriverlauncher/ui/HomeActivity.java`](https://github.com/674809/carlife/blob/master/DuerOS-Launcher/app-headunit-open/src/main/java/com/baidu/che/codriverlauncher/ui/HomeActivity.java) (Launcher variants), [`CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/CarlifeActivity.java`](https://github.com/674809/carlife/blob/master/CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/CarlifeActivity.java) (CarLife activity)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_android["Android CarLife HU"]
  node_android_manifest["Android startup<br/>manifest"]
  node_application["CarLife application<br/>Android application"]
  node_activity["CarLife activity<br/>UI host"]
  node_ui_navigation["Fragments and layouts<br/>head-unit UI"]
  node_connection_service["Connection service<br/>session boundary"]
  node_connection_manager["Transport lifecycle<br/>connection manager"]
  node_socket_transport["Socket transport<br/>transport channel<br/>[ConnectSocket.java]"]
  node_protocol["Protocol dispatch<br/>message handlers"]
  node_protobuf_android["Android protobuf schemas<br/>protocol contract"]
  node_security["Authentication and crypto<br/>security boundary"]
  node_vehicle_io["Vehicle input and telemetry<br/>vehicle I/O"]
  node_media["Local media playback<br/>audio pipeline"]
  node_hfp["Bluetooth HFP<br/>Android Binder integration<br/>[BtHfpManager.java]"]
end

subgraph group_library["C++ CarLife Library"]
  node_cpp_api["C++ embedding API<br/>dynamic library API<br/>[CCarLifeLib.h]"]
  node_cpp_wrapper["C++ library wrapper<br/>library implementation<br/>[CCarLifeLib.cpp]"]
  node_cpp_connection["C++ connection setup<br/>channel setup"]
  node_protobuf_cpp["C++ protobuf schemas<br/>protocol contract"]
end

subgraph group_launcher["DuerOS Launcher"]
  node_launcher_variant["Launcher variants<br/>Android launcher<br/>[HomeActivity.java]"]
  node_launcher_core["Launcher core<br/>shared runtime"]
  node_map_sdk["Map SDK wrapper<br/>map boundary<br/>[MapSdkWrapper.java]"]
end

subgraph group_docs["Integration Documents"]
  node_dsp_docs["DSP voice design<br/>documentation deliverable"]
  node_auto_spec["DuerOS Auto specification<br/>OEM integration documentation"]
end

node_android_manifest -->|"starts"| node_application
node_application -->|"initializes"| node_activity
node_activity -->|"hosts"| node_ui_navigation
node_application -->|"runs session"| node_connection_service
node_connection_service -->|"delegates lifecycle"| node_connection_manager
node_connection_manager -->|"opens channel"| node_socket_transport
node_socket_transport -->|"carries messages"| node_protocol
node_protocol -->|"serializes"| node_protobuf_android
node_protocol -->|"negotiates auth"| node_security
node_protocol -->|"drives UI state"| node_ui_navigation
node_vehicle_io -->|"sends car events"| node_protocol
node_protocol -->|"delivers media"| node_media
node_protocol -->|"coordinates calls"| node_hfp
node_cpp_api -->|"implemented by"| node_cpp_wrapper
node_cpp_wrapper -->|"sets up channels"| node_cpp_connection
node_cpp_connection -->|"uses"| node_protobuf_cpp
node_protobuf_android -.->|"conceptual shared contract"| node_protobuf_cpp
node_launcher_variant -->|"uses"| node_launcher_core
node_launcher_variant -->|"accesses maps through"| node_map_sdk
node_dsp_docs -.->|"complements OEM integration"| node_auto_spec

click node_android_manifest "https://github.com/674809/carlife/blob/master/CarLife-Android-Vehicle/AndroidManifest.xml"
click node_application "https://github.com/674809/carlife/blob/master/CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/CarLifeApplication.java"
click node_activity "https://github.com/674809/carlife/blob/master/CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/CarlifeActivity.java"
click node_ui_navigation "https://github.com/674809/carlife/blob/master/CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/fragment/CarLifeFragmentManager.java"
click node_connection_service "https://github.com/674809/carlife/blob/master/CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/connect/ConnectService.java"
click node_connection_manager "https://github.com/674809/carlife/blob/master/CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/connect/ConnectManager.java"
click node_socket_transport "https://github.com/674809/carlife/blob/master/CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/connect/ConnectSocket.java"
click node_protocol "https://github.com/674809/carlife/blob/master/CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/message/MsgHandlerCenter.java"
click node_security "https://github.com/674809/carlife/blob/master/CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/encryption/EncryptSetupManager.java"
click node_vehicle_io "https://github.com/674809/carlife/blob/master/CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/touch/TouchListenerManager.java"
click node_media "https://github.com/674809/carlife/blob/master/CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/audioplayer/VehiclePCMPlayer.java"
click node_hfp "https://github.com/674809/carlife/blob/master/CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/bluetooth/BtHfpManager.java"
click node_cpp_api "https://github.com/674809/carlife/blob/master/CarLife-Vehicle-Lib/LibSource/include/CCarLifeLib.h"
click node_cpp_wrapper "https://github.com/674809/carlife/blob/master/CarLife-Vehicle-Lib/LibSource/libwrapper/CCarLifeLib.cpp"
click node_cpp_connection "https://github.com/674809/carlife/blob/master/CarLife-Vehicle-Lib/LibSource/modules/CConnectionSetupModule.cpp"
click node_launcher_variant "https://github.com/674809/carlife/blob/master/DuerOS-Launcher/app-headunit-open/src/main/java/com/baidu/che/codriverlauncher/ui/HomeActivity.java"
click node_map_sdk "https://github.com/674809/carlife/blob/master/DuerOS-Launcher/map-sdk/src/main/java/com/baidu/che/codriverlauncher.mapsdk/MapSdkWrapper.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_android_manifest,node_application,node_activity,node_ui_navigation,node_connection_service,node_connection_manager,node_socket_transport,node_protocol,node_protobuf_android,node_security,node_vehicle_io,node_media,node_hfp toneBlue
class node_cpp_api,node_cpp_wrapper,node_cpp_connection,node_protobuf_cpp toneAmber
class node_launcher_variant,node_launcher_core,node_map_sdk toneMint
class node_dsp_docs,node_auto_spec toneRose
```

## Components

### Android CarLife HU

- [Android startup](https://github.com/674809/carlife/blob/master/CarLife-Android-Vehicle/AndroidManifest.xml): manifest · `CarLife-Android-Vehicle/AndroidManifest.xml`
- [CarLife application](https://github.com/674809/carlife/blob/master/CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/CarLifeApplication.java): Android application · `CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/CarLifeApplication.java`
- [CarLife activity](https://github.com/674809/carlife/blob/master/CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/CarlifeActivity.java): UI host · `CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/CarlifeActivity.java`
- [Fragments and layouts](https://github.com/674809/carlife/blob/master/CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/fragment/CarLifeFragmentManager.java): head-unit UI · Connected, call, settings, authorization, and recovery states. · `CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/fragment/CarLifeFragmentManager.java`
- [Connection service](https://github.com/674809/carlife/blob/master/CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/connect/ConnectService.java): session boundary · `CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/connect/ConnectService.java`
- [Transport lifecycle](https://github.com/674809/carlife/blob/master/CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/connect/ConnectManager.java): connection manager · Coordinates USB, NCM, Wi-Fi, and iPhone multiplexed transports. · `CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/connect/ConnectManager.java`
- [Socket transport](https://github.com/674809/carlife/blob/master/CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/connect/ConnectSocket.java): transport channel · `CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/connect/ConnectSocket.java`
- [Protocol dispatch](https://github.com/674809/carlife/blob/master/CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/message/MsgHandlerCenter.java): message handlers · `CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/message/MsgHandlerCenter.java`
- **Android protobuf schemas**: protocol contract
- [Authentication and crypto](https://github.com/674809/carlife/blob/master/CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/encryption/EncryptSetupManager.java): security boundary · Establishes encryption and RSA/AES key exchange. · `CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/encryption/EncryptSetupManager.java`
- [Vehicle input and telemetry](https://github.com/674809/carlife/blob/master/CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/touch/TouchListenerManager.java): vehicle I/O · Forwards touch and reports vehicle data as protocol events. · `CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/touch/TouchListenerManager.java`
- [Local media playback](https://github.com/674809/carlife/blob/master/CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/audioplayer/VehiclePCMPlayer.java): audio pipeline · Buffers, arbitrates, and plays incoming PCM audio. · `CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/audioplayer/VehiclePCMPlayer.java`
- [Bluetooth HFP](https://github.com/674809/carlife/blob/master/CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/bluetooth/BtHfpManager.java): Android Binder integration · `CarLife-Android-Vehicle/src/com/baidu/carlifevehicle/bluetooth/BtHfpManager.java`

### C++ CarLife Library

- [C++ embedding API](https://github.com/674809/carlife/blob/master/CarLife-Vehicle-Lib/LibSource/include/CCarLifeLib.h): dynamic library API · Linux and QNX head-unit integration surface. · `CarLife-Vehicle-Lib/LibSource/include/CCarLifeLib.h`
- [C++ library wrapper](https://github.com/674809/carlife/blob/master/CarLife-Vehicle-Lib/LibSource/libwrapper/CCarLifeLib.cpp): library implementation · `CarLife-Vehicle-Lib/LibSource/libwrapper/CCarLifeLib.cpp`
- [C++ connection setup](https://github.com/674809/carlife/blob/master/CarLife-Vehicle-Lib/LibSource/modules/CConnectionSetupModule.cpp): channel setup · `CarLife-Vehicle-Lib/LibSource/modules/CConnectionSetupModule.cpp`
- **C++ protobuf schemas**: protocol contract

### DuerOS Launcher

- [Launcher variants](https://github.com/674809/carlife/blob/master/DuerOS-Launcher/app-headunit-open/src/main/java/com/baidu/che/codriverlauncher/ui/HomeActivity.java): Android launcher · Landscape, portrait, and mirror head-unit products. · `DuerOS-Launcher/app-headunit-open/src/main/java/com/baidu/che/codriverlauncher/ui/HomeActivity.java`
- **Launcher core**: shared runtime · Application base, networking, cache, adaptation, and CoDriver SDK.
- [Map SDK wrapper](https://github.com/674809/carlife/blob/master/DuerOS-Launcher/map-sdk/src/main/java/com/baidu/che/codriverlauncher.mapsdk/MapSdkWrapper.java): map boundary · `DuerOS-Launcher/map-sdk/src/main/java/com/baidu/che/codriverlauncher.mapsdk/MapSdkWrapper.java`

### Integration Documents

- **DSP voice design**: documentation deliverable
- **DuerOS Auto specification**: OEM integration documentation

## Connections

- Android startup → CarLife application: starts
- CarLife application → CarLife activity: initializes
- CarLife activity → Fragments and layouts: hosts
- CarLife application → Connection service: runs session
- Connection service → Transport lifecycle: delegates lifecycle
- Transport lifecycle → Socket transport: opens channel
- Socket transport → Protocol dispatch: carries messages
- Protocol dispatch → Android protobuf schemas: serializes
- Protocol dispatch → Authentication and crypto: negotiates auth
- Protocol dispatch → Fragments and layouts: drives UI state
- Vehicle input and telemetry → Protocol dispatch: sends car events
- Protocol dispatch → Local media playback: delivers media
- Protocol dispatch → Bluetooth HFP: coordinates calls
- C++ embedding API → C++ library wrapper: implemented by
- C++ library wrapper → C++ connection setup: sets up channels
- C++ connection setup → C++ protobuf schemas: uses
- Android protobuf schemas → C++ protobuf schemas: conceptual shared contract
- Launcher variants → Launcher core: uses
- Launcher variants → Map SDK wrapper: accesses maps through
- DSP voice design → DuerOS Auto specification: complements OEM integration
