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
namein theapexblock,vsidlcuses the file'spackagename (for example,com.android.sdv.example) as the fully qualified APEX name and writes generated files togenerated/apex/<package>/. - If you specify
name(for example,name: "tire_apex"),vsidlcscopes the name under the file'spackagename to form the fully qualified APEX name<package>.<name>(for example,com.android.sdv.example.tire_apex) and writes generated files togenerated/apex/<package>.<name>/. - If you run
vsidlc --apexor define ahostblock without defining anyapexblocks in your catalog,vsidlcsynthesizes a single default APEX named after the first service bundle'spackagename that packages all service bundles in the catalog.
- If you omit
- Service bundle manifest (
service_bundle_manifest):service_bundle(required): References aservice_bundledefinition in the catalog by unqualified name, relative path, or fully qualified name.name(optional): Identifies the manifest entry. If omitted,vsidlcdefaultsnameto the unqualified name of the referencedservice_bundle.version_numberandversion_name(optional): Default to0and"0.1 Alpha"when omitted.log_tag(optional): Sets the logcat tag insdv_service_bundles_manifest.textproto.native_libraryandnative_library_path(optional): Mutually exclusive fields that configure the shared library for the service bundle. By default,native_libraryis set tolibsdv_lm_<snake_case_service_bundle_fqn>andnative_library_pathis set tolib64/<native_library>.so.metadata(optional): Attaches customkeyandvaluepairs 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). Whensrcis set,vsidlcvalidates the file and copies it into the APEX instead of generating the configuration automatically.dst: Destination path inside the APEX. Everydstpath must start withetc/and must be unique within theapexblock.
A service_bundle_manifest supports two categories of resource blocks:
- Automatically generated resources:
vsidlcgenerates these files by default unless you override them withsrc:orchestration: Lifecycle configuration (defaultdst:etc/<BundleName>/orchestrator.textproto).authz: Communication authorization policy (defaultdst:etc/<BundleName>/permissions.textproto).health: Health and QoS monitoring configuration, generated when an instance configureshealthorqos(defaultdst:etc/<BundleName>/health.textproto).diagnostics: Diagnostics configuration, generated when the service bundle declaresdiagnostics_declaration(defaultdst:etc/<BundleName>/diagnostics-config.binpb).someip: SOME/IP mapping configuration, generated when the catalog or its dependencies contain SOME/IP mappings (defaultdst:etc/<BundleName>/someip-config.binpb).vsidl_schema: Binary VSIDL reflection descriptor, generated when the service bundle declares publishers, subscribers, servers, or clients (defaultdst:etc/<BundleName>/vsidl-config.binpb).
- Manual-only resources:
vsidlcincludes these configurations in the APEX only when you specify asrcfile:concal: Configuration and calibration settings (defaultdstwhensrcis provided:etc/<BundleName>/<src_filename>).preferences: User preferences settings (defaultdstwhensrcis provided:etc/<BundleName>/<src_filename>).scheduling: Quality of service scheduling configuration (defaultdstwhensrcis 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
hostandvmblocks: Eachhostmust have a globally uniquenameacross the catalog, and eachvmmust have a uniquenamewithin itshost. Separatehostorvmblocks aren't merged. - Service bundle instances (
instanceorservice_bundle_instance): Inside avmblock, you can declare instances using either theinstancekeyword or theservice_bundle_instancekeyword. - Multiple instance names per block: A single
instanceblock can specify multiplenamefields. All instances listed in the same block instantiate the sameservice_bundle_manifestand share the block'sgroup,orchestration,health, andqosconfigurations. - Instance naming format: Every instance
namemust 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.textprotofiles,vsidlcparses the boolean expression and writes structuredand,or,not,power_state, andvehicle_stateprotobuf 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, andSUSPEND_TO_DISK_POST_FINISH. - Vehicle states (
VpmVehicleState): Conditions can reference standard VPM vehicle states:LOW_POWER,SOFTWARE_UPDATE,PARK,LIFE_ON_BOARD,VEHICLE_ON, andTRACTION_ON. - Action precedence: If multiple conditions evaluate to true at the same
time for a group or instance,
destroytakes highest precedence, followed bystart, and thencreate.
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 ahealthblock, itsservice_bundlemust declare apublisherfor thecom.android.sdv.health.ServiceHeartbeatmessage. Bothperiod_msandnum_periodsmust be greater than0. - Monitored topic publisher (
qos): Eachqosblock must reference atopicthat the service bundle instance publishes QoS heartbeats on, and itsconfigblock must specify at least one threshold (qos_period_threshold_msorqos_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 declaredmessageon its configuredtopiclist. - Subscribers (
subscriber): Grants permission to subscribe to each declaredmessageon its configuredtopiclist. - RPC servers (
server): Grants permission to offer each declared RPCserviceon its configuredchannel. - RPC clients (
client): Grants permission to call each declared RPCserviceon its configuredchannel.
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:
- Use the generated
--servicesand--hwcscaffolding: When you runvsidlcwith--services(and optionally--hwc <dir>, which defaults to<output_path>/hwc),vsidlcgenerates arust_defaultstarget (libsdv_lm_<snake_case_service_bundle_fqn>@defaults) and a generated skeleton library (libsdv_lm_<snake_case_service_bundle_fqn>_gen) ingenerated/services/<package_path>/<service_bundle_name>/Android.bp. If the handwritten code directory doesn't exist yet,vsidlcalso initializes a modifiablerust_ffi_sharedtarget (libsdv_lm_<snake_case_service_bundle_fqn>) andsrc/main.rsinhwc/services/<package_path>/<service_bundle_name>/. Because the defaultnative_libraryinservice_bundle_manifestpoints tolibsdv_lm_<snake_case_service_bundle_fqn>, no changes to your.vsidlfile are required. Specify a custom Soong library target (
native_library): If you define a customrust_ffi_sharedorcc_library_sharedmodule in your ownAndroid.bpfile, setnative_libraryinservice_bundle_manifestto that Soong target name.vsidlcadds the target tonative_shared_libsin the APEX'sAndroid.bpfile and setsnative_library_pathtolib64/<native_library>.soinsdv_service_bundles_manifest.textproto:apex { service_bundle_manifest { service_bundle: "TireAnalytics" native_library: "libtpms_service" } }Include a prebuilt library (
prebuilt_etcandnative_library_path): If you package a precompiled binary using aprebuilt_etcmodule, add the module name toprebuilt_etcin theapexblock and setnative_library_pathinservice_bundle_manifest(mutually exclusive withnative_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:
- To build and deploy your generated APEX packages, see Build and deploy service bundles.
- To read the formal grammar, protobuf schema, and compiler constraints for system graph elements, see the Language specification.