diff options
author | David Pursell <dpursell@google.com> | 2015-12-08 16:12:22 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-12-08 16:12:22 +0000 |
commit | 663e949b2bbda5dcc2b92e4d1936555019cdd66b (patch) | |
tree | daff8cfe5f50797bd320280590721ed955aa4245 /adb/transport.cpp | |
parent | 5986d9f263d08ef8876656098cbe95b59d310f21 (diff) | |
parent | d2acbd19312a66cbee2c49f455eddd82b6700d1d (diff) | |
download | core-663e949b2bbda5dcc2b92e4d1936555019cdd66b.tar.gz core-663e949b2bbda5dcc2b92e4d1936555019cdd66b.tar.bz2 core-663e949b2bbda5dcc2b92e4d1936555019cdd66b.zip |
Merge "adb: add help text for USB permission errors."
Diffstat (limited to 'adb/transport.cpp')
-rw-r--r-- | adb/transport.cpp | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/adb/transport.cpp b/adb/transport.cpp index d20eaff67..d4f60ece4 100644 --- a/adb/transport.cpp +++ b/adb/transport.cpp @@ -674,7 +674,11 @@ atransport* acquire_one_transport(TransportType type, const char* serial, adb_mutex_lock(&transport_lock); for (const auto& t : transport_list) { if (t->connection_state == kCsNoPerm) { - *error_out = "insufficient permissions for device"; + *error_out = UsbNoPermissionsLongHelpText(); + // If we couldn't figure out a reasonable help message default to something generic. + if (error_out->empty()) { + *error_out = "insufficient permissions for device"; + } continue; } @@ -748,17 +752,20 @@ atransport* acquire_one_transport(TransportType type, const char* serial, return result; } -const char* atransport::connection_state_name() const { +const std::string atransport::connection_state_name() const { switch (connection_state) { - case kCsOffline: return "offline"; - case kCsBootloader: return "bootloader"; - case kCsDevice: return "device"; - case kCsHost: return "host"; - case kCsRecovery: return "recovery"; - case kCsNoPerm: return "no permissions"; - case kCsSideload: return "sideload"; - case kCsUnauthorized: return "unauthorized"; - default: return "unknown"; + case kCsOffline: return "offline"; + case kCsBootloader: return "bootloader"; + case kCsDevice: return "device"; + case kCsHost: return "host"; + case kCsRecovery: return "recovery"; + case kCsNoPerm: { + std::string message = UsbNoPermissionsShortHelpText(); + return message.empty() ? "no permissions" : message; + } + case kCsSideload: return "sideload"; + case kCsUnauthorized: return "unauthorized"; + default: return "unknown"; } } @@ -866,7 +873,8 @@ static void append_transport(const atransport* t, std::string* result, *result += '\t'; *result += t->connection_state_name(); } else { - android::base::StringAppendF(result, "%-22s %s", serial, t->connection_state_name()); + android::base::StringAppendF(result, "%-22s %s", serial, + t->connection_state_name().c_str()); append_transport_info(result, "", t->devpath, false); append_transport_info(result, "product:", t->product, false); |