dilink-auto-android

Car Server App (app-server)

Overview

The car server app runs on the BYD DiLink infotainment system. It uses a parallel connection model with WiFi (3 dedicated connections) and USB tracks running simultaneously:

  1. Track A (WiFi): gateway IP + mDNS discovery, control connect (9637), handshake with phone
  2. After handshake: video (9638) + input (9639) connections opened in parallel
  3. Track B (USB): scan devices, USB ADB connect (with logSink diagnostics), launch phone app
  4. checkAndAdvance() evaluates state when any prerequisite changes
  5. Receives H.264 video and renders on car display (early decoder start on offscreen surface)
  6. Captures touch events and sends to phone via input connection for VD input injection

States: IDLE → CONNECTING → CONNECTED → STREAMING

Car APK is embedded in the phone APK. The phone auto-updates the car app via dadb when version mismatch is detected during handshake. Car receives UPDATING_CAR message and shows status instead of reconnecting blindly.

Two-Mode UI

The car app separates the connection flow from the streaming experience into two distinct modes, matching the phone app’s approach:

The transition trigger: when the phone sends APP_LIST via the control connection and the connection state reaches CONNECTED/STREAMING, the UI switches from launch mode to streaming mode.

Components

CarConnectionService

Foreground service managing the full connection lifecycle with a parallel prerequisite state machine and 3 dedicated connections.

3-Connection Architecture:

Parallel Track Architecture:

Track A — WiFi:

Track B — USB:

Update Flow:

State Flows:

VD Server Launch:

Early Decoder Start:

Car Log Routing:

VideoDecoder

H.264 decoder using MediaCodec with Surface output (GPU-direct rendering).

ServerApp

Application class. Creates notification channel dilinkauto_car_service with IMPORTANCE_LOW.

RemoteAdbController

Direct ADB client using dadb library. Provides tap, swipe, back, home, and app launch via shell commands on the virtual display. Used as an alternative input path.

CarLaunchScreen

Full-screen connection-focused composable shown before the phone connection is established — no nav bar, no app grid.

PersistentNavBar

76dp left navigation bar — only shown in streaming mode — with:

Width computed to guarantee even viewport for H.264 encoder.

NotificationScreen

App Grid (HomeContent)

Shown as the main content area when streaming mode is active and current screen is HOME:

LauncherScreen (Legacy)

Full integrated launcher layout with CarStatusBar, SideNavBar (80dp), and AppGrid. Not used in the current CarShell routing — the active UI uses PersistentNavBar + HomeContent/MirrorContent/NotificationContent composables inline.

RecentAppsState

Tracks recently launched apps (max 5), persisted to SharedPreferences. pruneUnavailable() removes apps no longer present when app list updates.

Individual nav bar widget composables: ClockDisplay (updates every 1s), NetworkInfo (connected/disconnected state), RecentAppIcon (40dp, with active state highlight), NavActionButton (40dp icons, 12sp labels).

CarTheme

Material3 dark color scheme (CarDark) with category-specific app tile colors: Navigation (green), Music (pink), Communication (blue), Other (gray).

Car Display Info

Tested on BYD DiLink 3.0:

Dependencies