Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a96d8d0b authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add byte size of the bytes fields to statslog c++ APIs."

parents 7597ca88 1fe9f594
Loading
Loading
Loading
Loading
+39 −8
Original line number Diff line number Diff line
@@ -264,6 +264,10 @@ static int write_stats_log_cpp(FILE *out, const Atoms &atoms,
                                 chainField.name.c_str(), chainField.name.c_str());
                    }
                }
            } else if (*arg == JAVA_TYPE_BYTE_ARRAY) {
                fprintf(out, ", %s arg%d, size_t arg%d_length",
                        cpp_type_name(*arg), argIndex, argIndex);

            } else if (*arg == JAVA_TYPE_KEY_VALUE_PAIR) {
                fprintf(out, ", const std::map<int, int32_t>& arg%d_1, "
                             "const std::map<int, int64_t>& arg%d_2, "
@@ -343,6 +347,10 @@ static int write_stats_log_cpp(FILE *out, const Atoms &atoms,
                    fprintf(out, "    }\n");

                    fprintf(out, "    event.end();\n\n");
            } else if (*arg == JAVA_TYPE_BYTE_ARRAY) {
                fprintf(out,
                        "    event.AppendCharArray(arg%d, arg%d_length);\n",
                        argIndex, argIndex);
            } else {
                if (*arg == JAVA_TYPE_STRING) {
                    fprintf(out, "    if (arg%d == NULL) {\n", argIndex);
@@ -383,8 +391,13 @@ static int write_stats_log_cpp(FILE *out, const Atoms &atoms,
                                chainField.name.c_str(), chainField.name.c_str());
                   }
               }
           } else if (*arg == JAVA_TYPE_BYTE_ARRAY) {
               fprintf(out, ", %s arg%d, size_t arg%d_length",
                       cpp_type_name(*arg), argIndex, argIndex);

           } else if (*arg == JAVA_TYPE_KEY_VALUE_PAIR) {
                fprintf(out, ", const std::map<int, int32_t>& arg%d_1, "
               fprintf(out,
                       ", const std::map<int, int32_t>& arg%d_1, "
                       "const std::map<int, int64_t>& arg%d_2, "
                       "const std::map<int, char const*>& arg%d_3, "
                       "const std::map<int, float>& arg%d_4",
@@ -415,9 +428,11 @@ static int write_stats_log_cpp(FILE *out, const Atoms &atoms,
                                chainField.name.c_str(), chainField.name.c_str());
                   }
               }
           } else if (*arg == JAVA_TYPE_BYTE_ARRAY) {
               fprintf(out, ", arg%d, arg%d_length", argIndex, argIndex);
           } else if (*arg == JAVA_TYPE_KEY_VALUE_PAIR) {
                fprintf(out, ", arg%d_1, arg%d_2, arg%d_3, arg%d_4",
                        argIndex, argIndex, argIndex, argIndex);
               fprintf(out, ", arg%d_1, arg%d_2, arg%d_3, arg%d_4", argIndex,
                       argIndex, argIndex, argIndex);
           } else {
               fprintf(out, ", arg%d", argIndex);
           }
@@ -580,6 +595,11 @@ static void write_cpp_usage(
                         field->name.c_str(),
                         field->name.c_str(),
                         field->name.c_str());
        } else if (field->javaType == JAVA_TYPE_BYTE_ARRAY) {
            fprintf(out, ", %s %s, size_t %s_length",
                    cpp_type_name(field->javaType), field->name.c_str(),
                    field->name.c_str());

        } else {
            fprintf(out, ", %s %s", cpp_type_name(field->javaType), field->name.c_str());
        }
@@ -613,6 +633,9 @@ static void write_cpp_method_header(
                             "const std::map<int, char const*>& arg%d_3, "
                             "const std::map<int, float>& arg%d_4",
                             argIndex, argIndex, argIndex, argIndex);
            } else if (*arg == JAVA_TYPE_BYTE_ARRAY) {
                fprintf(out, ", %s arg%d, size_t arg%d_length",
                        cpp_type_name(*arg), argIndex, argIndex);
            } else {
                fprintf(out, ", %s arg%d", cpp_type_name(*arg), argIndex);
            }
@@ -1128,6 +1151,7 @@ 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, "    int str%d_length = 0;\n", argIndex);
                fprintf(out,
                        "    if (arg%d != NULL && env->GetArrayLength(arg%d) > "
                        "0) {\n",
@@ -1136,6 +1160,9 @@ write_stats_log_jni(FILE* out, const string& java_method_name, const string& cpp
                        "        jbyte_array%d = "
                        "env->GetByteArrayElements(arg%d, NULL);\n",
                        argIndex, argIndex);
                fprintf(out,
                        "        str%d_length = env->GetArrayLength(arg%d);\n",
                        argIndex, argIndex);
                fprintf(out,
                        "        str%d = "
                        "reinterpret_cast<char*>(env->GetByteArrayElements(arg%"
@@ -1224,6 +1251,10 @@ write_stats_log_jni(FILE* out, const string& java_method_name, const string& cpp
                                              ? "str"
                                              : "arg";
                fprintf(out, ", (%s)%s%d", cpp_type_name(*arg), argName, argIndex);

                if (*arg == JAVA_TYPE_BYTE_ARRAY) {
                    fprintf(out, ", %s%d_length", argName, argIndex);
                }
            }
            argIndex++;
        }