Implement your own HIDL
This note will explain the purpose of HIDL (.hal), how to implment, how to build and how to use those libraries?
HIDL | Android Open Source Project
Purpose:
HIDL is intended to be used for inter-process communication (IPC).
Some HALs are using another IPC methods like JNI or Socket to communicate with processes.

What do we do for HIDL? How to implement ?
1. (C++->.so)OEM/Vendor should write HAL (server) to register service to system.
https://source.android.com/devices/architecture/hidl/services#register

Ref.
https://android.googlesource.com/platform/hardware/ril/+/refs/heads/master/libril/ril_service.cpp#8568
2. (.hal) HIDL
formats and example:
https://source.android.com/devices/architecture/hidl/code-style

Ref.
https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/master/radio/1.5/
3. Add your HAL to framework (client) and let upper layer’s service know your driver’s service. (.java)
https://source.android.com/devices/architecture/hidl-java

Ref.
Using the method of HIDL:
https://android.googlesource.com/platform/frameworks/opt/telephony/+/refs/heads/master/src/java/com/android/internal/telephony/RIL.java#5273
Modify Android.dp
https://android.googlesource.com/platform/frameworks/opt/telephony/+/refs/heads/master/Android.bp?autodive=0#81
How to build your HIDL as .so and .jar ?
Method 1: using update-makefiles.sh:
source system/tools/hidl/update-makefiles-helper.sh
do_makefiles_update \
"{HIDL library name}:{path}"
Output:
out/soong/.intermediates/hardware/interfaces/ … /
You can find .java and .so which are generated by your HIDL.
Method 2: using hidl-gen tool:
You may use hidl-gen -h to find the manual.
hidl-gen -o {output_path} -L {language} -r {interface name with path}:{interface path} -r android.hidl:system/libhidl/transport {output library name}
e.g.
hidl-gen -o output -L c++ -r android.hardware:hardware/interfaces -r android.hidl:system/libhidl/transport [email protected]::INfc.hal
Hash:
hidl-gen -L hash -r vendor.awesome:vendor/awesome/hardware/interfaces -r android.hardware:hardware/interfaces -r android.hidl:system/libhidl/transport [email protected]
hidl-gen User Guide:
https://android.googlesource.com/platform/system/tools/hidl/+/master/README.md
Last modified 1yr ago