summaryrefslogtreecommitdiffstats
path: root/adb/adb.cpp
diff options
context:
space:
mode:
authorJosh Gao <jmgao@google.com>2018-05-04 16:04:49 -0700
committerJosh Gao <jmgao@google.com>2018-05-04 18:05:18 -0700
commit704494b0707a49e064b63192619a73336c1be05a (patch)
tree4359d4c0bcc8bff18ab5275982ade02abbb9190e /adb/adb.cpp
parent48cf760bea211b43aa79675c6b73f846202865f9 (diff)
downloadsystem_core-704494b0707a49e064b63192619a73336c1be05a.tar.gz
system_core-704494b0707a49e064b63192619a73336c1be05a.tar.bz2
system_core-704494b0707a49e064b63192619a73336c1be05a.zip
adb: add authorizing, connecting states to transport.
Add two states: connecting and authorizing, to disambiguate the offline and unauthorized states, respectively. Previously, devices would transition as follows: offline -> unauthorized -> offline -> online offline -> unauthorized (when actually unauthorized) With this patch: connecting -> authorizing -> online connecting -> authorizing -> unauthorized (when actually unauthorized) This allows test automation and the like to distinguish between offline devices, unauthorized devices, and working devices without having to do retry loops with arbitrary sleeps on their end. Bug: http://b/79257434 Test: adb_test Test: adbd_test Test: manually plugging in a device with `while true; do adb shell echo foo; done` Change-Id: I036d9b593b51a27a59ac3fc57da966fd52658567
Diffstat (limited to 'adb/adb.cpp')
-rw-r--r--adb/adb.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/adb/adb.cpp b/adb/adb.cpp
index 3bf281c6d..76ca19a79 100644
--- a/adb/adb.cpp
+++ b/adb/adb.cpp
@@ -365,8 +365,8 @@ void handle_packet(apacket *p, atransport *t)
switch (p->msg.arg0) {
#if ADB_HOST
case ADB_AUTH_TOKEN:
- if (t->GetConnectionState() == kCsOffline) {
- t->SetConnectionState(kCsUnauthorized);
+ if (t->GetConnectionState() != kCsAuthorizing) {
+ t->SetConnectionState(kCsAuthorizing);
}
send_auth_response(p->payload.data(), p->msg.data_length, t);
break;
@@ -1103,14 +1103,11 @@ int handle_host_request(const char* service, TransportType type, const char* ser
if (!strcmp(service, "reconnect-offline")) {
std::string response;
close_usb_devices([&response](const atransport* transport) {
- switch (transport->GetConnectionState()) {
- case kCsOffline:
- case kCsUnauthorized:
- response += "reconnecting " + transport->serial_name() + "\n";
- return true;
- default:
- return false;
+ if (!ConnectionStateIsOnline(transport->GetConnectionState())) {
+ response += "reconnecting " + transport->serial_name() + "\n";
+ return true;
}
+ return false;
});
if (!response.empty()) {
response.resize(response.size() - 1);