Loading cmds/statsd/src/StatsLogProcessor.cpp +14 −4 Original line number Diff line number Diff line Loading @@ -92,10 +92,20 @@ void StatsLogProcessor::onAnomalyAlarmFired( void StatsLogProcessor::mapIsolatedUidToHostUidIfNecessaryLocked(LogEvent* event) const { std::vector<Field> uidFields; if (android::util::kAtomsWithAttributionChain.find(event->GetTagId()) != android::util::kAtomsWithAttributionChain.end()) { findFields( event->getFieldValueMap(), buildAttributionUidFieldMatcher(event->GetTagId(), Position::ANY), &uidFields); } else if (android::util::kAtomsWithUidField.find(event->GetTagId()) != android::util::kAtomsWithUidField.end()) { findFields( event->getFieldValueMap(), buildSimpleAtomFieldMatcher(event->GetTagId(), 1 /* uid is always the 1st field. */), &uidFields); } for (size_t i = 0; i < uidFields.size(); ++i) { DimensionsValue* value = event->findFieldValueOrNull(uidFields[i]); if (value != nullptr && value->value_case() == DimensionsValue::ValueCase::kValueInt) { Loading cmds/statsd/src/logd/LogEvent.h +3 −3 Original line number Diff line number Diff line Loading @@ -58,14 +58,14 @@ public: /** * Get the timestamp associated with this event. */ uint64_t GetTimestampNs() const { return mTimestampNs; } inline uint64_t GetTimestampNs() const { return mTimestampNs; } /** * Get the tag for this event. */ int GetTagId() const { return mTagId; } inline int GetTagId() const { return mTagId; } uint32_t GetUid() const { inline uint32_t GetUid() const { return mLogUid; } Loading tools/stats_log_api_gen/main.cpp +31 −0 Original line number Diff line number Diff line Loading @@ -317,6 +317,7 @@ write_stats_log_header(FILE* out, const Atoms& atoms, const AtomDecl &attributio fprintf(out, "\n"); fprintf(out, "#include <stdint.h>\n"); fprintf(out, "#include <vector>\n"); fprintf(out, "#include <set>\n"); fprintf(out, "\n"); fprintf(out, "namespace android {\n"); Loading Loading @@ -361,6 +362,36 @@ write_stats_log_header(FILE* out, const Atoms& atoms, const AtomDecl &attributio fprintf(out, "};\n"); fprintf(out, "\n"); fprintf(out, "const static std::set<int> kAtomsWithUidField = {\n"); for (set<AtomDecl>::const_iterator atom = atoms.decls.begin(); atom != atoms.decls.end(); atom++) { for (vector<AtomField>::const_iterator field = atom->fields.begin(); field != atom->fields.end(); field++) { if (field->name == "uid") { string constant = make_constant_name(atom->name); fprintf(out, " %s,\n", constant.c_str()); break; } } } fprintf(out, "};\n"); fprintf(out, "\n"); fprintf(out, "const static std::set<int> kAtomsWithAttributionChain = {\n"); for (set<AtomDecl>::const_iterator atom = atoms.decls.begin(); atom != atoms.decls.end(); atom++) { 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()); break; } } } fprintf(out, "};\n"); fprintf(out, "\n"); fprintf(out, "const static int kMaxPushedAtomId = %d;\n\n", maxPushedAtomId); // Print write methods Loading Loading
cmds/statsd/src/StatsLogProcessor.cpp +14 −4 Original line number Diff line number Diff line Loading @@ -92,10 +92,20 @@ void StatsLogProcessor::onAnomalyAlarmFired( void StatsLogProcessor::mapIsolatedUidToHostUidIfNecessaryLocked(LogEvent* event) const { std::vector<Field> uidFields; if (android::util::kAtomsWithAttributionChain.find(event->GetTagId()) != android::util::kAtomsWithAttributionChain.end()) { findFields( event->getFieldValueMap(), buildAttributionUidFieldMatcher(event->GetTagId(), Position::ANY), &uidFields); } else if (android::util::kAtomsWithUidField.find(event->GetTagId()) != android::util::kAtomsWithUidField.end()) { findFields( event->getFieldValueMap(), buildSimpleAtomFieldMatcher(event->GetTagId(), 1 /* uid is always the 1st field. */), &uidFields); } for (size_t i = 0; i < uidFields.size(); ++i) { DimensionsValue* value = event->findFieldValueOrNull(uidFields[i]); if (value != nullptr && value->value_case() == DimensionsValue::ValueCase::kValueInt) { Loading
cmds/statsd/src/logd/LogEvent.h +3 −3 Original line number Diff line number Diff line Loading @@ -58,14 +58,14 @@ public: /** * Get the timestamp associated with this event. */ uint64_t GetTimestampNs() const { return mTimestampNs; } inline uint64_t GetTimestampNs() const { return mTimestampNs; } /** * Get the tag for this event. */ int GetTagId() const { return mTagId; } inline int GetTagId() const { return mTagId; } uint32_t GetUid() const { inline uint32_t GetUid() const { return mLogUid; } Loading
tools/stats_log_api_gen/main.cpp +31 −0 Original line number Diff line number Diff line Loading @@ -317,6 +317,7 @@ write_stats_log_header(FILE* out, const Atoms& atoms, const AtomDecl &attributio fprintf(out, "\n"); fprintf(out, "#include <stdint.h>\n"); fprintf(out, "#include <vector>\n"); fprintf(out, "#include <set>\n"); fprintf(out, "\n"); fprintf(out, "namespace android {\n"); Loading Loading @@ -361,6 +362,36 @@ write_stats_log_header(FILE* out, const Atoms& atoms, const AtomDecl &attributio fprintf(out, "};\n"); fprintf(out, "\n"); fprintf(out, "const static std::set<int> kAtomsWithUidField = {\n"); for (set<AtomDecl>::const_iterator atom = atoms.decls.begin(); atom != atoms.decls.end(); atom++) { for (vector<AtomField>::const_iterator field = atom->fields.begin(); field != atom->fields.end(); field++) { if (field->name == "uid") { string constant = make_constant_name(atom->name); fprintf(out, " %s,\n", constant.c_str()); break; } } } fprintf(out, "};\n"); fprintf(out, "\n"); fprintf(out, "const static std::set<int> kAtomsWithAttributionChain = {\n"); for (set<AtomDecl>::const_iterator atom = atoms.decls.begin(); atom != atoms.decls.end(); atom++) { 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()); break; } } } fprintf(out, "};\n"); fprintf(out, "\n"); fprintf(out, "const static int kMaxPushedAtomId = %d;\n\n", maxPushedAtomId); // Print write methods Loading