Android 如何生成HIDL interface的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.


hidl-gen -L hash -r -r android.hardware:hardware/interfaces -r android.hidl:system/libhidl/transport


  • vendor.qti.hardware.camera是root,来自对应HIDL的Android.bp的root:

    // This file is autogenerated by hidl-gen -Landroidbp.
    hidl_interface {
      name: "",
      root: "",
      system_ext_specific: true,
      srcs: [
      interfaces: [
      gen_java: true,
  • vendor/qcom/opensource/interfaces/camera/是hidl_package_root Android.bp的文件路径名



deepinout@deepinout:out/host/linux-x86/bin$ hidl-gen -L hash -r -r android.hardware:hardware/interfaces -r android.hidl:system/libhidl/transport



ERROR: has hash 9a98e8c57dccdc51c5c318a45d73b370689aaab1ae8322b1cc91bfd498e425d8 which does not match hash on record. This interface has been frozen. Do not change it!


未经允许不得转载:极客笔记 » Android 如何生成HIDL interface的hash值

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址