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


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.


2. (.hal) HIDL
formats and example:


3. Add your HAL to framework (client) and let upper layer’s service know your driver’s service. (.java)

Using the method of HIDL:

Modify Android.dp

How to build your HIDL as .so and .jar ?

Method 1: using

source system/tools/hidl/
do_makefiles_update \
"{HIDL library name}:{path}"

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}


hidl-gen -o output -L c++ -r android.hardware:hardware/interfaces -r android.hidl:system/libhidl/transport android.hardware.nfc@1.0::INfc.hal


hidl-gen -L hash -r vendor.awesome:vendor/awesome/hardware/interfaces -r android.hardware:hardware/interfaces -r android.hidl:system/libhidl/transport vendor.awesome.nfc@1.0

hidl-gen User Guide: