Merge "Surface the log write errors to StatsLog.write" into pi-dev am: 03cd687912
am: e079e5784f
Change-Id: Ia329c68a8b737a62ce78ebcbd2082bd022d9d5fe
diff --git a/tools/stats_log_api_gen/main.cpp b/tools/stats_log_api_gen/main.cpp
index 300c701..499f254 100644
--- a/tools/stats_log_api_gen/main.cpp
+++ b/tools/stats_log_api_gen/main.cpp
@@ -211,7 +211,7 @@
signature != atoms.signatures.end(); signature++) {
int argIndex;
- fprintf(out, "void\n");
+ fprintf(out, "int\n");
fprintf(out, "stats_write(int32_t code");
argIndex = 1;
for (vector<java_type_t>::const_iterator arg = signature->begin();
@@ -251,7 +251,7 @@
" diff length: %s vs %s\");\n",
attributionDecl.fields.front().name.c_str(),
chainField.name.c_str());
- fprintf(out, " return;\n");
+ fprintf(out, " return -EINVAL;\n");
fprintf(out, " }\n");
}
}
@@ -284,7 +284,7 @@
argIndex++;
}
- fprintf(out, " event.write(LOG_ID_STATS);\n");
+ fprintf(out, " return event.write(LOG_ID_STATS);\n");
fprintf(out, "}\n");
fprintf(out, "\n");
}
@@ -293,7 +293,7 @@
signature != atoms.non_chained_signatures.end(); signature++) {
int argIndex;
- fprintf(out, "void\n");
+ fprintf(out, "int\n");
fprintf(out, "stats_write_non_chained(int32_t code");
argIndex = 1;
for (vector<java_type_t>::const_iterator arg = signature->begin();
@@ -327,7 +327,7 @@
argIndex++;
}
- fprintf(out, " event.write(LOG_ID_STATS);\n");
+ fprintf(out, " return event.write(LOG_ID_STATS);\n");
fprintf(out, "}\n");
fprintf(out, "\n");
}
@@ -377,7 +377,7 @@
const AtomDecl &attributionDecl) {
for (set<vector<java_type_t>>::const_iterator signature = signatures.begin();
signature != signatures.end(); signature++) {
- fprintf(out, "void %s(int32_t code ", method_name.c_str());
+ fprintf(out, "int %s(int32_t code ", method_name.c_str());
int argIndex = 1;
for (vector<java_type_t>::const_iterator arg = signature->begin();
arg != signature->end(); arg++) {
@@ -522,7 +522,7 @@
const AtomDecl &attributionDecl) {
for (set<vector<java_type_t>>::const_iterator signature = signatures.begin();
signature != signatures.end(); signature++) {
- fprintf(out, " public static native void %s(int code", method_name.c_str());
+ fprintf(out, " public static native int %s(int code", method_name.c_str());
int argIndex = 1;
for (vector<java_type_t>::const_iterator arg = signature->begin();
arg != signature->end(); arg++) {
@@ -719,7 +719,7 @@
result += java_type_signature(*arg);
}
}
- result += ")V";
+ result += ")I";
return result;
}
@@ -732,7 +732,7 @@
signature != signatures.end(); signature++) {
int argIndex;
- fprintf(out, "static void\n");
+ fprintf(out, "static int\n");
fprintf(out, "%s(JNIEnv* env, jobject clazz UNUSED, jint code",
jni_function_name(java_method_name, *signature).c_str());
argIndex = 1;
@@ -779,7 +779,7 @@
"\"java/lang/IllegalArgumentException\", "
"\"invalid attribution field(%s) length.\");\n",
chainField.name.c_str());
- fprintf(out, " return;\n");
+ fprintf(out, " return -EINVAL;\n");
fprintf(out, " }\n");
}
if (chainField.javaType == JAVA_TYPE_INT) {
@@ -822,7 +822,7 @@
// stats_write call
argIndex = 1;
- fprintf(out, " android::util::%s(code", cpp_method_name.c_str());
+ fprintf(out, " int ret = android::util::%s(code", cpp_method_name.c_str());
for (vector<java_type_t>::const_iterator arg = signature->begin();
arg != signature->end(); arg++) {
if (*arg == JAVA_TYPE_ATTRIBUTION_CHAIN) {
@@ -868,6 +868,7 @@
}
argIndex++;
}
+ fprintf(out, " return ret;\n");
fprintf(out, "}\n");
fprintf(out, "\n");