adb incorrectly sends OKAY when failing to pair (requiring Studio workaround).
Bug: 207654388
Test: See below for mDNS tests.
aosp-master-with-phones$adb pair 10.0.0.222:33367
Enter pairing code: dkfdf
* daemon not running; starting now at tcp:5037
* daemon started successfully
error: protocol fault (couldn't read status message): Undefined error: 0
aosp-master-with-phones$echo $?
1
aosp-master-with-phones$adb devices
List of devices attached
aosp-master-with-phones$adb pair 10.0.0.222:37927
Enter pairing code: 470570
Successfully paired to 10.0.0.222:37927 [guid=adb-24121FDH20001N-zoXAul]
aosp-master-with-phones$adb devices
List of devices attached
adb-24121FDH20001N-zoXAul._adb-tls-connect._tcp. device
shaju@shaju-macbookpro3.roam.internal:/Volumes/AOSP/aosp-master-with-phones$echo $?
0
Change-Id: Icbe99d83d8e9a4f365d998af84822a6041008b25
diff --git a/services.cpp b/services.cpp
index 43cacb3..eb369f1 100644
--- a/services.cpp
+++ b/services.cpp
@@ -149,7 +149,15 @@
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);
+ if (android::base::StartsWith(response, "Successful")) {
+ SendProtocolString(fd.get(), response);
+ } else {
+ SendFail(fd,
+ response); // Since the transport is being torn down, the
+ // response string will not reach the client-end
+ // (TODO: at the moment), and instead consumes a
+ // generic "protocol fault" error.
+ }
}
static void wait_service(unique_fd fd, std::string serial, TransportId transport_id,