有两种方法可以产生HIDL的Hash值。
使用hidl-gen 产生HIDL Hash值
执行 hidl-gen -h
能得到如下输出:
Usage: hidl-gen -o <output path> -L <language> [-O <owner>] [-p <root path>] (-r <interface root>)+ [-R] [-v] [-d <depfile>] FQNAME...
Process FQNAME, PACKAGE(.SUBPACKAGE)*@[0-9]+.[0-9]+(::TYPE)?, to create output.
-h: Prints this menu.
-L <language>: The following options are available:
check : Parses the interface to see if valid but doesn't write any files.
c++ : (internal) (deprecated) Generates C++ interface files for talking to HIDL interfaces.
c++-headers : (internal) Generates C++ headers for interface files for talking to HIDL interfaces.
c++-sources : (internal) Generates C++ sources for interface files for talking to HIDL interfaces.
export-header : Generates a header file from @export enumerations to help maintain legacy code.
c++-impl : Generates boilerplate implementation of a hidl interface in C++ (for convenience).
c++-impl-headers: c++-impl but headers only.
c++-impl-sources: c++-impl but sources only.
c++-adapter : Takes a x.(y+n) interface and mocks an x.y interface.
c++-adapter-headers: c++-adapter but helper headers only.
c++-adapter-sources: c++-adapter but helper sources only.
c++-adapter-main: c++-adapter but the adapter binary source only.
java : (internal) Generates Java library for talking to HIDL interfaces in Java.
java-impl : Generates boilerplate implementation of a hidl interface in Java (for convenience).
java-constants : (internal) Like export-header but for Java (always created by -Lmakefile if @export exists).
vts : (internal) Generates vts proto files for use in vtsd.
makefile : (removed) Used to generate makefiles for -Ljava and -Ljava-constants.
androidbp : (internal) Generates Soong bp files for -Lc++-headers, -Lc++-sources, -Ljava, -Ljava-constants, and -Lc++-adapter.
androidbp-impl : Generates boilerplate bp files for implementation created with -Lc++-impl.
hash : Prints hashes of interface in `current.txt` format to standard out.
function-count : Prints the total number of functions added by the package or interface.
dependencies : Prints all depended types.
inheritance-hierarchy: Prints the hierarchy of inherited types as a JSON object.
format : Reformats the .hal files
-O <owner>: The owner of the module for -Landroidbp(-impl)?.
-o <output path>: Location to output files.
-p <root path>: Android build root, defaults to $ANDROID_BUILD_TOP or pwd.
-R: Do not add default package roots if not specified in -r.
-r <package:path root>: E.g., android.hardware:hardware/interfaces.
-v: verbose output.
-d <depfile>: location of depfile to write to.
进入到./out/host/linux-x86/bin/
执行如下命令产生hash值:
hidl-gen -L hash -r vendor.qti.hardware.camera:vendor/qcom/opensource/interfaces/camera/ -r android.hardware:hardware/interfaces -r android.hidl:system/libhidl/transport vendor.qti.hardware.camera.postproc@1.0
其中:
-
vendor.qti.hardware.camera
是root,来自对应HIDL的Android.bp
的root:// This file is autogenerated by hidl-gen -Landroidbp. hidl_interface { name: "vendor.qti.hardware.camera.postproc@1.0", root: "vendor.qti.hardware.camera", system_ext_specific: true, srcs: [ "types.hal", "IPostProcService.hal", "IPostProcServiceCallBacks.hal", "IPostProcSession.hal", ], interfaces: [ "android.hidl.base@1.0", ], gen_java: true, }
-
vendor/qcom/opensource/interfaces/camera/
是hidl_package_root Android.bp的文件路径名 -
vendor.qti.hardware.camera.postproc@1.0
的对应HIDL的name
示例输出如下:
deepinout@deepinout:out/host/linux-x86/bin$ hidl-gen -L hash -r vendor.qti.hardware.camera:vendor/qcom/opensource/interfaces/camera/ -r android.hardware:hardware/interfaces -r android.hidl:system/libhidl/transport vendor.qti.hardware.camera.postproc@1.0
8e82153c316275c570e7e803be447308745dfd84a8ef19c26e4f66e38612b27b vendor.qti.hardware.camera.postproc@1.0::types
1f128a60e07e9750d93ba106e74cd2ab38268994ca8c53816659ae2abce31176 vendor.qti.hardware.camera.postproc@1.0::IPostProcService
129c97e20ef36e8ac4ec9b2b8a2083849bc5932a62e434af2eb977f1ab8594db vendor.qti.hardware.camera.postproc@1.0::IPostProcServiceCallBacks
df8ddeff86819bb9775c2d1ee4c6d3adb55f1c9c9964d730f99d37136b0a2f5d vendor.qti.hardware.camera.postproc@1.0::IPostProcSession
通过编译错误来产生Hash值
修改HIDL接口后,直接编译会报错,提示:
ERROR: vendor.qti.hardware.camera.postproc@1.0::types has hash 9a98e8c57dccdc51c5c318a45d73b370689aaab1ae8322b1cc91bfd498e425d8 which does not match hash on record. This interface has been frozen. Do not change it!
然后直接将新产生的Hash值9a98e8c57dccdc51c5c318a45d73b370689aaab1ae8322b1cc91bfd498e425d8
粘贴到vendor/qcom/opensource/interfaces/camera/current.txt
里面。