use custom Parcel format to pull data
When statsd pulls data from StatsCompanionService, the data is put into
log_msg format on java side and expanded into LogEvent on cpp side.
There is a lot of dependency on log_msg and liblog to add new types.
There is pending bug to rewrite thta part of the code in statsd to
completely rid the legacy of logd and liblog. But that may not happen
soon.
Now we can support new storage type.
Also no need to specify number of fields in StatsLogEventWrapper cstr,
which is a source of bug in P.
Bug: 115775035
Test: manual test and cts test
Change-Id: Id1f0b033885da6f3bcebe043968061821db48f35
diff --git a/cmds/statsd/src/FieldValue.cpp b/cmds/statsd/src/FieldValue.cpp
index 7b6d29b..fc1a61c 100644
--- a/cmds/statsd/src/FieldValue.cpp
+++ b/cmds/statsd/src/FieldValue.cpp
@@ -147,6 +147,9 @@
case STRING:
str_value = from.str_value;
break;
+ case STORAGE:
+ storage_value = from.storage_value;
+ break;
default:
break;
}
@@ -164,6 +167,8 @@
return std::to_string(double_value) + "[D]";
case STRING:
return str_value + "[S]";
+ case STORAGE:
+ return "bytes of size " + std::to_string(storage_value.size()) + "[ST]";
default:
return "[UNKNOWN]";
}
@@ -183,6 +188,8 @@
return double_value == that.double_value;
case STRING:
return str_value == that.str_value;
+ case STORAGE:
+ return storage_value == that.storage_value;
default:
return false;
}
@@ -201,6 +208,8 @@
return double_value != that.double_value;
case STRING:
return str_value != that.str_value;
+ case STORAGE:
+ return storage_value != that.storage_value;
default:
return false;
}
@@ -220,6 +229,8 @@
return double_value < that.double_value;
case STRING:
return str_value < that.str_value;
+ case STORAGE:
+ return storage_value < that.storage_value;
default:
return false;
}
@@ -239,6 +250,8 @@
return double_value > that.double_value;
case STRING:
return str_value > that.str_value;
+ case STORAGE:
+ return storage_value > that.storage_value;
default:
return false;
}
@@ -258,6 +271,8 @@
return double_value >= that.double_value;
case STRING:
return str_value >= that.str_value;
+ case STORAGE:
+ return storage_value >= that.storage_value;
default:
return false;
}
@@ -274,6 +289,11 @@
return v;
}
+ if (type == STORAGE) {
+ ALOGE("Can't operate on storage value type");
+ return v;
+ }
+
switch (type) {
case INT:
v.setInt(int_value - that.int_value);
@@ -311,6 +331,9 @@
case STRING:
str_value = that.str_value;
break;
+ case STORAGE:
+ storage_value = that.storage_value;
+ break;
default:
break;
}
@@ -326,6 +349,10 @@
ALOGE("Can't operate on string value type");
return *this;
}
+ if (type == STORAGE) {
+ ALOGE("Can't operate on storage value type");
+ return *this;
+ }
switch (type) {
case INT: