Before starting the addition of the new HIDL interface you should source and lunch your environment, and compile it in order to build the needed HIDL tools
$ cd ~/repo
$ . build/envsetup.sh
$ lunch <product>
$ make -j64
- Create the new HIDL interface directory, method and types definitions
$ cd ~/repo # This is the root of Android Pie repo
$ mkdir -p hardware/interfaces/nayobixlabs/1.0
$ cd hardware/interfaces/nayobixlabs/1.0
$ vim INayobixlabs.hal
$ vim types.hal
$ cd ../../../../
$ cd hardware/interfaces
$ ./update-makefiles.sh
- Setup env variables for the new HIDL interface
$ cd ~/repo
$ PACKAGE=android.hardware.nayobixlabs@1.0
$ LOC=hardware/interfaces/nayobixlabs/1.0/default/
- Generate the defaut implementation:
$ cd ~/repo
$ hidl-gen -o $LOC -Lc++-impl -randroid.hardware:hardware/interfaces \
-randroid.hidl:system/libhidl/transport $PACKAGE
- Generate Android.bp for default implementation
$ hidl-gen -o $LOC -Landroidbp-impl -randroid.hardware:hardware/interfaces \
-randroid.hidl:system/libhidl/transport $PACKAGE
- Edit
device/<vendor>/<product>/manifest.xml file
Example:
Add the new HIDL interface to device/generic/goldfish/manifest.xml
-
After adding it to the device manifest file, then we should build Android again.
-
Check that the new HIDL interface is on the device and it is running:
$ adb shell lshal | grep nayobixlabs
android.hardware.nayobixlabs@1.0::I*/* (/vendor/lib/hw/) N/A N/A
$ adb shell ls /vendor/lib/hw | grep nayobixlabs
android.hardware.nayobixlabs@1.0-impl.so
Directory structure
.
├── device
│ └── generic
│ └── goldfish
│ └── manifest.xml
├── nayobixlabs # Created by us in hardware/interfaces
│ └── 1.0 # Created by us in hardware/interfaces
│ ├── Android.bp # Autogenerated by hidl-gen
│ ├── default # Autogenerated by hidl-gen
│ │ ├── Android.bp # Autogenerated by hidl-gen
│ │ ├── Nayobixlabs.cpp # Autogenerated by hidl-gen
│ │ └── Nayobixlabs.h # Autogenerated by hidl-gen
│ ├── INayobixlabs.hal # Created by us
│ └── types.hal # Created by us
└── README.md