From 9a24711fd21b2bcab7d3ae67d0f34599f1eae4b1 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 26 Oct 2016 14:25:28 -0700 Subject: [PATCH] Replace bluetooth protos with protobuf-lite Use lite protobufs for bluetooth to remove dependency on libprotobuf-cpp-full, which will be removed from the platform. Requires dropping support for adb shell dumpsys bluetooth_manager --proto-text which requires full protobufs to call TextToString. The functionality can be restored without adding a dependency on full protobufs with a host protobuf decoder. Bug: 32417805 Test: builds Change-Id: Ifc9ee23264b1bfff3ad1f85ef4914f788028971a --- btif/src/bluetooth.cc | 5 ----- hci/Android.mk | 2 +- osi/Android.mk | 4 ++-- osi/include/metrics.h | 4 ---- osi/src/metrics.cc | 21 --------------------- osi/src/metrics_linux.cc | 4 ---- osi/src/protos/bluetooth.proto | 1 + 7 files changed, 4 insertions(+), 37 deletions(-) diff --git a/btif/src/bluetooth.cc b/btif/src/bluetooth.cc index 2e47b600f..51ecb9611 100644 --- a/btif/src/bluetooth.cc +++ b/btif/src/bluetooth.cc @@ -295,11 +295,6 @@ static int read_energy_info() { static void dump(int fd, const char** arguments) { if (arguments != NULL && arguments[0] != NULL) { - if (strncmp(arguments[0], "--proto-text", 12) == 0) { - btif_update_a2dp_metrics(); - metrics_print(fd, true); - return; - } if (strncmp(arguments[0], "--proto-bin", 11) == 0) { btif_update_a2dp_metrics(); metrics_write(fd, true); diff --git a/hci/Android.mk b/hci/Android.mk index 2f4279842..0672520d4 100644 --- a/hci/Android.mk +++ b/hci/Android.mk @@ -71,7 +71,7 @@ LOCAL_SRC_FILES := \ LOCAL_MODULE := net_test_hci LOCAL_MODULE_TAGS := tests -LOCAL_SHARED_LIBRARIES := liblog libdl libprotobuf-cpp-full +LOCAL_SHARED_LIBRARIES := liblog libdl libprotobuf-cpp-lite LOCAL_STATIC_LIBRARIES := libbt-hci libosi libcutils libbtcore libbt-protos LOCAL_CFLAGS += $(bluetooth_CFLAGS) diff --git a/osi/Android.mk b/osi/Android.mk index 22c44c5a9..f93fdfb8c 100644 --- a/osi/Android.mk +++ b/osi/Android.mk @@ -168,7 +168,7 @@ LOCAL_C_INCLUDES := $(btosiCommonIncludes) LOCAL_SRC_FILES := $(btosiCommonTestSrc) LOCAL_MODULE := net_test_osi LOCAL_MODULE_TAGS := tests -LOCAL_SHARED_LIBRARIES := libc liblog libprotobuf-cpp-full libchrome libcutils +LOCAL_SHARED_LIBRARIES := libc liblog libprotobuf-cpp-lite libchrome libcutils LOCAL_STATIC_LIBRARIES := libosi libbt-protos LOCAL_CFLAGS += $(bluetooth_CFLAGS) @@ -187,7 +187,7 @@ LOCAL_SRC_FILES := $(btosiCommonTestSrc) LOCAL_LDLIBS := -lrt -lpthread LOCAL_MODULE := net_test_osi LOCAL_MODULE_TAGS := tests -LOCAL_SHARED_LIBRARIES := liblog libprotobuf-cpp-full libchrome +LOCAL_SHARED_LIBRARIES := liblog libprotobuf-cpp-lite libchrome LOCAL_STATIC_LIBRARIES := libosi-host libbt-protos LOCAL_CFLAGS += $(bluetooth_CFLAGS) -DOS_GENERIC diff --git a/osi/include/metrics.h b/osi/include/metrics.h index 644a8f753..05ad191ae 100644 --- a/osi/include/metrics.h +++ b/osi/include/metrics.h @@ -92,10 +92,6 @@ void metrics_a2dp_session( // If |clear| is true, metrics events are cleared afterwards. void metrics_write(int fd, bool clear); -// Writes the metrics, in human-readable protobuf format, into the descriptor -// |fd|. If |clear| is true, metrics events are cleared afterwards. -void metrics_print(int fd, bool clear); - #ifdef __cplusplus } #endif diff --git a/osi/src/metrics.cc b/osi/src/metrics.cc index c161869d3..8f188291e 100644 --- a/osi/src/metrics.cc +++ b/osi/src/metrics.cc @@ -185,24 +185,3 @@ void metrics_write(int fd, bool clear) { strerror(errno), errno); } } - -void metrics_print(int fd, bool clear) { - log_lock.lock(); - LOG_DEBUG(LOG_TAG, "%s printing metrics", __func__); - lazy_initialize(); - - std::string pretty_output; - google::protobuf::TextFormat::PrintToString(*pending, &pretty_output); - - if (clear) { - pending->Clear(); - } - log_lock.unlock(); - - ssize_t ret; - OSI_NO_INTR(ret = write(fd, pretty_output.c_str(), pretty_output.size())); - if (ret == -1) { - LOG_ERROR(LOG_TAG, "%s: error writing to dumpsys fd: %s (%d)", __func__, - strerror(errno), errno); - } -} diff --git a/osi/src/metrics_linux.cc b/osi/src/metrics_linux.cc index 64bf175b7..6c4cc9467 100644 --- a/osi/src/metrics_linux.cc +++ b/osi/src/metrics_linux.cc @@ -47,7 +47,3 @@ void metrics_a2dp_session( void metrics_write(int fd, bool clear) { // TODO(jpawlowski): implement } - -void metrics_print(int fd, bool clear) { - // TODO(jpawlowski): implement -} diff --git a/osi/src/protos/bluetooth.proto b/osi/src/protos/bluetooth.proto index 95266d8c0..1b281d3e9 100644 --- a/osi/src/protos/bluetooth.proto +++ b/osi/src/protos/bluetooth.proto @@ -3,6 +3,7 @@ // Protos for uploading bluetooth metrics. syntax = "proto2"; +option optimize_for = LITE_RUNTIME; package clearcut.connectivity; -- 2.11.0