[adb] Document and harden async transport flow.

Add detailed documentation to the global 'transports' map and its
associated helper functions in adbd auth. These helpers are used to
safely pass 'atransport' objects across asynchronous boundaries (like
user authorization popups or background TLS handshakes) without risking
Use-After-Free.

Also add CHECK_LOOPER_THREAD() assertions to ensure these functions are
only called on the main fdevent thread, which is a requirement for the
thread-safety of the global map and the underlying weak_ptr.

Finally, refactor transport_from_callback_arg to use std::map::extract,
which simplifies the code and ensures the entry is always removed from
the map upon retrieval.

Bug: 499053500
Test: atest adb_test --host
Flag: EXEMPT BUGFIX
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:ca8689b1047a05598bb42ff034652ea679dd6056
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:ea885606faf989081914b3aa699d42d0a46abb28
Merged-In: Ic419a1fb6f0df1ff868a1a31a33ded8a0ae7b2e8
Change-Id: Ic419a1fb6f0df1ff868a1a31a33ded8a0ae7b2e8
1 file changed
tree: 7d3eebcce40603970ef5cfead1a0d02ebbd37c0b
  1. apex/
  2. client/
  3. coverage/
  4. crypto/
  5. daemon/
  6. docs/
  7. fastdeploy/
  8. fdevent/
  9. libs/
  10. pairing_auth/
  11. pairing_connection/
  12. proto/
  13. sysdeps/
  14. test_device_apks/
  15. test_utils/
  16. tls/
  17. tools/
  18. .clang-format
  19. adb.bash
  20. adb.cpp
  21. adb.h
  22. adb_auth.h
  23. adb_integration_test_adb.xml
  24. adb_integration_test_device.xml
  25. adb_io.cpp
  26. adb_io.h
  27. adb_io_test.cpp
  28. adb_listeners.cpp
  29. adb_listeners.h
  30. adb_listeners_test.cpp
  31. adb_mdns.cpp
  32. adb_mdns.h
  33. adb_trace.cpp
  34. adb_trace.h
  35. adb_unique_fd.cpp
  36. adb_unique_fd.h
  37. adb_utils.cpp
  38. adb_utils.h
  39. adb_utils_test.cpp
  40. adbd_flags.aconfig
  41. adbd_test.map
  42. adbd_test.xml
  43. Android.bp
  44. apacket_reader.cpp
  45. apacket_reader.h
  46. benchmark_device.py
  47. bugreport_test.cpp
  48. compression_utils.h
  49. file_sync_protocol.h
  50. mdns_test.cpp
  51. MODULE_LICENSE_APACHE2
  52. NOTICE
  53. OWNERS
  54. PREUPLOAD.cfg
  55. README.md
  56. run-device-tests.sh
  57. security_log_tags.h
  58. services.cpp
  59. services.h
  60. shell_protocol.h
  61. shell_service_protocol.cpp
  62. shell_service_protocol_test.cpp
  63. socket.h
  64. socket_spec.cpp
  65. socket_spec.h
  66. socket_spec_test.cpp
  67. socket_test.cpp
  68. sockets.cpp
  69. sockets.dia
  70. sysdeps.h
  71. sysdeps_test.cpp
  72. sysdeps_unix.cpp
  73. sysdeps_win32.cpp
  74. sysdeps_win32_test.cpp
  75. test_adb.py
  76. test_device.py
  77. TEST_MAPPING
  78. trace.sh
  79. transfer_id.h
  80. transport.cpp
  81. transport.h
  82. transport_benchmark.cpp
  83. transport_fd.cpp
  84. transport_test.cpp
  85. types.cpp
  86. types.h
  87. types_test.cpp
README.md

ADB (Android Debug Bridge) repository

The Android Debug Bridge connects Android devices to computers running other OSes (Linux, MacOS, and Windows) over USB or TCP.

User documentation

Developer documentation

main page