[adbwifi] Add adbwifi_libs, TLS connection, and MDNS implementation.
Bug: 111434128, 119493510, 119494503
Test: Enable wireless debugging in Settings UI, click "pair with pairing code"
to generate pairing code.
On client, 'adb pair <ip_address>', enter pairing code at prompt and hit
enter. Pairing should complete.
'adb logcat'.
Change-Id: I86527bd3fc52e30a8e08ec5843dc3e100abf91fa
Exempt-From-Owner-Approval: approved already
diff --git a/services.cpp b/services.cpp
index 6185aa6..853d658 100644
--- a/services.cpp
+++ b/services.cpp
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <string.h>
+#include <cstring>
#include <thread>
#include <android-base/stringprintf.h>
@@ -34,6 +35,7 @@
#include "adb_io.h"
#include "adb_unique_fd.h"
#include "adb_utils.h"
+#include "adb_wifi.h"
#include "services.h"
#include "socket_spec.h"
#include "sysdeps.h"
@@ -193,6 +195,12 @@
// Send response for emulator and device
SendProtocolString(fd.get(), response);
}
+
+static void pair_service(unique_fd fd, std::string host, std::string password) {
+ std::string response;
+ adb_wifi_pair_device(host, password, response);
+ SendProtocolString(fd.get(), response);
+}
#endif
#if ADB_HOST
@@ -248,6 +256,16 @@
unique_fd fd = create_service_thread(
"connect", std::bind(connect_service, std::placeholders::_1, host));
return create_local_socket(std::move(fd));
+ } else if (android::base::ConsumePrefix(&name, "pair:")) {
+ const char* divider = strchr(name.data(), ':');
+ if (!divider) {
+ return nullptr;
+ }
+ std::string password(name.data(), divider);
+ std::string host(divider + 1);
+ unique_fd fd = create_service_thread(
+ "pair", std::bind(pair_service, std::placeholders::_1, host, password));
+ return create_local_socket(std::move(fd));
}
return nullptr;
}