Merge "Send TLS Server port to framework over adb_auth" into main
diff --git a/Android.bp b/Android.bp
index f335c91..2dcd0c8 100644
--- a/Android.bp
+++ b/Android.bp
@@ -30,12 +30,6 @@
],
}
-tidy_errors = [
- "-*",
- "bugprone-inaccurate-erase",
- "bugprone-use-after-move",
-]
-
cc_defaults {
name: "adb_defaults",
@@ -104,10 +98,6 @@
],
},
},
-
- tidy: true,
- tidy_checks: tidy_errors,
- tidy_checks_as_errors: tidy_errors,
}
cc_defaults {
diff --git a/docs/dev/README.md b/docs/dev/README.md
index a590914..684c581 100644
--- a/docs/dev/README.md
+++ b/docs/dev/README.md
@@ -8,5 +8,6 @@
- [How ADB uses USB Zero-length packets](zero_length_packet.md)
- [How adbd starts](how_adbd_starts.md)
- [How burst mode works](delayed_ack.md)
+- [How adbd and framework communicate](adbd_framework.md)
- [How ADB Wifi works](adb_wifi.md)
- [How ADB Incremental install works](incremental-install.md)
diff --git a/docs/dev/adbd_framework.md b/docs/dev/adbd_framework.md
new file mode 100644
index 0000000..3339710
--- /dev/null
+++ b/docs/dev/adbd_framework.md
@@ -0,0 +1,46 @@
+# How ADBd and Framework communicate
+
+## adbd_auth
+
+The recommended way is to use `libadbd_auth` (frameworks/native/libs/adbd_auth).
+It is a bidirectional socket originally used to handle authentication messages (hence the name).
+It has since evolved to carry other categories of messages.
+
+```
+ ┌────────────┐ ┌─────────────────────┐
+ │ ADBService ◄───────────────► AdbDebuggingManager │
+ └────────────┘ └──────────▲──────────┘
+ │
+ ┌──────────▼──────────┐
+ │ AdbDebuggingThread │
+ └──────────▲──────────┘
+ │
+ Framework ┌───────▼───────┐
+ ─────────────────────────────────────┤ "adbd" socket ├─────────
+ ADBd └───────▲───────┘
+ │
+ ┌───────┐ ┌──────▼─────┐
+ │ ADBd ◄─────────────────────► adbd_auth │
+ └───────┘ └────────────┘
+```
+
+Example of usages (adbd-framework direction, packet header):
+
+- [>> DD] Upon authentication, prompt user with a window to accept/refuse adb server's public key.
+- [<< OK] Upon authentication, tell adbd the user accepted the key.
+- [<< KO] Upon authentication, tell adbd the user refused the key.
+- [>> DC] When a device disconnects.
+- [>> TP] When the TLS Server starts, advertise its TLS port.
+- [>> WE] When a TLS device connects.
+- [>> WF] When a TLS device disconnects.
+
+## System properties
+
+A hacky way which should be avoided as much as possible is to use system property setter + getter. There
+are threads listening on system property changes in both adbd and framework. See examples as follows.
+
+- adbd writes `service.adb.tls.port`, framework uses a thread to monitor it.
+- framework writes `persist.adb.tls_server.enable`, adbd uses a thread to monitor it.
+
+If you are an ADB maintainer or/and have a few spare cycles, it would not be a bad idea to remove
+these in favor of using `adbd_auth`.