Use String.getBytes().length to determine string length.

String.length() returns the number of UTF-16 code units,
but hidl_string objects are encoded in UTF-8; this will
cause verification failures in strings that are valid UTF-8,
but have a different number of code units in (Java's) UTF-16
encoding than in the native UTF-8 encoding.

Bug: 37722371
Test: hidl_test_java with shiny UTF-8 string (that requires a
      different number of code units in UTF-16)
Change-Id: I4fcf12c91b306c54c73013aef11bb049cb09190a
2 files changed
tree: 382dce2cdac906ab86d5e4abc5b14edcec868008
  1. c2hal/
  2. include_hash/
  3. test/
  4. utils/
  5. Android.bp
  6. Annotation.cpp
  7. Annotation.h
  8. ArrayType.cpp
  9. ArrayType.h
  10. AST.cpp
  11. AST.h
  12. CompoundType.cpp
  13. CompoundType.h
  14. ConstantExpression.cpp
  15. ConstantExpression.h
  16. Coordinator.cpp
  17. Coordinator.h
  18. DeathRecipientType.cpp
  19. DeathRecipientType.h
  20. EnumType.cpp
  21. EnumType.h
  22. FmqType.cpp
  23. FmqType.h
  24. generateCpp.cpp
  25. generateCppImpl.cpp
  26. generateJava.cpp
  27. generateVts.cpp
  28. HandleType.cpp
  29. HandleType.h
  30. Hash.cpp
  31. hidl-gen_l.ll
  32. hidl-gen_y.yy
  33. HidlTypeAssertion.cpp
  34. HidlTypeAssertion.h
  35. Interface.cpp
  36. Interface.h
  37. Location.h
  38. main.cpp
  39. MemoryType.cpp
  40. MemoryType.h
  41. Method.cpp
  42. Method.h
  43. MODULE_LICENSE_APACHE2
  44. NamedType.cpp
  45. NamedType.h
  46. NOTICE
  47. PointerType.cpp
  48. PointerType.h
  49. README.md
  50. RefType.cpp
  51. RefType.h
  52. ScalarType.cpp
  53. ScalarType.h
  54. Scope.cpp
  55. Scope.h
  56. StringType.cpp
  57. StringType.h
  58. Type.cpp
  59. Type.h
  60. TypeDef.cpp
  61. TypeDef.h
  62. update-makefiles-helper.sh
  63. VectorType.cpp
  64. VectorType.h
README.md

hidl-gen user guide

1. Build

croot
make hidl-gen

2. Run

hidl-gen -o output-path -L language (-r interface-root) fqname

output-path: directory to store the output files.
language: output file for given language. e.g.c++, vts..

fqname: fully qualified name of the input files.
For singe file input, follow the format: package@version::fileName
For directory input, follow the format: package@version

interface-root(optional): prefix and root path for fqname.
If not set, use the default prefix: android.hardware and default root path
defined in $TOP.

examples:

croot
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 -o output -L vts -r android.hardware:hardware/interfaces -r android.hidl:system/libhidl/transport android.hardware.nfc@1.0
hidl-gen -o test -L c++ -r android.hardware:hardware/interfaces -r android.hidl:system/libhidl/transport android.hardware.nfc@1.0