Write Protobuf in Base64

Change-Id: I3868365e7fd166517b13ff03a15d629271bd47b4
diff --git a/system/main/Android.mk b/system/main/Android.mk
index badabee..303f395 100644
--- a/system/main/Android.mk
+++ b/system/main/Android.mk
@@ -62,7 +62,8 @@
     libpower \
     libprotobuf-cpp-full \
     libmedia \
-    libutils
+    libutils \
+    libchrome
 
 LOCAL_STATIC_LIBRARIES := \
     libbt-qcom_sbc_decoder
diff --git a/system/osi/Android.mk b/system/osi/Android.mk
index ba3df00..d05aa80 100644
--- a/system/osi/Android.mk
+++ b/system/osi/Android.mk
@@ -117,7 +117,7 @@
 LOCAL_SRC_FILES := $(btosiCommonSrc)
 LOCAL_MODULE := libosi
 LOCAL_MODULE_TAGS := optional
-LOCAL_SHARED_LIBRARIES := libc liblog
+LOCAL_SHARED_LIBRARIES := libc liblog libchrome
 LOCAL_STATIC_LIBRARIES := libbt-protos
 LOCAL_MODULE_CLASS := STATIC_LIBRARIES
 
@@ -135,7 +135,7 @@
 LOCAL_SRC_FILES := $(btosiCommonSrc)
 LOCAL_MODULE := libosi-host
 LOCAL_MODULE_TAGS := optional
-LOCAL_SHARED_LIBRARIES := liblog
+LOCAL_SHARED_LIBRARIES := liblog libchrome
 LOCAL_STATIC_LIBRARIES := libbt-protos
 LOCAL_MODULE_CLASS := STATIC_LIBRARIES
 
@@ -160,7 +160,7 @@
 LOCAL_SRC_FILES := $(btosiCommonTestSrc)
 LOCAL_MODULE := net_test_osi
 LOCAL_MODULE_TAGS := tests
-LOCAL_SHARED_LIBRARIES := liblog libprotobuf-cpp-full
+LOCAL_SHARED_LIBRARIES := liblog libprotobuf-cpp-full libchrome
 LOCAL_STATIC_LIBRARIES := libosi libbt-protos
 
 LOCAL_CFLAGS += $(bluetooth_CFLAGS)
@@ -178,7 +178,7 @@
 LOCAL_LDLIBS := -lrt -lpthread
 LOCAL_MODULE := net_test_osi
 LOCAL_MODULE_TAGS := tests
-LOCAL_SHARED_LIBRARIES := liblog libprotobuf-cpp-full
+LOCAL_SHARED_LIBRARIES := liblog libprotobuf-cpp-full libchrome
 LOCAL_STATIC_LIBRARIES := libosi-host libbt-protos
 
 LOCAL_CFLAGS += $(bluetooth_CFLAGS)
diff --git a/system/osi/src/metrics.cpp b/system/osi/src/metrics.cpp
index 63be98a..bb3b0f1 100644
--- a/system/osi/src/metrics.cpp
+++ b/system/osi/src/metrics.cpp
@@ -30,6 +30,7 @@
 
 #include "osi/src/protos/bluetooth.pb.h"
 
+#include <base/base64.h>
 #include <google/protobuf/text_format.h>
 
 using clearcut::connectivity::A2DPSession;
@@ -180,7 +181,10 @@
     return;
   }
 
-  if (write(fd, serialized.c_str(), serialized.size()) == -1) {
+  std::string protoBase64;
+  base::Base64Encode(serialized, &protoBase64);
+
+  if (write(fd, protoBase64.c_str(), protoBase64.size()) == -1) {
     LOG_ERROR(LOG_TAG, "%s: error writing to dumpsys fd: %s (%d)", __func__,
               strerror(errno), errno);
   }