From 01a65eebbfcb829f40232b13c9f30f190d8ab915 Mon Sep 17 00:00:00 2001 From: Alex Buynytskyy Date: Thu, 17 Jan 2019 13:13:56 -0800 Subject: [PATCH] Adding new feature to adb "abb". It will allow clients to detect if abb is supported. Test: manual BUG: 111621042 Change-Id: Ifddabe49214882a6c6ad898c7e2a0f5cc92458d8 --- adb/client/commandline.cpp | 11 +++++++++++ adb/transport.cpp | 4 +++- adb/transport.h | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/adb/client/commandline.cpp b/adb/client/commandline.cpp index 9bc42e110..e963e3d20 100644 --- a/adb/client/commandline.cpp +++ b/adb/client/commandline.cpp @@ -762,6 +762,17 @@ static int adb_shell(int argc, const char** argv) { } static int adb_abb(int argc, const char** argv) { + FeatureSet features; + std::string error_message; + if (!adb_get_feature_set(&features, &error_message)) { + fprintf(stderr, "error: %s\n", error_message.c_str()); + return 1; + } + + if (!CanUseFeature(features, kFeatureAbb)) { + error_exit("abb is not supported by the device"); + } + // Defaults. constexpr char escape_char = '~'; // -e constexpr bool use_shell_protocol = true; diff --git a/adb/transport.cpp b/adb/transport.cpp index f59a13583..ae5359794 100644 --- a/adb/transport.cpp +++ b/adb/transport.cpp @@ -68,6 +68,7 @@ const char* const kFeatureLibusb = "libusb"; const char* const kFeaturePushSync = "push_sync"; const char* const kFeatureApex = "apex"; const char* const kFeatureFixedPushMkdir = "fixed_push_mkdir"; +const char* const kFeatureAbb = "abb"; namespace { @@ -1013,7 +1014,8 @@ size_t atransport::get_max_payload() const { const FeatureSet& supported_features() { // Local static allocation to avoid global non-POD variables. static const FeatureSet* features = new FeatureSet{ - kFeatureShell2, kFeatureCmd, kFeatureStat2, kFeatureFixedPushMkdir, kFeatureApex + kFeatureShell2, kFeatureCmd, kFeatureStat2, + kFeatureFixedPushMkdir, kFeatureApex, kFeatureAbb, // Increment ADB_SERVER_VERSION when adding a feature that adbd needs // to know about. Otherwise, the client can be stuck running an old // version of the server even after upgrading their copy of adb. diff --git a/adb/transport.h b/adb/transport.h index 790004fdd..6f53e6ec3 100644 --- a/adb/transport.h +++ b/adb/transport.h @@ -64,6 +64,8 @@ extern const char* const kFeaturePushSync; extern const char* const kFeatureApex; // adbd has b/110953234 fixed. extern const char* const kFeatureFixedPushMkdir; +// adbd supports android binder bridge (abb). +extern const char* const kFeatureAbb; TransportId NextTransportId();