diff options
author | Muhammad Qureshi <muhammadq@google.com> | 2020-03-05 16:35:26 -0800 |
---|---|---|
committer | Muhammad Qureshi <muhammadq@google.com> | 2020-03-05 17:20:58 -0800 |
commit | 9e0f728fe4215d8e09d5ee495b69cbbff9ae70fc (patch) | |
tree | bd71b5375d3550b4cb9ff1db39f1336f4f8e7f2b /tools | |
parent | f8460f70d072a3ae839002e5b2698ba535da7f76 (diff) |
Remove libstatslog from libstatsmetadata
Instead of relying on the constants in libstatslog, hardcode them in
atoms_info to get rid of the dependency on libstatslog
New generated atoms_info.cpp:
https://paste.googleplex.com/5779947622760448
Bug: 150417465
Test: m libstatsmetadata
Change-Id: I954c963f1883f889053b63d308c648548de71e56
Diffstat (limited to 'tools')
-rw-r--r-- | tools/stats_log_api_gen/atoms_info_writer.cpp | 49 | ||||
-rw-r--r-- | tools/stats_log_api_gen/atoms_info_writer.h | 2 | ||||
-rw-r--r-- | tools/stats_log_api_gen/main.cpp | 2 |
3 files changed, 29 insertions, 24 deletions
diff --git a/tools/stats_log_api_gen/atoms_info_writer.cpp b/tools/stats_log_api_gen/atoms_info_writer.cpp index 984c929f63bd..58f13a4c1934 100644 --- a/tools/stats_log_api_gen/atoms_info_writer.cpp +++ b/tools/stats_log_api_gen/atoms_info_writer.cpp @@ -58,19 +58,25 @@ static void write_atoms_info_header_body(FILE* out, const Atoms& atoms) { } static void write_atoms_info_cpp_body(FILE* out, const Atoms& atoms) { - std::set<string> kTruncatingAtomNames = {"mobile_radio_power_state_changed", - "audio_state_changed", - "call_state_changed", - "phone_signal_strength_changed", - "mobile_bytes_transfer_by_fg_bg", - "mobile_bytes_transfer"}; + std::set<string> kTruncatingAtomNames = { + "mobile_radio_power_state_changed", + "audio_state_changed", + "call_state_changed", + "phone_signal_strength_changed", + "mobile_bytes_transfer_by_fg_bg", + "mobile_bytes_transfer" + }; fprintf(out, "const std::set<int> " "AtomsInfo::kTruncatingTimestampAtomBlackList = {\n"); - for (set<string>::const_iterator blacklistedAtom = kTruncatingAtomNames.begin(); - blacklistedAtom != kTruncatingAtomNames.end(); blacklistedAtom++) { - fprintf(out, " %s,\n", make_constant_name(*blacklistedAtom).c_str()); + for (set<AtomDecl>::const_iterator atom = atoms.decls.begin(); + atom != atoms.decls.end(); atom++) { + if (kTruncatingAtomNames.find(atom->name) != kTruncatingAtomNames.end()) { + const string constant = make_constant_name(atom->name); + fprintf(out, " %d, // %s\n", atom->code, constant.c_str()); + } } + fprintf(out, "};\n"); fprintf(out, "\n"); @@ -81,8 +87,8 @@ static void write_atoms_info_cpp_body(FILE* out, const Atoms& atoms) { for (vector<AtomField>::const_iterator field = atom->fields.begin(); field != atom->fields.end(); field++) { if (field->javaType == JAVA_TYPE_ATTRIBUTION_CHAIN) { - string constant = make_constant_name(atom->name); - fprintf(out, " %s,\n", constant.c_str()); + const string constant = make_constant_name(atom->name); + fprintf(out, " %d, // %s\n", atom->code, constant.c_str()); break; } } @@ -96,8 +102,8 @@ static void write_atoms_info_cpp_body(FILE* out, const Atoms& atoms) { for (set<AtomDecl>::const_iterator atom = atoms.decls.begin(); atom != atoms.decls.end(); atom++) { if (atom->whitelisted) { - string constant = make_constant_name(atom->name); - fprintf(out, " %s,\n", constant.c_str()); + const string constant = make_constant_name(atom->name); + fprintf(out, " %d, // %s\n", atom->code, constant.c_str()); } } @@ -105,7 +111,7 @@ static void write_atoms_info_cpp_body(FILE* out, const Atoms& atoms) { fprintf(out, "\n"); fprintf(out, "static std::map<int, int> getAtomUidField() {\n"); - fprintf(out, " std::map<int, int> uidField;\n"); + fprintf(out, " std::map<int, int> uidField;\n"); for (set<AtomDecl>::const_iterator atom = atoms.decls.begin(); atom != atoms.decls.end(); atom++) { if (atom->uidField == 0) { @@ -115,8 +121,8 @@ static void write_atoms_info_cpp_body(FILE* out, const Atoms& atoms) { "\n // Adding uid field for atom " "(%d)%s\n", atom->code, atom->name.c_str()); - fprintf(out, " uidField[static_cast<int>(%s)] = %d;\n", - make_constant_name(atom->name).c_str(), atom->uidField); + fprintf(out, " uidField[%d /* %s */] = %d;\n", + atom->code, make_constant_name(atom->name).c_str(), atom->uidField); } fprintf(out, " return uidField;\n"); @@ -140,8 +146,8 @@ static void write_atoms_info_cpp_body(FILE* out, const Atoms& atoms) { "\n // Adding primary and exclusive fields for atom " "(%d)%s\n", atom->code, atom->name.c_str()); - fprintf(out, " opt = &(options[static_cast<int>(%s)]);\n", - make_constant_name(atom->name).c_str()); + fprintf(out, " opt = &(options[%d /* %s */]);\n", + atom->code, make_constant_name(atom->name).c_str()); fprintf(out, " opt->primaryFields.reserve(%lu);\n", atom->primaryFields.size()); for (const auto& field : atom->primaryFields) { fprintf(out, " opt->primaryFields.push_back(%d);\n", field); @@ -185,8 +191,8 @@ static void write_atoms_info_cpp_body(FILE* out, const Atoms& atoms) { atom->code, atom->name.c_str()); for (const auto& field : atom->binaryFields) { - fprintf(out, " options[static_cast<int>(%s)].push_back(%d);\n", - make_constant_name(atom->name).c_str(), field); + fprintf(out, " options[%d /* %s */].push_back(%d);\n", + atom->code, make_constant_name(atom->name).c_str(), field); } } @@ -222,12 +228,11 @@ int write_atoms_info_header(FILE* out, const Atoms &atoms, const string& namespa } int write_atoms_info_cpp(FILE *out, const Atoms &atoms, const string& namespaceStr, - const string& importHeader, const string& statslogHeader) { + const string& importHeader) { // Print prelude fprintf(out, "// This file is autogenerated\n"); fprintf(out, "\n"); fprintf(out, "#include <%s>\n", importHeader.c_str()); - fprintf(out, "#include <%s>\n", statslogHeader.c_str()); fprintf(out, "\n"); write_namespace(out, namespaceStr); diff --git a/tools/stats_log_api_gen/atoms_info_writer.h b/tools/stats_log_api_gen/atoms_info_writer.h index 12ac862871ef..d04e65a1b060 100644 --- a/tools/stats_log_api_gen/atoms_info_writer.h +++ b/tools/stats_log_api_gen/atoms_info_writer.h @@ -27,7 +27,7 @@ namespace stats_log_api_gen { using namespace std; int write_atoms_info_cpp(FILE* out, const Atoms& atoms, const string& namespaceStr, - const string& importHeader, const string& statslogHeader); + const string& importHeader); int write_atoms_info_header(FILE* out, const Atoms& atoms, const string& namespaceStr); diff --git a/tools/stats_log_api_gen/main.cpp b/tools/stats_log_api_gen/main.cpp index ddbf22c7f12a..8ea6fcba8fb2 100644 --- a/tools/stats_log_api_gen/main.cpp +++ b/tools/stats_log_api_gen/main.cpp @@ -682,7 +682,7 @@ run(int argc, char const*const* argv) return 1; } errorCount = android::stats_log_api_gen::write_atoms_info_cpp( - out, atoms, cppNamespace, atomsInfoCppHeaderImport, cppHeaderImport); + out, atoms, cppNamespace, atomsInfoCppHeaderImport); fclose(out); } |