Modify aidl tracing code gen for Java

Enabling aidl#generate_traces in aosp/2190022 increases framework.jar
size by ~3%. This is primarily due to the increase in transaction name
strings in the dex. The real issue here is that the dex size increases
proportional to the number of methods vs the number of interfaces

To fix this, we take advantage of the already generated txn name strings
in the framework.jar aidl as part of the enabled
aidl#'generate_get_transaction_name'. This tag creates a method
getDefaultTransactionName(txnCode) with a switch statement to convert
txnCode -> txnName. We can then emit traceBegin code once per Stub
interface that looks like:

boolean onTransact(int code...) {
  try {
    ...
    traceBegin(getDefaultTransactionName(code))
    ...
  } finally {
    traceEnd(...)
  }
}

instead of emitting a traceBegin per txn case statement.

Unfortunately, this approach does not extend to the Proxy interface
because each txn exposes an individual method and there's no single
entry point to emit a traceBegin like the Stub#onTransact. Hence we
skip tracing the Proxy side. This means we don't get any 'client'
aidl tracing for Java aidl interfaces but this was arguably unnecessary
anyways and might be worth considering dropping that for the Cpp backend

Test: Manual
Bug: 161393989

Change-Id: Ib78d82ceea41d13e047337907a1f49f9f1615a86
2 files changed
tree: 829c430e2a8ecbcb6316c55575a3c63a50048da4
  1. aidl_api/
  2. analyzer/
  3. build/
  4. metadata/
  5. scripts/
  6. tests/
  7. trace/
  8. aidl-format.sh
  9. aidl.cpp
  10. aidl.h
  11. aidl_checkapi.cpp
  12. aidl_checkapi.h
  13. aidl_const_expressions.cpp
  14. aidl_dumpapi.cpp
  15. aidl_dumpapi.h
  16. aidl_language.cpp
  17. aidl_language.h
  18. aidl_language_l.ll
  19. aidl_language_y.yy
  20. aidl_to_cpp.cpp
  21. aidl_to_cpp.h
  22. aidl_to_cpp_common.cpp
  23. aidl_to_cpp_common.h
  24. aidl_to_java.cpp
  25. aidl_to_java.h
  26. aidl_to_ndk.cpp
  27. aidl_to_ndk.h
  28. aidl_to_rust.cpp
  29. aidl_to_rust.h
  30. aidl_typenames.cpp
  31. aidl_typenames.h
  32. aidl_unittest.cpp
  33. Android.bp
  34. ast_java.cpp
  35. ast_java.h
  36. ast_java_unittest.cpp
  37. check_valid.cpp
  38. check_valid.h
  39. code_writer.cpp
  40. code_writer.h
  41. code_writer_unittest.cpp
  42. comments.cpp
  43. comments.h
  44. diagnostics.cpp
  45. diagnostics.h
  46. diagnostics.inc
  47. diagnostics_unittest.cpp
  48. generate_aidl_mappings.cpp
  49. generate_aidl_mappings.h
  50. generate_cpp.cpp
  51. generate_cpp.h
  52. generate_cpp_analyzer.cpp
  53. generate_cpp_analyzer.h
  54. generate_cpp_unittest.cpp
  55. generate_java.cpp
  56. generate_java.h
  57. generate_java_binder.cpp
  58. generate_ndk.cpp
  59. generate_ndk.h
  60. generate_rust.cpp
  61. generate_rust.h
  62. hiddenapi-greylist
  63. import_resolver.cpp
  64. import_resolver.h
  65. io_delegate.cpp
  66. io_delegate.h
  67. io_delegate_unittest.cpp
  68. location.cpp
  69. location.h
  70. logging.cpp
  71. logging.h
  72. main.cpp
  73. NOTICE
  74. options.cpp
  75. options.h
  76. options_unittest.cpp
  77. os.h
  78. OWNERS
  79. parser.cpp
  80. parser.h
  81. permission.cpp
  82. permission.h
  83. preprocess.cpp
  84. preprocess.h
  85. PREUPLOAD.cfg
  86. README.md
  87. run_integration_tests.sh
  88. TEST_MAPPING
README.md

Documentation for this project is currently maintained here:

https://source.android.com/devices/architecture/aidl/overview