Bug-fix: Log data supports array value
As-is: When log data contains array, it saves only last element of the
array.
for (const auto& v: in_uids) _log_input_args["in_uids"] = Json::Value(v);
To-be: It saves every element of the array
_log_input_args["in_uids"] = Json::Value(Json::arrayValue);
for (const auto& v: in_uids) _log_input_args["in_uids"].append(Json::Value(v));
Bug: 127187108
Test: m -j
Change-Id: Ibee1767daa1cd6fe04efa41a3745363da0752590
diff --git a/aidl_to_cpp.cpp b/aidl_to_cpp.cpp
index efd5b6b..9dba75a 100644
--- a/aidl_to_cpp.cpp
+++ b/aidl_to_cpp.cpp
@@ -128,10 +128,11 @@
const string var_object_expr = ((c.isPointer ? "*" : "")) + c.name;
if (c.type.IsArray()) {
+ c.writer << c.log << "[\"" << c.name << "\"] = Json::Value(Json::arrayValue);\n";
c.writer << "for (const auto& v: " << var_object_expr << ") " << c.log << "[\"" << c.name
- << "\"] = ";
+ << "\"].append(";
info.toJsonValueExpr(c, "v");
- c.writer << ";";
+ c.writer << ");";
} else {
c.writer << c.log << "[\"" << c.name << "\"] = ";
info.toJsonValueExpr(c, var_object_expr);