summaryrefslogtreecommitdiff
path: root/adb/client/commandline.cpp
diff options
context:
space:
mode:
authorJosh Gao <jmgao@google.com>2019-02-26 20:55:19 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2019-02-26 20:55:19 +0000
commit216d158daf88edfd954dc03c65b339698319f63d (patch)
treef925f4c4dec9a8e1c25943920c0ad882dd8e5b47 /adb/client/commandline.cpp
parent1706eb08fe8a7600d4698566b3d779b97bd1e279 (diff)
parent43f3805950d69f9da87664ada214d5af0e02753f (diff)
Merge changes I86c3ec0f,I57d1a30a,Ib50d289b,I791a4f82,I316a8799, ...
* changes: adb: switch sockets.cpp to ConsumePrefix. adbd: switch abb to ConsumePrefix. adb: increment server version. adb: wait for device to disconnect upon `adb root`. adb: implement wait-for-disconnect. adb: tell the client what transport it received. adbd: switch daemon/services to ConsumePrefix. adb: switch host_service_to_socket to string_view. adb: switch handle_host_request to string_view. adb: switch adb_io.h to string_view. adb: add helper to consume a prefix on a string_view. adb: make ParseUint reject garbage at the end by default.
Diffstat (limited to 'adb/client/commandline.cpp')
-rw-r--r--adb/client/commandline.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/adb/client/commandline.cpp b/adb/client/commandline.cpp
index f70b480099..32869590c3 100644
--- a/adb/client/commandline.cpp
+++ b/adb/client/commandline.cpp
@@ -190,8 +190,8 @@ static void help() {
"scripting:\n"
" wait-for[-TRANSPORT]-STATE\n"
" wait for device to be in the given state\n"
- " State: device, recovery, sideload, or bootloader\n"
- " Transport: usb, local, or any [default=any]\n"
+ " STATE: device, recovery, sideload, bootloader, or disconnect\n"
+ " TRANSPORT: usb, local, or any [default=any]\n"
" get-state print offline | bootloader | device\n"
" get-serialno print <serial-number>\n"
" get-devpath print <device-path>\n"
@@ -1031,10 +1031,11 @@ static bool wait_for_device(const char* service) {
}
if (components[3] != "any" && components[3] != "bootloader" && components[3] != "device" &&
- components[3] != "recovery" && components[3] != "sideload") {
+ components[3] != "recovery" && components[3] != "sideload" &&
+ components[3] != "disconnect") {
fprintf(stderr,
"adb: unknown state %s; "
- "expected 'any', 'bootloader', 'device', 'recovery', or 'sideload'\n",
+ "expected 'any', 'bootloader', 'device', 'recovery', 'sideload', or 'disconnect'\n",
components[3].c_str());
return false;
}
@@ -1046,7 +1047,8 @@ static bool wait_for_device(const char* service) {
static bool adb_root(const char* command) {
std::string error;
- unique_fd fd(adb_connect(android::base::StringPrintf("%s:", command), &error));
+ TransportId transport_id;
+ unique_fd fd(adb_connect(&transport_id, android::base::StringPrintf("%s:", command), &error));
if (fd < 0) {
fprintf(stderr, "adb: unable to connect for %s: %s\n", command, error.c_str());
return false;
@@ -1079,9 +1081,9 @@ static bool adb_root(const char* command) {
return true;
}
- // Give adbd some time to kill itself and come back up.
- // We can't use wait-for-device because devices (e.g. adb over network) might not come back.
- std::this_thread::sleep_for(3s);
+ // Wait for the device to go away.
+ adb_set_transport(kTransportAny, nullptr, transport_id);
+ wait_for_device("wait-for-disconnect");
return true;
}