This is a bit of process.
It’s been a while since we were using the default vehicle impl, so these instructions might be a bit out of date.
Adding the Automotive HAL to a device
Inherit from the “car” build
Inherit from the car
product in the device makefile (device/linaro/hikey/hikey960.mk
):
$(call inherit-product, packages/services/Car/car_product/build/car.mk)
The vehicle HAL (android.hardware.automotive.vehicle@2.0
) and other required services/apps are included through car.mk
Set SELinux to Permissive
In order to get the HAL to appear in the binderized section of the lshal
command, we must:
Manually start the service:
Do this in a terminal window you don’t mind losing.
Backgrounding like this while inside an adb connection will cause you to lose it.
Note that this will not work if you pass the command to adb shell
.
It must be an interactive shell to work properly.
adb shell
/vendor/bin/hw/android.hardware.automotive.vehicle@2.0-service &
Fix the Device Manifest (optional)
To prevent this warning in the logcat logs add the vehicle HAL to the manifest.xml
(device/linaro/hikey/manifest.xml
)
https://source.android.com/devices/architecture/vintf/objects#device-manifest-file
ERROR:
The following error occurred when manifest.xml defined ‘hikey.hardware.automotive.vehicle’
‘/system/bin/hwservicemanager: getTransport: Cannot find entry android.hardware.automotive.vehicle@2.0::IVehicle/default in either framework or device manifest’
<hal format="hidl">
<name>android.hardware.automotive.vehicle</name>
<transport>hwbinder</transport>
<version>2.0</version>
<interface>
<name>IVehicle</name>
<instance>default</instance>
</interface>
</hal>
Don’t forget to rebuild the device and re-install.
Automatically Start the Service on Boot
Finally, in order for init
to automatically start the hardware service on boot, we need to add an SELinux domain and file context.
(Even though we’ve set SELinux to permissive, it is still enabled. Android does not allow disabling SELinux, only making it more permissive. So, there is still a minimal amount of configuration to be done.)
Create a *.te
file for the hardware service that defines the domain.
device/linaro/hikey/sepolicy/hal_vehicle_hikey.te
# vehicle subsystem
type hal_vehicle_hikey, domain;
# may be started by init
type hal_vehicle_hikey_exec, exec_type, file_type;
init_daemon_domain(hal_vehicle_hikey)
Then add the domain to the executable to the domain.
device/linaro/hikey/sepolicy/file_contexts
/system/vendor/bin/hw/android\.hardware\.automotive\.vehicle@2\.0-service u:object_r:hal_vehicle_hikey_exec:s0
Demonstrating the fake-value-generator HAL