adb: fix track-devices-l.
Also add a -l to the undocumented `adb track-devices` for easier
testing.
Bug: https://issuetracker.google.com/118470090
Test: manual
Change-Id: I436f6e45b249b98a073aa147ad4ed67d4d87f9bd
diff --git a/adb/client/commandline.cpp b/adb/client/commandline.cpp
index 936fd5a..3c03eb2 100644
--- a/adb/client/commandline.cpp
+++ b/adb/client/commandline.cpp
@@ -1890,7 +1890,10 @@
} else if (!strcmp(argv[0], "track-jdwp")) {
return adb_connect_command("track-jdwp");
} else if (!strcmp(argv[0], "track-devices")) {
- return adb_connect_command("host:track-devices");
+ if (argc > 2 || (argc == 2 && strcmp(argv[1], "-l"))) {
+ error_exit("usage: adb track-devices [-l]");
+ }
+ return adb_connect_command(argc == 2 ? "host:track-devices-l" : "host:track-devices");
} else if (!strcmp(argv[0], "raw")) {
if (argc != 2) {
error_exit("usage: adb raw SERVICE");
diff --git a/adb/transport.cpp b/adb/transport.cpp
index 8bc925f..3d1d620 100644
--- a/adb/transport.cpp
+++ b/adb/transport.cpp
@@ -542,9 +542,7 @@
// for the first time, even if no update occurred.
if (tracker->update_needed) {
tracker->update_needed = false;
-
- std::string transports = list_transports(tracker->long_output);
- device_tracker_send(tracker, transports);
+ device_tracker_send(tracker, list_transports(tracker->long_output));
}
}
@@ -587,13 +585,11 @@
update_transport_status();
// Notify `adb track-devices` clients.
- std::string transports = list_transports(false);
-
device_tracker* tracker = device_tracker_list;
while (tracker != nullptr) {
device_tracker* next = tracker->next;
// This may destroy the tracker if the connection is closed.
- device_tracker_send(tracker, transports);
+ device_tracker_send(tracker, list_transports(tracker->long_output));
tracker = next;
}
}