diff options
author | Josh Gao <jmgao@google.com> | 2018-05-04 16:04:49 -0700 |
---|---|---|
committer | Josh Gao <jmgao@google.com> | 2018-05-04 18:05:18 -0700 |
commit | 7a7c5cb2af1a3aaad517c6e62f178749637f44bd (patch) | |
tree | 0c5f46815ca6f184cde8b208f747025c83ec7817 /adb.h | |
parent | 52328b65ea21e72de9e5d846f8d1c6167b080ffa (diff) | |
download | adb-7a7c5cb2af1a3aaad517c6e62f178749637f44bd.tar.gz |
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.h')
-rw-r--r-- | adb.h | 23 |
1 files changed, 20 insertions, 3 deletions
@@ -95,16 +95,33 @@ enum TransportType { enum ConnectionState { kCsAny = -1, - kCsOffline = 0, + + kCsConnecting = 0, // Haven't received a response from the device yet. + kCsAuthorizing, // Authorizing with keys from ADB_VENDOR_KEYS. + kCsUnauthorized, // ADB_VENDOR_KEYS exhausted, fell back to user prompt. + kCsNoPerm, // Insufficient permissions to communicate with the device. + kCsOffline, + kCsBootloader, kCsDevice, kCsHost, kCsRecovery, - kCsNoPerm, // Insufficient permissions to communicate with the device. kCsSideload, - kCsUnauthorized, }; +inline bool ConnectionStateIsOnline(ConnectionState state) { + switch (state) { + case kCsBootloader: + case kCsDevice: + case kCsHost: + case kCsRecovery: + case kCsSideload: + return true; + default: + return false; + } +} + void print_packet(const char* label, apacket* p); // These use the system (v)fprintf, not the adb prefixed ones defined in sysdeps.h, so they |