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
Merged-In: Ib1d4f37c764470a96fbdfbcf991c8ca244746ea0
Change-Id: Ib1d4f37c764470a96fbdfbcf991c8ca244746ea0
5 files changed
tree: c478eca137a0f17e1831e0a0d354221a4cb80d56
  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