This tutorial will cover a specific use case with Android Automotive: how to dynamically change vehicle properties?
Concepts
In Android Automotive, several parameters of the vehicle are abstracted by the Vehicle HAL and handled via Vehicle Properties.
These parameters include the vehicle speed, doors opening, gear selection, fuel level, and many more (see VehiclePropertyIds for a more detailed list).
In a real vehicle, the Vehicle HAL continuously communicates with various vehicle sensors and ECUs to retrieve the value of these parameters and expose them to the Android apps.
In an automotive emulator, the VHAL is not connected to any real hardware. For testing and demonstration purposes, we implemented a way to dynamically inject values for these properties via a gRPC server (running on the device) and a gRPC client (running either on the device or on a host machine).
This allows you to mock the state of the vehicle in a simple way, which can be very useful in the context of automated tests.
Using the gRPC client
For this example, we have implemented a small gRPC client which is able to get and set the values of a subset of vehicle properties. You can try it as follows:
- On the device, click on the icon
at the bottom navigation area, swipe to the right and start the VehicleDemo application. It displays the current state of some vehicle properties:
- Open a new browser tab with the IP address of your device, and go to the Shell panel:

- Run the following commands:
# Display the help of the gRPC client:
./system/vendor/bin/grpc-vhal-aidl-client --help
# Get or set the value of a vehicle property by sending messages to the VHAL gRPC server.
# If no new value is passed via '-v', then the current value will be retrieved.
#
# usage: ./system/vendor/bin/grpc-vhal-aidl-client -s <grpc_server_address:port> -i <prop_id> -v <prop_value>
# ex: ./system/vendor/bin/grpc-vhal-aidl-client -s 0.0.0.0:45001 -i 287310602 -v 1
#
# Supported properties:
# FUEL_LEVEL id=291504903 type=float range=[0-15000] (in mL)
# FUEL_DOOR_OPEN id=287310600 type=int32 range=[0,1]
# FUEL_LEVEL_LOW id=287310853 type=int32 range=[0,1]
# PERF_VEHICLE_SPEED id=291504647 type=float range=[<0 when vehicle is going backwards, >0 forward] (in m/s)
# GEAR_SELECTION id=289408000 type=int32 range=[0,1,2,4,8,16,32,64,128,256,512,1024,2048,4096]
# EV_BATTERY_LEVEL id=291504905 type=float range=[0-150000] (in Wh)
# EV_CHARGE_PORT_OPEN id=287310602 type=int32 range=[0,1]
# Open the fuel door:
./system/vendor/bin/grpc-vhal-aidl-client -s 0.0.0.0:45001 -i 287310600 -v 1
# Connecting to server at 0.0.0.0:45001
# Connected to the server at 0.0.0.0:45001
# Setting the value of 287310600 to 1
# Get whether the fuel door is opened (1) or not (0):
./system/vendor/bin/grpc-vhal-aidl-client -s 0.0.0.0:45001 -i 287310600
# Connecting to server at 0.0.0.0:45001
# Connected to the server at 0.0.0.0:45001
# The value of 287310600 is:
# VehiclePropValue{timestamp: 288592858284, areaId: 0, prop: 287310600, status: AVAILABLE,
# value: RawPropValues{int32Values: [1], floatValues: [], int64Values: [], byteValues: [], stringValue: }}The fuel door now appears in red in the VehicleDemo application:

This small demonstration client only covers a subset of vehicle properties, but the good news is that you can implement your own gRPC client!
Access the gRPC server
The gRPC server running on the device is accessible via TCP requests on <virtual_device_IP_address:45001> (don’t forget to open this port in your AWS EC2 security group). Then you can implement your gRPC client by relying on the AAOS VehicleServer.proto gRPC APIs and the corresponding proto files.
