OSDN Git Service

Replace bluetooth protos with protobuf-lite
authorColin Cross <ccross@android.com>
Wed, 26 Oct 2016 21:25:28 +0000 (14:25 -0700)
committerAndre Eisenbach <eisenbach@google.com>
Wed, 26 Oct 2016 21:31:32 +0000 (21:31 +0000)
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
hci/Android.mk
osi/Android.mk
osi/include/metrics.h
osi/src/metrics.cc
osi/src/metrics_linux.cc
osi/src/protos/bluetooth.proto

index 2e47b60..51ecb96 100644 (file)
@@ -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);
index 2f42798..0672520 100644 (file)
@@ -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)
index 22c44c5..f93fdfb 100644 (file)
@@ -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
index 644a8f7..05ad191 100644 (file)
@@ -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
index c161869..8f18829 100644 (file)
@@ -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);
-  }
-}
index 64bf175..6c4cc94 100644 (file)
@@ -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
-}
index 95266d8..1b281d3 100644 (file)
@@ -3,6 +3,7 @@
 // Protos for uploading bluetooth metrics.
 
 syntax = "proto2";
+option optimize_for = LITE_RUNTIME;
 
 package clearcut.connectivity;