Define the system graph

Android 17 QPR2 introduces the VSIDL system graph, which lets you declaratively define the deployment topology, lifecycle orchestration, health and quality of service (QoS) monitoring, APEX packaging, and communication authorization policies of a software-defined vehicle (SDV) directly in .vsidl files. By centralizing the system definition in your catalog, vsidlc validates system-wide architectural rules at compile time and automatically generates the required Soong build targets and runtime configuration files.

vsidlc runs system graph and APEX generation automatically whenever your catalog contains at least one apex or host block, or when you pass the --apex flag on the command line.

Define APEX build rules

The apex block defines how service bundles are packaged into Android Pony EXpress (APEX) artifacts. It maps logical service bundle definitions to physical libraries and runtime configuration files.

The following example defines an apex block and a service_bundle_manifest entry:

package: "com.android.sdv.example"

apex {
  name: "tire_apex"

  service_bundle_manifest {
    name: "TireAnalytics"
    service_bundle: "TireAnalytics"
    version_name: "2.7.0-beta"
    version_number: 2
    log_tag: "ta-bundle"
    metadata {
      key: "domain"
      value: "chassis"
    }
  }
}

This block serves as the source of truth for generating APEX build rules and metadata, including Android.bp, apex_manifest.json, sdv_service_bundles_manifest.textproto, file_contexts, and signing keys.

APEX naming and defaults

When you define an apex block, vsidlc resolves names and defaults as follows:

  • APEX name (name):
    • If you omit name in the apex block, vsidlc uses the file's package name (for example, com.android.sdv.example) as the fully qualified APEX name and writes generated files to generated/apex/<package>/.
    • If you specify name (for example, name: "tire_apex"), vsidlc scopes the name under the file's package name to form the fully qualified APEX name <package>.<name> (for example, com.android.sdv.example.tire_apex) and writes generated files to generated/apex/<package>.<name>/.
    • If you run vsidlc --apex or define a host block without defining any apex blocks in your catalog, vsidlc synthesizes a single default APEX named after the first service bundle's package name that packages all service bundles in the catalog.
  • Service bundle manifest (service_bundle_manifest):
    • service_bundle (required): References a service_bundle definition in the catalog by unqualified name, relative path, or fully qualified name.
    • name (optional): Identifies the manifest entry. If omitted, vsidlc defaults name to the unqualified name of the referenced service_bundle.
    • version_number and version_name (optional): Default to 0 and "0.1 Alpha" when omitted.
    • log_tag (optional): Sets the logcat tag in sdv_service_bundles_manifest.textproto.
    • native_library and native_library_path (optional): Mutually exclusive fields that configure the shared library for the service bundle. By default, native_library is set to libsdv_lm_<snake_case_service_bundle_fqn> and native_library_path is set to lib64/<native_library>.so.
    • metadata (optional): Attaches custom key and value pairs to the service bundle manifest.

Override generated configurations

By default, vsidlc generates runtime configuration files for each service bundle in an APEX. You can override any generated file or change its install location in the APEX by specifying a resource block with src and dst fields inside service_bundle_manifest:

  • src: Path to a custom configuration file, relative to your catalog directory (--catalog-path). When src is set, vsidlc validates the file and copies it into the APEX instead of generating the configuration automatically.
  • dst: Destination path inside the APEX. Every dst path must start with etc/ and must be unique within the apex block.

A service_bundle_manifest supports two categories of resource blocks:

  • Automatically generated resources: vsidlc generates these files by default unless you override them with src:
    • orchestration: Lifecycle configuration (default dst: etc/<BundleName>/orchestrator.textproto).
    • authz: Communication authorization policy (default dst: etc/<BundleName>/permissions.textproto).
    • health: Health and QoS monitoring configuration, generated when an instance configures health or qos (default dst: etc/<BundleName>/health.textproto).
    • diagnostics: Diagnostics configuration, generated when the service bundle declares diagnostics_declaration (default dst: etc/<BundleName>/diagnostics-config.binpb).
    • someip: SOME/IP mapping configuration, generated when the catalog or its dependencies contain SOME/IP mappings (default dst: etc/<BundleName>/someip-config.binpb).
    • vsidl_schema: Binary VSIDL reflection descriptor, generated when the service bundle declares publishers, subscribers, servers, or clients (default dst: etc/<BundleName>/vsidl-config.binpb).
  • Manual-only resources: vsidlc includes these configurations in the APEX only when you specify a src file:
    • concal: Configuration and calibration settings (default dst when src is provided: etc/<BundleName>/<src_filename>).
    • preferences: User preferences settings (default dst when src is provided: etc/<BundleName>/<src_filename>).
    • scheduling: Quality of service scheduling configuration (default dst when src is provided: etc/<BundleName>/<src_filename>).

The following example overrides the generated authorization policy with a custom file from the catalog and includes a manual concal configuration:

apex {
  service_bundle_manifest {
    service_bundle: "TireAnalytics"

    authz {
      src: "overrides/custom_permissions.textproto"
      dst: "etc/TireAnalytics/permissions.textproto"
    }

    concal {
      src: "configs/tire_concal.binpb"
    }
  }
}

Define the system topology

The host and vm blocks define the runtime deployment topology. They specify how service bundle manifests are instantiated and distributed across hosts and virtual machines (VMs).

The following example defines a host with one VM and three service bundle instances:

host {
  name: "TireMonitoringSystem"

  vm {
    name: "ZoneController"

    instance {
      name: "instance-main"
      service_bundle_manifest: "TireAnalytics"
    }

    instance {
      name: "instance-front"
      name: "instance-rear"
      service_bundle_manifest: "TireSensor"
    }
  }
}

When defining your system topology, keep the following rules in mind:

  • Unique host and vm blocks: Each host must have a globally unique name across the catalog, and each vm must have a unique name within its host. Separate host or vm blocks aren't merged.
  • Service bundle instances (instance or service_bundle_instance): Inside a vm block, you can declare instances using either the instance keyword or the service_bundle_instance keyword.
  • Multiple instance names per block: A single instance block can specify multiple name fields. All instances listed in the same block instantiate the same service_bundle_manifest and share the block's group, orchestration, health, and qos configurations.
  • Instance naming format: Every instance name must use lowercase dash case (start with a lowercase letter, contain only lowercase letters, digits, and hyphens, and avoid consecutive or trailing hyphens) and must be unique per combination of VM, APEX, and service bundle.

Configure orchestration

You can configure the lifecycle behavior of service bundle instances using orchestration blocks at both the VM level and the instance level.

If you don't define any host or vm blocks in your catalog, vsidlc synthesizes a default VM (named after the last segment of the APEX's package name) and default orchestration configuration. In this default configuration, each service bundle has a single instance named instance in an auto-start group (vm_<snake_case_vm_name>_auto_start, a subgroup of auto_start) that is created during suspend-to-RAM states (SUSPEND_TO_RAM_ENTER || WAIT_FOR_FINISH || SUSPEND_TO_RAM_POST_FINISH) and started during active power states (ON || POWER_OFF_EXIT || SUSPEND_TO_RAM_EXIT). When at least one vm block is defined in your catalog, vsidlc generates orchestrator.textproto only for service bundles that have a declared instance in a vm, though any defined vm that omits group or state blocks still receives the default auto_start group mapping and power state transitions.

Condition expressions and state precedence

Orchestration state blocks use boolean condition expressions to trigger create, start, and destroy lifecycle actions:

  • Boolean operators: Conditions support logical NOT (!), logical AND (&&), logical OR (||), and parentheses (( and )). When generating .textproto files, vsidlc parses the boolean expression and writes structured and, or, not, power_state, and vehicle_state protobuf fields.
  • Power states (PowerStateReport): Conditions can reference standard Vehicle Power Mode (VPM) power states: POWER_OFF_EXIT, SUSPEND_TO_RAM_EXIT, SUSPEND_TO_DISK_EXIT, ON, POWER_OFF_ENTER, SUSPEND_TO_RAM_ENTER, SUSPEND_TO_DISK_ENTER, WAIT_FOR_FINISH, SHUTDOWN_CANCELLED, POWER_OFF_POST_FINISH, SUSPEND_TO_RAM_POST_FINISH, and SUSPEND_TO_DISK_POST_FINISH.
  • Vehicle states (VpmVehicleState): Conditions can reference standard VPM vehicle states: LOW_POWER, SOFTWARE_UPDATE, PARK, LIFE_ON_BOARD, VEHICLE_ON, and TRACTION_ON.
  • Action precedence: If multiple conditions evaluate to true at the same time for a group or instance, destroy takes highest precedence, followed by start, and then create.

Configure VM-level orchestration

At the VM level, the orchestration block organizes instances into groups (including hierarchical subgroups using subgroup_of) and defines group-level state transitions in generated/vm/<snake_case_vm_name>/vm_<snake_case_vm_name>_orch_config.textproto.

The following example configures a parent group, a subgroup, and group state transitions for a VM:

vm {
  name: "ZoneController"

  orchestration {
    group {
      name: "auto_start"
    }
    group {
      name: "driving_services"
      subgroup_of: "auto_start"
    }
    state {
      condition: "ON || POWER_OFF_EXIT || SUSPEND_TO_RAM_EXIT"
      groups_states {
        start: "auto_start"
      }
    }
    state {
      condition: "SUSPEND_TO_RAM_ENTER || WAIT_FOR_FINISH || SUSPEND_TO_RAM_POST_FINISH"
      groups_states {
        create: "auto_start"
      }
    }
  }

  instance {
    name: "instance1"
    service_bundle_manifest: "TireAnalytics"
    group: "driving_services"
  }
}

Configure instance-level orchestration

At the instance level, the orchestration block configures instance-specific lifecycle transitions and the maximum number of restart retries (must be 0 or greater; defaults to the value of the sysprop ro.boot.sdv.orchestrator.recovery.max_retries or 0 if not defined). vsidlc writes these settings to the service bundle's orchestrator.textproto file.

The following example configures retries and instance-level state transitions:

instance {
  name: "instance1"
  service_bundle_manifest: "TireAnalytics"
  group: "auto_start"

  orchestration {
    retries: 2
    state {
      condition: "LOW_POWER"
      instances_states {
        destroy: "instance1"
      }
    }
  }
}

For more information about orchestration concepts, see Configure the Orchestrator.

Configure health monitoring and QoS

You can configure periodic heartbeat monitoring (health) and topic-level quality of service monitoring (qos) directly on service bundle instances. When at least one instance of a service bundle includes a health or qos block, vsidlc generates a health.textproto configuration file for that bundle.

The following example configures both heartbeat monitoring and QoS latency and period thresholds on an instance:

instance {
  name: "instance1"
  service_bundle_manifest: "TireAnalytics"
  group: "auto_start"

  health {
    initial_delay_ms: 20
    period_ms: 200
    num_periods: 4
    task_duration_ms: 500
  }

  qos {
    topic: "pressure"
    config {
      qos_period_threshold_ms: 100
      qos_latency_threshold_ms: 50
    }
  }
}

When configuring health and QoS monitoring, ensure your service bundle satisfies the following requirements:

  • Heartbeat publisher (health): If an instance defines a health block, its service_bundle must declare a publisher for the com.android.sdv.health.ServiceHeartbeat message. Both period_ms and num_periods must be greater than 0.
  • Monitored topic publisher (qos): Each qos block must reference a topic that the service bundle instance publishes QoS heartbeats on, and its config block must specify at least one threshold (qos_period_threshold_ms or qos_latency_threshold_ms).

For more information about runtime monitoring, see Health monitoring and Quality of service scheduling.

Generate authorization policies

For each service bundle in an APEX (unless overridden with a custom authz src file), vsidlc automatically generates a permissions.textproto communication authorization policy (AuthzPolicy) in generated/apex/<fully_qualified_apex_name>/<service_bundle_name>/permissions.textproto following the principle of least privilege:

  • Publishers (publisher): Grants permission to publish each declared message on its configured topic list.
  • Subscribers (subscriber): Grants permission to subscribe to each declared message on its configured topic list.
  • RPC servers (server): Grants permission to offer each declared RPC service on its configured channel.
  • RPC clients (client): Grants permission to call each declared RPC service on its configured channel.

Generated permissions.textproto files never set allow_all_topics: true or allow_all_channels: true. For more information about manually authoring authorization policies (such as custom authz override files), see Authorization policy.

Integrate handwritten code

You can integrate your service bundle business logic with the generated APEX build targets in three ways:

  1. Use the generated --services and --hwc scaffolding: When you run vsidlc with --services (and optionally --hwc <dir>, which defaults to <output_path>/hwc), vsidlc generates a rust_defaults target (libsdv_lm_<snake_case_service_bundle_fqn>@defaults) and a generated skeleton library (libsdv_lm_<snake_case_service_bundle_fqn>_gen) in generated/services/<package_path>/<service_bundle_name>/Android.bp. If the handwritten code directory doesn't exist yet, vsidlc also initializes a modifiable rust_ffi_shared target (libsdv_lm_<snake_case_service_bundle_fqn>) and src/main.rs in hwc/services/<package_path>/<service_bundle_name>/. Because the default native_library in service_bundle_manifest points to libsdv_lm_<snake_case_service_bundle_fqn>, no changes to your .vsidl file are required.
  2. Specify a custom Soong library target (native_library): If you define a custom rust_ffi_shared or cc_library_shared module in your own Android.bp file, set native_library in service_bundle_manifest to that Soong target name. vsidlc adds the target to native_shared_libs in the APEX's Android.bp file and sets native_library_path to lib64/<native_library>.so in sdv_service_bundles_manifest.textproto:

    apex {
      service_bundle_manifest {
        service_bundle: "TireAnalytics"
        native_library: "libtpms_service"
      }
    }
    
  3. Include a prebuilt library (prebuilt_etc and native_library_path): If you package a precompiled binary using a prebuilt_etc module, add the module name to prebuilt_etc in the apex block and set native_library_path in service_bundle_manifest (mutually exclusive with native_library):

    apex {
      prebuilt_etc: "my_prebuilt_library"
    
      service_bundle_manifest {
        service_bundle: "TireAnalytics"
        native_library_path: "etc/my_prebuilt_library.so"
      }
    }
    

What's next

After defining your system graph, see the following resources: