1# How ADBd and Framework communicate 2 3## adbd_auth 4 5The recommended way is to use `libadbd_auth` (frameworks/native/libs/adbd_auth). 6It is a bidirectional socket originally used to handle authentication messages (hence the name). 7It has since evolved to carry other categories of messages. 8 9``` 10 ┌────────────┐ ┌─────────────────────┐ 11 │ ADBService ◄───────────────► AdbDebuggingManager │ 12 └────────────┘ └──────────▲──────────┘ 13 │ 14 ┌──────────▼──────────┐ 15 │ AdbDebuggingThread │ 16 └──────────▲──────────┘ 17 │ 18 Framework ┌───────▼───────┐ 19 ─────────────────────────────────────┤ "adbd" socket ├───────── 20 ADBd └───────▲───────┘ 21 │ 22 ┌───────┐ ┌──────▼─────┐ 23 │ ADBd ◄─────────────────────► adbd_auth │ 24 └───────┘ └────────────┘ 25``` 26 27Example of usages (adbd-framework direction, packet header): 28 29- [>> DD] Upon authentication, prompt user with a window to accept/refuse adb server's public key. 30- [<< OK] Upon authentication, tell adbd the user accepted the key. 31- [<< KO] Upon authentication, tell adbd the user refused the key. 32- [>> DC] When a device disconnects. 33- [>> TP] When the TLS Server starts, advertise its TLS port. 34- [>> WE] When a TLS device connects. 35- [>> WF] When a TLS device disconnects. 36 37## System properties 38 39A hacky way which should be avoided as much as possible is to use system property setter + getter. There 40are threads listening on system property changes in both adbd and framework. See examples as follows. 41 42- adbd writes `service.adb.tls.port`, framework uses a thread to monitor it. 43- framework writes `persist.adb.tls_server.enable`, adbd uses a thread to monitor it. 44 45If you are an ADB maintainer or/and have a few spare cycles, it would not be a bad idea to remove 46these in favor of using `adbd_auth`. 47