summaryrefslogtreecommitdiff
path: root/tools/stats_log_api_gen/main.cpp
diff options
context:
space:
mode:
authorYao Chen <yaochen@google.com>2018-11-29 09:39:45 -0800
committerJack He <siyuanh@google.com>2018-12-15 13:52:27 -0800
commit2822b4f42f49650b194f6561454aeb48f4f3d9d1 (patch)
tree76a4e9cc9ad13c0acd8878c86a5ce4594cd4c003 /tools/stats_log_api_gen/main.cpp
parent046b51295ea28500333794fb93b6ce96ad71c6af (diff)
Skip writing message field in an atom if it's empty
Test: unit test added Bug: 120635548 Change-Id: I825b1ce526944a20fe65705508ad180ece37492c Merged-In: I825b1ce526944a20fe65705508ad180ece37492c (cherry picked from commit 8e6f9983009eadf32d05ad65e38906d3985bc9ba)
Diffstat (limited to 'tools/stats_log_api_gen/main.cpp')
-rw-r--r--tools/stats_log_api_gen/main.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/stats_log_api_gen/main.cpp b/tools/stats_log_api_gen/main.cpp
index 597b0556ee63..f7e0039dcb4d 100644
--- a/tools/stats_log_api_gen/main.cpp
+++ b/tools/stats_log_api_gen/main.cpp
@@ -1007,7 +1007,10 @@ write_stats_log_jni(FILE* out, const string& java_method_name, const string& cpp
hadStringOrChain = true;
fprintf(out, " jbyte* jbyte_array%d;\n", argIndex);
fprintf(out, " const char* str%d;\n", argIndex);
- fprintf(out, " if (arg%d != NULL) {\n", argIndex);
+ fprintf(out,
+ " if (arg%d != NULL && env->GetArrayLength(arg%d) > "
+ "0) {\n",
+ argIndex, argIndex);
fprintf(out,
" jbyte_array%d = "
"env->GetByteArrayElements(arg%d, NULL);\n",