Require manifest specification for HIDL devices.

Changed vintfEmpty -> vintfLegacy which is based on
__ANDROID_TREBLE__.

This change does two things:
- make sure that race conditions between framework startup and
  service startup don't occur unless "tryGetService" is explicitly
  used. Since this change makes sure hals are actually in the manifest,
  getService will always wait when appropriate.
- prevent framework backwards compatibility breaking for certain
  development models (described below).

On Treble devices, allow this safety check to be turned off
during tests (like hidl_test) which register and unregister
services dynamically for testing purposes. On legacy/pre-Treble
devices, behavior is unchanged.

This means that you must set TREBLE_TESTING_OVERRIDE when running a test such
as hidl_test. Ideally these binaries set this value themselves. This allows
test modules to dynamically add and unset services even though they are not
declared in the device manifest. This prevents a problem where framework
changes are accidentally made in a way that is not backwards compatible. For
instance, consider the following situation for two devices developed in the
same tree:
A: serves @1.1::IFoo, declares @1.0::IFoo (incorrect)
B: serves @1.0::IFoo, declares @1.0::IFoo (correct configuration)
If development is done on device A, then framework code like: "V1_1::IFoo::
getService()->doV1_0Api()" will work. However, this will unintentionally break
the feature for devices like device B for which "V1_1::IFoo::getService()
will return nullptr. In order to prevent problems like this, we only allow
fetching an interface if it is declared in a VINTF manifest.

Test: multiple internal devices boot/work, lshal
Test: hidl_test, hidl_test_java
Test: added additional logging to hwservicemanager and made sure no
  getService requests anywhere in the system were failing from this.
Bug: 38415912
Change-Id: Ib1d4f37c764470a96fbdfbcf991c8ca244746ea0
5 files changed
tree: 895c6ec3e68fff25ae4551773773f8aaaf67bea0
  1. c2hal/
  2. include_hash/
  3. test/
  4. utils/
  5. .clang-format
  6. Android.bp
  7. Annotation.cpp
  8. Annotation.h
  9. ArrayType.cpp
  10. ArrayType.h
  11. AST.cpp
  12. AST.h
  13. CompoundType.cpp
  14. CompoundType.h
  15. ConstantExpression.cpp
  16. ConstantExpression.h
  17. Coordinator.cpp
  18. Coordinator.h
  19. DeathRecipientType.cpp
  20. DeathRecipientType.h
  21. EnumType.cpp
  22. EnumType.h
  23. FmqType.cpp
  24. FmqType.h
  25. generateCpp.cpp
  26. generateCppImpl.cpp
  27. generateJava.cpp
  28. generateVts.cpp
  29. HandleType.cpp
  30. HandleType.h
  31. Hash.cpp
  32. hidl-gen_l.ll
  33. hidl-gen_y.yy
  34. HidlTypeAssertion.cpp
  35. HidlTypeAssertion.h
  36. Interface.cpp
  37. Interface.h
  38. Location.h
  39. main.cpp
  40. MemoryType.cpp
  41. MemoryType.h
  42. Method.cpp
  43. Method.h
  44. MODULE_LICENSE_APACHE2
  45. NamedType.cpp
  46. NamedType.h
  47. NOTICE
  48. PointerType.cpp
  49. PointerType.h
  50. PREUPLOAD.cfg
  51. README.md
  52. RefType.cpp
  53. RefType.h
  54. ScalarType.cpp
  55. ScalarType.h
  56. Scope.cpp
  57. Scope.h
  58. StringType.cpp
  59. StringType.h
  60. Type.cpp
  61. Type.h
  62. TypeDef.cpp
  63. TypeDef.h
  64. update-all-google-makefiles.sh
  65. update-makefiles-helper.sh
  66. VectorType.cpp
  67. 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