Add bytes interface to LogEvent for pulled atoms
This adds a writeBytes interface to LogEvent for native pulled atoms,
which have been using write(string). The function still takes in a
string, but instead uses the write_char_array interface to avoid
stopping on null termination.
Test: modified tests and ran statsd_test
Test: statsd_testdrive 10055 to test against gpu app stats
Bug: 141965020
Change-Id: Iaedfb73310769165d8b61affb55e784f109355cf
diff --git a/cmds/statsd/src/logd/LogEvent.cpp b/cmds/statsd/src/logd/LogEvent.cpp
index 0ade5311..fd19c9d 100644
--- a/cmds/statsd/src/logd/LogEvent.cpp
+++ b/cmds/statsd/src/logd/LogEvent.cpp
@@ -332,6 +332,13 @@
return false;
}
+bool LogEvent::writeBytes(const string& value) {
+ if (mContext) {
+ return android_log_write_char_array(mContext, value.c_str(), value.length()) >= 0;
+ }
+ return false;
+}
+
bool LogEvent::writeKeyValuePairs(int32_t uid,
const std::map<int32_t, int32_t>& int_map,
const std::map<int32_t, int64_t>& long_map,